sbv-13.6: SMT Based Verification: Symbolic Haskell theorem prover using SMT solving.
Copyright(c) Levent Erkok
LicenseBSD3
Maintainererkokl@gmail.com
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Documentation.SBV.Examples.TP.UpDown

Description

Proves reverse (down n) = up n.

This problem is motivated by an ACL2 midterm exam question, from Fall 2011. See: https://www.cs.utexas.edu/~moore/classes/cs389r/midterm-answers.lisp.

Synopsis

Documentation

up :: SNat -> SList Integer Source #

Construct a list of size n, containing numbers 1 to n.

>>> up 0
[] :: [SInteger]
>>> up 5
[1,2,3,4,5] :: [SInteger]

upAcc :: SNat -> SList Integer -> SList Integer Source #

Keep consing the first argument on to the accumulator, until we hit zero. After that, return the second argument. Normally, we'd define this as a local function, but the definition needs to be visible for the proofs.

down :: SNat -> SList Integer Source #

Construct a list of size n, containing numbers n-1 down to 0.

>>> down 0
[] :: [SInteger]
>>> down 5
[5,4,3,2,1] :: [SInteger]

upDown :: TP (Proof (Forall "n" Nat -> SBool)) Source #

Prove that reverse (down n) is the same as up n

>>> runTP upDown
Lemma: n2iNonNeg                        Q.E.D.
Lemma: revCons                          Q.E.D.
Inductive lemma (strong): upDownGen
  Step: Measure is non-negative         Q.E.D.
  Step: 1 (2 way case split)
    Step: 1.1                           Q.E.D.
    Step: 1.2.1                         Q.E.D.
    Step: 1.2.2                         Q.E.D.
    Step: 1.2.3                         Q.E.D.
    Step: 1.2.4                         Q.E.D.
    Step: 1.Completeness                Q.E.D.
  Result:                               Q.E.D.
Lemma: upDown                           Q.E.D.
[Proven] upDown :: Ɐn ∷ Nat → Bool