smtlib2-0.3.1: A type-safe interface to communicate with an SMT solver.

Safe HaskellNone
LanguageHaskell98

Language.SMTLib2.Internals.Interface

Description

Defines the user-accessible interface of the smtlib2 library

Synopsis

Documentation

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)

checkSatUsing :: Monad m => Tactic -> SMT' m Bool Source #

Check if the model is satisfiable using a given tactic. (Works only with Z3)

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

apply :: Monad m => Tactic -> SMT' m [SMTExpr Bool] Source #

Apply the given tactic to the current assertions. (Works only with Z3)

push :: Monad m => SMT' m () Source #

Push a new context on the stack

pop :: Monad m => SMT' m () Source #

Pop a new context from the stack

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.

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.

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

var :: (SMTType t, Typeable t, Unit (SMTAnnotation t), Monad m) => SMT' m (SMTExpr t) Source #

Create a fresh new variable

untypedNamedVar :: Monad m => String -> Sort -> SMT' m (SMTExpr Untyped) Source #

Create a fresh untyped variable with a name

untypedVar :: Monad m => Sort -> SMT' m (SMTExpr Untyped) Source #

Create a fresh untyped variable

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.

argVars :: (Args a, Unit (ArgAnnotation a), Monad m) => SMT' m a Source #

Like argVarsAnn, but can only be used for unit type annotations.

constant :: (SMTValue t, Unit (SMTAnnotation t)) => t -> SMTExpr t Source #

A constant expression.

constantAnn :: SMTValue t => t -> SMTAnnotation t -> SMTExpr t Source #

An annotated constant expression.

getValue :: (SMTValue t, Monad m) => SMTExpr t -> SMT' m t Source #

getValues :: (LiftArgs arg, Monad m) => arg -> SMT' m (Unpacked arg) Source #

getModel :: Monad m => SMT' m SMTModel Source #

Extract all assigned values of the model

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.

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

defConst :: (SMTType r, Monad m) => SMTExpr r -> SMT' m (SMTExpr r) Source #

Define a new constant.

defConstNamed :: (SMTType r, Monad m) => String -> SMTExpr r -> SMT' m (SMTExpr r) Source #

Define a new constant with a name

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.

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".

and' :: SMTFunction [SMTExpr Bool] Bool Source #

Boolean conjunction

or' :: SMTFunction [SMTExpr Bool] Bool Source #

Boolean disjunction

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.

assert :: Monad m => SMTExpr Bool -> SMT' m () Source #

Asserts that a boolean expression is true

interpolationGroup :: Monad m => SMT' m InterpolationGroup Source #

Create a new interpolation group

assertId :: Monad m => SMTExpr Bool -> SMT' m ClauseId Source #

Assert a boolean expression and track it for an unsat core call later

assertInterp :: Monad m => SMTExpr Bool -> InterpolationGroup -> SMT' m () Source #

Assert a boolean expression to be true and assign it to an interpolation group

setOption :: Monad m => SMTOption -> SMT' m () Source #

Set an option for the underlying SMT solver

getInfo :: (Monad m, Typeable i) => SMTInfo i -> SMT' m i Source #

Get information about the underlying SMT solver

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

map' :: (Liftable arg, Args i, SMTType res) => SMTFunction arg res -> SMTFunction (Lifted arg i) (SMTArray i res) Source #

Lift a function to arrays

(.==.) :: SMTType a => SMTExpr a -> SMTExpr a -> SMTExpr Bool infix 4 Source #

Two expressions shall be equal

argEq :: Args a => a -> a -> SMTExpr Bool Source #

A generalized version of .==.

distinct :: SMTType a => [SMTExpr a] -> SMTExpr Bool Source #

Declares all arguments to be distinct

plus :: SMTArith a => SMTFunction [SMTExpr a] a Source #

Calculate the sum of arithmetic expressions

mult :: SMTArith a => SMTFunction [SMTExpr a] a Source #

Calculate the product of arithmetic expressions

minus :: SMTArith a => SMTFunction (SMTExpr a, SMTExpr a) a Source #

Subtracts two 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

divide :: SMTExpr Rational -> SMTExpr Rational -> SMTExpr Rational Source #

Divide a rational expression by another one

neg :: SMTArith a => SMTFunction (SMTExpr a) a Source #

For an expression x, this returns the expression -x.

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

ite Source #

Arguments

:: 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.

(.=>.) Source #

Arguments

:: SMTExpr Bool

If this expression is true

-> SMTExpr Bool

This one must be as well

-> SMTExpr Bool 

Implication

not' :: SMTExpr Bool -> SMTExpr Bool Source #

Negates a boolean expression

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.

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.

constArray Source #

Arguments

:: (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.

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

bvnot :: IsBitVector t => SMTExpr (BitVector t) -> SMTExpr (BitVector t) Source #

Bitvector not

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.

bvextract Source #

Arguments

:: (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.

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.

mkQuantified :: (Args a, SMTType b) => (Integer -> [ProxyArg] -> SMTExpr b -> SMTExpr b) -> ArgAnnotation a -> (a -> SMTExpr b) -> SMTExpr b Source #

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.

forAllAnn :: Args a => ArgAnnotation a -> (a -> SMTExpr Bool) -> SMTExpr Bool Source #

An annotated version of forAll.

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.

existsAnn :: Args a => ArgAnnotation a -> (a -> SMTExpr Bool) -> SMTExpr Bool Source #

An annotated version of exists.

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.

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.

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.

forAllList Source #

Arguments

:: (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).

existsList Source #

Arguments

:: (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).

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

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

isNil :: SMTType a => SMTExpr [a] -> SMTExpr Bool Source #

Checks if a list is empty.

isInsert :: (SMTType a, Unit (SMTAnnotation a)) => SMTExpr [a] -> SMTExpr Bool Source #

Checks if a list is non-empty.

setLogic :: Monad m => String -> SMT' m () Source #

Sets the logic used for the following program (Not needed for many solvers).

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".

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.

getUnsatCore :: Monad m => SMT' m [ClauseId] Source #

After an unsuccessful checkSat, return a list of clauses which make the instance unsatisfiable.