Safe Handle & Context API Reference (Z3 5.3.3)¶
This reference covers all 29 safe RAII handle structs and 769 C-API bindings generated directly from api/z3-api.json for Z3 5.3.3. For Pythonic free functions, operators, and callback traits, see Pythonic API. For direct 1-to-1 Z3_* C functions, see Low-Level C API.
Handle Types & Ownership¶
| Mojo Struct | Z3 C Handle | Ownership | Destructor / Refcount |
|---|---|---|---|
App |
Z3_app |
context_managed |
Owned by Context (Z3_del_context) |
ApplyResult |
Z3_apply_result |
refcounted |
Z3_apply_result_inc_ref / Z3_apply_result_dec_ref |
Ast |
Z3_ast |
context_managed |
Owned by Context (Z3_del_context) |
AstMap |
Z3_ast_map |
refcounted |
Z3_ast_map_inc_ref / Z3_ast_map_dec_ref |
AstVector |
Z3_ast_vector |
refcounted |
Z3_ast_vector_inc_ref / Z3_ast_vector_dec_ref |
Config |
Z3_config |
explicit_del |
Z3_del_config |
Constructor |
Z3_constructor |
explicit_del |
Z3_del_constructor |
ConstructorList |
Z3_constructor_list |
explicit_del |
Z3_del_constructor_list |
Context |
Z3_context |
explicit_del |
Z3_del_context |
Fixedpoint |
Z3_fixedpoint |
refcounted |
Z3_fixedpoint_inc_ref / Z3_fixedpoint_dec_ref |
FuncDecl |
Z3_func_decl |
context_managed |
Owned by Context (Z3_del_context) |
FuncEntry |
Z3_func_entry |
refcounted |
Z3_func_entry_inc_ref / Z3_func_entry_dec_ref |
FuncInterp |
Z3_func_interp |
refcounted |
Z3_func_interp_inc_ref / Z3_func_interp_dec_ref |
Goal |
Z3_goal |
refcounted |
Z3_goal_inc_ref / Z3_goal_dec_ref |
Model |
Z3_model |
refcounted |
Z3_model_inc_ref / Z3_model_dec_ref |
Optimize |
Z3_optimize |
refcounted |
Z3_optimize_inc_ref / Z3_optimize_dec_ref |
ParamDescrs |
Z3_param_descrs |
refcounted |
Z3_param_descrs_inc_ref / Z3_param_descrs_dec_ref |
Params |
Z3_params |
refcounted |
Z3_params_inc_ref / Z3_params_dec_ref |
ParserContext |
Z3_parser_context |
refcounted |
Z3_parser_context_inc_ref / Z3_parser_context_dec_ref |
Pattern |
Z3_pattern |
context_managed |
Owned by Context (Z3_del_context) |
Probe |
Z3_probe |
refcounted |
Z3_probe_inc_ref / Z3_probe_dec_ref |
RcfNum |
Z3_rcf_num |
explicit_del |
Z3_rcf_del |
Simplifier |
Z3_simplifier |
refcounted |
Z3_simplifier_inc_ref / Z3_simplifier_dec_ref |
Solver |
Z3_solver |
refcounted |
Z3_solver_inc_ref / Z3_solver_dec_ref |
SolverCallback |
Z3_solver_callback |
borrowed |
Borrowed inside Z3 callback |
Sort |
Z3_sort |
context_managed |
Owned by Context (Z3_del_context) |
Stats |
Z3_stats |
refcounted |
Z3_stats_inc_ref / Z3_stats_dec_ref |
Symbol |
Z3_symbol |
context_managed |
Owned by Context (Z3_del_context) |
Tactic |
Z3_tactic |
refcounted |
Z3_tactic_inc_ref / Z3_tactic_dec_ref |
Global Functions¶
Re-exported at the package root (from z3_mojo import ...).
append_log¶
def append_log(string: String) raises
Append user-defined string to interaction log.
The interaction log is opened using Z3_open_log. It contains the formulas that are checked using Z3. You can use this command to append comments, for instance.
close_log¶
def close_log() raises
Close interaction log.
disable_trace¶
def disable_trace(tag: String) raises
Disable tracing messages tagged as tag when Z3 is compiled in debug mode. It is a NOOP otherwise
enable_trace¶
def enable_trace(tag: String) raises
Enable tracing messages tagged as tag when Z3 is compiled in debug mode. It is a NOOP otherwise
finalize_memory¶
def finalize_memory() raises
Destroy all allocated resources.
Any pointers previously returned by the API become invalid. Can be used for memory leak detection.
get_estimated_alloc_size¶
def get_estimated_alloc_size() raises -> UInt64
Return the estimated allocated memory in bytes.
get_full_version¶
def get_full_version() raises -> String
Return a string that fully describes the version of Z3 in use.
get_version¶
def get_version() raises -> Tuple[UInt32, UInt32, UInt32, UInt32]
Return Z3 version number information.
global_param_get¶
def global_param_get(param_id: String) raises -> Optional[String]
Get a global (or module) parameter.
Returns false if the parameter value does not exist.
global_param_reset_all¶
def global_param_reset_all() raises
Restore the value of all global (and module) parameters. This command will not affect already created objects (such as tactics and solvers).
global_param_set¶
def global_param_set(param_id: String, param_value: String) raises
Set a global (or module) parameter. This setting is shared by all Z3 contexts.
When a Z3 module is initialized it will use the value of these parameters when Z3_params objects are not provided.
The name of parameter can be composed of characters [a-z][A-Z], digits [0-9], '-' and '_'. The character '.' is a delimiter (more later).
The parameter names are case-insensitive. The character '-' should be viewed as an "alias" for '_'. Thus, the following parameter names are considered equivalent: "pp.decimal-precision" and "PP.DECIMAL_PRECISION".
This function can be used to set parameters for a specific Z3 module. This can be done by using <module-name>.<parameter-name>. For example: Z3_global_param_set('pp.decimal', 'true') will set the parameter "decimal" in the module "pp" to true.
open_log¶
def open_log(filename: String) raises -> Bool
Log interaction to a file.
reset_memory¶
def reset_memory() raises
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.
toggle_warning_messages¶
def toggle_warning_messages(enabled: Bool) raises
Enable/disable printing warning messages to the console.
Warnings are printed after passing true, warning messages are suppressed after calling this method with false.
Context¶
var ctx = Context()
var x = ctx.mk_int_const("x")
var f = ctx.mk_eq(ctx.mk_add(x, ctx.mk_int(1)), ctx.mk_int(5))
Commonly used Context methods:
| Method | Purpose |
|---|---|
int_sort |
Create the integer type. |
real_sort |
Create the real type. |
bool_sort |
Create the Boolean type. |
bv_sort |
Create a bit-vector type of the given size. |
string_sort |
Create a sort for unicode strings. |
mk_int_const |
Create an Int constant (variable) named name. |
mk_real_const |
Create a Real constant (variable) named name. |
mk_const |
Declare and create a constant. |
mk_add |
Create an AST node representing args[0] + ... + args[num_args-1]. |
mk_and |
Create an AST node representing args[0] and ... and args[num_args-1]. |
mk_eq |
Create an AST node representing l = r. |
mk_ite |
Create an AST node representing an if-then-else: ite(t1, t2, t3). |
mk_forall |
Create a universal quantifier using a list of constants that will form the set of bound variables. |
mk_bvadd |
Standard two's complement addition. |
mk_select |
Array read. The argument a is the array and i is the index of the array that gets read. |
mk_store |
Array update. |
mk_seq_concat |
Concatenate sequences. |
Exposes 510 Z3 C API bindings plus 9 ergonomic Mojo helpers, organized by Z3 topic group:
Convenience Constructors & Helpers (9) Context and AST Reference Counting (5) Symbols (2) Sorts (29) Constants and Applications (7) Propositional Logic and Equality (11) Integers and Reals (17) Bit-vectors (49) Arrays (8) Sets (12) Finite Sets (14) Numerals (8) Sequences and regular expressions (69) Special relations (5) Quantifiers (12) Accessors (102) Modifiers (5) Models (5) String conversion (6) Parser interface (4) Error Handling (3) Tactics, Simplifiers and Probes (19) Solvers (3) AST vectors (1) AST maps (1) Floating-Point Arithmetic (61) Z3-specific floating-point extensions (20) Algebraic Numbers (21) Polynomials (1) Real Closed Fields (5) Fixedpoint facilities (1) Spacer facilities (4)
Convenience Constructors & Helpers (9)¶
from_config¶
def from_config(cfg: Config) raises -> Context
Create a Context from an explicit Config.
mk_bool¶
def mk_bool(self, val: Bool) raises -> Ast
Create a Boolean literal (true or false) from val.
mk_bool_const¶
def mk_bool_const(self, name: String) raises -> Ast
Create a Bool constant (variable) named name.
mk_bv¶
def mk_bv(self, val: Int, width: Int) raises -> Ast
Create a BitVec numeral of bit-width width from Int.
mk_bv_const¶
def mk_bv_const(self, name: String, width: Int) raises -> Ast
Create a BitVec constant (variable) of bit-width width named name.
mk_int_const¶
def mk_int_const(self, name: String) raises -> Ast
Create an Int constant (variable) named name.
mk_integer¶
def mk_integer(self, val: Integer) raises -> Ast
Create an arbitrary-precision Int numeral from apn_mojo.Integer.
mk_real_const¶
def mk_real_const(self, name: String) raises -> Ast
Create a Real constant (variable) named name.
version¶
def version(self) raises -> String
Return the full Z3 version string (Z3_get_full_version).
Context and AST Reference Counting (5)¶
__init__¶
def __init__(out self) raises
Create a context using the given configuration.
After a context is created, the configuration cannot be changed, although some parameters can be changed using Z3_update_param_value. All main interaction with Z3 happens in the context of a Z3_context.
In contrast to Z3_mk_context_rc the life time of Z3_ast objects persists with the life time of the context.
Note that all other reference counted objects, including Z3_model, Z3_solver, Z3_func_interp have to be managed by the caller. Their reference counts are not handled by the context.
enable_concurrent_dec_ref¶
def enable_concurrent_dec_ref(self) raises
use concurrency control for dec-ref. Reference counting decrements are allowed in separate threads from the context. If this setting is not invoked, reference counting decrements are not going to be thread safe.
get_global_param_descrs¶
def get_global_param_descrs(self) raises -> ParamDescrs
Retrieve description of global parameters.
interrupt¶
def interrupt(self) raises
Interrupt the execution of a Z3 procedure. This procedure can be used to interrupt: solvers, simplifiers and tactics.
update_param¶
def update_param(self, key: String, val: String) raises
Set a value of a context parameter.
Symbols (2)¶
mk_int_symbol¶
def mk_int_symbol(self, i: Int) raises -> Symbol
Create a Z3 symbol using an integer.
Symbols are used to name several term and type constructors.
NB. Not all integers can be passed to this function. The legal range of unsigned integers is 0 to 2^30-1.
mk_symbol¶
def mk_symbol(self, name: String) raises -> Symbol
Create a Z3 symbol using a C string.
Symbols are used to name several term and type constructors.
Sorts (29)¶
array_sort¶
def array_sort(self, domain: Sort, range_: Sort) raises -> Sort
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.
bool_sort¶
def bool_sort(self) raises -> Sort
Create the Boolean type.
This type is used to create propositional variables and predicates.
bv_sort¶
def bv_sort(self, width: Int) raises -> Sort
Create a bit-vector type of the given size.
This type can also be seen as a machine integer.
get_finite_field_sort_size¶
def get_finite_field_sort_size(self, s: Sort) raises -> String
Return the decimal modulus of a finite-field sort.
int_sort¶
def int_sort(self) raises -> Sort
Create the 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.
mk_array_sort_n¶
def mk_array_sort_n(self, domain: List[Sort], range_: Sort) raises -> Sort
Create an array type with N arguments
mk_complex¶
def mk_complex(self, re: Ast, im: Ast) raises -> Ast
Create a complex number with the given real and imaginary components. Integer components are coerced to Real.
mk_complex_sort¶
def mk_complex_sort(self) raises -> Sort
Create the Complex sort. Complex numbers are pairs of Reals.
Use Z3_mk_complex to construct values and Z3_mk_real_part and Z3_mk_imag_part to access their components. The arithmetic APIs for addition, subtraction, multiplication, negation, and division accept Complex expressions. Ordering and exponentiation do not.
mk_constructor¶
def mk_constructor(self, name: Symbol, recognizer: Symbol, field_names: List[Symbol], sorts: List[Sort], sort_refs: List[UInt32]) raises -> Constructor
Create a constructor.
mk_constructor_list¶
def mk_constructor_list(self, constructors: List[Constructor]) raises -> ConstructorList
Create list of constructors.
mk_datatype¶
def mk_datatype(self, name: Symbol, constructors: List[Constructor]) raises -> Sort
Create datatype, such as lists, trees, records, enumerations or unions of records. The datatype may be recursive. Return the datatype sort.
mk_datatype_sort¶
def mk_datatype_sort(self, name: Symbol, params: List[Sort]) raises -> Sort
create a forward reference to a recursive datatype being declared. The forward reference can be used in a nested occurrence: the range of an array or as element sort of a sequence. The forward reference should only be used when used in an accessor for a recursive datatype that gets declared.
Forward references can replace the use sort references, that are unsigned integers in the Z3_mk_constructor call
mk_datatypes¶
def mk_datatypes(self, sort_names: List[Symbol], constructor_lists: List[ConstructorList]) raises -> List[Sort]
Create mutually recursive datatypes.
mk_enumeration_sort¶
def mk_enumeration_sort(self, name: Symbol, enum_names: List[Symbol]) raises -> Tuple[Sort, List[FuncDecl], List[FuncDecl]]
Create a enumeration sort.
An enumeration sort with n elements. This function will also declare the functions corresponding to the enumerations.
For example, if this function is called with three symbols A, B, C and the name S, then s is a sort whose name is S, and the function returns three terms corresponding to A, B, C in enum_consts. The array enum_testers has three predicates of type (s -> Bool). The first predicate (corresponding to A) is true when applied to A, and false otherwise. Similarly for the other predicates.
mk_ff_add¶
def mk_ff_add(self, args: List[Ast]) raises -> Ast
Sum at least two elements of the same prime field.
mk_ff_bitsum¶
def mk_ff_bitsum(self, args: List[Ast]) raises -> Ast
Weighted sum a0 + 2a1 + 4a2 + ... (does not constrain arguments to bits).
mk_ff_mul¶
def mk_ff_mul(self, args: List[Ast]) raises -> Ast
Multiply at least two elements of the same prime field.
mk_ff_neg¶
def mk_ff_neg(self, a: Ast) raises -> Ast
Additive inverse in a prime field.
mk_finite_domain_sort¶
def mk_finite_domain_sort(self, name: Symbol, size: UInt64) raises -> Sort
Create a named finite domain sort.
To create constants that belong to the finite domain, use the APIs for creating numerals and pass a numeric constant together with the sort returned by this call. The numeric constant should be between 0 and the less than the size of the domain.
mk_finite_field_sort¶
def mk_finite_field_sort(self, prime: String) raises -> Sort
Create a prime-field sort. Large moduli undergo probable-prime screening.
mk_imag_part¶
def mk_imag_part(self, z: Ast) raises -> Ast
Return the imaginary component of a Complex expression.
mk_list_sort¶
def mk_list_sort(self, name: Symbol, elem_sort: Sort) raises -> Tuple[Sort, FuncDecl, FuncDecl, FuncDecl, FuncDecl, FuncDecl, FuncDecl]
Create a list sort
A list sort over elem_sort This function declares the corresponding constructors and testers for lists.
mk_polymorphic_datatype¶
def mk_polymorphic_datatype(self, name: Symbol, parameters: List[Sort], constructors: List[Constructor]) raises -> Sort
Create a parametric datatype with explicit type parameters.
This function is similar to Z3_mk_datatype, except it takes an explicit set of type parameters. The parameters can be type variables created with Z3_mk_type_variable, allowing the definition of polymorphic datatypes that can be instantiated with different concrete types.
mk_real_part¶
def mk_real_part(self, z: Ast) raises -> Ast
Return the real component of a Complex expression.
mk_tuple_sort¶
def mk_tuple_sort(self, name: Symbol, field_names: List[Symbol], field_sorts: List[Sort]) raises -> Tuple[Sort, FuncDecl, List[FuncDecl]]
Create a tuple type.
A tuple with n fields has a constructor and n projections. This function will also declare the constructor and projection functions.
mk_type_variable¶
def mk_type_variable(self, s: Symbol) raises -> Sort
Create a type variable.
Functions using type variables can be applied to instantiations that match the signature of the function. Assertions using type variables correspond to assertions over all possible instantiations.
query_constructor¶
def query_constructor(self, constr: Constructor, num_fields: Int) raises -> Tuple[FuncDecl, FuncDecl, List[FuncDecl]]
Query constructor for declared functions.
real_sort¶
def real_sort(self) raises -> Sort
Create the real type.
Note that this type is not a floating point number.
uninterpreted_sort¶
def uninterpreted_sort(self, name: String) raises -> Sort
Create a free (uninterpreted) type using the given name (symbol).
Two free types are considered the same iff the have the same name.
Constants and Applications (7)¶
add_rec_def¶
def add_rec_def(self, f: FuncDecl, args: List[Ast], body: Ast) raises
Define the body of a recursive function.
After declaring a recursive function or a collection of mutually recursive functions, use this function to provide the definition for the recursive function.
mk_app¶
def mk_app(self, decl: FuncDecl, args: List[Ast]) raises -> Ast
Create a constant or function application.
mk_const¶
def mk_const(self, name: String, sort: Sort) raises -> Ast
Declare and create a constant.
This function is a shorthand for:
Z3_func_decl d = Z3_mk_func_decl(c, s, 0, 0, ty);
Z3_ast n = Z3_mk_app(c, d, 0, 0);
mk_fresh_const¶
def mk_fresh_const(self, prefix: String, ty: Sort) raises -> Ast
Declare and create a fresh constant.
This function is a shorthand for:
Z3_func_decl d = Z3_mk_fresh_func_decl(c, prefix, 0, 0, ty); Z3_ast n = Z3_mk_app(c, d, 0, 0);
mk_fresh_func_decl¶
def mk_fresh_func_decl(self, prefix: String, domain: List[Sort], range_: Sort) raises -> FuncDecl
Declare a fresh constant or function.
Z3 will generate an unique name for this function declaration. If prefix is different from NULL, then the name generate by Z3 will start with prefix.
mk_func_decl¶
def mk_func_decl(self, name: String, domain: List[Sort], range_: Sort) raises -> FuncDecl
Declare a constant or function.
After declaring a constant or function, the function Z3_mk_app can be used to create a constant or function application.
mk_rec_func_decl¶
def mk_rec_func_decl(self, s: Symbol, domain: List[Sort], range_: Sort) raises -> FuncDecl
Declare a recursive function
After declaring recursive function, it should be associated with a recursive definition Z3_add_rec_def. The function Z3_mk_app can be used to create a constant or function application.
Propositional Logic and Equality (11)¶
mk_and¶
def mk_and(self, a: Ast, b: Ast) raises -> Ast
def mk_and(self, args: List[Ast]) raises -> Ast
Create an AST node representing args[0] and ... and args[num_args-1].
The array args must have num_args elements. All arguments must have Boolean sort.
mk_distinct¶
def mk_distinct(self, args: List[Ast]) raises -> Ast
Create an AST node representing distinct(args[0], ..., args[num_args-1]).
The distinct construct is used for declaring the arguments pairwise distinct. That is, Forall 0 <= i < j < num_args. not args[i] = args[j].
All arguments must have the same sort.
mk_eq¶
def mk_eq(self, a: Ast, b: Ast) raises -> Ast
Create an AST node representing l = r.
The nodes l and r must have the same type.
mk_false¶
def mk_false(self) raises -> Ast
Create an AST node representing false.
mk_iff¶
def mk_iff(self, a: Ast, b: Ast) raises -> Ast
Create an AST node representing t1 iff t2.
The nodes t1 and t2 must have Boolean sort.
mk_implies¶
def mk_implies(self, a: Ast, b: Ast) raises -> Ast
Create an AST node representing t1 implies t2.
The nodes t1 and t2 must have Boolean sort.
mk_ite¶
def mk_ite(self, cond: Ast, then_t: Ast, else_t: Ast) raises -> Ast
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_not¶
def mk_not(self, a: Ast) raises -> Ast
Create an AST node representing not(a).
The node a must have Boolean sort.
mk_or¶
def mk_or(self, a: Ast, b: Ast) raises -> Ast
def mk_or(self, args: List[Ast]) raises -> Ast
Create an AST node representing args[0] or ... or args[num_args-1].
The array args must have num_args elements. All arguments must have Boolean sort.
mk_true¶
def mk_true(self) raises -> Ast
Create an AST node representing true.
mk_xor¶
def mk_xor(self, a: Ast, b: Ast) raises -> Ast
Create an AST node representing t1 xor t2.
The nodes t1 and t2 must have Boolean sort.
Integers and Reals (17)¶
mk_abs¶
def mk_abs(self, arg: Ast) raises -> Ast
Take the absolute value of an integer
mk_add¶
def mk_add(self, a: Ast, b: Ast) raises -> Ast
def mk_add(self, args: List[Ast]) raises -> Ast
Create an AST node representing args[0] + ... + args[num_args-1].
The array args must have num_args elements. All arguments must have Int, Real, or Complex sort.
mk_div¶
def mk_div(self, a: Ast, b: Ast) raises -> Ast
Create an AST node representing arg1 div arg2.
The arguments must have Int, Real, or Complex sort. Int arguments use integer division. Real and Complex arguments use their respective division operations, with Int embedded in Real and Int/Real embedded in Complex. Complex division is lowered to Real component division; at a zero Complex denominator, both components are the same totalized Real 0/0 value.
mk_divides¶
def mk_divides(self, t1: Ast, t2: Ast) raises -> Ast
Create division predicate.
The nodes t1 and t2 must be of integer sort. The predicate is true when t1 divides t2. For the predicate to be part of linear integer arithmetic, the first argument t1 must be a non-zero integer.
mk_ge¶
def mk_ge(self, a: Ast, b: Ast) raises -> Ast
Create greater than or equal to.
The nodes t1 and t2 must have the same sort, and must be int or real.
mk_gt¶
def mk_gt(self, a: Ast, b: Ast) raises -> Ast
Create greater than.
The nodes t1 and t2 must have the same sort, and must be int or real.
mk_int2real¶
def mk_int2real(self, a: Ast) raises -> Ast
Coerce an integer to a real.
There is also a converse operation exposed. It follows the semantics prescribed by the SMT-LIB standard.
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_is_int¶
def mk_is_int(self, a: Ast) raises -> Ast
Check if a real number is an integer.
mk_le¶
def mk_le(self, a: Ast, b: Ast) raises -> Ast
Create less than or equal to.
The nodes t1 and t2 must have the same sort, and must be int or real.
mk_lt¶
def mk_lt(self, a: Ast, b: Ast) raises -> Ast
Create less than.
The nodes t1 and t2 must have the same sort, and must be int or real.
mk_mod¶
def mk_mod(self, a: Ast, b: Ast) raises -> Ast
Create an AST node representing arg1 mod arg2.
The arguments must have int type.
mk_mul¶
def mk_mul(self, a: Ast, b: Ast) raises -> Ast
def mk_mul(self, args: List[Ast]) raises -> Ast
Create an AST node representing args[0] * ... * args[num_args-1].
The array args must have num_args elements. All arguments must have Int, Real, or Complex sort.
mk_neg¶
def mk_neg(self, a: Ast) raises -> Ast
Create an AST node representing - arg.
The argument must have Int, Real, or Complex sort.
mk_pow¶
def mk_pow(self, base: Ast, exp: Ast) raises -> Ast
Create an AST node representing arg1 ^ arg2.
The arguments must have int or real type.
mk_real2int¶
def mk_real2int(self, a: Ast) raises -> Ast
Coerce a real to an integer.
The semantics of this function follows the SMT-LIB standard for the function to_int
mk_rem¶
def mk_rem(self, a: Ast, b: Ast) raises -> Ast
Create an AST node representing arg1 rem arg2.
The arguments must have int type.
mk_sub¶
def mk_sub(self, a: Ast, b: Ast) raises -> Ast
Create an AST node representing args[0] - ... - args[num_args - 1].
The array args must have num_args elements. All arguments must have Int, Real, or Complex sort.
Bit-vectors (49)¶
mk_bit2bool¶
def mk_bit2bool(self, i: UInt32, t1: Ast) raises -> Ast
Extracts the bit at position i of a bit-vector and yields a boolean.
The node t1 must have a bit-vector sort.
mk_bv2int¶
def mk_bv2int(self, t1: Ast, is_signed: Bool) raises -> Ast
Create an integer from the bit-vector argument t1. If is_signed is false, then the bit-vector t1 is treated as unsigned. So the result is non-negative and in the range [0..2^N-1], where N are the number of bits in t1. If is_signed is true, t1 is treated as a signed bit-vector.
The node t1 must have a bit-vector sort.
mk_bvadd¶
def mk_bvadd(self, a: Ast, b: Ast) raises -> Ast
Standard two's complement addition.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvadd_no_overflow¶
def mk_bvadd_no_overflow(self, t1: Ast, t2: Ast, is_signed: Bool) raises -> Ast
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. The returned node is of sort Bool.
mk_bvadd_no_underflow¶
def mk_bvadd_no_underflow(self, t1: Ast, t2: Ast) raises -> Ast
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. The returned node is of sort Bool.
mk_bvand¶
def mk_bvand(self, a: Ast, b: Ast) raises -> Ast
Bitwise and.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvashr¶
def mk_bvashr(self, t1: Ast, t2: Ast) raises -> Ast
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 semantics of shift operations varies between environments. This definition does not necessarily capture directly the semantics of the programming language or assembly architecture you are modeling.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvlshr¶
def mk_bvlshr(self, t1: Ast, t2: Ast) raises -> Ast
Logical shift right.
It is equivalent to unsigned division by 2^x where x is the value of the third argument.
NB. The semantics of shift operations varies between environments. This definition does not necessarily capture directly the semantics of the programming language or assembly architecture you are modeling.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvmul¶
def mk_bvmul(self, a: Ast, b: Ast) raises -> Ast
Standard two's complement multiplication.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvmul_no_overflow¶
def mk_bvmul_no_overflow(self, t1: Ast, t2: Ast, is_signed: Bool) raises -> Ast
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. The returned node is of sort Bool.
mk_bvmul_no_underflow¶
def mk_bvmul_no_underflow(self, t1: Ast, t2: Ast) raises -> Ast
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. The returned node is of sort Bool.
mk_bvnand¶
def mk_bvnand(self, t1: Ast, t2: Ast) raises -> Ast
Bitwise nand.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvneg¶
def mk_bvneg(self, a: Ast) raises -> Ast
Standard two's complement unary minus.
The node t1 must have bit-vector sort.
mk_bvneg_no_overflow¶
def mk_bvneg_no_overflow(self, t1: Ast) raises -> Ast
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. The returned node is of sort Bool.
mk_bvnor¶
def mk_bvnor(self, t1: Ast, t2: Ast) raises -> Ast
Bitwise nor.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvnot¶
def mk_bvnot(self, a: Ast) raises -> Ast
Bitwise negation.
The node t1 must have a bit-vector sort.
mk_bvor¶
def mk_bvor(self, a: Ast, b: Ast) raises -> Ast
Bitwise or.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvredand¶
def mk_bvredand(self, t1: Ast) raises -> Ast
Take conjunction of bits in vector, return vector of length 1.
The node t1 must have a bit-vector sort.
mk_bvredor¶
def mk_bvredor(self, t1: Ast) raises -> Ast
Take disjunction of bits in vector, return vector of length 1.
The node t1 must have a bit-vector sort.
mk_bvsdiv¶
def mk_bvsdiv(self, t1: Ast, t2: Ast) raises -> Ast
Two's complement signed division.
It is defined in the following way:
-
The
flooroft1/t2ift2is different from zero, andt1*t2 >= 0. -
The
ceilingoft1/t2ift2is different from zero, andt1*t2 < 0.
If t2 is zero, then the result is undefined.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvsdiv_no_overflow¶
def mk_bvsdiv_no_overflow(self, t1: Ast, t2: Ast) raises -> Ast
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. The returned node is of sort Bool.
mk_bvsge¶
def mk_bvsge(self, t1: Ast, t2: Ast) raises -> Ast
Two's complement signed greater than or equal to.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvsgt¶
def mk_bvsgt(self, t1: Ast, t2: Ast) raises -> Ast
Two's complement signed greater than.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvshl¶
def mk_bvshl(self, t1: Ast, t2: Ast) raises -> Ast
Shift left.
It is equivalent to multiplication by 2^x where x is the value of the third argument.
NB. The semantics of shift operations varies between environments. This definition does not necessarily capture directly the semantics of the programming language or assembly architecture you are modeling.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvsle¶
def mk_bvsle(self, a: Ast, b: Ast) raises -> Ast
Two's complement signed less than or equal to.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvslt¶
def mk_bvslt(self, a: Ast, b: Ast) raises -> Ast
Two's complement signed less than.
It abbreviates:
(or (and (= (extract[|m-1|:|m-1|] t1) bit1)
(= (extract[|m-1|:|m-1|] t2) bit0))
(and (= (extract[|m-1|:|m-1|] t1) (extract[|m-1|:|m-1|] t2))
(bvult t1 t2)))
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvsmod¶
def mk_bvsmod(self, t1: Ast, t2: Ast) raises -> Ast
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.
mk_bvsrem¶
def mk_bvsrem(self, t1: Ast, t2: Ast) raises -> Ast
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.
mk_bvsub¶
def mk_bvsub(self, a: Ast, b: Ast) raises -> Ast
Standard two's complement subtraction.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvsub_no_overflow¶
def mk_bvsub_no_overflow(self, t1: Ast, t2: Ast) raises -> Ast
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. The returned node is of sort Bool.
mk_bvsub_no_underflow¶
def mk_bvsub_no_underflow(self, t1: Ast, t2: Ast, is_signed: Bool) raises -> Ast
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. The returned node is of sort Bool.
mk_bvudiv¶
def mk_bvudiv(self, t1: Ast, t2: Ast) raises -> Ast
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_bvuge¶
def mk_bvuge(self, t1: Ast, t2: Ast) raises -> Ast
Unsigned greater than or equal to.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvugt¶
def mk_bvugt(self, t1: Ast, t2: Ast) raises -> Ast
Unsigned greater than.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvule¶
def mk_bvule(self, a: Ast, b: Ast) raises -> Ast
Unsigned less than or equal to.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvult¶
def mk_bvult(self, a: Ast, b: Ast) raises -> Ast
Unsigned less than.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvurem¶
def mk_bvurem(self, t1: Ast, t2: Ast) raises -> Ast
Unsigned remainder.
It is defined as t1 - (t1 /u t2) * t2, where /u represents unsigned division.
If t2 is zero, then the result is undefined.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvxnor¶
def mk_bvxnor(self, t1: Ast, t2: Ast) raises -> Ast
Bitwise xnor.
The nodes t1 and t2 must have the same bit-vector sort.
mk_bvxor¶
def mk_bvxor(self, a: Ast, b: Ast) raises -> Ast
Bitwise exclusive-or.
The nodes t1 and t2 must have the same bit-vector sort.
mk_concat¶
def mk_concat(self, a: Ast, b: Ast) raises -> Ast
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_ext_rotate_left¶
def mk_ext_rotate_left(self, t1: Ast, t2: Ast) raises -> Ast
Rotate bits of t1 to the left t2 times.
The nodes t1 and t2 must have the same bit-vector sort.
mk_ext_rotate_right¶
def mk_ext_rotate_right(self, t1: Ast, t2: Ast) raises -> Ast
Rotate bits of t1 to the right t2 times.
The nodes t1 and t2 must have the same bit-vector sort.
mk_extract¶
def mk_extract(self, high: Int, low: Int, a: Ast) raises -> Ast
Extract the bits high down to low from a bit-vector of size m to yield a new bit-vector of size n, where n = high - low + 1.
The node t1 must have a bit-vector sort.
mk_int2bv¶
def mk_int2bv(self, n: UInt32, t1: Ast) raises -> Ast
Create an n bit bit-vector from the integer argument t1.
The resulting bit-vector has n bits, where the i'th bit (counting from 0 to n-1) is 1 if (t1 div 2^i) mod 2 is 1.
The node t1 must have integer sort.
mk_repeat¶
def mk_repeat(self, i: UInt32, t1: Ast) raises -> Ast
Repeat the given bit-vector up length i.
The node t1 must have a bit-vector sort.
mk_rotate_left¶
def mk_rotate_left(self, i: UInt32, t1: Ast) raises -> Ast
Rotate bits of t1 to the left i times.
The node t1 must have a bit-vector sort.
mk_rotate_right¶
def mk_rotate_right(self, i: UInt32, t1: Ast) raises -> Ast
Rotate bits of t1 to the right i times.
The node t1 must have a bit-vector sort.
mk_sign_ext¶
def mk_sign_ext(self, i: UInt32, t1: Ast) raises -> Ast
Sign-extend of the given bit-vector to the (signed) equivalent bit-vector 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¶
def mk_zero_ext(self, i: UInt32, t1: Ast) raises -> Ast
Extend the given bit-vector with zeros to the (unsigned) equivalent bit-vector of size m+i, where m is the size of the given bit-vector.
The node t1 must have a bit-vector sort.
Arrays (8)¶
mk_array_default¶
def mk_array_default(self, array: Ast) raises -> Ast
Access the array default value. Produces the default range value, for arrays that can be represented as finite maps with a default range value.
mk_as_array¶
def mk_as_array(self, f: FuncDecl) raises -> Ast
Create array with the same interpretation as a function. The array satisfies the property (f x) = (select (_ as-array f) x) for every argument x.
mk_const_array¶
def mk_const_array(self, domain: Sort, v: Ast) raises -> Ast
Create the constant array.
The resulting term is an array, such that a select on an arbitrary index produces the value v.
mk_map¶
def mk_map(self, f: FuncDecl, args: List[Ast]) raises -> Ast
Map f on 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].
mk_select¶
def mk_select(self, arr: Ast, idx: Ast) raises -> Ast
Array read. The argument a is the array and i is the index of the array that gets 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.
mk_select_n¶
def mk_select_n(self, a: Ast, idxs: List[Ast]) raises -> Ast
n-ary Array read. The argument a is the array and idxs are the indices of the array that gets read.
mk_store¶
def mk_store(self, arr: Ast, idx: Ast, val: Ast) raises -> Ast
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]. The semantics of this function is given by the theory of arrays described in the SMT-LIB standard. See http://smtlib.org for more details. The result of this function is an array that is equal to a (with respect to select) on all indices except for i, where it maps to v (and the select of a with respect to i may be a different value).
mk_store_n¶
def mk_store_n(self, a: Ast, idxs: List[Ast], v: Ast) raises -> Ast
n-ary Array update.
Sets (12)¶
mk_array_ext¶
def mk_array_ext(self, arg1: Ast, arg2: Ast) raises -> Ast
Create array extensionality index given two arrays with the same sort. The meaning is given by the axiom: (=> (= (select A (array-ext A B)) (select B (array-ext A B))) (= A B))
mk_empty_set¶
def mk_empty_set(self, domain: Sort) raises -> Ast
Create the empty set.
mk_full_set¶
def mk_full_set(self, domain: Sort) raises -> Ast
Create the full set.
mk_set_add¶
def mk_set_add(self, set: Ast, elem: Ast) raises -> Ast
Add an element to a set.
The first argument must be a set, the second an element.
mk_set_complement¶
def mk_set_complement(self, arg: Ast) raises -> Ast
Take the complement of a set.
mk_set_del¶
def mk_set_del(self, set: Ast, elem: Ast) raises -> Ast
Remove an element to a set.
The first argument must be a set, the second an element.
mk_set_difference¶
def mk_set_difference(self, arg1: Ast, arg2: Ast) raises -> Ast
Take the set difference between two sets.
mk_set_intersect¶
def mk_set_intersect(self, args: List[Ast]) raises -> Ast
Take the intersection of a list of sets.
mk_set_member¶
def mk_set_member(self, elem: Ast, set: Ast) raises -> Ast
Check for set membership.
The first argument should be an element type of the set.
mk_set_sort¶
def mk_set_sort(self, ty: Sort) raises -> Sort
Create Set type.
mk_set_subset¶
def mk_set_subset(self, arg1: Ast, arg2: Ast) raises -> Ast
Check for subsetness of sets.
mk_set_union¶
def mk_set_union(self, args: List[Ast]) raises -> Ast
Take the union of a list of sets.
Finite Sets (14)¶
get_finite_set_sort_basis¶
def get_finite_set_sort_basis(self, s: Sort) raises -> Sort
Get the element sort of a finite set sort.
is_finite_set_sort¶
def is_finite_set_sort(self, s: Sort) raises -> Bool
Check if a sort is a finite set sort.
mk_finite_set_difference¶
def mk_finite_set_difference(self, s1: Ast, s2: Ast) raises -> Ast
Create the set difference of two finite sets.
mk_finite_set_empty¶
def mk_finite_set_empty(self, set_sort: Sort) raises -> Ast
Create an empty finite set of the given sort.
mk_finite_set_filter¶
def mk_finite_set_filter(self, f: Ast, set: Ast) raises -> Ast
Filter a finite set using a predicate.
mk_finite_set_intersect¶
def mk_finite_set_intersect(self, s1: Ast, s2: Ast) raises -> Ast
Create the intersection of two finite sets.
mk_finite_set_map¶
def mk_finite_set_map(self, f: Ast, set: Ast) raises -> Ast
Apply a function to all elements of a finite set.
mk_finite_set_member¶
def mk_finite_set_member(self, elem: Ast, set: Ast) raises -> Ast
Check if an element is a member of a finite set.
mk_finite_set_range¶
def mk_finite_set_range(self, low: Ast, high: Ast) raises -> Ast
Create a finite set of integers in the range [low, high].
mk_finite_set_singleton¶
def mk_finite_set_singleton(self, elem: Ast) raises -> Ast
Create a singleton finite set.
mk_finite_set_size¶
def mk_finite_set_size(self, set: Ast) raises -> Ast
Get the size (cardinality) of a finite set.
mk_finite_set_sort¶
def mk_finite_set_sort(self, elem_sort: Sort) raises -> Sort
Create a finite set sort.
mk_finite_set_subset¶
def mk_finite_set_subset(self, s1: Ast, s2: Ast) raises -> Ast
Check if one finite set is a subset of another.
mk_finite_set_union¶
def mk_finite_set_union(self, s1: Ast, s2: Ast) raises -> Ast
Create the union of two finite sets.
Numerals (8)¶
Z3_mk_int¶
def Z3_mk_int(self, v: Int32, ty: Sort) raises -> Ast
Create a numeral of an int, bit-vector, or finite-domain sort.
This function can be used 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.
mk_bv_numeral¶
def mk_bv_numeral(self, bits: List[Bool]) raises -> Ast
create a bit-vector numeral from a vector of Booleans.
mk_int¶
def mk_int(self, val: Int) raises -> Ast
Create a numeral of a int, bit-vector, or finite-domain sort.
This function can be used to create numerals that fit in a machine int64_t integer. It is slightly faster than Z3_mk_numeral since it is not necessary to parse a string.
mk_numeral¶
def mk_numeral(self, numeral: String, sort: Sort) raises -> Ast
Create a numeral of a given sort.
mk_real¶
def mk_real(self, val: Int) raises -> Ast
def mk_real(self, val: Rational) raises -> Ast
Create a real from a fraction of int64.
Create an exact arbitrary-precision Z3 Real numeral from apn_mojo.Rational.
mk_real_frac¶
def mk_real_frac(self, num: Int, den: Int) raises -> Ast
Create a real from a fraction.
mk_unsigned_int¶
def mk_unsigned_int(self, v: UInt32, ty: Sort) raises -> Ast
Create a numeral of a int, bit-vector, or finite-domain sort.
This function can be used to create numerals that fit in a machine unsigned integer. It is slightly faster than Z3_mk_numeral since it is not necessary to parse a string.
mk_unsigned_int64¶
def mk_unsigned_int64(self, v: UInt64, ty: Sort) raises -> Ast
Create a numeral of a int, bit-vector, or finite-domain sort.
This function can be used to create numerals that fit in a machine uint64_t integer. It is slightly faster than Z3_mk_numeral since it is not necessary to parse a string.
Sequences and regular expressions (69)¶
get_lstring¶
def get_lstring(self, s: Ast) raises -> List[UInt8]
Retrieve the string constant stored in s. The string can contain escape sequences. Characters in the range 1 to 255 are literal. Characters in the range 0, and 256 above are escaped.
get_re_sort_basis¶
def get_re_sort_basis(self, s: Sort) raises -> Sort
Retrieve basis sort for regex sort.
get_seq_sort_basis¶
def get_seq_sort_basis(self, s: Sort) raises -> Sort
Retrieve basis sort for sequence sort.
get_string¶
def get_string(self, s: Ast) raises -> String
Retrieve the string constant stored in s. Characters outside the basic printable ASCII range are escaped.
get_string_contents¶
def get_string_contents(self, s: Ast) raises -> List[UInt32]
Retrieve the unescaped string constant stored in s.
get_string_length¶
def get_string_length(self, s: Ast) raises -> UInt32
Retrieve the length of the unescaped string constant stored in s.
is_char_sort¶
def is_char_sort(self, s: Sort) raises -> Bool
Check if s is a character sort.
is_re_sort¶
def is_re_sort(self, s: Sort) raises -> Bool
Check if s is a regular expression sort.
is_seq_sort¶
def is_seq_sort(self, s: Sort) raises -> Bool
Check if s is a sequence sort.
is_string¶
def is_string(self, s: Ast) raises -> Bool
Determine if s is a string constant.
is_string_sort¶
def is_string_sort(self, s: Sort) raises -> Bool
Check if s is a string sort.
mk_char¶
def mk_char(self, ch: UInt32) raises -> Ast
Create a character literal
mk_char_from_bv¶
def mk_char_from_bv(self, bv: Ast) raises -> Ast
Create a character from a bit-vector (code point).
mk_char_is_digit¶
def mk_char_is_digit(self, ch: Ast) raises -> Ast
Create a check if the character is a digit.
mk_char_le¶
def mk_char_le(self, ch1: Ast, ch2: Ast) raises -> Ast
Create less than or equal to between two characters.
mk_char_sort¶
def mk_char_sort(self) raises -> Sort
Create a sort for unicode characters.
The sort for characters can be changed to ASCII by setting the global parameter encoding to ascii, or alternative to 16 bit characters by setting encoding to bmp.
mk_char_to_bv¶
def mk_char_to_bv(self, ch: Ast) raises -> Ast
Create a bit-vector (code point) from character.
mk_char_to_int¶
def mk_char_to_int(self, ch: Ast) raises -> Ast
Create an integer (code point) from character.
mk_int_to_str¶
def mk_int_to_str(self, s: Ast) raises -> Ast
Integer to string conversion.
mk_lstring¶
def mk_lstring(self, len_: UInt32, s: String) raises -> Ast
Create a string constant out of the string that is passed in It takes the length of the string as well to take into account 0 characters. The string is treated as if it is unescaped so a sequence of characters \u{0} is treated as 5 characters and not the character 0.
mk_re_allchar¶
def mk_re_allchar(self, regex_sort: Sort) raises -> Ast
Create a regular expression that accepts all singleton sequences of the regular expression sort
mk_re_complement¶
def mk_re_complement(self, re: Ast) raises -> Ast
Create the complement of the regular language re.
mk_re_concat¶
def mk_re_concat(self, args: List[Ast]) raises -> Ast
Create the concatenation of the regular languages.
mk_re_diff¶
def mk_re_diff(self, re1: Ast, re2: Ast) raises -> Ast
Create the difference of regular expressions.
mk_re_empty¶
def mk_re_empty(self, re: Sort) raises -> Ast
Create an empty regular expression of sort re.
mk_re_full¶
def mk_re_full(self, re: Sort) raises -> Ast
Create an universal regular expression of sort re.
mk_re_intersect¶
def mk_re_intersect(self, args: List[Ast]) raises -> Ast
Create the intersection of the regular languages.
mk_re_loop¶
def mk_re_loop(self, r: Ast, lo: UInt32, hi: UInt32) raises -> Ast
Create a regular expression loop. The supplied regular expression r is repeated between lo and hi times. The lo should be below hi with one exception: when supplying the value hi as 0, the meaning is to repeat the argument r at least lo number of times, and with an unbounded upper bound.
mk_re_option¶
def mk_re_option(self, re: Ast) raises -> Ast
Create the regular language [re].
mk_re_plus¶
def mk_re_plus(self, re: Ast) raises -> Ast
Create the regular language re+.
mk_re_power¶
def mk_re_power(self, re: Ast, n: UInt32) raises -> Ast
Create a power regular expression.
mk_re_range¶
def mk_re_range(self, lo: Ast, hi: Ast) raises -> Ast
Create the range regular expression over two sequences of length 1.
mk_re_sort¶
def mk_re_sort(self, seq: Sort) raises -> Sort
Create a regular expression sort out of a sequence sort.
mk_re_star¶
def mk_re_star(self, re: Ast) raises -> Ast
Create the regular language re*.
mk_re_union¶
def mk_re_union(self, args: List[Ast]) raises -> Ast
Create the union of the regular languages.
mk_sbv_to_str¶
def mk_sbv_to_str(self, s: Ast) raises -> Ast
Signed bit-vector to string conversion.
mk_seq_at¶
def mk_seq_at(self, s: Ast, index: Ast) raises -> Ast
Retrieve from s the unit sequence positioned at position index. The sequence is empty if the index is out of bounds.
mk_seq_concat¶
def mk_seq_concat(self, args: List[Ast]) raises -> Ast
Concatenate sequences.
mk_seq_contains¶
def mk_seq_contains(self, container: Ast, containee: Ast) raises -> Ast
Check if container contains containee.
mk_seq_empty¶
def mk_seq_empty(self, seq: Sort) raises -> Ast
Create an empty sequence of the sequence sort seq.
mk_seq_extract¶
def mk_seq_extract(self, s: Ast, offset: Ast, length: Ast) raises -> Ast
Extract subsequence starting at offset of length.
mk_seq_foldl¶
def mk_seq_foldl(self, f: Ast, a: Ast, s: Ast) raises -> Ast
Create a fold of the function f over the sequence s with accumulator a.
mk_seq_foldli¶
def mk_seq_foldli(self, f: Ast, i: Ast, a: Ast, s: Ast) raises -> Ast
Create a fold with index tracking of the function f over the sequence s with accumulator a starting at index i.
mk_seq_in_re¶
def mk_seq_in_re(self, seq: Ast, re: Ast) raises -> Ast
Check if seq is in the language generated by the regular expression re.
mk_seq_index¶
def mk_seq_index(self, s: Ast, substr: Ast, offset: Ast) raises -> Ast
Return index of the first occurrence of substr in s starting from offset offset. If s does not contain substr, then the value is -1, if offset is the length of s, then the value is -1 as well. The value is -1 if offset is negative or larger than the length of s.
mk_seq_last_index¶
def mk_seq_last_index(self, s: Ast, substr: Ast) raises -> Ast
Return index of the last occurrence of substr in s. If s does not contain substr, then the value is -1,
mk_seq_length¶
def mk_seq_length(self, s: Ast) raises -> Ast
Return the length of the sequence s.
mk_seq_map¶
def mk_seq_map(self, f: Ast, s: Ast) raises -> Ast
Create a map of the function f over the sequence s.
mk_seq_mapi¶
def mk_seq_mapi(self, f: Ast, i: Ast, s: Ast) raises -> Ast
Create a map of the function f over the sequence s starting at index i.
mk_seq_nth¶
def mk_seq_nth(self, s: Ast, index: Ast) raises -> Ast
Retrieve from s the element positioned at position index. The function is under-specified if the index is out of bounds.
mk_seq_power¶
def mk_seq_power(self, s: Ast, n: Ast) raises -> Ast
Create the sequence s concatenated n times with itself. The result is the empty sequence when n is not positive.
mk_seq_prefix¶
def mk_seq_prefix(self, prefix: Ast, s: Ast) raises -> Ast
Check if prefix is a prefix of s.
mk_seq_replace¶
def mk_seq_replace(self, s: Ast, src: Ast, dst: Ast) raises -> Ast
Replace the first occurrence of src with dst in s.
mk_seq_replace_all¶
def mk_seq_replace_all(self, s: Ast, src: Ast, dst: Ast) raises -> Ast
Replace all occurrences of src with dst in s.
mk_seq_replace_re¶
def mk_seq_replace_re(self, s: Ast, re: Ast, dst: Ast) raises -> Ast
Replace the first occurrence of regular expression re with dst in s.
mk_seq_replace_re_all¶
def mk_seq_replace_re_all(self, s: Ast, re: Ast, dst: Ast) raises -> Ast
Replace all occurrences of regular expression re with dst in s.
mk_seq_sort¶
def mk_seq_sort(self, s: Sort) raises -> Sort
Create a sequence sort out of the sort for the elements.
mk_seq_suffix¶
def mk_seq_suffix(self, suffix: Ast, s: Ast) raises -> Ast
Check if suffix is a suffix of s.
mk_seq_to_re¶
def mk_seq_to_re(self, seq: Ast) raises -> Ast
Create a regular expression that accepts the sequence seq.
mk_seq_unit¶
def mk_seq_unit(self, a: Ast) raises -> Ast
Create a unit sequence of a.
mk_str_le¶
def mk_str_le(self, prefix: Ast, s: Ast) raises -> Ast
Check if s1 is equal or lexicographically strictly less than s2.
mk_str_lt¶
def mk_str_lt(self, prefix: Ast, s: Ast) raises -> Ast
Check if s1 is lexicographically strictly less than s2.
mk_str_to_int¶
def mk_str_to_int(self, s: Ast) raises -> Ast
Convert string to integer.
mk_string¶
def mk_string(self, s: String) raises -> Ast
Create a string constant out of the string that is passed in The string may contain escape encoding for non-printable characters or characters outside of the basic printable ASCII range. For example, the escape encoding \u{0} represents the character 0 and the encoding \u{100} represents the character 256.
mk_string_from_code¶
def mk_string_from_code(self, a: Ast) raises -> Ast
Code to string conversion.
mk_string_to_code¶
def mk_string_to_code(self, a: Ast) raises -> Ast
String to code conversion.
mk_u32string¶
def mk_u32string(self, chars: List[UInt32]) raises -> Ast
Create a string constant out of the string that is passed in It takes the length of the string as well to take into account 0 characters. The string is unescaped.
mk_ubv_to_str¶
def mk_ubv_to_str(self, s: Ast) raises -> Ast
Unsigned bit-vector to string conversion.
string_sort¶
def string_sort(self) raises -> Sort
Create a sort for unicode strings.
The sort for characters can be changed to ASCII by setting the global parameter encoding to ascii, or alternative to 16 bit characters by setting encoding to bmp.
Special relations (5)¶
mk_linear_order¶
def mk_linear_order(self, a: Sort, id: UInt32) raises -> FuncDecl
create a linear ordering relation over signature a. The relation is identified by the index id.
mk_partial_order¶
def mk_partial_order(self, a: Sort, id: UInt32) raises -> FuncDecl
create a partial ordering relation over signature a and index id.
mk_piecewise_linear_order¶
def mk_piecewise_linear_order(self, a: Sort, id: UInt32) raises -> FuncDecl
create a piecewise linear ordering relation over signature a and index id.
mk_transitive_closure¶
def mk_transitive_closure(self, f: FuncDecl) raises -> FuncDecl
create transitive closure of binary relation.
The resulting relation f+ represents the transitive closure of f.
mk_tree_order¶
def mk_tree_order(self, a: Sort, id: UInt32) raises -> FuncDecl
create a tree ordering relation over signature a identified using index id.
Quantifiers (12)¶
Z3_mk_exists¶
def Z3_mk_exists(self, weight: UInt32, patterns: List[Pattern], sorts: List[Sort], decl_names: List[Symbol], body: Ast) raises -> Ast
Create an exists formula. Similar to Z3_mk_forall.
Z3_mk_forall¶
def Z3_mk_forall(self, weight: UInt32, patterns: List[Pattern], sorts: List[Sort], decl_names: List[Symbol], body: Ast) raises -> Ast
Create a forall formula. It takes an expression body that contains bound variables of the same sorts as the sorts listed in the array sorts. The bound variables are de-Bruijn indices created using Z3_mk_bound. The array decl_names contains the names that the quantified formula uses for the bound variables. Z3 applies the convention that the last element in the decl_names and sorts array refers to the variable with index 0, the second to last element of decl_names and sorts refers to the variable with index 1, etc.
mk_bound¶
def mk_bound(self, index: UInt32, ty: Sort) raises -> Ast
Create a variable.
Variables are intended to be bound by a scope created by a quantifier. So we call them bound variables even if they appear as free variables in the expression produced by Z3_mk_bound.
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.
mk_exists¶
def mk_exists(self, bound_consts: List[Ast], body: Ast) raises -> Ast
Similar to Z3_mk_forall_const.
Create an existential quantifier using a list of constants that will form the set of bound variables.
mk_forall¶
def mk_forall(self, bound_consts: List[Ast], body: Ast) raises -> Ast
Create a universal quantifier using a list of constants that will form the set of bound variables.
mk_lambda¶
def mk_lambda(self, sorts: List[Sort], decl_names: List[Symbol], body: Ast) raises -> Ast
Create a lambda expression. It takes an expression body that contains bound variables of the same sorts as the sorts listed in the array sorts. The bound variables are de-Bruijn indices created using Z3_mk_bound. The array decl_names contains the names that the quantified formula uses for the bound variables. Z3 applies the convention that the last element in the decl_names and sorts array refers to the variable with index 0, the second to last element of decl_names and sorts refers to the variable with index 1, etc. The sort of the resulting expression is (Array sorts range) where range is the sort of body. For example, if the lambda binds two variables of sort Int and Bool, and the body has sort Real, the sort of the expression is (Array Int Bool Real).
mk_lambda_const¶
def mk_lambda_const(self, bound: List[App], body: Ast) raises -> Ast
Create a lambda expression using a list of constants that form the set of bound variables
mk_pattern¶
def mk_pattern(self, terms: List[Ast]) raises -> Pattern
Create a pattern for quantifier instantiation.
Z3 uses pattern matching to instantiate quantifiers. If a pattern is not provided for a quantifier, then Z3 will automatically compute a set of patterns for it. However, for optimal performance, the user should provide the patterns.
Patterns comprise a list of terms. The list should be non-empty. If the list comprises of more than one term, it is a called a multi-pattern.
In general, one can pass in a list of (multi-)patterns in the quantifier constructor.
mk_quantifier¶
def mk_quantifier(self, is_forall: Bool, weight: UInt32, patterns: List[Pattern], sorts: List[Sort], decl_names: List[Symbol], body: Ast) raises -> Ast
Create a quantifier - universal or existential, with pattern hints. See the documentation for Z3_mk_forall for an explanation of the parameters.
mk_quantifier_const¶
def mk_quantifier_const(self, is_forall: Bool, weight: UInt32, bound: List[App], patterns: List[Pattern], body: Ast) raises -> Ast
Create a universal or existential quantifier using a list of constants that will form the set of bound variables.
mk_quantifier_const_ex¶
def mk_quantifier_const_ex(self, is_forall: Bool, weight: UInt32, quantifier_id: Symbol, skolem_id: Symbol, bound: List[App], patterns: List[Pattern], no_patterns: List[Ast], body: Ast) raises -> Ast
Create a universal or existential quantifier using a list of constants that will form the set of bound variables.
mk_quantifier_ex¶
def mk_quantifier_ex(self, is_forall: Bool, weight: UInt32, quantifier_id: Symbol, skolem_id: Symbol, patterns: List[Pattern], no_patterns: List[Ast], sorts: List[Sort], decl_names: List[Symbol], body: Ast) raises -> Ast
Create a quantifier - universal or existential, with pattern hints, no patterns, and attributes
Accessors (102)¶
app_to_ast¶
def app_to_ast(self, a: App) raises -> Ast
Convert a Z3_app into Z3_ast. This is just type casting.
datatype_update_field¶
def datatype_update_field(self, field_access: FuncDecl, t: Ast, value: Ast) raises -> Ast
Update record field with a value.
This corresponds to the 'with' construct in OCaml. It has the effect of updating a record field with a given value. The remaining fields are left unchanged. It is the record equivalent of an array store (see Z3_mk_store). If the datatype has more than one constructor, then the update function behaves as identity if there is a mismatch between the accessor and constructor. For example ((_ update-field car) nil 1) is nil, while ((_ update-field car) (cons 2 nil) 1) is (cons 1 nil).
func_decl_to_ast¶
def func_decl_to_ast(self, f: FuncDecl) raises -> Ast
Convert a Z3_func_decl into Z3_ast. This is just type casting.
get_algebraic_number_lower¶
def get_algebraic_number_lower(self, a: Ast, precision: UInt32) raises -> Ast
Return a lower bound for the given real algebraic number. The interval isolating the number is smaller than 1/10^precision. The result is a numeral AST of sort Real.
get_algebraic_number_upper¶
def get_algebraic_number_upper(self, a: Ast, precision: UInt32) raises -> Ast
Return a upper bound for the given real algebraic number. The interval isolating the number is smaller than 1/10^precision. The result is a numeral AST of sort Real.
get_app_arg¶
def get_app_arg(self, a: App, i: UInt32) raises -> Ast
Return the i-th argument of the given application.
get_app_decl¶
def get_app_decl(self, a: App) raises -> FuncDecl
Return the declaration of a constant or function application.
get_app_num_args¶
def get_app_num_args(self, a: App) raises -> UInt32
Return the number of argument of an application. If t is an constant, then the number of arguments is 0.
get_arity¶
def get_arity(self, d: FuncDecl) raises -> UInt32
Alias for Z3_get_domain_size.
get_array_arity¶
def get_array_arity(self, s: Sort) raises -> UInt32
Return the arity (number of dimensions) of the given array sort.
get_array_sort_domain¶
def get_array_sort_domain(self, t: Sort) raises -> Sort
Return the domain of the given array sort. In the case of a multi-dimensional array, this function returns the sort of the first dimension.
get_array_sort_domain_n¶
def get_array_sort_domain_n(self, t: Sort, idx: UInt32) raises -> Sort
Return the i'th domain sort of an n-dimensional array.
get_array_sort_range¶
def get_array_sort_range(self, t: Sort) raises -> Sort
Return the range of the given array sort.
get_ast_hash¶
def get_ast_hash(self, a: Ast) raises -> UInt32
Return a hash code for the given AST. The hash code is structural but two different AST objects can map to the same hash. The result of Z3_get_ast_id returns an identifier that is unique over the set of live AST objects.
get_ast_id¶
def get_ast_id(self, t: Ast) raises -> UInt32
Return a unique identifier for t. The identifier is unique up to structural equality. Thus, two ast nodes created by the same context and having the same children and same function symbols have the same identifiers. Ast nodes created in the same context, but having different children or different functions have different identifiers. Variables and quantifiers are also assigned different identifiers according to their structure.
get_ast_kind¶
def get_ast_kind(self, a: Ast) raises -> AstKind
Return the kind of the given AST.
get_bool_value¶
def get_bool_value(self, a: Ast) raises -> Lbool
Return Z3_L_TRUE if a is true, Z3_L_FALSE if it is false, and Z3_L_UNDEF otherwise.
get_bv_sort_size¶
def get_bv_sort_size(self, t: Sort) raises -> UInt32
Return the size of the given bit-vector sort.
get_datatype_sort_constructor¶
def get_datatype_sort_constructor(self, t: Sort, idx: UInt32) raises -> FuncDecl
Return idx'th constructor.
get_datatype_sort_constructor_accessor¶
def get_datatype_sort_constructor_accessor(self, t: Sort, idx_c: UInt32, idx_a: UInt32) raises -> FuncDecl
Return idx_a'th accessor for the idx_c'th constructor.
get_datatype_sort_num_constructors¶
def get_datatype_sort_num_constructors(self, t: Sort) raises -> UInt32
Return number of constructors for datatype.
get_datatype_sort_recognizer¶
def get_datatype_sort_recognizer(self, t: Sort, idx: UInt32) raises -> FuncDecl
Return idx'th recognizer.
get_decl_ast_parameter¶
def get_decl_ast_parameter(self, d: FuncDecl, idx: UInt32) raises -> Ast
Return the expression value associated with an expression parameter.
get_decl_double_parameter¶
def get_decl_double_parameter(self, d: FuncDecl, idx: UInt32) raises -> Float64
Return the double value associated with an double parameter.
get_decl_func_decl_parameter¶
def get_decl_func_decl_parameter(self, d: FuncDecl, idx: UInt32) raises -> FuncDecl
Return the expression value associated with an expression parameter.
get_decl_int_parameter¶
def get_decl_int_parameter(self, d: FuncDecl, idx: UInt32) raises -> Int32
Return the integer value associated with an integer parameter.
get_decl_kind¶
def get_decl_kind(self, d: FuncDecl) raises -> DeclKind
Return declaration kind corresponding to declaration.
get_decl_name¶
def get_decl_name(self, d: FuncDecl) raises -> Symbol
Return the constant declaration name as a symbol.
get_decl_num_parameters¶
def get_decl_num_parameters(self, d: FuncDecl) raises -> UInt32
Return the number of parameters associated with a declaration.
get_decl_parameter_kind¶
def get_decl_parameter_kind(self, d: FuncDecl, idx: UInt32) raises -> ParameterKind
Return the parameter type associated with a declaration.
get_decl_rational_parameter¶
def get_decl_rational_parameter(self, d: FuncDecl, idx: UInt32) raises -> String
Return the rational value, as a string, associated with a rational parameter.
get_decl_sort_parameter¶
def get_decl_sort_parameter(self, d: FuncDecl, idx: UInt32) raises -> Sort
Return the sort value associated with a sort parameter.
get_decl_symbol_parameter¶
def get_decl_symbol_parameter(self, d: FuncDecl, idx: UInt32) raises -> Symbol
Return the double value associated with an double parameter.
get_denominator¶
def get_denominator(self, a: Ast) raises -> Ast
Return the denominator (as a numeral AST) of a numeral AST of sort Real.
get_depth¶
def get_depth(self, a: Ast) raises -> UInt32
Safe wrapper for Z3_get_depth.
get_domain¶
def get_domain(self, d: FuncDecl, i: UInt32) raises -> Sort
Return the sort of the i-th parameter of the given function declaration.
get_domain_size¶
def get_domain_size(self, d: FuncDecl) raises -> UInt32
Return the number of parameters of the given declaration.
get_finite_domain_sort_size¶
def get_finite_domain_sort_size(self, s: Sort) raises -> Optional[UInt64]
Store the size of the sort in r. Return false if the call failed. That is, Z3_get_sort_kind(s) == Z3_FINITE_DOMAIN_SORT
get_func_decl_id¶
def get_func_decl_id(self, f: FuncDecl) raises -> UInt32
Return a unique identifier for f.
get_index_value¶
def get_index_value(self, a: Ast) raises -> UInt32
Return index of de-Bruijn bound variable.
get_numeral_binary_string¶
def get_numeral_binary_string(self, a: Ast) raises -> String
Return numeral value, as a binary string of a numeric constant term
get_numeral_decimal_string¶
def get_numeral_decimal_string(self, a: Ast, precision: UInt32) raises -> String
Return numeral as a string in decimal notation. The result has at most precision decimal places.
get_numeral_double¶
def get_numeral_double(self, a: Ast) raises -> Float64
Return numeral as a double.
get_numeral_int¶
def get_numeral_int(self, v: Ast) raises -> Optional[Int32]
Similar to Z3_get_numeral_string, but only succeeds if the value can fit in a machine int. Return true if the call succeeded.
get_numeral_int64¶
def get_numeral_int64(self, v: Ast) raises -> Optional[Int64]
Similar to Z3_get_numeral_string, but only succeeds if the value can fit in a machine int64_t int. Return true if the call succeeded.
get_numeral_rational_int64¶
def get_numeral_rational_int64(self, v: Ast) raises -> Optional[Tuple[Int64, Int64]]
Similar to Z3_get_numeral_string, but only succeeds if the value can fit as a rational number as machine int64_t int. Return true if the call succeeded.
get_numeral_small¶
def get_numeral_small(self, a: Ast) raises -> Optional[Tuple[Int64, Int64]]
Return numeral value, as a pair of 64 bit numbers if the representation fits.
Return true if the numeral value fits in 64 bit numerals, false otherwise.
Equivalent to Z3_get_numeral_rational_int64 except that for unsupported expression arguments Z3_get_numeral_small signals an error while Z3_get_numeral_rational_int64 returns false.
get_numeral_string¶
def get_numeral_string(self, a: Ast) raises -> String
Return numeral value, as a decimal string of a numeric constant term
get_numeral_uint¶
def get_numeral_uint(self, v: Ast) raises -> Optional[UInt32]
Similar to Z3_get_numeral_string, but only succeeds if the value can fit in a machine unsigned int. Return true if the call succeeded.
get_numeral_uint64¶
def get_numeral_uint64(self, v: Ast) raises -> Optional[UInt64]
Similar to Z3_get_numeral_string, but only succeeds if the value can fit in a machine uint64_t int. Return true if the call succeeded.
get_numerator¶
def get_numerator(self, a: Ast) raises -> Ast
Return the numerator (as a numeral AST) of a numeral AST of sort Real.
get_pattern¶
def get_pattern(self, p: Pattern, idx: UInt32) raises -> Ast
Return i'th ast in pattern.
get_pattern_num_terms¶
def get_pattern_num_terms(self, p: Pattern) raises -> UInt32
Return number of terms in pattern.
get_quantifier_body¶
def get_quantifier_body(self, a: Ast) raises -> Ast
Return body of quantifier.
get_quantifier_bound_name¶
def get_quantifier_bound_name(self, a: Ast, i: UInt32) raises -> Symbol
Return symbol of the i'th bound variable.
get_quantifier_bound_sort¶
def get_quantifier_bound_sort(self, a: Ast, i: UInt32) raises -> Sort
Return sort of the i'th bound variable.
get_quantifier_id¶
def get_quantifier_id(self, a: Ast) raises -> Symbol
Obtain id of quantifier.
get_quantifier_no_pattern_ast¶
def get_quantifier_no_pattern_ast(self, a: Ast, i: UInt32) raises -> Ast
Return i'th no_pattern.
get_quantifier_num_bound¶
def get_quantifier_num_bound(self, a: Ast) raises -> UInt32
Return number of bound variables of quantifier.
get_quantifier_num_no_patterns¶
def get_quantifier_num_no_patterns(self, a: Ast) raises -> UInt32
Return number of no_patterns used in quantifier.
get_quantifier_num_patterns¶
def get_quantifier_num_patterns(self, a: Ast) raises -> UInt32
Return number of patterns used in quantifier.
get_quantifier_pattern_ast¶
def get_quantifier_pattern_ast(self, a: Ast, i: UInt32) raises -> Pattern
Return i'th pattern.
get_quantifier_skolem_id¶
def get_quantifier_skolem_id(self, a: Ast) raises -> Symbol
Obtain skolem id of quantifier.
get_quantifier_weight¶
def get_quantifier_weight(self, a: Ast) raises -> UInt32
Obtain weight of quantifier.
get_range¶
def get_range(self, d: FuncDecl) raises -> Sort
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_relation_arity¶
def get_relation_arity(self, s: Sort) raises -> UInt32
Return arity of relation.
get_relation_column¶
def get_relation_column(self, s: Sort, col: UInt32) raises -> Sort
Return sort at i'th column of relation sort.
get_sort¶
def get_sort(self, a: Ast) raises -> Sort
Return the sort of an AST node.
The AST node must be a constant, application, numeral, bound variable, or quantifier.
get_sort_id¶
def get_sort_id(self, s: Sort) raises -> UInt32
Return a unique identifier for s.
get_sort_kind¶
def get_sort_kind(self, t: Sort) raises -> SortKind
Return the sort kind (e.g., array, tuple, int, bool, etc).
get_sort_name¶
def get_sort_name(self, d: Sort) raises -> Symbol
Return the sort name as a symbol.
get_symbol_int¶
def get_symbol_int(self, s: Symbol) raises -> Int32
Return the symbol int value.
get_symbol_kind¶
def get_symbol_kind(self, s: Symbol) raises -> SymbolKind
Return Z3_INT_SYMBOL if the symbol was constructed using Z3_mk_int_symbol, and Z3_STRING_SYMBOL if the symbol was constructed using Z3_mk_string_symbol.
get_symbol_string¶
def get_symbol_string(self, s: Symbol) raises -> String
Return the symbol name.
get_tuple_sort_field_decl¶
def get_tuple_sort_field_decl(self, t: Sort, i: UInt32) raises -> FuncDecl
Return the i-th field declaration (i.e., projection function declaration) of the given tuple sort.
get_tuple_sort_mk_decl¶
def get_tuple_sort_mk_decl(self, t: Sort) raises -> FuncDecl
Return the constructor declaration of the given tuple sort.
get_tuple_sort_num_fields¶
def get_tuple_sort_num_fields(self, t: Sort) raises -> UInt32
Return the number of fields of the given tuple sort.
is_algebraic_number¶
def is_algebraic_number(self, a: Ast) raises -> Bool
Return true if the given AST is a real algebraic number.
is_app¶
def is_app(self, a: Ast) raises -> Bool
Safe wrapper for Z3_is_app.
is_eq_ast¶
def is_eq_ast(self, t1: Ast, t2: Ast) raises -> Bool
Compare terms.
is_eq_func_decl¶
def is_eq_func_decl(self, f1: FuncDecl, f2: FuncDecl) raises -> Bool
Compare terms.
is_eq_sort¶
def is_eq_sort(self, s1: Sort, s2: Sort) raises -> Bool
compare sorts.
is_ground¶
def is_ground(self, a: Ast) raises -> Bool
Safe wrapper for Z3_is_ground.
is_lambda¶
def is_lambda(self, a: Ast) raises -> Bool
Determine if ast is a lambda expression.
is_numeral_ast¶
def is_numeral_ast(self, a: Ast) raises -> Bool
Safe wrapper for Z3_is_numeral_ast.
is_quantifier_exists¶
def is_quantifier_exists(self, a: Ast) raises -> Bool
Determine if ast is an existential quantifier.
is_quantifier_forall¶
def is_quantifier_forall(self, a: Ast) raises -> Bool
Determine if an ast is a universal quantifier.
is_recursive_datatype_sort¶
def is_recursive_datatype_sort(self, s: Sort) raises -> Bool
Check if s is a recursive datatype sort.
is_well_sorted¶
def is_well_sorted(self, t: Ast) raises -> Bool
Return true if the given expression t is well sorted.
mk_atleast¶
def mk_atleast(self, args: List[Ast], k: UInt32) raises -> Ast
Pseudo-Boolean relations.
Encode p1 + p2 + ... + pn >= k
mk_atmost¶
def mk_atmost(self, args: List[Ast], k: UInt32) raises -> Ast
Pseudo-Boolean relations.
Encode p1 + p2 + ... + pn <= k
mk_pbeq¶
def mk_pbeq(self, args: List[Ast], coeffs: List[Int32], k: Int32) raises -> Ast
Pseudo-Boolean relations.
Encode k1p1 + k2p2 + ... + kn*pn = k
mk_pbge¶
def mk_pbge(self, args: List[Ast], coeffs: List[Int32], k: Int32) raises -> Ast
Pseudo-Boolean relations.
Encode k1p1 + k2p2 + ... + kn*pn >= k
mk_pble¶
def mk_pble(self, args: List[Ast], coeffs: List[Int32], k: Int32) raises -> Ast
Pseudo-Boolean relations.
Encode k1p1 + k2p2 + ... + kn*pn <= k
pattern_to_ast¶
def pattern_to_ast(self, p: Pattern) raises -> Ast
Convert a Z3_pattern into Z3_ast. This is just type casting.
simplify¶
def simplify(self, a: Ast) raises -> Ast
Interface to simplifier.
Provides an interface to the AST simplifier used by Z3. It returns an AST object which is equal to the argument. The returned AST is simplified using algebraic simplification rules, such as constant propagation (propagating true/false over logical connectives).
simplify_ex¶
def simplify_ex(self, a: Ast, p: Params) raises -> Ast
Interface to simplifier.
Provides an interface to the AST simplifier used by Z3. This procedure is similar to Z3_simplify, but the behavior of the simplifier can be configured using the given parameter set.
simplify_get_help¶
def simplify_get_help(self) raises -> String
Return a string describing all available parameters.
simplify_get_param_descrs¶
def simplify_get_param_descrs(self) raises -> ParamDescrs
Return the parameter description set for the simplify procedure.
sort_to_ast¶
def sort_to_ast(self, s: Sort) raises -> Ast
Convert a Z3_sort into Z3_ast. This is just type casting.
to_app¶
def to_app(self, a: Ast) raises -> App
Convert an ast into an APP_AST. This is just type casting.
to_func_decl¶
def to_func_decl(self, a: Ast) raises -> FuncDecl
Convert an AST into a FUNC_DECL_AST. This is just type casting.
Modifiers (5)¶
substitute¶
def substitute(self, a: Ast, from_: List[Ast], to: List[Ast]) raises -> Ast
Substitute every occurrence of from[i] in a with to[i], for i smaller than num_exprs. The result is the new AST. The arrays from and to must have size num_exprs. For every i smaller than num_exprs, we must have that sort of from[i] must be equal to sort of to[i].
substitute_funs¶
def substitute_funs(self, a: Ast, from_: List[FuncDecl], to: List[Ast]) raises -> Ast
Substitute functions in from with new expressions in to.
The expressions in to can have free variables. The free variable in to at index 0 refers to the first argument of from, the free variable at index 1 corresponds to the second argument.
substitute_vars¶
def substitute_vars(self, a: Ast, to: List[Ast]) raises -> Ast
Substitute the variables in a with the expressions in to. For every i smaller than num_exprs, the variable with de-Bruijn index i is replaced with term to[i]. Note that a variable is created using the function Z3_mk_bound.
translate¶
def translate(self, a: Ast, target: Context) raises -> Ast
Translate/Copy the AST a from context source to context target. AST a must have been created using context source.
update_term¶
def update_term(self, a: Ast, args: List[Ast]) raises -> Ast
Update the arguments of term a using the arguments args. The number of arguments num_args should coincide with the number of arguments to a. If a is a quantifier, then num_args has to be 1.
Models (5)¶
add_const_interp¶
def add_const_interp(self, m: Model, f: FuncDecl, a: Ast) raises
Add a constant interpretation.
add_func_interp¶
def add_func_interp(self, m: Model, f: FuncDecl, default_value: Ast) raises -> FuncInterp
Create a fresh func_interp object, add it to a model for a specified function. It has reference count 0.
get_as_array_func_decl¶
def get_as_array_func_decl(self, a: Ast) raises -> FuncDecl
Return the function declaration f associated with a (_ as_array f) node.
is_as_array¶
def is_as_array(self, a: Ast) raises -> Bool
The (_ as-array f) AST node is a construct for assigning interpretations for arrays in Z3. It is the array such that forall indices i we have that (select (_ as-array f) i) is equal to (f i). This procedure returns true if the a is an as-array AST node.
Z3 current solvers have minimal support for as_array nodes.
mk_model¶
def mk_model(self) raises -> Model
Create a fresh model object. It has reference count 0.
String conversion (6)¶
ast_to_string¶
def ast_to_string(self, a: Ast) raises -> String
Convert the given AST node into a string.
benchmark_to_smtlib_string¶
def benchmark_to_smtlib_string(self, name: String, logic: String, status: String, attributes: String, assumptions: List[Ast], formula: Ast) raises -> String
Convert the given benchmark into SMT-LIB formatted string.
func_decl_to_string¶
def func_decl_to_string(self, d: FuncDecl) raises -> String
Safe wrapper for Z3_func_decl_to_string.
pattern_to_string¶
def pattern_to_string(self, p: Pattern) raises -> String
Safe wrapper for Z3_pattern_to_string.
set_ast_print_mode¶
def set_ast_print_mode(self, mode: AstPrintMode) raises
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 Z3_PRINT_SMTLIB_FULL. To print shared common subexpressions only once, use the Z3_PRINT_LOW_LEVEL mode. To print in way that conforms to SMT-LIB standards and uses let expressions to share common sub-expressions use Z3_PRINT_SMTLIB2_COMPLIANT.
sort_to_string¶
def sort_to_string(self, s: Sort) raises -> String
Safe wrapper for Z3_sort_to_string.
Parser interface (4)¶
eval_smtlib2_string¶
def eval_smtlib2_string(self, str: String) raises -> String
Parse and evaluate and SMT-LIB2 command sequence. The state from a previous call is saved so the next evaluation builds on top of the previous call.
mk_parser_context¶
def mk_parser_context(self) raises -> ParserContext
Create a parser context.
A parser context maintains state between calls to Z3_parser_context_parse_string where the caller can pass in a set of SMTLIB2 commands. It maintains all the declarations from previous calls together with of sorts and function declarations (including 0-ary) that are added directly to the context.
parse_smtlib2_file¶
def parse_smtlib2_file(self, file_name: String, sort_names: List[Symbol], sorts: List[Sort], decl_names: List[Symbol], decls: List[FuncDecl]) raises -> AstVector
Similar to Z3_parse_smtlib2_string, but reads the benchmark from a file.
parse_smtlib2_string¶
def parse_smtlib2_string(self, str: String, sort_names: List[Symbol], sorts: List[Sort], decl_names: List[Symbol], decls: List[FuncDecl]) raises -> AstVector
Parse the given string using the SMT-LIB2 parser.
It returns a formula comprising of the conjunction of assertions in the scope (up to push/pop) at the end of the string.
Error Handling (3)¶
get_error_code¶
def get_error_code(self) raises -> ErrorCode
Return the error code for the last API call.
A call to a Z3 function may return a non Z3_OK error code, when it is not used correctly.
get_error_msg¶
def get_error_msg(self, err: ErrorCode) raises -> String
Return a string describing the given error code.
set_error¶
def set_error(self, e: ErrorCode) raises
Set an error.
Tactics, Simplifiers and Probes (19)¶
get_num_probes¶
def get_num_probes(self) raises -> UInt32
Return the number of builtin probes available in Z3.
get_num_simplifiers¶
def get_num_simplifiers(self) raises -> UInt32
Return the number of builtin simplifiers available in Z3.
get_num_tactics¶
def get_num_tactics(self) raises -> UInt32
Return the number of builtin tactics available in Z3.
get_probe_name¶
def get_probe_name(self, i: UInt32) raises -> String
Return the name of the i probe.
get_simplifier_name¶
def get_simplifier_name(self, i: UInt32) raises -> String
Return the name of the idx simplifier.
get_tactic_name¶
def get_tactic_name(self, i: UInt32) raises -> String
Return the name of the idx tactic.
mk_probe¶
def mk_probe(self, name: String) raises -> Probe
Return a probe associated with the given name. The complete list of probes may be obtained using the procedures Z3_get_num_probes and Z3_get_probe_name. It may also be obtained using the command (help-tactic) in the SMT 2.0 front-end.
Probes are used to inspect a goal (aka problem) and collect information that may be used to decide which solver and/or preprocessing step will be used.
mk_simplifier¶
def mk_simplifier(self, name: String) raises -> Simplifier
Return a simplifier associated with the given name. The complete list of simplifiers may be obtained using the procedures Z3_get_num_simplifiers and Z3_get_simplifier_name. It may also be obtained using the command (help-simplifier) in the SMT 2.0 front-end.
Simplifiers are the basic building block for creating custom solvers for specific problem domains.
probe_const¶
def probe_const(self, val: Float64) raises -> Probe
Return a probe that always evaluates to val.
probe_get_descr¶
def probe_get_descr(self, name: String) raises -> String
Return a string containing a description of the probe with the given name.
simplifier_get_descr¶
def simplifier_get_descr(self, name: String) raises -> String
Return a string containing a description of the simplifier with the given name.
tactic_cond¶
def tactic_cond(self, p: Probe, t1: Tactic, t2: Tactic) raises -> Tactic
Return a tactic that applies t1 to a given goal if the probe p evaluates to true, and t2 if p evaluates to false.
tactic_fail¶
def tactic_fail(self) raises -> Tactic
Return a tactic that always fails.
tactic_fail_if¶
def tactic_fail_if(self, p: Probe) raises -> Tactic
Return a tactic that fails if the probe p evaluates to false.
tactic_fail_if_not_decided¶
def tactic_fail_if_not_decided(self) raises -> Tactic
Return a tactic that fails if the goal is not trivially satisfiable (i.e., empty) or trivially unsatisfiable (i.e., contains false).
tactic_get_descr¶
def tactic_get_descr(self, name: String) raises -> String
Return a string containing a description of the tactic with the given name.
tactic_par_or¶
def tactic_par_or(self, ts: List[Tactic]) raises -> Tactic
Return a tactic that applies the given tactics in parallel.
tactic_skip¶
def tactic_skip(self) raises -> Tactic
Return a tactic that just return the given goal.
tactic_when¶
def tactic_when(self, p: Probe, t: Tactic) raises -> Tactic
Return a tactic that applies t to a given goal is the probe p evaluates to true. If p evaluates to false, then the new tactic behaves like the skip tactic.
Solvers (3)¶
mk_simple_solver¶
def mk_simple_solver(self) raises -> Solver
Create a new incremental solver.
This is equivalent to applying the "smt" tactic.
Unlike Z3_mk_solver() this solver
- Does not attempt to apply any logic specific tactics.
- Does not change its behaviour based on whether it used incrementally/non-incrementally.
Note that these differences can result in very different performance compared to Z3_mk_solver().
The function Z3_solver_get_model retrieves a model if the assertions is satisfiable (i.e., the result is Z3_L_TRUE) and model construction is enabled. The function Z3_solver_get_model can also be used even if the result is Z3_L_UNDEF, but the returned model is not guaranteed to satisfy quantified assertions.
solver_next_split¶
def solver_next_split(self, cb: SolverCallback, t: Ast, idx: UInt32, phase: Lbool) raises -> Bool
Sets the next (registered) expression to split on. The function returns false and ignores the given expression in case the expression is already assigned internally (due to relevancy propagation, this assignments might not have been reported yet by the fixed callback). In case the function is called in the decide callback, it overrides the currently selected variable and phase.
solver_propagate_declare¶
def solver_propagate_declare(self, name: Symbol, domain: List[Sort], range_: Sort) raises -> FuncDecl
Create uninterpreted function declaration for the user propagator. When expressions using the function are created by the solver invoke a callback to Z3_solver_propagate_created with arguments
- context and callback solve
- declared_expr: expression using function that was used as the top-level symbol
- declared_id: a unique identifier (unique within the current scope) to track the expression.
AST vectors (1)¶
mk_ast_vector¶
def mk_ast_vector(self) raises -> AstVector
Return an empty AST vector.
AST maps (1)¶
mk_ast_map¶
def mk_ast_map(self) raises -> AstMap
Return an empty mapping from AST to AST
Floating-Point Arithmetic (61)¶
mk_fpa_abs¶
def mk_fpa_abs(self, t: Ast) raises -> Ast
Floating-point absolute value
mk_fpa_add¶
def mk_fpa_add(self, rm: Ast, t1: Ast, t2: Ast) raises -> Ast
Floating-point addition
rm must be of RoundingMode sort, t1 and t2 must have the same FloatingPoint sort.
mk_fpa_div¶
def mk_fpa_div(self, rm: Ast, t1: Ast, t2: Ast) raises -> Ast
Floating-point division
The nodes rm must be of RoundingMode sort, t1 and t2 must have the same FloatingPoint sort.
mk_fpa_eq¶
def mk_fpa_eq(self, t1: Ast, t2: Ast) raises -> Ast
Floating-point equality.
Note that this is IEEE 754 equality (as opposed to SMT-LIB =).
t1 and t2 must have the same FloatingPoint sort.
mk_fpa_fma¶
def mk_fpa_fma(self, rm: Ast, t1: Ast, t2: Ast, t3: Ast) raises -> Ast
Floating-point fused multiply-add.
The result is round((t1 * t2) + t3).
rm must be of RoundingMode sort, t1, t2, and t3 must have the same FloatingPoint sort.
mk_fpa_fp¶
def mk_fpa_fp(self, sgn: Ast, exp: Ast, sig: Ast) raises -> Ast
Create an expression of FloatingPoint sort from three bit-vector expressions.
This is the operator named fp' in the SMT FP theory definition. Note thatsgn` is required to be a bit-vector of size 1. Significand and exponent are required to be longer than 1 and 2 respectively. The FloatingPoint sort of the resulting expression is automatically determined from the bit-vector sizes of the arguments. The exponent is assumed to be in IEEE-754 biased representation.
mk_fpa_geq¶
def mk_fpa_geq(self, t1: Ast, t2: Ast) raises -> Ast
Floating-point greater than or equal.
t1 and t2 must have the same FloatingPoint sort.
mk_fpa_gt¶
def mk_fpa_gt(self, t1: Ast, t2: Ast) raises -> Ast
Floating-point greater than.
t1 and t2 must have the same FloatingPoint sort.
mk_fpa_inf¶
def mk_fpa_inf(self, s: Sort, negative: Bool) raises -> Ast
Create a floating-point infinity of sort s.
When negative is true, -oo will be generated instead of +oo.
mk_fpa_is_infinite¶
def mk_fpa_is_infinite(self, t: Ast) raises -> Ast
Predicate indicating whether t is a floating-point number representing +oo or -oo.
t must have FloatingPoint sort.
mk_fpa_is_nan¶
def mk_fpa_is_nan(self, t: Ast) raises -> Ast
Predicate indicating whether t is a NaN.
t must have FloatingPoint sort.
mk_fpa_is_negative¶
def mk_fpa_is_negative(self, t: Ast) raises -> Ast
Predicate indicating whether t is a negative floating-point number.
t must have FloatingPoint sort.
mk_fpa_is_normal¶
def mk_fpa_is_normal(self, t: Ast) raises -> Ast
Predicate indicating whether t is a normal floating-point number.
t must have FloatingPoint sort.
mk_fpa_is_positive¶
def mk_fpa_is_positive(self, t: Ast) raises -> Ast
Predicate indicating whether t is a positive floating-point number.
t must have FloatingPoint sort.
mk_fpa_is_subnormal¶
def mk_fpa_is_subnormal(self, t: Ast) raises -> Ast
Predicate indicating whether t is a subnormal floating-point number.
t must have FloatingPoint sort.
mk_fpa_is_zero¶
def mk_fpa_is_zero(self, t: Ast) raises -> Ast
Predicate indicating whether t is a floating-point number with zero value, i.e., +zero or -zero.
t must have FloatingPoint sort.
mk_fpa_leq¶
def mk_fpa_leq(self, t1: Ast, t2: Ast) raises -> Ast
Floating-point less than or equal.
t1 and t2 must have the same FloatingPoint sort.
mk_fpa_lt¶
def mk_fpa_lt(self, t1: Ast, t2: Ast) raises -> Ast
Floating-point less than.
t1 and t2 must have the same FloatingPoint sort.
mk_fpa_max¶
def mk_fpa_max(self, t1: Ast, t2: Ast) raises -> Ast
Maximum of floating-point numbers.
t1, t2 must have the same FloatingPoint sort.
mk_fpa_min¶
def mk_fpa_min(self, t1: Ast, t2: Ast) raises -> Ast
Minimum of floating-point numbers.
t1, t2 must have the same FloatingPoint sort.
mk_fpa_mul¶
def mk_fpa_mul(self, rm: Ast, t1: Ast, t2: Ast) raises -> Ast
Floating-point multiplication
rm must be of RoundingMode sort, t1 and t2 must have the same FloatingPoint sort.
mk_fpa_nan¶
def mk_fpa_nan(self, s: Sort) raises -> Ast
Create a floating-point NaN of sort s.
mk_fpa_neg¶
def mk_fpa_neg(self, t: Ast) raises -> Ast
Floating-point negation
mk_fpa_numeral_double¶
def mk_fpa_numeral_double(self, v: Float64, ty: Sort) raises -> Ast
Create a numeral of FloatingPoint sort from a double.
This function is used to create numerals that fit in a double value. It is slightly faster than Z3_mk_numeral since it is not necessary to parse a string.
ty must be a FloatingPoint sort
mk_fpa_numeral_float¶
def mk_fpa_numeral_float(self, v: Float32, ty: Sort) raises -> Ast
Create a numeral of FloatingPoint sort from a float.
This function is used to create numerals that fit in a float value. It is slightly faster than Z3_mk_numeral since it is not necessary to parse a string.
ty must be a FloatingPoint sort
mk_fpa_numeral_int¶
def mk_fpa_numeral_int(self, v: Int32, ty: Sort) raises -> Ast
Create a numeral of FloatingPoint sort from a signed integer.
ty must be a FloatingPoint sort
mk_fpa_numeral_int64_uint64¶
def mk_fpa_numeral_int64_uint64(self, sgn: Bool, exp: Int64, sig: UInt64, ty: Sort) raises -> Ast
Create a numeral of FloatingPoint sort from a sign bit and two 64-bit integers.
ty must be a FloatingPoint sort
mk_fpa_numeral_int_uint¶
def mk_fpa_numeral_int_uint(self, sgn: Bool, exp: Int32, sig: UInt32, ty: Sort) raises -> Ast
Create a numeral of FloatingPoint sort from a sign bit and two integers.
ty must be a FloatingPoint sort
mk_fpa_rem¶
def mk_fpa_rem(self, t1: Ast, t2: Ast) raises -> Ast
Floating-point remainder
t1 and t2 must have the same FloatingPoint sort.
mk_fpa_rna¶
def mk_fpa_rna(self) raises -> Ast
Create a numeral of RoundingMode sort which represents the NearestTiesToAway rounding mode.
This is the same as Z3_mk_fpa_round_nearest_ties_to_away.
mk_fpa_rne¶
def mk_fpa_rne(self) raises -> Ast
Create a numeral of RoundingMode sort which represents the NearestTiesToEven rounding mode.
This is the same as Z3_mk_fpa_round_nearest_ties_to_even.
mk_fpa_round_nearest_ties_to_away¶
def mk_fpa_round_nearest_ties_to_away(self) raises -> Ast
Create a numeral of RoundingMode sort which represents the NearestTiesToAway rounding mode.
This is the same as Z3_mk_fpa_rna.
mk_fpa_round_nearest_ties_to_even¶
def mk_fpa_round_nearest_ties_to_even(self) raises -> Ast
Create a numeral of RoundingMode sort which represents the NearestTiesToEven rounding mode.
This is the same as Z3_mk_fpa_rne.
mk_fpa_round_to_integral¶
def mk_fpa_round_to_integral(self, rm: Ast, t: Ast) raises -> Ast
Floating-point roundToIntegral. Rounds a floating-point number to the closest integer, again represented as a floating-point number.
t must be of FloatingPoint sort.
mk_fpa_round_toward_negative¶
def mk_fpa_round_toward_negative(self) raises -> Ast
Create a numeral of RoundingMode sort which represents the TowardNegative rounding mode.
This is the same as Z3_mk_fpa_rtn.
mk_fpa_round_toward_positive¶
def mk_fpa_round_toward_positive(self) raises -> Ast
Create a numeral of RoundingMode sort which represents the TowardPositive rounding mode.
This is the same as Z3_mk_fpa_rtp.
mk_fpa_round_toward_zero¶
def mk_fpa_round_toward_zero(self) raises -> Ast
Create a numeral of RoundingMode sort which represents the TowardZero rounding mode.
This is the same as Z3_mk_fpa_rtz.
mk_fpa_rounding_mode_sort¶
def mk_fpa_rounding_mode_sort(self) raises -> Sort
Create the RoundingMode sort.
mk_fpa_rtn¶
def mk_fpa_rtn(self) raises -> Ast
Create a numeral of RoundingMode sort which represents the TowardNegative rounding mode.
This is the same as Z3_mk_fpa_round_toward_negative.
mk_fpa_rtp¶
def mk_fpa_rtp(self) raises -> Ast
Create a numeral of RoundingMode sort which represents the TowardPositive rounding mode.
This is the same as Z3_mk_fpa_round_toward_positive.
mk_fpa_rtz¶
def mk_fpa_rtz(self) raises -> Ast
Create a numeral of RoundingMode sort which represents the TowardZero rounding mode.
This is the same as Z3_mk_fpa_round_toward_zero.
mk_fpa_sort¶
def mk_fpa_sort(self, ebits: UInt32, sbits: UInt32) raises -> Sort
Create a FloatingPoint sort.
mk_fpa_sort_128¶
def mk_fpa_sort_128(self) raises -> Sort
Create the quadruple-precision (128-bit) FloatingPoint sort.
This is the same as Z3_mk_fpa_sort_quadruple.
mk_fpa_sort_16¶
def mk_fpa_sort_16(self) raises -> Sort
Create the half-precision (16-bit) FloatingPoint sort.
This is the same as Z3_mk_fpa_sort_half.
mk_fpa_sort_32¶
def mk_fpa_sort_32(self) raises -> Sort
Create the single-precision (32-bit) FloatingPoint sort.
This is the same as Z3_mk_fpa_sort_single.
mk_fpa_sort_64¶
def mk_fpa_sort_64(self) raises -> Sort
Create the double-precision (64-bit) FloatingPoint sort.
This is the same as Z3_mk_fpa_sort_double.
mk_fpa_sort_double¶
def mk_fpa_sort_double(self) raises -> Sort
Create the double-precision (64-bit) FloatingPoint sort.
This is the same as Z3_mk_fpa_sort_64.
mk_fpa_sort_half¶
def mk_fpa_sort_half(self) raises -> Sort
Create the half-precision (16-bit) FloatingPoint sort.
This is the same as Z3_mk_fpa_sort_16.
mk_fpa_sort_quadruple¶
def mk_fpa_sort_quadruple(self) raises -> Sort
Create the quadruple-precision (128-bit) FloatingPoint sort.
This is the same as Z3_mk_fpa_sort_128.
mk_fpa_sort_single¶
def mk_fpa_sort_single(self) raises -> Sort
Create the single-precision (32-bit) FloatingPoint sort.
This is the same as Z3_mk_fpa_sort_32.
mk_fpa_sqrt¶
def mk_fpa_sqrt(self, rm: Ast, t: Ast) raises -> Ast
Floating-point square root
rm must be of RoundingMode sort, t must have FloatingPoint sort.
mk_fpa_sub¶
def mk_fpa_sub(self, rm: Ast, t1: Ast, t2: Ast) raises -> Ast
Floating-point subtraction
rm must be of RoundingMode sort, t1 and t2 must have the same FloatingPoint sort.
mk_fpa_to_fp_bv¶
def mk_fpa_to_fp_bv(self, bv: Ast, s: Sort) raises -> Ast
Conversion of a single IEEE 754-2008 bit-vector into a floating-point number.
Produces a term that represents the conversion of a bit-vector term bv to a floating-point term of sort s.
s must be a FloatingPoint sort, t must be of bit-vector sort, and the bit-vector size of bv must be equal to ebits+sbits of s. The format of the bit-vector is as defined by the IEEE 754-2008 interchange format.
mk_fpa_to_fp_float¶
def mk_fpa_to_fp_float(self, rm: Ast, t: Ast, s: Sort) raises -> Ast
Conversion of a FloatingPoint term into another term of different FloatingPoint sort.
Produces a term that represents the conversion of a floating-point term t to a floating-point term of sort s. If necessary, the result will be rounded according to rounding mode rm.
s must be a FloatingPoint sort, rm must be of RoundingMode sort, t must be of floating-point sort.
mk_fpa_to_fp_real¶
def mk_fpa_to_fp_real(self, rm: Ast, t: Ast, s: Sort) raises -> Ast
Conversion of a term of real sort into a term of FloatingPoint sort.
Produces a term that represents the conversion of term t of real sort into a floating-point term of sort s. If necessary, the result will be rounded according to rounding mode rm.
s must be a FloatingPoint sort, rm must be of RoundingMode sort, t must be of real sort.
mk_fpa_to_fp_signed¶
def mk_fpa_to_fp_signed(self, rm: Ast, t: Ast, s: Sort) raises -> Ast
Conversion of a 2's complement signed bit-vector term into a term of FloatingPoint sort.
Produces a term that represents the conversion of the bit-vector term t into a floating-point term of sort s. The bit-vector t is taken to be in signed 2's complement format. If necessary, the result will be rounded according to rounding mode rm.
s must be a FloatingPoint sort, rm must be of RoundingMode sort, t must be of bit-vector sort.
mk_fpa_to_fp_unsigned¶
def mk_fpa_to_fp_unsigned(self, rm: Ast, t: Ast, s: Sort) raises -> Ast
Conversion of a 2's complement unsigned bit-vector term into a term of FloatingPoint sort.
Produces a term that represents the conversion of the bit-vector term t into a floating-point term of sort s. The bit-vector t is taken to be in unsigned 2's complement format. If necessary, the result will be rounded according to rounding mode rm.
s must be a FloatingPoint sort, rm must be of RoundingMode sort, t must be of bit-vector sort.
mk_fpa_to_real¶
def mk_fpa_to_real(self, t: Ast) raises -> Ast
Conversion of a floating-point term into a real-numbered term.
Produces a term that represents the conversion of the floating-point term t into a real number. Note that this type of conversion will often result in non-linear constraints over real terms.
mk_fpa_to_sbv¶
def mk_fpa_to_sbv(self, rm: Ast, t: Ast, sz: UInt32) raises -> Ast
Conversion of a floating-point term into a signed bit-vector.
Produces a term that represents the conversion of the floating-point term t into a bit-vector term of size sz in signed 2's complement format. If necessary, the result will be rounded according to rounding mode rm.
mk_fpa_to_ubv¶
def mk_fpa_to_ubv(self, rm: Ast, t: Ast, sz: UInt32) raises -> Ast
Conversion of a floating-point term into an unsigned bit-vector.
Produces a term that represents the conversion of the floating-point term t into a bit-vector term of size sz in unsigned 2's complement format. If necessary, the result will be rounded according to rounding mode rm.
mk_fpa_zero¶
def mk_fpa_zero(self, s: Sort, negative: Bool) raises -> Ast
Create a floating-point zero of sort s.
When negative is true, -zero will be generated instead of +zero.
Z3-specific floating-point extensions (20)¶
fpa_get_ebits¶
def fpa_get_ebits(self, s: Sort) raises -> UInt32
Retrieves the number of bits reserved for the exponent in a FloatingPoint sort.
fpa_get_numeral_exponent_bv¶
def fpa_get_numeral_exponent_bv(self, t: Ast, biased: Bool) raises -> Ast
Retrieves the exponent of a floating-point literal as a bit-vector expression.
Remarks: This function extracts the exponent in t, without normalization. NaN is an invalid arguments.
fpa_get_numeral_exponent_int64¶
def fpa_get_numeral_exponent_int64(self, t: Ast, biased: Bool) raises -> Optional[Int64]
Return the exponent value of a floating-point numeral as a signed 64-bit integer
Remarks: This function extracts the exponent in t, without normalization. NaN is an invalid argument.
fpa_get_numeral_exponent_string¶
def fpa_get_numeral_exponent_string(self, t: Ast, biased: Bool) raises -> String
Return the exponent value of a floating-point numeral as a string.
Remarks: This function extracts the exponent in t, without normalization. NaN is an invalid argument.
fpa_get_numeral_sign¶
def fpa_get_numeral_sign(self, t: Ast) raises -> Optional[Bool]
Retrieves the sign of a floating-point literal.
Remarks: sets sgn to false if t' is positive and totrue` otherwise, except for NaN, which is an invalid argument.
fpa_get_numeral_sign_bv¶
def fpa_get_numeral_sign_bv(self, t: Ast) raises -> Ast
Retrieves the sign of a floating-point literal as a bit-vector expression.
Remarks: NaN is an invalid argument.
fpa_get_numeral_significand_bv¶
def fpa_get_numeral_significand_bv(self, t: Ast) raises -> Ast
Retrieves the significand of a floating-point literal as a bit-vector expression.
Remarks: NaN is an invalid argument.
fpa_get_numeral_significand_string¶
def fpa_get_numeral_significand_string(self, t: Ast) raises -> String
Return the significand value of a floating-point numeral as a string.
Remarks: The significand s is always 0.0 <= s < 2.0; the resulting string is long enough to represent the real significand precisely.
fpa_get_numeral_significand_uint64¶
def fpa_get_numeral_significand_uint64(self, t: Ast) raises -> Optional[UInt64]
Return the significand value of a floating-point numeral as a uint64.
Remarks: This function extracts the significand bits in t, without the hidden bit or normalization. Sets the Z3_INVALID_ARG error code if the significand does not fit into a uint64. NaN is an invalid argument.
fpa_get_sbits¶
def fpa_get_sbits(self, s: Sort) raises -> UInt32
Retrieves the number of bits reserved for the significand in a FloatingPoint sort.
fpa_is_numeral¶
def fpa_is_numeral(self, t: Ast) raises -> Bool
Checks whether a given ast is a floating-point numeral.
fpa_is_numeral_inf¶
def fpa_is_numeral_inf(self, t: Ast) raises -> Bool
Checks whether a given floating-point numeral is a +oo or -oo.
fpa_is_numeral_nan¶
def fpa_is_numeral_nan(self, t: Ast) raises -> Bool
Checks whether a given floating-point numeral is a NaN.
fpa_is_numeral_negative¶
def fpa_is_numeral_negative(self, t: Ast) raises -> Bool
Checks whether a given floating-point numeral is negative.
fpa_is_numeral_normal¶
def fpa_is_numeral_normal(self, t: Ast) raises -> Bool
Checks whether a given floating-point numeral is normal.
fpa_is_numeral_positive¶
def fpa_is_numeral_positive(self, t: Ast) raises -> Bool
Checks whether a given floating-point numeral is positive.
fpa_is_numeral_subnormal¶
def fpa_is_numeral_subnormal(self, t: Ast) raises -> Bool
Checks whether a given floating-point numeral is subnormal.
fpa_is_numeral_zero¶
def fpa_is_numeral_zero(self, t: Ast) raises -> Bool
Checks whether a given floating-point numeral is +zero or -zero.
mk_fpa_to_fp_int_real¶
def mk_fpa_to_fp_int_real(self, rm: Ast, exp: Ast, sig: Ast, s: Sort) raises -> Ast
Conversion of a real-sorted significand and an integer-sorted exponent into a term of FloatingPoint sort.
Produces a term that represents the conversion of sig * 2^exp into a floating-point term of sort s. If necessary, the result will be rounded according to rounding mode rm.
s must be a FloatingPoint sort, rm must be of RoundingMode sort, exp must be of int sort, sig must be of real sort.
mk_fpa_to_ieee_bv¶
def mk_fpa_to_ieee_bv(self, t: Ast) raises -> Ast
Conversion of a floating-point term into a bit-vector term in IEEE 754-2008 format.
t must have FloatingPoint sort. The size of the resulting bit-vector is automatically determined.
Note that IEEE 754-2008 allows multiple different representations of NaN. This conversion knows only one NaN and it will always produce the same bit-vector representation of that NaN.
Algebraic Numbers (21)¶
algebraic_add¶
def algebraic_add(self, a: Ast, b: Ast) raises -> Ast
Return the value a + b.
algebraic_div¶
def algebraic_div(self, a: Ast, b: Ast) raises -> Ast
Return the value a / b.
algebraic_eq¶
def algebraic_eq(self, a: Ast, b: Ast) raises -> Bool
Return true if a == b, and false otherwise.
algebraic_eval¶
def algebraic_eval(self, p: Ast, a: List[Ast]) raises -> Int32
Given a multivariate polynomial p(x_0, ..., x_{n-1}), return the sign of p(a[0], ..., a[n-1]).
algebraic_ge¶
def algebraic_ge(self, a: Ast, b: Ast) raises -> Bool
Return true if a >= b, and false otherwise.
algebraic_get_i¶
def algebraic_get_i(self, a: Ast) raises -> UInt32
Return which root of the polynomial the algebraic number represents.
algebraic_get_poly¶
def algebraic_get_poly(self, a: Ast) raises -> AstVector
Return the coefficients of the defining polynomial.
algebraic_gt¶
def algebraic_gt(self, a: Ast, b: Ast) raises -> Bool
Return true if a > b, and false otherwise.
algebraic_is_neg¶
def algebraic_is_neg(self, a: Ast) raises -> Bool
Return true if a is negative, and false otherwise.
algebraic_is_pos¶
def algebraic_is_pos(self, a: Ast) raises -> Bool
Return true if a is positive, and false otherwise.
algebraic_is_value¶
def algebraic_is_value(self, a: Ast) raises -> Bool
Return true if a can be used as value in the Z3 real algebraic number package.
algebraic_is_zero¶
def algebraic_is_zero(self, a: Ast) raises -> Bool
Return true if a is zero, and false otherwise.
algebraic_le¶
def algebraic_le(self, a: Ast, b: Ast) raises -> Bool
Return true if a <= b, and false otherwise.
algebraic_lt¶
def algebraic_lt(self, a: Ast, b: Ast) raises -> Bool
Return true if a < b, and false otherwise.
algebraic_mul¶
def algebraic_mul(self, a: Ast, b: Ast) raises -> Ast
Return the value a * b.
algebraic_neq¶
def algebraic_neq(self, a: Ast, b: Ast) raises -> Bool
Return true if a != b, and false otherwise.
algebraic_power¶
def algebraic_power(self, a: Ast, k: UInt32) raises -> Ast
Return the a^k
algebraic_root¶
def algebraic_root(self, a: Ast, k: UInt32) raises -> Ast
Return the a^(1/k)
algebraic_roots¶
def algebraic_roots(self, p: Ast, a: List[Ast]) raises -> AstVector
Given a multivariate polynomial p(x_0, ..., x_{n-1}, x_n), returns the roots of the univariate polynomial p(a[0], ..., a[n-1], x_n).
algebraic_sign¶
def algebraic_sign(self, a: Ast) raises -> Int32
Return 1 if a is positive, 0 if a is zero, and -1 if a is negative.
algebraic_sub¶
def algebraic_sub(self, a: Ast, b: Ast) raises -> Ast
Return the value a - b.
Polynomials (1)¶
polynomial_subresultants¶
def polynomial_subresultants(self, p: Ast, q: Ast, x: Ast) raises -> AstVector
Return the nonzero subresultants of p and q with respect to the "variable" x.
Real Closed Fields (5)¶
mk_rcf_e¶
def mk_rcf_e(self) raises -> RcfNum
Return e (Euler's constant)
mk_rcf_infinitesimal¶
def mk_rcf_infinitesimal(self) raises -> RcfNum
Return a new infinitesimal that is smaller than all elements in the Z3 field.
mk_rcf_int¶
def mk_rcf_int(self, val: Int) raises -> RcfNum
Return a RCF small integer.
mk_rcf_pi¶
def mk_rcf_pi(self) raises -> RcfNum
Return Pi
mk_rcf_rational¶
def mk_rcf_rational(self, val: Rational) raises -> RcfNum
Return a RCF rational using the given string.
Create an exact Real Closed Field number from apn_mojo.Rational (Z3_rcf_mk_rational).
Fixedpoint facilities (1)¶
mk_fixedpoint¶
def mk_fixedpoint(self) raises -> Fixedpoint
Create a new fixedpoint context.
Spacer facilities (4)¶
qe_lite¶
def qe_lite(self, vars: AstVector, body: Ast) raises -> Ast
Best-effort quantifier elimination
qe_model_project¶
def qe_model_project(self, m: Model, bound: List[App], body: Ast) raises -> Ast
Project variables given a model
qe_model_project_skolem¶
def qe_model_project_skolem(self, m: Model, bound: List[App], body: Ast, map: AstMap) raises -> Ast
Project variables given a model
qe_model_project_with_witness¶
def qe_model_project_with_witness(self, m: Model, bound: List[App], body: Ast, map: AstMap) raises -> Ast
Project with witness extraction.
The returned map contains a binding of variables to terms that such that when the binding is used for the formula, it remains true within the model.
Config¶
Exposes 2 Z3 C API bindings.
__init__¶
def __init__(out self) raises
def __init__(out self, api: CApiPtr, raw: Z3_config)
def __init__(out self, api: CApiPtr, ctx: Z3_context, owns_ctx: Bool = True)
Create a configuration object for the Z3 context object.
Configurations are created in order to assign parameters prior to creating contexts for Z3 interaction. For example, if the users wishes to use proof generation, then call:
Z3_set_param_value(cfg, "proof", "true")
The following parameters can be set:
- proof (Boolean) Enable proof generation
- debug_ref_count (Boolean) Enable debug support for Z3_ast reference counting
- trace (Boolean) Tracing support for VCC
- trace_file_name (String) Trace out file for VCC traces
- timeout (unsigned) default timeout (in milliseconds) used for solvers
- well_sorted_check type checker
- auto_config use heuristics to automatically select solver and configure it
- model model generation for solvers, this parameter can be overwritten when creating a solver
- model_validate validate models produced by solvers
- unsat_core unsat-core generation for solvers, this parameter can be overwritten when creating a solver
- encoding the string encoding used internally (must be either "unicode" - 18 bit, "bmp" - 16 bit or "ascii" - 8 bit)
set_param_value¶
def set_param_value(self, param_id: String, param_value: String) raises
Set a configuration parameter.
The following parameters can be set for
Solver¶
var s = Solver.for_logic(ctx, "QF_LIA")
s.assert_formula(ctx.mk_gt(x, ctx.mk_int(0)))
if s.check().is_sat():
var m = s.get_model().value()
Pythonic & ergonomic methods: add, append, assert_exprs, consequences, cube_vars, dimacs, from_tactic, help, insert, model, non_units, num_scopes, on_clause, param_descrs, proof, set, set_param_bool, set_param_uint, set_rlimit, set_seed, set_timeout_ms, set_unsat_core, sexpr, solutions, statistics, to_smt2, trail, trail_levels, units, unsat_core (see Pythonic API Reference).
Commonly used Solver methods:
| Method | Purpose |
|---|---|
for_logic |
Create a new solver customized for the given logic. It behaves like Z3_mk_solver if the logic is unknown or unsupported. |
assert_formula |
Assert a constraint into the solver. |
assert_and_track |
Assert a constraint a into the solver, and track it (in the unsat) core using the Boolean constant p. |
check |
Check whether the assertions in a given solver are consistent or not. |
check_assumptions |
Check whether the assertions in the given solver and optional assumptions are consistent or not. |
get_model |
Retrieve the model for the last Z3_solver_check or Z3_solver_check_assumptions |
get_unsat_core |
Retrieve the unsat core for the last Z3_solver_check_assumptions The unsat core is a subset of the assumptions a. |
push |
Create a backtracking point. |
pop |
Backtrack n backtracking points. |
reset |
Remove all assertions from the solver. |
set_params |
Set the given solver using the given parameters. |
set_propagator |
register a callback when a new expression with a registered function is used by the solver The registered function appears at t... |
Exposes 42 methods (49 Z3 C API bindings).
__init__¶
def __init__(out self, ctx: Context) raises
Create a new solver. This solver is a "combined solver" (see combined_solver module) that internally uses a non-incremental (solver1) and an incremental solver (solver2). This combined solver changes its behaviour based on how it is used and how its parameters are set.
If the solver is used in a non incremental way (i.e. no calls to Z3_solver_push() or Z3_solver_pop(), and no calls to Z3_solver_assert() or Z3_solver_assert_and_track() after checking satisfiability without an intervening Z3_solver_reset()) then solver1 will be used. This solver will apply Z3's "default" tactic.
The "default" tactic will attempt to probe the logic used by the assertions and will apply a specialized tactic if one is supported. Otherwise the general (and-then simplify smt) tactic will be used.
If the solver is used in an incremental way then the combined solver will switch to using solver2 (which behaves similarly to the general "smt" tactic).
Note however it is possible to set the solver2_timeout, solver2_unknown, and ignore_solver1 parameters of the combined solver to change its behaviour.
The function Z3_solver_get_model retrieves a model if the assertions is satisfiable (i.e., the result is Z3_L_TRUE) and model construction is enabled. The function Z3_solver_get_model can also be used even if the result is Z3_L_UNDEF, but the returned model is not guaranteed to satisfy quantified assertions.
add_simplifier¶
def add_simplifier(self, simplifier: Simplifier) raises -> Solver
Attach simplifier to a solver. The solver will use the simplifier for incremental pre-processing.
assert_and_track¶
def assert_and_track(self, formula: Ast, tracker: Ast) raises
Assert a constraint a into the solver, and track it (in the unsat) core using the Boolean constant p.
This API is an alternative to Z3_solver_check_assumptions for extracting unsat cores. Both APIs can be used in the same solver. The unsat core will contain a combination of the Boolean variables provided using Z3_solver_assert_and_track and the Boolean literals provided using Z3_solver_check_assumptions.
assert_formula¶
def assert_formula(self, formula: Ast) raises
Assert a constraint into the solver.
The functions Z3_solver_check and Z3_solver_check_assumptions should be used to check whether the logical context is consistent or not.
assertions¶
def assertions(self) raises -> List[Ast]
Return the set of asserted formulas on the solver.
check¶
def check(self) raises -> CheckResult
Check whether the assertions in a given solver are consistent or not.
The function Z3_solver_get_model retrieves a model if the assertions is satisfiable (i.e., the result is Z3_L_TRUE) and model construction is enabled. Note that if the call returns Z3_L_UNDEF, Z3 does not ensure that calls to Z3_solver_get_model succeed and any models produced in this case are not guaranteed to satisfy the assertions.
The function Z3_solver_get_proof retrieves a proof if proof generation was enabled when the context was created, and the assertions are unsatisfiable (i.e., the result is Z3_L_FALSE).
check_assumptions¶
def check_assumptions(self, assumptions: List[Ast]) raises -> CheckResult
Check whether the assertions in the given solver and optional assumptions are consistent or not.
The function Z3_solver_get_unsat_core retrieves the subset of the assumptions used in the unsatisfiability proof produced by Z3.
congruence_explain¶
def congruence_explain(self, a: Ast, b: Ast) raises -> Ast
retrieve explanation for congruence.
congruence_next¶
def congruence_next(self, a: Ast) raises -> Ast
retrieve the next expression in the congruence class. The set of congruent siblings form a cyclic list. Repeated calls on the siblings will result in returning to the original expression.
congruence_root¶
def congruence_root(self, a: Ast) raises -> Ast
retrieve the congruence closure root of an expression. The root is retrieved relative to the state where the solver was in when it completed. If it completed during a set of case splits, the congruence roots are relative to these case splits. That is, the congruences are not consequences but they are true under the current state.
cube¶
def cube(self, vars: AstVector, backtrack_level: UInt32) raises -> AstVector
extract a next cube for a solver. The last cube is the constant true or false. The number of (non-constant) cubes is by default 1. For the sat solver cubing is controlled using parameters sat.lookahead.cube.cutoff and sat.lookahead.cube.fraction.
The third argument is a vector of variables that may be used for cubing. The contents of the vector is only used in the first call. The initial list of variables is used in subsequent calls until it returns the unsatisfiable cube. The vector is modified to contain a set of Autarky variables that occur in clauses that are affected by the (last literal in the) cube. These variables could be used by a different cuber (on a different solver object) for further recursive cubing.
The last argument is a backtracking level. It instructs the cube process to backtrack below the indicated level for the next cube.
for_logic¶
def for_logic(ctx: Context, logic: String) raises -> Solver
Create a new solver customized for the given logic. It behaves like Z3_mk_solver if the logic is unknown or unsupported.
from_file¶
def from_file(self, file_name: String) raises
load solver assertions from a file.
from_string¶
def from_string(self, smt2: String) raises
load solver assertions from a string.
get_consequences¶
def get_consequences(self, assumptions: AstVector, variables: AstVector, consequences: AstVector) raises -> Lbool
retrieve consequences from solver that determine values of the supplied function symbols.
get_help¶
def get_help(self) raises -> String
Return a string describing all solver available parameters.
get_implied_equalities¶
def get_implied_equalities(self, terms: List[Ast]) raises -> Tuple[CheckResult, List[UInt32]]
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). All implied equalities are returned by this call. This means that two terms map to the same class identifier if and only if the current context implies that they are equal.
A side-effect of the function is a satisfiability check on the assertions on the solver that is passed in. The function return Z3_L_FALSE if the current assertions are not satisfiable.
get_levels¶
def get_levels(self, literals: AstVector) raises -> List[UInt32]
retrieve the decision depth of Boolean literals (variables or their negations). Assumes a check-sat call and no other calls (to extract models) have been invoked.
get_model¶
def get_model(self) raises -> Optional[Model]
Retrieve the model for the last Z3_solver_check or Z3_solver_check_assumptions
The error handler is invoked if a model is not available because the commands above were not invoked for the given solver, or if the result was Z3_L_FALSE.
get_non_units¶
def get_non_units(self) raises -> AstVector
Return the set of non units in the solver state.
get_num_scopes¶
def get_num_scopes(self) raises -> UInt32
Return the number of backtracking points.
get_param_descrs¶
def get_param_descrs(self) raises -> ParamDescrs
Return the parameter description set for the given solver object.
get_proof¶
def get_proof(self) raises -> Ast
Retrieve the proof for the last Z3_solver_check or Z3_solver_check_assumptions
The error handler is invoked if proof generation is not enabled, or if the commands above were not invoked for the given solver, or if the result was different from Z3_L_FALSE.
get_statistics¶
def get_statistics(self) raises -> Stats
Return statistics for the given solver.
get_trail¶
def get_trail(self) raises -> AstVector
Return the trail modulo model conversion, in order of decision level The decision level can be retrieved using Z3_solver_get_level based on the trail.
get_units¶
def get_units(self) raises -> AstVector
Return the set of units modulo model conversion.
get_unsat_core¶
def get_unsat_core(self) raises -> List[Ast]
Retrieve the unsat core for the last Z3_solver_check_assumptions The unsat core is a subset of the assumptions a.
By default, the unsat core will not be minimized. Generation of a minimized unsat core can be enabled via the "sat.core.minimize" and "smt.core.minimize" settings for SAT and SMT cores respectively. Generation of minimized unsat cores will be more expensive.
import_model_converter¶
def import_model_converter(self, dst: Solver) raises
Ad-hoc method for importing model conversion from solver.
This method is used for scenarios where src has been used to solve a set of formulas and was interrupted. The dst solver may be a strengthening of src obtained from cubing (assigning a subset of literals or adding constraints over the assertions available in src). If dst ends up being satisfiable, the model for dst may not correspond to a model of the original formula due to inprocessing in src. This method is used to take the side-effect of inprocessing into account when returning a model for dst.
interrupt¶
def interrupt(self) raises
Solver local interrupt. Normally you should use Z3_interrupt to cancel solvers because only one solver is enabled concurrently per context. However, per GitHub issue #1006, there are use cases where it is more convenient to cancel a specific solver. Solvers that are not selected for interrupts are left alone.
pop¶
def pop(self, n: Int = 1) raises
Backtrack n backtracking points.
propagate_register¶
def propagate_register(self, e: Ast) raises
register an expression to propagate on with the solver. Only expressions of type Bool and type Bit-Vector can be registered for propagation.
push¶
def push(self) raises
Create a backtracking point.
The solver contains a stack of assertions.
reason_unknown¶
def reason_unknown(self) raises -> String
Return a brief justification for an "unknown" result (i.e., Z3_L_UNDEF) for the commands Z3_solver_check and Z3_solver_check_assumptions
register_on_clause¶
def register_on_clause[H: ClauseHandler](self, handler: ArcPointer[H]) raises
register a callback to that retrieves assumed, inferred and deleted clauses during search.
Register a ClauseHandler called on asserted, inferred, and deleted CDCL(T) clauses (Z3_solver_register_on_clause).
reset¶
def reset(self) raises
Remove all assertions from the solver.
set_initial_value¶
def set_initial_value(self, v: Ast, val: Ast) raises
provide an initialization hint to the solver. The initialization hint is used to calibrate an initial value of the expression that represents a variable. If the variable is Boolean, the initial phase is set according to value. If the variable is an integer or real, the initial Simplex tableau is recalibrated to attempt to follow the value assignment.
set_params¶
def set_params(self, params: Params) raises
Set the given solver using the given parameters.
set_propagator¶
def set_propagator[P: UserPropagator](self, propagator: ArcPointer[P], *, fixed: Bool = False, final: Bool = False, eq: Bool = False, diseq: Bool = False, created: Bool = False, decide: Bool = False, on_binding: Bool = False,) raises
Attach a UserPropagator to this solver and register the selected Z3 callbacks.
solve_for¶
def solve_for(self, variables: AstVector, terms: AstVector, guards: AstVector) raises
retrieve a 'solution' for variables as defined by equalities in maintained by solvers. At this point, only linear solution are supported. The solution to variables may be presented in triangular form, such that variables used in solutions themselves have solutions.
to_dimacs_string¶
def to_dimacs_string(self, include_names: Bool) raises -> String
Convert a solver into a DIMACS formatted string.
to_string¶
def to_string(self) raises -> String
Convert a solver into a string.
translate¶
def translate(self, target: Context) raises -> Solver
Copy a solver s from the context source to the context target.
Model¶
var m = s.get_model().value()
var val = m.eval(x, model_completion=True).value()
print("x =", val)
Pythonic & ergonomic methods: consts, decls, evaluate, func_interp, funcs, get_bool, get_integer, get_rational, get_universe, num_sorts, project, sexpr, sorts (see Pythonic API Reference).
Commonly used Model methods:
| Method | Purpose |
|---|---|
eval |
Evaluate the AST node t in the given model. Return true if succeeded, and store the result in v. |
get_const_interp |
Return the interpretation (i.e., assignment) of constant a in the model m. |
get_func_interp |
Return the interpretation of the function f in the model m. |
const_decl |
Return the i-th constant in the given model. |
num_consts |
Return the number of constants assigned by the given model. |
has_interp |
Test if there exists an interpretation (i.e., assignment) for a in the model m. |
to_string |
Convert the given model into a string. |
translate |
translate model from context c to context dst. |
Exposes 14 Z3 C API bindings.
const_decl¶
def const_decl(self, index: Int) raises -> FuncDecl
Return the i-th constant in the given model.
eval¶
def eval(self, ast: Ast, model_completion: Bool = True) raises -> Optional[Ast]
Evaluate the AST node t in the given model. Return true if succeeded, and store the result in v.
If model_completion is true, then Z3 will assign an interpretation for any constant or function that does not have an interpretation in m. These constants and functions were essentially don't cares.
If model_completion is false, then Z3 will not assign interpretations to constants for functions that do not have interpretations in m. Evaluation behaves as the identify function in this case.
The evaluation may fail for the following reasons:
-
tcontains a quantifier. -
the model
mis partial, that is, it doesn't have a complete interpretation for uninterpreted functions. That is, the optionMODEL_PARTIAL=truewas used. -
tis type incorrect. -
Z3_interruptwas invoked during evaluation.
extrapolate¶
def extrapolate(self, fml: Ast) raises -> Ast
Extrapolates a model of a formula
get_const_interp¶
def get_const_interp(self, a: FuncDecl) raises -> Ast
Return the interpretation (i.e., assignment) of constant a in the model m. Return NULL, if the model does not assign an interpretation for a. That should be interpreted as: the value of a does not matter.
get_func_decl¶
def get_func_decl(self, i: UInt32) raises -> FuncDecl
Return the declaration of the i-th function in the given model.
get_func_interp¶
def get_func_interp(self, f: FuncDecl) raises -> FuncInterp
Return the interpretation of the function f in the model m. Return NULL, if the model does not assign an interpretation for f. That should be interpreted as: the f does not matter.
get_num_funcs¶
def get_num_funcs(self) raises -> UInt32
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.
get_num_sorts¶
def get_num_sorts(self) raises -> UInt32
Return the number of uninterpreted sorts that m assigns an interpretation to.
Z3 also provides an interpretation for uninterpreted sorts used in a formula. The interpretation for a sort s is a finite set of distinct values. We say this finite set is the "universe" of s.
get_sort¶
def get_sort(self, i: UInt32) raises -> Sort
Return a uninterpreted sort that m assigns an interpretation.
get_sort_universe¶
def get_sort_universe(self, s: Sort) raises -> AstVector
Return the finite set of distinct values that represent the interpretation for sort s.
has_interp¶
def has_interp(self, a: FuncDecl) raises -> Bool
Test if there exists an interpretation (i.e., assignment) for a in the model m.
num_consts¶
def num_consts(self) raises -> Int
Return the number of constants assigned by the given model.
to_string¶
def to_string(self) raises -> String
Convert the given model into a string.
translate¶
def translate(self, dst: Context) raises -> Model
translate model from context c to context dst.
Optimize¶
var opt = Optimize.create(ctx)
opt.assert_formula(ctx.mk_le(x, ctx.mk_int(10)))
var obj = opt.maximize(x)
if opt.check().is_sat():
print("upper =", opt.get_upper(obj))
Pythonic & ergonomic methods: add, add_soft, append, assert_exprs, assertions, help, insert, lower, lower_values, model, objectives, param_descrs, reason_unknown, set, set_timeout_ms, sexpr, statistics, unsat_core, upper, upper_values (see Pythonic API Reference).
Commonly used Optimize methods:
| Method | Purpose |
|---|---|
create |
Create a new optimize context. |
assert_formula |
Assert hard constraint to the optimization context. |
assert_soft |
Assert soft constraint to the optimization context. |
maximize |
Add a maximization constraint. |
minimize |
Add a minimization constraint. |
check |
Check consistency and produce optimal values. |
get_model |
Retrieve the model for the last Z3_optimize_check |
get_lower |
Retrieve lower bound value or approximation for the i'th optimization objective. |
get_upper |
Retrieve upper bound value or approximation for the i'th optimization objective. |
push |
Create a backtracking point. |
pop |
Backtrack one level. |
set_on_model |
register a model event handler for new models. |
Exposes 28 Z3 C API bindings.
assert_and_track¶
def assert_and_track(self, a: Ast, t: Ast) raises
Assert tracked hard constraint to the optimization context.
assert_formula¶
def assert_formula(self, formula: Ast) raises
Assert hard constraint to the optimization context.
assert_soft¶
def assert_soft(self, formula: Ast, weight: String = "1", group: String = "") raises -> Int
Assert soft constraint to the optimization context.
check¶
def check(self) raises -> CheckResult
Check consistency and produce optimal values.
create¶
def create(ctx: Context) raises -> Optimize
Create a new optimize context.
from_file¶
def from_file(self, s: String) raises
Parse an SMT-LIB2 file with assertions, soft constraints and optimization objectives. Add the parsed constraints and objectives to the optimization context.
from_string¶
def from_string(self, s: String) raises
Parse an SMT-LIB2 string with assertions, soft constraints and optimization objectives. Add the parsed constraints and objectives to the optimization context.
get_assertions¶
def get_assertions(self) raises -> AstVector
Return the set of asserted formulas on the optimization context.
get_help¶
def get_help(self) raises -> String
Return a string containing a description of parameters accepted by optimize.
get_lower¶
def get_lower(self, handle: Int) raises -> Ast
Retrieve lower bound value or approximation for the i'th optimization objective.
An attained, certified irrational algebraic optimum is returned as an exact algebraic numeral by both Z3_optimize_get_lower and Z3_optimize_get_upper. Use Z3_get_algebraic_number_lower and Z3_get_algebraic_number_upper to obtain rational approximations.
A certified finite limit that is not attained includes an infinitesimal term: for example, sqrt(2) - epsilon for a supremum. The finite part can be algebraic even though the whole expression is not an algebraic numeral. Use Z3_optimize_get_lower_as_vector to inspect the finite part and the infinitesimal coefficient separately.
get_lower_as_vector¶
def get_lower_as_vector(self, idx: UInt32) raises -> AstVector
Retrieve lower bound value or approximation for the i'th optimization objective. The returned vector is of length 3. Its entries are coefficients a, b, c and encode the result of Z3_optimize_get_lower a * infinity + b + c * epsilon. The coefficients a and c are rational numerals. The finite part b is a rational numeral or an exact irrational algebraic numeral when such a bound has been certified. For a finite attained optimum, a and c are zero. A finite open limit has a equal to zero and a nonzero infinitesimal coefficient c, even when b is algebraic.
get_model¶
def get_model(self) raises -> Optional[Model]
Retrieve the model for the last Z3_optimize_check
The error handler is invoked if a model is not available because the commands above were not invoked for the given optimization solver, or if the result was Z3_L_FALSE.
get_objectives¶
def get_objectives(self) raises -> AstVector
Return objectives on the optimization context. If the objective function is a max-sat objective it is returned as a Pseudo-Boolean (minimization) sum of the form (+ (if f1 w1 0) (if f2 w2 0) ...) If the objective function is entered as a maximization objective, then return the corresponding minimization objective. In this way the resulting objective function is always returned as a minimization objective.
get_param_descrs¶
def get_param_descrs(self) raises -> ParamDescrs
Return the parameter description set for the given optimize object.
get_reason_unknown¶
def get_reason_unknown(self) raises -> String
Retrieve a string that describes the last status returned by Z3_optimize_check.
Use this method when Z3_optimize_check returns Z3_L_UNDEF.
get_statistics¶
def get_statistics(self) raises -> Stats
Retrieve statistics information from the last call to Z3_optimize_check
get_unsat_core¶
def get_unsat_core(self) raises -> AstVector
Retrieve the unsat core for the last Z3_optimize_check The unsat core is a subset of the assumptions a.
get_upper¶
def get_upper(self, handle: Int) raises -> Ast
Retrieve upper bound value or approximation for the i'th optimization objective.
Certified algebraic optima and finite open limits are returned as described for Z3_optimize_get_lower.
get_upper_as_vector¶
def get_upper_as_vector(self, idx: UInt32) raises -> AstVector
Retrieve upper bound value or approximation for the i'th optimization objective.
The returned vector has the same coefficient and algebraic-value semantics as Z3_optimize_get_lower_as_vector, and encodes the result of Z3_optimize_get_upper.
maximize¶
def maximize(self, expr: Ast) raises -> Int
Add a maximization constraint.
minimize¶
def minimize(self, expr: Ast) raises -> Int
Add a minimization constraint.
pop¶
def pop(self) raises
Backtrack one level.
push¶
def push(self) raises
Create a backtracking point.
The optimize solver contains a set of rules, added facts and assertions. The set of rules, facts and assertions are restored upon calling Z3_optimize_pop.
set_initial_value¶
def set_initial_value(self, v: Ast, val: Ast) raises
provide an initialization hint to the solver. The initialization hint is used to calibrate an initial value of the expression that represents a variable. If the variable is Boolean, the initial phase is set according to value. If the variable is an integer or real, the initial Simplex tableau is recalibrated to attempt to follow the value assignment.
set_on_model¶
def set_on_model[H: ModelHandler](self, handler: ArcPointer[H]) raises
register a model event handler for new models.
Register a ModelHandler called whenever optimization finds an improving model (Z3_optimize_register_model_eh).
set_params¶
def set_params(self, params: Params) raises
Set parameters on optimization context, including parameters for the underlying SMT solver.
to_string¶
def to_string(self) raises -> String
Print the current context as a string.
translate¶
def translate(self, target: Context) raises -> Optimize
Copy an optimization context from a source to a target context.
This function allows translating an optimization context from one Z3_context to another. This is useful when working with multiple contexts and needing to transfer optimization problems between them.
Fixedpoint¶
var fp = Fixedpoint(ctx)
fp.register_relation(reach)
fp.add_rule(rule, "step")
var ans = fp.query(goal)
Pythonic & ergonomic methods: add, append, assert_exprs, assertions, create, fact, help, insert, param_descrs, parse_file, parse_string, query_check, reason_unknown, rule, set, sexpr, statistics (see Pythonic API Reference).
Exposes 29 Z3 C API bindings.
add_constraint¶
def add_constraint(self, e: Ast, lvl: UInt32) raises
Safe wrapper for Z3_fixedpoint_add_constraint.
add_cover¶
def add_cover(self, level: Int32, pred: FuncDecl, property: Ast) raises
Add property about the predicate pred. Add a property of predicate pred at level. It gets pushed forward when possible.
Note: level = -1 is treated as the fixedpoint. So passing -1 for the level means that the property is true of the fixed-point unfolding with respect to pred.
Note: this functionality is PDR specific.
add_fact¶
def add_fact(self, r: FuncDecl, args: List[UInt32]) raises
Add a Database fact.
The number of arguments num_args should be equal to the number of sorts in the domain of r. Each sort in the domain should be an integral (bit-vector, Boolean or or finite domain sort).
The call has the same effect as adding a rule where r is applied to the arguments.
add_invariant¶
def add_invariant(self, pred: FuncDecl, property: Ast) raises
Add an invariant for the predicate pred. Add an assumed invariant of predicate pred.
Note: this functionality is Spacer specific.
add_rule¶
def add_rule(self, rule: Ast, name: String) raises
def add_rule(self, rule: Ast, name: Symbol) raises
Add a universal Horn clause as a named rule. The horn_rule should be of the form:
horn_rule ::= (forall (bound-vars) horn_rule)
| (=> atoms horn_rule)
| atom
assert_¶
def assert_(self, axiom: Ast) raises
Assert a constraint to the fixedpoint context.
The constraints are used as background axioms when the fixedpoint engine uses the PDR mode. They are ignored for standard Datalog mode.
from_file¶
def from_file(self, s: String) raises -> AstVector
Parse an SMT-LIB2 file with fixedpoint rules. Add the rules to the current fixedpoint context. Return the set of queries in the file.
from_string¶
def from_string(self, s: String) raises -> AstVector
Parse an SMT-LIB2 string with fixedpoint rules. Add the rules to the current fixedpoint context. Return the set of queries in the string.
get_answer¶
def get_answer(self) raises -> Ast
Retrieve a formula that encodes satisfying answers to the query.
When used in Datalog mode, the returned answer is a disjunction of conjuncts. Each conjunct encodes values of the bound variables of the query that are satisfied. In PDR mode, the returned answer is a single conjunction.
When used in Datalog mode the previous call to Z3_fixedpoint_query must have returned Z3_L_TRUE. When used with the PDR engine, the previous call must have been either Z3_L_TRUE or Z3_L_FALSE.
get_assertions¶
def get_assertions(self) raises -> AstVector
Retrieve set of background assertions from fixedpoint context.
get_cover_delta¶
def get_cover_delta(self, level: Int32, pred: FuncDecl) raises -> Ast
Retrieve the current cover of pred up to level unfoldings. Return just the delta that is known at level. To obtain the full set of properties of pred one should query at level+1 , level+2 etc, and include level=-1.
Note: this functionality is PDR specific.
get_ground_sat_answer¶
def get_ground_sat_answer(self) raises -> Ast
Retrieve a bottom-up (from query) sequence of ground facts
The previous call to Z3_fixedpoint_query must have returned Z3_L_TRUE.
get_help¶
def get_help(self) raises -> String
Return a string describing all fixedpoint available parameters.
get_num_levels¶
def get_num_levels(self, pred: FuncDecl) raises -> UInt32
Query the PDR engine for the maximal levels properties are known about predicate.
This call retrieves the maximal number of relevant unfoldings of pred with respect to the current exploration state. Note: this functionality is PDR specific.
get_param_descrs¶
def get_param_descrs(self) raises -> ParamDescrs
Return the parameter description set for the given fixedpoint object.
get_reachable¶
def get_reachable(self, pred: FuncDecl) raises -> Ast
Retrieve reachable states of a predicate. Note: this functionality is Spacer specific.
get_reason_unknown¶
def get_reason_unknown(self) raises -> String
Retrieve a string that describes the last status returned by Z3_fixedpoint_query.
Use this method when Z3_fixedpoint_query returns Z3_L_UNDEF.
get_rule_names_along_trace¶
def get_rule_names_along_trace(self) raises -> Symbol
Obtain the list of rules along the counterexample trace.
get_rules¶
def get_rules(self) raises -> AstVector
Retrieve set of rules from fixedpoint context.
get_rules_along_trace¶
def get_rules_along_trace(self) raises -> AstVector
Obtain the list of rules along the counterexample trace.
get_statistics¶
def get_statistics(self) raises -> Stats
Retrieve statistics information from the last call to Z3_fixedpoint_query.
query¶
def query(self, query: Ast) raises -> Lbool
Pose a query against the asserted rules.
query ::= (exists (bound-vars) query)
| literals
query returns
Z3_L_FALSEif the query is unsatisfiable.Z3_L_TRUEif the query is satisfiable. Obtain the answer by callingZ3_fixedpoint_get_answer.Z3_L_UNDEFif the query was interrupted, timed out or otherwise failed.
query_from_lvl¶
def query_from_lvl(self, query: Ast, lvl: UInt32) raises -> Lbool
Pose a query against the asserted rules at the given level.
query ::= (exists (bound-vars) query)
| literals
query returns
Z3_L_FALSEif the query is unsatisfiable.Z3_L_TRUEif the query is satisfiable. Obtain the answer by callingZ3_fixedpoint_get_answer.Z3_L_UNDEFif the query was interrupted, timed out or otherwise failed.
query_relations¶
def query_relations(self, relations: List[FuncDecl]) raises -> Lbool
Pose multiple queries against the asserted rules.
The queries are encoded as relations (function declarations).
query returns
Z3_L_FALSEif the query is unsatisfiable.Z3_L_TRUEif the query is satisfiable. Obtain the answer by callingZ3_fixedpoint_get_answer.Z3_L_UNDEFif the query was interrupted, timed out or otherwise failed.
register_relation¶
def register_relation(self, f: FuncDecl) raises
Register relation as Fixedpoint defined. Fixedpoint defined relations have least-fixedpoint semantics. For example, the relation is empty if it does not occur in a head or a fact.
set_params¶
def set_params(self, p: Params) raises
Set parameters on fixedpoint context.
set_predicate_representation¶
def set_predicate_representation(self, f: FuncDecl, relation_kinds: List[Symbol]) raises
Configure the predicate representation.
It sets the predicate to use a set of domains given by the list of symbols. The domains given by the list of symbols must belong to a set of built-in domains.
to_string¶
def to_string(self, queries: List[Ast]) raises -> String
Print the current rules and background axioms as a string.
update_rule¶
def update_rule(self, a: Ast, name: Symbol) raises
Update a named rule. A rule with the same name must have been previously created.
Tactic¶
var tac = Tactic.create(ctx, "simplify").and_then(Tactic.create(ctx, "qfnra-nlsat"))
var s = tac.to_solver()
Pythonic & ergonomic methods: ctx, help, param_descrs, solver (see Pythonic API Reference).
Exposes 12 Z3 C API bindings.
and_then¶
def and_then(self, other: Tactic) raises -> Tactic
Return a tactic that applies t1 to a given goal and t2 to every subgoal produced by t1.
apply¶
def apply(self, goal: Goal) raises -> ApplyResult
Apply tactic t to the goal g.
apply_ex¶
def apply_ex(self, g: Goal, p: Params) raises -> ApplyResult
Apply tactic t to the goal g using the parameter set p.
create¶
def create(ctx: Context, name: String) raises -> Tactic
Return a tactic associated with the given name. The complete list of tactics may be obtained using the procedures Z3_get_num_tactics and Z3_get_tactic_name. It may also be obtained using the command (help-tactic) in the SMT 2.0 front-end.
Tactics are the basic building block for creating custom solvers for specific problem domains.
get_help¶
def get_help(self) raises -> String
Return a string containing a description of parameters accepted by the given tactic.
get_param_descrs¶
def get_param_descrs(self) raises -> ParamDescrs
Return the parameter description set for the given tactic object.
or_else¶
def or_else(self, other: Tactic) raises -> Tactic
Return a tactic that first applies t1 to a given goal, if it fails then returns the result of t2 applied to the given goal.
par_and_then¶
def par_and_then(self, t2: Tactic) raises -> Tactic
Return a tactic that applies t1 to a given goal and then t2 to every subgoal produced by t1. The subgoals are processed in parallel.
repeat¶
def repeat(self, max: UInt32) raises -> Tactic
Return a tactic that keeps applying t until the goal is not modified anymore or the maximum number of iterations max is reached.
to_solver¶
def to_solver(self) raises -> Solver
Create a new solver that is implemented using the given tactic. The solver supports the commands Z3_solver_push and Z3_solver_pop, but it will always solve each Z3_solver_check from scratch.
try_for¶
def try_for(self, ms: Int) raises -> Tactic
Return a tactic that applies t to a given goal for ms milliseconds. If t does not terminate in ms milliseconds, then it fails.
with_params¶
def with_params(self, params: Params) raises -> Tactic
Return a tactic that applies t using the given set of parameters.
Goal¶
var g = Goal(ctx)
g.assert_formula(ctx.mk_lt(ctx.mk_mul(x, x), ctx.mk_int(0)))
var res = Tactic.create(ctx, "simplify").apply(g)
Pythonic & ergonomic methods: add, append, as_expr, assert_exprs, dimacs, get, insert, prec, sexpr, simplify (see Pythonic API Reference).
Exposes 15 Z3 C API bindings.
assert_formula¶
def assert_formula(self, formula: Ast) raises
Add a new formula a to the given goal. The formula is split according to the following procedure that is applied until a fixed-point: Conjunctions are split into separate formulas. Negations are distributed over disjunctions, resulting in separate formulas. If the goal is false, adding new formulas is a no-op. If the formula a is true, then nothing is added. If the formula a is false, then the entire goal is replaced by the formula false.
convert_model¶
def convert_model(self, m: Model) raises -> Model
Convert a model of the formulas of a goal to a model of an original goal. The model may be null, in which case the returned model is valid if the goal was established satisfiable.
When using this feature it is advisable to set the parameter model.compact to false. It is by default true, which erases variables created by the solver from models. Without access to model values for intermediary variables, values of other variables may end up having the wrong values.
create¶
def create(ctx: Context, models: Bool = True, unsat_cores: Bool = False, proofs: Bool = False) raises -> Goal
Create a goal (aka problem). A goal is essentially a set of formulas, that can be solved and/or transformed using tactics and solvers.
If models is true, then model generation is enabled for the new goal.
If unsat_cores is true, then unsat core generation is enabled for the new goal.
If proofs is true, then proof generation is enabled for the new goal. Remark, the Z3 context c must have been created with proof generation support.
depth¶
def depth(self) raises -> UInt32
Return the depth of the given goal. It tracks how many transformations were applied to it.
formula¶
def formula(self, index: Int) raises -> Ast
Return a formula from the given goal.
inconsistent¶
def inconsistent(self) raises -> Bool
Return true if the given goal contains the formula false.
is_decided_sat¶
def is_decided_sat(self) raises -> Bool
Return true if the goal is empty, and it is precise or the product of a under approximation.
is_decided_unsat¶
def is_decided_unsat(self) raises -> Bool
Return true if the goal contains false, and it is precise or the product of an over approximation.
num_exprs¶
def num_exprs(self) raises -> UInt32
Return the number of formulas, subformulas and terms in the given goal.
precision¶
def precision(self) raises -> GoalPrec
Return the "precision" of the given goal. Goals can be transformed using over and under approximations. A under approximation is applied when the objective is to find a model for a given goal. An over approximation is applied when the objective is to find a proof for a given goal.
reset¶
def reset(self) raises
Erase all formulas from the given goal.
size¶
def size(self) raises -> Int
Return the number of formulas in the given goal.
to_dimacs_string¶
def to_dimacs_string(self, include_names: Bool) raises -> String
Convert a goal into a DIMACS formatted string. The goal must be in CNF. You can convert a goal to CNF by applying the tseitin-cnf tactic. Bit-vectors are not automatically converted to Booleans either, so if the caller intends to preserve satisfiability, it should apply bit-blasting tactics. Quantifiers and theory atoms will not be encoded.
to_string¶
def to_string(self) raises -> String
Convert a goal into a string.
translate¶
def translate(self, target: Context) raises -> Goal
Copy a goal g from the context source to the context target.
ApplyResult¶
Exposes 3 Z3 C API bindings.
num_subgoals¶
def num_subgoals(self) raises -> Int
Return the number of subgoals in the Z3_apply_result object returned by Z3_tactic_apply.
subgoal¶
def subgoal(self, index: Int) raises -> Goal
Return one of the subgoals in the Z3_apply_result object returned by Z3_tactic_apply.
to_string¶
def to_string(self) raises -> String
Convert the Z3_apply_result object returned by Z3_tactic_apply into a string.
Probe¶
Pythonic & ergonomic methods: const, create, ctx (see Pythonic API Reference).
Exposes 9 Z3 C API bindings.
and_¶
def and_(self, p2: Probe) raises -> Probe
Return a probe that evaluates to "true" when p1 and p2 evaluates to true.
apply¶
def apply(self, g: Goal) raises -> Float64
Execute the probe over the goal. The probe always produce a double value. "Boolean" probes return 0.0 for false, and a value different from 0.0 for true.
eq¶
def eq(self, val: Float64) raises -> Probe
def eq(self, val: Int) raises -> Probe
def eq(self, p2: Probe) raises -> Probe
Return a probe that evaluates to "true" when the value returned by p1 is equal to the value returned by p2.
ge¶
def ge(self, p2: Probe) raises -> Probe
Return a probe that evaluates to "true" when the value returned by p1 is greater than or equal to the value returned by p2.
gt¶
def gt(self, p2: Probe) raises -> Probe
Return a probe that evaluates to "true" when the value returned by p1 is greater than the value returned by p2.
le¶
def le(self, p2: Probe) raises -> Probe
Return a probe that evaluates to "true" when the value returned by p1 is less than or equal to the value returned by p2.
lt¶
def lt(self, p2: Probe) raises -> Probe
Return a probe that evaluates to "true" when the value returned by p1 is less than the value returned by p2.
not_¶
def not_(self) raises -> Probe
Return a probe that evaluates to "true" when p does not evaluate to true.
or_¶
def or_(self, p2: Probe) raises -> Probe
Return a probe that evaluates to "true" when p1 or p2 evaluates to true.
Simplifier¶
Exposes 4 Z3 C API bindings.
and_then¶
def and_then(self, t2: Simplifier) raises -> Simplifier
Return a simplifier that applies t1 to a given goal and t2 to every subgoal produced by t1.
get_help¶
def get_help(self) raises -> String
Return a string containing a description of parameters accepted by the given simplifier.
get_param_descrs¶
def get_param_descrs(self) raises -> ParamDescrs
Return the parameter description set for the given simplifier object.
using_params¶
def using_params(self, p: Params) raises -> Simplifier
Return a simplifier that applies t using the given set of parameters.
Params¶
Exposes 7 Z3 C API bindings.
create¶
def create(ctx: Context) raises -> Params
Create a Z3 (empty) parameter set. Starting at Z3 4.0, parameter sets are used to configure many components such as: simplifiers, tactics, solvers, etc.
set_bool¶
def set_bool(self, key: String, val: Bool) raises
Add a Boolean parameter k with value v to the parameter set p.
set_double¶
def set_double(self, key: String, val: Float64) raises
Add a double parameter k with value v to the parameter set p.
set_symbol¶
def set_symbol(self, key: String, val: String) raises
Add a symbol parameter k with value v to the parameter set p.
set_uint¶
def set_uint(self, key: String, val: Int) raises
Add a unsigned parameter k with value v to the parameter set p.
to_string¶
def to_string(self) raises -> String
Convert a parameter set into a string. This function is mainly used for printing the contents of a parameter set.
validate¶
def validate(self, d: ParamDescrs) raises
Validate the parameter set p against the parameter description set d.
The procedure invokes the error handler if p is invalid.
ParamDescrs¶
Exposes 5 Z3 C API bindings.
get_documentation¶
def get_documentation(self, s: Symbol) raises -> String
Retrieve documentation string corresponding to parameter name s.
get_kind¶
def get_kind(self, n: Symbol) raises -> ParamKind
Return the kind associated with the given parameter name n.
get_name¶
def get_name(self, i: UInt32) raises -> Symbol
Return the name of the parameter at given index i.
size¶
def size(self) raises -> UInt32
Return the number of parameters in the given parameter description set.
to_string¶
def to_string(self) raises -> String
Convert a parameter description set into a string. This function is mainly used for printing the contents of a parameter description set.
Stats¶
Pythonic & ergonomic methods: entries, get_double, get_uint (see Pythonic API Reference).
Exposes 7 Z3 C API bindings.
get_double_value¶
def get_double_value(self, idx: UInt32) raises -> Float64
Return the double value of the given statistical data.
get_key¶
def get_key(self, idx: UInt32) raises -> String
Return the key (a string) for a particular statistical data.
get_uint_value¶
def get_uint_value(self, idx: UInt32) raises -> UInt32
Return the unsigned value of the given statistical data.
is_double¶
def is_double(self, idx: UInt32) raises -> Bool
Return true if the given statistical data is a double.
is_uint¶
def is_uint(self, idx: UInt32) raises -> Bool
Return true if the given statistical data is a unsigned integer.
size¶
def size(self) raises -> UInt32
Return the number of statistical data in s.
to_string¶
def to_string(self) raises -> String
Convert a statistics into a string.
Ast¶
Pythonic & ergonomic methods: arg, as_bool, as_integer, as_rational, children, ctx, decl, decl_kind, eq, get_id, hash, hash_code, implies, is_algebraic_number, is_app, is_array, is_bool, is_bv, is_complex, is_const, is_false, is_finite_field, is_finite_set, is_fp, is_int, is_numeral, is_quantifier, is_real, is_string, is_true, kind, ne, num_args, sexpr, simplify, sort, sort_kind, substitute, to_string, translate, write_to (see Pythonic API Reference).
Value/handle wrapper managed by Context; see Context methods and Pythonic API.
Sort¶
Pythonic & ergonomic methods: ctx, get_id, kind, name, sexpr, to_string, write_to (see Pythonic API Reference).
Value/handle wrapper managed by Context; see Context methods and Pythonic API.
Symbol¶
Pythonic & ergonomic methods: kind, to_string, write_to (see Pythonic API Reference).
Value/handle wrapper managed by Context; see Context methods and Pythonic API.
FuncDecl¶
Pythonic & ergonomic methods: arity, ctx, domain, get_id, hash, kind, name, range, sexpr (see Pythonic API Reference).
Value/handle wrapper managed by Context; see Context methods and Pythonic API.
App¶
Value/handle wrapper managed by Context; see Context methods and Pythonic API.
Pattern¶
Value/handle wrapper managed by Context; see Context methods and Pythonic API.
AstVector¶
Pythonic & ergonomic methods: to_list (see Pythonic API Reference).
Exposes 7 Z3 C API bindings.
get¶
def get(self, i: UInt32) raises -> Ast
Return the AST at position i in the AST vector v.
push¶
def push(self, a: Ast) raises
Add the AST a in the end of the AST vector v. The size of v is increased by one.
resize¶
def resize(self, n: UInt32) raises
Resize the AST vector v.
set¶
def set(self, i: UInt32, a: Ast) raises
Update position i of the AST vector v with the AST a.
size¶
def size(self) raises -> UInt32
Return the size of the given AST vector.
to_string¶
def to_string(self) raises -> String
Convert AST vector into a string.
translate¶
def translate(self, t: Context) raises -> AstVector
Translate the AST vector v from context s into an AST vector in context t.
AstMap¶
Exposes 8 Z3 C API bindings.
contains¶
def contains(self, k: Ast) raises -> Bool
Return true if the map m contains the AST key k.
erase¶
def erase(self, k: Ast) raises
Erase a key from the map.
find¶
def find(self, k: Ast) raises -> Ast
Return the value associated with the key k.
The procedure invokes the error handler if k is not in the map.
insert¶
def insert(self, k: Ast, v: Ast) raises
Store/Replace a new key, value pair in the given map.
keys¶
def keys(self) raises -> AstVector
Return the keys stored in the given map.
reset¶
def reset(self) raises
Remove all keys from the given map.
size¶
def size(self) raises -> UInt32
Return the size of the given map.
to_string¶
def to_string(self) raises -> String
Convert the given map into a string.
FuncInterp¶
Pythonic & ergonomic methods: else_value, entries (see Pythonic API Reference).
Exposes 6 Z3 C API bindings.
add_entry¶
def add_entry(self, args: AstVector, value: Ast) raises
add a function entry to a function interpretation.
It is assumed that entries added to a function cover disjoint arguments. If an two entries are added with the same arguments, only the second insertion survives and the first inserted entry is removed.
get_arity¶
def get_arity(self) raises -> UInt32
Return the arity (number of arguments) of the given function interpretation.
get_else¶
def get_else(self) raises -> Ast
Return the 'else' value of the given function interpretation.
A function interpretation is represented as a finite map and an 'else' value. This procedure returns the 'else' value.
get_entry¶
def get_entry(self, i: UInt32) raises -> FuncEntry
Return a "point" of the given function interpretation. It represents the value of f in a particular point.
get_num_entries¶
def get_num_entries(self) raises -> UInt32
Return the number of entries in the given function interpretation.
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. This procedure return the number of element in the finite map of f.
set_else¶
def set_else(self, else_value: Ast) raises
Return the 'else' value of the given function interpretation.
A function interpretation is represented as a finite map and an 'else' value. This procedure can be used to update the 'else' value.
FuncEntry¶
Exposes 3 Z3 C API bindings.
get_arg¶
def get_arg(self, i: UInt32) raises -> Ast
Return an argument of a Z3_func_entry object.
get_num_args¶
def get_num_args(self) raises -> UInt32
Return the number of arguments in a Z3_func_entry object.
get_value¶
def get_value(self) raises -> Ast
Return the value of this point.
A Z3_func_entry object represents an element in the finite map used to encode a function interpretation.
ParserContext¶
Exposes 3 Z3 C API bindings.
add_decl¶
def add_decl(self, f: FuncDecl) raises
Add a function declaration.
add_sort¶
def add_sort(self, s: Sort) raises
Add a sort declaration.
from_string¶
def from_string(self, s: String) raises -> AstVector
Parse a string of SMTLIB2 commands. Return assertions.
Constructor¶
Exposes 1 Z3 C API bindings.
num_fields¶
def num_fields(self) raises -> UInt32
Retrieve the number of fields of a constructor
ConstructorList¶
Value/handle wrapper managed by Context; see Context methods and Pythonic API.
RcfNum¶
var coeffs: List[RcfNum] = [ctx.mk_rcf_int(-2), ctx.mk_rcf_int(0), ctx.mk_rcf_int(1)]
var roots = RcfNum.mk_roots(ctx, coeffs)
print("sqrt(2) ~=", roots[1].to_decimal(10))
Exposes 31 Z3 C API bindings.
add¶
def add(self, b: RcfNum) raises -> RcfNum
Return the value a + b.
coefficient¶
def coefficient(self, i: UInt32) raises -> RcfNum
Extract a coefficient from an algebraic number.
div¶
def div(self, b: RcfNum) raises -> RcfNum
Return the value a / b.
eq¶
def eq(self, b: RcfNum) raises -> Bool
Return true if a == b.
extension_index¶
def extension_index(self) raises -> UInt32
Return the index of a field extension.
ge¶
def ge(self, b: RcfNum) raises -> Bool
Return true if a >= b.
gt¶
def gt(self, b: RcfNum) raises -> Bool
Return true if a > b.
infinitesimal_name¶
def infinitesimal_name(self) raises -> Symbol
Return the name of an infinitesimal.
interval¶
def interval(self) raises -> Tuple[Int32, Bool, Bool, RcfNum, Bool, Bool, RcfNum]
Extract an interval from an algebraic number.
inv¶
def inv(self) raises -> RcfNum
Return the value 1/a.
is_algebraic¶
def is_algebraic(self) raises -> Bool
Return true if a represents an algebraic number.
is_infinitesimal¶
def is_infinitesimal(self) raises -> Bool
Return true if a represents an infinitesimal.
is_rational¶
def is_rational(self) raises -> Bool
Return true if a represents a rational number.
is_transcendental¶
def is_transcendental(self) raises -> Bool
Return true if a represents a transcendental number.
le¶
def le(self, b: RcfNum) raises -> Bool
Return true if a <= b.
lt¶
def lt(self, b: RcfNum) raises -> Bool
Return true if a < b.
mk_roots¶
def mk_roots(ctx: Context, coeffs: List[RcfNum]) raises -> List[RcfNum]
Store in roots the roots of the polynomial a[n-1]*x^{n-1} + ... + a[0]. The output vector roots must have size n. It returns the number of roots of the polynomial.
mul¶
def mul(self, b: RcfNum) raises -> RcfNum
Return the value a * b.
neg¶
def neg(self) raises -> RcfNum
Return the value -a.
neq¶
def neq(self, b: RcfNum) raises -> Bool
Return true if a != b.
num_coefficients¶
def num_coefficients(self) raises -> UInt32
Return the number of coefficients in an algebraic number.
num_sign_condition_coefficients¶
def num_sign_condition_coefficients(self, i: UInt32) raises -> UInt32
Return the number of sign condition polynomial coefficients of an algebraic number.
num_sign_conditions¶
def num_sign_conditions(self) raises -> UInt32
Return the number of sign conditions of an algebraic number.
numerator_denominator¶
def numerator_denominator(self) raises -> Tuple[RcfNum, RcfNum]
Extract the "numerator" and "denominator" of the given RCF numeral. We have that a = n/d, moreover n and d are not represented using rational functions.
power¶
def power(self, k: UInt32) raises -> RcfNum
Return the value a^k.
sign_condition_coefficient¶
def sign_condition_coefficient(self, i: UInt32, j: UInt32) raises -> RcfNum
Extract the j-th polynomial coefficient of the i-th sign condition.
sign_condition_sign¶
def sign_condition_sign(self, i: UInt32) raises -> Int32
Extract the sign of a sign condition from an algebraic number.
sub¶
def sub(self, b: RcfNum) raises -> RcfNum
Return the value a - b.
to_decimal¶
def to_decimal(self, prec: Int = 15) raises -> String
Convert the RCF numeral into a string in decimal notation.
to_string¶
def to_string(self, compact: Bool = True, html: Bool = False) raises -> String
Convert the RCF numeral into a string.
transcendental_name¶
def transcendental_name(self) raises -> Symbol
Return the name of a transcendental.
SolverCallback¶
Pythonic & ergonomic methods: add, conflict, ctx, next_split, propagate (see Pythonic API Reference).
Exposes 2 Z3 C API bindings.
consequence¶
def consequence(self, fixed: List[Ast], eq_lhs: List[Ast], eq_rhs: List[Ast], conseq: Ast) raises -> Bool
propagate a consequence based on fixed values and equalities. A client may invoke it during the propagate_fixed, propagate_eq, propagate_diseq, and propagate_final callbacks. The callback adds a propagation consequence based on the fixed values passed in fixed and equalities between eq_lhs and eq_rhs.
The solver might discard the propagation in case it is true in the current state. The function returns false in this case; otw. the function returns true. At least one propagation in the final callback has to return true in order to prevent the solver from finishing.
register_cb¶
def register_cb(self, e: Ast) raises
register an expression to propagate on with the solver. Only expressions of type Bool and type Bit-Vector can be registered for propagation. Unlike Z3_solver_propagate_register, this function takes a solver callback context as argument. It can be invoked during a callback to register new expressions.