z3-408.2: Bindings for the Z3 Theorem Prover
Copyright(c) Iago Abal 2012-2015
(c) David Castro 2012-2015
LicenseBSD3
MaintainerIago Abal <mail@iagoabal.eu>, David Castro <david.castro.dcp@gmail.com>
Safe HaskellSafe-Inferred
LanguageHaskell2010

Z3.Base

Description

Low-level bindings to Z3 API.

There is (mostly) a one-to-one correspondence with Z3 C API, thus see http://z3prover.github.io/api/html/group__capi.html for further details.

Synopsis

Types

data Config Source #

A Z3 configuration object.

Instances

Instances details
Eq Config Source # 
Instance details

Defined in Z3.Base

Methods

(==) :: Config -> Config -> Bool #

(/=) :: Config -> Config -> Bool #

data Context Source #

A Z3 logical context.

Instances

Instances details
Eq Context Source # 
Instance details

Defined in Z3.Base

Methods

(==) :: Context -> Context -> Bool #

(/=) :: Context -> Context -> Bool #

data Symbol Source #

A Z3 symbol.

Used to name types, constants and functions.

Instances

Instances details
Storable Symbol Source # 
Instance details

Defined in Z3.Base

Show Symbol Source # 
Instance details

Defined in Z3.Base

Eq Symbol Source # 
Instance details

Defined in Z3.Base

Methods

(==) :: Symbol -> Symbol -> Bool #

(/=) :: Symbol -> Symbol -> Bool #

Ord Symbol Source # 
Instance details

Defined in Z3.Base

data AST Source #

A Z3 AST node.

This is the data-structure used in Z3 to represent terms, formulas and types.

Instances

Instances details
Show AST Source # 
Instance details

Defined in Z3.Base

Methods

showsPrec :: Int -> AST -> ShowS #

show :: AST -> String #

showList :: [AST] -> ShowS #

Eq AST Source # 
Instance details

Defined in Z3.Base

Methods

(==) :: AST -> AST -> Bool #

(/=) :: AST -> AST -> Bool #

Ord AST Source # 
Instance details

Defined in Z3.Base

Methods

compare :: AST -> AST -> Ordering #

(<) :: AST -> AST -> Bool #

(<=) :: AST -> AST -> Bool #

(>) :: AST -> AST -> Bool #

(>=) :: AST -> AST -> Bool #

max :: AST -> AST -> AST #

min :: AST -> AST -> AST #

data Sort Source #

A kind of AST representing types.

Instances

Instances details
Show Sort Source # 
Instance details

Defined in Z3.Base

Methods

showsPrec :: Int -> Sort -> ShowS #

show :: Sort -> String #

showList :: [Sort] -> ShowS #

Eq Sort Source # 
Instance details

Defined in Z3.Base

Methods

(==) :: Sort -> Sort -> Bool #

(/=) :: Sort -> Sort -> Bool #

Ord Sort Source # 
Instance details

Defined in Z3.Base

Methods

compare :: Sort -> Sort -> Ordering #

(<) :: Sort -> Sort -> Bool #

(<=) :: Sort -> Sort -> Bool #

(>) :: Sort -> Sort -> Bool #

(>=) :: Sort -> Sort -> Bool #

max :: Sort -> Sort -> Sort #

min :: Sort -> Sort -> Sort #

data TupleType Source #

A sort representing named tuples with associated functions

Constructors

TupleType 

Fields

data FuncDecl Source #

A kind of AST representing function symbols.

Instances

Instances details
Show FuncDecl Source # 
Instance details

Defined in Z3.Base

Eq FuncDecl Source # 
Instance details

Defined in Z3.Base

Ord FuncDecl Source # 
Instance details

Defined in Z3.Base

data App Source #

A kind of AST representing constant and function declarations.

Instances

Instances details
Show App Source # 
Instance details

Defined in Z3.Base

Methods

showsPrec :: Int -> App -> ShowS #

show :: App -> String #

showList :: [App] -> ShowS #

Eq App Source # 
Instance details

Defined in Z3.Base

Methods

(==) :: App -> App -> Bool #

(/=) :: App -> App -> Bool #

Ord App Source # 
Instance details

Defined in Z3.Base

Methods

compare :: App -> App -> Ordering #

(<) :: App -> App -> Bool #

(<=) :: App -> App -> Bool #

(>) :: App -> App -> Bool #

(>=) :: App -> App -> Bool #

max :: App -> App -> App #

min :: App -> App -> App #

data Pattern Source #

A kind of AST representing pattern and multi-patterns to guide quantifier instantiation.

Instances

Instances details
Show Pattern Source # 
Instance details

Defined in Z3.Base

Eq Pattern Source # 
Instance details

Defined in Z3.Base

Methods

(==) :: Pattern -> Pattern -> Bool #

(/=) :: Pattern -> Pattern -> Bool #

Ord Pattern Source # 
Instance details

Defined in Z3.Base

data Constructor Source #

A type contructor for a (recursive) datatype.

data Model Source #

A model for the constraints asserted into the logical context.

Instances

Instances details
Eq Model Source # 
Instance details

Defined in Z3.Base

Methods

(==) :: Model -> Model -> Bool #

(/=) :: Model -> Model -> Bool #

data FuncInterp Source #

An interpretation of a function in a model.

Instances

Instances details
Eq FuncInterp Source # 
Instance details

Defined in Z3.Base

data FuncEntry Source #

Representation of the value of a Z3_func_interp at a particular point.

Instances

Instances details
Eq FuncEntry Source # 
Instance details

Defined in Z3.Base

data Params Source #

A Z3 parameter set.

Starting at Z3 4.0, parameter sets are used to configure many components such as: simplifiers, tactics, solvers, etc.

Instances

Instances details
Eq Params Source # 
Instance details

Defined in Z3.Base

Methods

(==) :: Params -> Params -> Bool #

(/=) :: Params -> Params -> Bool #

data Solver Source #

A Z3 solver engine.

A(n) (incremental) solver, possibly specialized by a particular tactic or logic.

Instances

Instances details
Eq Solver Source # 
Instance details

Defined in Z3.Base

Methods

(==) :: Solver -> Solver -> Bool #

(/=) :: Solver -> Solver -> Bool #

data ASTKind Source #

Different kinds of Z3 AST nodes.

Instances

Instances details
Show ASTKind Source # 
Instance details

Defined in Z3.Base

Eq ASTKind Source # 
Instance details

Defined in Z3.Base

Methods

(==) :: ASTKind -> ASTKind -> Bool #

(/=) :: ASTKind -> ASTKind -> Bool #

data Tactic Source #

A tactic

Instances

Instances details
Eq Tactic Source # 
Instance details

Defined in Z3.Base

Methods

(==) :: Tactic -> Tactic -> Bool #

(/=) :: Tactic -> Tactic -> Bool #

data ApplyResult Source #

A result of applying a tactic

Instances

Instances details
Eq ApplyResult Source # 
Instance details

Defined in Z3.Base

data Goal Source #

A goal (aka problem)

Instances

Instances details
Eq Goal Source # 
Instance details

Defined in Z3.Base

Methods

(==) :: Goal -> Goal -> Bool #

(/=) :: Goal -> Goal -> Bool #

Satisfiability result

data Result Source #

Result of a satisfiability check.

This corresponds to the z3_lbool type in the C API.

Constructors

Sat 
Unsat 
Undef 

Instances

Instances details
Read Result Source # 
Instance details

Defined in Z3.Base

Show Result Source # 
Instance details

Defined in Z3.Base

Eq Result Source # 
Instance details

Defined in Z3.Base

Methods

(==) :: Result -> Result -> Bool #

(/=) :: Result -> Result -> Bool #

Ord Result Source # 
Instance details

Defined in Z3.Base

Algebraic Numbers

Global Parameters

Create configuration

mkConfig :: IO Config Source #

Create a configuration.

See withConfig.

delConfig :: Config -> IO () Source #

Delete a configuration.

See withConfig.

setParamValue :: Config -> String -> String -> IO () Source #

Set a configuration parameter.

Helpers

withConfig :: (Config -> IO a) -> IO a Source #

Run a computation using a temporally created configuration.

Note that the configuration object can be thrown away once it has been used to create the Z3 Context.

Create context

