z3-408.2: 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 HaskellSafe-Inferred
LanguageHaskell2010

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

MonadZ3 m => MonadZ3 (ExceptT e m) Source # 
Instance details

Defined in Z3.Monad

MonadZ3 m => MonadZ3 (ReaderT r m) Source # 
Instance details

Defined in Z3.Monad

MonadZ3 m => MonadZ3 (StateT s m) Source # 
Instance details

Defined in Z3.Monad

MonadZ3 m => MonadZ3 (StateT s m) Source # 
Instance details

Defined in Z3.Monad

data Z3 a Source #

Instances

Instances details
MonadFail Z3 Source # 
Instance details

Defined in Z3.Monad

Methods

fail :: String -> Z3 a #

MonadFix Z3 Source # 
Instance details

Defined in Z3.Monad

Methods

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

MonadIO Z3 Source # 
Instance details

Defined in Z3.Monad

Methods

liftIO :: IO a -> 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 #

Functor Z3 Source # 
Instance details

Defined in Z3.Monad

Methods

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

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

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 #

MonadFixedpoint Z3 Source # 
Instance details

Defined in Z3.Monad

MonadOptimize Z3 Source # 
Instance details

Defined in Z3.Monad

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

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

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 constructor

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

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

A recursive Z3 function

addRecDef :: MonadZ3 z3 => FuncDecl -> [AST] -> AST -> z3 () Source #

Define the body of a recursive 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.

Requires a non-empty list.

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

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

Same as mkDistinct but type-safe.

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

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

Same as mkSub but type-safe.

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

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.

Sequences and regular expressions

mkSeqSort :: MonadZ3 z3 => Sort -> z3 Sort Source #

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

isSeqSort :: MonadZ3 z3 => Sort -> z3 Bool Source #

Check if s is a sequence sort.

mkReSort :: MonadZ3 z3 => Sort -> z3 Sort Source #

Create a regular expression sort out of a sequence sort.

isReSort :: MonadZ3 z3 => Sort -> z3 Bool Source #

Check if s is a regular expression sort.

mkStringSort :: MonadZ3 z3 => z3 Sort Source #

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

isStringSort :: MonadZ3 z3 => Sort -> z3 Bool Source #

Check if s is a string sort.

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

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

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

Determine if s is a string constant.

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

Retrieve the string constant stored in s.

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

Create an empty sequence of the sequence sort seq.

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

Create a unit sequence of a.

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

Concatenate sequences.

mkSeqPrefix Source #

Arguments

:: MonadZ3 z3 
=> AST

prefix

-> AST

s

-> z3 AST 

Check if prefix is a prefix of s.

mkSeqSuffix Source #

Arguments

:: MonadZ3 z3 
=> AST

suffix

-> AST

s

-> z3 AST 

Check if suffix is a suffix of s.

mkSeqContains Source #

Arguments

:: MonadZ3 z3 
=> AST

container

-> AST

containee

-> z3 AST 

Check if container contains containee.

mkStrLt Source #

Arguments

:: MonadZ3 z3 
=> AST

s1

-> AST

s2

-> z3 AST 

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

mkStrLe Source #

Arguments

:: MonadZ3 z3 
=> AST

s1

-> AST

s2

-> z3 AST 

Check if s1 is lexicographically strictly less than s2.

mkSeqExtract Source #

Arguments

:: MonadZ3 z3 
=> AST

s

-> AST

offset

-> AST

length

-> z3 AST 

Extract subsequence starting at offset of length.

mkSeqReplace Source #

Arguments

:: MonadZ3 z3 
=> AST

s

-> AST

src

-> AST

dst

-> z3 AST 

Replace the first occurrence of src with dst in s.

mkSeqAt Source #

Arguments

:: MonadZ3 z3 
=> AST

s

-> AST

index

-> z3 AST 

Retrieve from s the unit sequence positioned at position index.

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

Return the length of the sequence s.

mkSeqIndex Source #

Arguments

:: MonadZ3 z3 
=> AST

s

-> AST

substr

-> AST

offset

-> z3 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 :: MonadZ3 z3 => AST -> z3 AST Source #

Convert string to integer.

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

Integer to string conversion.

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

Create a regular expression that accepts the sequence.

mkSeqInRe Source #

Arguments

:: MonadZ3 z3 
=> AST

seq

-> AST

re

-> z3 AST 

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

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

Create the regular language re+.

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

Create the regular language re*.

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

Create the regular language [re].

