{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE OverloadedLists #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeAbstractions #-}
{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -Wall -Werror #-}
module Documentation.SBV.Examples.TP.QuickSort where
import Prelude hiding (null, length, (++), tail, all, fst, snd, elem)
import Control.Monad.Trans (liftIO)
import Data.SBV
import Data.SBV.List hiding (partition)
import Data.SBV.Tuple
import Data.SBV.TP
import qualified Data.SBV.TP.List as TP
import qualified Documentation.SBV.Examples.TP.SortHelpers as SH
#ifdef DOCTEST
#endif
quickSort :: (Ord a, SymVal a) => SList a -> SList a
quickSort :: forall a. (Ord a, SymVal a) => SList a -> SList a
quickSort = String -> (SList a -> SList a) -> SList a -> SList a
forall a.
(SMTDefinable a, Typeable a, Lambda Symbolic a) =>
String -> a -> a
smtFunction String
"quickSort" ((SList a -> SList a) -> SList a -> SList a)
-> (SList a -> SList a) -> SList a -> SList a
forall a b. (a -> b) -> a -> b
$ \SList a
l -> SBool -> SList a -> SList a -> SList a
forall a. Mergeable a => SBool -> a -> a -> a
ite (SList a -> SBool
forall a. SymVal a => SList a -> SBool
null SList a
l)
SList a
forall a. SymVal a => SList a
nil
(let (SBV a
x, SList a
xs) = SList a -> (SBV a, SList a)
forall a. SymVal a => SList a -> (SBV a, SList a)
uncons SList a
l
(SList a
lo, SList a
hi) = SBV ([a], [a]) -> (SList a, SList a)
forall tup a. Tuple tup a => SBV tup -> a
untuple (SBV a -> SList a -> SBV ([a], [a])
forall a. (Ord a, SymVal a) => SBV a -> SList a -> STuple [a] [a]
partition SBV a
x SList a
xs)
in SList a -> SList a
forall a. (Ord a, SymVal a) => SList a -> SList a
quickSort SList a
lo SList a -> SList a -> SList a
forall a. SymVal a => SList a -> SList a -> SList a
++ [Item (SList a)
SBV a
x] SList a -> SList a -> SList a
forall a. SymVal a => SList a -> SList a -> SList a
++ SList a -> SList a
forall a. (Ord a, SymVal a) => SList a -> SList a
quickSort SList a
hi)
partition :: (Ord a, SymVal a) => SBV a -> SList a -> STuple [a] [a]
partition :: forall a. (Ord a, SymVal a) => SBV a -> SList a -> STuple [a] [a]
partition = String
-> (SBV a -> SList a -> STuple [a] [a])
-> SBV a
-> SList a
-> STuple [a] [a]
forall a.
(SMTDefinable a, Typeable a, Lambda Symbolic a) =>
String -> a -> a
smtFunction String
"partition" ((SBV a -> SList a -> STuple [a] [a])
-> SBV a -> SList a -> STuple [a] [a])
-> (SBV a -> SList a -> STuple [a] [a])
-> SBV a
-> SList a
-> STuple [a] [a]
forall a b. (a -> b) -> a -> b
$ \SBV a
pivot SList a
xs -> SBool -> STuple [a] [a] -> STuple [a] [a] -> STuple [a] [a]
forall a. Mergeable a => SBool -> a -> a -> a
ite (SList a -> SBool
forall a. SymVal a => SList a -> SBool
null SList a
xs)
((SList a, SList a) -> STuple [a] [a]
forall tup a. Tuple tup a => a -> SBV tup
tuple (SList a
forall a. SymVal a => SList a
nil, SList a
forall a. SymVal a => SList a
nil))
(let (SBV a
a, SList a
as) = SList a -> (SBV a, SList a)
forall a. SymVal a => SList a -> (SBV a, SList a)
uncons SList a
xs
(SList a
lo, SList a
hi) = STuple [a] [a] -> (SList a, SList a)
forall tup a. Tuple tup a => SBV tup -> a
untuple (SBV a -> SList a -> STuple [a] [a]
forall a. (Ord a, SymVal a) => SBV a -> SList a -> STuple [a] [a]
partition SBV a
pivot SList a
as)
in SBool -> STuple [a] [a] -> STuple [a] [a] -> STuple [a] [a]
forall a. Mergeable a => SBool -> a -> a -> a
ite (SBV a
a SBV a -> SBV a -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.< SBV a
pivot)
((SList a, SList a) -> STuple [a] [a]
forall tup a. Tuple tup a => a -> SBV tup
tuple (SBV a
a SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: SList a
lo, SList a
hi))
((SList a, SList a) -> STuple [a] [a]
forall tup a. Tuple tup a => a -> SBV tup
tuple (SList a
lo, SBV a
a SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: SList a
hi)))
correctness :: forall a. (Ord a, SymVal a) => IO (Proof (Forall "xs" [a] -> SBool))
correctness :: forall a.
(Ord a, SymVal a) =>
IO (Proof (Forall "xs" [a] -> SBool))
correctness = SMTConfig
-> TP (Proof (Forall "xs" [a] -> SBool))
-> IO (Proof (Forall "xs" [a] -> SBool))
forall a. SMTConfig -> TP a -> IO a
runTPWith (Int -> SMTConfig -> SMTConfig
tpRibbon Int
60 SMTConfig
z3) (TP (Proof (Forall "xs" [a] -> SBool))
-> IO (Proof (Forall "xs" [a] -> SBool)))
-> TP (Proof (Forall "xs" [a] -> SBool))
-> IO (Proof (Forall "xs" [a] -> SBool))
forall a b. (a -> b) -> a -> b
$ do
let count :: SBV a -> SList a -> SInteger
count = forall a. SymVal a => SBV a -> SList a -> SInteger
TP.count @a
isPermutation :: SList a -> SList a -> SBool
isPermutation = forall a. SymVal a => SList a -> SList a -> SBool
SH.isPermutation @a
nonDecreasing :: SList a -> SBool
nonDecreasing = forall a. (Ord a, SymVal a) => SList a -> SBool
SH.nonDecreasing @a
sublist :: SList a -> SList a -> SBool
sublist = forall a. SymVal a => SList a -> SList a -> SBool
SH.sublist @a
Proof (Forall "xs" [a] -> Forall "ys" [a] -> Forall "e" a -> SBool)
countAppend <- forall a.
SymVal a =>
TP
(Proof
(Forall "xs" [a] -> Forall "ys" [a] -> Forall "e" a -> SBool))
TP.countAppend @a
Proof (Forall "x" a -> Forall "xs" [a] -> Forall "ys" [a] -> SBool)
sublistElem <- forall a.
(Eq a, SymVal a) =>
TP
(Proof
(Forall "x" a -> Forall "xs" [a] -> Forall "ys" [a] -> SBool))
SH.sublistElem @a
Proof (Forall "x" a -> Forall "xs" [a] -> Forall "ys" [a] -> SBool)
sublistTail <- forall a.
(Eq a, SymVal a) =>
TP
(Proof
(Forall "x" a -> Forall "xs" [a] -> Forall "ys" [a] -> SBool))
SH.sublistTail @a
Proof (Forall "xs" [a] -> Forall "ys" [a] -> SBool)
sublistIfPerm <- forall a.
(Eq a, SymVal a) =>
TP (Proof (Forall "xs" [a] -> Forall "ys" [a] -> SBool))
SH.sublistIfPerm @a
let llt, lge :: SBV a -> SList a -> SBool
llt :: SBV a -> SList a -> SBool
llt = String -> (SBV a -> SList a -> SBool) -> SBV a -> SList a -> SBool
forall a.
(SMTDefinable a, Typeable a, Lambda Symbolic a) =>
String -> a -> a
smtFunction String
"llt" ((SBV a -> SList a -> SBool) -> SBV a -> SList a -> SBool)
-> (SBV a -> SList a -> SBool) -> SBV a -> SList a -> SBool
forall a b. (a -> b) -> a -> b
$ \SBV a
pivot SList a
l -> SList a -> SBool
forall a. SymVal a => SList a -> SBool
null SList a
l SBool -> SBool -> SBool
.|| let (SBV a
x, SList a
xs) = SList a -> (SBV a, SList a)
forall a. SymVal a => SList a -> (SBV a, SList a)
uncons SList a
l in SBV a
x SBV a -> SBV a -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.< SBV a
pivot SBool -> SBool -> SBool
.&& SBV a -> SList a -> SBool
llt SBV a
pivot SList a
xs
lge :: SBV a -> SList a -> SBool
lge = String -> (SBV a -> SList a -> SBool) -> SBV a -> SList a -> SBool
forall a.
(SMTDefinable a, Typeable a, Lambda Symbolic a) =>
String -> a -> a
smtFunction String
"lge" ((SBV a -> SList a -> SBool) -> SBV a -> SList a -> SBool)
-> (SBV a -> SList a -> SBool) -> SBV a -> SList a -> SBool
forall a b. (a -> b) -> a -> b
$ \SBV a
pivot SList a
l -> SList a -> SBool
forall a. SymVal a => SList a -> SBool
null SList a
l SBool -> SBool -> SBool
.|| let (SBV a
x, SList a
xs) = SList a -> (SBV a, SList a)
forall a. SymVal a => SList a -> (SBV a, SList a)
uncons SList a
l in SBV a
x SBV a -> SBV a -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.>= SBV a
pivot SBool -> SBool -> SBool
.&& SBV a -> SList a -> SBool
lge SBV a
pivot SList a
xs
Proof
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool)
lltCorrect <-
String
-> (Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool)
-> (Proof
(IHType
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool))
-> IHArg
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool)
-> IStepArgs
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool)
Bool)
-> TP
(Proof
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool))
forall t.
(Proposition
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool),
SymVal t, EqSymbolic (SBV t)) =>
String
-> (Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool)
-> (Proof
(IHType
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool))
-> IHArg
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool)
-> IStepArgs
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool) t)
-> TP
(Proof
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> 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
"lltCorrect"
(\(Forall SList a
xs) (Forall SBV a
e) (Forall SBV a
pivot) -> SBV a -> SList a -> SBool
llt SBV a
pivot SList a
xs SBool -> SBool -> SBool
.&& SBV a
e SBV a -> SList a -> SBool
forall a. (Eq a, SymVal a) => SBV a -> SList a -> SBool
`elem` SList a
xs SBool -> SBool -> SBool
.=> SBV a
e SBV a -> SBV a -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.< SBV a
pivot) ((Proof
(IHType
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool))
-> IHArg
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool)
-> IStepArgs
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool)
Bool)
-> TP
(Proof
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool)))
-> (Proof
(IHType
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool))
-> IHArg
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool)
-> IStepArgs
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool)
Bool)
-> TP
(Proof
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool))
forall a b. (a -> b) -> a -> b
$
\Proof
(IHType
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool))
ih (SBV a
x, SList a
xs) SBV a
e SBV a
pivot -> [SBV a -> SList a -> SBool
llt SBV a
pivot (SBV a
x SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: SList a
xs), SBV a
e SBV a -> SList a -> SBool
forall a. (Eq a, SymVal a) => SBV a -> SList a -> SBool
`elem` (SBV a
x SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: SList a
xs)]
[SBool] -> TPProofRaw SBool -> (SBool, TPProofRaw SBool)
forall a. [SBool] -> TPProofRaw a -> (SBool, TPProofRaw a)
|- SBV a
e SBV a -> SBV a -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.< SBV a
pivot
SBool
-> Proof (Forall "e" a -> Forall "pivot" a -> SBool)
-> Hinted SBool
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof
(IHType
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool))
Proof (Forall "e" a -> Forall "pivot" a -> 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
Proof
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool)
lgeCorrect <-
String
-> (Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool)
-> (Proof
(IHType
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool))
-> IHArg
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool)
-> IStepArgs
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool)
Bool)
-> TP
(Proof
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool))
forall t.
(Proposition
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool),
SymVal t, EqSymbolic (SBV t)) =>
String
-> (Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool)
-> (Proof
(IHType
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool))
-> IHArg
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool)
-> IStepArgs
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool) t)
-> TP
(Proof
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> 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
"lgeCorrect"
(\(Forall SList a
xs) (Forall SBV a
e) (Forall SBV a
pivot) -> SBV a -> SList a -> SBool
lge SBV a
pivot SList a
xs SBool -> SBool -> SBool
.&& SBV a
e SBV a -> SList a -> SBool
forall a. (Eq a, SymVal a) => SBV a -> SList a -> SBool
`elem` SList a
xs SBool -> SBool -> SBool
.=> SBV a
e SBV a -> SBV a -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.>= SBV a
pivot) ((Proof
(IHType
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool))
-> IHArg
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool)
-> IStepArgs
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool)
Bool)
-> TP
(Proof
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool)))
-> (Proof
(IHType
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool))
-> IHArg
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool)
-> IStepArgs
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool)
Bool)
-> TP
(Proof
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool))
forall a b. (a -> b) -> a -> b
$
\Proof
(IHType
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool))
ih (SBV a
x, SList a
xs) SBV a
e SBV a
pivot -> [SBV a -> SList a -> SBool
lge SBV a
pivot (SBV a
x SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: SList a
xs), SBV a
e SBV a -> SList a -> SBool
forall a. (Eq a, SymVal a) => SBV a -> SList a -> SBool
`elem` (SBV a
x SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: SList a
xs)]
[SBool] -> TPProofRaw SBool -> (SBool, TPProofRaw SBool)
forall a. [SBool] -> TPProofRaw a -> (SBool, TPProofRaw a)
|- SBV a
e SBV a -> SBV a -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.>= SBV a
pivot
SBool
-> Proof (Forall "e" a -> Forall "pivot" a -> SBool)
-> Hinted SBool
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof
(IHType
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool))
Proof (Forall "e" a -> Forall "pivot" a -> 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
Proof
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
lltSublist <-
SMTConfig
-> String
-> (Forall "xs" [a]
-> Forall "pivot" a -> Forall "ys" [a] -> SBool)
-> (Proof
(IHType
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool))
-> IHArg
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
-> IStepArgs
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
Bool)
-> TP
(Proof
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool))
forall t.
(Proposition
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool),
SymVal t, EqSymbolic (SBV t)) =>
SMTConfig
-> String
-> (Forall "xs" [a]
-> Forall "pivot" a -> Forall "ys" [a] -> SBool)
-> (Proof
(IHType
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool))
-> IHArg
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
-> IStepArgs
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
t)
-> TP
(Proof
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> 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
"lltSublist"
(\(Forall SList a
xs) (Forall SBV a
pivot) (Forall SList a
ys) -> SBV a -> SList a -> SBool
llt SBV a
pivot SList a
ys SBool -> SBool -> SBool
.&& SList a
xs SList a -> SList a -> SBool
`sublist` SList a
ys SBool -> SBool -> SBool
.=> SBV a -> SList a -> SBool
llt SBV a
pivot SList a
xs) ((Proof
(IHType
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool))
-> IHArg
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
-> IStepArgs
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
Bool)
-> TP
(Proof
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)))
-> (Proof
(IHType
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool))
-> IHArg
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
-> IStepArgs
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
Bool)
-> TP
(Proof
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool))
forall a b. (a -> b) -> a -> b
$
\Proof
(IHType
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool))
ih (SBV a
x, SList a
xs) SBV a
pivot SList a
ys -> [SBV a -> SList a -> SBool
llt SBV a
pivot SList a
ys, (SBV a
x SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: SList a
xs) SList a -> SList a -> SBool
`sublist` SList a
ys]
[SBool] -> TPProofRaw SBool -> (SBool, TPProofRaw SBool)
forall a. [SBool] -> TPProofRaw a -> (SBool, TPProofRaw a)
|- SBV a -> SList a -> SBool
llt SBV a
pivot (SBV a
x SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: SList a
xs)
SBool -> ChainsTo SBool -> ChainsTo SBool
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SBV a
x SBV a -> SBV a -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.< SBV a
pivot SBool -> SBool -> SBool
.&& SBV a -> SList a -> SBool
llt SBV a
pivot SList a
xs
SBool -> Proof Bool -> Hinted SBool
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof (Forall "x" a -> Forall "xs" [a] -> Forall "ys" [a] -> SBool)
sublistElem Proof (Forall "x" a -> Forall "xs" [a] -> Forall "ys" [a] -> SBool)
-> IArgs
(Forall "x" a -> Forall "xs" [a] -> Forall "ys" [a] -> 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" SBV a
x, forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"xs" SList a
xs, forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"ys" SList a
ys)
TPProofRaw SBool -> Proof Bool -> Hinted (TPProofRaw SBool)
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool)
lltCorrect Proof
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool)
-> IArgs
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool)
-> Proof Bool
forall a. Instantiatable a => Proof a -> IArgs a -> Proof Bool
`at` (forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"xs" SList a
ys, forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"e" SBV a
x, forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"pivot" SBV a
pivot)
Hinted (TPProofRaw SBool)
-> Proof Bool -> Hinted (Hinted (TPProofRaw SBool))
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof (Forall "x" a -> Forall "xs" [a] -> Forall "ys" [a] -> SBool)
sublistTail Proof (Forall "x" a -> Forall "xs" [a] -> Forall "ys" [a] -> SBool)
-> IArgs
(Forall "x" a -> Forall "xs" [a] -> Forall "ys" [a] -> 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" SBV a
x, forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"xs" SList a
xs, forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"ys" SList a
ys)
Hinted (Hinted (TPProofRaw SBool))
-> Proof Bool -> Hinted (Hinted (Hinted (TPProofRaw SBool)))
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof
(IHType
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool))
Proof (Forall "pivot" a -> Forall "ys" [a] -> SBool)
ih Proof (Forall "pivot" a -> Forall "ys" [a] -> SBool)
-> IArgs (Forall "pivot" a -> Forall "ys" [a] -> SBool)
-> Proof Bool
forall a. Instantiatable a => Proof a -> IArgs a -> Proof Bool
`at` (forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"pivot" SBV a
pivot, forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"ys" SList a
ys)
Hinted (Hinted (Hinted (TPProofRaw SBool)))
-> ChainsTo (Hinted (Hinted (Hinted (TPProofRaw SBool))))
-> ChainsTo (Hinted (Hinted (Hinted (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
Proof
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
lltPermutation <-
String
-> (Forall "xs" [a]
-> Forall "pivot" a -> Forall "ys" [a] -> SBool)
-> StepArgs
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
Bool
-> TP
(Proof
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool))
forall t.
(Proposition
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool),
SymVal t, EqSymbolic (SBV t)) =>
String
-> (Forall "xs" [a]
-> Forall "pivot" a -> Forall "ys" [a] -> SBool)
-> StepArgs
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool) t
-> TP
(Proof
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool))
forall a t.
(Calc a, Proposition a, SymVal t, EqSymbolic (SBV t)) =>
String -> a -> StepArgs a t -> TP (Proof a)
calc String
"lltPermutation"
(\(Forall SList a
xs) (Forall SBV a
pivot) (Forall SList a
ys) -> SBV a -> SList a -> SBool
llt SBV a
pivot SList a
ys SBool -> SBool -> SBool
.&& SList a -> SList a -> SBool
isPermutation SList a
xs SList a
ys SBool -> SBool -> SBool
.=> SBV a -> SList a -> SBool
llt SBV a
pivot SList a
xs) (StepArgs
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
Bool
-> TP
(Proof
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)))
-> StepArgs
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
Bool
-> TP
(Proof
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool))
forall a b. (a -> b) -> a -> b
$
\SList a
xs SBV a
pivot SList a
ys -> [SBV a -> SList a -> SBool
llt SBV a
pivot SList a
ys, SList a -> SList a -> SBool
isPermutation SList a
xs SList a
ys]
[SBool] -> TPProofRaw SBool -> (SBool, TPProofRaw SBool)
forall a. [SBool] -> TPProofRaw a -> (SBool, TPProofRaw a)
|- SBV a -> SList a -> SBool
llt SBV a
pivot SList a
xs
SBool -> Proof Bool -> Hinted SBool
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
lltSublist Proof
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
-> IArgs
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
-> Proof Bool
forall a. Instantiatable a => Proof a -> IArgs a -> Proof Bool
`at` (forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"xs" SList a
xs, forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"pivot" SBV a
pivot, forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"ys" SList a
ys)
TPProofRaw SBool -> Proof Bool -> Hinted (TPProofRaw SBool)
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof (Forall "xs" [a] -> Forall "ys" [a] -> SBool)
sublistIfPerm Proof (Forall "xs" [a] -> Forall "ys" [a] -> SBool)
-> IArgs (Forall "xs" [a] -> Forall "ys" [a] -> SBool)
-> Proof Bool
forall a. Instantiatable a => Proof a -> IArgs a -> Proof Bool
`at` (forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"xs" SList a
xs, forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"ys" SList a
ys)
Hinted (TPProofRaw SBool)
-> ChainsTo (Hinted (TPProofRaw SBool))
-> ChainsTo (Hinted (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
Proof
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
lgeSublist <-
SMTConfig
-> String
-> (Forall "xs" [a]
-> Forall "pivot" a -> Forall "ys" [a] -> SBool)
-> (Proof
(IHType
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool))
-> IHArg
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
-> IStepArgs
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
Bool)
-> TP
(Proof
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool))
forall t.
(Proposition
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool),
SymVal t, EqSymbolic (SBV t)) =>
SMTConfig
-> String
-> (Forall "xs" [a]
-> Forall "pivot" a -> Forall "ys" [a] -> SBool)
-> (Proof
(IHType
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool))
-> IHArg
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
-> IStepArgs
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
t)
-> TP
(Proof
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> 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
"lgeSublist"
(\(Forall SList a
xs) (Forall SBV a
pivot) (Forall SList a
ys) -> SBV a -> SList a -> SBool
lge SBV a
pivot SList a
ys SBool -> SBool -> SBool
.&& SList a
xs SList a -> SList a -> SBool
`sublist` SList a
ys SBool -> SBool -> SBool
.=> SBV a -> SList a -> SBool
lge SBV a
pivot SList a
xs) ((Proof
(IHType
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool))
-> IHArg
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
-> IStepArgs
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
Bool)
-> TP
(Proof
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)))
-> (Proof
(IHType
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool))
-> IHArg
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
-> IStepArgs
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
Bool)
-> TP
(Proof
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool))
forall a b. (a -> b) -> a -> b
$
\Proof
(IHType
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool))
ih (SBV a
x, SList a
xs) SBV a
pivot SList a
ys -> [SBV a -> SList a -> SBool
lge SBV a
pivot SList a
ys, (SBV a
x SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: SList a
xs) SList a -> SList a -> SBool
`sublist` SList a
ys]
[SBool] -> TPProofRaw SBool -> (SBool, TPProofRaw SBool)
forall a. [SBool] -> TPProofRaw a -> (SBool, TPProofRaw a)
|- SBV a -> SList a -> SBool
lge SBV a
pivot (SBV a
x SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: SList a
xs)
SBool -> ChainsTo SBool -> ChainsTo SBool
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SBV a
x SBV a -> SBV a -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.>= SBV a
pivot SBool -> SBool -> SBool
.&& SBV a -> SList a -> SBool
lge SBV a
pivot SList a
xs
SBool -> Proof Bool -> Hinted SBool
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof (Forall "x" a -> Forall "xs" [a] -> Forall "ys" [a] -> SBool)
sublistElem Proof (Forall "x" a -> Forall "xs" [a] -> Forall "ys" [a] -> SBool)
-> IArgs
(Forall "x" a -> Forall "xs" [a] -> Forall "ys" [a] -> 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" SBV a
x, forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"xs" SList a
xs, forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"ys" SList a
ys)
TPProofRaw SBool -> Proof Bool -> Hinted (TPProofRaw SBool)
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool)
lgeCorrect Proof
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool)
-> IArgs
(Forall "xs" [a] -> Forall "e" a -> Forall "pivot" a -> SBool)
-> Proof Bool
forall a. Instantiatable a => Proof a -> IArgs a -> Proof Bool
`at` (forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"xs" SList a
ys, forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"e" SBV a
x, forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"pivot" SBV a
pivot)
Hinted (TPProofRaw SBool)
-> Proof Bool -> Hinted (Hinted (TPProofRaw SBool))
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof (Forall "x" a -> Forall "xs" [a] -> Forall "ys" [a] -> SBool)
sublistTail Proof (Forall "x" a -> Forall "xs" [a] -> Forall "ys" [a] -> SBool)
-> IArgs
(Forall "x" a -> Forall "xs" [a] -> Forall "ys" [a] -> 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" SBV a
x, forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"xs" SList a
xs, forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"ys" SList a
ys)
Hinted (Hinted (TPProofRaw SBool))
-> Proof Bool -> Hinted (Hinted (Hinted (TPProofRaw SBool)))
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof
(IHType
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool))
Proof (Forall "pivot" a -> Forall "ys" [a] -> SBool)
ih Proof (Forall "pivot" a -> Forall "ys" [a] -> SBool)
-> IArgs (Forall "pivot" a -> Forall "ys" [a] -> SBool)
-> Proof Bool
forall a. Instantiatable a => Proof a -> IArgs a -> Proof Bool
`at` (forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"pivot" SBV a
pivot, forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"ys" SList a
ys)
Hinted (Hinted (Hinted (TPProofRaw SBool)))
-> ChainsTo (Hinted (Hinted (Hinted (TPProofRaw SBool))))
-> ChainsTo (Hinted (Hinted (Hinted (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
Proof
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
lgePermutation <-
String
-> (Forall "xs" [a]
-> Forall "pivot" a -> Forall "ys" [a] -> SBool)
-> StepArgs
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
Bool
-> TP
(Proof
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool))
forall t.
(Proposition
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool),
SymVal t, EqSymbolic (SBV t)) =>
String
-> (Forall "xs" [a]
-> Forall "pivot" a -> Forall "ys" [a] -> SBool)
-> StepArgs
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool) t
-> TP
(Proof
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool))
forall a t.
(Calc a, Proposition a, SymVal t, EqSymbolic (SBV t)) =>
String -> a -> StepArgs a t -> TP (Proof a)
calc String
"lgePermutation"
(\(Forall SList a
xs) (Forall SBV a
pivot) (Forall SList a
ys) -> SBV a -> SList a -> SBool
lge SBV a
pivot SList a
ys SBool -> SBool -> SBool
.&& SList a -> SList a -> SBool
isPermutation SList a
xs SList a
ys SBool -> SBool -> SBool
.=> SBV a -> SList a -> SBool
lge SBV a
pivot SList a
xs) (StepArgs
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
Bool
-> TP
(Proof
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)))
-> StepArgs
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
Bool
-> TP
(Proof
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool))
forall a b. (a -> b) -> a -> b
$
\SList a
xs SBV a
pivot SList a
ys -> [SBV a -> SList a -> SBool
lge SBV a
pivot SList a
ys, SList a -> SList a -> SBool
isPermutation SList a
xs SList a
ys]
[SBool] -> TPProofRaw SBool -> (SBool, TPProofRaw SBool)
forall a. [SBool] -> TPProofRaw a -> (SBool, TPProofRaw a)
|- SBV a -> SList a -> SBool
lge SBV a
pivot SList a
xs
SBool -> Proof Bool -> Hinted SBool
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
lgeSublist Proof
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
-> IArgs
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
-> Proof Bool
forall a. Instantiatable a => Proof a -> IArgs a -> Proof Bool
`at` (forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"xs" SList a
xs, forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"pivot" SBV a
pivot, forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"ys" SList a
ys)
TPProofRaw SBool -> Proof Bool -> Hinted (TPProofRaw SBool)
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof (Forall "xs" [a] -> Forall "ys" [a] -> SBool)
sublistIfPerm Proof (Forall "xs" [a] -> Forall "ys" [a] -> SBool)
-> IArgs (Forall "xs" [a] -> Forall "ys" [a] -> SBool)
-> Proof Bool
forall a. Instantiatable a => Proof a -> IArgs a -> Proof Bool
`at` (forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"xs" SList a
xs, forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"ys" SList a
ys)
Hinted (TPProofRaw SBool)
-> ChainsTo (Hinted (TPProofRaw SBool))
-> ChainsTo (Hinted (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
Proof (Forall "l" [a] -> Forall "pivot" a -> SBool)
partitionFstLT <- SMTConfig
-> String
-> (Forall "l" [a] -> Forall "pivot" a -> SBool)
-> (Proof (IHType (Forall "l" [a] -> Forall "pivot" a -> SBool))
-> IHArg (Forall "l" [a] -> Forall "pivot" a -> SBool)
-> IStepArgs (Forall "l" [a] -> Forall "pivot" a -> SBool) Bool)
-> TP (Proof (Forall "l" [a] -> Forall "pivot" a -> SBool))
forall t.
(Proposition (Forall "l" [a] -> Forall "pivot" a -> SBool),
SymVal t, EqSymbolic (SBV t)) =>
SMTConfig
-> String
-> (Forall "l" [a] -> Forall "pivot" a -> SBool)
-> (Proof (IHType (Forall "l" [a] -> Forall "pivot" a -> SBool))
-> IHArg (Forall "l" [a] -> Forall "pivot" a -> SBool)
-> IStepArgs (Forall "l" [a] -> Forall "pivot" a -> SBool) t)
-> TP (Proof (Forall "l" [a] -> Forall "pivot" a -> 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
"partitionFstLT"
(\(Forall SList a
l) (Forall SBV a
pivot) -> SBV a -> SList a -> SBool
llt SBV a
pivot (STuple [a] [a] -> SList a
forall a b. (SymVal a, SymVal b) => STuple a b -> SBV a
fst (SBV a -> SList a -> STuple [a] [a]
forall a. (Ord a, SymVal a) => SBV a -> SList a -> STuple [a] [a]
partition SBV a
pivot SList a
l))) ((Proof (IHType (Forall "l" [a] -> Forall "pivot" a -> SBool))
-> IHArg (Forall "l" [a] -> Forall "pivot" a -> SBool)
-> IStepArgs (Forall "l" [a] -> Forall "pivot" a -> SBool) Bool)
-> TP (Proof (Forall "l" [a] -> Forall "pivot" a -> SBool)))
-> (Proof (IHType (Forall "l" [a] -> Forall "pivot" a -> SBool))
-> IHArg (Forall "l" [a] -> Forall "pivot" a -> SBool)
-> IStepArgs (Forall "l" [a] -> Forall "pivot" a -> SBool) Bool)
-> TP (Proof (Forall "l" [a] -> Forall "pivot" a -> SBool))
forall a b. (a -> b) -> a -> b
$
\Proof (IHType (Forall "l" [a] -> Forall "pivot" a -> SBool))
ih (SBV a
a, SList a
as) SBV a
pivot -> [] [SBool] -> TPProofRaw SBool -> (SBool, TPProofRaw SBool)
forall a. [SBool] -> TPProofRaw a -> (SBool, TPProofRaw a)
|- SBV a -> SList a -> SBool
llt SBV a
pivot (STuple [a] [a] -> SList a
forall a b. (SymVal a, SymVal b) => STuple a b -> SBV a
fst (SBV a -> SList a -> STuple [a] [a]
forall a. (Ord a, SymVal a) => SBV a -> SList a -> STuple [a] [a]
partition SBV a
pivot (SBV a
a SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: SList a
as)))
SBool -> ChainsTo SBool -> ChainsTo SBool
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SBV a -> SList a -> SBool
llt SBV a
pivot (SBool -> SList a -> SList a -> SList a
forall a. Mergeable a => SBool -> a -> a -> a
ite (SBV a
a SBV a -> SBV a -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.< SBV a
pivot)
(SBV a
a SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: STuple [a] [a] -> SList a
forall a b. (SymVal a, SymVal b) => STuple a b -> SBV a
fst (SBV a -> SList a -> STuple [a] [a]
forall a. (Ord a, SymVal a) => SBV a -> SList a -> STuple [a] [a]
partition SBV a
pivot SList a
as))
( STuple [a] [a] -> SList a
forall a b. (SymVal a, SymVal b) => STuple a b -> SBV a
fst (SBV a -> SList a -> STuple [a] [a]
forall a. (Ord a, SymVal a) => SBV a -> SList a -> STuple [a] [a]
partition SBV a
pivot SList a
as)))
SBool -> String -> Hinted SBool
forall a b. HintsTo a b => a -> b -> Hinted a
?? String
"push llt down"
TPProofRaw SBool
-> ChainsTo (TPProofRaw SBool) -> ChainsTo (TPProofRaw SBool)
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SBool -> SBool -> SBool -> SBool
forall a. Mergeable a => SBool -> a -> a -> a
ite (SBV a
a SBV a -> SBV a -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.< SBV a
pivot)
(SBV a
a SBV a -> SBV a -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.< SBV a
pivot SBool -> SBool -> SBool
.&& SBV a -> SList a -> SBool
llt SBV a
pivot (STuple [a] [a] -> SList a
forall a b. (SymVal a, SymVal b) => STuple a b -> SBV a
fst (SBV a -> SList a -> STuple [a] [a]
forall a. (Ord a, SymVal a) => SBV a -> SList a -> STuple [a] [a]
partition SBV a
pivot SList a
as)))
( SBV a -> SList a -> SBool
llt SBV a
pivot (STuple [a] [a] -> SList a
forall a b. (SymVal a, SymVal b) => STuple a b -> SBV a
fst (SBV a -> SList a -> STuple [a] [a]
forall a. (Ord a, SymVal a) => SBV a -> SList a -> STuple [a] [a]
partition SBV a
pivot SList a
as)))
SBool -> Proof (Forall "pivot" a -> SBool) -> Hinted SBool
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof (IHType (Forall "l" [a] -> Forall "pivot" a -> SBool))
Proof (Forall "pivot" a -> 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
Proof (Forall "l" [a] -> Forall "pivot" a -> SBool)
partitionSndGE <- SMTConfig
-> String
-> (Forall "l" [a] -> Forall "pivot" a -> SBool)
-> (Proof (IHType (Forall "l" [a] -> Forall "pivot" a -> SBool))
-> IHArg (Forall "l" [a] -> Forall "pivot" a -> SBool)
-> IStepArgs (Forall "l" [a] -> Forall "pivot" a -> SBool) Bool)
-> TP (Proof (Forall "l" [a] -> Forall "pivot" a -> SBool))
forall t.
(Proposition (Forall "l" [a] -> Forall "pivot" a -> SBool),
SymVal t, EqSymbolic (SBV t)) =>
SMTConfig
-> String
-> (Forall "l" [a] -> Forall "pivot" a -> SBool)
-> (Proof (IHType (Forall "l" [a] -> Forall "pivot" a -> SBool))
-> IHArg (Forall "l" [a] -> Forall "pivot" a -> SBool)
-> IStepArgs (Forall "l" [a] -> Forall "pivot" a -> SBool) t)
-> TP (Proof (Forall "l" [a] -> Forall "pivot" a -> 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
"partitionSndGE"
(\(Forall SList a
l) (Forall SBV a
pivot) -> SBV a -> SList a -> SBool
lge SBV a
pivot (STuple [a] [a] -> SList a
forall a b. (SymVal a, SymVal b) => STuple a b -> SBV b
snd (SBV a -> SList a -> STuple [a] [a]
forall a. (Ord a, SymVal a) => SBV a -> SList a -> STuple [a] [a]
partition SBV a
pivot SList a
l))) ((Proof (IHType (Forall "l" [a] -> Forall "pivot" a -> SBool))
-> IHArg (Forall "l" [a] -> Forall "pivot" a -> SBool)
-> IStepArgs (Forall "l" [a] -> Forall "pivot" a -> SBool) Bool)
-> TP (Proof (Forall "l" [a] -> Forall "pivot" a -> SBool)))
-> (Proof (IHType (Forall "l" [a] -> Forall "pivot" a -> SBool))
-> IHArg (Forall "l" [a] -> Forall "pivot" a -> SBool)
-> IStepArgs (Forall "l" [a] -> Forall "pivot" a -> SBool) Bool)
-> TP (Proof (Forall "l" [a] -> Forall "pivot" a -> SBool))
forall a b. (a -> b) -> a -> b
$
\Proof (IHType (Forall "l" [a] -> Forall "pivot" a -> SBool))
ih (SBV a
a, SList a
as) SBV a
pivot -> [] [SBool] -> TPProofRaw SBool -> (SBool, TPProofRaw SBool)
forall a. [SBool] -> TPProofRaw a -> (SBool, TPProofRaw a)
|- SBV a -> SList a -> SBool
lge SBV a
pivot (STuple [a] [a] -> SList a
forall a b. (SymVal a, SymVal b) => STuple a b -> SBV b
snd (SBV a -> SList a -> STuple [a] [a]
forall a. (Ord a, SymVal a) => SBV a -> SList a -> STuple [a] [a]
partition SBV a
pivot (SBV a
a SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: SList a
as)))
SBool -> ChainsTo SBool -> ChainsTo SBool
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SBV a -> SList a -> SBool
lge SBV a
pivot (SBool -> SList a -> SList a -> SList a
forall a. Mergeable a => SBool -> a -> a -> a
ite (SBV a
a SBV a -> SBV a -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.< SBV a
pivot)
( STuple [a] [a] -> SList a
forall a b. (SymVal a, SymVal b) => STuple a b -> SBV b
snd (SBV a -> SList a -> STuple [a] [a]
forall a. (Ord a, SymVal a) => SBV a -> SList a -> STuple [a] [a]
partition SBV a
pivot SList a
as))
(SBV a
a SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: STuple [a] [a] -> SList a
forall a b. (SymVal a, SymVal b) => STuple a b -> SBV b
snd (SBV a -> SList a -> STuple [a] [a]
forall a. (Ord a, SymVal a) => SBV a -> SList a -> STuple [a] [a]
partition SBV a
pivot SList a
as)))
SBool -> String -> Hinted SBool
forall a b. HintsTo a b => a -> b -> Hinted a
?? String
"push lge down"
TPProofRaw SBool
-> ChainsTo (TPProofRaw SBool) -> ChainsTo (TPProofRaw SBool)
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SBool -> SBool -> SBool -> SBool
forall a. Mergeable a => SBool -> a -> a -> a
ite (SBV a
a SBV a -> SBV a -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.< SBV a
pivot)
(SBV a
a SBV a -> SBV a -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.< SBV a
pivot SBool -> SBool -> SBool
.&& SBV a -> SList a -> SBool
lge SBV a
pivot (STuple [a] [a] -> SList a
forall a b. (SymVal a, SymVal b) => STuple a b -> SBV b
snd (SBV a -> SList a -> STuple [a] [a]
forall a. (Ord a, SymVal a) => SBV a -> SList a -> STuple [a] [a]
partition SBV a
pivot SList a
as)))
( SBV a -> SList a -> SBool
lge SBV a
pivot (STuple [a] [a] -> SList a
forall a b. (SymVal a, SymVal b) => STuple a b -> SBV b
snd (SBV a -> SList a -> STuple [a] [a]
forall a. (Ord a, SymVal a) => SBV a -> SList a -> STuple [a] [a]
partition SBV a
pivot SList a
as)))
SBool -> Proof (Forall "pivot" a -> SBool) -> Hinted SBool
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof (IHType (Forall "l" [a] -> Forall "pivot" a -> SBool))
Proof (Forall "pivot" a -> 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
Proof (Forall "l" [a] -> Forall "pivot" a -> SBool)
partitionNotLongerFst <- String
-> (Forall "l" [a] -> Forall "pivot" a -> SBool)
-> MeasureArgs
(Forall "l" [a] -> Forall "pivot" a -> SBool) Integer
-> (Proof (Forall "l" [a] -> Forall "pivot" a -> SBool)
-> StepArgs (Forall "l" [a] -> Forall "pivot" a -> SBool) Bool)
-> TP (Proof (Forall "l" [a] -> Forall "pivot" a -> SBool))
forall a m t.
(SInductive a, Proposition a, Zero m, SymVal t,
EqSymbolic (SBV t)) =>
String
-> a
-> MeasureArgs a m
-> (Proof a -> StepArgs a t)
-> TP (Proof a)
forall m t.
(Proposition (Forall "l" [a] -> Forall "pivot" a -> SBool), Zero m,
SymVal t, EqSymbolic (SBV t)) =>
String
-> (Forall "l" [a] -> Forall "pivot" a -> SBool)
-> MeasureArgs (Forall "l" [a] -> Forall "pivot" a -> SBool) m
-> (Proof (Forall "l" [a] -> Forall "pivot" a -> SBool)
-> StepArgs (Forall "l" [a] -> Forall "pivot" a -> SBool) t)
-> TP (Proof (Forall "l" [a] -> Forall "pivot" a -> SBool))
sInduct String
"partitionNotLongerFst"
(\(Forall SList a
l) (Forall SBV a
pivot) -> SList a -> SInteger
forall a. SymVal a => SList a -> SInteger
length (STuple [a] [a] -> SList a
forall a b. (SymVal a, SymVal b) => STuple a b -> SBV a
fst (forall a. (Ord a, SymVal a) => SBV a -> SList a -> STuple [a] [a]
partition @a SBV a
pivot SList a
l)) SInteger -> SInteger -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.<= SList a -> SInteger
forall a. SymVal a => SList a -> SInteger
length SList a
l)
(\SList a
l SBV a
_ -> SList a -> SInteger
forall a. SymVal a => SList a -> SInteger
length SList a
l) ((Proof (Forall "l" [a] -> Forall "pivot" a -> SBool)
-> StepArgs (Forall "l" [a] -> Forall "pivot" a -> SBool) Bool)
-> TP (Proof (Forall "l" [a] -> Forall "pivot" a -> SBool)))
-> (Proof (Forall "l" [a] -> Forall "pivot" a -> SBool)
-> StepArgs (Forall "l" [a] -> Forall "pivot" a -> SBool) Bool)
-> TP (Proof (Forall "l" [a] -> Forall "pivot" a -> SBool))
forall a b. (a -> b) -> a -> b
$
\Proof (Forall "l" [a] -> Forall "pivot" a -> SBool)
ih SList a
l SBV a
pivot -> [] [SBool] -> TPProofRaw SBool -> (SBool, TPProofRaw SBool)
forall a. [SBool] -> TPProofRaw a -> (SBool, TPProofRaw a)
|- SList a -> SInteger
forall a. SymVal a => SList a -> SInteger
length (STuple [a] [a] -> SList a
forall a b. (SymVal a, SymVal b) => STuple a b -> SBV a
fst (forall a. (Ord a, SymVal a) => SBV a -> SList a -> STuple [a] [a]
partition @a SBV a
pivot SList a
l)) SInteger -> SInteger -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.<= SList a -> SInteger
forall a. SymVal a => SList a -> SInteger
length SList a
l
SBool -> ChainsTo SBool -> ChainsTo SBool
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SList a
-> TPProofRaw SBool
-> (SBV a -> SList a -> TPProofRaw SBool)
-> TPProofRaw SBool
forall a r.
SymVal a =>
SList a
-> TPProofRaw r
-> (SBV a -> SList a -> TPProofRaw r)
-> TPProofRaw r
split SList a
l TPProofRaw SBool
forall a. Trivial a => a
trivial
(\SBV a
a SList a
as -> let lo :: SList a
lo = STuple [a] [a] -> SList a
forall a b. (SymVal a, SymVal b) => STuple a b -> SBV a
fst (SBV a -> SList a -> STuple [a] [a]
forall a. (Ord a, SymVal a) => SBV a -> SList a -> STuple [a] [a]
partition SBV a
pivot SList a
as)
in SBool -> SBool -> SBool -> SBool
forall a. Mergeable a => SBool -> a -> a -> a
ite (SBV a
a SBV a -> SBV a -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.< SBV a
pivot)
(SList a -> SInteger
forall a. SymVal a => SList a -> SInteger
length (SBV a
a SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: SList a
lo) SInteger -> SInteger -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.<= SList a -> SInteger
forall a. SymVal a => SList a -> SInteger
length (SBV a
a SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: SList a
as))
(SList a -> SInteger
forall a. SymVal a => SList a -> SInteger
length SList a
lo SInteger -> SInteger -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.<= SList a -> SInteger
forall a. SymVal a => SList a -> SInteger
length (SBV a
a SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: SList a
as))
SBool -> String -> Hinted SBool
forall a b. HintsTo a b => a -> b -> Hinted a
?? String
"simplify"
TPProofRaw SBool
-> ChainsTo (TPProofRaw SBool) -> ChainsTo (TPProofRaw SBool)
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SBool -> SBool -> SBool -> SBool
forall a. Mergeable a => SBool -> a -> a -> a
ite (SBV a
a SBV a -> SBV a -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.< SBV a
pivot)
(SList a -> SInteger
forall a. SymVal a => SList a -> SInteger
length SList a
lo SInteger -> SInteger -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.<= SList a -> SInteger
forall a. SymVal a => SList a -> SInteger
length SList a
as)
(SList a -> SInteger
forall a. SymVal a => SList a -> SInteger
length SList a
lo SInteger -> SInteger -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.<= SInteger
1 SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+ SList a -> SInteger
forall a. SymVal a => SList a -> SInteger
length SList a
as)
SBool -> Proof Bool -> Hinted SBool
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof (Forall "l" [a] -> Forall "pivot" a -> SBool)
ih Proof (Forall "l" [a] -> Forall "pivot" a -> SBool)
-> IArgs (Forall "l" [a] -> Forall "pivot" a -> SBool)
-> Proof Bool
forall a. Instantiatable a => Proof a -> IArgs a -> Proof Bool
`at` (forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"l" SList a
as, forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"pivot" SBV a
pivot)
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)
Proof (Forall "l" [a] -> Forall "pivot" a -> SBool)
partitionNotLongerSnd <- String
-> (Forall "l" [a] -> Forall "pivot" a -> SBool)
-> MeasureArgs
(Forall "l" [a] -> Forall "pivot" a -> SBool) Integer
-> (Proof (Forall "l" [a] -> Forall "pivot" a -> SBool)
-> StepArgs (Forall "l" [a] -> Forall "pivot" a -> SBool) Bool)
-> TP (Proof (Forall "l" [a] -> Forall "pivot" a -> SBool))
forall a m t.
(SInductive a, Proposition a, Zero m, SymVal t,
EqSymbolic (SBV t)) =>
String
-> a
-> MeasureArgs a m
-> (Proof a -> StepArgs a t)
-> TP (Proof a)
forall m t.
(Proposition (Forall "l" [a] -> Forall "pivot" a -> SBool), Zero m,
SymVal t, EqSymbolic (SBV t)) =>
String
-> (Forall "l" [a] -> Forall "pivot" a -> SBool)
-> MeasureArgs (Forall "l" [a] -> Forall "pivot" a -> SBool) m
-> (Proof (Forall "l" [a] -> Forall "pivot" a -> SBool)
-> StepArgs (Forall "l" [a] -> Forall "pivot" a -> SBool) t)
-> TP (Proof (Forall "l" [a] -> Forall "pivot" a -> SBool))
sInduct String
"partitionNotLongerSnd"
(\(Forall SList a
l) (Forall SBV a
pivot) -> SList a -> SInteger
forall a. SymVal a => SList a -> SInteger
length (STuple [a] [a] -> SList a
forall a b. (SymVal a, SymVal b) => STuple a b -> SBV b
snd (forall a. (Ord a, SymVal a) => SBV a -> SList a -> STuple [a] [a]
partition @a SBV a
pivot SList a
l)) SInteger -> SInteger -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.<= SList a -> SInteger
forall a. SymVal a => SList a -> SInteger
length SList a
l)
(\SList a
l SBV a
_ -> SList a -> SInteger
forall a. SymVal a => SList a -> SInteger
length SList a
l) ((Proof (Forall "l" [a] -> Forall "pivot" a -> SBool)
-> StepArgs (Forall "l" [a] -> Forall "pivot" a -> SBool) Bool)
-> TP (Proof (Forall "l" [a] -> Forall "pivot" a -> SBool)))
-> (Proof (Forall "l" [a] -> Forall "pivot" a -> SBool)
-> StepArgs (Forall "l" [a] -> Forall "pivot" a -> SBool) Bool)
-> TP (Proof (Forall "l" [a] -> Forall "pivot" a -> SBool))
forall a b. (a -> b) -> a -> b
$
\Proof (Forall "l" [a] -> Forall "pivot" a -> SBool)
ih SList a
l SBV a
pivot -> [] [SBool] -> TPProofRaw SBool -> (SBool, TPProofRaw SBool)
forall a. [SBool] -> TPProofRaw a -> (SBool, TPProofRaw a)
|- SList a -> SInteger
forall a. SymVal a => SList a -> SInteger
length (STuple [a] [a] -> SList a
forall a b. (SymVal a, SymVal b) => STuple a b -> SBV b
snd (forall a. (Ord a, SymVal a) => SBV a -> SList a -> STuple [a] [a]
partition @a SBV a
pivot SList a
l)) SInteger -> SInteger -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.<= SList a -> SInteger
forall a. SymVal a => SList a -> SInteger
length SList a
l
SBool -> ChainsTo SBool -> ChainsTo SBool
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SList a
-> TPProofRaw SBool
-> (SBV a -> SList a -> TPProofRaw SBool)
-> TPProofRaw SBool
forall a r.
SymVal a =>
SList a
-> TPProofRaw r
-> (SBV a -> SList a -> TPProofRaw r)
-> TPProofRaw r
split SList a
l TPProofRaw SBool
forall a. Trivial a => a
trivial
(\SBV a
a SList a
as -> let hi :: SList a
hi = STuple [a] [a] -> SList a
forall a b. (SymVal a, SymVal b) => STuple a b -> SBV b
snd (SBV a -> SList a -> STuple [a] [a]
forall a. (Ord a, SymVal a) => SBV a -> SList a -> STuple [a] [a]
partition SBV a
pivot SList a
as)
in SBool -> SBool -> SBool -> SBool
forall a. Mergeable a => SBool -> a -> a -> a
ite (SBV a
a SBV a -> SBV a -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.< SBV a
pivot)
(SList a -> SInteger
forall a. SymVal a => SList a -> SInteger
length SList a
hi SInteger -> SInteger -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.<= SList a -> SInteger
forall a. SymVal a => SList a -> SInteger
length (SBV a
a SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: SList a
as))
(SList a -> SInteger
forall a. SymVal a => SList a -> SInteger
length (SBV a
a SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: SList a
hi) SInteger -> SInteger -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.<= SList a -> SInteger
forall a. SymVal a => SList a -> SInteger
length (SBV a
a SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: SList a
as))
SBool -> String -> Hinted SBool
forall a b. HintsTo a b => a -> b -> Hinted a
?? String
"simplify"
TPProofRaw SBool
-> ChainsTo (TPProofRaw SBool) -> ChainsTo (TPProofRaw SBool)
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SBool -> SBool -> SBool -> SBool
forall a. Mergeable a => SBool -> a -> a -> a
ite (SBV a
a SBV a -> SBV a -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.< SBV a
pivot)
(SList a -> SInteger
forall a. SymVal a => SList a -> SInteger
length SList a
hi SInteger -> SInteger -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.<= SInteger
1 SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+ SList a -> SInteger
forall a. SymVal a => SList a -> SInteger
length SList a
as)
(SList a -> SInteger
forall a. SymVal a => SList a -> SInteger
length SList a
hi SInteger -> SInteger -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.<= SList a -> SInteger
forall a. SymVal a => SList a -> SInteger
length SList a
as)
SBool -> Proof Bool -> Hinted SBool
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof (Forall "l" [a] -> Forall "pivot" a -> SBool)
ih Proof (Forall "l" [a] -> Forall "pivot" a -> SBool)
-> IArgs (Forall "l" [a] -> Forall "pivot" a -> SBool)
-> Proof Bool
forall a. Instantiatable a => Proof a -> IArgs a -> Proof Bool
`at` (forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"l" SList a
as, forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"pivot" SBV a
pivot)
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)
let countTuple :: SBV a -> STuple [a] [a] -> SInteger
countTuple :: SBV a -> STuple [a] [a] -> SInteger
countTuple SBV a
e STuple [a] [a]
xsys = SBV a -> SList a -> SInteger
count SBV a
e SList a
xs SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+ SBV a -> SList a -> SInteger
count SBV a
e SList a
ys
where (SList a
xs, SList a
ys) = STuple [a] [a] -> (SList a, SList a)
forall tup a. Tuple tup a => SBV tup -> a
untuple STuple [a] [a]
xsys
Proof
(Forall "xs" [a] -> Forall "pivot" a -> Forall "e" a -> SBool)
countPartition <-
String
-> (Forall "xs" [a] -> Forall "pivot" a -> Forall "e" a -> SBool)
-> (Proof
(IHType
(Forall "xs" [a] -> Forall "pivot" a -> Forall "e" a -> SBool))
-> IHArg
(Forall "xs" [a] -> Forall "pivot" a -> Forall "e" a -> SBool)
-> IStepArgs
(Forall "xs" [a] -> Forall "pivot" a -> Forall "e" a -> SBool)
Integer)
-> TP
(Proof
(Forall "xs" [a] -> Forall "pivot" a -> Forall "e" a -> SBool))
forall t.
(Proposition
(Forall "xs" [a] -> Forall "pivot" a -> Forall "e" a -> SBool),
SymVal t, EqSymbolic (SBV t)) =>
String
-> (Forall "xs" [a] -> Forall "pivot" a -> Forall "e" a -> SBool)
-> (Proof
(IHType
(Forall "xs" [a] -> Forall "pivot" a -> Forall "e" a -> SBool))
-> IHArg
(Forall "xs" [a] -> Forall "pivot" a -> Forall "e" a -> SBool)
-> IStepArgs
(Forall "xs" [a] -> Forall "pivot" a -> Forall "e" a -> SBool) t)
-> TP
(Proof
(Forall "xs" [a] -> Forall "pivot" a -> Forall "e" a -> 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
"countPartition"
(\(Forall SList a
xs) (Forall SBV a
pivot) (Forall SBV a
e) -> SBV a -> STuple [a] [a] -> SInteger
countTuple SBV a
e (SBV a -> SList a -> STuple [a] [a]
forall a. (Ord a, SymVal a) => SBV a -> SList a -> STuple [a] [a]
partition SBV a
pivot SList a
xs) SInteger -> SInteger -> SBool
forall a. EqSymbolic a => a -> a -> SBool
.== SBV a -> SList a -> SInteger
count SBV a
e SList a
xs) ((Proof
(IHType
(Forall "xs" [a] -> Forall "pivot" a -> Forall "e" a -> SBool))
-> IHArg
(Forall "xs" [a] -> Forall "pivot" a -> Forall "e" a -> SBool)
-> IStepArgs
(Forall "xs" [a] -> Forall "pivot" a -> Forall "e" a -> SBool)
Integer)
-> TP
(Proof
(Forall "xs" [a] -> Forall "pivot" a -> Forall "e" a -> SBool)))
-> (Proof
(IHType
(Forall "xs" [a] -> Forall "pivot" a -> Forall "e" a -> SBool))
-> IHArg
(Forall "xs" [a] -> Forall "pivot" a -> Forall "e" a -> SBool)
-> IStepArgs
(Forall "xs" [a] -> Forall "pivot" a -> Forall "e" a -> SBool)
Integer)
-> TP
(Proof
(Forall "xs" [a] -> Forall "pivot" a -> Forall "e" a -> SBool))
forall a b. (a -> b) -> a -> b
$
\Proof
(IHType
(Forall "xs" [a] -> Forall "pivot" a -> Forall "e" a -> SBool))
ih (SBV a
a, SList a
as) SBV a
pivot SBV a
e ->
[] [SBool] -> TPProofRaw SInteger -> (SBool, TPProofRaw SInteger)
forall a. [SBool] -> TPProofRaw a -> (SBool, TPProofRaw a)
|- SBV a -> STuple [a] [a] -> SInteger
countTuple SBV a
e (SBV a -> SList a -> STuple [a] [a]
forall a. (Ord a, SymVal a) => SBV a -> SList a -> STuple [a] [a]
partition SBV a
pivot (SBV a
a SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: SList a
as))
SInteger -> String -> Hinted SInteger
forall a b. HintsTo a b => a -> b -> Hinted a
?? String
"expand partition"
TPProofRaw SInteger
-> ChainsTo (TPProofRaw SInteger) -> ChainsTo (TPProofRaw SInteger)
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SBV a -> STuple [a] [a] -> SInteger
countTuple SBV a
e (let (SList a
lo, SList a
hi) = STuple [a] [a] -> (SList a, SList a)
forall tup a. Tuple tup a => SBV tup -> a
untuple (SBV a -> SList a -> STuple [a] [a]
forall a. (Ord a, SymVal a) => SBV a -> SList a -> STuple [a] [a]
partition SBV a
pivot SList a
as)
in SBool -> STuple [a] [a] -> STuple [a] [a] -> STuple [a] [a]
forall a. Mergeable a => SBool -> a -> a -> a
ite (SBV a
a SBV a -> SBV a -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.< SBV a
pivot)
((SList a, SList a) -> STuple [a] [a]
forall tup a. Tuple tup a => a -> SBV tup
tuple (SBV a
a SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: SList a
lo, SList a
hi))
((SList a, SList a) -> STuple [a] [a]
forall tup a. Tuple tup a => a -> SBV tup
tuple (SList a
lo, SBV a
a SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: SList a
hi)))
SInteger -> String -> Hinted SInteger
forall a b. HintsTo a b => a -> b -> Hinted a
?? String
"push countTuple down"
TPProofRaw SInteger
-> ChainsTo (TPProofRaw SInteger) -> ChainsTo (TPProofRaw SInteger)
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: let (SList a
lo, SList a
hi) = STuple [a] [a] -> (SList a, SList a)
forall tup a. Tuple tup a => SBV tup -> a
untuple (SBV a -> SList a -> STuple [a] [a]
forall a. (Ord a, SymVal a) => SBV a -> SList a -> STuple [a] [a]
partition SBV a
pivot SList a
as)
in SBool -> SInteger -> SInteger -> SInteger
forall a. Mergeable a => SBool -> a -> a -> a
ite (SBV a
a SBV a -> SBV a -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.< SBV a
pivot)
(SBV a -> SList a -> SInteger
count SBV a
e (SBV a
a SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: SList a
lo) SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+ SBV a -> SList a -> SInteger
count SBV a
e SList a
hi)
(SBV a -> SList a -> SInteger
count SBV a
e SList a
lo SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+ SBV a -> SList a -> SInteger
count SBV a
e (SBV a
a SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: SList a
hi))
SInteger -> ChainsTo SInteger -> ChainsTo SInteger
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: [(SBool, TPProofRaw SInteger)] -> TPProofRaw SInteger
forall a. [(SBool, TPProofRaw a)] -> TPProofRaw a
cases [SBV a
e SBV a -> SBV a -> SBool
forall a. EqSymbolic a => a -> a -> SBool
.== SBV a
a SBool -> TPProofRaw SInteger -> (SBool, TPProofRaw SInteger)
forall a. SBool -> TPProofRaw a -> (SBool, TPProofRaw a)
==> SBool -> SInteger -> SInteger -> SInteger
forall a. Mergeable a => SBool -> a -> a -> a
ite (SBV a
a SBV a -> SBV a -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.< SBV a
pivot)
(SInteger
1 SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+ SBV a -> SList a -> SInteger
count SBV a
e SList a
lo SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+ SBV a -> SList a -> SInteger
count SBV a
e SList a
hi)
(SBV a -> SList a -> SInteger
count SBV a
e SList a
lo SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+ SInteger
1 SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+ SBV a -> SList a -> SInteger
count SBV a
e SList a
hi)
SInteger -> String -> Hinted SInteger
forall a b. HintsTo a b => a -> b -> Hinted a
?? String
"simplify"
TPProofRaw SInteger
-> ChainsTo (TPProofRaw SInteger) -> ChainsTo (TPProofRaw SInteger)
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SInteger
1 SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+ SBV a -> SList a -> SInteger
count SBV a
e SList a
lo SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+ SBV a -> SList a -> SInteger
count SBV a
e SList a
hi
SInteger
-> Proof (Forall "pivot" a -> Forall "e" a -> SBool)
-> Hinted SInteger
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof
(IHType
(Forall "xs" [a] -> Forall "pivot" a -> Forall "e" a -> SBool))
Proof (Forall "pivot" a -> Forall "e" a -> SBool)
ih
TPProofRaw SInteger
-> ChainsTo (TPProofRaw SInteger) -> ChainsTo (TPProofRaw SInteger)
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SInteger
1 SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+ SBV a -> SList a -> SInteger
count SBV a
e SList a
as
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
, SBV a
e SBV a -> SBV a -> SBool
forall a. EqSymbolic a => a -> a -> SBool
./= SBV a
a SBool -> TPProofRaw SInteger -> (SBool, TPProofRaw SInteger)
forall a. SBool -> TPProofRaw a -> (SBool, TPProofRaw a)
==> SBool -> SInteger -> SInteger -> SInteger
forall a. Mergeable a => SBool -> a -> a -> a
ite (SBV a
a SBV a -> SBV a -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.< SBV a
pivot)
(SBV a -> SList a -> SInteger
count SBV a
e SList a
lo SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+ SBV a -> SList a -> SInteger
count SBV a
e SList a
hi)
(SBV a -> SList a -> SInteger
count SBV a
e SList a
lo SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+ SBV a -> SList a -> SInteger
count SBV a
e SList a
hi)
SInteger -> String -> Hinted SInteger
forall a b. HintsTo a b => a -> b -> Hinted a
?? String
"simplify"
TPProofRaw SInteger
-> ChainsTo (TPProofRaw SInteger) -> ChainsTo (TPProofRaw SInteger)
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SBV a -> SList a -> SInteger
count SBV a
e SList a
lo SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+ SBV a -> SList a -> SInteger
count SBV a
e SList a
hi
SInteger
-> Proof (Forall "pivot" a -> Forall "e" a -> SBool)
-> Hinted SInteger
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof
(IHType
(Forall "xs" [a] -> Forall "pivot" a -> Forall "e" a -> SBool))
Proof (Forall "pivot" a -> Forall "e" a -> SBool)
ih
TPProofRaw SInteger
-> ChainsTo (TPProofRaw SInteger) -> ChainsTo (TPProofRaw SInteger)
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SBV a -> SList a -> SInteger
count SBV a
e SList a
as
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
]
Proof (Forall "xs" [a] -> Forall "e" a -> SBool)
sortCountsMatch <-
String
-> (Forall "xs" [a] -> Forall "e" a -> SBool)
-> MeasureArgs (Forall "xs" [a] -> Forall "e" a -> SBool) Integer
-> (Proof (Forall "xs" [a] -> Forall "e" a -> SBool)
-> StepArgs (Forall "xs" [a] -> Forall "e" a -> SBool) Integer)
-> TP (Proof (Forall "xs" [a] -> Forall "e" a -> SBool))
forall a m t.
(SInductive a, Proposition a, Zero m, SymVal t,
EqSymbolic (SBV t)) =>
String
-> a
-> MeasureArgs a m
-> (Proof a -> StepArgs a t)
-> TP (Proof a)
forall m t.
(Proposition (Forall "xs" [a] -> Forall "e" a -> SBool), Zero m,
SymVal t, EqSymbolic (SBV t)) =>
String
-> (Forall "xs" [a] -> Forall "e" a -> SBool)
-> MeasureArgs (Forall "xs" [a] -> Forall "e" a -> SBool) m
-> (Proof (Forall "xs" [a] -> Forall "e" a -> SBool)
-> StepArgs (Forall "xs" [a] -> Forall "e" a -> SBool) t)
-> TP (Proof (Forall "xs" [a] -> Forall "e" a -> SBool))
sInduct String
"sortCountsMatch"
(\(Forall SList a
xs) (Forall SBV a
e) -> SBV a -> SList a -> SInteger
count SBV a
e SList a
xs SInteger -> SInteger -> SBool
forall a. EqSymbolic a => a -> a -> SBool
.== SBV a -> SList a -> SInteger
count SBV a
e (SList a -> SList a
forall a. (Ord a, SymVal a) => SList a -> SList a
quickSort SList a
xs))
(\SList a
xs SBV a
_ -> SList a -> SInteger
forall a. SymVal a => SList a -> SInteger
length SList a
xs) ((Proof (Forall "xs" [a] -> Forall "e" a -> SBool)
-> StepArgs (Forall "xs" [a] -> Forall "e" a -> SBool) Integer)
-> TP (Proof (Forall "xs" [a] -> Forall "e" a -> SBool)))
-> (Proof (Forall "xs" [a] -> Forall "e" a -> SBool)
-> StepArgs (Forall "xs" [a] -> Forall "e" a -> SBool) Integer)
-> TP (Proof (Forall "xs" [a] -> Forall "e" a -> SBool))
forall a b. (a -> b) -> a -> b
$
\Proof (Forall "xs" [a] -> Forall "e" a -> SBool)
ih SList a
xs SBV a
e ->
[] [SBool] -> TPProofRaw SInteger -> (SBool, TPProofRaw SInteger)
forall a. [SBool] -> TPProofRaw a -> (SBool, TPProofRaw a)
|- SBV a -> SList a -> SInteger
count SBV a
e (SList a -> SList a
forall a. (Ord a, SymVal a) => SList a -> SList a
quickSort SList a
xs)
SInteger -> ChainsTo SInteger -> ChainsTo SInteger
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SList a
-> TPProofRaw SInteger
-> (SBV a -> SList a -> TPProofRaw SInteger)
-> TPProofRaw SInteger
forall a r.
SymVal a =>
SList a
-> TPProofRaw r
-> (SBV a -> SList a -> TPProofRaw r)
-> TPProofRaw r
split SList a
xs TPProofRaw SInteger
forall a. Trivial a => a
trivial
(\SBV a
a SList a
as -> SBV a -> SList a -> SInteger
count SBV a
e (SList a -> SList a
forall a. (Ord a, SymVal a) => SList a -> SList a
quickSort (SBV a
a SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: SList a
as))
SInteger -> String -> Hinted SInteger
forall a b. HintsTo a b => a -> b -> Hinted a
?? String
"expand quickSort"
TPProofRaw SInteger
-> ChainsTo (TPProofRaw SInteger) -> ChainsTo (TPProofRaw SInteger)
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SBV a -> SList a -> SInteger
count SBV a
e (let (SList a
lo, SList a
hi) = STuple [a] [a] -> (SList a, SList a)
forall tup a. Tuple tup a => SBV tup -> a
untuple (SBV a -> SList a -> STuple [a] [a]
forall a. (Ord a, SymVal a) => SBV a -> SList a -> STuple [a] [a]
partition SBV a
a SList a
as)
in SList a -> SList a
forall a. (Ord a, SymVal a) => SList a -> SList a
quickSort SList a
lo SList a -> SList a -> SList a
forall a. SymVal a => SList a -> SList a -> SList a
++ [Item (SList a)
SBV a
a] SList a -> SList a -> SList a
forall a. SymVal a => SList a -> SList a -> SList a
++ SList a -> SList a
forall a. (Ord a, SymVal a) => SList a -> SList a
quickSort SList a
hi)
SInteger -> String -> Hinted SInteger
forall a b. HintsTo a b => a -> b -> Hinted a
?? String
"push count down"
TPProofRaw SInteger
-> ChainsTo (TPProofRaw SInteger) -> ChainsTo (TPProofRaw SInteger)
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: let (SList a
lo, SList a
hi) = STuple [a] [a] -> (SList a, SList a)
forall tup a. Tuple tup a => SBV tup -> a
untuple (SBV a -> SList a -> STuple [a] [a]
forall a. (Ord a, SymVal a) => SBV a -> SList a -> STuple [a] [a]
partition SBV a
a SList a
as)
in SBV a -> SList a -> SInteger
count SBV a
e (SList a -> SList a
forall a. (Ord a, SymVal a) => SList a -> SList a
quickSort SList a
lo SList a -> SList a -> SList a
forall a. SymVal a => SList a -> SList a -> SList a
++ [Item (SList a)
SBV a
a] SList a -> SList a -> SList a
forall a. SymVal a => SList a -> SList a -> SList a
++ SList a -> SList a
forall a. (Ord a, SymVal a) => SList a -> SList a
quickSort SList a
hi)
SInteger -> Proof Bool -> Hinted SInteger
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof (Forall "xs" [a] -> Forall "ys" [a] -> Forall "e" a -> SBool)
countAppend Proof (Forall "xs" [a] -> Forall "ys" [a] -> Forall "e" a -> SBool)
-> IArgs
(Forall "xs" [a] -> Forall "ys" [a] -> Forall "e" a -> SBool)
-> Proof Bool
forall a. Instantiatable a => Proof a -> IArgs a -> Proof Bool
`at` (forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"xs" (SList a -> SList a
forall a. (Ord a, SymVal a) => SList a -> SList a
quickSort SList a
lo), forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"ys" ([Item (SList a)
SBV a
a] SList a -> SList a -> SList a
forall a. SymVal a => SList a -> SList a -> SList a
++ SList a -> SList a
forall a. (Ord a, SymVal a) => SList a -> SList a
quickSort SList a
hi), forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"e" SBV a
e)
TPProofRaw SInteger
-> ChainsTo (TPProofRaw SInteger) -> ChainsTo (TPProofRaw SInteger)
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SBV a -> SList a -> SInteger
count SBV a
e (SList a -> SList a
forall a. (Ord a, SymVal a) => SList a -> SList a
quickSort SList a
lo) SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+ SBV a -> SList a -> SInteger
count SBV a
e ([Item (SList a)
SBV a
a] SList a -> SList a -> SList a
forall a. SymVal a => SList a -> SList a -> SList a
++ SList a -> SList a
forall a. (Ord a, SymVal a) => SList a -> SList a
quickSort SList a
hi)
SInteger -> Proof Bool -> Hinted SInteger
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof (Forall "xs" [a] -> Forall "ys" [a] -> Forall "e" a -> SBool)
countAppend Proof (Forall "xs" [a] -> Forall "ys" [a] -> Forall "e" a -> SBool)
-> IArgs
(Forall "xs" [a] -> Forall "ys" [a] -> Forall "e" a -> SBool)
-> Proof Bool
forall a. Instantiatable a => Proof a -> IArgs a -> Proof Bool
`at` (forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"xs" [Item (SList a)
SBV a
a], forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"ys" (SList a -> SList a
forall a. (Ord a, SymVal a) => SList a -> SList a
quickSort SList a
hi), forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"e" SBV a
e)
TPProofRaw SInteger
-> ChainsTo (TPProofRaw SInteger) -> ChainsTo (TPProofRaw SInteger)
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SBV a -> SList a -> SInteger
count SBV a
e (SList a -> SList a
forall a. (Ord a, SymVal a) => SList a -> SList a
quickSort SList a
lo) SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+ SBV a -> SList a -> SInteger
count SBV a
e [Item (SList a)
SBV a
a] SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+ SBV a -> SList a -> SInteger
count SBV a
e (SList a -> SList a
forall a. (Ord a, SymVal a) => SList a -> SList a
quickSort SList a
hi)
SInteger -> Proof Bool -> Hinted SInteger
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof (Forall "xs" [a] -> Forall "e" a -> SBool)
ih Proof (Forall "xs" [a] -> Forall "e" a -> SBool)
-> IArgs (Forall "xs" [a] -> Forall "e" a -> SBool) -> Proof Bool
forall a. Instantiatable a => Proof a -> IArgs a -> Proof Bool
`at` (forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"xs" SList a
lo, forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"e" SBV a
e)
TPProofRaw SInteger -> Proof Bool -> Hinted (TPProofRaw SInteger)
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof (Forall "l" [a] -> Forall "pivot" a -> SBool)
partitionNotLongerFst Proof (Forall "l" [a] -> Forall "pivot" a -> SBool)
-> IArgs (Forall "l" [a] -> Forall "pivot" a -> SBool)
-> Proof Bool
forall a. Instantiatable a => Proof a -> IArgs a -> Proof Bool
`at` (forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"l" SList a
as, forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"pivot" SBV a
a)
Hinted (TPProofRaw SInteger)
-> String -> Hinted (Hinted (TPProofRaw SInteger))
forall a b. HintsTo a b => a -> b -> Hinted a
?? String
"IH on lo"
Hinted (Hinted (TPProofRaw SInteger))
-> ChainsTo (Hinted (Hinted (TPProofRaw SInteger)))
-> ChainsTo (Hinted (Hinted (TPProofRaw SInteger)))
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SBV a -> SList a -> SInteger
count SBV a
e SList a
lo SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+ SBV a -> SList a -> SInteger
count SBV a
e [Item (SList a)
SBV a
a] SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+ SBV a -> SList a -> SInteger
count SBV a
e (SList a -> SList a
forall a. (Ord a, SymVal a) => SList a -> SList a
quickSort SList a
hi)
SInteger -> Proof Bool -> Hinted SInteger
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof (Forall "xs" [a] -> Forall "e" a -> SBool)
ih Proof (Forall "xs" [a] -> Forall "e" a -> SBool)
-> IArgs (Forall "xs" [a] -> Forall "e" a -> SBool) -> Proof Bool
forall a. Instantiatable a => Proof a -> IArgs a -> Proof Bool
`at` (forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"xs" SList a
hi, forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"e" SBV a
e)
TPProofRaw SInteger -> Proof Bool -> Hinted (TPProofRaw SInteger)
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof (Forall "l" [a] -> Forall "pivot" a -> SBool)
partitionNotLongerSnd Proof (Forall "l" [a] -> Forall "pivot" a -> SBool)
-> IArgs (Forall "l" [a] -> Forall "pivot" a -> SBool)
-> Proof Bool
forall a. Instantiatable a => Proof a -> IArgs a -> Proof Bool
`at` (forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"l" SList a
as, forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"pivot" SBV a
a)
Hinted (TPProofRaw SInteger)
-> String -> Hinted (Hinted (TPProofRaw SInteger))
forall a b. HintsTo a b => a -> b -> Hinted a
?? String
"IH on hi"
Hinted (Hinted (TPProofRaw SInteger))
-> ChainsTo (Hinted (Hinted (TPProofRaw SInteger)))
-> ChainsTo (Hinted (Hinted (TPProofRaw SInteger)))
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SBV a -> SList a -> SInteger
count SBV a
e SList a
lo SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+ SBV a -> SList a -> SInteger
count SBV a
e [Item (SList a)
SBV a
a] SInteger -> SInteger -> SInteger
forall a. Num a => a -> a -> a
+ SBV a -> SList a -> SInteger
count SBV a
e SList a
hi
SInteger -> Proof Bool -> Hinted SInteger
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof
(Forall "xs" [a] -> Forall "pivot" a -> Forall "e" a -> SBool)
countPartition Proof
(Forall "xs" [a] -> Forall "pivot" a -> Forall "e" a -> SBool)
-> IArgs
(Forall "xs" [a] -> Forall "pivot" a -> Forall "e" a -> SBool)
-> Proof Bool
forall a. Instantiatable a => Proof a -> IArgs a -> Proof Bool
`at` (forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"xs" SList a
as, forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"pivot" SBV a
a, forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"e" SBV a
e)
TPProofRaw SInteger
-> ChainsTo (TPProofRaw SInteger) -> ChainsTo (TPProofRaw SInteger)
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SBV a -> SList a -> SInteger
count SBV a
e SList a
xs
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)
Proof (Forall "xs" [a] -> SBool)
sortIsPermutation <- String
-> (Forall "xs" [a] -> SBool)
-> [ProofObj]
-> TP (Proof (Forall "xs" [a] -> SBool))
forall a.
Proposition a =>
String -> a -> [ProofObj] -> TP (Proof a)
lemma String
"sortIsPermutation" (\(Forall SList a
xs) -> SList a -> SList a -> SBool
isPermutation SList a
xs (SList a -> SList a
forall a. (Ord a, SymVal a) => SList a -> SList a
quickSort SList a
xs)) [Proof (Forall "xs" [a] -> Forall "e" a -> SBool) -> ProofObj
forall a. Proof a -> ProofObj
proofOf Proof (Forall "xs" [a] -> Forall "e" a -> SBool)
sortCountsMatch]
Proof
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
nonDecreasingMerge <-
SMTConfig
-> String
-> (Forall "xs" [a]
-> Forall "pivot" a -> Forall "ys" [a] -> SBool)
-> (Proof
(IHType
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool))
-> IHArg
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
-> IStepArgs
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
Bool)
-> TP
(Proof
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool))
forall t.
(Proposition
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool),
SymVal t, EqSymbolic (SBV t)) =>
SMTConfig
-> String
-> (Forall "xs" [a]
-> Forall "pivot" a -> Forall "ys" [a] -> SBool)
-> (Proof
(IHType
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool))
-> IHArg
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
-> IStepArgs
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
t)
-> TP
(Proof
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> 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
"nonDecreasingMerge"
(\(Forall SList a
xs) (Forall SBV a
pivot) (Forall SList a
ys) ->
SList a -> SBool
nonDecreasing SList a
xs SBool -> SBool -> SBool
.&& SBV a -> SList a -> SBool
llt SBV a
pivot SList a
xs
SBool -> SBool -> SBool
.&& SList a -> SBool
nonDecreasing SList a
ys SBool -> SBool -> SBool
.&& SBV a -> SList a -> SBool
lge SBV a
pivot SList a
ys SBool -> SBool -> SBool
.=> SList a -> SBool
nonDecreasing (SList a
xs SList a -> SList a -> SList a
forall a. SymVal a => SList a -> SList a -> SList a
++ [Item (SList a)
SBV a
pivot] SList a -> SList a -> SList a
forall a. SymVal a => SList a -> SList a -> SList a
++ SList a
ys)) ((Proof
(IHType
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool))
-> IHArg
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
-> IStepArgs
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
Bool)
-> TP
(Proof
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)))
-> (Proof
(IHType
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool))
-> IHArg
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
-> IStepArgs
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
Bool)
-> TP
(Proof
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool))
forall a b. (a -> b) -> a -> b
$
\Proof
(IHType
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool))
ih (SBV a
x, SList a
xs) SBV a
pivot SList a
ys ->
[SList a -> SBool
nonDecreasing (SBV a
x SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: SList a
xs), SBV a -> SList a -> SBool
llt SBV a
pivot SList a
xs, SList a -> SBool
nonDecreasing SList a
ys, SBV a -> SList a -> SBool
lge SBV a
pivot SList a
ys]
[SBool] -> TPProofRaw SBool -> (SBool, TPProofRaw SBool)
forall a. [SBool] -> TPProofRaw a -> (SBool, TPProofRaw a)
|- SList a -> SBool
nonDecreasing (SBV a
x SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: SList a
xs SList a -> SList a -> SList a
forall a. SymVal a => SList a -> SList a -> SList a
++ [Item (SList a)
SBV a
pivot] SList a -> SList a -> SList a
forall a. SymVal a => SList a -> SList a -> SList a
++ SList a
ys)
SBool -> ChainsTo SBool -> ChainsTo SBool
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SList a
-> TPProofRaw SBool
-> (SBV a -> SList a -> TPProofRaw SBool)
-> TPProofRaw SBool
forall a r.
SymVal a =>
SList a
-> TPProofRaw r
-> (SBV a -> SList a -> TPProofRaw r)
-> TPProofRaw r
split SList a
xs TPProofRaw SBool
forall a. Trivial a => a
trivial
(\SBV a
a SList a
as -> SList a -> SBool
nonDecreasing (SBV a
x SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: SBV a
a SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: SList a
as SList a -> SList a -> SList a
forall a. SymVal a => SList a -> SList a -> SList a
++ [Item (SList a)
SBV a
pivot] SList a -> SList a -> SList a
forall a. SymVal a => SList a -> SList a -> SList a
++ SList a
ys)
SBool -> ChainsTo SBool -> ChainsTo SBool
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SBV a
x SBV a -> SBV a -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.<= SBV a
a SBool -> SBool -> SBool
.&& SList a -> SBool
nonDecreasing (SBV a
a SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: SList a
as SList a -> SList a -> SList a
forall a. SymVal a => SList a -> SList a -> SList a
++ [Item (SList a)
SBV a
pivot] SList a -> SList a -> SList a
forall a. SymVal a => SList a -> SList a -> SList a
++ SList a
ys)
SBool
-> Proof (Forall "pivot" a -> Forall "ys" [a] -> SBool)
-> Hinted SBool
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof
(IHType
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool))
Proof (Forall "pivot" a -> Forall "ys" [a] -> 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)
Proof (Forall "xs" [a] -> SBool)
sortIsNonDecreasing <-
SMTConfig
-> String
-> (Forall "xs" [a] -> SBool)
-> MeasureArgs (Forall "xs" [a] -> SBool) Integer
-> (Proof (Forall "xs" [a] -> SBool)
-> StepArgs (Forall "xs" [a] -> SBool) Bool)
-> TP (Proof (Forall "xs" [a] -> SBool))
forall a m t.
(SInductive a, Proposition a, Zero m, SymVal t,
EqSymbolic (SBV t)) =>
SMTConfig
-> String
-> a
-> MeasureArgs a m
-> (Proof a -> StepArgs a t)
-> TP (Proof a)
forall m t.
(Proposition (Forall "xs" [a] -> SBool), Zero m, SymVal t,
EqSymbolic (SBV t)) =>
SMTConfig
-> String
-> (Forall "xs" [a] -> SBool)
-> MeasureArgs (Forall "xs" [a] -> SBool) m
-> (Proof (Forall "xs" [a] -> SBool)
-> StepArgs (Forall "xs" [a] -> SBool) t)
-> TP (Proof (Forall "xs" [a] -> SBool))
sInductWith SMTConfig
cvc5 String
"sortIsNonDecreasing"
(\(Forall SList a
xs) -> SList a -> SBool
nonDecreasing (SList a -> SList a
forall a. (Ord a, SymVal a) => SList a -> SList a
quickSort SList a
xs))
(forall a. SymVal a => SList a -> SInteger
length @a) ((Proof (Forall "xs" [a] -> SBool)
-> StepArgs (Forall "xs" [a] -> SBool) Bool)
-> TP (Proof (Forall "xs" [a] -> SBool)))
-> (Proof (Forall "xs" [a] -> SBool)
-> StepArgs (Forall "xs" [a] -> SBool) Bool)
-> TP (Proof (Forall "xs" [a] -> SBool))
forall a b. (a -> b) -> a -> b
$
\Proof (Forall "xs" [a] -> SBool)
ih SList a
xs ->
[] [SBool] -> TPProofRaw SBool -> (SBool, TPProofRaw SBool)
forall a. [SBool] -> TPProofRaw a -> (SBool, TPProofRaw a)
|- SList a -> SBool
nonDecreasing (SList a -> SList a
forall a. (Ord a, SymVal a) => SList a -> SList a
quickSort SList a
xs)
SBool -> ChainsTo SBool -> ChainsTo SBool
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SList a
-> TPProofRaw SBool
-> (SBV a -> SList a -> TPProofRaw SBool)
-> TPProofRaw SBool
forall a r.
SymVal a =>
SList a
-> TPProofRaw r
-> (SBV a -> SList a -> TPProofRaw r)
-> TPProofRaw r
split SList a
xs TPProofRaw SBool
forall a. Trivial a => a
trivial
(\SBV a
a SList a
as -> SList a -> SBool
nonDecreasing (SList a -> SList a
forall a. (Ord a, SymVal a) => SList a -> SList a
quickSort (SBV a
a SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: SList a
as))
SBool -> String -> Hinted SBool
forall a b. HintsTo a b => a -> b -> Hinted a
?? String
"expand quickSort"
TPProofRaw SBool
-> ChainsTo (TPProofRaw SBool) -> ChainsTo (TPProofRaw SBool)
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SList a -> SBool
nonDecreasing (let (SList a
lo, SList a
hi) = STuple [a] [a] -> (SList a, SList a)
forall tup a. Tuple tup a => SBV tup -> a
untuple (SBV a -> SList a -> STuple [a] [a]
forall a. (Ord a, SymVal a) => SBV a -> SList a -> STuple [a] [a]
partition SBV a
a SList a
as)
in SList a -> SList a
forall a. (Ord a, SymVal a) => SList a -> SList a
quickSort SList a
lo SList a -> SList a -> SList a
forall a. SymVal a => SList a -> SList a -> SList a
++ [Item (SList a)
SBV a
a] SList a -> SList a -> SList a
forall a. SymVal a => SList a -> SList a -> SList a
++ SList a -> SList a
forall a. (Ord a, SymVal a) => SList a -> SList a
quickSort SList a
hi)
SBool -> String -> Hinted SBool
forall a b. HintsTo a b => a -> b -> Hinted a
?? String
"push nonDecreasing down"
TPProofRaw SBool
-> ChainsTo (TPProofRaw SBool) -> ChainsTo (TPProofRaw SBool)
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: let (SList a
lo, SList a
hi) = STuple [a] [a] -> (SList a, SList a)
forall tup a. Tuple tup a => SBV tup -> a
untuple (SBV a -> SList a -> STuple [a] [a]
forall a. (Ord a, SymVal a) => SBV a -> SList a -> STuple [a] [a]
partition SBV a
a SList a
as)
in SList a -> SBool
nonDecreasing (SList a -> SList a
forall a. (Ord a, SymVal a) => SList a -> SList a
quickSort SList a
lo SList a -> SList a -> SList a
forall a. SymVal a => SList a -> SList a -> SList a
++ [Item (SList a)
SBV a
a] SList a -> SList a -> SList a
forall a. SymVal a => SList a -> SList a -> SList a
++ SList a -> SList a
forall a. (Ord a, SymVal a) => SList a -> SList a
quickSort SList a
hi)
SBool -> Proof Bool -> Hinted SBool
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof (Forall "l" [a] -> Forall "pivot" a -> SBool)
partitionNotLongerFst Proof (Forall "l" [a] -> Forall "pivot" a -> SBool)
-> IArgs (Forall "l" [a] -> Forall "pivot" a -> SBool)
-> Proof Bool
forall a. Instantiatable a => Proof a -> IArgs a -> Proof Bool
`at` (forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"l" SList a
as, forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"pivot" SBV a
a)
TPProofRaw SBool -> Proof Bool -> Hinted (TPProofRaw SBool)
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof (Forall "l" [a] -> Forall "pivot" a -> SBool)
partitionNotLongerSnd Proof (Forall "l" [a] -> Forall "pivot" a -> SBool)
-> IArgs (Forall "l" [a] -> Forall "pivot" a -> SBool)
-> Proof Bool
forall a. Instantiatable a => Proof a -> IArgs a -> Proof Bool
`at` (forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"l" SList a
as, forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"pivot" SBV a
a)
Hinted (TPProofRaw SBool)
-> Proof Bool -> Hinted (Hinted (TPProofRaw SBool))
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof (Forall "xs" [a] -> SBool)
ih Proof (Forall "xs" [a] -> SBool)
-> IArgs (Forall "xs" [a] -> SBool) -> Proof Bool
forall a. Instantiatable a => Proof a -> IArgs a -> Proof Bool
`at` forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"xs" SList a
lo
Hinted (Hinted (TPProofRaw SBool))
-> Proof Bool -> Hinted (Hinted (Hinted (TPProofRaw SBool)))
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof (Forall "xs" [a] -> SBool)
ih Proof (Forall "xs" [a] -> SBool)
-> IArgs (Forall "xs" [a] -> SBool) -> Proof Bool
forall a. Instantiatable a => Proof a -> IArgs a -> Proof Bool
`at` forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"xs" SList a
hi
Hinted (Hinted (Hinted (TPProofRaw SBool)))
-> Proof Bool
-> Hinted (Hinted (Hinted (Hinted (TPProofRaw SBool))))
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof (Forall "l" [a] -> Forall "pivot" a -> SBool)
partitionFstLT Proof (Forall "l" [a] -> Forall "pivot" a -> SBool)
-> IArgs (Forall "l" [a] -> Forall "pivot" a -> SBool)
-> Proof Bool
forall a. Instantiatable a => Proof a -> IArgs a -> Proof Bool
`at` (forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"l" SList a
as, forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"pivot" SBV a
a)
Hinted (Hinted (Hinted (Hinted (TPProofRaw SBool))))
-> Proof Bool
-> Hinted (Hinted (Hinted (Hinted (Hinted (TPProofRaw SBool)))))
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof (Forall "l" [a] -> Forall "pivot" a -> SBool)
partitionSndGE Proof (Forall "l" [a] -> Forall "pivot" a -> SBool)
-> IArgs (Forall "l" [a] -> Forall "pivot" a -> SBool)
-> Proof Bool
forall a. Instantiatable a => Proof a -> IArgs a -> Proof Bool
`at` (forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"l" SList a
as, forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"pivot" SBV a
a)
Hinted (Hinted (Hinted (Hinted (Hinted (TPProofRaw SBool)))))
-> Proof Bool
-> Hinted
(Hinted (Hinted (Hinted (Hinted (Hinted (TPProofRaw SBool))))))
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof (Forall "xs" [a] -> SBool)
sortIsPermutation Proof (Forall "xs" [a] -> SBool)
-> IArgs (Forall "xs" [a] -> SBool) -> Proof Bool
forall a. Instantiatable a => Proof a -> IArgs a -> Proof Bool
`at` forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"xs" SList a
lo
Hinted
(Hinted (Hinted (Hinted (Hinted (Hinted (TPProofRaw SBool))))))
-> Proof Bool
-> Hinted
(Hinted
(Hinted (Hinted (Hinted (Hinted (Hinted (TPProofRaw SBool)))))))
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
lltPermutation Proof
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
-> IArgs
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
-> Proof Bool
forall a. Instantiatable a => Proof a -> IArgs a -> Proof Bool
`at` (forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"xs" (SList a -> SList a
forall a. (Ord a, SymVal a) => SList a -> SList a
quickSort SList a
lo), forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"pivot" SBV a
a, forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"ys" SList a
lo)
Hinted
(Hinted
(Hinted (Hinted (Hinted (Hinted (Hinted (TPProofRaw SBool)))))))
-> Proof Bool
-> Hinted
(Hinted
(Hinted
(Hinted (Hinted (Hinted (Hinted (Hinted (TPProofRaw SBool))))))))
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof (Forall "xs" [a] -> SBool)
sortIsPermutation Proof (Forall "xs" [a] -> SBool)
-> IArgs (Forall "xs" [a] -> SBool) -> Proof Bool
forall a. Instantiatable a => Proof a -> IArgs a -> Proof Bool
`at` forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"xs" SList a
hi
Hinted
(Hinted
(Hinted
(Hinted (Hinted (Hinted (Hinted (Hinted (TPProofRaw SBool))))))))
-> Proof Bool
-> Hinted
(Hinted
(Hinted
(Hinted
(Hinted (Hinted (Hinted (Hinted (Hinted (TPProofRaw SBool)))))))))
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
lgePermutation Proof
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
-> IArgs
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
-> Proof Bool
forall a. Instantiatable a => Proof a -> IArgs a -> Proof Bool
`at` (forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"xs" (SList a -> SList a
forall a. (Ord a, SymVal a) => SList a -> SList a
quickSort SList a
hi), forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"pivot" SBV a
a, forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"ys" SList a
hi)
Hinted
(Hinted
(Hinted
(Hinted
(Hinted (Hinted (Hinted (Hinted (Hinted (TPProofRaw SBool)))))))))
-> Proof Bool
-> Hinted
(Hinted
(Hinted
(Hinted
(Hinted
(Hinted (Hinted (Hinted (Hinted (Hinted (TPProofRaw SBool))))))))))
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
nonDecreasingMerge Proof
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
-> IArgs
(Forall "xs" [a] -> Forall "pivot" a -> Forall "ys" [a] -> SBool)
-> Proof Bool
forall a. Instantiatable a => Proof a -> IArgs a -> Proof Bool
`at` (forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"xs" (SList a -> SList a
forall a. (Ord a, SymVal a) => SList a -> SList a
quickSort SList a
lo), forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"pivot" SBV a
a, forall (nm :: Symbol) a. SBV a -> Inst nm a
Inst @"ys" (SList a -> SList a
forall a. (Ord a, SymVal a) => SList a -> SList a
quickSort SList a
hi))
Hinted
(Hinted
(Hinted
(Hinted
(Hinted
(Hinted (Hinted (Hinted (Hinted (Hinted (TPProofRaw SBool))))))))))
-> ChainsTo
(Hinted
(Hinted
(Hinted
(Hinted
(Hinted
(Hinted
(Hinted (Hinted (Hinted (Hinted (TPProofRaw SBool)))))))))))
-> ChainsTo
(Hinted
(Hinted
(Hinted
(Hinted
(Hinted
(Hinted
(Hinted (Hinted (Hinted (Hinted (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)
Proof (Forall "xs" [a] -> SBool)
qs <- String
-> (Forall "xs" [a] -> SBool)
-> [ProofObj]
-> TP (Proof (Forall "xs" [a] -> SBool))
forall a.
Proposition a =>
String -> a -> [ProofObj] -> TP (Proof a)
lemma String
"quickSortIsCorrect"
(\(Forall SList a
xs) -> let out :: SList a
out = SList a -> SList a
forall a. (Ord a, SymVal a) => SList a -> SList a
quickSort SList a
xs in SList a -> SList a -> SBool
isPermutation SList a
xs SList a
out SBool -> SBool -> SBool
.&& SList a -> SBool
nonDecreasing SList a
out)
[Proof (Forall "xs" [a] -> SBool) -> ProofObj
forall a. Proof a -> ProofObj
proofOf Proof (Forall "xs" [a] -> SBool)
sortIsPermutation, Proof (Forall "xs" [a] -> SBool) -> ProofObj
forall a. Proof a -> ProofObj
proofOf Proof (Forall "xs" [a] -> SBool)
sortIsNonDecreasing]
Proof (Forall "as" [a] -> Forall "pivot" a -> SBool)
partitionSortedLeft <-
SMTConfig
-> String
-> (Forall "as" [a] -> Forall "pivot" a -> SBool)
-> (Proof (IHType (Forall "as" [a] -> Forall "pivot" a -> SBool))
-> IHArg (Forall "as" [a] -> Forall "pivot" a -> SBool)
-> IStepArgs (Forall "as" [a] -> Forall "pivot" a -> SBool) [a])
-> TP (Proof (Forall "as" [a] -> Forall "pivot" a -> SBool))
forall t.
(Proposition (Forall "as" [a] -> Forall "pivot" a -> SBool),
SymVal t, EqSymbolic (SBV t)) =>
SMTConfig
-> String
-> (Forall "as" [a] -> Forall "pivot" a -> SBool)
-> (Proof (IHType (Forall "as" [a] -> Forall "pivot" a -> SBool))
-> IHArg (Forall "as" [a] -> Forall "pivot" a -> SBool)
-> IStepArgs (Forall "as" [a] -> Forall "pivot" a -> SBool) t)
-> TP (Proof (Forall "as" [a] -> Forall "pivot" a -> 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
"partitionSortedLeft"
(\(Forall @"as" SList a
as) (Forall @"pivot" SBV a
pivot) -> SList a -> SBool
nonDecreasing (SBV a
pivot SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: SList a
as) SBool -> SBool -> SBool
.=> SList a -> SBool
forall a. SymVal a => SList a -> SBool
null (STuple [a] [a] -> SList a
forall a b. (SymVal a, SymVal b) => STuple a b -> SBV a
fst (SBV a -> SList a -> STuple [a] [a]
forall a. (Ord a, SymVal a) => SBV a -> SList a -> STuple [a] [a]
partition SBV a
pivot SList a
as))) ((Proof (IHType (Forall "as" [a] -> Forall "pivot" a -> SBool))
-> IHArg (Forall "as" [a] -> Forall "pivot" a -> SBool)
-> IStepArgs (Forall "as" [a] -> Forall "pivot" a -> SBool) [a])
-> TP (Proof (Forall "as" [a] -> Forall "pivot" a -> SBool)))
-> (Proof (IHType (Forall "as" [a] -> Forall "pivot" a -> SBool))
-> IHArg (Forall "as" [a] -> Forall "pivot" a -> SBool)
-> IStepArgs (Forall "as" [a] -> Forall "pivot" a -> SBool) [a])
-> TP (Proof (Forall "as" [a] -> Forall "pivot" a -> SBool))
forall a b. (a -> b) -> a -> b
$
\Proof (IHType (Forall "as" [a] -> Forall "pivot" a -> SBool))
ih (SBV a
a, SList a
as) SBV a
pivot -> [SList a -> SBool
nonDecreasing (SBV a
pivot SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: SBV a
a SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: SList a
as)]
[SBool] -> TPProofRaw (SList a) -> (SBool, TPProofRaw (SList a))
forall a. [SBool] -> TPProofRaw a -> (SBool, TPProofRaw a)
|- STuple [a] [a] -> SList a
forall a b. (SymVal a, SymVal b) => STuple a b -> SBV a
fst (SBV a -> SList a -> STuple [a] [a]
forall a. (Ord a, SymVal a) => SBV a -> SList a -> STuple [a] [a]
partition SBV a
pivot (SBV a
a SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: SList a
as))
SList a -> ChainsTo (SList a) -> ChainsTo (SList a)
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: let (SList a
lo, SList a
_) = STuple [a] [a] -> (SList a, SList a)
forall tup a. Tuple tup a => SBV tup -> a
untuple (SBV a -> SList a -> STuple [a] [a]
forall a. (Ord a, SymVal a) => SBV a -> SList a -> STuple [a] [a]
partition SBV a
pivot SList a
as)
in SList a
lo
SList a -> Proof (Forall "pivot" a -> SBool) -> Hinted (SList a)
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof (IHType (Forall "as" [a] -> Forall "pivot" a -> SBool))
Proof (Forall "pivot" a -> SBool)
ih
TPProofRaw (SList a)
-> ChainsTo (TPProofRaw (SList a))
-> ChainsTo (TPProofRaw (SList a))
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SList a
forall a. SymVal a => SList a
nil
SList a -> ChainsTo (SList a) -> ChainsTo (SList a)
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: ChainsTo (SList a)
TPProofRaw (SList a)
forall a. TPProofRaw a
qed
Proof (Forall "xs" [a] -> Forall "pivot" a -> SBool)
partitionSortedRight <-
SMTConfig
-> String
-> (Forall "xs" [a] -> Forall "pivot" a -> SBool)
-> (Proof (IHType (Forall "xs" [a] -> Forall "pivot" a -> SBool))
-> IHArg (Forall "xs" [a] -> Forall "pivot" a -> SBool)
-> IStepArgs (Forall "xs" [a] -> Forall "pivot" a -> SBool) [a])
-> TP (Proof (Forall "xs" [a] -> Forall "pivot" a -> SBool))
forall t.
(Proposition (Forall "xs" [a] -> Forall "pivot" a -> SBool),
SymVal t, EqSymbolic (SBV t)) =>
SMTConfig
-> String
-> (Forall "xs" [a] -> Forall "pivot" a -> SBool)
-> (Proof (IHType (Forall "xs" [a] -> Forall "pivot" a -> SBool))
-> IHArg (Forall "xs" [a] -> Forall "pivot" a -> SBool)
-> IStepArgs (Forall "xs" [a] -> Forall "pivot" a -> SBool) t)
-> TP (Proof (Forall "xs" [a] -> Forall "pivot" a -> 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
"partitionSortedRight"
(\(Forall @"xs" SList a
xs) (Forall @"pivot" SBV a
pivot) -> SList a -> SBool
nonDecreasing (SBV a
pivot SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: SList a
xs) SBool -> SBool -> SBool
.=> SList a
xs SList a -> SList a -> SBool
forall a. EqSymbolic a => a -> a -> SBool
.== STuple [a] [a] -> SList a
forall a b. (SymVal a, SymVal b) => STuple a b -> SBV b
snd (SBV a -> SList a -> STuple [a] [a]
forall a. (Ord a, SymVal a) => SBV a -> SList a -> STuple [a] [a]
partition SBV a
pivot SList a
xs)) ((Proof (IHType (Forall "xs" [a] -> Forall "pivot" a -> SBool))
-> IHArg (Forall "xs" [a] -> Forall "pivot" a -> SBool)
-> IStepArgs (Forall "xs" [a] -> Forall "pivot" a -> SBool) [a])
-> TP (Proof (Forall "xs" [a] -> Forall "pivot" a -> SBool)))
-> (Proof (IHType (Forall "xs" [a] -> Forall "pivot" a -> SBool))
-> IHArg (Forall "xs" [a] -> Forall "pivot" a -> SBool)
-> IStepArgs (Forall "xs" [a] -> Forall "pivot" a -> SBool) [a])
-> TP (Proof (Forall "xs" [a] -> Forall "pivot" a -> SBool))
forall a b. (a -> b) -> a -> b
$
\Proof (IHType (Forall "xs" [a] -> Forall "pivot" a -> SBool))
ih (SBV a
a, SList a
as) SBV a
pivot -> [SList a -> SBool
nonDecreasing (SBV a
pivot SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: SBV a
a SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: SList a
as)]
[SBool] -> TPProofRaw (SList a) -> (SBool, TPProofRaw (SList a))
forall a. [SBool] -> TPProofRaw a -> (SBool, TPProofRaw a)
|- STuple [a] [a] -> SList a
forall a b. (SymVal a, SymVal b) => STuple a b -> SBV b
snd (SBV a -> SList a -> STuple [a] [a]
forall a. (Ord a, SymVal a) => SBV a -> SList a -> STuple [a] [a]
partition SBV a
pivot (SBV a
a SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: SList a
as))
SList a -> ChainsTo (SList a) -> ChainsTo (SList a)
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: let (SList a
_, SList a
hi) = STuple [a] [a] -> (SList a, SList a)
forall tup a. Tuple tup a => SBV tup -> a
untuple (SBV a -> SList a -> STuple [a] [a]
forall a. (Ord a, SymVal a) => SBV a -> SList a -> STuple [a] [a]
partition SBV a
pivot SList a
as)
in SBV a
a SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: SList a
hi
SList a -> Proof (Forall "pivot" a -> SBool) -> Hinted (SList a)
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof (IHType (Forall "xs" [a] -> Forall "pivot" a -> SBool))
Proof (Forall "pivot" a -> SBool)
ih
TPProofRaw (SList a)
-> ChainsTo (TPProofRaw (SList a))
-> ChainsTo (TPProofRaw (SList a))
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SBV a
a SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: SList a
as
SList a -> ChainsTo (SList a) -> ChainsTo (SList a)
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: ChainsTo (SList a)
TPProofRaw (SList a)
forall a. TPProofRaw a
qed
Proof (Forall "xs" [a] -> SBool)
unchangedIfNondecreasing <-
String
-> (Forall "xs" [a] -> SBool)
-> (Proof (IHType (Forall "xs" [a] -> SBool))
-> IHArg (Forall "xs" [a] -> SBool)
-> IStepArgs (Forall "xs" [a] -> SBool) [a])
-> TP (Proof (Forall "xs" [a] -> SBool))
forall t.
(Proposition (Forall "xs" [a] -> SBool), SymVal t,
EqSymbolic (SBV t)) =>
String
-> (Forall "xs" [a] -> SBool)
-> (Proof (IHType (Forall "xs" [a] -> SBool))
-> IHArg (Forall "xs" [a] -> SBool)
-> IStepArgs (Forall "xs" [a] -> SBool) t)
-> TP (Proof (Forall "xs" [a] -> 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
"unchangedIfNondecreasing"
(\(Forall @"xs" SList a
xs) -> SList a -> SBool
nonDecreasing SList a
xs SBool -> SBool -> SBool
.=> SList a -> SList a
forall a. (Ord a, SymVal a) => SList a -> SList a
quickSort SList a
xs SList a -> SList a -> SBool
forall a. EqSymbolic a => a -> a -> SBool
.== SList a
xs) ((Proof (IHType (Forall "xs" [a] -> SBool))
-> IHArg (Forall "xs" [a] -> SBool)
-> IStepArgs (Forall "xs" [a] -> SBool) [a])
-> TP (Proof (Forall "xs" [a] -> SBool)))
-> (Proof (IHType (Forall "xs" [a] -> SBool))
-> IHArg (Forall "xs" [a] -> SBool)
-> IStepArgs (Forall "xs" [a] -> SBool) [a])
-> TP (Proof (Forall "xs" [a] -> SBool))
forall a b. (a -> b) -> a -> b
$
\Proof (IHType (Forall "xs" [a] -> SBool))
ih (SBV a
x, SList a
xs) -> [SList a -> SBool
nonDecreasing (SBV a
x SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: SList a
xs)]
[SBool] -> TPProofRaw (SList a) -> (SBool, TPProofRaw (SList a))
forall a. [SBool] -> TPProofRaw a -> (SBool, TPProofRaw a)
|- SList a -> SList a
forall a. (Ord a, SymVal a) => SList a -> SList a
quickSort (SBV a
x SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: SList a
xs)
SList a -> ChainsTo (SList a) -> ChainsTo (SList a)
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: let (SList a
lo, SList a
hi) = STuple [a] [a] -> (SList a, SList a)
forall tup a. Tuple tup a => SBV tup -> a
untuple (SBV a -> SList a -> STuple [a] [a]
forall a. (Ord a, SymVal a) => SBV a -> SList a -> STuple [a] [a]
partition SBV a
x SList a
xs)
in SList a -> SList a
forall a. (Ord a, SymVal a) => SList a -> SList a
quickSort SList a
lo SList a -> SList a -> SList a
forall a. SymVal a => SList a -> SList a -> SList a
++ [Item (SList a)
SBV a
x] SList a -> SList a -> SList a
forall a. SymVal a => SList a -> SList a -> SList a
++ SList a -> SList a
forall a. (Ord a, SymVal a) => SList a -> SList a
quickSort SList a
hi
SList a
-> Proof (Forall "as" [a] -> Forall "pivot" a -> SBool)
-> Hinted (SList a)
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof (Forall "as" [a] -> Forall "pivot" a -> SBool)
partitionSortedLeft
TPProofRaw (SList a)
-> ChainsTo (TPProofRaw (SList a))
-> ChainsTo (TPProofRaw (SList a))
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: [Item (SList a)
SBV a
x] SList a -> SList a -> SList a
forall a. SymVal a => SList a -> SList a -> SList a
++ SList a -> SList a
forall a. (Ord a, SymVal a) => SList a -> SList a
quickSort SList a
hi
SList a
-> Proof (Forall "xs" [a] -> Forall "pivot" a -> SBool)
-> Hinted (SList a)
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof (Forall "xs" [a] -> Forall "pivot" a -> SBool)
partitionSortedRight
TPProofRaw (SList a)
-> ChainsTo (TPProofRaw (SList a))
-> ChainsTo (TPProofRaw (SList a))
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: [Item (SList a)
SBV a
x] SList a -> SList a -> SList a
forall a. SymVal a => SList a -> SList a -> SList a
++ SList a -> SList a
forall a. (Ord a, SymVal a) => SList a -> SList a
quickSort SList a
xs
SList a -> Proof SBool -> Hinted (SList a)
forall a b. HintsTo a b => a -> b -> Hinted a
?? Proof SBool
Proof (IHType (Forall "xs" [a] -> SBool))
ih
TPProofRaw (SList a)
-> ChainsTo (TPProofRaw (SList a))
-> ChainsTo (TPProofRaw (SList a))
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: SBV a
x SBV a -> SList a -> SList a
forall a. SymVal a => SBV a -> SList a -> SList a
.: SList a
xs
SList a -> ChainsTo (SList a) -> ChainsTo (SList a)
forall a. ChainStep a (ChainsTo a) => a -> ChainsTo a -> ChainsTo a
=: ChainsTo (SList a)
TPProofRaw (SList a)
forall a. TPProofRaw a
qed
Proof (Forall "xs" [a] -> SBool)
_ <- String
-> (Forall "xs" [a] -> SBool)
-> [ProofObj]
-> TP (Proof (Forall "xs" [a] -> SBool))
forall a.
Proposition a =>
String -> a -> [ProofObj] -> TP (Proof a)
lemma String
"ifChangedThenUnsorted"
(\(Forall @"xs" SList a
xs) -> SList a -> SList a
forall a. (Ord a, SymVal a) => SList a -> SList a
quickSort SList a
xs SList a -> SList a -> SBool
forall a. EqSymbolic a => a -> a -> SBool
./= SList a
xs SBool -> SBool -> SBool
.=> SBool -> SBool
sNot (SList a -> SBool
nonDecreasing SList a
xs))
[Proof (Forall "xs" [a] -> SBool) -> ProofObj
forall a. Proof a -> ProofObj
proofOf Proof (Forall "xs" [a] -> SBool)
unchangedIfNondecreasing]
IO () -> TP ()
forall a. IO a -> TP a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> TP ()) -> IO () -> TP ()
forall a b. (a -> b) -> a -> b
$ do String -> IO ()
putStrLn String
"== Proof tree:"
String -> IO ()
putStr (String -> IO ()) -> String -> IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> Proof (Forall "xs" [a] -> SBool) -> String
forall a. Bool -> Proof a -> String
showProofTree Bool
True Proof (Forall "xs" [a] -> SBool)
qs
Proof (Forall "xs" [a] -> SBool)
-> TP (Proof (Forall "xs" [a] -> SBool))
forall a. a -> TP a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Proof (Forall "xs" [a] -> SBool)
qs