mkContext :: Config -> IO Context Source #

Create a context using the given configuration.

Z3_del_context is called by Haskell's garbage collector before freeing the Context object.

Parameters

mkParams :: Context -> IO Params Source #

Create a Z3 (empty) parameter set.

Starting at Z3 4.0, parameter sets are used to configure many components such as: simplifiers, tactics, solvers, etc.

paramsSetBool :: Context -> Params -> Symbol -> Bool -> IO () Source #

Add a Boolean parameter k with value v to the parameter set p.

paramsSetUInt :: Context -> Params -> Symbol -> Word -> IO () Source #

Add a unsigned parameter k with value v to the parameter set p.

paramsSetDouble :: Context -> Params -> Symbol -> Double -> IO () Source #

Add a double parameter k with value v to the parameter set p.

paramsSetSymbol :: Context -> Params -> Symbol -> Symbol -> IO () Source #

Add a symbol parameter k with value v to the parameter set p.

paramsToString :: Context -> Params -> IO String Source #

Convert a parameter set into a string.

This function is mainly used for printing the contents of a parameter set.

Symbols

mkIntSymbol :: Integral int => Context -> int -> IO Symbol Source #

Create a Z3 symbol using an integer.

mkIntSymbol c i requires 0 <= i < 2^30

mkStringSymbol :: Context -> String -> IO Symbol Source #

Create a Z3 symbol using a String.

Sorts

mkUninterpretedSort :: Context -> Symbol -> IO Sort Source #

Create a free (uninterpreted) type using the given name (symbol).

Two free types are considered the same iff the have the same name.

mkBoolSort :: Context -> IO Sort Source #

Create the boolean type.

This type is used to create propositional variables and predicates.

mkIntSort :: Context -> IO Sort Source #

Create the integer type.

This is the type of arbitrary precision integers. A machine integer can be represented using bit-vectors, see mkBvSort.

mkRealSort :: Context -> IO Sort Source #

Create the real type.

This type is not a floating point number. Z3 does not have support for floating point numbers yet.

mkBvSort :: Integral int => Context -> int -> IO Sort Source #

Create a bit-vector type of the given size.

This type can also be seen as a machine integer.

mkBvSort c sz requires sz >= 0

mkFiniteDomainSort :: Context -> Symbol -> Word64 -> IO Sort Source #

Create a finite-domain type.

mkArraySort :: Context -> Sort -> Sort -> IO Sort Source #

Create an array type

We usually represent the array type as: [domain -> range]. Arrays are usually used to model the heap/memory in software verification.

mkArraySortN :: Context -> [Sort] -> Sort -> IO Sort Source #

Create an array type with N arguments.

mkTupleSort Source #

Arguments

:: Context

Context

-> Symbol

Name of the sort

-> [(Symbol, Sort)]

Name and sort of each field

-> IO (Sort, FuncDecl, [FuncDecl])

Resulting sort, and function declarations for the constructor and projections.

Create a tuple type

A tuple with n fields has a constructor and n projections. This function will also declare the constructor and projection functions.

mkTupleType :: Context -> Symbol -> [(String, Sort)] -> IO TupleType Source #

Like mkTupleSort but wraps the result in a TupleType record

mkTuple :: Context -> TupleType -> [AST] -> IO AST Source #

Create an instance of the tuple sort wrapped in TupleType

mkIndexTuple :: Context -> TupleType -> Int -> AST -> IO AST Source #

Project the i-th field of the given tuple,

mkProjTuple :: Context -> TupleType -> String -> AST -> IO AST Source #

Project a field of the given tuple by name,

mkEnumerationSort Source #

Arguments

:: Context

logical context

-> Symbol

name of the enumeration sort

-> [Symbol]

names of the enumerated elements

-> IO (Sort, [FuncDecl], [FuncDecl])

the created enumeration sort, enum_consts, enum_testers

Create a enumeration sort.

An enumeration sort with n elements. This function will also declare the functions corresponding to the enumerations:

  • enum_consts: constants corresponding to the enumerated elements.
  • enum_testers: predicates testing if terms of the enumeration sort correspond to an enumeration.

mkListSort Source #

Arguments

:: Context

Context

-> Symbol

name of the list sort

-> Sort

sort of list elements

-> IO (Sort, FuncDecl, FuncDecl, FuncDecl, FuncDecl, FuncDecl, FuncDecl)

the created list sort, nilDecl isnilDecl, consDecl, isconsDecl headDecl, tailDecl

Create a list sort.

A list sort over elem_sort. This function declares the corresponding constructors and testers for lists:

  • nilDecl: declaration for the empty list
  • isnilDecl: test for the empty list
  • consDecl: declaration for a cons cell
  • isconsDecl: cons cell test
  • headDecl: list head
  • tailDecl: list tail

mkConstructor Source #

Arguments

:: Context

Context

-> Symbol

Name of the constructor

-> Symbol

Name of recognizer function

-> [(Symbol, Maybe Sort, Int)]

Name, sort option, and sortRefs

-> IO Constructor 

Create a contructor

mkDatatype :: Context -> Symbol -> [Constructor] -> IO Sort Source #

Create datatype, such as lists, trees, records, enumerations or unions of records.

The datatype may be recursive. Returns the datatype sort.

mkDatatypes :: Context -> [Symbol] -> [[Constructor]] -> IO [Sort] Source #

Create mutually recursive datatypes, such as a tree and forest.

Returns the datatype sorts

mkSetSort :: Context -> Sort -> IO Sort Source #

Create an set type with a given domain type

Constants and Applications

mkFuncDecl Source #

Arguments

:: Context

Logical context.

-> Symbol

Name of the function (or constant).

-> [Sort]

Function domain (empty for constants).

-> Sort

Return sort of the function.

-> IO FuncDecl 

Declare a constant or function.

mkApp :: Context -> FuncDecl -> [AST] -> IO AST Source #

Create a constant or function application.

mkConst :: Context -> Symbol -> Sort -> IO AST Source #

Declare and create a constant.

This is a shorthand for: do xd <- mkFunDecl c x [] s; mkApp c xd []

mkFreshFuncDecl :: Context -> String -> [Sort] -> Sort -> IO FuncDecl Source #

Declare a fresh constant or function.

mkFreshConst Source #

Arguments

:: Context

Logical context.

-> String

Prefix.

-> Sort

Sort of the constant.

-> IO AST 

Declare and create a fresh constant.

mkRecFuncDecl Source #

Arguments

:: Context

Logical context.

-> Symbol

Name of the function (or constant).

-> [Sort]

Function domain (empty for constants).

-> Sort

Return sort of the function.

-> IO FuncDecl 

Declare a recursive function.

addRecDef Source #

Arguments

:: Context

Logical context.

-> FuncDecl

Declaration of the function being defined.

-> [AST]

Constants to use as the function's formal arguments.

-> AST

Body of the function to define

-> IO () 

Define the body of a recursive function. Declare it first with mkRecFuncDecl

Helpers

mkVar :: Context -> Symbol -> Sort -> IO AST Source #

Declare and create a variable (aka constant).

An alias for mkConst.

mkBoolVar :: Context -> Symbol -> IO AST Source #

Declarate and create a variable of sort bool.

See mkVar.

mkRealVar :: Context -> Symbol -> IO AST Source #

Declarate and create a variable of sort real.

See mkVar.

mkIntVar :: Context -> Symbol -> IO AST Source #

Declarate and create a variable of sort int.

See mkVar.

mkBvVar Source #

Arguments

:: Context 
-> Symbol 
-> Int

bit-width

-> IO AST 

Declarate and create a variable of sort bit-vector.

See mkVar.

mkFreshVar :: Context -> String -> Sort -> IO AST Source #

Declare and create a fresh variable (aka constant).

An alias for mkFreshConst.

mkFreshBoolVar :: Context -> String -> IO AST Source #

Declarate and create a fresh variable of sort bool.

See mkFreshVar.

mkFreshRealVar :: Context -> String -> IO AST Source #

Declarate and create a fresh variable of sort real.

See mkFreshVar.

mkFreshIntVar :: Context -> String -> IO AST Source #

Declarate and create a fresh variable of sort int.

See mkFreshVar.

mkFreshBvVar Source #

Arguments

:: Context 
-> String 
-> Int

bit-width

