| Home | • | Docs | • | Download | • | • | FAQ | • | Awards | • | Status | • | MSR |
|---|
An Efficient SMT Solver
module Z3: sig end
| |
L_FALSE |
| |
L_UNDEF |
| |
L_TRUE |
| |
INT_SYMBOL |
| |
STRING_SYMBOL |
| |
PARAMETER_INT |
| |
PARAMETER_DOUBLE |
| |
PARAMETER_RATIONAL |
| |
PARAMETER_SYMBOL |
| |
PARAMETER_SORT |
| |
PARAMETER_AST |
| |
PARAMETER_FUNC_DECL |
| |
UNINTERPRETED_SORT |
| |
BOOL_SORT |
| |
INT_SORT |
| |
REAL_SORT |
| |
BV_SORT |
| |
ARRAY_SORT |
| |
DATATYPE_SORT |
| |
UNKNOWN_SORT |
| |
NUMERAL_AST |
| |
APP_AST |
| |
VAR_AST |
| |
QUANTIFIER_AST |
| |
UNKNOWN_AST |
| |
OP_TRUE |
| |
OP_FALSE |
| |
OP_EQ |
| |
OP_DISTINCT |
| |
OP_ITE |
| |
OP_AND |
| |
OP_OR |
| |
OP_IFF |
| |
OP_XOR |
| |
OP_NOT |
| |
OP_IMPLIES |
| |
OP_OEQ |
| |
OP_ANUM |
| |
OP_LE |
| |
OP_GE |
| |
OP_LT |
| |
OP_GT |
| |
OP_ADD |
| |
OP_SUB |
| |
OP_UMINUS |
| |
OP_MUL |
| |
OP_DIV |
| |
OP_IDIV |
| |
OP_REM |
| |
OP_MOD |
| |
OP_TO_REAL |
| |
OP_STORE |
| |
OP_SELECT |
| |
OP_CONST_ARRAY |
| |
OP_ARRAY_MAP |
| |
OP_ARRAY_DEFAULT |
| |
OP_SET_UNION |
| |
OP_SET_INTERSECT |
| |
OP_SET_DIFFERENCE |
| |
OP_SET_COMPLEMENT |
| |
OP_SET_SUBSET |
| |
OP_BNUM |
| |
OP_BIT1 |
| |
OP_BIT0 |
| |
OP_BNEG |
| |
OP_BADD |
| |
OP_BSUB |
| |
OP_BMUL |
| |
OP_BSDIV |
| |
OP_BUDIV |
| |
OP_BSREM |
| |
OP_BUREM |
| |
OP_BSMOD |
| |
OP_BSDIV0 |
| |
OP_BUDIV0 |
| |
OP_BSREM0 |
| |
OP_BUREM0 |
| |
OP_BSMOD0 |
| |
OP_ULEQ |
| |
OP_SLEQ |
| |
OP_UGEQ |
| |
OP_SGEQ |
| |
OP_ULT |
| |
OP_SLT |
| |
OP_UGT |
| |
OP_SGT |
| |
OP_BAND |
| |
OP_BOR |
| |
OP_BNOT |
| |
OP_BXOR |
| |
OP_BNAND |
| |
OP_BNOR |
| |
OP_BXNOR |
| |
OP_CONCAT |
| |
OP_SIGN_EXT |
| |
OP_ZERO_EXT |
| |
OP_EXTRACT |
| |
OP_REPEAT |
| |
OP_BREDOR |
| |
OP_BREDAND |
| |
OP_BCOMP |
| |
OP_BSHL |
| |
OP_BLSHR |
| |
OP_BASHR |
| |
OP_ROTATE_LEFT |
| |
OP_ROTATE_RIGHT |
| |
OP_INT2BV |
| |
OP_BV2INT |
| |
OP_PR_UNDEF |
| |
OP_PR_TRUE |
| |
OP_PR_ASSERTED |
| |
OP_PR_GOAL |
| |
OP_PR_MODUS_PONENS |
| |
OP_PR_REFLEXIVITY |
| |
OP_PR_SYMMETRY |
| |
OP_PR_TRANSITIVITY |
| |
OP_PR_TRANSITIVITY_STAR |
| |
OP_PR_MONOTONICITY |
| |
OP_PR_QUANT_INTRO |
| |
OP_PR_DISTRIBUTIVITY |
| |
OP_PR_AND_ELIM |
| |
OP_PR_NOT_OR_ELIM |
| |
OP_PR_REWRITE |
| |
OP_PR_REWRITE_STAR |
| |
OP_PR_PULL_QUANT |
| |
OP_PR_PULL_QUANT_STAR |
| |
OP_PR_PUSH_QUANT |
| |
OP_PR_ELIM_UNUSED_VARS |
| |
OP_PR_DER |
| |
OP_PR_QUANT_INST |
| |
OP_PR_HYPOTHESIS |
| |
OP_PR_LEMMA |
| |
OP_PR_UNIT_RESOLUTION |
| |
OP_PR_IFF_TRUE |
| |
OP_PR_IFF_FALSE |
| |
OP_PR_COMMUTATIVITY |
| |
OP_PR_DEF_AXIOM |
| |
OP_PR_DEF_INTRO |
| |
OP_PR_APPLY_DEF |
| |
OP_PR_IFF_OEQ |
| |
OP_PR_NNF_POS |
| |
OP_PR_NNF_NEG |
| |
OP_PR_NNF_STAR |
| |
OP_PR_CNF_STAR |
| |
OP_PR_SKOLEMIZE |
| |
OP_PR_MODUS_PONENS_OEQ |
| |
OP_PR_TH_LEMMA |
| |
OP_UNINTERPRETED |
| |
NO_FAILURE |
| |
UNKNOWN |
| |
TIMEOUT |
| |
MEMOUT_WATERMARK |
| |
CANCELED |
| |
NUM_CONFLICTS |
| |
THEORY |
| |
QUANTIFIERS |
| |
PRINT_SMTLIB_FULL |
| |
PRINT_LOW_LEVEL |
f(a1,..,a_n)i = f(a1i,...,a_ni) for every i.
mp T1 T2: q
The second antecedents may also be a proof for (iff p q).
symmetry T1: (R s t)
T1 is the antecedent of this proof object.
trans T1 T2: (R t u)
trans* T1 T2 T3: (R a d)
R must be a symmetric and transitive relation.
Assuming that this proof object is a proof for (R s t), then a proof checker must check if it is possible to prove (R s t) using the antecedents, symmetry and transitivity. That is, if there is a path from s to t, if we view every antecedent (R a b) as an edge between a and b.
monotonicity T1 ... Tn: (R (f t_1 ... t_n) (f s_1 ... s_n))
Remark: if t_i == s_i, then the antecedent Ti is suppressed.
That is, reflexivity proofs are supressed to save space.
quant-intro T1: (~ (forall (x) p) (forall (x) q))
If f and g are associative, this proof also justifies the following equality:
(= (f (g a b) (g c d)) (g (f a c) (f a d) (f b c) (f b d)))
where each f and g can have arbitrary number of arguments.
This proof object has no antecedents. Remark. This rule is used by the CNF conversion pass and instantiated by f = or, and g = and.
and-elim T1: l_i
not-or-elim T1: (not l_i)
Examples: (= (+ x 0) x) (= (+ x 1 2) (+ 3 x)) (iff (or x false) x)
x_1 ... x_m ... p_nx_1 ... x_m))
(and (forall (x_1 ... x_m) p_1x_1 ... x_m)
...
(forall (x_1 ... x_m) p_nx_1 ... x_m)))
This proof object has no antecedents.
x_1 ... x_n)
(forall (x_1 ... x_n) px_1 ... x_n))
x)) Pt)
if x does not occur in t.
Several variables can be eliminated simultaneously.
lemma T1: (or (not l_1) ... (not l_n))
This proof object has one antecedent: a hypothetical proof for false.
It converts the proof in a proof for (or (not l_1) ... (not l_n)),
when T1 contains the hypotheses: l_1, ..., l_n.
unit-resolution T1 ... T(n+1): (or l_1' ... l_m')
iff-true T1: (iff p true)
iff-false T1: (iff p false)
comm: (= (f a b) (f b a))
f is a commutative operator.
This proof object has no antecedents. Remark: if f is bool, then = is iff.
def-intro: (and (or n (not e)) (or (not n) e))
or:
def-intro: (or (not n) e)
when e only occurs positively.
When e is of the form (ite cond th el):
def-intro: (and (or (not cond) (= n th)) (or cond (= n el)))
Otherwise:
def-intro: (= n e)
apply-def T1: F ~ n
F is 'equivalent' to n, given that T1 is a proof that
n is a name for F.
iff~ T1: (~ p q)
nnf-pos T1 T2 T3 T4: (~ (iff s_1 s_2)
(and (or r_1 r_2') (or r_1' r_2)))
The negation normal form steps NNF_POS and NNF_NEG are used in the following cases:
(a) When creating the NNF of a positive force quantifier.
The quantifier is retained (unless the bound variables are eliminated).
Example
T1: q ~ q_new
nnf-pos T1: (~ (forall (x T) q) (forall (x T) q_new))
(b) When recursively creating NNF over Boolean formulas, where the top-level
connective is changed during NNF conversion. The relevant Boolean connectives
for NNF_POS are 'implies', 'iff', 'xor', 'ite'.
NNF_NEG furthermore handles the case where negation is pushed
over Boolean connectives 'and' and 'or'.
nnf-neg T1 ... Tn: (not (and s_1 ... s_n)) ~ (or r_1 ... r_n)
and
T1: (not s_1) ~ r_1
...
Tn: (not s_n) ~ r_n
nnf-neg T1 ... Tn: (not (or s_1 ... s_n)) ~ (and r_1 ... r_n)
and
T1: (not s_1) ~ r_1
T2: (not s_2) ~ r_2
T3: s_1 ~ r_1'
T4: s_2 ~ r_2'
nnf-neg T1 T2 T3 T4: (~ (not (iff s_1 s_2))
(and (or r_1 r_2) (or r_1' r_2')))
This proof object may have n antecedents. Each antecedent is a PR_DEF_INTRO.
sk: (~ (not (forall x (p x y))) (not (p (sk y) y)))
sk: (~ (exists x (p x y)) (p (sk y) y))
This proof object has no antecedents.
mp~ T1 T2: q
Create configuration
|
Configurations are created in order to assign parameters prior to creating contexts for Z3 interaction. For example, if the users whishes to use model generation, then call:
set_param_value cfg "MODEL" "true"
Z3.mk_context_x instead of using
explicit configuration objects. The function Z3.mk_context_x
receives an array of string pairs. This array represents the
configuration options.
Z3.set_param_value
Z3.del_configThe list of all configuration parameters can be obtained using the Z3 executable:
z3.exe -ini?
Z3.mk_configCreate context
|
After a context is created, the configuration cannot be changed. All main interaction with Z3 happens in the context of a context.
Z3.mk_context_x instead of using
explicit configuration objects. The function Z3.mk_context_x
receives an array of string pairs. This array represents the
configuration options.
Z3.del_contextWhen trace messages are enabled, Z3 will record the operations performed on a context in the given file file. Return TRUE if the file was opened successfully, and FALSE otherwise.
Z3.trace_off
Z3.trace_to_file
Z3.trace_to_stdout
Z3.trace_to_stderrSymbols
|
Symbols are used to name several term and type constructors.
Z3.mk_string_symbolSymbols are used to name several term and type constructors.
Z3.mk_int_symbolSorts
|
Two free types are considered the same iff the have the same name.
This type is used to create propositional variables and predicates.
This type is not the int type found in programming languages.
A machine integer can be represented using bit-vectors. The function
Z3.mk_bv_sort creates a bit-vector type.
Z3.mk_bv_sort
This type is not a floating point number.
Z3 does not have support for floating point numbers yet.
This type can also be seen as a machine integer.
We usually represent the array type as: domain -> range .
Arrays are usually used to model the heap/memory in software verification.
Z3.mk_select
Z3.mk_storecontext ->
symbol ->
symbol array ->
sort array -> sort * func_decl * func_decl array
mk_tuple_sort c name field_names field_sorts creates a tuple with a constructor named name,
a n fields, where n is the size of the arrays field_names and field_sorts.
context ->
symbol ->
symbol array -> sort * func_decl array * func_decl array
mk_enumeration_sort c enums creates an enumeration sort with enumeration names enums,
it also returns n predicates, where n is the number of enums corresponding
to testing whether an element is one of the enumerants.
context ->
symbol ->
sort ->
sort * func_decl * func_decl * func_decl * func_decl *
func_decl * func_decl
mk_list_sort c name elem_sort creates a list sort of name, over elements of sort elem_sort.
context ->
symbol ->
symbol -> symbol array -> sort array -> int array -> constructor
sort reference is 0, then the value in sort_refs should be an index referring to
one of the recursive datatypes that is declared.
Each constructor inside the constructor list must be independently reclaimed using Z3.del_constructor.
context ->
symbol array ->
constructor_list array -> sort array * constructor_list arrayInjective functions
|
Constants and Applications
|
mk_func_decl c n d r creates a function with name n, domain d, and range r.
The arity of the function is the size of the array d.
After declaring a constant or function, the function
Z3.mk_app can be used to create a constant or function
application.
Z3.mk_app
mk_const c s t is a shorthand for mk_app c (mk_func_decl c s [||] t) [||]
Z3.mk_func_decl
Z3.mk_app
A label behaves as an identity function, so the truth value of the
labeled formula is unchanged. Labels are used for identifying
useful sub-formulas when generating counter-examples.
Z3 will generate an unique name for this function declaration.
Z3.mk_func_decl
mk_fresh_const c p t is a shorthand for mk_app c (mk_fresh_func_decl c p [||] t) [||].
Z3.mk_func_decl
Z3.mk_app mk_eq c l r ]
Create an AST node representing l = r .
The nodes l and r must have the same type.
mk_distinct c [| t_1; ...; t_n |] ] Create an AST
node represeting a distinct construct. It is used for declaring
the arguments t_i pairwise distinct.
All arguments must have the same sort.
mk_not c a ]
Create an AST node representing not(a) .
The node a must have Boolean sort.
mk_ite c t1 t2 t2 ]
Create an AST node representing an if-then-else: ite(t1, t2,
t3) .
The node t1 must have Boolean sort, t2 and t3 must have the same sort.
The sort of the new node is equal to the sort of t2 and t3.
mk_iff c t1 t2 ]
Create an AST node representing t1 iff t2 .
The nodes t1 and t2 must have Boolean sort.
mk_implies c t1 t2 ]
Create an AST node representing t1 implies t2 .
The nodes t1 and t2 must have Boolean sort.
mk_xor c t1 t2 ]
Create an AST node representing t1 xor t2 .
The nodes t1 and t2 must have Boolean sort.
mk_and c [| t_1; ...; t_n |] ] Create the conjunction: t_1 and ... and t_n.
All arguments must have Boolean sort.
mk_or c [| t_1; ...; t_n |] ] Create the disjunction: t_1 or ... or t_n.
All arguments must have Boolean sort.
mk_add c [| t_1; ...; t_n |] ] Create the term: t_1 + ... + t_n.
All arguments must have int or real sort.
mk_mul c [| t_1; ...; t_n |] ] Create the term: t_1 * ... * t_n.
All arguments must have int or real sort.
mk_sub c [| t_1; ...; t_n |] ] Create the term: t_1 - ... - t_n.
All arguments must have int or real sort.
mk_unary_minus c arg ] Create the term: - arg.
The argument must have int or real type.
mk_div c t_1 t_2 ] Create the term: t_1 div t_2.
The arguments must either both have int type or both have real type.
If the arguments have int type, then the result type is an int type, otherwise the
the result type is real.
mk_mod c t_1 t_2 ] Create the term: t_1 mod t_2.
The arguments must have int type.
mk_rem c t_1 t_2 ] Create the term: t_1 rem t_2.
The arguments must have int type.
mk_lt c t1 t2 ]
Create less than.
The nodes t1 and t2 must have the same sort, and must be int or real.
mk_le c t1 t2 ]
Create less than or equal to.
The nodes t1 and t2 must have the same sort, and must be int or real.
mk_gt c t1 t2 ]
Create greater than.
The nodes t1 and t2 must have the same sort, and must be int or real.
mk_ge c t1 t2 ]
Create greater than or equal to.
The nodes t1 and t2 must have the same sort, and must be int or real.
mk_int2real c t1 ]
Coerce an integer to a real.
There is no converse operation exposed, but you can take the floor of a real by creating an auxiliary integer constant k and and asserting mk_int2real(k) <= t1 < mk_int2real(k)+1 .
The node t1 must have sort integer.
mk_bvneg c t1 ]
Bitwise negation.
The node t1 must have a bit-vector sort.
mk_bvand c t1 t2 ]
Bitwise and.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvor c t1 t2 ]
Bitwise or.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvxor c t1 t2 ]
Bitwise exclusive-or.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvnand c t1 t2 ]
Bitwise nand.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvnor c t1 t2 ]
Bitwise nor.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvxnor c t1 t2 ]
Bitwise xnor.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvneg c t1 ]
Standard two's complement unary minus.
The node t1 must have bit-vector sort.
mk_bvadd c t1 t2 ]
Standard two's complement addition.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvsub c t1 t2 ]
Standard two's complement subtraction.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvmul c t1 t2 ]
Standard two's complement multiplication.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvudiv c t1 t2 ]
Unsigned division.
It is defined as the floor of t1/t2 if t2 is different from zero. If t2 is zero, then the result is undefined.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvsdiv c t1 t2 ]
Two's complement signed division.
It is defined in the following way:
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvurem c t1 t2 ]
Unsigned remainder.
It is defined as t1 - (t1 /u t2) * t2 , where /u represents unsigned int division.
If t2 is zero, then the result is undefined.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvsrem c t1 t2 ]
Two's complement signed remainder (sign follows dividend).
It is defined as t1 - (t1 /s t2) * t2 , where /s represents signed division. The most significant bit (sign) of the result is equal to the most significant bit of t1.
If t2 is zero, then the result is undefined.
The nodes t1 and t2 must have the same bit-vector sort.
Z3.mk_bvsmod mk_bvsmod c t1 t2 ]
Two's complement signed remainder (sign follows divisor).
If t2 is zero, then the result is undefined.
The nodes t1 and t2 must have the same bit-vector sort.
Z3.mk_bvsrem mk_bvult c t1 t2 ]
Unsigned less than.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvslt c t1 t2 ]
Two's complement signed less than.
It abbreviates:
(or (and (= (extract[|m-1|:|m-1|] s) bit1)
(= (extract[|m-1|:|m-1|] t) bit0))
(and (= (extract[|m-1|:|m-1|] s) (extract[|m-1|:|m-1|] t))
(bvult s t)))
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvule c t1 t2 ]
Unsigned less than or equal to.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvsle c t1 t2 ]
Two's complement signed less than or equal to.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvuge c t1 t2 ]
Unsigned greater than or equal to.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvsge c t1 t2 ]
Two's complement signed greater than or equal to.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvugt c t1 t2 ]
Unsigned greater than.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvsgt c t1 t2 ]
Two's complement signed greater than.
The nodes t1 and t2 must have the same bit-vector sort.
mk_concat c t1 t2 ]
Concatenate the given bit-vectors.
The nodes t1 and t2 must have (possibly different) bit-vector sorts
The result is a bit-vector of size n1+n2 , where n1 (n2) is the size
of t1 (t2).
mk_extract c high low t1 ]
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 .
The node t1 must have a bit-vector sort.
mk_sign_ext c i t1 ]
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.
The node t1 must have a bit-vector sort.
mk_zero_ext c i t1 ]
Extend the given bit-vector with zeros to the (unsigned int) equivalent
bitvector of size m+i , where m is the size of the
given bit-vector.
The node t1 must have a bit-vector sort.
mk_bvshl c t1 t2 ]
Shift left.
It is equivalent to multiplication by 2^x where x is the value of the third argument.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvlshr c t1 t2 ]
Logical shift right.
It is equivalent to unsigned int division by 2^x where x is the value of the third argument.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvashr c t1 t2 ]
Arithmetic shift right.
It is like logical shift right except that the most significant bits of the result always copy the most significant bit of the second argument.
The nodes t1 and t2 must have the same bit-vector sort.
mk_rotate_left c i t1 ]
Rotate bits of t1 to the left i times.
The node t1 must have a bit-vector sort.
mk_rotate_right c i t1 ]
Rotate bits of t1 to the right i times.
The node t1 must have a bit-vector sort.
mk_int2bv c n t1 ]
Create an n bit bit-vector from the integer argument t1.
NB. This function is essentially treated as uninterpreted. So you cannot expect Z3 to precisely reflect the semantics of this function when solving constraints with this function.
The node t1 must have integer sort.
mk_bv2int c t1 is_signed ]
Create an integer from the bit-vector argument t1.
If is_signed is false, then the bit-vector t1 is treated as unsigned int.
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.
NB. This function is essentially treated as uninterpreted. So you cannot expect Z3 to precisely reflect the semantics of this function when solving constraints with this function.
The node t1 must have a bit-vector sort.
mk_bvadd_no_overflow c t1 t2 is_signed ]
Create a predicate that checks that the bit-wise addition
of t1 and t2 does not overflow.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvadd_no_underflow c t1 t2 ]
Create a predicate that checks that the bit-wise signed addition
of t1 and t2 does not underflow.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvsub_no_overflow c t1 t2 ]
Create a predicate that checks that the bit-wise signed subtraction
of t1 and t2 does not overflow.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvsub_no_underflow c t1 t2 is_signed ]
Create a predicate that checks that the bit-wise subtraction
of t1 and t2 does not underflow.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvsdiv_no_overflow c t1 t2 ]
Create a predicate that checks that the bit-wise signed division
of t1 and t2 does not overflow.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvneg_no_overflow c t1 ]
Check that bit-wise negation does not overflow when
t1 is interpreted as a signed bit-vector.
The node t1 must have bit-vector sort.
mk_bvmul_no_overflow c t1 t2 is_signed ]
Create a predicate that checks that the bit-wise multiplication
of t1 and t2 does not overflow.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvmul_no_underflow c t1 t2 ]
Create a predicate that checks that the bit-wise signed multiplication
of t1 and t2 does not underflow.
The nodes t1 and t2 must have the same bit-vector sort.
mk_select c a i ]
Array read.
The node a must have an array sort domain -> range , and i must have the sort domain.
The sort of the result is range.
Z3.mk_array_sort
Z3.mk_store mk_store c a i v ]
Array update.
The node a must have an array sort domain -> range , i must have sort domain,
v must have sort range. The sort of the result is domain -> range .
Z3.mk_array_sort
Z3.mk_select mk_map f n args ]
map f on the the argument arrays.
The n nodes args must be of array sorts domain_i -> range_i .
The function declaration f must have type range_1 .. range_n -> range .
v must have sort range. The sort of the result is domain_i -> range .
Z3.mk_array_sort
Z3.mk_store
Z3.mk_selectNumerals
|
Z3.mk_numeral
Z3.mk_int
Z3.mk_unsigned_int
This function can be use to create numerals that fit in a machine integer.
It is slightly faster than Z3.mk_numeral since it is not necessary to parse a string.
Z3.mk_numeral
This function can be use to create numerals that fit in a machine unsinged integer.
It is slightly faster than Z3.mk_numeral since it is not necessary to parse a string.
Z3.mk_numeralQuantifiers
|
Z3 uses pattern matching to instantiate quantifiers. If a pattern is not provided for a quantifier, then Z3 will automatically compute a set of patterns for it. However, for optimal performance, the user should provide the patterns.
Patterns comprise a list of terms. The list should be non-empty. If the list comprises of more than one term, it is a called a multi-pattern.
In general, one can pass in a list of (multi-)patterns in the quantifier constructor.
Z3.mk_forall
Z3.mk_existsBound variables are indexed by de-Bruijn indices. It is perhaps easiest to explain the meaning of de-Bruijn indices by indicating the compilation process from non-de-Bruijn formulas to de-Bruijn format.
abs(forall (x1) phi) = forall (x1) abs1(phi, x1, 0)
abs(forall (x1, x2) phi) = abs(forall (x1) abs(forall (x2) phi))
abs1(x, x, n) = b_n
abs1(y, x, n) = y
abs1(f(t1,...,tn), x, n) = f(abs1(t1,x,n), ..., abs1(tn,x,n))
abs1(forall (x1) phi, x, n) = forall (x1) (abs1(phi, x, n+1))
The last line is significant: the index of a bound variable is different depending on the scope in which it appears. The deeper x appears, the higher is its index.
Z3.mk_forall
Z3.mk_exists
mk_forall c w p t n b creates a forall formula, where
w is the weight, p is an array of patterns, t is an array
with the sorts of the bound variables, n is an array with the
'names' of the bound variables, and b is the body of the
quantifier. Quantifiers are associated with weights indicating
the importance of using the quantifier during
instantiation.
Z3.mk_pattern
Z3.mk_bound
Z3.mk_existsZ3.mk_forall.
Z3.mk_pattern
Z3.mk_bound
Z3.mk_forallcontext ->
bool ->
int ->
pattern array -> sort array -> symbol array -> ast -> ast
Z3.mk_pattern
Z3.mk_bound
Z3.mk_forall
Z3.mk_existsthe quantifier during instantiation. By default, pass the weight 0.
Z3.mk_pattern
Z3.mk_exists_constZ3.mk_forall_const.
Summary: Create an existential quantifier using a list of constants that will form the set of bound variables.
the quantifier during instantiation. By default, pass the weight 0.
Z3.mk_pattern
Z3.mk_forall_constAccessors
|
Z3.mk_int_symbol, and STRING_SYMBOL if the symbol
was constructed using Z3.mk_string_symbol. get_symbol_int c s ]
Return the symbol int value.
Z3.mk_int_symbol get_symbol_string c s ]
Return the symbol name.
Z3.mk_string_symbol
Preturn TRUE if the numeral value fits in 64 bit numerals, FALSE otherwise.
get_numeral_int c v ]
Similar to Z3.get_numeral_string, but only succeeds if
the value can fit in a machine int. Return TRUE if the call succeeded.
Z3.get_numeral_string get_numeral_uint c v ]
Similar to Z3.get_numeral_string, but only succeeds if
the value can fit in a machine unsigned int int. Return TRUE if the call succeeded.
Z3.get_numeral_string get_app_num_args c a ]
Return the number of argument of an application. If t
is an constant, then the number of arguments is 0. get_app_arg c a i ]
Return the i-th argument of the given application.
The AST node must be a constant, application, numeral, bound variable, or quantifier.
get_domain c d i ]
Return the sort of the i-th parameter of the given function declaration.
Z3.get_domain_size get_range c d ]
Return the range of the given declaration.
If d is a constant (i.e., has zero arguments), then this
function returns the sort of the constant.
get_bv_sort_size c t ]
Return the size of the given bit-vector sort.
Z3.mk_bv_sort
Z3.get_sort_kind get_array_sort_domain c t ]
Return the domain of the given array sort.
Z3.mk_array_sort
Z3.get_sort_kind get_array_sort_range c t ]
Return the range of the given array sort.
Z3.mk_array_sort
Z3.get_sort_kind get_tuple_sort_mk_decl c t ]
Return the constructor declaration of the given tuple
sort.
Z3.mk_tuple_sort
Z3.get_sort_kind get_tuple_sort_num_fields c t ]
Return the number of fields of the given tuple sort.
Z3.get_tuple_sort, which
returns a tuple: tuple constructor, and an array of the tuple sort fields.
Z3.mk_tuple_sort
Z3.get_sort_kind get_tuple_sort_field_decl c t i ]
Return the i-th field declaration (i.e., projection function declaration)
of the given tuple sort.
Z3.get_tuple_sort, which
returns a tuple: tuple constructor, and an array of the tuple sort fields.
Z3.mk_tuple_sort
Z3.get_sort_kind
Z3.get_datatype_sort_constructor
Z3.get_datatype_sort_recognizer
Z3.get_datatype_sort_constructor_accessor
Z3.get_datatype_sort_num_constructors
Z3.get_datatype_sort_recognizer
Z3.get_datatype_sort_constructor_accessor
Z3.get_datatype_sort_num_constructors
Z3.get_datatype_sort_constructor
Z3.get_datatype_sort_constructor_accessor
Z3.get_datatype_sort_num_constructors
Z3.get_datatype_sort_constructor
Z3.get_datatype_sort_recognizer
Provides an interface to the AST simplifier used by Z3.
It allows clients to piggyback on top of the AST simplifier
for their own term manipulation.
Coercions
|
Z3.get_ast_kind returns app.Constraints
|
The logical context can be viewed as a stack of contexts. The scope level is the number of elements on this stack. The stack of contexts is simulated using trail (undo) stacks.
Z3.pop
Restores the context from the top of the stack, and pops it off the
stack. Any changes to the logical context (by Z3.assert_cnstr or
other functions) between the matching Z3.push and pop
operators are flushed, and the context is completely restored to
what it was right before the Z3.push.
Z3.push
Normally, references to terms are no longer valid when
popping scopes beyond the level where the terms are created.
If you want to reference a term below the scope where it
was created, use this method to specify how many pops
the term should survive.
The num_scopes should be at most equal to the number of
calls to push subtracted with the calls to pop.
After one assertion, the logical context may become inconsistent.
The functions Z3.check or Z3.check_and_get_model should be
used to check whether the logical context is consistent or not.
Z3.check
Z3.check_and_get_model
If the logical context is not unsatisfiable (i.e., the return value is different from L_FALSE)
and model construction is enabled (see Z3.mk_config), then a model is stored in m. Otherwise,
the value 0 is stored in m.
The caller is responsible for deleting the model using the function Z3.del_model.
Z3.mk_config).
Z3.check
Z3.del_model
The function Z3.check_and_get_model should be used when models are needed.
Z3.check_and_get_modelcontext ->
ast array ->
int -> ast array -> lbool * model * ast * int * ast array
If the logical context is not unsatisfiable (i.e., the return value is different from L_FALSE),
a non-0 model argument is passed in,
and model construction is enabled (see Z3.mk_config), then a model is stored in m.
Otherwise, m is left unchanged.
The caller is responsible for deleting the model using the function Z3.del_model.
Z3.mk_config).
Z3.check
Z3.del_modelThe function can be used for relying on Z3 to identify equal terms under the current set of assumptions. The array of terms and array of class identifiers should have the same length. The class identifiers are numerals that are assigned to the same value for their corresponding terms if the current context forces the terms to be equal. You cannot deduce that terms corresponding to different numerals must be all different, (especially when using non-convex theories). Since Z3 does not rely on exhaustive equality propagation, it is the case that that not all implied equalities are returned by this call. Only implied equalities that follow from simple constraint and equality propagation is discovered.
A side-effect of the function is a satisfiability check. The function return L_FALSE if the current assertions are not satisfiable.
Z3.check_and_get_model
Z3.checkSearch control.
|
Notifies the current check to abort and return.
This method should be called from a different thread
than the one performing the check.
If a call to Z3.check or Z3.check_and_get_model returns L_UNDEF,
use this facility to determine the more detailed cause of search failure.
Labels.
|
Z3.del_literals
Z3.get_num_literals
Z3.get_label_symbol
Z3.get_literal
Z3.del_literals
Z3.get_num_literals
Z3.get_label_symbol
Z3.get_literal
Z3.del_literals
Z3.get_num_literals
Z3.get_label_symbol
Z3.get_literalThe disabled label is not going to be used when blocking the subsequent search.
Z3.block_literalsModel navigation
|
Z3.get_model_constants.
Z3.get_model_constant get_model_constant c m i ]
Return the i-th constant in the given model.
Z3.get_model_constants.
Z3.eval is_array_value c v ]
Determine whether the term encodes an array value.
Return the number of entries mapping to non-default values of the array. get_array_value c v ]
An array values is represented as a dictionary plus a
default (else) value. This function returns the array graph.
A function interpretation is represented as a finite map and an 'else' value. Each entry in the finite map represents the value of a function given a set of arguments.
Z3.get_model_funcs.
Z3.get_model_func_decl
Z3.get_model_func_else
Z3.get_model_func_num_entries
Z3.get_model_func_entry_num_args
Z3.get_model_func_entry_arg get_model_func_decl c m i ]
Return the declaration of the i-th function in the given model.
Z3.get_model_funcs.
Z3.get_model_num_funcs get_model_func_else c m i ]
Return the 'else' value of the i-th function interpretation in the given model.
A function interpretation is represented as a finite map and an 'else' value.
Z3.get_model_funcs.
Z3.get_model_num_funcs
Z3.get_model_func_num_entries
Z3.get_model_func_entry_num_args
Z3.get_model_func_entry_arg get_model_func_num_entries c m i ]
Return the number of entries of the i-th function interpretation in the given model.
A function interpretation is represented as a finite map and an 'else' value.
Z3.get_model_funcs.
Z3.get_model_num_funcs
Z3.get_model_func_else
Z3.get_model_func_entry_num_args
Z3.get_model_func_entry_arg get_model_func_entry_num_args c m i j ]
Return the number of arguments of the j-th entry of the i-th function interpretation in the given
model.
A function interpretation is represented as a finite map and an 'else' value. This function returns the j-th entry of this map.
An entry represents the value of a function given a set of arguments.
Z3.get_model_funcs.
Z3.get_model_num_funcs
Z3.get_model_func_num_entries
Z3.get_model_func_entry_arg get_model_func_entry_arg c m i j k ]
Return the k-th argument of the j-th entry of the i-th function interpretation in the given
model.
A function interpretation is represented as a finite map and an 'else' value. This function returns the j-th entry of this map.
An entry represents the value of a function given a set of arguments.
Z3.get_model_funcs.
Z3.get_model_num_funcs
Z3.get_model_func_num_entries
Z3.get_model_func_entry_num_args get_model_func_entry_value c m i j ]
Return the return value of the j-th entry of the i-th function interpretation in the given
model.
A function interpretation is represented as a finite map and an 'else' value. This function returns the j-th entry of this map.
An entry represents the value of a function given a set of arguments.
Z3.get_model_funcs.
Z3.get_model_num_funcs
Z3.get_model_func_num_entries eval c m t ]
Evaluate the AST node t in the given model.
Return a pair: Boolean and value. The Boolean is true if the term was successfully evaluated.
The evaluation may fail for the following reasons:
Provides direct way to evaluate declarations
without going over terms.
Interaction logging.
|
String conversion
|
The default mode for pretty printing AST nodes is to produce SMT-LIB style output where common subexpressions are printed at each occurrence. The mode is called PRINT_SMTLIB_FULL. To print shared common subexpressions only once, use the PRINT_LOW_LEVEL mode.
Z3.ast_to_string
Z3.pattern_to_string
Z3.func_decl_to_string
Z3.pattern_to_string
Z3.sort_to_stringcontext -> pattern -> stringval sort_to_string : context -> sort -> stringval func_decl_to_string : context -> func_decl -> stringval model_to_string : context -> model -> stringcontext ->
string -> string -> string -> string -> ast array -> ast -> string
This function is mainly used for debugging purposes. It displays
the internal structure of a logical context.
This function can be used for debugging purposes. It returns a conjunction
of formulas that are assigned to true in the current context.
This conjunction will contain not only the assertions that are set to true
under the current assignment, but will also include additional literals
if there has been a call to Z3.check or Z3.check_and_get_model.
Parser interface
|
context ->
string ->
symbol array ->
sort array -> symbol array -> func_decl array -> unit parse_smtlib_string c str sort_names sorts decl_names decls ]
Parse the given string using the SMT-LIB parser.
The symbol table of the parser can be initialized using the given sorts and declarations. The symbols in the arrays sort_names and decl_names don't need to match the names of the sorts and declarations in the arrays sorts and decls. This is an useful feature since we can use arbitrary names to reference sorts and declarations defined using the C API.
The formulas, assumptions and declarations defined in str can be extracted using the functions:
Z3.get_smtlib_num_formulas, Z3.get_smtlib_formula, Z3.get_smtlib_num_assumptions, Z3.get_smtlib_assumption,
Z3.get_smtlib_num_decls, and Z3.get_smtlib_decl.
context ->
string ->
symbol array ->
sort array -> symbol array -> func_decl array -> unitZ3.parse_smtlib_string, but reads the benchmark from a file.Z3.parse_smtlib_string or Z3.parse_smtlib_file. get_smtlib_formula c i ]
Return the i-th formula parsed by the last call to Z3.parse_smtlib_string or Z3.parse_smtlib_file.
Z3.parse_smtlib_string or Z3.parse_smtlib_file. get_smtlib_assumption c i ]
Return the i-th assumption parsed by the last call to Z3.parse_smtlib_string or Z3.parse_smtlib_file.
Z3.parse_smtlib_string or Z3.parse_smtlib_file. get_smtlib_decl c i ]
Return the i-th declaration parsed by the last call to Z3.parse_smtlib_string or Z3.parse_smtlib_file.
get_smtlib_sort c i ]
Return the i-th sort parsed by the last call to Z3.parse_smtlib_string or Z3.parse_smtlib_file.
get_smtlib_error c ]
Retrieve that last error message information generated from parsing. parse_z3_string c str ]
Parse the given string using the Z3 native parser.
Return the conjunction of asserts made in the input.
Z3.parse_z3_string, but reads the benchmark from a file.Miscellaneous
|
Use this facility on out-of memory errors.
It allows discharging the previous state and resuming afresh.
Any pointers previously returned by the API
become invalid.
ML Extensions
|
mk_context_x configs ] is a shorthand for the context with configurations in configs. get_app_args c a ] is the array of arguments of an application. If t is a constant, then the array is empty.
Z3.get_app_num_args
Z3.get_app_arg get_app_args c d ] is the array of parameters of d.
Z3.get_domain_size
Z3.get_domain get_array_sort c t ] is the domain and the range of t.
Z3.get_array_sort_domain
Z3.get_array_sort_range get_tuple_sort c ty ] is the pair (mk_decl, fields) where mk_decl is the constructor declaration of ty, and fields is the array of fields in ty.
Z3.get_tuple_sort_mk_decl
Z3.get_tuple_sort_num_fields
Z3.get_tuple_sort_field_decltype datatype_constructor_refined = {
|
constructor : |
|
recognizer : |
|
accessors : |
datatype_constructor_refined ] is the refinement of a datatype constructor.
It contains the constructor declaration, recognizer, and list of accessor functions.
get_datatype_sort c ty ] is the array of triples (constructor, recognizer, fields) where constructor is the constructor declaration of ty, recognizer is the recognizer for the constructor, and fields is the array of fields in ty.
Z3.get_datatype_sort_num_constructors
Z3.get_datatype_sort_constructor
Z3.get_datatype_sort_recognizer
Z3.get_datatype_sort_constructor_accessorcontext -> sort -> datatype_constructor_refined arrayval get_model_constants : context -> model -> func_decl array get_model_constants c m ] is the array of constants in the model m.
Z3.get_model_num_constants
Z3.get_model_constant get_model_func_entry c m i j ] is the j'th entry in the i'th function in the model m.
Z3.get_model_func_entry_num_args
Z3.get_model_func_entry_arg
Z3.get_model_func_entry_value get_model_func_entries c m i ] is the array of entries in the i'th function in the model m.
Z3.get_model_func_num_entries
Z3.get_model_func_entry get_model_funcs c m ] is the array of functions in the model m. Each function is represented by the triple (decl, entries, else), where decl is the declaration name for the function, entries is the array of entries in the function, and else is the default (else) value for the function.
Z3.get_model_num_funcs
Z3.get_model_func_decl
Z3.get_model_func_entries
Z3.get_model_func_else get_smtlib_formulas c ] is the array of formulas created by a preceding call to Z3.parse_smtlib_string or Z3.parse_smtlib_file.
Recommend use Z3.parse_smtlib_string_x or Z3.parse_smtlib_file_x for functional style interface to the SMT-LIB parser.
Z3.parse_smtlib_string_x
Z3.parse_smtlib_file_x
Z3.parse_smtlib_string
Z3.parse_smtlib_file
Z3.get_smtlib_num_formulas
Z3.get_smtlib_formulaget_smtlib_assumptions c ] is the array of assumptions created by a preceding call to Z3.parse_smtlib_string or Z3.parse_smtlib_file.
Recommend use Z3.parse_smtlib_string_x or Z3.parse_smtlib_file_x for functional style interface to the SMT-LIB parser.
Z3.parse_smtlib_string_x
Z3.parse_smtlib_file_x
Z3.parse_smtlib_string
Z3.parse_smtlib_file
Z3.get_smtlib_num_assumptions
Z3.get_smtlib_assumption get_smtlib_decls c ] is the array of declarations created by a preceding call to Z3.parse_smtlib_string or Z3.parse_smtlib_file.
Recommend use Z3.parse_smtlib_string_x or Z3.parse_smtlib_file_x for functional style interface to the SMT-LIB parser.
Z3.parse_smtlib_string_x
Z3.parse_smtlib_file_x
Z3.parse_smtlib_string
Z3.parse_smtlib_file
Z3.get_smtlib_num_decls
Z3.get_smtlib_decl get_smtlib_parse_results c ] is the triple (get_smtlib_formulas c, get_smtlib_assumptions c, get_smtlib_decls c).
Recommend use Z3.parse_smtlib_string_x or Z3.parse_smtlib_file_x for functional style interface to the SMT-LIB parser.
Z3.parse_smtlib_string_x
Z3.parse_smtlib_file_x
Z3.parse_smtlib_string
Z3.parse_smtlib_file
Z3.get_smtlib_formulas
Z3.get_smtlib_assumptions
Z3.get_smtlib_declscontext ->
string ->
symbol array ->
sort array -> symbol array -> func_decl array -> ast parse_smtlib_string_formula c ... ] calls (parse_smtlib_string c ...) and returns the single formula produced.
Recommended for functional style interface to the SMT-LIB parser.
Z3.parse_smtlib_file_formula
Z3.parse_smtlib_string_xcontext ->
string ->
symbol array ->
sort array -> symbol array -> func_decl array -> ast parse_smtlib_file_formula c ... ] calls (parse_smtlib_file c ...) and returns the single formula produced.
Recommended for functional style interface to the SMT-LIB parser.
Z3.parse_smtlib_file_formula
Z3.parse_smtlib_file_xcontext ->
string ->
symbol array ->
sort array ->
symbol array ->
func_decl array -> ast array * ast array * func_decl array parse_smtlib_string_x c ... ] is (parse_smtlib_string c ...; get_smtlib_parse_results c)
Recommended for functional style interface to the SMT-LIB parser.
Z3.parse_smtlib_file_x
Z3.parse_smtlib_string
Z3.get_smtlib_parse_resultscontext ->
string ->
symbol array ->
sort array ->
symbol array ->
func_decl array -> ast array * ast array * func_decl array parse_smtlib_file_x c ... ] is (parse_smtlib_file c ...; get_smtlib_parse_results c)
Recommended for functional style interface to the SMT-LIB parser.
Z3.parse_smtlib_string_x
Z3.parse_smtlib_file
Z3.get_smtlib_parse_results
| |
Symbol_int of |
| |
Symbol_string of |
| |
Symbol_unknown |
symbol_refined ] is the refinement of a Z3.symbol .
Z3.symbol_refine
Z3.get_symbol_kind symbol_refine c s ] is the refined symbol of s.
Z3.symbol_refined
Z3.get_symbol_kind sort_refined ] is the refinement of a Z3.sort .
Z3.sort_refine
Z3.get_sort_kind
| |
Sort_uninterpreted of |
| |
Sort_bool |
| |
Sort_int |
| |
Sort_real |
| |
Sort_bv of |
| |
Sort_array of |
| |
Sort_datatype of |
| |
Sort_unknown of |
| |
Forall |
| |
Exists |
| |
Numeral_small of |
| |
Numeral_large of |
numeral_refined ] is the refinement of a numeral .
Numerals whose fractional representation can be fit with
64 bit integers are treated as small.
| |
Term_app of |
| |
Term_quantifier of |
| |
Term_numeral of |
| |
Term_var of |