sbv-10.2: SMT Based Verification: Symbolic Haskell theorem prover using SMT solving.

Copyright | (c) Levent Erkok
License | BSD3
Maintainer | erkokl@gmail.com
Stability | experimental
Safe Haskell | Safe-Inferred
Language | Haskell2010

Documentation.SBV.Examples.Uninterpreted.UISortAllSat

Description

Demonstrates uninterpreted sorts and how all-sat behaves for them. Thanks to Eric Seidel for the idea.

Synopsis

- data L
- type SL = SBV L
- classify :: SL -> SInteger
- genLs :: Predicate

# Documentation

    >>> -- For doctest purposes only:
    >>> import Data.SBV

data L Source #

A "list-like" data type, but one we plan to uninterpret at the SMT level. The actual shape is really immaterial for us.

#### Instances

Instances details

Data L Source # |

Instance details

Defined in Documentation.SBV.Examples.Uninterpreted.UISortAllSat

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> L -> c L Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c L Source #

toConstr :: L -> Constr Source #

dataTypeOf :: L -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c L) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c L) Source #

gmapT :: (forall b. Data b => b -> b) -> L -> L Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> L -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> L -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> L -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> L -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> L -> m L Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> L -> m L Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> L -> m L Source #

Read L Source # |
Instance details Defined in Documentation.SBV.Examples.Uninterpreted.UISortAllSat Methods readsPrec :: Int -> ReadS L Source # readList :: ReadS [L] Source # readPrec :: ReadPrec L Source # readListPrec :: ReadPrec [L] Source #
Show L Source # |
Instance details Defined in Documentation.SBV.Examples.Uninterpreted.UISortAllSat Methods showsPrec :: Int -> L -> ShowS Source # show :: L -> String Source # showList :: [L] -> ShowS Source #
SymVal L Source # |

Instance details

Defined in Documentation.SBV.Examples.Uninterpreted.UISortAllSat

Methods

mkSymVal :: MonadSymbolic m => VarContext -> Maybe String -> m (SBV L) Source #

literal :: L -> SBV L Source #

fromCV :: CV -> L Source #

isConcretely :: SBV L -> (L -> Bool) -> Bool Source #

free :: MonadSymbolic m => String -> m (SBV L) Source #

free_ :: MonadSymbolic m => m (SBV L) Source #

mkFreeVars :: MonadSymbolic m => Int -> m [SBV L] Source #

symbolic :: MonadSymbolic m => String -> m (SBV L) Source #

symbolics :: MonadSymbolic m => [String] -> m [SBV L] Source #

unliteral :: SBV L -> Maybe L Source #

isConcrete :: SBV L -> Bool Source #

isSymbolic :: SBV L -> Bool Source #

HasKind L Source # |

Instance details

Defined in Documentation.SBV.Examples.Uninterpreted.UISortAllSat

Methods

kindOf :: L -> Kind Source #

hasSign :: L -> Bool Source #

intSizeOf :: L -> Int Source #

isBoolean :: L -> Bool Source #

isBounded :: L -> Bool Source #

isReal :: L -> Bool Source #

isFloat :: L -> Bool Source #

isDouble :: L -> Bool Source #

isRational :: L -> Bool Source #

isFP :: L -> Bool Source #

isUnbounded :: L -> Bool Source #

isUserSort :: L -> Bool Source #

isChar :: L -> Bool Source #

isString :: L -> Bool Source #

isList :: L -> Bool Source #

isSet :: L -> Bool Source #

isTuple :: L -> Bool Source #

isMaybe :: L -> Bool Source #

isEither :: L -> Bool Source #

showType :: L -> String Source #

SatModel L Source # |
Instance details Defined in Documentation.SBV.Examples.Uninterpreted.UISortAllSat Methods parseCVs :: [CV] -> Maybe (L, [CV]) Source # cvtModel :: (L -> Maybe b) -> Maybe (L, [CV]) -> Maybe (b, [CV]) Source #

type SL = SBV L Source #

Symbolic version of the type `L`.

classify :: SL -> SInteger Source #

An uninterpreted "classify" function. Really, we only care about the fact that such a function exists, not what it does.

genLs :: Predicate Source #

Formulate a query that essentially asserts a cardinality constraint on the uninterpreted sort `L`. The goal is to say there are precisely 3 such things, as it might be the case. We manage this by declaring four elements, and asserting that for a free variable of this sort, the shape of the data matches one of these three instances. That is, we assert that all the instances of the data `L` can be classified into 3 equivalence classes. Then, allSat returns all the possible instances, which of course are all uninterpreted.

As expected, we have:

    >>> allSat genLs
    Solution #1:
      l  = L!val!2 :: L
      l0 = L!val!0 :: L
      l1 = L!val!1 :: L
      l2 = L!val!2 :: L

      classify :: L -> Integer
      classify L!val!2 = 2
      classify L!val!1 = 1
      classify _       = 0
    Solution #2:
      l  = L!val!1 :: L
      l0 = L!val!0 :: L
      l1 = L!val!1 :: L
      l2 = L!val!2 :: L

      classify :: L -> Integer
      classify L!val!2 = 2
      classify L!val!1 = 1
      classify _       = 0
    Solution #3:
      l  = L!val!0 :: L
      l0 = L!val!0 :: L
      l1 = L!val!1 :: L
      l2 = L!val!2 :: L

      classify :: L -> Integer
      classify L!val!2 = 2
      classify L!val!1 = 1
      classify _       = 0
    Found 3 different solutions.