-> IO AST 

Declarate and create a fresh variable of sort bit-vector.

See mkFreshVar.

Propositional Logic and Equality

mkTrue :: Context -> IO AST Source #

Create an AST node representing true.

mkFalse :: Context -> IO AST Source #

Create an AST node representing false.

mkEq :: Context -> AST -> AST -> IO AST Source #

Create an AST node representing l = r.

mkNot :: Context -> AST -> IO AST Source #

Create an AST node representing not(a).

mkIte :: Context -> AST -> AST -> AST -> IO AST Source #

Create an AST node representing an if-then-else: ite(t1, t2, t3).

mkIff :: Context -> AST -> AST -> IO AST Source #

Create an AST node representing t1 iff t2.

mkImplies :: Context -> AST -> AST -> IO AST Source #

Create an AST node representing t1 implies t2.

mkXor :: Context -> AST -> AST -> IO AST Source #

Create an AST node representing t1 xor t2.

mkAnd :: Context -> [AST] -> IO AST Source #

Create an AST node representing args[0] and ... and args[num_args-1].

mkOr :: Context -> [AST] -> IO AST Source #

Create an AST node representing args[0] or ... or args[num_args-1].

mkDistinct :: Context -> [AST] -> IO AST Source #

The distinct construct is used for declaring the arguments pairwise distinct.

That is, and [ args!!i /= args!!j | i <- [0..length(args)-1], j <- [i+1..length(args)-1] ]

Requires a non-empty list.

mkDistinct1 :: Context -> NonEmpty AST -> IO AST Source #

Same as mkDistinct but type-safe.

Helpers

mkBool :: Context -> Bool -> IO AST Source #

Create an AST node representing the given boolean.

Arithmetic: Integers and Reals

mkAdd :: Context -> [AST] -> IO AST Source #

Create an AST node representing args[0] + ... + args[num_args-1].

mkMul :: Context -> [AST] -> IO AST Source #

Create an AST node representing args[0] * ... * args[num_args-1].

mkSub :: Context -> [AST] -> IO AST Source #

Create an AST node representing args[0] - ... - args[num_args - 1].

Requires a non-empty list.

mkSub1 :: Context -> NonEmpty AST -> IO AST Source #

Same as mkSub but type-safe.

mkUnaryMinus :: Context -> AST -> IO AST Source #

Create an AST node representing -arg.

mkDiv :: Context -> AST -> AST -> IO AST Source #

Create an AST node representing arg1 div arg2.

mkMod :: Context -> AST -> AST -> IO AST Source #

Create an AST node representing arg1 mod arg2.

mkRem :: Context -> AST -> AST -> IO AST Source #

Create an AST node representing arg1 rem arg2.

mkPower :: Context -> AST -> AST -> IO AST Source #

Create an AST node representing arg1 ^ arg2.

mkLt :: Context -> AST -> AST -> IO AST Source #

Create less than.

mkLe :: Context -> AST -> AST -> IO AST Source #

Create less than or equal to.

mkGt :: Context -> AST -> AST -> IO AST Source #

Create greater than.

mkGe :: Context -> AST -> AST -> IO AST Source #

Create greater than or equal to.

mkInt2Real :: Context -> AST -> IO AST Source #

Coerce an integer to a real.

mkReal2Int :: Context -> AST -> IO AST Source #

Coerce a real to an integer.

mkIsInt :: Context -> AST -> IO AST Source #

Check if a real number is an integer.

Bit-vectors

mkBvnot :: Context -> AST -> IO AST Source #

Bitwise negation.

mkBvredand :: Context -> AST -> IO AST Source #

Take conjunction of bits in vector, return vector of length 1.

mkBvredor :: Context -> AST -> IO AST Source #

Take disjunction of bits in vector, return vector of length 1.

mkBvand :: Context -> AST -> AST -> IO AST Source #

Bitwise and.

mkBvor :: Context -> AST -> AST -> IO AST Source #

Bitwise or.

mkBvxor :: Context -> AST -> AST -> IO AST Source #

Bitwise exclusive-or.

mkBvnand :: Context -> AST -> AST -> IO AST Source #

Bitwise nand.

mkBvnor :: Context -> AST -> AST -> IO AST Source #

Bitwise nor.

mkBvxnor :: Context -> AST -> AST -> IO AST Source #

Bitwise xnor.

mkBvneg :: Context -> AST -> IO AST Source #

Standard two's complement unary minus.

mkBvadd :: Context -> AST -> AST -> IO AST Source #

Standard two's complement addition.

mkBvsub :: Context -> AST -> AST -> IO AST Source #

Standard two's complement subtraction.

mkBvmul :: Context -> AST -> AST -> IO AST Source #

Standard two's complement multiplication.

mkBvudiv :: Context -> AST -> AST -> IO AST Source #

Unsigned division.

mkBvsdiv :: Context -> AST -> AST -> IO AST Source #

Two's complement signed division.

mkBvurem :: Context -> AST -> AST -> IO AST Source #

Unsigned remainder.

mkBvsrem :: Context -> AST -> AST -> IO AST Source #

Two's complement signed remainder (sign follows dividend).

mkBvsmod :: Context -> AST -> AST -> IO AST Source #

Two's complement signed remainder (sign follows divisor).

mkBvult :: Context -> AST -> AST -> IO AST Source #

Unsigned less than.

mkBvslt :: Context -> AST -> AST -> IO AST Source #

Two's complement signed less than.

mkBvule :: Context -> AST -> AST -> IO AST Source #

Unsigned less than or equal to.

mkBvsle :: Context -> AST -> AST -> IO AST Source #

Two's complement signed less than or equal to.

mkBvuge :: Context -> AST -> AST -> IO AST Source #

Unsigned greater than or equal to.

mkBvsge :: Context -> AST -> AST -> IO AST Source #

Two's complement signed greater than or equal to.

mkBvugt :: Context -> AST -> AST -> IO AST Source #

Unsigned greater than.

mkBvsgt :: Context -> AST -> AST -> IO AST Source #

Two's complement signed greater than.

mkConcat :: Context -> AST -> AST -> IO AST Source #

Concatenate the given bit-vectors.

mkExtract :: Context -> Int -> Int -> AST -> IO AST Source #

Extract the bits high down to low from a bitvector of size m to yield a new bitvector of size n, where n = high - low + 1.

mkSignExt :: Context -> Int -> AST -> IO AST Source #

Sign-extend of the given bit-vector to the (signed) equivalent bitvector of size m+i, where m is the size of the given bit-vector.

mkZeroExt :: Context -> Int -> AST -> IO AST Source #

Extend the given bit-vector with zeros to the (unsigned) equivalent bitvector of size m+i, where m is the size of the given bit-vector.

mkRepeat :: Context -> Int -> AST -> IO AST Source #

Repeat the given bit-vector up length i.

mkBvshl :: Context -> AST -> AST -> IO AST Source #

Shift left.

mkBvlshr :: Context -> AST -> AST -> IO AST Source #

Logical shift right.

mkBvashr :: Context -> AST -> AST -> IO AST Source #

Arithmetic shift right.

mkRotateLeft :: Context -> Int -> AST -> IO AST Source #

Rotate bits of t1 to the left i times.

mkRotateRight :: Context -> Int -> AST -> IO AST Source #

Rotate bits of t1 to the right i times.

mkExtRotateLeft :: Context -> AST -> AST -> IO AST Source #

Rotate bits of t1 to the left t2 times.

mkExtRotateRight :: Context -> AST -> AST -> IO AST Source #

Rotate bits of t1 to the right t2 times.

mkInt2bv :: Context -> Int -> AST -> IO AST Source #

Create an n bit bit-vector from the integer argument t1.

mkBv2int :: Context -> AST -> Bool -> IO AST Source #

Create an integer from the bit-vector argument t1.

If is_signed is false, then the bit-vector t1 is treated as unsigned. So the result is non-negative and in the range [0..2^N-1], where N are the number of bits in t1. If is_signed is true, t1 is treated as a signed bit-vector.

mkBvnegNoOverflow :: Context -> AST -> IO AST Source #

Check that bit-wise negation does not overflow when t1 is interpreted as a signed bit-vector.

mkBvaddNoOverflow :: Context -> AST -> AST -> Bool -> IO AST Source #

Create a predicate that checks that the bit-wise addition of t1 and t2 does not overflow.

mkBvaddNoUnderflow :: Context -> AST -> AST -> IO AST Source #

Create a predicate that checks that the bit-wise signed addition of t1 and t2 does not underflow.

mkBvsubNoOverflow :: Context -> AST -> AST -> IO AST Source #

Create a predicate that checks that the bit-wise signed subtraction of t1 and t2 does not overflow.

mkBvsubNoUnderflow :: Context -> AST -> AST -> IO AST Source #

Create a predicate that checks that the bit-wise subtraction of t1 and t2 does not underflow.

mkBvmulNoOverflow :: Context -> AST -> AST -> Bool -> IO AST Source #

Create a predicate that checks that the bit-wise multiplication of t1 and t2 does not overflow.

mkBvmulNoUnderflow :: Context -> AST -> AST -> IO AST Source #

Create a predicate that checks that the bit-wise signed multiplication of t1 and t2 does not underflow.

mkBvsdivNoOverflow :: Context -> AST -> AST -> IO AST Source #

Create a predicate that checks that the bit-wise signed division of t1 and t2 does not overflow.

Arrays

mkSelect Source #

Arguments

:: Context 
-> AST

Array.

-> AST

Index of the array to read.

-> IO AST 

Array read. The argument a is the array and i is the index of the array that gets read.

mkStore Source #

Arguments

:: Context 
-> AST

Array.

-> AST

Index i of the array.

-> AST

New value for i.

-> IO AST 

Array update.

The result of this function is an array that is equal to the input array (with respect to select) on all indices except for i, where it maps to v.

The semantics of this function is given by the theory of arrays described in the SMT-LIB standard. See http://smtlib.org for more details.

mkConstArray Source #

Arguments

:: Context 
-> Sort

Domain sort of the array.

-> AST

Value v that the array maps to.

-> IO AST 

Create the constant array.

The resulting term is an array, such that a select on an arbitrary index produces the value v.

mkMap Source #

Arguments

:: Context 
-> FuncDecl

Function f.

-> [AST]

List of arrays.

-> IO AST 

Map a function f on the the argument arrays.

The n nodes args must be of array sorts [domain -> range_i]. The function declaration f must have type range_1 .. range_n -> range. The sort of the result is [domain -> range].

mkArrayDefault Source #

Arguments

:: Context 
-> AST

Array.

-> IO AST 

Access the array default value.

Produces the default range value, for arrays that can be represented as finite maps with a default range value.

Sets

mkEmptySet Source #

Arguments

:: Context 
-> Sort

Domain sort of the set.

-> IO AST 

Create the empty set.

mkFullSet Source #

Arguments

:: Context 
-> Sort

Domain sort of the set.

-> IO AST 

Create the full set.

mkSetAdd Source #

Arguments

:: Context 
-> AST

Set.

-> AST

Element.

-> IO AST 

Add an element to a set.

mkSetDel Source #

Arguments

:: Context 
-> AST

Set.

-> AST

Element.

-> IO AST 

Remove an element from a set.

mkSetUnion :: Context -> [AST] -> IO AST Source #

Take the union of a list of sets.

mkSetIntersect :: Context -> [AST] -> IO AST Source #

Take the intersection of a list of sets.

mkSetDifference Source #

Arguments

:: Context 
-> AST

First set.

-> AST

Second set.

-> IO AST 

Take the set difference between two sets.

mkSetComplement Source #

Arguments

:: Context 
-> AST

Set.

-> IO AST 

Take the complement of a set.

mkSetMember Source #

Arguments

:: Context 
-> AST

Element.

-> AST

Set.

-> IO AST 

Check for set membership.

mkSetSubset Source #

Arguments

:: Context 
-> AST

First set.

-> AST

Second set.

-> IO AST 

Check if the first set is a subset of the second set.

Numerals

mkNumeral :: Context -> String -> Sort -> IO AST Source #

Create a numeral of a given sort.

mkReal Source #

Arguments

:: Context 
-> Int

numerator

-> Int

denominator (/= 0)

-> IO AST 

Create a real from a fraction.

mkInt :: Context -> Int -> Sort -> IO AST Source #

Create a numeral of an int, bit-vector, or finite-domain sort.

This function can be use to create numerals that fit in a machine integer. It is slightly faster than mkNumeral since it is not necessary to parse a string.

mkUnsignedInt :: Context -> Word -> Sort -> IO AST Source #

Create a numeral of an int, bit-vector, or finite-domain sort.

This function can be use to create numerals that fit in a machine unsigned integer. It is slightly faster than mkNumeral since it is not necessary to parse a string.

mkInt64 :: Context -> Int64 -> Sort -> IO AST Source #

Create a numeral of an int, bit-vector, or finite-domain sort.

This function can be use to create numerals that fit in a machine 64-bit integer. It is slightly faster than mkNumeral since it is not necessary to parse a string.

mkUnsignedInt64 :: Context -> Word64 -> Sort -> IO AST Source #

Create a numeral of an int, bit-vector, or finite-domain sort.

This function can be use to create numerals that fit in a machine unsigned 64-bit integer. It is slightly faster than mkNumeral since it is not necessary to parse a string.

Helpers

mkIntegral :: Integral a => Context -> a -> Sort -> IO AST Source #

Create a numeral of an int, bit-vector, or finite-domain sort.

mkRational :: Context -> Rational -> IO AST Source #

Create a numeral of sort real from a Rational.

mkFixed :: HasResolution a => Context -> Fixed a -> IO AST Source #

Create a numeral of sort real from a Fixed.

mkRealNum :: Real r => Context -> r -> IO AST Source #

Create a numeral of sort real from a Real.

mkInteger :: Context -> Integer -> IO AST Source #

Create a numeral of sort int from an Integer.

mkIntNum :: Integral a => Context -> a -> IO AST Source #

Create a numeral of sort int from an Integral.

mkBitvector Source #

Arguments

:: Context 
-> Int

bit-width

-> Integer

integer value

-> IO AST 

Create a numeral of sort Bit-vector from an Integer.

mkBvNum Source #

Arguments

:: Integral i 
=> Context 
-> Int

bit-width

-> i

integer value

-> IO AST 

Create a numeral of sort Bit-vector from an Integral.

Sequences and regular expressions

mkSeqSort :: Context -> Sort -> IO Sort Source #

Create a sequence sort out of the sort for the elements.

isSeqSort :: Context -> Sort -> IO Bool Source #

Check if s is a sequence sort.

mkReSort :: Context -> Sort -> IO Sort Source #

Create a regular expression sort out of a sequence sort.

isReSort :: Context -> Sort -> IO Bool Source #

Check if s is a regular expression sort.

mkStringSort :: Context -> IO Sort Source #

Create a sort for 8 bit strings. This function creates a sort for ASCII strings. Each character is 8 bits.

isStringSort :: Context -> Sort -> IO Bool Source #

Check if s is a string sort.

mkString :: Context -> String -> IO AST Source #

Create a string constant out of the string that is passed in.

isString :: Context -> AST -> IO Bool Source #

Determine if s is a string constant.

getString :: Context -> AST -> IO String Source #

Retrieve the string constant stored in s.

mkSeqEmpty :: Context -> Sort -> IO AST Source #

Create an empty sequence of the sequence sort seq.

mkSeqUnit :: Context -> AST -> IO AST Source #

Create a unit sequence of a.

mkSeqConcat :: Context -> [AST] -> IO AST Source #

Concatenate sequences.

mkSeqPrefix Source #

Arguments

:: Context 
-> AST

prefix

-> AST

s

-> IO AST 

Check if prefix is a prefix of s.

mkSeqSuffix Source #

Arguments

:: Context 
-> AST

suffix

-> AST

s

-> IO AST 

Check if suffix is a suffix of s.

mkSeqContains Source #

Arguments

:: Context 
-> AST

container

-> AST

containee

-> IO AST 

Check if container contains containee.

mkStrLt Source #

Arguments

:: Context 
-> AST

s1

-> AST

s2

-> IO AST 

Check if s1 is equal or lexicographically strictly less than s2.

mkStrLe Source #

Arguments

:: Context 
-> AST

s1

-> AST

s2

-> IO AST 

Check if s1 is lexicographically strictly less than s2.

