Home Docs Download Mail FAQ Awards Status MSR

Z3An Efficient SMT Solver

OCaml API (Index)

Module Z3: Sections

module Z3: sig  end

type config
type context
type sort
type func_decl
type ast
type app
type pattern
type symbol
type parameter
type model
type literals
type constructor
type constructor_list

type enum_1 =
| L_FALSE
| L_UNDEF
| L_TRUE
type lbool = enum_1

type enum_2 =
| INT_SYMBOL
| STRING_SYMBOL
type symbol_kind = enum_2

type enum_3 =
| PARAMETER_INT
| PARAMETER_DOUBLE
| PARAMETER_RATIONAL
| PARAMETER_SYMBOL
| PARAMETER_SORT
| PARAMETER_AST
| PARAMETER_FUNC_DECL
type parameter_kind = enum_3

type enum_4 =
| UNINTERPRETED_SORT
| BOOL_SORT
| INT_SORT
| REAL_SORT
| BV_SORT
| ARRAY_SORT
| DATATYPE_SORT
| UNKNOWN_SORT
type sort_kind = enum_4

type enum_5 =
| NUMERAL_AST
| APP_AST
| VAR_AST
| QUANTIFIER_AST
| UNKNOWN_AST
type ast_kind = enum_5

type enum_6 =
| 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
type decl_kind = enum_6

type enum_7 =
| NO_FAILURE
| UNKNOWN
| TIMEOUT
| MEMOUT_WATERMARK
| CANCELED
| NUM_CONFLICTS
| THEORY
| QUANTIFIERS
type search_failure = enum_7

type enum_8 =
| PRINT_SMTLIB_FULL
| PRINT_LOW_LEVEL
type ast_print_mode = enum_8

