Safe Haskell | None |
---|---|
Language | Haskell98 |
Example usage: This program tries to find two numbers greater than zero which sum up to 5.
import Language.SMTLib2 import Language.SMTLib2.Solver program :: SMT (Integer,Integer) program = do x <- var y <- var assert $ (plus [x,y]) .==. (constant 5) assert $ x .>. (constant 0) assert $ y .>. (constant 0) checkSat vx <- getValue x vy <- getValue y return (vx,vy) main = withZ3 program >>= print
- data SMT' m a
- type SMT = SMT' IO
- class Monad m => SMTBackend a m
- data AnyBackend m = SMTBackend b m => AnyBackend b
- class (Ord t, Typeable t, Ord (SMTAnnotation t), Typeable (SMTAnnotation t), Show (SMTAnnotation t)) => SMTType t where
- type SMTAnnotation t
- class (SMTType t, Show t) => SMTValue t
- class (SMTValue t, Num t, SMTAnnotation t ~ ()) => SMTArith t
- class SMTType t => SMTOrd t where
- data SMTExpr t
- data SMTFunction arg res
- data SMTOption
- data SMTArray i v
- data Constructor arg res
- data Field a f
- class (Ord a, Typeable a, Show a, Ord (ArgAnnotation a), Typeable (ArgAnnotation a), Show (ArgAnnotation a)) => Args a where
- type ArgAnnotation a
- class Args a => LiftArgs a where
- type Unpacked a
- withSMTBackend :: SMTBackend a m => a -> SMT' m b -> m b
- withSMTBackendExitCleanly :: SMTBackend b IO => b -> SMT a -> IO a
- setOption :: Monad m => SMTOption -> SMT' m ()
- getInfo :: (Monad m, Typeable i) => SMTInfo i -> SMT' m i
- setLogic :: Monad m => String -> SMT' m ()
- data SMTInfo i where
- assert :: Monad m => SMTExpr Bool -> SMT' m ()
- push :: Monad m => SMT' m ()
- pop :: Monad m => SMT' m ()
- stack :: Monad m => SMT' m a -> SMT' m a
- checkSat :: Monad m => SMT' m Bool
- checkSat' :: Monad m => Maybe Tactic -> CheckSatLimits -> SMT' m CheckSatResult
- checkSatUsing :: Monad m => Tactic -> SMT' m Bool
- apply :: Monad m => Tactic -> SMT' m [SMTExpr Bool]
- data CheckSatResult
- data CheckSatLimits = CheckSatLimits {}
- noLimits :: CheckSatLimits
- getValue :: (SMTValue t, Monad m) => SMTExpr t -> SMT' m t
- getValues :: (LiftArgs arg, Monad m) => arg -> SMT' m (Unpacked arg)
- getModel :: Monad m => SMT' m SMTModel
- comment :: Monad m => String -> SMT' m ()
- getProof :: Monad m => SMT' m (SMTExpr Bool)
- simplify :: (SMTType t, Monad m) => SMTExpr t -> SMT' m (SMTExpr t)
- data ClauseId
- assertId :: Monad m => SMTExpr Bool -> SMT' m ClauseId
- getUnsatCore :: Monad m => SMT' m [ClauseId]
- data InterpolationGroup
- interpolationGroup :: Monad m => SMT' m InterpolationGroup
- assertInterp :: Monad m => SMTExpr Bool -> InterpolationGroup -> SMT' m ()
- getInterpolant :: Monad m => [InterpolationGroup] -> SMT' m (SMTExpr Bool)
- interpolate :: Monad m => [SMTExpr Bool] -> SMT' m [SMTExpr Bool]
- var :: (SMTType t, Typeable t, Unit (SMTAnnotation t), Monad m) => SMT' m (SMTExpr t)
- varNamed :: (SMTType t, Typeable t, Unit (SMTAnnotation t), Monad m) => String -> SMT' m (SMTExpr t)
- varNamedAnn :: (SMTType t, Typeable t, Monad m) => String -> SMTAnnotation t -> SMT' m (SMTExpr t)
- varAnn :: (SMTType t, Typeable t, Monad m) => SMTAnnotation t -> SMT' m (SMTExpr t)
- argVars :: (Args a, Unit (ArgAnnotation a), Monad m) => SMT' m a
- argVarsAnn :: (Args a, Monad m) => ArgAnnotation a -> SMT' m a
- argVarsAnnNamed :: (Args a, Monad m) => String -> ArgAnnotation a -> SMT' m a
- untypedVar :: Monad m => Sort -> SMT' m (SMTExpr Untyped)
- untypedNamedVar :: Monad m => String -> Sort -> SMT' m (SMTExpr Untyped)
- constant :: (SMTValue t, Unit (SMTAnnotation t)) => t -> SMTExpr t
- constantAnn :: SMTValue t => t -> SMTAnnotation t -> SMTExpr t
- extractAnnotation :: SMTExpr a -> SMTAnnotation a
- let' :: (Args a, Unit (ArgAnnotation a), SMTType b) => a -> (a -> SMTExpr b) -> SMTExpr b
- lets :: (Args a, Unit (ArgAnnotation a), SMTType b) => [a] -> ([a] -> SMTExpr b) -> SMTExpr b
- letAnn :: (Args a, SMTType b) => ArgAnnotation a -> a -> (a -> SMTExpr b) -> SMTExpr b
- named :: (SMTType a, SMTAnnotation a ~ (), Monad m) => String -> SMTExpr a -> SMT' m (SMTExpr a, SMTExpr a)
- named' :: (SMTType a, SMTAnnotation a ~ (), Monad m) => SMTExpr a -> SMT' m (SMTExpr a, SMTExpr a)
- optimizeExpr :: SMTExpr t -> Maybe (SMTExpr t)
- optimizeExpr' :: SMTExpr a -> SMTExpr a
- foldExpr :: SMTType a => (forall t. SMTType t => s -> SMTExpr t -> (s, SMTExpr t)) -> s -> SMTExpr a -> (s, SMTExpr a)
- foldExprM :: (SMTType a, Monad m) => (forall t. SMTType t => s -> SMTExpr t -> m (s, [SMTExpr t])) -> s -> SMTExpr a -> m (s, [SMTExpr a])
- foldArgs :: Args a => (forall t. SMTType t => s -> SMTExpr t -> (s, SMTExpr t)) -> s -> a -> (s, a)
- foldArgsM :: (Args a, Monad m) => (forall t. SMTType t => s -> SMTExpr t -> m (s, [SMTExpr t])) -> s -> a -> m (s, [a])
- (.==.) :: SMTType a => SMTExpr a -> SMTExpr a -> SMTExpr Bool
- argEq :: Args a => a -> a -> SMTExpr Bool
- distinct :: SMTType a => [SMTExpr a] -> SMTExpr Bool
- ite :: SMTType a => SMTExpr Bool -> SMTExpr a -> SMTExpr a -> SMTExpr a
- (.&&.) :: SMTExpr Bool -> SMTExpr Bool -> SMTExpr Bool
- (.||.) :: SMTExpr Bool -> SMTExpr Bool -> SMTExpr Bool
- and' :: SMTFunction [SMTExpr Bool] Bool
- or' :: SMTFunction [SMTExpr Bool] Bool
- xor :: SMTFunction [SMTExpr Bool] Bool
- not' :: SMTExpr Bool -> SMTExpr Bool
- not'' :: SMTFunction (SMTExpr Bool) Bool
- (.=>.) :: SMTExpr Bool -> SMTExpr Bool -> SMTExpr Bool
- forAll :: (Args a, Unit (ArgAnnotation a)) => (a -> SMTExpr Bool) -> SMTExpr Bool
- exists :: (Args a, Unit (ArgAnnotation a)) => (a -> SMTExpr Bool) -> SMTExpr Bool
- forAllAnn :: Args a => ArgAnnotation a -> (a -> SMTExpr Bool) -> SMTExpr Bool
- existsAnn :: Args a => ArgAnnotation a -> (a -> SMTExpr Bool) -> SMTExpr Bool
- forAllList :: (Args a, Unit (ArgAnnotation a)) => Integer -> ([a] -> SMTExpr Bool) -> SMTExpr Bool
- existsList :: (Args a, Unit (ArgAnnotation a)) => Integer -> ([a] -> SMTExpr Bool) -> SMTExpr Bool
- plus :: SMTArith a => SMTFunction [SMTExpr a] a
- minus :: SMTArith a => SMTFunction (SMTExpr a, SMTExpr a) a
- mult :: SMTArith a => SMTFunction [SMTExpr a] a
- div' :: SMTExpr Integer -> SMTExpr Integer -> SMTExpr Integer
- mod' :: SMTExpr Integer -> SMTExpr Integer -> SMTExpr Integer
- rem' :: SMTExpr Integer -> SMTExpr Integer -> SMTExpr Integer
- neg :: SMTArith a => SMTFunction (SMTExpr a) a
- divide :: SMTExpr Rational -> SMTExpr Rational -> SMTExpr Rational
- toReal :: SMTExpr Integer -> SMTExpr Rational
- toInt :: SMTExpr Rational -> SMTExpr Integer
- select :: (Liftable i, SMTType v) => SMTExpr (SMTArray i v) -> i -> SMTExpr v
- store :: (Liftable i, SMTType v) => SMTExpr (SMTArray i v) -> i -> SMTExpr v -> SMTExpr (SMTArray i v)
- arrayEquals :: (LiftArgs i, Liftable i, SMTValue v, Ix (Unpacked i), Unit (ArgAnnotation i), Unit (SMTAnnotation v)) => SMTExpr (SMTArray i v) -> Array (Unpacked i) v -> SMTExpr Bool
- unmangleArray :: (Liftable i, LiftArgs i, Ix (Unpacked i), SMTValue v, Unit (ArgAnnotation i), Monad m) => (Unpacked i, Unpacked i) -> SMTExpr (SMTArray i v) -> SMT' m (Array (Unpacked i) v)
- asArray :: (Args arg, Unit (ArgAnnotation arg), SMTType res) => SMTFunction arg res -> SMTExpr (SMTArray arg res)
- constArray :: (Args i, SMTType v) => SMTExpr v -> ArgAnnotation i -> SMTExpr (SMTArray i v)
- bvand :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) -> SMTExpr (BitVector t)
- bvor :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) -> SMTExpr (BitVector t)
- bvxor :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) -> SMTExpr (BitVector t)
- bvnot :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t)
- bvneg :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t)
- bvadd :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) -> SMTExpr (BitVector t)
- bvsub :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) -> SMTExpr (BitVector t)
- bvmul :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) -> SMTExpr (BitVector t)
- bvurem :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) -> SMTExpr (BitVector t)
- bvsrem :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) -> SMTExpr (BitVector t)
- bvudiv :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) -> SMTExpr (BitVector t)
- bvsdiv :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) -> SMTExpr (BitVector t)
- bvule :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) -> SMTExpr Bool
- bvult :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) -> SMTExpr Bool
- bvuge :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) -> SMTExpr Bool
- bvugt :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) -> SMTExpr Bool
- bvsle :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) -> SMTExpr Bool
- bvslt :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) -> SMTExpr Bool
- bvsge :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) -> SMTExpr Bool
- bvsgt :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) -> SMTExpr Bool
- bvshl :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) -> SMTExpr (BitVector t)
- bvlshr :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) -> SMTExpr (BitVector t)
- bvashr :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) -> SMTExpr (BitVector t)
- data BitVector b = BitVector Integer
- data BVTyped n
- data BVUntyped
- type BV8 = BitVector (BVTyped N8)
- type BV16 = BitVector (BVTyped N16)
- type BV32 = BitVector (BVTyped N32)
- type BV64 = BitVector (BVTyped N64)
- type N0 = Z
- type N1 = S N0
- type N2 = S N1
- type N3 = S N2
- type N4 = S N3
- type N5 = S N4
- type N6 = S N5
- type N7 = S N6
- type N8 = S N7
- type N9 = S N8
- type N10 = S N9
- type N11 = S N10
- type N12 = S N11
- type N13 = S N12
- type N14 = S N13
- type N15 = S N14
- type N16 = S N15
- type N17 = S N16
- type N18 = S N17
- type N19 = S N18
- type N20 = S N19
- type N21 = S N20
- type N22 = S N21
- type N23 = S N22
- type N24 = S N23
- type N25 = S N24
- type N26 = S N25
- type N27 = S N26
- type N28 = S N27
- type N29 = S N28
- type N30 = S N29
- type N31 = S N30
- type N32 = S N31
- type N33 = S N32
- type N34 = S N33
- type N35 = S N34
- type N36 = S N35
- type N37 = S N36
- type N38 = S N37
- type N39 = S N38
- type N40 = S N39
- type N41 = S N40
- type N42 = S N41
- type N43 = S N42
- type N44 = S N43
- type N45 = S N44
- type N46 = S N45
- type N47 = S N46
- type N48 = S N47
- type N49 = S N48
- type N50 = S N49
- type N51 = S N50
- type N52 = S N51
- type N53 = S N52
- type N54 = S N53
- type N55 = S N54
- type N56 = S N55
- type N57 = S N56
- type N58 = S N57
- type N59 = S N58
- type N60 = S N59
- type N61 = S N60
- type N62 = S N61
- type N63 = S N62
- type N64 = S N63
- bvconcat :: Concatable t1 t2 => SMTExpr (BitVector t1) -> SMTExpr (BitVector t2) -> SMTExpr (BitVector (ConcatResult t1 t2))
- bvsplitu16to8 :: SMTExpr BV16 -> (SMTExpr BV8, SMTExpr BV8)
- bvsplitu32to16 :: SMTExpr BV32 -> (SMTExpr BV16, SMTExpr BV16)
- bvsplitu32to8 :: SMTExpr BV32 -> (SMTExpr BV8, SMTExpr BV8, SMTExpr BV8, SMTExpr BV8)
- bvsplitu64to32 :: SMTExpr BV64 -> (SMTExpr BV32, SMTExpr BV32)
- bvsplitu64to16 :: SMTExpr BV64 -> (SMTExpr BV16, SMTExpr BV16, SMTExpr BV16, SMTExpr BV16)
- bvsplitu64to8 :: SMTExpr BV64 -> (SMTExpr BV8, SMTExpr BV8, SMTExpr BV8, SMTExpr BV8, SMTExpr BV8, SMTExpr BV8, SMTExpr BV8, SMTExpr BV8)
- bvextract :: (TypeableNat start, TypeableNat len, Extractable tp len') => Proxy start -> Proxy len -> SMTExpr (BitVector tp) -> SMTExpr (BitVector len')
- bvextract' :: Integer -> Integer -> SMTExpr (BitVector BVUntyped) -> SMTExpr (BitVector BVUntyped)
- funAnn :: (Liftable a, SMTType r, Monad m) => ArgAnnotation a -> SMTAnnotation r -> SMT' m (SMTFunction a r)
- funAnnNamed :: (Liftable a, SMTType r, Monad m) => String -> ArgAnnotation a -> SMTAnnotation r -> SMT' m (SMTFunction a r)
- funAnnRet :: (Liftable a, SMTType r, Unit (ArgAnnotation a), Monad m) => SMTAnnotation r -> SMT' m (SMTFunction a r)
- fun :: (Liftable a, SMTType r, SMTAnnotation r ~ (), Unit (ArgAnnotation a), Monad m) => SMT' m (SMTFunction a r)
- app :: (Args arg, SMTType res) => SMTFunction arg res -> arg -> SMTExpr res
- defFun :: (Args a, SMTType r, Unit (ArgAnnotation a), Monad m) => (a -> SMTExpr r) -> SMT' m (SMTFunction a r)
- defConst :: (SMTType r, Monad m) => SMTExpr r -> SMT' m (SMTExpr r)
- defConstNamed :: (SMTType r, Monad m) => String -> SMTExpr r -> SMT' m (SMTExpr r)
- defFunAnn :: (Args a, SMTType r, Monad m) => ArgAnnotation a -> (a -> SMTExpr r) -> SMT' m (SMTFunction a r)
- defFunAnnNamed :: (Args a, SMTType r, Monad m) => String -> ArgAnnotation a -> (a -> SMTExpr r) -> SMT' m (SMTFunction a r)
- map' :: (Liftable arg, Args i, SMTType res) => SMTFunction arg res -> SMTFunction (Lifted arg i) (SMTArray i res)
- is :: (Args arg, SMTType dt) => SMTExpr dt -> Constructor arg dt -> SMTExpr Bool
- (.#) :: (SMTType a, SMTType f) => SMTExpr a -> Field a f -> SMTExpr f
- head' :: (SMTType a, Unit (SMTAnnotation a)) => SMTExpr [a] -> SMTExpr a
- tail' :: (SMTType a, Unit (SMTAnnotation a)) => SMTExpr [a] -> SMTExpr [a]
- insert' :: SMTType a => SMTAnnotation a -> Constructor (SMTExpr a, SMTExpr [a]) [a]
- isNil :: SMTType a => SMTExpr [a] -> SMTExpr Bool
- isInsert :: (SMTType a, Unit (SMTAnnotation a)) => SMTExpr [a] -> SMTExpr Bool
- data Untyped
- data UntypedValue
- entype :: (forall a. SMTType a => SMTExpr a -> b) -> SMTExpr Untyped -> b
- entypeValue :: (forall a. SMTValue a => SMTExpr a -> b) -> SMTExpr UntypedValue -> b
- castUntypedExpr :: SMTType t => SMTExpr Untyped -> SMTExpr t
- castUntypedExprValue :: SMTType t => SMTExpr UntypedValue -> SMTExpr t
Data types
The SMT monad used for communating with the SMT solver
class Monad m => SMTBackend a m Source #
MonadIO m => SMTBackend SMTPipe m Source # | |
Monad m => SMTBackend (AnyBackend m) m Source # | |
data AnyBackend m Source #
SMTBackend b m => AnyBackend b |
Monad m => SMTBackend (AnyBackend m) m Source # | |
class (Ord t, Typeable t, Ord (SMTAnnotation t), Typeable (SMTAnnotation t), Show (SMTAnnotation t)) => SMTType t Source #
Haskell types which can be represented in SMT
type SMTAnnotation t Source #
class (SMTType t, Show t) => SMTValue t Source #
Haskell values which can be represented as SMT constants
class (SMTValue t, Num t, SMTAnnotation t ~ ()) => SMTArith t Source #
A type class for all types which support arithmetic operations in SMT
An abstract SMT expression
data SMTFunction arg res Source #
Show (SMTFunction arg res) Source # | |
Options controling the behaviour of the SMT solver
PrintSuccess Bool | Whether or not to print "success" after each operation |
ProduceModels Bool | Produce a satisfying assignment after each successful checkSat |
ProduceProofs Bool | Produce a proof of unsatisfiability after each failed checkSat |
ProduceUnsatCores Bool | Enable the querying of unsatisfiable cores after a failed checkSat |
ProduceInterpolants Bool | Enable the generation of craig interpolants |
An array which maps indices of type i to elements of type v.
data Constructor arg res Source #
Represents a constructor of a datatype a Can be obtained by using the template haskell extension module
Show (Constructor arg res) Source # | |
class (Ord a, Typeable a, Show a, Ord (ArgAnnotation a), Typeable (ArgAnnotation a), Show (ArgAnnotation a)) => Args a where Source #
Instances of this class may be used as arguments for constructed functions and quantifiers.
type ArgAnnotation a Source #
foldExprs :: Monad m => (forall t. SMTType t => s -> SMTExpr t -> SMTAnnotation t -> m (s, SMTExpr t)) -> s -> a -> ArgAnnotation a -> m (s, a) Source #
foldsExprs :: Monad m => (forall t. SMTType t => s -> [(SMTExpr t, b)] -> SMTAnnotation t -> m (s, [SMTExpr t], SMTExpr t)) -> s -> [(a, b)] -> ArgAnnotation a -> m (s, [a], a) Source #
extractArgAnnotation :: a -> ArgAnnotation a Source #
toArgs :: ArgAnnotation a -> [SMTExpr Untyped] -> Maybe (a, [SMTExpr Untyped]) Source #
fromArgs :: a -> [SMTExpr Untyped] Source #
getTypes :: a -> ArgAnnotation a -> [ProxyArg] Source #
getArgAnnotation :: a -> [Sort] -> (ArgAnnotation a, [Sort]) Source #
class Args a => LiftArgs a where Source #
An extension of the Args
class: Instances of this class can be represented as native haskell data types.
Environment
withSMTBackend :: SMTBackend a m => a -> SMT' m b -> m b Source #
withSMTBackendExitCleanly :: SMTBackend b IO => b -> SMT a -> IO a Source #
getInfo :: (Monad m, Typeable i) => SMTInfo i -> SMT' m i Source #
Get information about the underlying SMT solver
setLogic :: Monad m => String -> SMT' m () Source #
Sets the logic used for the following program (Not needed for many solvers).
stack :: Monad m => SMT' m a -> SMT' m a Source #
Perform a stacked operation, meaning that every assertion and declaration made in it will be undone after the operation.
checkSat :: Monad m => SMT' m Bool Source #
Check if the model is satisfiable (e.g. if there is a value for each variable so that every assertion holds)
checkSat' :: Monad m => Maybe Tactic -> CheckSatLimits -> SMT' m CheckSatResult Source #
Like checkSat
, but gives you more options like choosing a tactic (Z3 only) or providing memory/time-limits
checkSatUsing :: Monad m => Tactic -> SMT' m Bool Source #
Check if the model is satisfiable using a given tactic. (Works only with Z3)
apply :: Monad m => Tactic -> SMT' m [SMTExpr Bool] Source #
Apply the given tactic to the current assertions. (Works only with Z3)
data CheckSatResult Source #
The result of a check-sat query
data CheckSatLimits Source #
Describe limits on the ressources that an SMT-solver can use
comment :: Monad m => String -> SMT' m () Source #
Insert a comment into the SMTLib2 command stream. If you aren't looking at the command stream for debugging, this will do nothing.
getProof :: Monad m => SMT' m (SMTExpr Bool) Source #
After an unsuccessful checkSat
this method extracts a proof from the SMT solver that the instance is unsatisfiable.
simplify :: (SMTType t, Monad m) => SMTExpr t -> SMT' m (SMTExpr t) Source #
Use the SMT solver to simplify a given expression. Currently only works with Z3.
Unsatisfiable Core
Identifies a clause in an unsatisfiable core
assertId :: Monad m => SMTExpr Bool -> SMT' m ClauseId Source #
Assert a boolean expression and track it for an unsat core call later
getUnsatCore :: Monad m => SMT' m [ClauseId] Source #
After an unsuccessful checkSat
, return a list of clauses which make the
instance unsatisfiable.
Interpolation
data InterpolationGroup Source #
interpolationGroup :: Monad m => SMT' m InterpolationGroup Source #
Create a new interpolation group
assertInterp :: Monad m => SMTExpr Bool -> InterpolationGroup -> SMT' m () Source #
Assert a boolean expression to be true and assign it to an interpolation group
getInterpolant :: Monad m => [InterpolationGroup] -> SMT' m (SMTExpr Bool) Source #
Expressions
var :: (SMTType t, Typeable t, Unit (SMTAnnotation t), Monad m) => SMT' m (SMTExpr t) Source #
Create a fresh new variable
varNamed :: (SMTType t, Typeable t, Unit (SMTAnnotation t), Monad m) => String -> SMT' m (SMTExpr t) Source #
Create a new named variable
varNamedAnn :: (SMTType t, Typeable t, Monad m) => String -> SMTAnnotation t -> SMT' m (SMTExpr t) Source #
Create a named and annotated variable.
varAnn :: (SMTType t, Typeable t, Monad m) => SMTAnnotation t -> SMT' m (SMTExpr t) Source #
Create a annotated variable
argVars :: (Args a, Unit (ArgAnnotation a), Monad m) => SMT' m a Source #
Like argVarsAnn
, but can only be used for unit type annotations.
argVarsAnn :: (Args a, Monad m) => ArgAnnotation a -> SMT' m a Source #
Like argVarsAnnNamed
, but defaults the name to "var"
argVarsAnnNamed :: (Args a, Monad m) => String -> ArgAnnotation a -> SMT' m a Source #
Create annotated named SMT variables of the Args
class.
If more than one variable is needed, they get a numerical suffix.
untypedNamedVar :: Monad m => String -> Sort -> SMT' m (SMTExpr Untyped) Source #
Create a fresh untyped variable with a name
constantAnn :: SMTValue t => t -> SMTAnnotation t -> SMTExpr t Source #
An annotated constant expression.
extractAnnotation :: SMTExpr a -> SMTAnnotation a Source #
Reconstruct the type annotation for a given SMT expression.
let' :: (Args a, Unit (ArgAnnotation a), SMTType b) => a -> (a -> SMTExpr b) -> SMTExpr b Source #
Binds an expression to a variable.
Can be used to prevent blowups in the command stream if expressions are used multiple times.
let' x f
is functionally equivalent to f x
.
lets :: (Args a, Unit (ArgAnnotation a), SMTType b) => [a] -> ([a] -> SMTExpr b) -> SMTExpr b Source #
Like let'
, but can define multiple variables of the same type.
letAnn :: (Args a, SMTType b) => ArgAnnotation a -> a -> (a -> SMTExpr b) -> SMTExpr b Source #
Like let'
, but can be given an additional type annotation for the argument of the function.
named :: (SMTType a, SMTAnnotation a ~ (), Monad m) => String -> SMTExpr a -> SMT' m (SMTExpr a, SMTExpr a) Source #
Given an arbitrary expression, this creates a named version of it and a name to reference it later on.
named' :: (SMTType a, SMTAnnotation a ~ (), Monad m) => SMTExpr a -> SMT' m (SMTExpr a, SMTExpr a) Source #
Like named
, but defaults the name to "named".
optimizeExpr' :: SMTExpr a -> SMTExpr a Source #
foldExpr :: SMTType a => (forall t. SMTType t => s -> SMTExpr t -> (s, SMTExpr t)) -> s -> SMTExpr a -> (s, SMTExpr a) Source #
Recursively fold a function over all sub-expressions of this expression.
It is implemented as a special case of foldExprM
.
foldExprM :: (SMTType a, Monad m) => (forall t. SMTType t => s -> SMTExpr t -> m (s, [SMTExpr t])) -> s -> SMTExpr a -> m (s, [SMTExpr a]) Source #
Recursively fold a monadic function over all sub-expressions of this expression
foldArgs :: Args a => (forall t. SMTType t => s -> SMTExpr t -> (s, SMTExpr t)) -> s -> a -> (s, a) Source #
Recursively fold a function over all sub-expressions of the argument.
It is implemented as a special case of foldArgsM
.
foldArgsM :: (Args a, Monad m) => (forall t. SMTType t => s -> SMTExpr t -> m (s, [SMTExpr t])) -> s -> a -> m (s, [a]) Source #
Recursively fold a monadic function over all sub-expressions of the argument
Basic logic
(.==.) :: SMTType a => SMTExpr a -> SMTExpr a -> SMTExpr Bool infix 4 Source #
Two expressions shall be equal
:: SMTType a | |
=> SMTExpr Bool | If this expression is true |
-> SMTExpr a | Then return this expression |
-> SMTExpr a | Else this one |
-> SMTExpr a |
If-then-else construct
xor :: SMTFunction [SMTExpr Bool] Bool Source #
Exclusive or: Return true if exactly one argument is true.
Implication
forAll :: (Args a, Unit (ArgAnnotation a)) => (a -> SMTExpr Bool) -> SMTExpr Bool Source #
If the supplied function returns true for all possible values, the forall quantification returns true.
exists :: (Args a, Unit (ArgAnnotation a)) => (a -> SMTExpr Bool) -> SMTExpr Bool Source #
If the supplied function returns true for at least one possible value, the exists quantification returns true.
forAllAnn :: Args a => ArgAnnotation a -> (a -> SMTExpr Bool) -> SMTExpr Bool Source #
An annotated version of forAll
.
existsAnn :: Args a => ArgAnnotation a -> (a -> SMTExpr Bool) -> SMTExpr Bool Source #
An annotated version of exists
.
:: (Args a, Unit (ArgAnnotation a)) | |
=> Integer | Number of variables to quantify |
-> ([a] -> SMTExpr Bool) | Function which takes a list of the quantified variables |
-> SMTExpr Bool |
Like forAll
, but can quantify over more than one variable (of the same type).
:: (Args a, Unit (ArgAnnotation a)) | |
=> Integer | Number of variables to quantify |
-> ([a] -> SMTExpr Bool) | Function which takes a list of the quantified variables |
-> SMTExpr Bool |
Like exists
, but can quantify over more than one variable (of the same type).
Arithmetic
mult :: SMTArith a => SMTFunction [SMTExpr a] a Source #
Calculate the product of arithmetic expressions
div' :: SMTExpr Integer -> SMTExpr Integer -> SMTExpr Integer Source #
Divide an arithmetic expression by another
mod' :: SMTExpr Integer -> SMTExpr Integer -> SMTExpr Integer Source #
Perform a modulo operation on an arithmetic expression
rem' :: SMTExpr Integer -> SMTExpr Integer -> SMTExpr Integer Source #
Calculate the remainder of the division of two integer expressions
neg :: SMTArith a => SMTFunction (SMTExpr a) a Source #
For an expression x
, this returns the expression -x
.
divide :: SMTExpr Rational -> SMTExpr Rational -> SMTExpr Rational Source #
Divide a rational expression by another one
toReal :: SMTExpr Integer -> SMTExpr Rational Source #
Convert an integer expression to a real expression
toInt :: SMTExpr Rational -> SMTExpr Integer Source #
Convert a real expression into an integer expression
Arrays
select :: (Liftable i, SMTType v) => SMTExpr (SMTArray i v) -> i -> SMTExpr v Source #
Extracts an element of an array by its index
store :: (Liftable i, SMTType v) => SMTExpr (SMTArray i v) -> i -> SMTExpr v -> SMTExpr (SMTArray i v) Source #
The expression store arr i v
stores the value v in the array arr at position i and returns the resulting new array.
arrayEquals :: (LiftArgs i, Liftable i, SMTValue v, Ix (Unpacked i), Unit (ArgAnnotation i), Unit (SMTAnnotation v)) => SMTExpr (SMTArray i v) -> Array (Unpacked i) v -> SMTExpr Bool Source #
Create a boolean expression that encodes that the array is equal to the supplied constant array.
unmangleArray :: (Liftable i, LiftArgs i, Ix (Unpacked i), SMTValue v, Unit (ArgAnnotation i), Monad m) => (Unpacked i, Unpacked i) -> SMTExpr (SMTArray i v) -> SMT' m (Array (Unpacked i) v) Source #
Extract all values of an array by giving the range of indices.
asArray :: (Args arg, Unit (ArgAnnotation arg), SMTType res) => SMTFunction arg res -> SMTExpr (SMTArray arg res) Source #
Interpret a function f from i to v as an array with indices i and elements v.
Such that: f `app` j .==. select (asArray f) j
for all indices j.
:: (Args i, SMTType v) | |
=> SMTExpr v | This element will be at every index of the array |
-> ArgAnnotation i | Annotations of the index type |
-> SMTExpr (SMTArray i v) |
Create an array where each element is the same.
Bitvectors
bvand :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) -> SMTExpr (BitVector t) Source #
Bitvector and
bvor :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) -> SMTExpr (BitVector t) Source #
Bitvector or
bvxor :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) -> SMTExpr (BitVector t) Source #
Bitvector or
bvneg :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) Source #
Bitvector signed negation
bvadd :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) -> SMTExpr (BitVector t) Source #
Bitvector addition
bvsub :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) -> SMTExpr (BitVector t) Source #
Bitvector subtraction
bvmul :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) -> SMTExpr (BitVector t) Source #
Bitvector multiplication
bvurem :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) -> SMTExpr (BitVector t) Source #
Bitvector unsigned remainder
bvsrem :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) -> SMTExpr (BitVector t) Source #
Bitvector signed remainder
bvudiv :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) -> SMTExpr (BitVector t) Source #
Bitvector unsigned division
bvsdiv :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) -> SMTExpr (BitVector t) Source #
Bitvector signed division
bvule :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) -> SMTExpr Bool Source #
Bitvector unsigned less-or-equal
bvult :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) -> SMTExpr Bool Source #
Bitvector unsigned less-than
bvuge :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) -> SMTExpr Bool Source #
Bitvector unsigned greater-or-equal
bvugt :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) -> SMTExpr Bool Source #
Bitvector unsigned greater-than
bvsle :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) -> SMTExpr Bool Source #
Bitvector signed less-or-equal
bvslt :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) -> SMTExpr Bool Source #
Bitvector signed less-than
bvsge :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) -> SMTExpr Bool Source #
Bitvector signed greater-or-equal
bvsgt :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) -> SMTExpr Bool Source #
Bitvector signed greater-than
bvshl :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) -> SMTExpr (BitVector t) Source #
Bitvector shift left
bvlshr :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) -> SMTExpr (BitVector t) Source #
Bitvector logical right shift
bvashr :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) -> SMTExpr (BitVector t) Source #
Bitvector arithmetical right shift
bvconcat :: Concatable t1 t2 => SMTExpr (BitVector t1) -> SMTExpr (BitVector t2) -> SMTExpr (BitVector (ConcatResult t1 t2)) Source #
Concats two bitvectors into one.
bvsplitu16to8 :: SMTExpr BV16 -> (SMTExpr BV8, SMTExpr BV8) Source #
Safely split a 16-bit bitvector into two 8-bit bitvectors.
bvsplitu32to16 :: SMTExpr BV32 -> (SMTExpr BV16, SMTExpr BV16) Source #
Safely split a 32-bit bitvector into two 16-bit bitvectors.
bvsplitu32to8 :: SMTExpr BV32 -> (SMTExpr BV8, SMTExpr BV8, SMTExpr BV8, SMTExpr BV8) Source #
Safely split a 32-bit bitvector into four 8-bit bitvectors.
bvsplitu64to32 :: SMTExpr BV64 -> (SMTExpr BV32, SMTExpr BV32) Source #
Safely split a 64-bit bitvector into two 32-bit bitvectors.
bvsplitu64to16 :: SMTExpr BV64 -> (SMTExpr BV16, SMTExpr BV16, SMTExpr BV16, SMTExpr BV16) Source #
Safely split a 64-bit bitvector into four 16-bit bitvectors.
bvsplitu64to8 :: SMTExpr BV64 -> (SMTExpr BV8, SMTExpr BV8, SMTExpr BV8, SMTExpr BV8, SMTExpr BV8, SMTExpr BV8, SMTExpr BV8, SMTExpr BV8) Source #
Safely split a 64-bit bitvector into eight 8-bit bitvectors.
:: (TypeableNat start, TypeableNat len, Extractable tp len') | |
=> Proxy start | The start of the extracted region |
-> Proxy len | |
-> SMTExpr (BitVector tp) | The bitvector to extract from |
-> SMTExpr (BitVector len') |
Extract a sub-vector out of a given bitvector.
bvextract' :: Integer -> Integer -> SMTExpr (BitVector BVUntyped) -> SMTExpr (BitVector BVUntyped) Source #
Functions
funAnn :: (Liftable a, SMTType r, Monad m) => ArgAnnotation a -> SMTAnnotation r -> SMT' m (SMTFunction a r) Source #
Create a new uniterpreted function with annotations for the argument and the return type.
funAnnNamed :: (Liftable a, SMTType r, Monad m) => String -> ArgAnnotation a -> SMTAnnotation r -> SMT' m (SMTFunction a r) Source #
Create a new uninterpreted named function with annotation for the argument and the return type.
funAnnRet :: (Liftable a, SMTType r, Unit (ArgAnnotation a), Monad m) => SMTAnnotation r -> SMT' m (SMTFunction a r) Source #
funAnn with an annotation only for the return type.
fun :: (Liftable a, SMTType r, SMTAnnotation r ~ (), Unit (ArgAnnotation a), Monad m) => SMT' m (SMTFunction a r) Source #
Create a new uninterpreted function.
app :: (Args arg, SMTType res) => SMTFunction arg res -> arg -> SMTExpr res Source #
Apply a function to an argument
defFun :: (Args a, SMTType r, Unit (ArgAnnotation a), Monad m) => (a -> SMTExpr r) -> SMT' m (SMTFunction a r) Source #
Define a new function with a body
defConstNamed :: (SMTType r, Monad m) => String -> SMTExpr r -> SMT' m (SMTExpr r) Source #
Define a new constant with a name
defFunAnn :: (Args a, SMTType r, Monad m) => ArgAnnotation a -> (a -> SMTExpr r) -> SMT' m (SMTFunction a r) Source #
Like defFunAnnNamed
, but defaults the function name to "fun".
defFunAnnNamed :: (Args a, SMTType r, Monad m) => String -> ArgAnnotation a -> (a -> SMTExpr r) -> SMT' m (SMTFunction a r) Source #
Define a new function with a body and custom type annotations for arguments and result.
map' :: (Liftable arg, Args i, SMTType res) => SMTFunction arg res -> SMTFunction (Lifted arg i) (SMTArray i res) Source #
Lift a function to arrays
Data types
is :: (Args arg, SMTType dt) => SMTExpr dt -> Constructor arg dt -> SMTExpr Bool Source #
Checks if the expression is formed a specific constructor.
(.#) :: (SMTType a, SMTType f) => SMTExpr a -> Field a f -> SMTExpr f Source #
Access a field of an expression
Lists
head' :: (SMTType a, Unit (SMTAnnotation a)) => SMTExpr [a] -> SMTExpr a Source #
Takes the first element of a list
tail' :: (SMTType a, Unit (SMTAnnotation a)) => SMTExpr [a] -> SMTExpr [a] Source #
Drops the first element from a list
insert' :: SMTType a => SMTAnnotation a -> Constructor (SMTExpr a, SMTExpr [a]) [a] Source #
isInsert :: (SMTType a, Unit (SMTAnnotation a)) => SMTExpr [a] -> SMTExpr Bool Source #
Checks if a list is non-empty.
Untyped expressions
data UntypedValue Source #
entypeValue :: (forall a. SMTValue a => SMTExpr a -> b) -> SMTExpr UntypedValue -> b Source #
castUntypedExprValue :: SMTType t => SMTExpr UntypedValue -> SMTExpr t Source #