mkSeqExtract Source #

Arguments

:: Context 
-> AST

s

-> AST

offset

-> AST

length

-> IO AST 

Extract subsequence starting at offset of length.

mkSeqReplace Source #

Arguments

:: Context 
-> AST

s

-> AST

src

-> AST

dst

-> IO AST 

Replace the first occurrence of src with dst in s.

mkSeqAt Source #

Arguments

:: Context 
-> AST

s

-> AST

index

-> IO AST 

Retrieve from s the unit sequence positioned at position index.

mkSeqLength Source #

Arguments

:: Context 
-> AST

s

-> IO AST 

Return the length of the sequence s.

mkSeqIndex Source #

Arguments

:: Context 
-> AST

s

-> AST

substr

-> AST

offset

-> IO AST 

Return index of first occurrence of substr in s starting from offset offset. If s does not contain substr, then the value is -1, if offset is the length of s, then the value is -1 as well. The function is under-specified if offset is negative or larger than the length of s.

mkStrToInt :: Context -> AST -> IO AST Source #

Convert string to integer.

mkIntToStr :: Context -> AST -> IO AST Source #

Integer to string conversion.

mkSeqToRe :: Context -> AST -> IO AST Source #

Create a regular expression that accepts the sequence.

mkSeqInRe Source #

Arguments

:: Context 
-> AST

seq

-> AST

re

-> IO AST 

Check if seq is in the language generated by the regular expression re.

mkRePlus :: Context -> AST -> IO AST Source #

Create the regular language re+.

mkReStar :: Context -> AST -> IO AST Source #

Create the regular language re*.

mkReOption :: Context -> AST -> IO AST Source #

Create the regular language [re].

mkReUnion :: Integral int => Context -> int -> [AST] -> IO AST Source #

Create the union of the regular languages.

mkReConcat :: Integral int => Context -> int -> [AST] -> IO AST Source #

Create the concatenation of the regular languages.

mkReRange Source #

Arguments

:: Context 
-> AST

lo

-> AST

hi

-> IO AST 

Create the range regular expression over two sequences of length 1.

mkReLoop Source #

Arguments

:: Integral int 
=> Context 
-> AST

r

-> int

lo

-> int

hi

-> IO AST 

Create a regular expression loop. The supplied regular expression r is repeated between lo and hi times. The lo should be below hi with one exception: when supplying the value hi as 0, the meaning is to repeat the argument r at least lo number of times, and with an unbounded upper bound.

mkReIntersect :: Integral int => Context -> int -> [AST] -> IO AST Source #

Create the intersection of the regular languages.

mkReComplement :: Context -> AST -> IO AST Source #

Create the complement of the regular language.

mkReEmpty :: Context -> Sort -> IO AST Source #

Create an empty regular expression of sort re.

mkReFull :: Context -> Sort -> IO AST Source #

Create an universal regular expression of sort re.

Quantifiers

mkPattern Source #

Arguments

:: Context 
-> [AST]

Terms.

-> IO Pattern 

Create a pattern for quantifier instantiation.

Z3 uses pattern matching to instantiate quantifiers. If a pattern is not provided for a quantifier, then Z3 will automatically compute a set of patterns for it. However, for optimal performance, the user should provide the patterns.

Patterns comprise a list of terms. The list should be non-empty. If the list comprises of more than one term, it is a called a multi-pattern.

In general, one can pass in a list of (multi-)patterns in the quantifier constructor.

mkBound Source #

Arguments

:: Context 
-> Int

de-Bruijn index.

-> Sort 
-> IO AST 

Create a bound variable.

Bound variables are indexed by de-Bruijn indices.

See http://z3prover.github.io/api/html/group__capi.html#ga1d4da8849fca699b345322f8ee1fa31e

mkForall Source #

Arguments

:: Context 
-> [Pattern]

Instantiation patterns (see mkPattern).

-> [Symbol]

Bound (quantified) variables xs.

-> [Sort]

Sorts of the bound variables.

-> AST

Body of the quantifier.

-> IO AST 

mkForall with weight 0 (the default).

mkForallW Source #

Arguments

:: Context 
-> Int

quantifiers are associated with weights indicating the importance of using the quantifier during instantiation. By default, pass the weight 0.

-> [Pattern]

Instantiation patterns (see mkPattern).

-> [Symbol]

Bound (quantified) variables xs.

-> [Sort]

Sorts of the bound variables.

-> AST

Body of the quantifier.

-> IO AST 

Create a forall formula.

The bound variables are de-Bruijn indices created using mkBound.

Z3 applies the convention that the last element in xs refers to the variable with index 0, the second to last element of xs refers to the variable with index 1, etc.

mkExists :: Context -> [Pattern] -> [Symbol] -> [Sort] -> AST -> IO AST Source #

mkExistsW with weight 0 (the default).

mkExistsW :: Context -> Int -> [Pattern] -> [Symbol] -> [Sort] -> AST -> IO AST Source #

Create an exists formula.

Similar to mkForallW.

mkForallConst :: Context -> [Pattern] -> [App] -> AST -> IO AST Source #

mkForallWConst with weight set to 0 (the default).

mkForallWConst Source #

Arguments

:: Context 
-> Int

quantifiers are associated with weights indicating the importance of using the quantifier during instantiation. By default, pass the weight 0.

-> [Pattern]

Instantiation patterns (see mkPattern).

-> [App]

Constants to be abstracted into bound variables.

-> AST

Quantifier body.

-> IO AST 

Create a universal quantifier using a list of constants that will form the set of bound variables.

mkExistsConst :: Context -> [Pattern] -> [App] -> AST -> IO AST Source #

mkForallWConst with weight set to 0 (the default).

mkExistsWConst Source #

Arguments

:: Context 
-> Int

quantifiers are associated with weights indicating the importance of using the quantifier during instantiation. By default, pass the weight 0.

-> [Pattern]

Instantiation patterns (see mkPattern).

-> [App]

Constants to be abstracted into bound variables.

-> AST

Quantifier body.

-> IO AST 

Create a existential quantifier using a list of constants that will form the set of bound variables.

Accessors

getSymbolString :: Context -> Symbol -> IO String Source #

Return the symbol name.

isEqSort :: Context -> Sort -> Sort -> IO Bool Source #

Compare sorts.

getSortName :: Context -> Sort -> IO Symbol Source #

Return the sort name as a symbol.

sortToAst :: Context -> Sort -> IO AST Source #

Convert a Z3_sort into Z3_ast. This is just type casting.

getSortId :: Context -> Sort -> IO Int Source #

Return a unique identifier for s.

getSortKind :: Context -> Sort -> IO SortKind Source #

Return the sort kind of the given sort.

getBvSortSize :: Context -> Sort -> IO Int Source #

Return the size of the given bit-vector sort.

getDatatypeSortConstructors Source #

Arguments

:: Context 
-> Sort

Datatype sort.

-> IO [FuncDecl]

Constructor declarations.

Get list of constructors for datatype.

getDatatypeSortRecognizers Source #

Arguments

:: Context 
-> Sort

Datatype sort.

-> IO [FuncDecl]

Constructor recognizers.

Get list of recognizers for datatype.

getDatatypeSortConstructorAccessors Source #

Arguments

:: Context 
-> Sort

Datatype sort.

-> IO [[FuncDecl]]

Constructor accessors.

Get list of accessors for the datatype constructor.

getDeclName :: Context -> FuncDecl -> IO Symbol Source #

Return the constant declaration name as a symbol.

getArity :: Context -> FuncDecl -> IO Int Source #

Returns the number of parameters of the given declaration

getDomain Source #

Arguments

:: Context 
-> FuncDecl

A function declaration

-> Int

i

-> IO Sort 

Returns the sort of the i-th parameter of the given function declaration

getRange :: Context -> FuncDecl -> IO Sort Source #

Returns the range of the given declaration.

appToAst :: Context -> App -> IO AST Source #

Convert an app into AST. This is just type casting.

getAppDecl :: Context -> App -> IO FuncDecl Source #

Return the declaration of a constant or function application.

getAppNumArgs :: Context -> App -> IO Int Source #

Return the number of argument of an application. If t is an constant, then the number of arguments is 0.

getAppArg :: Context -> App -> Int -> IO AST Source #

