{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeAbstractions #-}
{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -Wall -Werror #-}
module Documentation.SBV.Examples.TP.Numeric where
import Prelude hiding (sum, map, product, length, (^), replicate, elem)
import Data.SBV
import Data.SBV.TP
import Data.SBV.List
#ifdef DOCTEST
#endif
sumConstProof :: SInteger -> TP (Proof (Forall "n" Integer -> SBool))
sumConstProof :: SInteger -> TP (Proof (Forall "n" Integer -> SBool))
sumConstProof SInteger
c = String
-> (Forall "n" Integer -> SBool)
-> (Proof (IHType (Forall "n" Integer -> SBool))
-> IHArg (Forall "n" Integer -> SBool)
-> IStepArgs (Forall "n" Integer -> SBool) Integer)
-> TP (Proof (Forall "n" Integer -> SBool))
forall t.
(Proposition (Forall "n" Integer -> SBool), SymVal t,
EqSymbolic (SBV t)) =>
String
-> (Forall "n" Integer -> SBool)
-> (Proof (IHType (Forall "n" Integer -> SBool))
-> IHArg (Forall "n" Integer -> SBool)
-> IStepArgs (Forall "n" Integer -> SBool) t)
-> TP (Proof (Forall "n" Integer -> SBool))
forall a t.
(Inductive a, Proposition a, SymVal t, EqSymbolic (SBV t)) =>
String
-> a
-> (Proof (IHType a) -> IHArg a -> IStepArgs a t)
-> TP (Proof a)
induct String
"sumConst_correct"
(\(Forall SInteger
n) -> SInteger
n SInteger -> SInteger -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.>= SInteger
0 SBool -> SBool -> SBool
.=> SList Integer -> SInteger
forall a. (SymVal a, Num (SBV a)) => SList a -> SBV a
sum (SInteger -> SInteger -> SList Integer
forall a. SymVal a => SInteger -> SBV a -> SList a
replicate SInteger
n SInteger
c) SInteger -> SInteger -> SBool
forall a. EqSymbolic a => a -> a -> SBool
.== SInteger
c SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
* SInteger
n) ((Proof (IHType (Forall "n" Integer -> SBool))
-> IHArg (Forall "n" Integer -> SBool)
-> IStepArgs (Forall "n" Integer -> SBool) Integer)
-> TP (Proof (Forall "n" Integer -> SBool)))
-> (Proof (IHType (Forall "n" Integer -> SBool))
-> IHArg (Forall "n" Integer -> SBool)
-> IStepArgs (Forall "n" Integer -> SBool) Integer)
-> TP (Proof (Forall "n" Integer -> SBool))
forall a b. (a -> b) -> a -> b
$
\Proof (IHType (Forall "n" Integer -> SBool))
ih IHArg (Forall "n" Integer -> SBool)
n -> [SInteger
IHArg (Forall "n" Integer -> SBool)
n SInteger -> SInteger -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.>= SInteger
0] [SBool] -> TPProofRaw SInteger -> (SBool, TPProofRaw SInteger)
forall a. [SBool] -> TPProofRaw a -> (SBool, TPProofRaw a)
|- SList Integer -> SInteger
forall a. (SymVal a, Num (SBV a)) => SList a -> SBV a
sum (SInteger -> SInteger -> SList Integer
forall a. SymVal a => SInteger -> SBV a -> SList a
replicate (SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1) SInteger
c)
SInteger -> ChainsTo SInteger -> ChainsTo SInteger
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SList Integer -> SInteger
forall a. (SymVal a, Num (SBV a)) => SList a -> SBV a
sum (SInteger
c SInteger -> SList Integer -> SList Integer
forall a. SymVal a => SBV a -> SList a -> SList a
.: SInteger -> SInteger -> SList Integer
forall a. SymVal a => SInteger -> SBV a -> SList a
replicate SInteger
IHArg (Forall "n" Integer -> SBool)
n SInteger
c)
SInteger -> ChainsTo SInteger -> ChainsTo SInteger
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SInteger
c SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+ SList Integer -> SInteger
forall a. (SymVal a, Num (SBV a)) => SList a -> SBV a
sum (SInteger -> SInteger -> SList Integer
forall a. SymVal a => SInteger -> SBV a -> SList a
replicate SInteger
IHArg (Forall "n" Integer -> SBool)
n SInteger
c)
SInteger -> Proof SBool -> Hinted SInteger
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof SBool
Proof (IHType (Forall "n" Integer -> SBool))
ih
TPProofRaw SInteger
-> ChainsTo (TPProofRaw SInteger) -> ChainsTo (TPProofRaw SInteger)
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SInteger
c SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+ SInteger
cSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
*SInteger
IHArg (Forall "n" Integer -> SBool)
n
SInteger -> ChainsTo SInteger -> ChainsTo SInteger
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SInteger
cSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
*(SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1)
SInteger -> ChainsTo SInteger -> ChainsTo SInteger
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: ChainsTo SInteger
TPProofRaw SInteger
forall a. TPProofRaw a
qed
sumProof :: TP (Proof (Forall "n" Integer -> SBool))
sumProof :: TP (Proof (Forall "n" Integer -> SBool))
sumProof = String
-> (Forall "n" Integer -> SBool)
-> (Proof (IHType (Forall "n" Integer -> SBool))
-> IHArg (Forall "n" Integer -> SBool)
-> IStepArgs (Forall "n" Integer -> SBool) Integer)
-> TP (Proof (Forall "n" Integer -> SBool))
forall t.
(Proposition (Forall "n" Integer -> SBool), SymVal t,
EqSymbolic (SBV t)) =>
String
-> (Forall "n" Integer -> SBool)
-> (Proof (IHType (Forall "n" Integer -> SBool))
-> IHArg (Forall "n" Integer -> SBool)
-> IStepArgs (Forall "n" Integer -> SBool) t)
-> TP (Proof (Forall "n" Integer -> SBool))
forall a t.
(Inductive a, Proposition a, SymVal t, EqSymbolic (SBV t)) =>
String
-> a
-> (Proof (IHType a) -> IHArg a -> IStepArgs a t)
-> TP (Proof a)
induct String
"sum_correct"
(\(Forall SInteger
n) -> SInteger
n SInteger -> SInteger -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.>= SInteger
0 SBool -> SBool -> SBool
.=> SList Integer -> SInteger
forall a. (SymVal a, Num (SBV a)) => SList a -> SBV a
sum [sEnum|n, n-1 .. 0|] SInteger -> SInteger -> SBool
forall a. EqSymbolic a => a -> a -> SBool
.== (SInteger
n SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
* (SInteger
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1)) SInteger -> SInteger -> SInteger
`sEDiv` SInteger
2) ((Proof (IHType (Forall "n" Integer -> SBool))
-> IHArg (Forall "n" Integer -> SBool)
-> IStepArgs (Forall "n" Integer -> SBool) Integer)
-> TP (Proof (Forall "n" Integer -> SBool)))
-> (Proof (IHType (Forall "n" Integer -> SBool))
-> IHArg (Forall "n" Integer -> SBool)
-> IStepArgs (Forall "n" Integer -> SBool) Integer)
-> TP (Proof (Forall "n" Integer -> SBool))
forall a b. (a -> b) -> a -> b
$
\Proof (IHType (Forall "n" Integer -> SBool))
ih IHArg (Forall "n" Integer -> SBool)
n -> [SInteger
IHArg (Forall "n" Integer -> SBool)
n SInteger -> SInteger -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.>= SInteger
0] [SBool] -> TPProofRaw SInteger -> (SBool, TPProofRaw SInteger)
forall a. [SBool] -> TPProofRaw a -> (SBool, TPProofRaw a)
|- SList Integer -> SInteger
forall a. (SymVal a, Num (SBV a)) => SList a -> SBV a
sum [sEnum|n+1, n .. 0|]
SInteger -> ChainsTo SInteger -> ChainsTo SInteger
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1 SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+ SList Integer -> SInteger
forall a. (SymVal a, Num (SBV a)) => SList a -> SBV a
sum [sEnum|n, n-1 .. 0|]
SInteger -> Proof SBool -> Hinted SInteger
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof SBool
Proof (IHType (Forall "n" Integer -> SBool))
ih
TPProofRaw SInteger
-> ChainsTo (TPProofRaw SInteger) -> ChainsTo (TPProofRaw SInteger)
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1 SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+ (SInteger
IHArg (Forall "n" Integer -> SBool)
n SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
* (SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1)) SInteger -> SInteger -> SInteger
`sEDiv` SInteger
2
SInteger -> ChainsTo SInteger -> ChainsTo SInteger
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: ((SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1) SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
* (SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
2)) SInteger -> SInteger -> SInteger
`sEDiv` SInteger
2
SInteger -> ChainsTo SInteger -> ChainsTo SInteger
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: ChainsTo SInteger
TPProofRaw SInteger
forall a. TPProofRaw a
qed
sumSquareProof :: TP (Proof (Forall "n" Integer -> SBool))
sumSquareProof :: TP (Proof (Forall "n" Integer -> SBool))
sumSquareProof = do
let sq :: SInteger -> SInteger
sq :: SInteger -> SInteger
sq SInteger
k = SInteger
k SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
* SInteger
k
sumSquare :: SInteger -> SInteger
sumSquare SInteger
n = SList Integer -> SInteger
forall a. (SymVal a, Num (SBV a)) => SList a -> SBV a
sum (SList Integer -> SInteger) -> SList Integer -> SInteger
forall a b. (a -> b) -> a -> b
$ (SInteger -> SInteger) -> SList Integer -> SList Integer
forall func a b. SMap func a b => func -> SList a -> SList b
map SInteger -> SInteger
sq [sEnum|n, n-1 .. 0|]
String
-> (Forall "n" Integer -> SBool)
-> (Proof (IHType (Forall "n" Integer -> SBool))
-> IHArg (Forall "n" Integer -> SBool)
-> IStepArgs (Forall "n" Integer -> SBool) Integer)
-> TP (Proof (Forall "n" Integer -> SBool))
forall t.
(Proposition (Forall "n" Integer -> SBool), SymVal t,
EqSymbolic (SBV t)) =>
String
-> (Forall "n" Integer -> SBool)
-> (Proof (IHType (Forall "n" Integer -> SBool))
-> IHArg (Forall "n" Integer -> SBool)
-> IStepArgs (Forall "n" Integer -> SBool) t)
-> TP (Proof (Forall "n" Integer -> SBool))
forall a t.
(Inductive a, Proposition a, SymVal t, EqSymbolic (SBV t)) =>
String
-> a
-> (Proof (IHType a) -> IHArg a -> IStepArgs a t)
-> TP (Proof a)
induct String
"sumSquare_correct"
(\(Forall SInteger
n) -> SInteger
n SInteger -> SInteger -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.>= SInteger
0 SBool -> SBool -> SBool
.=> SInteger -> SInteger
sumSquare SInteger
n SInteger -> SInteger -> SBool
forall a. EqSymbolic a => a -> a -> SBool
.== (SInteger
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
*(SInteger
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1)SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
*(SInteger
2SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
*SInteger
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1)) SInteger -> SInteger -> SInteger
`sEDiv` SInteger
6) ((Proof (IHType (Forall "n" Integer -> SBool))
-> IHArg (Forall "n" Integer -> SBool)
-> IStepArgs (Forall "n" Integer -> SBool) Integer)
-> TP (Proof (Forall "n" Integer -> SBool)))
-> (Proof (IHType (Forall "n" Integer -> SBool))
-> IHArg (Forall "n" Integer -> SBool)
-> IStepArgs (Forall "n" Integer -> SBool) Integer)
-> TP (Proof (Forall "n" Integer -> SBool))
forall a b. (a -> b) -> a -> b
$
\Proof (IHType (Forall "n" Integer -> SBool))
ih IHArg (Forall "n" Integer -> SBool)
n -> [SInteger
IHArg (Forall "n" Integer -> SBool)
n SInteger -> SInteger -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.>= SInteger
0] [SBool] -> TPProofRaw SInteger -> (SBool, TPProofRaw SInteger)
forall a. [SBool] -> TPProofRaw a -> (SBool, TPProofRaw a)
|- SInteger -> SInteger
sumSquare (SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1)
SInteger -> ChainsTo SInteger -> ChainsTo SInteger
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SList Integer -> SInteger
forall a. (SymVal a, Num (SBV a)) => SList a -> SBV a
sum ((SInteger -> SInteger) -> SList Integer -> SList Integer
forall func a b. SMap func a b => func -> SList a -> SList b
map SInteger -> SInteger
sq [sEnum|n+1, n .. 0|])
SInteger -> ChainsTo SInteger -> ChainsTo SInteger
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SList Integer -> SInteger
forall a. (SymVal a, Num (SBV a)) => SList a -> SBV a
sum ((SInteger -> SInteger) -> SList Integer -> SList Integer
forall func a b. SMap func a b => func -> SList a -> SList b
map SInteger -> SInteger
sq (SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1 SInteger -> SList Integer -> SList Integer
forall a. SymVal a => SBV a -> SList a -> SList a
.: [sEnum|n, n-1 .. 0|]))
SInteger -> ChainsTo SInteger -> ChainsTo SInteger
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SList Integer -> SInteger
forall a. (SymVal a, Num (SBV a)) => SList a -> SBV a
sum ((SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1)SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
*(SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1) SInteger -> SList Integer -> SList Integer
forall a. SymVal a => SBV a -> SList a -> SList a
.: (SInteger -> SInteger) -> SList Integer -> SList Integer
forall func a b. SMap func a b => func -> SList a -> SList b
map SInteger -> SInteger
sq [sEnum|n, n-1 .. 0|])
SInteger -> ChainsTo SInteger -> ChainsTo SInteger
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: (SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1)SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
*(SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1) SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+ SList Integer -> SInteger
forall a. (SymVal a, Num (SBV a)) => SList a -> SBV a
sum ((SInteger -> SInteger) -> SList Integer -> SList Integer
forall func a b. SMap func a b => func -> SList a -> SList b
map SInteger -> SInteger
sq [sEnum|n, n-1 .. 0|])
SInteger -> Proof SBool -> Hinted SInteger
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof SBool
Proof (IHType (Forall "n" Integer -> SBool))
ih
TPProofRaw SInteger
-> ChainsTo (TPProofRaw SInteger) -> ChainsTo (TPProofRaw SInteger)
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: (SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1)SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
*(SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1) SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+ (SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
*(SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1)SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
*(SInteger
2SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
*SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1)) SInteger -> SInteger -> SInteger
`sEDiv` SInteger
6
SInteger -> ChainsTo SInteger -> ChainsTo SInteger
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: ((SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1)SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
*(SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
2)SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
*(SInteger
2SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
*SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
3)) SInteger -> SInteger -> SInteger
`sEDiv` SInteger
6
SInteger -> ChainsTo SInteger -> ChainsTo SInteger
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: ChainsTo SInteger
TPProofRaw SInteger
forall a. TPProofRaw a
qed
nicomachus :: TP (Proof (Forall "n" Integer -> SBool))
nicomachus :: TP (Proof (Forall "n" Integer -> SBool))
nicomachus = do
let (^) :: SInteger -> Integer -> SInteger
SInteger
_ ^ :: SInteger -> Integer -> SInteger
^ Integer
0 = SInteger
1
SInteger
b ^ Integer
n = SInteger
b SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
* SInteger
b SInteger -> Integer -> SInteger
^ (Integer
nInteger -> Integer -> Integer
forall a. Num a => a -> a -> a
-Integer
1)
infixr 8 ^
sumCubed :: SInteger -> SInteger
sumCubed :: SInteger -> SInteger
sumCubed = String -> (SInteger -> SInteger) -> SInteger -> SInteger
forall a.
(SMTDefinable a, Typeable a, Lambda Symbolic a) =>
String -> a -> a
smtFunction String
"sumCubed" ((SInteger -> SInteger) -> SInteger -> SInteger)
-> (SInteger -> SInteger) -> SInteger -> SInteger
forall a b. (a -> b) -> a -> b
$ \SInteger
n -> SBool -> SInteger -> SInteger -> SInteger
forall a. Mergeable a => SBool -> a -> a -> a
ite (SInteger
n SInteger -> SInteger -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.<= SInteger
0) SInteger
0 (SInteger
nSInteger -> Integer -> SInteger
^Integer
3 SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+ SInteger -> SInteger
sumCubed (SInteger
n SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
- SInteger
1))
Proof (Forall "n" Integer -> SBool)
sp <- TP (Proof (Forall "n" Integer -> SBool))
sumProof
Proof (Forall "n" Integer -> SBool)
ssp <- do
Proof (Forall "n" Integer -> SBool)
evenHalfSquared <- String
-> (Forall "n" Integer -> SBool)
-> [ProofObj]
-> TP (Proof (Forall "n" Integer -> SBool))
forall a.
Proposition a =>
String -> a -> [ProofObj] -> TP (Proof a)
lemma String
"evenHalfSquared"
(\(Forall SInteger
n) -> Integer
2 Integer -> SInteger -> SBool
`sDivides` SInteger
n SBool -> SBool -> SBool
.=> (SInteger
n SInteger -> SInteger -> SInteger
`sEDiv` SInteger
2) SInteger -> Integer -> SInteger
^ Integer
2 SInteger -> SInteger -> SBool
forall a. EqSymbolic a => a -> a -> SBool
.== (SInteger
n SInteger -> Integer -> SInteger
^ Integer
2) SInteger -> SInteger -> SInteger
`sEDiv` SInteger
4)
[]
Proof (Forall "n" Integer -> SBool)
nn1IsEven <- String
-> (Forall "n" Integer -> SBool)
-> (Proof (IHType (Forall "n" Integer -> SBool))
-> IHArg (Forall "n" Integer -> SBool)
-> IStepArgs (Forall "n" Integer -> SBool) Bool)
-> TP (Proof (Forall "n" Integer -> SBool))
forall t.
(Proposition (Forall "n" Integer -> SBool), SymVal t,
EqSymbolic (SBV t)) =>
String
-> (Forall "n" Integer -> SBool)
-> (Proof (IHType (Forall "n" Integer -> SBool))
-> IHArg (Forall "n" Integer -> SBool)
-> IStepArgs (Forall "n" Integer -> SBool) t)
-> TP (Proof (Forall "n" Integer -> SBool))
forall a t.
(Inductive a, Proposition a, SymVal t, EqSymbolic (SBV t)) =>
String
-> a
-> (Proof (IHType a) -> IHArg a -> IStepArgs a t)
-> TP (Proof a)
induct String
"nn1IsEven"
(\(Forall SInteger
n) -> SInteger
n SInteger -> SInteger -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.>= SInteger
0 SBool -> SBool -> SBool
.=> Integer
2 Integer -> SInteger -> SBool
`sDivides` (SInteger
n SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
* (SInteger
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1))) ((Proof (IHType (Forall "n" Integer -> SBool))
-> IHArg (Forall "n" Integer -> SBool)
-> IStepArgs (Forall "n" Integer -> SBool) Bool)
-> TP (Proof (Forall "n" Integer -> SBool)))
-> (Proof (IHType (Forall "n" Integer -> SBool))
-> IHArg (Forall "n" Integer -> SBool)
-> IStepArgs (Forall "n" Integer -> SBool) Bool)
-> TP (Proof (Forall "n" Integer -> SBool))
forall a b. (a -> b) -> a -> b
$
\Proof (IHType (Forall "n" Integer -> SBool))
ih IHArg (Forall "n" Integer -> SBool)
n -> [SInteger
IHArg (Forall "n" Integer -> SBool)
n SInteger -> SInteger -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.>= SInteger
0] [SBool] -> TPProofRaw SBool -> (SBool, TPProofRaw SBool)
forall a. [SBool] -> TPProofRaw a -> (SBool, TPProofRaw a)
|- Integer
2 Integer -> SInteger -> SBool
`sDivides` ((SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1) SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
* (SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
2))
SBool -> ChainsTo SBool -> ChainsTo SBool
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: Integer
2 Integer -> SInteger -> SBool
`sDivides` (SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
*(SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1) SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+ SInteger
2SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
*(SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1))
SBool -> ChainsTo SBool -> ChainsTo SBool
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: Integer
2 Integer -> SInteger -> SBool
`sDivides` (SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
*(SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1))
SBool -> Proof SBool -> Hinted SBool
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof SBool
Proof (IHType (Forall "n" Integer -> SBool))
ih
TPProofRaw SBool
-> ChainsTo (TPProofRaw SBool) -> ChainsTo (TPProofRaw SBool)
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SBool
sTrue
SBool -> ChainsTo SBool -> ChainsTo SBool
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: ChainsTo SBool
TPProofRaw SBool
forall a. TPProofRaw a
qed
String
-> (Forall "n" Integer -> SBool)
-> StepArgs (Forall "n" Integer -> SBool) Integer
-> TP (Proof (Forall "n" Integer -> SBool))
forall t.
(Proposition (Forall "n" Integer -> SBool), SymVal t,
EqSymbolic (SBV t)) =>
String
-> (Forall "n" Integer -> SBool)
-> StepArgs (Forall "n" Integer -> SBool) t
-> TP (Proof (Forall "n" Integer -> SBool))
forall a t.
(Calc a, Proposition a, SymVal t, EqSymbolic (SBV t)) =>
String -> a -> StepArgs a t -> TP (Proof a)
calc String
"sum_squared"
(\(Forall @"n" SInteger
n) -> SInteger
n SInteger -> SInteger -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.>= SInteger
0 SBool -> SBool -> SBool
.=> SList Integer -> SInteger
forall a. (SymVal a, Num (SBV a)) => SList a -> SBV a
sum [sEnum|n, n-1 .. 0|] SInteger -> Integer -> SInteger
^ Integer
2 SInteger -> SInteger -> SBool
forall a. EqSymbolic a => a -> a -> SBool
.== (SInteger
nSInteger -> Integer -> SInteger
^Integer
2 SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
* (SInteger
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1)SInteger -> Integer -> SInteger
^Integer
2) SInteger -> SInteger -> SInteger
`sEDiv` SInteger
4) (StepArgs (Forall "n" Integer -> SBool) Integer
-> TP (Proof (Forall "n" Integer -> SBool)))
-> StepArgs (Forall "n" Integer -> SBool) Integer
-> TP (Proof (Forall "n" Integer -> SBool))
forall a b. (a -> b) -> a -> b
$
\SInteger
n -> [SInteger
n SInteger -> SInteger -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.>= SInteger
0] [SBool] -> TPProofRaw SInteger -> (SBool, TPProofRaw SInteger)
forall a. [SBool] -> TPProofRaw a -> (SBool, TPProofRaw a)
|- SList Integer -> SInteger
forall a. (SymVal a, Num (SBV a)) => SList a -> SBV a
sum [sEnum|n, n-1 .. 0|] SInteger -> Integer -> SInteger
^ Integer
2
SInteger -> Proof Bool -> Hinted SInteger
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof (Forall "n" Integer -> SBool)
sp Proof (Forall "n" Integer -> SBool)
-> IArgs (Forall "n" Integer -> SBool) -> Proof Bool
forall a. Instantiatable a => Proof a -> IArgs a -> Proof Bool
`at` forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"n" SInteger
n
TPProofRaw SInteger
-> ChainsTo (TPProofRaw SInteger) -> ChainsTo (TPProofRaw SInteger)
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: ((SInteger
n SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
* (SInteger
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1)) SInteger -> SInteger -> SInteger
`sEDiv` SInteger
2)SInteger -> Integer -> SInteger
^Integer
2
SInteger -> Proof Bool -> Hinted SInteger
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof (Forall "n" Integer -> SBool)
nn1IsEven Proof (Forall "n" Integer -> SBool)
-> IArgs (Forall "n" Integer -> SBool) -> Proof Bool
forall a. Instantiatable a => Proof a -> IArgs a -> Proof Bool
`at` forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"n" SInteger
n
TPProofRaw SInteger -> Proof Bool -> Hinted (TPProofRaw SInteger)
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof (Forall "n" Integer -> SBool)
evenHalfSquared Proof (Forall "n" Integer -> SBool)
-> IArgs (Forall "n" Integer -> SBool) -> Proof Bool
forall a. Instantiatable a => Proof a -> IArgs a -> Proof Bool
`at` forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"n" (SInteger
n SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
* (SInteger
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1))
Hinted (TPProofRaw SInteger)
-> ChainsTo (Hinted (TPProofRaw SInteger))
-> ChainsTo (Hinted (TPProofRaw SInteger))
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: ((SInteger
n SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
* (SInteger
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1))SInteger -> Integer -> SInteger
^Integer
2) SInteger -> SInteger -> SInteger
`sEDiv` SInteger
4
SInteger -> ChainsTo SInteger -> ChainsTo SInteger
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: ChainsTo SInteger
TPProofRaw SInteger
forall a. TPProofRaw a
qed
String
-> (Forall "n" Integer -> SBool)
-> (Proof (IHType (Forall "n" Integer -> SBool))
-> IHArg (Forall "n" Integer -> SBool)
-> IStepArgs (Forall "n" Integer -> SBool) Integer)
-> TP (Proof (Forall "n" Integer -> SBool))
forall t.
(Proposition (Forall "n" Integer -> SBool), SymVal t,
EqSymbolic (SBV t)) =>
String
-> (Forall "n" Integer -> SBool)
-> (Proof (IHType (Forall "n" Integer -> SBool))
-> IHArg (Forall "n" Integer -> SBool)
-> IStepArgs (Forall "n" Integer -> SBool) t)
-> TP (Proof (Forall "n" Integer -> SBool))
forall a t.
(Inductive a, Proposition a, SymVal t, EqSymbolic (SBV t)) =>
String
-> a
-> (Proof (IHType a) -> IHArg a -> IStepArgs a t)
-> TP (Proof a)
induct String
"nicomachus"
(\(Forall SInteger
n) -> SInteger
n SInteger -> SInteger -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.>= SInteger
0 SBool -> SBool -> SBool
.=> SInteger -> SInteger
sumCubed SInteger
n SInteger -> SInteger -> SBool
forall a. EqSymbolic a => a -> a -> SBool
.== SList Integer -> SInteger
forall a. (SymVal a, Num (SBV a)) => SList a -> SBV a
sum [sEnum|n, n-1 .. 0|] SInteger -> Integer -> SInteger
^ Integer
2) ((Proof (IHType (Forall "n" Integer -> SBool))
-> IHArg (Forall "n" Integer -> SBool)
-> IStepArgs (Forall "n" Integer -> SBool) Integer)
-> TP (Proof (Forall "n" Integer -> SBool)))
-> (Proof (IHType (Forall "n" Integer -> SBool))
-> IHArg (Forall "n" Integer -> SBool)
-> IStepArgs (Forall "n" Integer -> SBool) Integer)
-> TP (Proof (Forall "n" Integer -> SBool))
forall a b. (a -> b) -> a -> b
$
\Proof (IHType (Forall "n" Integer -> SBool))
ih IHArg (Forall "n" Integer -> SBool)
n -> [SInteger
IHArg (Forall "n" Integer -> SBool)
n SInteger -> SInteger -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.>= SInteger
0]
[SBool] -> TPProofRaw SInteger -> (SBool, TPProofRaw SInteger)
forall a. [SBool] -> TPProofRaw a -> (SBool, TPProofRaw a)
|- SInteger -> SInteger
sumCubed (SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1)
SInteger -> ChainsTo SInteger -> ChainsTo SInteger
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: (SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1)SInteger -> Integer -> SInteger
^Integer
3 SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+ SInteger -> SInteger
sumCubed SInteger
IHArg (Forall "n" Integer -> SBool)
n
SInteger -> Proof SBool -> Hinted SInteger
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof SBool
Proof (IHType (Forall "n" Integer -> SBool))
ih
TPProofRaw SInteger
-> Proof (Forall "n" Integer -> SBool)
-> Hinted (TPProofRaw SInteger)
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof (Forall "n" Integer -> SBool)
ssp
Hinted (TPProofRaw SInteger)
-> ChainsTo (Hinted (TPProofRaw SInteger))
-> ChainsTo (Hinted (TPProofRaw SInteger))
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SList Integer -> SInteger
forall a. (SymVal a, Num (SBV a)) => SList a -> SBV a
sum [sEnum|n+1, n .. 0|] SInteger -> Integer -> SInteger
^ Integer
2
SInteger -> ChainsTo SInteger -> ChainsTo SInteger
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: ChainsTo SInteger
TPProofRaw SInteger
forall a. TPProofRaw a
qed
elevenMinusFour :: TP (Proof (Forall "n" Integer -> SBool))
elevenMinusFour :: TP (Proof (Forall "n" Integer -> SBool))
elevenMinusFour = do
let pow :: SInteger -> SInteger -> SInteger
pow :: SInteger -> SInteger -> SInteger
pow = String
-> (SInteger -> SInteger -> SInteger)
-> SInteger
-> SInteger
-> SInteger
forall a.
(SMTDefinable a, Typeable a, Lambda Symbolic a) =>
String -> a -> a
smtFunction String
"pow" ((SInteger -> SInteger -> SInteger)
-> SInteger -> SInteger -> SInteger)
-> (SInteger -> SInteger -> SInteger)
-> SInteger
-> SInteger
-> SInteger
forall a b. (a -> b) -> a -> b
$ \SInteger
x SInteger
y -> SBool -> SInteger -> SInteger -> SInteger
forall a. Mergeable a => SBool -> a -> a -> a
ite (SInteger
y SInteger -> SInteger -> SBool
forall a. EqSymbolic a => a -> a -> SBool
.== SInteger
0) SInteger
1 (SInteger
x SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
* SInteger -> SInteger -> SInteger
pow SInteger
x (SInteger
y SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
- SInteger
1))
emf :: SInteger -> SBool
emf :: SInteger -> SBool
emf SInteger
n = Integer
7 Integer -> SInteger -> SBool
`sDivides` (SInteger
11 SInteger -> SInteger -> SInteger
`pow` SInteger
n SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
- SInteger
4 SInteger -> SInteger -> SInteger
`pow` SInteger
n)
Proof (Forall "x" Integer -> Forall "n" Integer -> SBool)
powN <- String
-> (Forall "x" Integer -> Forall "n" Integer -> SBool)
-> [ProofObj]
-> TP (Proof (Forall "x" Integer -> Forall "n" Integer -> SBool))
forall a.
Proposition a =>
String -> a -> [ProofObj] -> TP (Proof a)
lemma String
"powN" (\(Forall SInteger
x) (Forall SInteger
n) -> SInteger
n SInteger -> SInteger -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.>= SInteger
0 SBool -> SBool -> SBool
.=> SInteger
x SInteger -> SInteger -> SInteger
`pow` (SInteger
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1) SInteger -> SInteger -> SBool
forall a. EqSymbolic a => a -> a -> SBool
.== SInteger
x SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
* SInteger
x SInteger -> SInteger -> SInteger
`pow` SInteger
n) []
SMTConfig
-> String
-> (Forall "n" Integer -> SBool)
-> (Proof (IHType (Forall "n" Integer -> SBool))
-> IHArg (Forall "n" Integer -> SBool)
-> IStepArgs (Forall "n" Integer -> SBool) Bool)
-> TP (Proof (Forall "n" Integer -> SBool))
forall t.
(Proposition (Forall "n" Integer -> SBool), SymVal t,
EqSymbolic (SBV t)) =>
SMTConfig
-> String
-> (Forall "n" Integer -> SBool)
-> (Proof (IHType (Forall "n" Integer -> SBool))
-> IHArg (Forall "n" Integer -> SBool)
-> IStepArgs (Forall "n" Integer -> SBool) t)
-> TP (Proof (Forall "n" Integer -> SBool))
forall a t.
(Inductive a, Proposition a, SymVal t, EqSymbolic (SBV t)) =>
SMTConfig
-> String
-> a
-> (Proof (IHType a) -> IHArg a -> IStepArgs a t)
-> TP (Proof a)
inductWith SMTConfig
cvc5 String
"elevenMinusFour"
(\(Forall SInteger
n) -> SInteger
n SInteger -> SInteger -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.>= SInteger
0 SBool -> SBool -> SBool
.=> SInteger -> SBool
emf SInteger
n) ((Proof (IHType (Forall "n" Integer -> SBool))
-> IHArg (Forall "n" Integer -> SBool)
-> IStepArgs (Forall "n" Integer -> SBool) Bool)
-> TP (Proof (Forall "n" Integer -> SBool)))
-> (Proof (IHType (Forall "n" Integer -> SBool))
-> IHArg (Forall "n" Integer -> SBool)
-> IStepArgs (Forall "n" Integer -> SBool) Bool)
-> TP (Proof (Forall "n" Integer -> SBool))
forall a b. (a -> b) -> a -> b
$
\Proof (IHType (Forall "n" Integer -> SBool))
ih IHArg (Forall "n" Integer -> SBool)
n -> [SInteger
IHArg (Forall "n" Integer -> SBool)
n SInteger -> SInteger -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.>= SInteger
0]
[SBool] -> TPProofRaw SBool -> (SBool, TPProofRaw SBool)
forall a. [SBool] -> TPProofRaw a -> (SBool, TPProofRaw a)
|- SInteger -> SBool
emf (SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1)
SBool -> ChainsTo SBool -> ChainsTo SBool
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: Integer
7 Integer -> SInteger -> SBool
`sDivides` (SInteger
11 SInteger -> SInteger -> SInteger
`pow` (SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1) SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
- SInteger
4 SInteger -> SInteger -> SInteger
`pow` (SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1))
SBool -> Proof Bool -> Hinted SBool
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof (Forall "x" Integer -> Forall "n" Integer -> SBool)
powN Proof (Forall "x" Integer -> Forall "n" Integer -> SBool)
-> IArgs (Forall "x" Integer -> Forall "n" Integer -> SBool)
-> Proof Bool
forall a. Instantiatable a => Proof a -> IArgs a -> Proof Bool
`at` (forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"x" SInteger
11, forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"n" SInteger
IHArg (Forall "n" Integer -> SBool)
n)
TPProofRaw SBool
-> ChainsTo (TPProofRaw SBool) -> ChainsTo (TPProofRaw SBool)
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: Integer
7 Integer -> SInteger -> SBool
`sDivides` (SInteger
11 SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
* SInteger
11 SInteger -> SInteger -> SInteger
`pow` SInteger
IHArg (Forall "n" Integer -> SBool)
n SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
- SInteger
4 SInteger -> SInteger -> SInteger
`pow` (SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1))
SBool -> Proof Bool -> Hinted SBool
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof (Forall "x" Integer -> Forall "n" Integer -> SBool)
powN Proof (Forall "x" Integer -> Forall "n" Integer -> SBool)
-> IArgs (Forall "x" Integer -> Forall "n" Integer -> SBool)
-> Proof Bool
forall a. Instantiatable a => Proof a -> IArgs a -> Proof Bool
`at` (forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"x" SInteger
4, forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"n" SInteger
IHArg (Forall "n" Integer -> SBool)
n)
TPProofRaw SBool
-> ChainsTo (TPProofRaw SBool) -> ChainsTo (TPProofRaw SBool)
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: Integer
7 Integer -> SInteger -> SBool
`sDivides` (SInteger
11 SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
* SInteger
11 SInteger -> SInteger -> SInteger
`pow` SInteger
IHArg (Forall "n" Integer -> SBool)
n SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
- SInteger
4 SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
* SInteger
4 SInteger -> SInteger -> SInteger
`pow` SInteger
IHArg (Forall "n" Integer -> SBool)
n)
SBool -> ChainsTo SBool -> ChainsTo SBool
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: Integer
7 Integer -> SInteger -> SBool
`sDivides` (SInteger
7 SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
* SInteger
11 SInteger -> SInteger -> SInteger
`pow` SInteger
IHArg (Forall "n" Integer -> SBool)
n SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+ SInteger
4 SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
* SInteger
11 SInteger -> SInteger -> SInteger
`pow` SInteger
IHArg (Forall "n" Integer -> SBool)
n SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
- SInteger
4 SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
* SInteger
4 SInteger -> SInteger -> SInteger
`pow` SInteger
IHArg (Forall "n" Integer -> SBool)
n)
SBool -> ChainsTo SBool -> ChainsTo SBool
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: Integer
7 Integer -> SInteger -> SBool
`sDivides` (SInteger
7 SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
* SInteger
11 SInteger -> SInteger -> SInteger
`pow` SInteger
IHArg (Forall "n" Integer -> SBool)
n SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+ SInteger
4 SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
* (SInteger
11 SInteger -> SInteger -> SInteger
`pow` SInteger
IHArg (Forall "n" Integer -> SBool)
n SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
- SInteger
4 SInteger -> SInteger -> SInteger
`pow` SInteger
IHArg (Forall "n" Integer -> SBool)
n))
SBool -> Proof SBool -> Hinted SBool
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof SBool
Proof (IHType (Forall "n" Integer -> SBool))
ih
TPProofRaw SBool
-> ChainsTo (TPProofRaw SBool) -> ChainsTo (TPProofRaw SBool)
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: let x :: SInteger
x = String -> (SInteger -> SBool) -> SInteger
forall a.
(SymVal a, HasKind a) =>
String -> (SBV a -> SBool) -> SBV a
some String
"x" (\SInteger
v -> SInteger
7SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
*SInteger
v SInteger -> SInteger -> SBool
forall a. EqSymbolic a => a -> a -> SBool
.== SInteger
11 SInteger -> SInteger -> SInteger
`pow` SInteger
IHArg (Forall "n" Integer -> SBool)
n SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
- SInteger
4 SInteger -> SInteger -> SInteger
`pow` SInteger
IHArg (Forall "n" Integer -> SBool)
n)
in Integer
7 Integer -> SInteger -> SBool
`sDivides` (SInteger
7 SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
* SInteger
11 SInteger -> SInteger -> SInteger
`pow` SInteger
IHArg (Forall "n" Integer -> SBool)
n SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+ SInteger
4 SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
* SInteger
7 SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
* SInteger
x)
SBool -> ChainsTo SBool -> ChainsTo SBool
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: Integer
7 Integer -> SInteger -> SBool
`sDivides` (SInteger
7 SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
* (SInteger
11 SInteger -> SInteger -> SInteger
`pow` SInteger
IHArg (Forall "n" Integer -> SBool)
n SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+ SInteger
4 SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
* SInteger
x))
SBool -> ChainsTo SBool -> ChainsTo SBool
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SBool
sTrue
SBool -> ChainsTo SBool -> ChainsTo SBool
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: ChainsTo SBool
TPProofRaw SBool
forall a. TPProofRaw a
qed
sumMulFactorial :: TP (Proof (Forall "n" Integer -> SBool))
sumMulFactorial :: TP (Proof (Forall "n" Integer -> SBool))
sumMulFactorial = do
let fact :: SInteger -> SInteger
fact :: SInteger -> SInteger
fact SInteger
n = SList Integer -> SInteger
forall a. (SymVal a, Num (SBV a)) => SList a -> SBV a
product [sEnum|n, n-1 .. 1|]
Proof (Forall "n" Integer -> SBool)
helper <- String
-> (Forall "n" Integer -> SBool)
-> StepArgs (Forall "n" Integer -> SBool) Integer
-> TP (Proof (Forall "n" Integer -> SBool))
forall t.
(Proposition (Forall "n" Integer -> SBool), SymVal t,
EqSymbolic (SBV t)) =>
String
-> (Forall "n" Integer -> SBool)
-> StepArgs (Forall "n" Integer -> SBool) t
-> TP (Proof (Forall "n" Integer -> SBool))
forall a t.
(Calc a, Proposition a, SymVal t, EqSymbolic (SBV t)) =>
String -> a -> StepArgs a t -> TP (Proof a)
calc String
"fact (n+1)"
(\(Forall SInteger
n) -> SInteger
n SInteger -> SInteger -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.>= SInteger
0 SBool -> SBool -> SBool
.=> SInteger -> SInteger
fact (SInteger
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1) SInteger -> SInteger -> SBool
forall a. EqSymbolic a => a -> a -> SBool
.== (SInteger
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1) SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
* SInteger -> SInteger
fact SInteger
n) (StepArgs (Forall "n" Integer -> SBool) Integer
-> TP (Proof (Forall "n" Integer -> SBool)))
-> StepArgs (Forall "n" Integer -> SBool) Integer
-> TP (Proof (Forall "n" Integer -> SBool))
forall a b. (a -> b) -> a -> b
$
\SInteger
n -> [SInteger
n SInteger -> SInteger -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.>= SInteger
0] [SBool] -> TPProofRaw SInteger -> (SBool, TPProofRaw SInteger)
forall a. [SBool] -> TPProofRaw a -> (SBool, TPProofRaw a)
|- SInteger -> SInteger
fact (SInteger
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1)
SInteger -> ChainsTo SInteger -> ChainsTo SInteger
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SList Integer -> SInteger
forall a. (SymVal a, Num (SBV a)) => SList a -> SBV a
product [sEnum|n+1, n .. 1|]
SInteger -> ChainsTo SInteger -> ChainsTo SInteger
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SList Integer -> SInteger
forall a. (SymVal a, Num (SBV a)) => SList a -> SBV a
product (SInteger
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1 SInteger -> SList Integer -> SList Integer
forall a. SymVal a => SBV a -> SList a -> SList a
.: [sEnum|n, n-1 .. 1|])
SInteger -> ChainsTo SInteger -> ChainsTo SInteger
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: (SInteger
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1) SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
* SList Integer -> SInteger
forall a. (SymVal a, Num (SBV a)) => SList a -> SBV a
product [sEnum|n, n-1 .. 1|]
SInteger -> ChainsTo SInteger -> ChainsTo SInteger
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: (SInteger
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1) SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
* SInteger -> SInteger
fact SInteger
n
SInteger -> ChainsTo SInteger -> ChainsTo SInteger
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: ChainsTo SInteger
TPProofRaw SInteger
forall a. TPProofRaw a
qed
String
-> (Forall "n" Integer -> SBool)
-> (Proof (IHType (Forall "n" Integer -> SBool))
-> IHArg (Forall "n" Integer -> SBool)
-> IStepArgs (Forall "n" Integer -> SBool) Integer)
-> TP (Proof (Forall "n" Integer -> SBool))
forall t.
(Proposition (Forall "n" Integer -> SBool), SymVal t,
EqSymbolic (SBV t)) =>
String
-> (Forall "n" Integer -> SBool)
-> (Proof (IHType (Forall "n" Integer -> SBool))
-> IHArg (Forall "n" Integer -> SBool)
-> IStepArgs (Forall "n" Integer -> SBool) t)
-> TP (Proof (Forall "n" Integer -> SBool))
forall a t.
(Inductive a, Proposition a, SymVal t, EqSymbolic (SBV t)) =>
String
-> a
-> (Proof (IHType a) -> IHArg a -> IStepArgs a t)
-> TP (Proof a)
induct String
"sumMulFactorial"
(\(Forall SInteger
n) -> SInteger
n SInteger -> SInteger -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.>= SInteger
0 SBool -> SBool -> SBool
.=> SList Integer -> SInteger
forall a. (SymVal a, Num (SBV a)) => SList a -> SBV a
sum ((SInteger -> SInteger) -> SList Integer -> SList Integer
forall func a b. SMap func a b => func -> SList a -> SList b
map (\SInteger
k -> SInteger
k SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
* SInteger -> SInteger
fact SInteger
k) [sEnum|n, n-1 .. 0|]) SInteger -> SInteger -> SBool
forall a. EqSymbolic a => a -> a -> SBool
.== SInteger -> SInteger
fact (SInteger
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1) SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
- SInteger
1) ((Proof (IHType (Forall "n" Integer -> SBool))
-> IHArg (Forall "n" Integer -> SBool)
-> IStepArgs (Forall "n" Integer -> SBool) Integer)
-> TP (Proof (Forall "n" Integer -> SBool)))
-> (Proof (IHType (Forall "n" Integer -> SBool))
-> IHArg (Forall "n" Integer -> SBool)
-> IStepArgs (Forall "n" Integer -> SBool) Integer)
-> TP (Proof (Forall "n" Integer -> SBool))
forall a b. (a -> b) -> a -> b
$
\Proof (IHType (Forall "n" Integer -> SBool))
ih IHArg (Forall "n" Integer -> SBool)
n -> [SInteger
IHArg (Forall "n" Integer -> SBool)
n SInteger -> SInteger -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.>= SInteger
0] [SBool] -> TPProofRaw SInteger -> (SBool, TPProofRaw SInteger)
forall a. [SBool] -> TPProofRaw a -> (SBool, TPProofRaw a)
|- SList Integer -> SInteger
forall a. (SymVal a, Num (SBV a)) => SList a -> SBV a
sum ((SInteger -> SInteger) -> SList Integer -> SList Integer
forall func a b. SMap func a b => func -> SList a -> SList b
map (\SInteger
k -> SInteger
k SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
* SInteger -> SInteger
fact SInteger
k) [sEnum|n+1, n .. 0|])
SInteger -> ChainsTo SInteger -> ChainsTo SInteger
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SList Integer -> SInteger
forall a. (SymVal a, Num (SBV a)) => SList a -> SBV a
sum ((SInteger -> SInteger) -> SList Integer -> SList Integer
forall func a b. SMap func a b => func -> SList a -> SList b
map (\SInteger
k -> SInteger
k SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
* SInteger -> SInteger
fact SInteger
k) (SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1 SInteger -> SList Integer -> SList Integer
forall a. SymVal a => SBV a -> SList a -> SList a
.: [sEnum|n, n-1 .. 0|]))
SInteger -> ChainsTo SInteger -> ChainsTo SInteger
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SList Integer -> SInteger
forall a. (SymVal a, Num (SBV a)) => SList a -> SBV a
sum ((SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1) SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
* SInteger -> SInteger
fact (SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1) SInteger -> SList Integer -> SList Integer
forall a. SymVal a => SBV a -> SList a -> SList a
.: (SInteger -> SInteger) -> SList Integer -> SList Integer
forall func a b. SMap func a b => func -> SList a -> SList b
map (\SInteger
k -> SInteger
k SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
* SInteger -> SInteger
fact SInteger
k) [sEnum|n, n-1 .. 0|])
SInteger -> ChainsTo SInteger -> ChainsTo SInteger
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: (SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1) SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
* SInteger -> SInteger
fact (SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1) SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+ SList Integer -> SInteger
forall a. (SymVal a, Num (SBV a)) => SList a -> SBV a
sum ((SInteger -> SInteger) -> SList Integer -> SList Integer
forall func a b. SMap func a b => func -> SList a -> SList b
map (\SInteger
k -> SInteger
k SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
* SInteger -> SInteger
fact SInteger
k) [sEnum|n, n-1 .. 0|])
SInteger -> Proof SBool -> Hinted SInteger
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof SBool
Proof (IHType (Forall "n" Integer -> SBool))
ih
TPProofRaw SInteger
-> ChainsTo (TPProofRaw SInteger) -> ChainsTo (TPProofRaw SInteger)
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: (SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1) SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
* SInteger -> SInteger
fact (SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1) SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+ SInteger -> SInteger
fact (SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1) SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
- SInteger
1
SInteger -> ChainsTo SInteger -> ChainsTo SInteger
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: ((SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1) SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+ SInteger
1) SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
* SInteger -> SInteger
fact (SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1) SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
- SInteger
1
SInteger -> ChainsTo SInteger -> ChainsTo SInteger
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: (SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
2) SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
* SInteger -> SInteger
fact (SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1) SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
- SInteger
1
SInteger -> Proof Bool -> Hinted SInteger
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof (Forall "n" Integer -> SBool)
helper Proof (Forall "n" Integer -> SBool)
-> IArgs (Forall "n" Integer -> SBool) -> Proof Bool
forall a. Instantiatable a => Proof a -> IArgs a -> Proof Bool
`at` forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"n" (SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
1)
TPProofRaw SInteger
-> ChainsTo (TPProofRaw SInteger) -> ChainsTo (TPProofRaw SInteger)
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SInteger -> SInteger
fact (SInteger
IHArg (Forall "n" Integer -> SBool)
nSInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+SInteger
2) SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
- SInteger
1
SInteger -> ChainsTo SInteger -> ChainsTo SInteger
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: ChainsTo SInteger
TPProofRaw SInteger
forall a. TPProofRaw a
qed
product0 :: TP (Proof (Forall "xs" [Integer] -> SBool))
product0 :: TP (Proof (Forall "xs" [Integer] -> SBool))
product0 =
String
-> (Forall "xs" [Integer] -> SBool)
-> (Proof (IHType (Forall "xs" [Integer] -> SBool))
-> IHArg (Forall "xs" [Integer] -> SBool)
-> IStepArgs (Forall "xs" [Integer] -> SBool) Bool)
-> TP (Proof (Forall "xs" [Integer] -> SBool))
forall t.
(Proposition (Forall "xs" [Integer] -> SBool), SymVal t,
EqSymbolic (SBV t)) =>
String
-> (Forall "xs" [Integer] -> SBool)
-> (Proof (IHType (Forall "xs" [Integer] -> SBool))
-> IHArg (Forall "xs" [Integer] -> SBool)
-> IStepArgs (Forall "xs" [Integer] -> SBool) t)
-> TP (Proof (Forall "xs" [Integer] -> SBool))
forall a t.
(Inductive a, Proposition a, SymVal t, EqSymbolic (SBV t)) =>
String
-> a
-> (Proof (IHType a) -> IHArg a -> IStepArgs a t)
-> TP (Proof a)
induct String
"product0"
(\(Forall @"xs" (SList Integer
xs :: SList Integer)) -> SList Integer -> SInteger
forall a. (SymVal a, Num (SBV a)) => SList a -> SBV a
product SList Integer
xs SInteger -> SInteger -> SBool
forall a. EqSymbolic a => a -> a -> SBool
.== SInteger
0 SBool -> SBool -> SBool
.<=> SInteger
0 SInteger -> SList Integer -> SBool
forall a. (Eq a, SymVal a) => SBV a -> SList a -> SBool
`elem` SList Integer
xs) ((Proof (IHType (Forall "xs" [Integer] -> SBool))
-> IHArg (Forall "xs" [Integer] -> SBool)
-> IStepArgs (Forall "xs" [Integer] -> SBool) Bool)
-> TP (Proof (Forall "xs" [Integer] -> SBool)))
-> (Proof (IHType (Forall "xs" [Integer] -> SBool))
-> IHArg (Forall "xs" [Integer] -> SBool)
-> IStepArgs (Forall "xs" [Integer] -> SBool) Bool)
-> TP (Proof (Forall "xs" [Integer] -> SBool))
forall a b. (a -> b) -> a -> b
$
\Proof (IHType (Forall "xs" [Integer] -> SBool))
ih (SInteger
x, SList Integer
xs) -> [] [SBool] -> TPProofRaw SBool -> (SBool, TPProofRaw SBool)
forall a. [SBool] -> TPProofRaw a -> (SBool, TPProofRaw a)
|- (SList Integer -> SInteger
forall a. (SymVal a, Num (SBV a)) => SList a -> SBV a
product (SInteger
x SInteger -> SList Integer -> SList Integer
forall a. SymVal a => SBV a -> SList a -> SList a
.: SList Integer
xs) SInteger -> SInteger -> SBool
forall a. EqSymbolic a => a -> a -> SBool
.== SInteger
0 SBool -> SBool -> SBool
.<=> SInteger
0 SInteger -> SList Integer -> SBool
forall a. (Eq a, SymVal a) => SBV a -> SList a -> SBool
`elem` (SInteger
x SInteger -> SList Integer -> SList Integer
forall a. SymVal a => SBV a -> SList a -> SList a
.: SList Integer
xs))
SBool -> ChainsTo SBool -> ChainsTo SBool
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: (SInteger
x SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
* SList Integer -> SInteger
forall a. (SymVal a, Num (SBV a)) => SList a -> SBV a
product SList Integer
xs SInteger -> SInteger -> SBool
forall a. EqSymbolic a => a -> a -> SBool
.== SInteger
0 SBool -> SBool -> SBool
.<=> SInteger
x SInteger -> SInteger -> SBool
forall a. EqSymbolic a => a -> a -> SBool
.== SInteger
0 SBool -> SBool -> SBool
.|| SInteger
0 SInteger -> SList Integer -> SBool
forall a. (Eq a, SymVal a) => SBV a -> SList a -> SBool
`elem` SList Integer
xs)
SBool -> ChainsTo SBool -> ChainsTo SBool
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: [(SBool, TPProofRaw SBool)] -> TPProofRaw SBool
forall a. [(SBool, TPProofRaw a)] -> TPProofRaw a
cases [ SInteger
x SInteger -> SInteger -> SBool
forall a. EqSymbolic a => a -> a -> SBool
.== SInteger
0 SBool -> TPProofRaw SBool -> (SBool, TPProofRaw SBool)
forall a. SBool -> TPProofRaw a -> (SBool, TPProofRaw a)
==> TPProofRaw SBool
forall a. Trivial a => a
trivial
, SInteger
x SInteger -> SInteger -> SBool
forall a. EqSymbolic a => a -> a -> SBool
./= SInteger
0 SBool -> TPProofRaw SBool -> (SBool, TPProofRaw SBool)
forall a. SBool -> TPProofRaw a -> (SBool, TPProofRaw a)
==> (SInteger
x SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
* SList Integer -> SInteger
forall a. (SymVal a, Num (SBV a)) => SList a -> SBV a
product SList Integer
xs SInteger -> SInteger -> SBool
forall a. EqSymbolic a => a -> a -> SBool
.== SInteger
0 SBool -> SBool -> SBool
.<=> SInteger
0 SInteger -> SList Integer -> SBool
forall a. (Eq a, SymVal a) => SBV a -> SList a -> SBool
`elem` SList Integer
xs)
SBool -> Proof SBool -> Hinted SBool
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof SBool
Proof (IHType (Forall "xs" [Integer] -> SBool))
ih
TPProofRaw SBool
-> ChainsTo (TPProofRaw SBool) -> ChainsTo (TPProofRaw SBool)
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SBool
sTrue
SBool -> ChainsTo SBool -> ChainsTo SBool
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: ChainsTo SBool
TPProofRaw SBool
forall a. TPProofRaw a
qed
]
badNonNegative :: IO ()
badNonNegative :: IO ()
badNonNegative = TP () -> IO ()
forall a. TP a -> IO a
runTP (TP () -> IO ()) -> TP () -> IO ()
forall a b. (a -> b) -> a -> b
$ do
Proof (Forall "n" Integer -> SBool)
_ <- String
-> (Forall "n" Integer -> SBool)
-> (Proof (IHType (Forall "n" Integer -> SBool))
-> IHArg (Forall "n" Integer -> SBool)
-> IStepArgs (Forall "n" Integer -> SBool) Bool)
-> TP (Proof (Forall "n" Integer -> SBool))
forall t.
(Proposition (Forall "n" Integer -> SBool), SymVal t,
EqSymbolic (SBV t)) =>
String
-> (Forall "n" Integer -> SBool)
-> (Proof (IHType (Forall "n" Integer -> SBool))
-> IHArg (Forall "n" Integer -> SBool)
-> IStepArgs (Forall "n" Integer -> SBool) t)
-> TP (Proof (Forall "n" Integer -> SBool))
forall a t.
(Inductive a, Proposition a, SymVal t, EqSymbolic (SBV t)) =>
String
-> a
-> (Proof (IHType a) -> IHArg a -> IStepArgs a t)
-> TP (Proof a)
induct String
"badNonNegative"
(\(Forall @"n" (SInteger
n :: SInteger)) -> SInteger
n SInteger -> SInteger -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.>= SInteger
0) ((Proof (IHType (Forall "n" Integer -> SBool))
-> IHArg (Forall "n" Integer -> SBool)
-> IStepArgs (Forall "n" Integer -> SBool) Bool)
-> TP (Proof (Forall "n" Integer -> SBool)))
-> (Proof (IHType (Forall "n" Integer -> SBool))
-> IHArg (Forall "n" Integer -> SBool)
-> IStepArgs (Forall "n" Integer -> SBool) Bool)
-> TP (Proof (Forall "n" Integer -> SBool))
forall a b. (a -> b) -> a -> b
$
\Proof (IHType (Forall "n" Integer -> SBool))
ih IHArg (Forall "n" Integer -> SBool)
n -> [] [SBool] -> TPProofRaw SBool -> (SBool, TPProofRaw SBool)
forall a. [SBool] -> TPProofRaw a -> (SBool, TPProofRaw a)
|- SInteger
IHArg (Forall "n" Integer -> SBool)
n SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+ SInteger
1 SInteger -> SInteger -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.>= SInteger
0
SBool -> Proof SBool -> Hinted SBool
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof SBool
Proof (IHType (Forall "n" Integer -> SBool))
ih
TPProofRaw SBool
-> ChainsTo (TPProofRaw SBool) -> ChainsTo (TPProofRaw SBool)
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SBool
sTrue
SBool -> ChainsTo SBool -> ChainsTo SBool
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: ChainsTo SBool
TPProofRaw SBool
forall a. TPProofRaw a
qed
() -> TP ()
forall a. a -> TP a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ()