Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
A module for interacting with an SMT solver, using SmtLib-2 format.
- data Solver
- newSolver :: String -> [String] -> Maybe Logger -> IO Solver
- command :: Solver -> SExpr -> IO SExpr
- stop :: Solver -> IO ExitCode
- ackCommand :: Solver -> SExpr -> IO ()
- simpleCommand :: Solver -> [String] -> IO ()
- data SExpr
- showsSExpr :: SExpr -> ShowS
- readSExpr :: String -> Maybe (SExpr, String)
- data Logger = Logger {}
- newLogger :: IO Logger
- setLogic :: Solver -> String -> IO ()
- setOption :: Solver -> String -> String -> IO ()
- push :: Solver -> IO ()
- pushMany :: Solver -> Integer -> IO ()
- pop :: Solver -> IO ()
- popMany :: Solver -> Integer -> IO ()
- declare :: Solver -> String -> SExpr -> IO SExpr
- declareFun :: Solver -> String -> [SExpr] -> SExpr -> IO SExpr
- assert :: Solver -> SExpr -> IO ()
- check :: Solver -> IO Result
- data Result
- getExprs :: Solver -> [SExpr] -> IO [(SExpr, Value)]
- getExpr :: Solver -> SExpr -> IO Value
- getConsts :: Solver -> [String] -> IO [(String, Value)]
- getConst :: Solver -> String -> IO Value
- data Value
- fam :: String -> [Integer] -> SExpr
- fun :: String -> [SExpr] -> SExpr
- const :: String -> SExpr
- tInt :: SExpr
- tBool :: SExpr
- tReal :: SExpr
- tArray :: SExpr -> SExpr -> SExpr
- tBits :: Integer -> SExpr
- int :: Integer -> SExpr
- real :: Rational -> SExpr
- bool :: Bool -> SExpr
- bvBin :: Int -> Integer -> SExpr
- bvHex :: Int -> Integer -> SExpr
- value :: Value -> SExpr
- not :: SExpr -> SExpr
- and :: SExpr -> SExpr -> SExpr
- or :: SExpr -> SExpr -> SExpr
- xor :: SExpr -> SExpr -> SExpr
- implies :: SExpr -> SExpr -> SExpr
- ite :: SExpr -> SExpr -> SExpr -> SExpr
- eq :: SExpr -> SExpr -> SExpr
- gt :: SExpr -> SExpr -> SExpr
- lt :: SExpr -> SExpr -> SExpr
- geq :: SExpr -> SExpr -> SExpr
- leq :: SExpr -> SExpr -> SExpr
- bvULt :: SExpr -> SExpr -> SExpr
- bvULeq :: SExpr -> SExpr -> SExpr
- bvSLt :: SExpr -> SExpr -> SExpr
- bvSLeq :: SExpr -> SExpr -> SExpr
- add :: SExpr -> SExpr -> SExpr
- sub :: SExpr -> SExpr -> SExpr
- neg :: SExpr -> SExpr
- mul :: SExpr -> SExpr -> SExpr
- abs :: SExpr -> SExpr
- div :: SExpr -> SExpr -> SExpr
- mod :: SExpr -> SExpr -> SExpr
- divisible :: SExpr -> Integer -> SExpr
- realDiv :: SExpr -> SExpr -> SExpr
- concat :: SExpr -> SExpr -> SExpr
- extract :: SExpr -> Integer -> Integer -> SExpr
- bvNot :: SExpr -> SExpr
- bvNeg :: SExpr -> SExpr
- bvAnd :: SExpr -> SExpr -> SExpr
- bvXOr :: SExpr -> SExpr -> SExpr
- bvOr :: SExpr -> SExpr -> SExpr
- bvAdd :: SExpr -> SExpr -> SExpr
- bvSub :: SExpr -> SExpr -> SExpr
- bvMul :: SExpr -> SExpr -> SExpr
- bvUDiv :: SExpr -> SExpr -> SExpr
- bvURem :: SExpr -> SExpr -> SExpr
- bvSDiv :: SExpr -> SExpr -> SExpr
- bvSRem :: SExpr -> SExpr -> SExpr
- bvShl :: SExpr -> SExpr -> SExpr
- bvLShr :: SExpr -> SExpr -> SExpr
- bvAShr :: SExpr -> SExpr -> SExpr
- select :: SExpr -> SExpr -> SExpr
- store :: SExpr -> SExpr -> SExpr -> SExpr
Basic Solver Interface
Start a new solver process.
ackCommand :: Solver -> SExpr -> IO () Source
A command with no interesting result.
simpleCommand :: Solver -> [String] -> IO () Source
A command entirely made out of atoms, with no interesting result.
S-Expressions
S-expressions. These are the basic format for SmtLib-2.
showsSExpr :: SExpr -> ShowS Source
Show an s-expression.
Logging and Debugging
Log messages with minimal formatting. Mostly for debugging.
Common SmtLib-2 Commands
setLogic :: Solver -> String -> IO () Source
Set the solver's logic. Usually, this should be done first.
declare :: Solver -> String -> SExpr -> IO SExpr Source
Declare a constant. A common abbreviation for declareFun
.
For convenience, returns an the declared name as a constant expression.
declareFun :: Solver -> String -> [SExpr] -> SExpr -> IO SExpr Source
Declare a function or a constant. For convenience, returns an the declared name as a constant expression.
Results of checking for satisfiability.
getExprs :: Solver -> [SExpr] -> IO [(SExpr, Value)] Source
Get the values of some s-expressions.
Only valid after a Sat
result.
Common values returned by SMT solvers.
Convenienct Functoins for SmtLib-2 Epxressions
fam :: String -> [Integer] -> SExpr Source
A constant, corresponding to a family indexed by some integers.
Types
Literals
A bit vector represented in binary.
- If the value does not fit in the bits, then the bits will be increased.
- The width should be strictly positive.
A bit vector represented in hex.
- If the value does not fit in the bits, the bits will be increased to the next multiple of 4 that will fit the value.
- If the width is not a multiple of 4, it will be rounded up so that it is.
- The width should be strictly positive.
value :: Value -> SExpr Source
Render a value as an expression. Bit-vectors are rendered in hex, if their width is a multiple of 4, and in binary otherwise.
Connectives
If-then-else
ite :: SExpr -> SExpr -> SExpr -> SExpr Source
If-then-else. This is polymorphic and can be used to construct any term.
Relational Predicates
Arithmetic
Bit Vectors
Arithemti shift right (copies most significant bit).