mkReUnion :: (Integral int, MonadZ3 z3) => int -> [AST] -> z3 AST Source #

Create the union of the regular languages.

mkReConcat :: (Integral int, MonadZ3 z3) => int -> [AST] -> z3 AST Source #

Create the concatenation of the regular languages.

mkReRange Source #

Arguments

:: MonadZ3 z3 
=> AST

lo

-> AST

hi

-> z3 AST 

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

mkReLoop Source #

Arguments

:: (Integral int, MonadZ3 z3) 
=> AST

r

-> int

lo

-> int

hi

-> z3 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, MonadZ3 z3) => int -> [AST] -> z3 AST Source #

Create the intersection of the regular languages.

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

Create the complement of the regular language.

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

Create an empty regular expression of sort re.

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

Create an universal regular expression of sort re.

Quantifiers

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

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

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

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

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

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

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

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

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

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

Accessors

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

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

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

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

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.

mkAtMost :: MonadZ3 z3 => [AST] -> Int -> z3 AST Source #

At most k of the arguments ps may be true, i.e. encode p1 + p2 + ... + pn <= k.

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

mkAtLeast :: MonadZ3 z3 => [AST] -> Int -> z3 AST Source #

At least k of the arguments ps may be true, i.e. encode p1 + p2 + ... + pn >= k.

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

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.

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

Modifiers

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