Return the i-th argument of the given application.

getAppArgs :: Context -> App -> IO [AST] Source #

Return a list of all the arguments of the given application.

getSort :: Context -> AST -> IO Sort Source #

Return the sort of an AST node.

getBoolValue :: Context -> AST -> IO (Maybe Bool) Source #

Return Z3_L_TRUE if a is true, Z3_L_FALSE if it is false, and Z3_L_UNDEF otherwise.

getAstKind :: Context -> AST -> IO ASTKind Source #

Return the kind of the given AST.

isApp :: Context -> AST -> IO Bool Source #

Return True if an ast is APP_AST, False otherwise.

toApp :: Context -> AST -> IO App Source #

Convert an ast into an APP_AST. This is just type casting.

getNumeralString :: Context -> AST -> IO String Source #

Return numeral value, as a string of a numeric constant term.

getNumerator :: Context -> AST -> IO AST Source #

Return the numerator (as a numeral AST) of a numeral AST of sort Real.

Reference: https://z3prover.github.io/api/html/group__capi.html#ga2d37084eb47ea0ab19638a3407ce610b

getDenominator :: Context -> AST -> IO AST Source #

Return the denominator (as a numeral AST) of a numeral AST of sort Real.

Reference: https://z3prover.github.io/api/html/group__capi.html#ga07549939888e8fdfc8e0fde1776c31a7

Helpers

getBool :: Context -> AST -> IO Bool Source #

Read a Bool value from an AST

getInt :: Context -> AST -> IO Integer Source #

Read an Integer value from an AST

getReal :: Context -> AST -> IO Rational Source #

Read a Rational value from an AST

Modifiers

Models

modelEval Source #

Arguments

:: Context 
-> Model

Model m.

-> AST

Expression to evaluate t.

-> Bool

Model completion?

-> IO (Maybe AST) 

Evaluate an AST node in the given model.

The evaluation may fail for the following reasons:

  • t contains a quantifier.
  • the model m is partial.
  • t is type incorrect.

evalArray :: Context -> Model -> AST -> IO (Maybe FuncModel) Source #

Evaluate an array as a function, if possible.

getFuncInterp :: Context -> Model -> FuncDecl -> IO (Maybe FuncInterp) Source #

Return the interpretation of the function f in the model m. Return NULL, if the model does not assign an interpretation for f. That should be interpreted as: the f does not matter.

isAsArray :: Context -> AST -> IO Bool Source #

The (_ as-array f) AST node is a construct for assigning interpretations for arrays in Z3. It is the array such that forall indices i we have that (select (_ as-array f) i) is equal to (f i). This procedure returns Z3_TRUE if the a is an as-array AST node.

getAsArrayFuncDecl :: Context -> AST -> IO FuncDecl Source #

Return the function declaration f associated with a (_ as_array f) node.

funcInterpGetNumEntries :: Context -> FuncInterp -> IO Int Source #

Return the number of entries in the given function interpretation.

funcInterpGetEntry :: Context -> FuncInterp -> Int -> IO FuncEntry Source #

Return a _point_ of the given function intepretation. It represents the value of f in a particular point.

funcInterpGetElse :: Context -> FuncInterp -> IO AST Source #

Return the 'else' value of the given function interpretation.

funcInterpGetArity :: Context -> FuncInterp -> IO Int Source #

Return the arity (number of arguments) of the given function interpretation.

funcEntryGetValue :: Context -> FuncEntry -> IO AST Source #

Return the value of this point.

funcEntryGetNumArgs :: Context -> FuncEntry -> IO Int Source #

Return the number of arguments in a Z3_func_entry object.

funcEntryGetArg :: Context -> FuncEntry -> Int -> IO AST Source #

Return an argument of a Z3_func_entry object.

modelToString :: Context -> Model -> IO String Source #

Convert the given model into a string.

showModel :: Context -> Model -> IO String Source #

Deprecated: Use modelToString instead.

Alias for modelToString.

Helpers

type EvalAst a = Model -> AST -> IO (Maybe a) Source #

Type of an evaluation function for AST.

Evaluation may fail (i.e. return Nothing) for a few reasons, see modelEval.

eval :: Context -> EvalAst AST Source #

An alias for modelEval with model completion enabled.

evalBool :: Context -> EvalAst Bool Source #

Evaluate an AST node of sort bool in the given model.

See modelEval and getBool.

evalInt :: Context -> EvalAst Integer Source #

Evaluate an AST node of sort int in the given model.

See modelEval and getInt.

evalReal :: Context -> EvalAst Rational Source #

Evaluate an AST node of sort real in the given model.

See modelEval and getReal.

evalBv Source #

Arguments

:: Context 
-> Bool

signed?

-> EvalAst Integer 

Evaluate an AST node of sort bit-vector in the given model.

The flag signed decides whether the bit-vector value is interpreted as a signed or unsigned integer.

See modelEval and mkBv2int.

mapEval :: Traversable t => EvalAst a -> Model -> t AST -> IO (Maybe (t a)) Source #

Run a evaluation function on a Traversable data structure of ASTs (e.g. [AST], Vector AST, Maybe AST, etc).

This a generic version of evalT which can be used in combination with other helpers. For instance, mapEval (evalInt c) can be used to obtain the Integer interpretation of a list of AST of sort int.

evalT :: Traversable t => Context -> Model -> t AST -> IO (Maybe (t AST)) Source #

Evaluate a collection of AST nodes in the given model.

data FuncModel Source #

The interpretation of a function.

Constructors

FuncModel 

Fields

evalFunc :: Context -> Model -> FuncDecl -> IO (Maybe FuncModel) Source #

Evaluate a function declaration to a list of argument/value pairs.

Tactics

String Conversion

data ASTPrintMode Source #

Pretty-printing mode for converting ASTs to strings. The mode can be one of the following:

  • Z3_PRINT_SMTLIB_FULL: Print AST nodes in SMTLIB verbose format.
  • Z3_PRINT_LOW_LEVEL: Print AST nodes using a low-level format.
  • Z3_PRINT_SMTLIB_COMPLIANT: Print AST nodes in SMTLIB 1.x compliant format.
  • Z3_PRINT_SMTLIB2_COMPLIANT: Print AST nodes in SMTLIB 2.x compliant format.

setASTPrintMode :: Context -> ASTPrintMode -> IO () Source #

Set the pretty-printing mode for converting ASTs to strings.

astToString :: Context -> AST -> IO String Source #

Convert an AST to a string.

patternToString :: Context -> Pattern -> IO String Source #

Convert a pattern to a string.

sortToString :: Context -> Sort -> IO String Source #

Convert a sort to a string.

funcDeclToString :: Context -> FuncDecl -> IO String Source #

Convert a FuncDecl to a string.

benchmarkToSMTLibString Source #

Arguments

:: Context 
-> String

name

-> String

logic

-> String

status

-> String

attributes

-> [AST]

assumptions

-> AST

formula

-> IO String 

Convert the given benchmark into SMT-LIB formatted string.

The output format can be configured via setASTPrintMode.

Parser interface

parseSMTLib2String Source #

Arguments

:: Context 
-> String

string to parse

-> [Symbol]

sort names

-> [Sort]

sorts

-> [Symbol]

declaration names

-> [FuncDecl]

declarations

-> IO [AST] 

parseSMTLib2File Source #

Arguments

:: Context 
-> String

file name

-> [Symbol]

sort names

-> [Sort]

sorts

-> [Symbol]

declaration names

-> [FuncDecl]

declarations

-> IO [AST] 

evalSMTLib2String Source #

Arguments

:: Context 
-> String

string to parse

-> IO String 

Error Handling

data Z3Error Source #

Z3 exceptions.

Z3 errors are re-thrown as Haskell Z3Error exceptions, see Exception.

Constructors

Z3Error 

Instances

Instances details
Exception Z3Error Source # 
Instance details

Defined in Z3.Base

Show Z3Error Source # 
Instance details

Defined in Z3.Base

Miscellaneous

data Version Source #

Constructors

Version 

Fields

Instances

Instances details
Show Version Source # 
Instance details

Defined in Z3.Base

Eq Version Source # 
Instance details

Defined in Z3.Base

Methods

(==) :: Version -> Version -> Bool #

(/=) :: Version -> Version -> Bool #

