hz3-96.0.0.0: Bindings for the Z3 Theorem Prover
Copyright(c) Iago Abal 2013-2015
(c) David Castro 2013-2015
LicenseBSD3
MaintainerIago Abal <mail@iagoabal.eu>, David Castro <david.castro.dcp@gmail.com>
Safe HaskellNone
LanguageHaskell98

Z3.Monad

Description

A simple monadic interface to Z3 API.

Examples: https://bitbucket.org/iago/z3-haskell/src/tip/examples/Example/Monad

Synopsis

Z3 monad

class (Applicative m, Monad m, MonadIO m) => MonadZ3 m where Source #

Instances

Instances details
MonadZ3 Z3 Source # 
Instance details

Defined in Z3.Monad

data Z3 a Source #

Instances

Instances details
Monad Z3 Source # 
Instance details

Defined in Z3.Monad

Methods

(>>=) :: Z3 a -> (a -> Z3 b) -> Z3 b #

(>>) :: Z3 a -> Z3 b -> Z3 b #

return :: a -> Z3 a #

Functor Z3 Source # 
Instance details

Defined in Z3.Monad

Methods

fmap :: (a -> b) -> Z3 a -> Z3 b #

(<$) :: a -> Z3 b -> Z3 a #

MonadFix Z3 Source # 
Instance details

Defined in Z3.Monad

Methods

mfix :: (a -> Z3 a) -> Z3 a #

MonadFail Z3 Source # 
Instance details

Defined in Z3.Monad

Methods

fail :: String -> Z3 a #

Applicative Z3 Source # 
Instance details

Defined in Z3.Monad

Methods

pure :: a -> Z3 a #

(<*>) :: Z3 (a -> b) -> Z3 a -> Z3 b #

liftA2 :: (a -> b -> c) -> Z3 a -> Z3 b -> Z3 c #

(*>) :: Z3 a -> Z3 b -> Z3 b #

(<*) :: Z3 a -> Z3 b -> Z3 a #

MonadIO Z3 Source # 
Instance details

Defined in Z3.Monad

Methods

liftIO :: IO a -> Z3 a #

MonadZ3 Z3 Source # 
Instance details

Defined in Z3.Monad

module Z3.Opts

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 #

evalZ3 :: Z3 a -> IO a Source #

Eval a Z3 script with default configuration options.

evalZ3With :: Maybe Logic -> Opts -> Z3 a -> IO a Source #

Eval a Z3 script.

Z3 enviroments

data Z3Env Source #

Z3 environment.

newEnv :: Maybe Logic -> Opts -> IO Z3Env Source #

Create a new Z3 environment.

evalZ3WithEnv :: Z3 a -> Z3Env -> IO a Source #

Eval a Z3 script with a given environment.

Environments may facilitate running many queries under the same logical context.

Note that an environment may change after each query. If you want to preserve the same environment then use local, as in evalZ3WithEnv env (local query).

Types

data Symbol Source #

A Z3 symbol.

Used to name types, constants and functions.

Instances

Instances details
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

Show Symbol Source # 
Instance details

Defined in Z3.Base

Storable 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
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 #

Show AST Source # 
Instance details

Defined in Z3.Base

Methods

showsPrec :: Int -> AST -> ShowS #

show :: AST -> String #

showList :: [AST] -> ShowS #

data Sort Source #

A kind of AST representing types.

Instances

Instances details
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 #

Show Sort Source # 
Instance details

Defined in Z3.Base

Methods

showsPrec :: Int -> Sort -> ShowS #

show :: Sort -> String #

showList :: [Sort] -> ShowS #

data FuncDecl Source #

A kind of AST representing function symbols.

Instances

Instances details
Eq FuncDecl Source # 
Instance details

Defined in Z3.Base

Ord FuncDecl Source # 
Instance details

Defined in Z3.Base

Show FuncDecl Source # 
Instance details

Defined in Z3.Base

data App Source #

A kind of AST representing constant and function declarations.

Instances

Instances details
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 #

