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

Safe HaskellNone
LanguageHaskell98

Language.SMTLib2

Contents

Description

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
     

Synopsis

Data types

data SMT' m a Source

The SMT monad used for communating with the SMT solver

type SMT = SMT' IO Source

class Monad m => SMTBackend a m Source

Minimal complete definition

smtHandle, smtGetNames, smtNextName

data AnyBackend m Source

Constructors

forall b . SMTBackend b m => AnyBackend b 

Instances

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

Minimal complete definition

getSort, asValueType, annotationFromSort, defaultExpr

Associated Types

type SMTAnnotation t Source

class (SMTType t, Show t) => SMTValue t Source

Haskell values which can be represented as SMT constants

Minimal complete definition

unmangle, mangle

class (SMTValue t, Num t, SMTAnnotation t ~ ()) => SMTArith t Source

A type class for all types which support arithmetic operations in SMT

class SMTType t => SMTOrd t where Source

Lifts the Ord class into SMT

Methods

(.<.) :: SMTExpr t -> SMTExpr t -> SMTExpr Bool infix 4 Source

(.>=.) :: SMTExpr t -> SMTExpr t -> SMTExpr Bool infix 4 Source

(.>.) :: SMTExpr t -> SMTExpr t -> SMTExpr Bool infix 4 Source

(.<=.) :: SMTExpr t -> SMTExpr t -> SMTExpr Bool infix 4 Source

data SMTExpr t Source

An abstract SMT expression

Instances

data SMTFunction arg res Source

Instances

Show (SMTFunction arg res) Source 

data SMTOption Source

Options controling the behaviour of the SMT solver

Constructors

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

data SMTArray i v Source

An array which maps indices of type i to elements of type v.

Instances

data Constructor arg res Source

Represents a constructor of a datatype a Can be obtained by using the template haskell extension module

Instances

Show (Constructor arg res) Source 

data Field a f Source

Represents a field of the datatype a of the type f

Instances

Show (Field a f) 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.

Associated Types

type ArgAnnotation a Source

Methods

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

Instances

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.

Associated Types

type Unpacked a Source

Methods

liftArgs :: Unpacked a -> ArgAnnotation a -> a Source

Converts a haskell value into its SMT representation.

unliftArgs :: Monad m => a -> (forall t. SMTValue t => SMTExpr t -> m t) -> m (Unpacked a) Source

Converts a SMT representation back into a haskell value.

Environment

withSMTBackend :: SMTBackend a m => a -> SMT' m b -> m b Source

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

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

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

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

Asserts that a boolean expression is true

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.

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

Constructors

Sat

The formula is satisfiable

Unsat

The formula is unsatisfiable

Unknown

The solver cannot determine the satisfiability of a formula

data CheckSatLimits Source

Describe limits on the ressources that an SMT-solver can use

Constructors

CheckSatLimits 

Fields

limitTime :: Maybe Integer

A limit on the amount of time the solver can spend on the problem (in milliseconds)

limitMemory :: Maybe Integer

A limit on the amount of memory the solver can use (in megabytes)

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

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

data ClauseId Source

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

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

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.

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

Create a fresh untyped variable

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

Create a fresh untyped variable with a name

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.

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

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

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

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

and' :: SMTFunction [SMTExpr Bool] Bool Source

Boolean conjunction

or' :: SMTFunction [SMTExpr Bool] Bool Source

Boolean disjunction

xor :: SMTFunction [SMTExpr Bool] Bool Source

Exclusive or: Return true if exactly one argument is true.

not' :: SMTExpr Bool -> SMTExpr Bool Source

Negates a boolean expression

(.=>.) Source

Arguments

:: SMTExpr Bool

If this expression is true

-> SMTExpr Bool

This one must be as well

-> SMTExpr Bool 

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.

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

Arithmetic

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

Calculate the sum of arithmetic expressions

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

Subtracts two expressions

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.

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.

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

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

type N0 = Z Source

type N1 = S N0 Source

type N2 = S N1 Source

type N3 = S N2 Source

type N4 = S N3 Source

type N5 = S N4 Source

type N6 = S N5 Source

type N7 = S N6 Source

type N8 = S N7 Source

type N9 = S N8 Source

type N10 = S N9 Source

type N11 = S N10 Source

type N12 = S N11 Source

type N13 = S N12 Source

type N14 = S N13 Source

type N15 = S N14 Source

type N16 = S N15 Source

type N17 = S N16 Source

type N18 = S N17 Source

type N19 = S N18 Source

type N20 = S N19 Source

type N21 = S N20 Source

type N22 = S N21 Source

type N23 = S N22 Source

type N24 = S N23 Source

type N25 = S N24 Source

type N26 = S N25 Source

type N27 = S N26 Source

type N28 = S N27 Source

type N29 = S N28 Source

type N30 = S N29 Source

type N31 = S N30 Source

type N32 = S N31 Source

type N33 = S N32 Source

type N34 = S N33 Source

type N35 = S N34 Source

type N36 = S N35 Source

type N37 = S N36 Source

type N38 = S N37 Source

type N39 = S N38 Source

type N40 = S N39 Source

type N41 = S N40 Source

type N42 = S N41 Source

type N43 = S N42 Source

type N44 = S N43 Source

type N45 = S N44 Source

type N46 = S N45 Source

type N47 = S N46 Source

type N48 = S N47 Source

type N49 = S N48 Source

type N50 = S N49 Source

type N51 = S N50 Source

type N52 = S N51 Source

type N53 = S N52 Source

type N54 = S N53 Source

type N55 = S N54 Source

type N56 = S N55 Source

type N57 = S N56 Source

type N58 = S N57 Source

type N59 = S N58 Source

type N60 = S N59 Source

type N61 = S N60 Source

type N62 = S N61 Source

type N63 = S N62 Source

type N64 = S N63 Source

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.

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.

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

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

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

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.

Untyped expressions

entype :: (forall a. SMTType a => SMTExpr a -> b) -> SMTExpr Untyped -> b Source

entypeValue :: (forall a. SMTValue a => SMTExpr a -> b) -> SMTExpr UntypedValue -> b Source