substitute :: MonadZ3 z3 => AST -> [(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

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

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

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.

evalSMTLib2String Source #

Arguments

:: MonadZ3 z3 
=> String

string to parse

-> z3 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 :: MonadZ3 z3 => z3 Version Source #

Return Z3 version number information.

Fixedpoint

class MonadZ3 m => MonadFixedpoint m where Source #

Instances

Instances details
MonadFixedpoint Z3 Source # 
Instance details

Defined in Z3.Monad

data Fixedpoint Source #

Instances

Instances details
Eq Fixedpoint Source # 
Instance details

Defined in Z3.Base

Floating-Point Arithmetic

mkFpaRoundingModeSort :: MonadZ3 z3 => z3 Sort Source #

Create the RoundingMode sort.

mkFpaRoundNearestTiesToEven :: MonadZ3 z3 => z3 AST Source #

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

mkFpaRne :: MonadZ3 z3 => z3 AST Source #

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

mkFpaRoundNearestTiesToAway :: MonadZ3 z3 => z3 AST Source #

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

mkFpaRna :: MonadZ3 z3 => z3 AST Source #

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

mkFpaRoundTowardPositive :: MonadZ3 z3 => z3 AST Source #

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

mkFpaRtp :: MonadZ3 z3 => z3 AST Source #

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

mkFpaRoundTowardNegative :: MonadZ3 z3 => z3 AST Source #

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

mkFpaRtn :: MonadZ3 z3 => z3 AST Source #

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

mkFpaRoundTowardZero :: MonadZ3 z3 => z3 AST Source #

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

mkFpaRtz :: MonadZ3 z3 => z3 AST Source #

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

mkFpaSort Source #

Arguments

:: (MonadZ3 z3, Integral int) 
=> int

Number of exponent bits

-> int

Number of significand bits

-> z3 Sort 

Create a FloatingPoint sort.

mkFpaSortHalf :: MonadZ3 z3 => z3 Sort Source #

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

mkFpaSort16 :: MonadZ3 z3 => z3 Sort Source #

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

mkFpaSortSingle :: MonadZ3 z3 => z3 Sort Source #

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

mkFpaSort32 :: MonadZ3 z3 => z3 Sort Source #

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

mkFpaSortDouble :: MonadZ3 z3 => z3 Sort Source #

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

mkFpaSort64 :: MonadZ3 z3 => z3 Sort Source #

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

mkFpaSortQuadruple :: MonadZ3 z3 => z3 Sort Source #

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

mkFpaSort128 :: MonadZ3 z3 => z3 Sort Source #

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

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

Create a floating-point NaN of sort s.

mkFpaInf Source #

Arguments

:: MonadZ3 z3 
=> Sort

Target sort

-> Bool

Indicates whether the result should be negative

-> z3 AST 

Create a floating-point infinity of sort s.

mkFpaZero Source #

Arguments

:: MonadZ3 z3 
=> Sort

Target sort

-> Bool

Indicates whether the result should be negative

-> z3 AST 

Create a floating-point zero of sort s.

mkFpaFp Source #

Arguments

:: MonadZ3 z3 
=> AST

Sign

-> AST

Exponent

-> AST

Significand

-> z3 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 :: MonadZ3 z3 => Float -> Sort -> z3 AST Source #

Create a numeral of FloatingPoint sort from a float.

mkFpaNumeralDouble :: MonadZ3 z3 => Double -> Sort -> z3 AST Source #

Create a numeral of FloatingPoint sort from a double.

mkFpaNumeralInt :: (MonadZ3 z3, Integral int) => int -> Sort -> z3 AST Source #

Create a numeral of FloatingPoint sort from a signed integer.

mkFpaNumeralIntUInt Source #

Arguments

:: (MonadZ3 z3, Integral int) 
=> Bool

Sign bit (true == negative)

-> int

Significand

-> int

Exponent

-> Sort

Result sort

-> z3 AST 

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

mkFpaNumeralInt64UInt64 Source #

Arguments

:: (MonadZ3 z3, Integral int) 
=> Bool

Sign bit (true == negative)

-> int

Significand

-> int

Exponent

-> Sort

Result sort

-> z3 AST 

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

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

Floating-point absolute value.

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

Floating-point negation.

mkFpaAdd Source #

Arguments

:: MonadZ3 z3 
=> AST

Rounding Mode

-> AST

FloatingPoint sort term

-> AST

FloatingPoint sort term

-> z3 AST 

Floating-point addition.

mkFpaSub Source #

Arguments

:: MonadZ3 z3 
=> AST

Rounding Mode

-> AST

FloatingPoint sort term

-> AST

FloatingPoint sort term

-> z3 AST 

Floating-point subtraction.

mkFpaMul Source #

Arguments

:: MonadZ3 z3 
=> AST

Rounding Mode

-> AST

FloatingPoint sort term

-> AST

FloatingPoint sort term

-> z3 AST 

Floating-point multiplication.

mkFpaDiv Source #

Arguments

:: MonadZ3 z3 
=> AST

Rounding Mode

-> AST

FloatingPoint sort term

-> AST

FloatingPoint sort term

-> z3 AST 

Floating-point division.

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

Floating-point fused multiply-add.

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

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

Floating-point square root.

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

Floating-point remainder.

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

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

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

Minimum of floating-point numbers.

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

Maximum of floating-point numbers.

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

Floating-point less than or equal.

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

Floating-point less than.

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

Floating-point greater than or equal.

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

Floating-point greater than.

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

Floating-point equality.

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

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

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

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

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

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

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

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

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

Predicate indicating whether t is NaN.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

mkFpaToUbv :: (MonadZ3 z3, Integral int) => AST -> AST -> int -> z3 AST Source #

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

mkFpaToSbv :: (MonadZ3 z3, Integral int) => AST -> AST -> int -> z3 AST Source #

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

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

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

Z3-specific floating-point extensions

fpaGetEbits :: (MonadZ3 z3, Integral int) => Sort -> z3 int Source #

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

fpaGetSbits :: (MonadZ3 z3, Integral int) => Sort -> z3 int Source #

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

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

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

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

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

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

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

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

Checks whether a given floating-point numeral is normal.

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

Checks whether a given floating-point numeral is subnormal.

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

Checks whether a given floating-point numeral is positive.

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

Checks whether a given floating-point numeral is negative.

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

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

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

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

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

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

fpaGetNumeralExponentString :: MonadZ3 z3 => AST -> Bool -> z3 String Source #

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

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

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

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

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

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

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

Optimization

class MonadZ3 m => MonadOptimize m where Source #

Instances

Instances details
MonadOptimize Z3 Source # 
Instance details

Defined in Z3.Monad

data Optimize Source #

Instances

Instances details
Eq Optimize Source # 
Instance details

Defined in Z3.Base

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.

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

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

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

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

solverGetModel :: MonadZ3 z3 => z3 Model Source #

Retrieve the model for the last solverCheck or solverCheckAssumptions.

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.

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

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

Alias for solverCheck

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

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

Alias for solverCheckAssumptions

solverCheckAndGetModel :: MonadZ3 z3 => z3 (Result, Maybe Model) Source #

Call solverCheck and based on the result also call solverGetModel.

getModel :: MonadZ3 z3 => z3 (Result, Maybe Model) Source #

Check and get model.

Alias for solverCheckAndGetModel

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.

Alias for solverGetUnsatCore

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

Create a backtracking point.

For push; m; pop 1 see local.

Alias for solverPush

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.

Alias for solverReset

getNumScopes :: MonadZ3 z3 => z3 Int Source #

Get number of backtracking points.