Show App Source # 
Instance details

Defined in Z3.Base

Methods

showsPrec :: Int -> App -> ShowS #

show :: App -> String #

showList :: [App] -> ShowS #

data Pattern Source #

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

Instances

Instances details
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

Show 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 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 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
Eq ASTKind Source # 
Instance details

Defined in Z3.Base

Methods

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

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

Show ASTKind Source # 
Instance details

Defined in Z3.Base

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

Read Result Source # 
Instance details

Defined in Z3.Base

Show Result Source # 
Instance details

Defined in Z3.Base

Parameters

mkParams :: MonadZ3 z3 => z3 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 :: MonadZ3 z3 => Params -> Symbol -> Bool -> z3 () Source #

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

paramsSetUInt :: MonadZ3 z3 => Params -> Symbol -> Word -> z3 () Source #

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

paramsSetDouble :: MonadZ3 z3 => Params -> Symbol -> Double -> z3 () Source #

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

paramsSetSymbol :: MonadZ3 z3 => Params -> Symbol -> Symbol -> z3 () Source #

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

paramsToString :: MonadZ3 z3 => Params -> z3 String Source #

Convert a parameter set into a string.

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

Symbols

mkIntSymbol :: (MonadZ3 z3, Integral i) => i -> z3 Symbol Source #

Create a Z3 symbol using an integer.

Sorts

mkBvSort :: MonadZ3 z3 => Int -> z3 Sort Source #

Create a bit-vector type of the given size.

This type can also be seen as a machine integer.

Reference: http://research.microsoft.com/en-us/um/redmond/projects/z3/group__capi.html#gaeed000a1bbb84b6ca6fdaac6cf0c1688

mkFiniteDomainSort :: MonadZ3 z3 => Symbol -> Word64 -> z3 Sort Source #

Create a finite-domain type.

mkTupleSort Source #

Arguments

:: MonadZ3 z3 
=> Symbol

Name of the sort

-> [(Symbol, Sort)]

Name and sort of each field

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

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

mkConstructor Source #

Arguments

:: MonadZ3 z3 
=> Symbol

Name of the sonstructor

-> Symbol

Name of recognizer function

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

Name, sort option, and sortRefs

-> z3 Constructor 

mkDatatype :: MonadZ3 z3 => Symbol -> [Constructor] -> z3 Sort Source #

Create datatype, such as lists, trees, records, enumerations or unions of records. The datatype may be recursive. Return the datatype sort.

Reference http://research.microsoft.com/en-us/um/redmond/projects/z3/group__capi.html#gab6809d53327d807da9158abdf75df387

mkDatatypes :: MonadZ3 z3 => [Symbol] -> [[Constructor]] -> z3 [Sort] Source #

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

Returns the datatype sorts

Constants and Applications

mkFuncDecl :: MonadZ3 z3 => Symbol -> [Sort] -> Sort -> z3 FuncDecl Source #

A Z3 function

Helpers

mkVar :: MonadZ3 z3 => Symbol -> Sort -> z3 AST Source #

Declare and create a variable (aka constant).

An alias for mkConst.

mkBoolVar :: MonadZ3 z3 => Symbol -> z3 AST Source #

Declarate and create a variable of sort bool.

See mkVar.

mkRealVar :: MonadZ3 z3 => Symbol -> z3 AST Source #

Declarate and create a variable of sort real.

See mkVar.

mkIntVar :: MonadZ3 z3 => Symbol -> z3 AST Source #

Declarate and create a variable of sort int.

See mkVar.

mkBvVar Source #

Arguments

:: MonadZ3 z3 
=> Symbol 
-> Int

bit-width

-> z3 AST 

Declarate and create a variable of sort bit-vector.

See mkVar.

mkFreshVar :: MonadZ3 z3 => String -> Sort -> z3 AST Source #

Declare and create a fresh variable (aka constant).

An alias for mkFreshConst.

mkFreshBoolVar :: MonadZ3 z3 => String -> z3 AST Source #

Declarate and create a fresh variable of sort bool.