Ord Version Source # 
Instance details

Defined in Z3.Base

getVersion :: IO Version Source #

Return Z3 version number information.

Fixedpoint

newtype Fixedpoint Source #

Instances

Instances details
Eq Fixedpoint Source # 
Instance details

Defined in Z3.Base

Floating-Point Arithmetic

mkFpaRoundingModeSort :: Context -> IO Sort Source #

Create the RoundingMode sort.

mkFpaRoundNearestTiesToEven :: Context -> IO AST Source #

Create a numeral of RoundingMode sort which represents the NearestTiesToEven rounding mode.

mkFpaRne :: Context -> IO AST Source #

Create a numeral of RoundingMode sort which represents the NearestTiesToEven rounding mode.

mkFpaRoundNearestTiesToAway :: Context -> IO AST Source #

Create a numeral of RoundingMode sort which represents the NearestTiesToAway rounding mode.

mkFpaRna :: Context -> IO AST Source #

Create a numeral of RoundingMode sort which represents the NearestTiesToAway rounding mode.

mkFpaRoundTowardPositive :: Context -> IO AST Source #

Create a numeral of RoundingMode sort which represents the TowardPositive rounding mode.

mkFpaRtp :: Context -> IO AST Source #

Create a numeral of RoundingMode sort which represents the TowardPositive rounding mode.

mkFpaRoundTowardNegative :: Context -> IO AST Source #

Create a numeral of RoundingMode sort which represents the TowardNegative rounding mode.

mkFpaRtn :: Context -> IO AST Source #

Create a numeral of RoundingMode sort which represents the TowardNegative rounding mode.

mkFpaRoundTowardZero :: Context -> IO AST Source #

Create a numeral of RoundingMode sort which represents the TowardZero rounding mode.

mkFpaRtz :: Context -> IO AST Source #

Create a numeral of RoundingMode sort which represents the TowardZero rounding mode.

mkFpaSort Source #

Arguments

:: Integral int 
=> Context

Context

-> int

Number of exponent bits

-> int

Number of significand bits

-> IO Sort 

Create a FloatingPoint sort.

mkFpaSortHalf :: Context -> IO Sort Source #

Create the half-precision (16-bit) FloatingPoint sort.

mkFpaSort16 :: Context -> IO Sort Source #

Create the half-precision (16-bit) FloatingPoint sort.

mkFpaSortSingle :: Context -> IO Sort Source #

Create the single-precision (32-bit) FloatingPoint sort.

mkFpaSort32 :: Context -> IO Sort Source #

Create the single-precision (32-bit) FloatingPoint sort.

mkFpaSortDouble :: Context -> IO Sort Source #

Create the double-precision (64-bit) FloatingPoint sort.

mkFpaSort64 :: Context -> IO Sort Source #

Create the double-precision (64-bit) FloatingPoint sort.

mkFpaSortQuadruple :: Context -> IO Sort Source #

Create the quadruple-precision (128-bit) FloatingPoint sort.

mkFpaSort128 :: Context -> IO Sort Source #

Create the quadruple-precision (128-bit) FloatingPoint sort.

mkFpaNaN :: Context -> Sort -> IO AST Source #

Create a floating-point NaN of sort s.

mkFpaInf Source #

Arguments

:: Context

Context

-> Sort

Target sort

-> Bool

Indicates whether the result should be negative

-> IO AST 

Create a floating-point infinity of sort s.

mkFpaZero Source #

Arguments

:: Context

Context

-> Sort

Target sort

-> Bool

Indicates whether the result should be negative

-> IO AST 

Create a floating-point zero of sort s.

mkFpaFp Source #

Arguments

:: Context

Context

-> AST

Sign

-> AST

Exponent

-> AST

Significand

-> IO AST 

Create an expression of FloatingPoint sort from three bit-vector expressions.

This is the operator named fp in the SMT FP theory definition. Note that sgn is required to be a bit-vector of size 1. Significand and exponent are required to be longer than 1 and 2 respectively. The FloatingPoint sort of the resulting expression is automatically determined from the bit-vector sizes of the arguments. The exponent is assumed to be in IEEE-754 biased representation.

mkFpaNumeralFloat :: Context -> Float -> Sort -> IO AST Source #

Create a numeral of FloatingPoint sort from a float.

mkFpaNumeralDouble :: Context -> Double -> Sort -> IO AST Source #

Create a numeral of FloatingPoint sort from a double.

mkFpaNumeralInt :: Integral int => Context -> int -> Sort -> IO AST Source #

Create a numeral of FloatingPoint sort from a signed integer.

mkFpaNumeralIntUInt Source #

Arguments

:: Integral int 
=> Context

Context

-> Bool

Sign bit (true == negative)

-> int

Significand

-> int

Exponent

-> Sort

Result sort

-> IO AST 

Create a numeral of FLoatingPoint sort from a sign bit and two integers.

mkFpaNumeralInt64UInt64 Source #

Arguments

:: Integral int 
=> Context

Context

-> Bool

Sign bit (true == negative)

-> int

Significand

-> int

Exponent

-> Sort

Result sort

-> IO AST 

Create a numeral of FloatingPoint sort from a sign bit and two 64-bit integers.

mkFpaAbs :: Context -> AST -> IO AST Source #

Floating-point absolute value.

mkFpaNeg :: Context -> AST -> IO AST Source #

Floating-point negation.

mkFpaAdd Source #

Arguments

:: Context

Context

-> AST

Rounding Mode

-> AST

FloatingPoint sort term

-> AST

FloatingPoint sort term

-> IO AST 

Floating-point addition.

mkFpaSub Source #

Arguments

:: Context

Context

-> AST

Rounding Mode

-> AST

FloatingPoint sort term

-> AST

FloatingPoint sort term

-> IO AST 

Floating-point subtraction.

mkFpaMul Source #

Arguments

:: Context

Context

-> AST

Rounding Mode

-> AST

FloatingPoint sort term

-> AST

FloatingPoint sort term

-> IO AST 

Floating-point multiplication.

mkFpaDiv Source #

Arguments

:: Context

Context

-> AST

Rounding Mode

-> AST

FloatingPoint sort term

-> AST

FloatingPoint sort term

-> IO AST 

Floating-point division.

mkFpaFma :: Context -> AST -> AST -> AST -> AST -> IO AST Source #

Floating-point fused multiply-add.

The result is round((t1 * t2) + t3).

mkFpaSqrt :: Context -> AST -> AST -> IO AST Source #

Floating-point square root.

mkFpaRem :: Context -> AST -> AST -> IO AST Source #

Floating-point remainder.

mkFpaRoundToIntegral :: Context -> AST -> AST -> IO AST Source #

Floating-point roundToIntegral. Rounds a floating-point number to the closest integer, again represented as a floating-point number.

mkFpaMin :: Context -> AST -> AST -> IO AST Source #

Minimum of floating-point numbers.

mkFpaMax :: Context -> AST -> AST -> IO AST Source #

Maximum of floating-point numbers.

mkFpaLeq :: Context -> AST -> AST -> IO AST Source #

Floating-point less than or equal.

mkFpaLt :: Context -> AST -> AST -> IO AST Source #

Floating-point less than.

mkFpaGeq :: Context -> AST -> AST -> IO AST Source #

Floating-point greater than or equal.

mkFpaGt :: Context -> AST -> AST -> IO AST Source #

Floating-point greater than.

mkFpaEq :: Context -> AST -> AST -> IO AST Source #

Floating-point equality.

mkFpaIsNormal :: Context -> AST -> IO AST Source #

Predicate indicating whether t is a normal floating-point number.

mkFpaIsSubnormal :: Context -> AST -> IO AST Source #

Predicate indicating whether t is a subnormal floating-point number.

mkFpaIsZero :: Context -> AST -> IO AST Source #

Predicate indicating whether t is a floating-point number with zero value, i.e., +zero or -zero.

mkFpaIsInfinite :: Context -> AST -> IO AST Source #

Predicate indicating whether t is a floating-point number representing infinity, i.e., +oo or -oo.

mkFpaIsNaN :: Context -> AST -> IO AST Source #

Predicate indicating whether t is NaN.

mkFpaIsNegative :: Context -> AST -> IO AST Source #

Predicate indicating whether t is a negative floating-point number.

