{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# OPTIONS_GHC -Wall -Werror #-}
module Documentation.SBV.Examples.WeakestPreconditions.GCD where
import Data.SBV
import Data.SBV.Control
import Data.SBV.Tools.WeakestPreconditions
import GHC.Generics (Generic)
import Prelude hiding (gcd)
import qualified Prelude as P (gcd)
data GCDS a = GCDS { GCDS a -> a
x :: a
, GCDS a -> a
y :: a
, GCDS a -> a
i :: a
, GCDS a -> a
j :: a
}
deriving (Int -> GCDS a -> ShowS
[GCDS a] -> ShowS
GCDS a -> String
(Int -> GCDS a -> ShowS)
-> (GCDS a -> String) -> ([GCDS a] -> ShowS) -> Show (GCDS a)
forall a. Show a => Int -> GCDS a -> ShowS
forall a. Show a => [GCDS a] -> ShowS
forall a. Show a => GCDS a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GCDS a] -> ShowS
$cshowList :: forall a. Show a => [GCDS a] -> ShowS
show :: GCDS a -> String
$cshow :: forall a. Show a => GCDS a -> String
showsPrec :: Int -> GCDS a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> GCDS a -> ShowS
Show, (forall x. GCDS a -> Rep (GCDS a) x)
-> (forall x. Rep (GCDS a) x -> GCDS a) -> Generic (GCDS a)
forall x. Rep (GCDS a) x -> GCDS a
forall x. GCDS a -> Rep (GCDS a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (GCDS a) x -> GCDS a
forall a x. GCDS a -> Rep (GCDS a) x
$cto :: forall a x. Rep (GCDS a) x -> GCDS a
$cfrom :: forall a x. GCDS a -> Rep (GCDS a) x
Generic, Bool -> SBool -> GCDS a -> GCDS a -> GCDS a
(Bool -> SBool -> GCDS a -> GCDS a -> GCDS a)
-> (forall b.
(Ord b, SymVal b, Num b) =>
[GCDS a] -> GCDS a -> SBV b -> GCDS a)
-> Mergeable (GCDS a)
forall b.
(Ord b, SymVal b, Num b) =>
[GCDS a] -> GCDS a -> SBV b -> GCDS a
forall a.
Mergeable a =>
Bool -> SBool -> GCDS a -> GCDS a -> GCDS a
forall a b.
(Mergeable a, Ord b, SymVal b, Num b) =>
[GCDS a] -> GCDS a -> SBV b -> GCDS a
forall a.
(Bool -> SBool -> a -> a -> a)
-> (forall b. (Ord b, SymVal b, Num b) => [a] -> a -> SBV b -> a)
-> Mergeable a
select :: [GCDS a] -> GCDS a -> SBV b -> GCDS a
$cselect :: forall a b.
(Mergeable a, Ord b, SymVal b, Num b) =>
[GCDS a] -> GCDS a -> SBV b -> GCDS a
symbolicMerge :: Bool -> SBool -> GCDS a -> GCDS a -> GCDS a
$csymbolicMerge :: forall a.
Mergeable a =>
Bool -> SBool -> GCDS a -> GCDS a -> GCDS a
Mergeable, a -> GCDS b -> GCDS a
(a -> b) -> GCDS a -> GCDS b
(forall a b. (a -> b) -> GCDS a -> GCDS b)
-> (forall a b. a -> GCDS b -> GCDS a) -> Functor GCDS
forall a b. a -> GCDS b -> GCDS a
forall a b. (a -> b) -> GCDS a -> GCDS b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> GCDS b -> GCDS a
$c<$ :: forall a b. a -> GCDS b -> GCDS a
fmap :: (a -> b) -> GCDS a -> GCDS b
$cfmap :: forall a b. (a -> b) -> GCDS a -> GCDS b
Functor, GCDS a -> Bool
(a -> m) -> GCDS a -> m
(a -> b -> b) -> b -> GCDS a -> b
(forall m. Monoid m => GCDS m -> m)
-> (forall m a. Monoid m => (a -> m) -> GCDS a -> m)
-> (forall m a. Monoid m => (a -> m) -> GCDS a -> m)
-> (forall a b. (a -> b -> b) -> b -> GCDS a -> b)
-> (forall a b. (a -> b -> b) -> b -> GCDS a -> b)
-> (forall b a. (b -> a -> b) -> b -> GCDS a -> b)
-> (forall b a. (b -> a -> b) -> b -> GCDS a -> b)
-> (forall a. (a -> a -> a) -> GCDS a -> a)
-> (forall a. (a -> a -> a) -> GCDS a -> a)
-> (forall a. GCDS a -> [a])
-> (forall a. GCDS a -> Bool)
-> (forall a. GCDS a -> Int)
-> (forall a. Eq a => a -> GCDS a -> Bool)
-> (forall a. Ord a => GCDS a -> a)
-> (forall a. Ord a => GCDS a -> a)
-> (forall a. Num a => GCDS a -> a)
-> (forall a. Num a => GCDS a -> a)
-> Foldable GCDS
forall a. Eq a => a -> GCDS a -> Bool
forall a. Num a => GCDS a -> a
forall a. Ord a => GCDS a -> a
forall m. Monoid m => GCDS m -> m
forall a. GCDS a -> Bool
forall a. GCDS a -> Int
forall a. GCDS a -> [a]
forall a. (a -> a -> a) -> GCDS a -> a
forall m a. Monoid m => (a -> m) -> GCDS a -> m
forall b a. (b -> a -> b) -> b -> GCDS a -> b
forall a b. (a -> b -> b) -> b -> GCDS a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: GCDS a -> a
$cproduct :: forall a. Num a => GCDS a -> a
sum :: GCDS a -> a
$csum :: forall a. Num a => GCDS a -> a
minimum :: GCDS a -> a
$cminimum :: forall a. Ord a => GCDS a -> a
maximum :: GCDS a -> a
$cmaximum :: forall a. Ord a => GCDS a -> a
elem :: a -> GCDS a -> Bool
$celem :: forall a. Eq a => a -> GCDS a -> Bool
length :: GCDS a -> Int
$clength :: forall a. GCDS a -> Int
null :: GCDS a -> Bool
$cnull :: forall a. GCDS a -> Bool
toList :: GCDS a -> [a]
$ctoList :: forall a. GCDS a -> [a]
foldl1 :: (a -> a -> a) -> GCDS a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> GCDS a -> a
foldr1 :: (a -> a -> a) -> GCDS a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> GCDS a -> a
foldl' :: (b -> a -> b) -> b -> GCDS a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> GCDS a -> b
foldl :: (b -> a -> b) -> b -> GCDS a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> GCDS a -> b
foldr' :: (a -> b -> b) -> b -> GCDS a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> GCDS a -> b
foldr :: (a -> b -> b) -> b -> GCDS a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> GCDS a -> b
foldMap' :: (a -> m) -> GCDS a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> GCDS a -> m
foldMap :: (a -> m) -> GCDS a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> GCDS a -> m
fold :: GCDS m -> m
$cfold :: forall m. Monoid m => GCDS m -> m
Foldable, Functor GCDS
Foldable GCDS
Functor GCDS
-> Foldable GCDS
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> GCDS a -> f (GCDS b))
-> (forall (f :: * -> *) a.
Applicative f =>
GCDS (f a) -> f (GCDS a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> GCDS a -> m (GCDS b))
-> (forall (m :: * -> *) a. Monad m => GCDS (m a) -> m (GCDS a))
-> Traversable GCDS
(a -> f b) -> GCDS a -> f (GCDS b)
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a. Monad m => GCDS (m a) -> m (GCDS a)
forall (f :: * -> *) a. Applicative f => GCDS (f a) -> f (GCDS a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> GCDS a -> m (GCDS b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> GCDS a -> f (GCDS b)
sequence :: GCDS (m a) -> m (GCDS a)
$csequence :: forall (m :: * -> *) a. Monad m => GCDS (m a) -> m (GCDS a)
mapM :: (a -> m b) -> GCDS a -> m (GCDS b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> GCDS a -> m (GCDS b)
sequenceA :: GCDS (f a) -> f (GCDS a)
$csequenceA :: forall (f :: * -> *) a. Applicative f => GCDS (f a) -> f (GCDS a)
traverse :: (a -> f b) -> GCDS a -> f (GCDS b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> GCDS a -> f (GCDS b)
$cp2Traversable :: Foldable GCDS
$cp1Traversable :: Functor GCDS
Traversable)
instance {-# OVERLAPS #-} (SymVal a, Show a) => Show (GCDS (SBV a)) where
show :: GCDS (SBV a) -> String
show (GCDS SBV a
x SBV a
y SBV a
i SBV a
j) = String
"{x = " String -> ShowS
forall a. [a] -> [a] -> [a]
++ SBV a -> String
forall a. (Show a, SymVal a) => SBV a -> String
sh SBV a
x String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
", y = " String -> ShowS
forall a. [a] -> [a] -> [a]
++ SBV a -> String
forall a. (Show a, SymVal a) => SBV a -> String
sh SBV a
y String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
", i = " String -> ShowS
forall a. [a] -> [a] -> [a]
++ SBV a -> String
forall a. (Show a, SymVal a) => SBV a -> String
sh SBV a
i String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
", j = " String -> ShowS
forall a. [a] -> [a] -> [a]
++ SBV a -> String
forall a. (Show a, SymVal a) => SBV a -> String
sh SBV a
j String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"}"
where sh :: SBV a -> String
sh SBV a
v = String -> (a -> String) -> Maybe a -> String
forall b a. b -> (a -> b) -> Maybe a -> b
maybe String
"<symbolic>" a -> String
forall a. Show a => a -> String
show (SBV a -> Maybe a
forall a. SymVal a => SBV a -> Maybe a
unliteral SBV a
v)
instance SymVal a => Fresh IO (GCDS (SBV a)) where
fresh :: QueryT IO (GCDS (SBV a))
fresh = SBV a -> SBV a -> SBV a -> SBV a -> GCDS (SBV a)
forall a. a -> a -> a -> a -> GCDS a
GCDS (SBV a -> SBV a -> SBV a -> SBV a -> GCDS (SBV a))
-> QueryT IO (SBV a)
-> QueryT IO (SBV a -> SBV a -> SBV a -> GCDS (SBV a))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> QueryT IO (SBV a)
forall a. SymVal a => Query (SBV a)
freshVar_ QueryT IO (SBV a -> SBV a -> SBV a -> GCDS (SBV a))
-> QueryT IO (SBV a) -> QueryT IO (SBV a -> SBV a -> GCDS (SBV a))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> QueryT IO (SBV a)
forall a. SymVal a => Query (SBV a)
freshVar_ QueryT IO (SBV a -> SBV a -> GCDS (SBV a))
-> QueryT IO (SBV a) -> QueryT IO (SBV a -> GCDS (SBV a))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> QueryT IO (SBV a)
forall a. SymVal a => Query (SBV a)
freshVar_ QueryT IO (SBV a -> GCDS (SBV a))
-> QueryT IO (SBV a) -> QueryT IO (GCDS (SBV a))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> QueryT IO (SBV a)
forall a. SymVal a => Query (SBV a)
freshVar_
type G = GCDS SInteger
algorithm :: Stmt G
algorithm :: Stmt G
algorithm = [Stmt G] -> Stmt G
forall st. [Stmt st] -> Stmt st
Seq [ String -> (G -> SBool) -> Stmt G
forall st. String -> (st -> SBool) -> Stmt st
assert String
"x > 0, y > 0" ((G -> SBool) -> Stmt G) -> (G -> SBool) -> Stmt G
forall a b. (a -> b) -> a -> b
$ \GCDS{SBV Integer
x :: SBV Integer
x :: forall a. GCDS a -> a
x, SBV Integer
y :: SBV Integer
y :: forall a. GCDS a -> a
y} -> SBV Integer
x SBV Integer -> SBV Integer -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.> SBV Integer
0 SBool -> SBool -> SBool
.&& SBV Integer
y SBV Integer -> SBV Integer -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.> SBV Integer
0
, (G -> G) -> Stmt G
forall st. (st -> st) -> Stmt st
Assign ((G -> G) -> Stmt G) -> (G -> G) -> Stmt G
forall a b. (a -> b) -> a -> b
$ \st :: G
st@GCDS{SBV Integer
x :: SBV Integer
x :: forall a. GCDS a -> a
x, SBV Integer
y :: SBV Integer
y :: forall a. GCDS a -> a
y} -> G
st{i :: SBV Integer
i = SBV Integer
x, j :: SBV Integer
j = SBV Integer
y}
, String
-> (G -> SBool)
-> Maybe (Measure G)
-> (G -> SBool)
-> Stmt G
-> Stmt G
forall st.
String
-> Invariant st
-> Maybe (Measure st)
-> Invariant st
-> Stmt st
-> Stmt st
While String
"i != j"
G -> SBool
inv
(Measure G -> Maybe (Measure G)
forall a. a -> Maybe a
Just Measure G
forall a. GCDS a -> [a]
msr)
(\GCDS{SBV Integer
i :: SBV Integer
i :: forall a. GCDS a -> a
i, SBV Integer
j :: SBV Integer
j :: forall a. GCDS a -> a
j} -> SBV Integer
i SBV Integer -> SBV Integer -> SBool
forall a. EqSymbolic a => a -> a -> SBool
./= SBV Integer
j)
(Stmt G -> Stmt G) -> Stmt G -> Stmt G
forall a b. (a -> b) -> a -> b
$ (G -> SBool) -> Stmt G -> Stmt G -> Stmt G
forall st. Invariant st -> Stmt st -> Stmt st -> Stmt st
If (\GCDS{SBV Integer
i :: SBV Integer
i :: forall a. GCDS a -> a
i, SBV Integer
j :: SBV Integer
j :: forall a. GCDS a -> a
j} -> SBV Integer
i SBV Integer -> SBV Integer -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.> SBV Integer
j)
((G -> G) -> Stmt G
forall st. (st -> st) -> Stmt st
Assign ((G -> G) -> Stmt G) -> (G -> G) -> Stmt G
forall a b. (a -> b) -> a -> b
$ \st :: G
st@GCDS{SBV Integer
i :: SBV Integer
i :: forall a. GCDS a -> a
i, SBV Integer
j :: SBV Integer
j :: forall a. GCDS a -> a
j} -> G
st{i :: SBV Integer
i = SBV Integer
i SBV Integer -> SBV Integer -> SBV Integer
forall a. Num a => a -> a -> a
- SBV Integer
j})
((G -> G) -> Stmt G
forall st. (st -> st) -> Stmt st
Assign ((G -> G) -> Stmt G) -> (G -> G) -> Stmt G
forall a b. (a -> b) -> a -> b
$ \st :: G
st@GCDS{SBV Integer
i :: SBV Integer
i :: forall a. GCDS a -> a
i, SBV Integer
j :: SBV Integer
j :: forall a. GCDS a -> a
j} -> G
st{j :: SBV Integer
j = SBV Integer
j SBV Integer -> SBV Integer -> SBV Integer
forall a. Num a => a -> a -> a
- SBV Integer
i})
]
where
inv :: G -> SBool
inv GCDS{SBV Integer
x :: SBV Integer
x :: forall a. GCDS a -> a
x, SBV Integer
y :: SBV Integer
y :: forall a. GCDS a -> a
y, SBV Integer
i :: SBV Integer
i :: forall a. GCDS a -> a
i, SBV Integer
j :: SBV Integer
j :: forall a. GCDS a -> a
j} = SBV Integer
x SBV Integer -> SBV Integer -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.> SBV Integer
0 SBool -> SBool -> SBool
.&& SBV Integer
y SBV Integer -> SBV Integer -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.> SBV Integer
0 SBool -> SBool -> SBool
.&& SBV Integer
i SBV Integer -> SBV Integer -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.> SBV Integer
0 SBool -> SBool -> SBool
.&& SBV Integer
j SBV Integer -> SBV Integer -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.> SBV Integer
0 SBool -> SBool -> SBool
.&& SBV Integer -> SBV Integer -> SBV Integer
gcd SBV Integer
x SBV Integer
y SBV Integer -> SBV Integer -> SBool
forall a. EqSymbolic a => a -> a -> SBool
.== SBV Integer -> SBV Integer -> SBV Integer
gcd SBV Integer
i SBV Integer
j
msr :: GCDS a -> [a]
msr GCDS{a
i :: a
i :: forall a. GCDS a -> a
i, a
j :: a
j :: forall a. GCDS a -> a
j} = [a
i, a
j]
gcd :: SInteger -> SInteger -> SInteger
gcd :: SBV Integer -> SBV Integer -> SBV Integer
gcd SBV Integer
x SBV Integer
y
| Just Integer
i <- SBV Integer -> Maybe Integer
forall a. SymVal a => SBV a -> Maybe a
unliteral SBV Integer
x, Just Integer
j <- SBV Integer -> Maybe Integer
forall a. SymVal a => SBV a -> Maybe a
unliteral SBV Integer
y
= Integer -> SBV Integer
forall a. SymVal a => a -> SBV a
literal (Integer -> Integer -> Integer
forall a. Integral a => a -> a -> a
P.gcd Integer
i Integer
j)
| Bool
True
= String -> SBV Integer -> SBV Integer -> SBV Integer
forall a. Uninterpreted a => String -> a
uninterpret String
"gcd" SBV Integer
x SBV Integer
y
axiomatizeGCD :: Symbolic ()
axiomatizeGCD :: Symbolic ()
axiomatizeGCD = do
SBV Integer
x <- Symbolic (SBV Integer)
sInteger_
SBool -> Symbolic ()
forall (m :: * -> *). SolverContext m => SBool -> m ()
constrain (SBool -> Symbolic ()) -> SBool -> Symbolic ()
forall a b. (a -> b) -> a -> b
$ SBV Integer -> SBV Integer -> SBV Integer
gcd SBV Integer
x SBV Integer
x SBV Integer -> SBV Integer -> SBool
forall a. EqSymbolic a => a -> a -> SBool
.== SBV Integer
x
String -> [String] -> Symbolic ()
forall (m :: * -> *). SolverContext m => String -> [String] -> m ()
addAxiom String
"gcd_equal" [ String
"(assert (forall ((x Int))"
, String
" (=> (> x 0) (= (gcd x x) x))))"
]
String -> [String] -> Symbolic ()
forall (m :: * -> *). SolverContext m => String -> [String] -> m ()
addAxiom String
"gcd_unequal1" [ String
"(assert (forall ((x Int) (y Int))"
, String
" (=> (and (> x 0) (> y 0)) (= (gcd (+ x y) y) (gcd x y)))))"
]
String -> [String] -> Symbolic ()
forall (m :: * -> *). SolverContext m => String -> [String] -> m ()
addAxiom String
"gcd_unequal2" [ String
"(assert (forall ((x Int) (y Int))"
, String
" (=> (and (> x 0) (> y 0)) (= (gcd x (+ y x)) (gcd x y)))))"
]
pre :: G -> SBool
pre :: G -> SBool
pre GCDS{SBV Integer
x :: SBV Integer
x :: forall a. GCDS a -> a
x, SBV Integer
y :: SBV Integer
y :: forall a. GCDS a -> a
y} = SBV Integer
x SBV Integer -> SBV Integer -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.> SBV Integer
0 SBool -> SBool -> SBool
.&& SBV Integer
y SBV Integer -> SBV Integer -> SBool
forall a. OrdSymbolic a => a -> a -> SBool
.> SBV Integer
0
post :: G -> SBool
post :: G -> SBool
post GCDS{SBV Integer
x :: SBV Integer
x :: forall a. GCDS a -> a
x, SBV Integer
y :: SBV Integer
y :: forall a. GCDS a -> a
y, SBV Integer
i :: SBV Integer
i :: forall a. GCDS a -> a
i, SBV Integer
j :: SBV Integer
j :: forall a. GCDS a -> a
j} = SBV Integer
i SBV Integer -> SBV Integer -> SBool
forall a. EqSymbolic a => a -> a -> SBool
.== SBV Integer
j SBool -> SBool -> SBool
.&& SBV Integer
i SBV Integer -> SBV Integer -> SBool
forall a. EqSymbolic a => a -> a -> SBool
.== SBV Integer -> SBV Integer -> SBV Integer
gcd SBV Integer
x SBV Integer
y
noChange :: Stable G
noChange :: Stable G
noChange = [String -> (G -> SBV Integer) -> G -> G -> (String, SBool)
forall a st.
EqSymbolic a =>
String -> (st -> a) -> st -> st -> (String, SBool)
stable String
"x" G -> SBV Integer
forall a. GCDS a -> a
x, String -> (G -> SBV Integer) -> G -> G -> (String, SBool)
forall a st.
EqSymbolic a =>
String -> (st -> a) -> st -> st -> (String, SBool)
stable String
"y" G -> SBV Integer
forall a. GCDS a -> a
y]
imperativeGCD :: Program G
imperativeGCD :: Program G
imperativeGCD = Program :: forall st.
Symbolic ()
-> (st -> SBool)
-> Stmt st
-> (st -> SBool)
-> Stable st
-> Program st
Program { setup :: Symbolic ()
setup = Symbolic ()
axiomatizeGCD
, precondition :: G -> SBool
precondition = G -> SBool
pre
, program :: Stmt G
program = Stmt G
algorithm
, postcondition :: G -> SBool
postcondition = G -> SBool
post
, stability :: Stable G
stability = Stable G
noChange
}
correctness :: IO (ProofResult (GCDS Integer))
correctness :: IO (ProofResult (GCDS Integer))
correctness = WPConfig -> Program G -> IO (ProofResult (GCDS Integer))
forall st res.
(Show res, Mergeable st, Queriable IO st res) =>
WPConfig -> Program st -> IO (ProofResult res)
wpProveWith WPConfig
defaultWPCfg{wpVerbose :: Bool
wpVerbose=Bool
True} Program G
imperativeGCD