See mkFreshVar.

mkFreshRealVar :: MonadZ3 z3 => String -> z3 AST Source #

Declarate and create a fresh variable of sort real.

See mkFreshVar.

mkFreshIntVar :: MonadZ3 z3 => String -> z3 AST Source #

Declarate and create a fresh variable of sort int.

See mkFreshVar.

mkFreshBvVar Source #

Arguments

:: MonadZ3 z3 
=> String 
-> Int

bit-width

-> z3 AST 

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

See mkFreshVar.

Propositional Logic and Equality

mkIte :: MonadZ3 z3 => AST -> AST -> AST -> z3 AST Source #

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

Reference: http://research.microsoft.com/en-us/um/redmond/projects/z3/group__capi.html#ga94417eed5c36e1ad48bcfc8ad6e83547

mkAnd :: MonadZ3 z3 => [AST] -> z3 AST Source #

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

Reference: http://research.microsoft.com/en-us/um/redmond/projects/z3/group__capi.html#gacde98ce4a8ed1dde50b9669db4838c61

mkOr :: MonadZ3 z3 => [AST] -> z3 AST Source #

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

Reference: http://research.microsoft.com/en-us/um/redmond/projects/z3/group__capi.html#ga00866d16331d505620a6c515302021f9

mkDistinct :: MonadZ3 z3 => [AST] -> z3 AST Source #

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

Reference: http://research.microsoft.com/en-us/um/redmond/projects/z3/group__capi.html#gaa076d3a668e0ec97d61744403153ecf7

Helpers

mkBool :: MonadZ3 z3 => Bool -> z3 AST Source #

Create an AST node representing the given boolean.

Arithmetic: Integers and Reals

mkAdd :: MonadZ3 z3 => [AST] -> z3 AST Source #

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

Reference: http://research.microsoft.com/en-us/um/redmond/projects/z3/group__capi.html#ga4e4ac0a4e53eee0b4b0ef159ed7d0cd5

mkMul :: MonadZ3 z3 => [AST] -> z3 AST Source #

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

Reference: http://research.microsoft.com/en-us/um/redmond/projects/z3/group__capi.html#gab9affbf8401a18eea474b59ad4adc890

mkSub :: MonadZ3 z3 => NonEmpty AST -> z3 AST Source #

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

Requires a non-empty list.

Reference: http://research.microsoft.com/en-us/um/redmond/projects/z3/group__capi.html#ga4f5fea9b683f9e674fd8f14d676cc9a9

Bit-vectors

mkBvredor :: MonadZ3 z3 => AST -> z3 AST Source #

mkExtract :: MonadZ3 z3 => Int -> Int -> AST -> z3 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.

Reference: http://research.microsoft.com/en-us/um/redmond/projects/z3/group__capi.html#ga32d2fe7563f3e6b114c1b97b205d4317

mkSignExt :: MonadZ3 z3 => Int -> AST -> z3 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.

Reference: http://research.microsoft.com/en-us/um/redmond/projects/z3/group__capi.html#gad29099270b36d0680bb54b560353c10e

mkZeroExt :: MonadZ3 z3 => Int -> AST -> z3 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.

Reference: http://research.microsoft.com/en-us/um/redmond/projects/z3/group__capi.html#gac9322fae11365a78640baf9078c428b3

mkBv2int :: MonadZ3 z3 => AST -> Bool -> z3 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.

Reference: http://research.microsoft.com/en-us/um/redmond/projects/z3/group__capi.html#gac87b227dc3821d57258d7f53a28323d4

mkBvnegNoOverflow :: MonadZ3 z3 => AST -> z3 AST Source #

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

Reference: http://research.microsoft.com/en-us/um/redmond/projects/z3/group__capi.html#gae9c5d72605ddcd0e76657341eaccb6c7

mkBvaddNoOverflow :: MonadZ3 z3 => AST -> AST -> Bool -> z3 AST Source #

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

Reference: http://research.microsoft.com/en-us/um/redmond/projects/z3/group__capi.html#ga88f6b5ec876f05e0d7ba51e96c4b077f

