| Copyright | (c) Levent Erkok |
|---|---|
| License | BSD3 |
| Maintainer | erkokl@gmail.com |
| Stability | experimental |
| Safe Haskell | None |
| Language | Haskell2010 |
Documentation.SBV.Examples.ProofTools.Sum
Contents
Description
Example inductive proof to show partial correctness of the traditional for-loop sum algorithm:
s = 0
i = 0
while i <= n:
s += i
i++
We prove the loop invariant and establish partial correctness that
s is the sum of all numbers up to and including n upon termination.
Synopsis
- data S a = S {}
- sumCorrect :: IO (InductionResult (S Integer))
System state
System state. We simply have two components, parameterized over the type so we can put in both concrete and symbolic values.
Instances
| Functor S Source # | |||||
| Foldable S Source # | |||||
Defined in Documentation.SBV.Examples.ProofTools.Sum Methods fold :: Monoid m => S m -> m # foldMap :: Monoid m => (a -> m) -> S a -> m # foldMap' :: Monoid m => (a -> m) -> S a -> m # foldr :: (a -> b -> b) -> b -> S a -> b # foldr' :: (a -> b -> b) -> b -> S a -> b # foldl :: (b -> a -> b) -> b -> S a -> b # foldl' :: (b -> a -> b) -> b -> S a -> b # foldr1 :: (a -> a -> a) -> S a -> a # foldl1 :: (a -> a -> a) -> S a -> a # elem :: Eq a => a -> S a -> Bool # maximum :: Ord a => S a -> a # | |||||
| Traversable S Source # | |||||
| Queriable IO (S SInteger) Source # | 'Queriable instance for our state | ||||
Defined in Documentation.SBV.Examples.ProofTools.Sum Associated Types
| |||||
| Show a => Show (S a) Source # | |||||
| type QueryResult (S SInteger) Source # | |||||
Defined in Documentation.SBV.Examples.ProofTools.Sum | |||||
sumCorrect :: IO (InductionResult (S Integer)) Source #
Encoding partial correctness of the sum algorithm. We have:
>>>sumCorrectQ.E.D.