mkFpaIsPositive :: Context -> AST -> IO AST Source #

Predicate indicating whether t is a positive floating-point number.

mkFpaToFpBv :: Context -> AST -> Sort -> IO AST Source #

Conversion of a single IEEE 754-2008 bit-vector into a floating-point number.

mkFpaToFpFloat :: Context -> AST -> AST -> Sort -> IO AST Source #

Conversion of a FloatingPoint term into another term of different FloatingPoint sort.

mkFpaToFpReal :: Context -> AST -> AST -> Sort -> IO AST Source #

Conversion of a term of real sort into a term of FloatingPoint sort.

mkFpaToFpSigned :: Context -> AST -> AST -> Sort -> IO AST Source #

Conversion of a 2's complement signed bit-vector term into a term of FloatingPoint sort.

mkFpaToFpUnsigned :: Context -> AST -> AST -> Sort -> IO AST Source #

Conversion of a 2's complement unsigned bit-vector term into a term of FloatingPoint sort.

mkFpaToUbv :: Integral int => Context -> AST -> AST -> int -> IO AST Source #

Conversion of a floating-point term into an unsigned bit-vector.

mkFpaToSbv :: Integral int => Context -> AST -> AST -> int -> IO AST Source #

Conversion of a floating-point term into a signed bit-vector.

mkFpaToReal :: Context -> AST -> IO AST Source #

Conversion of a floating-point term into an real-numbered term.

Z3-specific floating-point extensions

fpaGetEbits :: Integral int => Context -> Sort -> IO int Source #

Retrieves the number of bits reserved for the exponent in a FloatingPoint sort.

fpaGetSbits :: Integral int => Context -> Sort -> IO int Source #

Retrieves the number of bits reserved for the significand in a FloatingPoint sort.

fpaIsNumeralNaN :: Context -> AST -> IO Bool Source #

Checks whether a given floating-point numeral is a NaN.

fpaIsNumeralInf :: Context -> AST -> IO Bool Source #

Checks whether a given floating-point numeral is a +oo or -oo.

fpaIsNumeralZero :: Context -> AST -> IO Bool Source #

Checks whether a given floating-point numeral is a +zero or -zero.

fpaIsNumeralNormal :: Context -> AST -> IO Bool Source #

Checks whether a given floating-point numeral is normal.

fpaIsNumeralSubnormal :: Context -> AST -> IO Bool Source #

Checks whether a given floating-point numeral is subnormal.

fpaIsNumeralPositive :: Context -> AST -> IO Bool Source #

Checks whether a given floating-point numeral is positive.

fpaIsNumeralNegative :: Context -> AST -> IO Bool Source #

Checks whether a given floating-point numeral is negative.

fpaGetNumeralSignBv :: Context -> AST -> IO AST Source #

Retrieves the sign of a floating-point literal as a bit-vector expression.

fpaGetNumeralSignificandBv :: Context -> AST -> IO AST Source #

Retrieves the significand of a floating-point literal as a bit-vector expression.

fpaGetNumeralSignificandString :: Context -> AST -> IO String Source #

Return the significand value of a floating-point numeral as a string.

fpaGetNumeralExponentString :: Context -> AST -> Bool -> IO String Source #

Return the exponent value of a floating-point numeral as a string.

fpaGetNumeralExponentBv :: Context -> AST -> Bool -> IO AST Source #

Retrieves the exponent of a floating-point literal as a bit-vector expression.

mkFpaToIEEEBv :: Context -> AST -> IO AST Source #

Conversion of a floating-point term into a bit-vector term in IEEE 754-2008 format.

mkFpaToFpIntReal :: Context -> AST -> AST -> AST -> Sort -> IO AST Source #

Conversion of a real-sorted significand and an integer-sorted exponent into a term of FloatingPoint sort.

Optimization

newtype Optimize Source #

Constructors

Optimize 

Instances

Instances details
Eq Optimize Source # 
Instance details

Defined in Z3.Base

Solvers

data Logic Source #

Solvers available in Z3.

These are described at http://smtlib.cs.uiowa.edu/logics.html

Constructors

AUFLIA

Closed formulas over the theory of linear integer arithmetic and arrays extended with free sort and function symbols but restricted to arrays with integer indices and values.

AUFLIRA

Closed linear formulas with free sort and function symbols over one- and two-dimentional arrays of integer index and real value.

AUFNIRA

Closed formulas with free function and predicate symbols over a theory of arrays of arrays of integer index and real value.

LRA

Closed linear formulas in linear real arithmetic.

QF_ABV

Closed quantifier-free formulas over the theory of bitvectors and bitvector arrays.

QF_AUFBV

Closed quantifier-free formulas over the theory of bitvectors and bitvector arrays extended with free sort and function symbols.

QF_AUFLIA

Closed quantifier-free linear formulas over the theory of integer arrays extended with free sort and function symbols.

QF_AX

Closed quantifier-free formulas over the theory of arrays with extensionality.

QF_BV

Closed quantifier-free formulas over the theory of fixed-size bitvectors.

QF_IDL

Difference Logic over the integers. In essence, Boolean combinations of inequations of the form x - y < b where x and y are integer variables and b is an integer constant.

QF_LIA

Unquantified linear integer arithmetic. In essence, Boolean combinations of inequations between linear polynomials over integer variables.

QF_LRA

Unquantified linear real arithmetic. In essence, Boolean combinations of inequations between linear polynomials over real variables.

QF_NIA

Quantifier-free integer arithmetic.

QF_NRA

Quantifier-free real arithmetic.

QF_RDL

Difference Logic over the reals. In essence, Boolean combinations of inequations of the form x - y < b where x and y are real variables and b is a rational constant.

QF_UF

Unquantified formulas built over a signature of uninterpreted (i.e., free) sort and function symbols.

QF_UFBV

Unquantified formulas over bitvectors with uninterpreted sort function and symbols.

QF_UFIDL

Difference Logic over the integers (in essence) but with uninterpreted sort and function symbols.

QF_UFLIA

Unquantified linear integer arithmetic with uninterpreted sort and function symbols.

QF_UFLRA

Unquantified linear real arithmetic with uninterpreted sort and function symbols.

QF_UFNRA

Unquantified non-linear real arithmetic with uninterpreted sort and function symbols.

UFLRA

Linear real arithmetic with uninterpreted sort and function symbols.

UFNIA

Non-linear integer arithmetic with uninterpreted sort and function symbols.

Instances

Instances details
Show Logic Source # 
Instance details

Defined in Z3.Base

Methods

showsPrec :: Int -> Logic -> ShowS #

show :: Logic -> String #

showList :: [Logic] -> ShowS #

solverGetHelp :: Context -> Solver -> IO String Source #

Return a string describing all solver available parameters.

solverSetParams :: Context -> Solver -> Params -> IO () Source #

Set the given solver using the given parameters.

solverGetNumScopes :: Context -> Solver -> IO Int Source #

Number of backtracking points.

solverCheck :: Context -> Solver -> IO Result Source #

Check whether the assertions in a given solver are consistent or not.

solverCheckAssumptions :: Context -> Solver -> [AST] -> IO Result Source #

Check whether the assertions in the given solver and optional assumptions are consistent or not.

solverGetModel :: Context -> Solver -> IO Model Source #

Retrieve the model for the last solverCheck.

The error handler is invoked if a model is not available because the commands above were not invoked for the given solver, or if the result was Unsat.

solverGetProof :: Context -> Solver -> IO AST Source #

Retrieve the proof for the last solverCheck or solverCheckAssumptions.

The error handler is invoked if a proof is not available because the commands above were not invoked for the given solver, or if the result was different from Unsat (so Sat does not have a proof).

solverGetUnsatCore :: Context -> Solver -> IO [AST] Source #

Retrieve the unsat core for the last solverCheckAssumptions; the unsat core is a subset of the assumptions

solverGetReasonUnknown :: Context -> Solver -> IO String Source #

Return a brief justification for an Unknown result for the commands solverCheck and solverCheckAssumptions.

solverToString :: Context -> Solver -> IO String Source #

Convert the given solver into a string.

Helpers

solverCheckAndGetModel :: Context -> Solver -> IO (Result, Maybe Model) Source #

Call solverCheck and based on the result also call solverGetModel.