mkBvaddNoUnderflow :: MonadZ3 z3 => AST -> AST -> z3 AST Source #

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

Reference: http://research.microsoft.com/en-us/um/redmond/projects/z3/group__capi.html#ga1e2b1927cf4e50000c1600d47a152947

mkBvsubNoOverflow :: MonadZ3 z3 => AST -> AST -> z3 AST Source #

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

Reference: http://research.microsoft.com/en-us/um/redmond/projects/z3/group__capi.html#ga785f8127b87e0b42130e6d8f52167d7c

mkBvsubNoUnderflow :: MonadZ3 z3 => AST -> AST -> z3 AST Source #

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

Reference: http://research.microsoft.com/en-us/um/redmond/projects/z3/group__capi.html#ga6480850f9fa01e14aea936c88ff184c4

mkBvmulNoOverflow :: MonadZ3 z3 => AST -> AST -> Bool -> z3 AST Source #

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

Reference: http://research.microsoft.com/en-us/um/redmond/projects/z3/group__capi.html#ga86f4415719d295a2f6845c70b3aaa1df

mkBvmulNoUnderflow :: MonadZ3 z3 => AST -> AST -> z3 AST Source #

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

Reference: http://research.microsoft.com/en-us/um/redmond/projects/z3/group__capi.html#ga501ccc01d737aad3ede5699741717fda

mkBvsdivNoOverflow :: MonadZ3 z3 => AST -> AST -> z3 AST Source #

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

Reference: http://research.microsoft.com/en-us/um/redmond/projects/z3/group__capi.html#gaa17e7b2c33dfe2abbd74d390927ae83e

Arrays

mkSelect :: MonadZ3 z3 => AST -> AST -> z3 AST Source #

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

Reference: http://research.microsoft.com/en-us/um/redmond/projects/z3/group__capi.html#ga38f423f3683379e7f597a7fe59eccb67

mkArrayDefault :: MonadZ3 z3 => AST -> z3 AST Source #

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

Reference: http://research.microsoft.com/en-us/um/redmond/projects/z3/group__capi.html#ga78e89cca82f0ab4d5f4e662e5e5fba7d

Sets

Numerals

mkInt :: MonadZ3 z3 => Int -> Sort -> z3 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.

mkReal :: MonadZ3 z3 => Int -> Int -> z3 AST Source #

Create a numeral of sort real.

mkUnsignedInt :: MonadZ3 z3 => Word -> Sort -> z3 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 :: MonadZ3 z3 => Int64 -> Sort -> z3 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 :: MonadZ3 z3 => Word64 -> Sort -> z3 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 :: (MonadZ3 z3, Integral a) => a -> Sort -> z3 AST Source #

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

mkRational :: MonadZ3 z3 => Rational -> z3 AST Source #

Create a numeral of sort real from a Rational.

mkFixed :: (MonadZ3 z3, HasResolution a) => Fixed a -> z3 AST Source #

Create a numeral of sort real from a Fixed.

mkRealNum :: (MonadZ3 z3, Real r) => r -> z3 AST Source #

Create a numeral of sort real from a Real.

mkInteger :: MonadZ3 z3 => Integer -> z3 AST Source #

Create a numeral of sort int from an Integer.

mkIntNum :: (MonadZ3 z3, Integral a) => a -> z3 AST Source #

Create a numeral of sort int from an Integral.

mkBitvector Source #

Arguments

:: MonadZ3 z3 
=> Int

bit-width

-> Integer

integer value

-> z3 AST 

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

mkBvNum Source #

Arguments

:: (MonadZ3 z3, Integral i) 
=> Int

bit-width

-> i

integer value

-> z3 AST 

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

Quantifiers

mkBound :: MonadZ3 z3 => Int -> Sort -> z3 AST Source #

mkForall :: MonadZ3 z3 => [Pattern] -> [Symbol] -> [Sort] -> AST -> z3 AST Source #