(* Example: T1: (R a b) T2: (R c b) T3: (R c d) 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.

T1: (~ p q) quant-intro T1: (~ (forall (x) p) (forall (x) q))

(= (f a (g c d)) (g (f a c) (f a d)))

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.

T1: (and l_1 ... l_n) and-elim T1: l_i T1: (not (or l_1 ... l_n)) not-or-elim T1: (not l_i)

This proof object has no antecedents. The conclusion of a rewrite rule is either an equality (= t s), an equivalence (iff t s), or equi-satisfiability (~ t s). Remark: if f is bool, then = is iff.

Examples: (= (+ x 0) x) (= (+ x 1 2) (+ 3 x)) (iff (or x false) x)

(iff (forall (x_1 ... x_m) (and p_1x_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.

It is used to justify the elimination of unused variables. This proof object has no antecedents.

This proof object has no antecedents.

Several variables can be eliminated simultaneously.

T1: false 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.

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.

(or (not (and p q)) p) (or (not (and p q)) q) (or (not (and p q r)) p) (or (not (and p q r)) q) (or (not (and p q r)) r) ... (or (and p q) (not p) (not q)) (or (not (or p q)) p q) (or (or p q) (not p)) (or (or p q) (not q)) (or (not (iff p q)) (not p) q) (or (not (iff p q)) p (not q)) (or (iff p q) (not p) (not q)) (or (iff p q) p q) (or (not (ite a b c)) (not a) b) (or (not (ite a b c)) a c) (or (ite a b c) (not a) (not b)) (or (ite a b c) a (not c)) (or (not (not a)) (not a)) (or (not a) a) This proof object has no antecedents. Note: all axioms are propositional tautologies. Note also that 'and' and 'or' can take multiple arguments. You can recover the propositional tautologies by unfolding the Boolean connectives in the axioms a small bounded number of steps (=3).

When e is of Boolean type: 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)

This proof object is only used if the parameter PROOF_MODE is 1.

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.

*)



Create configuration


val mk_config : unit -> config
Summary: Create a 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"


val del_config : config -> unit
Summary: Delete the given configuration object.


val set_param_value : config -> string -> string -> unit
Summary: Set a configuration parameter.

The list of all configuration parameters can be obtained using the Z3 executable:

       z3.exe -ini?
       




Create context


val mk_context : config -> context
Summary: Create a logical context using the given configuration.

After a context is created, the configuration cannot be changed. All main interaction with Z3 happens in the context of a context.


val del_context : context -> unit
Summary: Delete the given logical context.


val trace_to_file : context -> string -> bool
Summary: Enable trace messages to a file

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


val trace_to_stderr : context -> unit
Summary: Enable trace messages to a standard error.


val trace_to_stdout : context -> unit
Summary: Enable trace messages to a standard output.


val trace_off : context -> unit
Summary: Disable trace messages.




Symbols


val mk_int_symbol : context -> int -> symbol
Summary: Create a Z3 symbol using an integer.

Symbols are used to name several term and type constructors.


val mk_string_symbol : context -> string -> symbol
Summary: Create a Z3 symbol using a C string.

Symbols are used to name several term and type constructors.




Sorts


val is_eq_sort : context -> sort -> sort -> bool
Summary: compare sorts.
val mk_uninterpreted_sort : context -> symbol -> sort
Summary: Create a free (uninterpreted) type using the given name (symbol).

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

val mk_bool_sort : context -> sort
Summary: Create the Boolean type.

This type is used to create propositional variables and predicates.

val mk_int_sort : context -> sort
Summary: Create an integer type.

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.


val mk_real_sort : context -> sort
Summary: Create a real type.

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

val mk_bv_sort : context -> int -> sort
Summary: Create a bit-vector type of the given size.

This type can also be seen as a machine integer.


val mk_array_sort : context -> sort -> sort -> sort
Summary: Create an array type.

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


val mk_tuple_sort : context ->
symbol ->
symbol array ->
sort array -> sort * func_decl * func_decl array
Summary: Create a tuple type.

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.

val mk_enumeration_sort : context ->
symbol ->
symbol array -> sort * func_decl array * func_decl array
Summary: Create a enumeration sort.

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.

val mk_list_sort : context ->
symbol ->
sort ->
sort * func_decl * func_decl * func_decl * func_decl *
func_decl * func_decl
Summary: Create a list sort

mk_list_sort c name elem_sort creates a list sort of name, over elements of sort elem_sort.

val mk_constructor : context ->
symbol ->
symbol -> symbol array -> sort array -> int array -> constructor
Summary: Create a 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.

val query_constructor : context ->
constructor -> int -> func_decl * func_decl * func_decl array
Summary: Query constructor for declared funcions.
val del_constructor : context -> constructor -> unit
Summary: Reclaim memory allocated to constructor.
val mk_datatype : context ->
symbol -> constructor array -> sort * constructor array
Summary: Create recursive datatype. Return the datatype sort.
val mk_constructor_list : context -> constructor array -> constructor_list
Summary: Create list of constructors.
val del_constructor_list : context -> constructor_list -> unit
Summary: reclaim memory allocated for constructor list.

Each constructor inside the constructor list must be independently reclaimed using Z3.del_constructor.

val mk_datatypes : context ->
symbol array ->
constructor_list array -> sort array * constructor_list array
Summary: Create mutually recursive datatypes.


Injective functions


val mk_injective_function : context -> symbol -> sort array -> sort -> func_decl
Summary: Create injective function declaration


Constants and Applications


val is_eq_ast : context -> ast -> ast -> bool
Summary: compare terms.
val mk_func_decl : context -> symbol -> sort array -> sort -> func_decl
Summary: Declare a constant or function.

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.


val mk_app : context -> func_decl -> ast array -> ast
Summary: Create a constant or function application.


val mk_const : context -> symbol -> sort -> ast
Summary: Declare and create a constant.

mk_const c s t is a shorthand for mk_app c (mk_func_decl c s [||] t) [||]


val mk_label : context -> symbol -> bool -> ast -> ast
Summary: Create a labeled formula.

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.

val mk_fresh_func_decl : context -> string -> sort array -> sort -> func_decl
Summary: Declare a fresh constant or function.

Z3 will generate an unique name for this function declaration.


val mk_fresh_const : context -> string -> sort -> ast
Summary: Declare and create a fresh constant.

mk_fresh_const c p t is a shorthand for mk_app c (mk_fresh_func_decl c p [||] t) [||].


val mk_true : context -> ast
Summary: Create an AST node representing true.
val mk_false : context -> ast
Summary: Create an AST node representing false.
val mk_eq : context -> ast -> ast -> ast
Summary: [ mk_eq c l r ] Create an AST node representing l = r .

The nodes l and r must have the same type.

val mk_distinct : context -> ast array -> ast
Summary: [ 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.


val mk_not : context -> ast -> ast
Summary: [ mk_not c a ] Create an AST node representing not(a) .

The node a must have Boolean sort.

val mk_ite : context -> ast -> ast -> ast -> ast
Summary: [ 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.

val mk_iff : context -> ast -> ast -> ast
Summary: [ mk_iff c t1 t2 ] Create an AST node representing t1 iff t2 .

The nodes t1 and t2 must have Boolean sort.

val mk_implies : context -> ast -> ast -> ast
Summary: [ mk_implies c t1 t2 ] Create an AST node representing t1 implies t2 .

The nodes t1 and t2 must have Boolean sort.

val mk_xor : context -> ast -> ast -> ast
Summary: [ mk_xor c t1 t2 ] Create an AST node representing t1 xor t2 .

The nodes t1 and t2 must have Boolean sort.

val mk_and : context -> ast array -> ast
Summary: [ mk_and c [| t_1; ...; t_n |] ] Create the conjunction: t_1 and ... and t_n.

All arguments must have Boolean sort.


val mk_or : context -> ast array -> ast
Summary: [ mk_or c [| t_1; ...; t_n |] ] Create the disjunction: t_1 or ... or t_n.

All arguments must have Boolean sort.


val mk_add : context -> ast array -> ast
Summary: [ mk_add c [| t_1; ...; t_n |] ] Create the term: t_1 + ... + t_n.

All arguments must have int or real sort.


val mk_mul : context -> ast array -> ast
Summary: [ mk_mul c [| t_1; ...; t_n |] ] Create the term: t_1 * ... * t_n.

All arguments must have int or real sort.


val mk_sub : context -> ast array -> ast
Summary: [ mk_sub c [| t_1; ...; t_n |] ] Create the term: t_1 - ... - t_n.

All arguments must have int or real sort.


val mk_unary_minus : context -> ast -> ast
Summary: [ mk_unary_minus c arg ] Create the term: - arg.

The argument must have int or real type.

val mk_div : context -> ast -> ast -> ast
Summary: [ 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.

val mk_mod : context -> ast -> ast -> ast
Summary: [ mk_mod c t_1 t_2 ] Create the term: t_1 mod t_2.

The arguments must have int type.

val mk_rem : context -> ast -> ast -> ast
Summary: [ mk_rem c t_1 t_2 ] Create the term: t_1 rem t_2.

The arguments must have int type.

val mk_lt : context -> ast -> ast -> ast
Summary: [ mk_lt c t1 t2 ] Create less than.

The nodes t1 and t2 must have the same sort, and must be int or real.

val mk_le : context -> ast -> ast -> ast
Summary: [ 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.

val mk_gt : context -> ast -> ast -> ast
Summary: [ mk_gt c t1 t2 ] Create greater than.

The nodes t1 and t2 must have the same sort, and must be int or real.

val mk_ge : context -> ast -> ast -> ast
Summary: [ 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.

val mk_int2real : context -> ast -> ast
Summary: [ 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.

val mk_bvnot : context -> ast -> ast
Summary: [ mk_bvneg c t1 ] Bitwise negation.

The node t1 must have a bit-vector sort.

val mk_bvand : context -> ast -> ast -> ast
Summary: [ mk_bvand c t1 t2 ] Bitwise and.

The nodes t1 and t2 must have the same bit-vector sort.

val mk_bvor : context -> ast -> ast -> ast
Summary: [ mk_bvor c t1 t2 ] Bitwise or.

The nodes t1 and t2 must have the same bit-vector sort.

val mk_bvxor : context -> ast -> ast -> ast
Summary: [ mk_bvxor c t1 t2 ] Bitwise exclusive-or.

The nodes t1 and t2 must have the same bit-vector sort.

val mk_bvnand : context -> ast -> ast -> ast
Summary: [ mk_bvnand c t1 t2 ] Bitwise nand.

The nodes t1 and t2 must have the same bit-vector sort.

val mk_bvnor : context -> ast -> ast -> ast
Summary: [ mk_bvnor c t1 t2 ] Bitwise nor.

The nodes t1 and t2 must have the same bit-vector sort.

val mk_bvxnor : context -> ast -> ast -> ast
Summary: [ mk_bvxnor c t1 t2 ] Bitwise xnor.

The nodes t1 and t2 must have the same bit-vector sort.

val mk_bvneg : context -> ast -> ast
Summary: [ mk_bvneg c t1 ] Standard two's complement unary minus.

The node t1 must have bit-vector sort.

val mk_bvadd : context -> ast -> ast -> ast
Summary: [ mk_bvadd c t1 t2 ] Standard two's complement addition.

The nodes t1 and t2 must have the same bit-vector sort.

val mk_bvsub : context -> ast -> ast -> ast
Summary: [ mk_bvsub c t1 t2 ] Standard two's complement subtraction.

The nodes t1 and t2 must have the same bit-vector sort.

val mk_bvmul : context -> ast -> ast -> ast
Summary: [ mk_bvmul c t1 t2 ] Standard two's complement multiplication.

The nodes t1 and t2 must have the same bit-vector sort.

val mk_bvudiv : context -> ast -> ast -> ast
Summary: [ 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.

val mk_bvsdiv : context -> ast -> ast -> ast
Summary: [ mk_bvsdiv c t1 t2 ] Two's complement signed division.

It is defined in the following way:

If t2 is zero, then the result is undefined.

The nodes t1 and t2 must have the same bit-vector sort.

val mk_bvurem : context -> ast -> ast -> ast
Summary: [ 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.

val mk_bvsrem : context -> ast -> ast -> ast
Summary: [ 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.


val mk_bvsmod : context -> ast -> ast -> ast
Summary: [ 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.


val mk_bvult : context -> ast -> ast -> ast
Summary: [ mk_bvult c t1 t2 ] Unsigned less than.

The nodes t1 and t2 must have the same bit-vector sort.

val mk_bvslt : context -> ast -> ast -> ast
Summary: [ 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.

val mk_bvule : context -> ast -> ast -> ast
Summary: [ mk_bvule c t1 t2 ] Unsigned less than or equal to.

The nodes t1 and t2 must have the same bit-vector sort.

val mk_bvsle : context -> ast -> ast -> ast
Summary: [ 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.

val mk_bvuge : context -> ast -> ast -> ast
Summary: [ mk_bvuge c t1 t2 ] Unsigned greater than or equal to.

The nodes t1 and t2 must have the same bit-vector sort.

val mk_bvsge : context -> ast -> ast -> ast
Summary: [ 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.

val mk_bvugt : context -> ast -> ast -> ast
Summary: [ mk_bvugt c t1 t2 ] Unsigned greater than.

The nodes t1 and t2 must have the same bit-vector sort.

val mk_bvsgt : context -> ast -> ast -> ast
Summary: [ mk_bvsgt c t1 t2 ] Two's complement signed greater than.

The nodes t1 and t2 must have the same bit-vector sort.

val mk_concat : context -> ast -> ast -> ast
Summary: [ 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).

val mk_extract : context -> int -> int -> ast -> ast
Summary: [ 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.

val mk_sign_ext : context -> int -> ast -> ast
Summary: [ 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.

val mk_zero_ext : context -> int -> ast -> ast
Summary: [ 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.

val mk_bvshl : context -> ast -> ast -> ast
Summary: [ 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.

val mk_bvlshr : context -> ast -> ast -> ast
Summary: [ 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.

val mk_bvashr : context -> ast -> ast -> ast
Summary: [ 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.

val mk_rotate_left : context -> int -> ast -> ast
Summary: [ mk_rotate_left c i t1 ] Rotate bits of t1 to the left i times.

The node t1 must have a bit-vector sort.

val mk_rotate_right : context -> int -> ast -> ast
Summary: [ mk_rotate_right c i t1 ] Rotate bits of t1 to the right i times.

The node t1 must have a bit-vector sort.

val mk_int2bv : context -> int -> ast -> ast
Summary: [ 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.

val mk_bv2int : context -> ast -> bool -> ast
Summary: [ 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.

val mk_bvadd_no_overflow : context -> ast -> ast -> bool -> ast
Summary: [ 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.

val mk_bvadd_no_underflow : context -> ast -> ast -> ast
Summary: [ 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.

val mk_bvsub_no_overflow : context -> ast -> ast -> ast
Summary: [ 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.

val mk_bvsub_no_underflow : context -> ast -> ast -> bool -> ast
Summary: [ 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.

val mk_bvsdiv_no_overflow : context -> ast -> ast -> ast
Summary: [ 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.

val mk_bvneg_no_overflow : context -> ast -> ast
Summary: [ 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.

val mk_bvmul_no_overflow : context -> ast -> ast -> bool -> ast
Summary: [ 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.

val mk_bvmul_no_underflow : context -> ast -> ast -> ast
Summary: [ 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.

val mk_select : context -> ast -> ast -> ast
Summary: [ 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.


val mk_store : context -> ast -> ast -> ast -> ast
Summary: [ 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 .


val mk_const_array : context -> sort -> ast -> ast
Summary: Create the constant array.
val mk_map : context -> func_decl -> int -> ast -> ast
Summary: [ 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 .


val mk_array_default : context -> ast -> ast
Summary: Access the array default value. Produces the default range value, for arrays that can be represented as finite maps with a default range value.


Numerals


val mk_numeral : context -> string -> sort -> ast
Summary: Create a numeral of a given sort.


val mk_real : context -> int -> int -> ast
Summary: Create a real from a fraction.


val mk_int : context -> int -> sort -> ast
Summary: Create a numeral of a given sort.

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.


val mk_unsigned_int : context -> int -> sort -> ast
Summary: Create a numeral of a given sort.

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.




Quantifiers


val mk_pattern : context -> ast array -> pattern
Summary: Create a pattern for quantifier instantiation.

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

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

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


val mk_bound : context -> int -> sort -> ast
Summary: Create a bound variable.

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


val mk_forall : context ->
int ->
pattern array -> sort array -> symbol array -> ast -> ast
Summary: Create a forall formula.

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.


val mk_exists : context ->
int ->
pattern array -> sort array -> symbol array -> ast -> ast
Summary: Create an exists formula. Similar to Z3.mk_forall.


val mk_quantifier : context ->
bool ->
int ->
pattern array -> sort array -> symbol array -> ast -> ast
Summary: Create a quantifier - universal or existential, with pattern hints.


val mk_forall_const : context -> int -> app array -> pattern array -> ast -> ast
Summary: Create a universal quantifier using a list of constants that will form the set of bound variables.

the quantifier during instantiation. By default, pass the weight 0.


val mk_exists_const : context -> int -> app array -> pattern array -> ast -> ast
Summary: Similar to Z3.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.




Accessors


val get_symbol_kind : context -> symbol -> symbol_kind
Summary: Return INT_SYMBOL if the symbol was constructed using Z3.mk_int_symbol, and STRING_SYMBOL if the symbol was constructed using Z3.mk_string_symbol.
val get_symbol_int : context -> symbol -> int
Summary: [ get_symbol_int c s ] Return the symbol int value.


val get_symbol_string : context -> symbol -> string
Summary: [ get_symbol_string c s ] Return the symbol name.


val get_ast_kind : context -> ast -> ast_kind
Summary: Return the kind of the given AST.
val get_numeral_string : context -> ast -> string
Summary: Return numeral value, as a string of a numeric constant term


val get_numeral_small : context -> ast -> bool * int64 * int64
Summary: Return numeral value, as a pair of 64 bit numbers if the representation fits.

Preturn TRUE if the numeral value fits in 64 bit numerals, FALSE otherwise.


val get_numeral_int : context -> ast -> bool * int
Summary: [ 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.


val get_numeral_uint : context -> ast -> bool * int
Summary: [ 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.


val get_bool_value : context -> ast -> lbool
Summary: Return L_TRUE if a is true, L_FALSE if it is false, and L_UNDEF otherwise.
val get_app_decl : context -> app -> func_decl
Summary: Return the declaration of a constant or function application.
val get_app_num_args : context -> app -> int
Summary: [ 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.
val get_app_arg : context -> app -> int -> ast
Summary: [ get_app_arg c a i ] Return the i-th argument of the given application.


val get_index_value : context -> ast -> int
Summary: Return index of de-Brujin bound variable.


val is_quantifier_forall : context -> ast -> bool
Summary: Determine if quantifier is universal.


val get_quantifier_weight : context -> ast -> int
Summary: Obtain weight of quantifier.


val get_quantifier_num_patterns : context -> ast -> int
Summary: Return number of patterns used in quantifier.


val get_quantifier_pattern_ast : context -> ast -> int -> pattern
Summary: Return i'th pattern.


val get_quantifier_bound_name : context -> ast -> int -> symbol
Summary: Return symbol of the i'th bound variable.


val get_quantifier_bound_sort : context -> ast -> int -> sort
Summary: Return sort of the i'th bound variable.


val get_quantifier_body : context -> ast -> ast
Summary: Return body of quantifier.


val get_quantifier_num_bound : context -> ast -> int
Summary: Return number of bound variables of quantifier.


val get_decl_name : context -> func_decl -> symbol
Summary: Return the constant declaration name as a symbol.
val get_decl_num_parameters : context -> func_decl -> int
Summary: Return the number of parameters associated with a declaration.
val get_decl_parameter_kind : context -> func_decl -> int -> parameter_kind
Summary: Return the parameter type associated with a declaration.
val get_decl_int_parameter : context -> func_decl -> int -> int
Summary: Return the integer value associated with an integer parameter.


val get_decl_double_parameter : context -> func_decl -> int -> float
Summary: Return the double value associated with an double parameter.


val get_decl_symbol_parameter : context -> func_decl -> int -> symbol
Summary: Return the double value associated with an double parameter.


val get_decl_sort_parameter : context -> func_decl -> int -> sort
Summary: Return the sort value associated with a sort parameter.


val get_decl_ast_parameter : context -> func_decl -> int -> ast
Summary: Return the expresson value associated with an expression parameter.


val get_decl_func_decl_parameter : context -> func_decl -> int -> func_decl
Summary: Return the expresson value associated with an expression parameter.


val get_decl_rational_parameter : context -> func_decl -> int -> string
Summary: Return the rational value, as a string, associated with a rational parameter.


val get_sort_name : context -> sort -> symbol
Summary: Return the sort name as a symbol.
val get_sort : context -> ast -> sort
Summary: Return the sort of an AST node.

The AST node must be a constant, application, numeral, bound variable, or quantifier.

val get_domain_size : context -> func_decl -> int
Summary: Return the number of parameters of the given declaration.


val get_domain : context -> func_decl -> int -> sort
Summary: [ get_domain c d i ] Return the sort of the i-th parameter of the given function declaration.


val get_range : context -> func_decl -> sort
Summary: [ 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.

val get_sort_kind : context -> sort -> sort_kind
Summary: Return the sort kind (e.g., array, tuple, int, bool, etc).


val get_bv_sort_size : context -> sort -> int
Summary: [ get_bv_sort_size c t ] Return the size of the given bit-vector sort.


val get_array_sort_domain : context -> sort -> sort
Summary: [ get_array_sort_domain c t ] Return the domain of the given array sort.


val get_array_sort_range : context -> sort -> sort
Summary: [ get_array_sort_range c t ] Return the range of the given array sort.


val get_tuple_sort_mk_decl : context -> sort -> func_decl
Summary: [ get_tuple_sort_mk_decl c t ] Return the constructor declaration of the given tuple sort.


val get_decl_kind : context -> func_decl -> decl_kind
Summary: Return declaration kind corresponding to declaration.
val get_tuple_sort_num_fields : context -> sort -> int
Summary: [ get_tuple_sort_num_fields c t ] Return the number of fields of the given tuple sort.


val get_tuple_sort_field_decl : context -> sort -> int -> func_decl
Summary: [ get_tuple_sort_field_decl c t i ] Return the i-th field declaration (i.e., projection function declaration) of the given tuple sort.


val get_datatype_sort_num_constructors : context -> sort -> int
Summary: Return number of constructors for datatype.


val get_datatype_sort_constructor : context -> sort -> int -> func_decl
Summary: Return idx'th constructor.


val get_datatype_sort_recognizer : context -> sort -> int -> func_decl
Summary: Return idx'th recognizer.


val get_datatype_sort_constructor_accessor : context -> sort -> int -> int -> func_decl
Summary: Return idx_a'th accessor for the idx_c'th constructor.


val get_pattern_num_terms : context -> pattern -> int
Summary: Return number of terms in pattern.
val get_pattern : context -> pattern -> int -> ast
Summary: Return i'th ast in pattern.
val simplify : context -> ast -> ast
Summary: Interface to simplifier.

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


val app_to_ast : context -> app -> ast
Summary: Convert a APP_AST into an AST. This is just type casting.
val to_app : context -> ast -> app
Summary: Convert an AST into a APP_AST. This is just type casting.




Constraints


val push : context -> unit
Summary: Create a backtracking point.

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.


val pop : context -> int -> unit
Summary: Backtrack.

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.


val persist_ast : context -> ast -> int -> unit
Summary: Persist AST through num_scopes pops.

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.

val assert_cnstr : context -> ast -> unit
Summary: Assert a constraing into the logical context.

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.


val check_and_get_model : context -> lbool * model
Summary: Check whether the given logical context is consistent or not.

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.


val check : context -> lbool
Summary: Check whether the given logical context is consistent or not.

The function Z3.check_and_get_model should be used when models are needed.


val check_assumptions : context ->
ast array ->
int -> ast array -> lbool * model * ast * int * ast array
Summary: Check whether the given logical context and optional assumptions is consistent or not.

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.

The unsatisfiable core is a subset of the assumptions, so the array has the same size as the assumptions. The core array is not populated if core_size is set to 0.


val get_implied_equalities : context -> ast array -> lbool * int array
Summary: Retrieve congruence class representatives for terms.

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


val del_model : context -> model -> unit
Summary: Delete a model object.




Search control.


val soft_check_cancel : context -> unit
Summary: Cancel an ongoing check.

Notifies the current check to abort and return. This method should be called from a different thread than the one performing the check.

val get_search_failure : context -> search_failure
Summary: Retrieve reason for search failure.

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.


val get_relevant_labels : context -> literals
Summary: Retrieve the set of labels that were relevant in the context of the current satisfied context.


val get_relevant_literals : context -> literals
Summary: Retrieve the set of literals that satisfy the current context.


val get_guessed_literals : context -> literals
Summary: Retrieve the set of literals that whose assignment were guess, but not propagated during the search.


val del_literals : context -> literals -> unit
Summary: Delete a labels context.


val get_num_literals : context -> literals -> int
Summary: Retrieve the number of label symbols that were returned.


val get_label_symbol : context -> literals -> int -> symbol
Summary: Retrieve label symbol at idx.
val get_literal : context -> literals -> int -> ast
Summary: Retrieve literal expression at idx.
val disable_literal : context -> literals -> int -> unit
Summary: Disable label.

The disabled label is not going to be used when blocking the subsequent search.


val block_literals : context -> literals -> unit
Summary: Block subsequent checks using the remaining enabled labels.


Model navigation


val get_model_num_constants : context -> model -> int
Summary: Return the number of constants assigned by the given model.


val get_model_constant : context -> model -> int -> func_decl
Summary: [ get_model_constant c m i ] Return the i-th constant in the given model.


val eval_func_decl : context -> model -> func_decl -> bool * ast
Summary: Return the value of the given constant or function in the given model.
val is_array_value : context -> ast -> bool * int
Summary: [ 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.
val get_array_value : context ->
ast ->
ast array -> ast array -> ast array * ast array * ast
Summary: [ get_array_value c v ] An array values is represented as a dictionary plus a default (else) value. This function returns the array graph.


val get_model_num_funcs : context -> model -> int
Summary: Return the number of function interpretations in the given model.

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.


val get_model_func_decl : context -> model -> int -> func_decl
Summary: [ get_model_func_decl c m i ] Return the declaration of the i-th function in the given model.


val get_model_func_else : context -> model -> int -> ast
Summary: [ 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.


val get_model_func_num_entries : context -> model -> int -> int
Summary: [ 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.


val get_model_func_entry_num_args : context -> model -> int -> int -> int
Summary: [ 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.


val get_model_func_entry_arg : context -> model -> int -> int -> int -> ast
Summary: [ 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.


val get_model_func_entry_value : context -> model -> int -> int -> ast
Summary: [ 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.


val eval : context -> model -> ast -> bool * ast
Summary: [ 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:


val eval_decl : context -> model -> func_decl -> ast array -> bool * ast
Summary: Evaluate declaration given values.

Provides direct way to evaluate declarations without going over terms.



Interaction logging.


val open_log : context -> string -> bool
Summary: Log interaction to a file.
val close_log : context -> unit
Summary: Close interaction log.


String conversion


val set_ast_print_mode : context -> ast_print_mode -> unit
Summary: Select mode for the format used for pretty-printing AST nodes.

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.


val ast_to_string : context -> ast -> string
Summary: Convert the given AST node into a string.


val pattern_to_string : context -> pattern -> string
val sort_to_string : context -> sort -> string
val func_decl_to_string : context -> func_decl -> string
val model_to_string : context -> model -> string
Summary: Convert the given model into a string.
val benchmark_to_smtlib_string : context ->
string -> string -> string -> string -> ast array -> ast -> string
Summary: Convert the given benchmark into SMT-LIB formatted string.
val context_to_string : context -> string
Summary: Convert the given logical context into a string.

This function is mainly used for debugging purposes. It displays the internal structure of a logical context.

val get_context_assignment : context -> ast
Summary: Extract satisfying assignment from context as a conjunction.

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


val parse_smtlib_string : context ->
string ->
symbol array ->
sort array -> symbol array -> func_decl array -> unit
Summary: [ 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.

val parse_smtlib_file : context ->
string ->
symbol array ->
sort array -> symbol array -> func_decl array -> unit
Summary: Similar to Z3.parse_smtlib_string, but reads the benchmark from a file.
val get_smtlib_num_formulas : context -> int
Summary: Return the number of SMTLIB formulas parsed by the last call to Z3.parse_smtlib_string or Z3.parse_smtlib_file.
val get_smtlib_formula : context -> int -> ast
Summary: [ 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.


val get_smtlib_num_assumptions : context -> int
Summary: Return the number of SMTLIB assumptions parsed by Z3.parse_smtlib_string or Z3.parse_smtlib_file.
val get_smtlib_assumption : context -> int -> ast
Summary: [ 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.


val get_smtlib_num_decls : context -> int
Summary: Return the number of declarations parsed by Z3.parse_smtlib_string or Z3.parse_smtlib_file.
val get_smtlib_decl : context -> int -> func_decl
Summary: [ 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.


val get_smtlib_num_sorts : context -> int
Summary: Return the number of sorts parsed by Z3.parse_smtlib_string or Z3.parse_smtlib_file.
val get_smtlib_sort : context -> int -> sort
Summary: [ 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.


val get_smtlib_error : context -> string
Summary: [ get_smtlib_error c ] Retrieve that last error message information generated from parsing.
val parse_z3_string : context -> string -> ast
Summary: [ parse_z3_string c str ] Parse the given string using the Z3 native parser.

Return the conjunction of asserts made in the input.

val parse_z3_file : context -> string -> ast
Summary: Similar to Z3.parse_z3_string, but reads the benchmark from a file.


Miscellaneous


val get_version : unit -> int * int * int * int
Summary: Return Z3 version number information.
val reset_memory : unit -> unit
Summary: Reset all allocated resources.

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


val mk_context_x : (string * string) array -> context
[ mk_context_x configs ] is a shorthand for the context with configurations in configs.
val get_app_args : context -> app -> ast array
[ get_app_args c a ] is the array of arguments of an application. If t is a constant, then the array is empty.


val get_domains : context -> func_decl -> sort array
[ get_app_args c d ] is the array of parameters of d.


val get_array_sort : context -> sort -> sort * sort
[ get_array_sort c t ] is the domain and the range of t.


val get_tuple_sort : context -> sort -> func_decl * func_decl array
[ 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.



type datatype_constructor_refined = {
   constructor : func_decl;
   recognizer : func_decl;
   accessors : func_decl array;
}
[ 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.



val get_datatype_sort : context -> sort -> datatype_constructor_refined array
val get_model_constants : context -> model -> func_decl array
[ get_model_constants c m ] is the array of constants in the model m.


val get_model_func_entry : context -> model -> int -> int -> ast array * ast
[ get_model_func_entry c m i j ] is the j'th entry in the i'th function in the model m.


val get_model_func_entries : context -> model -> int -> (ast array * ast) array
[ get_model_func_entries c m i ] is the array of entries in the i'th function in the model m.


val get_model_funcs : context ->
model -> (symbol * (ast array * ast) array * ast) array
[ 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.


val get_smtlib_formulas : context -> ast array
[ 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.


val get_smtlib_assumptions : context -> ast array
[ get_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.


val get_smtlib_decls : context -> func_decl array
[ 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.


val get_smtlib_parse_results : context -> ast array * ast array * func_decl array
[ 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.


val parse_smtlib_string_formula : context ->
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.


val parse_smtlib_file_formula : context ->
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.


val parse_smtlib_string_x : context ->
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.


val parse_smtlib_file_x : context ->
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.



type symbol_refined =
| Symbol_int of int
| Symbol_string of string
| Symbol_unknown
[ symbol_refined ] is the refinement of a Z3.symbol .


val symbol_refine : context -> symbol -> symbol_refined
[ symbol_refine c s ] is the refined symbol of s.



[ sort_refined ] is the refinement of a Z3.sort .




type sort_refined =
| Sort_uninterpreted of symbol
| Sort_bool
| Sort_int
| Sort_real
| Sort_bv of int
| Sort_array of (sort * sort)
| Sort_datatype of datatype_constructor_refined array
| Sort_unknown of symbol
val sort_refine : context -> sort -> sort_refined
[ sort_refine c t ] is the refined sort of t.



type binder_type =
| Forall
| Exists
[ binder_type ] is a universal or existential quantifier.



type numeral_refined =
| Numeral_small of (int64 * int64)
| Numeral_large of string
[ numeral_refined ] is the refinement of a numeral .

Numerals whose fractional representation can be fit with 64 bit integers are treated as small.


type term_refined =
| Term_app of (decl_kind * func_decl * ast array)
| Term_quantifier of (binder_type * int * ast array array * (symbol * sort) array
* ast)
| Term_numeral of (numeral_refined * sort)
| Term_var of (int * sort)
[ term_refined ] is the refinement of a Z3.ast .


val term_refine : context -> ast -> term_refined
[ term_refine c a ] is the refined term of a.