mkExists :: MonadZ3 z3 => [Pattern] -> [Symbol] -> [Sort] -> AST -> z3 AST Source #

mkForallConst :: MonadZ3 z3 => [Pattern] -> [App] -> AST -> z3 AST Source #

mkExistsConst :: MonadZ3 z3 => [Pattern] -> [App] -> AST -> z3 AST Source #

Accessors

getDatatypeSortConstructors Source #

Arguments

:: MonadZ3 z3 
=> Sort

Datatype sort.

-> z3 [FuncDecl]

Constructor declarations.

Get list of constructors for datatype.

getDatatypeSortRecognizers Source #

Arguments

:: MonadZ3 z3 
=> Sort

Datatype sort.

-> z3 [FuncDecl]

Constructor recognizers.

Get list of recognizers for datatype.

getDatatypeSortConstructorAccessors Source #

Arguments

:: MonadZ3 z3 
=> Sort

Datatype sort.

-> z3 [[FuncDecl]]

Constructor recognizers.

Get list of accessors for datatype.

getArity :: MonadZ3 z3 => FuncDecl -> z3 Int Source #

Returns the number of parameters of the given declaration

getDomain Source #

Arguments

:: MonadZ3 z3 
=> FuncDecl

A function declaration

-> Int

i

-> z3 Sort 

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

getRange :: MonadZ3 z3 => FuncDecl -> z3 Sort Source #

Returns the range of the given declaration.

appToAst :: MonadZ3 z3 => App -> z3 AST Source #

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

getAppDecl :: MonadZ3 z3 => App -> z3 FuncDecl Source #

Return the declaration of a constant or function application.

getAppNumArgs :: MonadZ3 z3 => App -> z3 Int Source #

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

getAppArg :: MonadZ3 z3 => App -> Int -> z3 AST Source #

Return the i-th argument of the given application.

getAppArgs :: MonadZ3 z3 => App -> z3 [AST] Source #

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

getSort :: MonadZ3 z3 => AST -> z3 Sort Source #

Return the sort of an AST node.

isApp :: MonadZ3 z3 => AST -> z3 Bool Source #

Return True if an ast is APP_AST, False otherwise.

toApp :: MonadZ3 z3 => AST -> z3 App Source #

Cast AST into an App.

getNumeralString :: MonadZ3 z3 => AST -> z3 String Source #

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

Helpers

getBool :: MonadZ3 z3 => AST -> z3 Bool Source #

Read a Bool value from an AST

getInt :: MonadZ3 z3 => AST -> z3 Integer Source #

Return the integer value

getReal :: MonadZ3 z3 => AST -> z3 Rational Source #

Return rational value

getBv Source #

Arguments

:: MonadZ3 z3 
=> AST 
-> Bool

signed?

-> z3 Integer 

Read the Integer value from an AST of sort bit-vector.

See mkBv2int.

Modifiers

substituteVars :: MonadZ3 z3 => AST -> [AST] -> z3 AST Source #

Models

modelEval Source #

Arguments

:: MonadZ3 z3 
=> Model 
-> AST 
-> Bool

Model completion?

-> z3 (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 :: MonadZ3 z3 => Model -> AST -> z3 (Maybe FuncModel) Source #

Get array as a list of argument/value pairs, if it is represented as a function (ie, using as-array).

getFuncInterp :: MonadZ3 z3 => Model -> FuncDecl -> z3 (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.

Reference: http://research.microsoft.com/en-us/um/redmond/projects/z3/group__capi.html#gafb9cc5eca9564d8a849c154c5a4a8633

isAsArray :: MonadZ3 z3 => AST -> z3 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.

Reference: http://research.microsoft.com/en-us/um/redmond/projects/z3/group__capi.html#ga4674da67d226bfb16861829b9f129cfa

addConstInterp :: MonadZ3 z3 => Model -> FuncDecl -> AST -> z3 () Source #

getAsArrayFuncDecl :: MonadZ3 z3 => AST -> z3 FuncDecl Source #

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

Reference: http://research.microsoft.com/en-us/um/redmond/projects/z3/group__capi.html#ga7d9262dc6e79f2aeb23fd4a383589dda

funcInterpGetEntry :: MonadZ3 z3 => FuncInterp -> Int -> z3 FuncEntry Source #

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

Reference: http://research.microsoft.com/en-us/um/redmond/projects/z3/group__capi.html#gaf157e1e1cd8c0cfe6a21be6370f659da

funcInterpGetArity :: MonadZ3 z3 => FuncInterp -> z3 Int Source #

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

Reference: http://research.microsoft.com/en-us/um/redmond/projects/z3/group__capi.html#gaca22cbdb6f7787aaae5d814f2ab383d8

modelToString :: MonadZ3 z3 => Model -> z3 String Source #

Convert the given model into a string.

Helpers

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

Type of an evaluation function for AST.

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

eval :: MonadZ3 z3 => EvalAst z3 AST Source #

An alias for modelEval with model completion enabled.

evalBool :: MonadZ3 z3 => EvalAst z3 Bool Source #

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

See modelEval and getBool.

evalInt :: MonadZ3 z3 => EvalAst z3 Integer Source #

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

See modelEval and getInt.

evalReal :: MonadZ3 z3 => EvalAst z3 Rational Source #

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

See modelEval and getReal.

evalBv Source #

Arguments

:: MonadZ3 z3 
=> Bool

signed?

-> EvalAst z3 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 getBv.

evalT :: (MonadZ3 z3, Traversable t) => Model -> t AST -> z3 (Maybe (t AST)) Source #

Evaluate a collection of AST nodes in the given model.

mapEval :: (MonadZ3 z3, Traversable t) => EvalAst z3 a -> Model -> t AST -> z3 (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 can be used to obtain the Integer interpretation of a list of AST of sort int.

data FuncModel Source #

The interpretation of a function.

Constructors

FuncModel 

Fields

evalFunc :: MonadZ3 z3 => Model -> FuncDecl -> z3 (Maybe FuncModel) Source #

Get function as a list of argument/value pairs.

Tactics

mkGoal :: MonadZ3 z3 => Bool -> Bool -> Bool -> z3 Goal Source #

goalAssert :: MonadZ3 z3 => Goal -> AST -> z3 () Source #

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 :: MonadZ3 z3 => ASTPrintMode -> z3 () Source #

Set the mode for converting expressions to strings.

astToString :: MonadZ3 z3 => AST -> z3 String Source #

Convert an AST to a string.

patternToString :: MonadZ3 z3 => Pattern -> z3 String Source #

Convert a pattern to a string.

sortToString :: MonadZ3 z3 => Sort -> z3 String Source #

Convert a sort to a string.

funcDeclToString :: MonadZ3 z3 => FuncDecl -> z3 String Source #

Convert a FuncDecl to a string.

benchmarkToSMTLibString Source #

Arguments

:: MonadZ3 z3 
=> String

name

-> String

logic

-> String

status

-> String

attributes

-> [AST]

assumptions1

-> AST

formula

-> z3 String 

Convert the given benchmark into SMT-LIB formatted string.

The output format can be configured via setASTPrintMode.

Parser interface

parseSMTLib2String Source #

Arguments

:: MonadZ3 z3 
=> String

string to parse

-> [Symbol]

sort names

-> [Sort]

sorts

-> [Symbol]

declaration names

-> [FuncDecl]

declarations

-> z3 AST 

Parse SMT expressions from a string

The sort and declaration arguments allow parsing in a context in which variables and functions have already been declared. They are almost never used.

parseSMTLib2File Source #

Arguments

:: MonadZ3 z3 
=> String

string to parse

-> [Symbol]

sort names

-> [Sort]

sorts

-> [Symbol]

declaration names

-> [FuncDecl]

declarations

-> z3 AST 

Parse SMT expressions from a file

The sort and declaration arguments allow parsing in a context in which variables and functions have already been declared. They are almost never used.

Error Handling

data Z3Error Source #

Z3 exceptions.

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

Constructors

Z3Error 

Instances

Instances details
Show Z3Error Source # 
Instance details

Defined in Z3.Base

Exception Z3Error Source # 
Instance details

Defined in Z3.Base

Miscellaneous

data Version Source #

Constructors

Version 

Fields

Instances

Instances details
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

Show Version Source # 
Instance details

Defined in Z3.Base

getVersion :: MonadZ3 z3 => z3 Version Source #

Return Z3 version number information.

Fixedpoint

data Fixedpoint Source #

Instances

Instances details
Eq Fixedpoint Source # 
Instance details

Defined in Z3.Base

fixedpointAddRule :: MonadFixedpoint z3 => AST -> Symbol -> z3 () Source #

fixedpointSetParams :: MonadFixedpoint z3 => Params -> z3 () Source #

fixedpointRegisterRelation :: MonadFixedpoint z3 => FuncDecl -> z3 () Source #

fixedpointQueryRelations :: MonadFixedpoint z3 => [FuncDecl] -> z3 Result Source #

fixedpointGetAnswer :: MonadFixedpoint z3 => z3 AST Source #

fixedpointGetAssertions :: MonadFixedpoint z3 => z3 [AST] Source #

Solvers

solverGetHelp :: MonadZ3 z3 => z3 String Source #

Return a string describing all solver available parameters.

solverSetParams :: MonadZ3 z3 => Params -> z3 () Source #

Set the solver using the given parameters.

solverPush :: MonadZ3 z3 => z3 () Source #

Create a backtracking point.

solverPop :: MonadZ3 z3 => Int -> z3 () Source #

Backtrack n backtracking points.

solverReset :: MonadZ3 z3 => z3 () Source #

solverGetNumScopes :: MonadZ3 z3 => z3 Int Source #

Number of backtracking points.

solverAssertAndTrack :: MonadZ3 z3 => AST -> AST -> z3 () Source #

Assert a constraint a into the solver, and track it (in the unsat) core using the Boolean constant p.

This API is an alternative to Z3_solver_check_assumptions for extracting unsat cores. Both APIs can be used in the same solver. The unsat core will contain a combination of the Boolean variables provided using Z3_solver_assert_and_track and the Boolean literals provided using Z3_solver_check_assumptions.

solverCheck :: MonadZ3 z3 => z3 Result Source #

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

solverCheckAssumptions :: MonadZ3 z3 => [AST] -> z3 Result Source #

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

solverGetModel :: MonadZ3 z3 => z3 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.

solverGetUnsatCore :: MonadZ3 z3 => z3 [AST] Source #

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

solverGetReasonUnknown :: MonadZ3 z3 => z3 String Source #

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

solverToString :: MonadZ3 z3 => z3 String Source #

Convert the given solver into a string.

Helpers

assert :: MonadZ3 z3 => AST -> z3 () Source #

check :: MonadZ3 z3 => z3 Result Source #

Check whether the given logical context is consistent or not.

checkAssumptions :: MonadZ3 z3 => [AST] -> z3 Result Source #

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

withModel :: (Applicative z3, MonadZ3 z3) => (Model -> z3 a) -> z3 (Result, Maybe a) Source #

Check satisfiability and, if sat, compute a value from the given model.

E.g. withModel $ \m -> fromJust <$> evalInt m x

getUnsatCore :: MonadZ3 z3 => z3 [AST] Source #

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

push :: MonadZ3 z3 => z3 () Source #

Create a backtracking point.

For push; m; pop 1 see local.

pop :: MonadZ3 z3 => Int -> z3 () Source #

Backtrack n backtracking points.

Contrary to solverPop this funtion checks whether n is within the size of the solver scope stack.

local :: MonadZ3 z3 => z3 a -> z3 a Source #

Run a query and restore the initial logical context.

This is a shorthand for push, run the query, and pop.

reset :: MonadZ3 z3 => z3 () Source #

Backtrack all the way.

getNumScopes :: MonadZ3 z3 => z3 Int Source #

Get number of backtracking points.