Z3
 
Loading...
Searching...
No Matches
Data Structures | Functions | Variables
z3py Namespace Reference

Data Structures

class  AlgebraicNumRef
 
class  ApplyResult
 
class  ArithRef
 
class  ArithSortRef
 Arithmetic. More...
 
class  ArrayRef
 
class  ArraySortRef
 Arrays. More...
 
class  AstMap
 
class  AstRef
 
class  AstVector
 
class  BitVecNumRef
 
class  BitVecRef
 
class  BitVecSortRef
 Bit-Vectors. More...
 
class  BoolRef
 
class  BoolSortRef
 Booleans. More...
 
class  CharRef
 
class  CharSortRef
 
class  CheckSatResult
 
class  Context
 
class  Datatype
 
class  DatatypeRef
 
class  DatatypeSortRef
 
class  ExprRef
 Expressions. More...
 
class  FiniteDomainNumRef
 
class  FiniteDomainRef
 
class  FiniteDomainSortRef
 
class  FiniteSetRef
 
class  FiniteSetSortRef
 Finite Sets. More...
 
class  Fixedpoint
 Fixedpoint. More...
 
class  FPNumRef
 
class  FPRef
 
class  FPRMRef
 
class  FPRMSortRef
 
class  FPSortRef
 
class  FuncDeclRef
 Function Declarations. More...
 
class  FuncEntry
 
class  FuncInterp
 
class  Goal
 
class  IntNumRef
 
class  ModelRef
 
class  OnClause
 
class  Optimize
 
class  OptimizeObjective
 Optimize. More...
 
class  ParamDescrsRef
 
class  ParamsRef
 Parameter Sets. More...
 
class  ParserContext
 
class  PatternRef
 Patterns. More...
 
class  Probe
 
class  PropClosures
 
class  QuantifierRef
 Quantifiers. More...
 
class  RatNumRef
 
class  ReRef
 
class  ReSortRef
 
class  ScopedConstructor
 
class  ScopedConstructorList
 
class  SeqRef
 
class  SeqSortRef
 Strings, Sequences and Regular expressions. More...
 
class  Simplifier
 
class  Solver
 
class  SortRef
 
class  Statistics
 Statistics. More...
 
class  Tactic
 
class  TypeVarRef
 
class  UserPropagateBase
 
class  Z3PPObject
 ASTs base class. More...
 

Functions

 z3_debug ()
 
 _is_int (v)
 
 enable_trace (msg)
 
 disable_trace (msg)
 
 get_version_string ()
 
 get_version ()
 
 get_full_version ()
 
 _z3_assert (cond, msg)
 
 _z3_check_cint_overflow (n, name)
 
 open_log (fname)
 
 append_log (s)
 
 to_symbol (s, ctx=None)
 
 _symbol2py (ctx, s)
 
 _get_args (args)
 
 _get_args_ast_list (args)
 
 _to_param_value (val)
 
 z3_error_handler (c, e)
 
Context main_ctx ()
 
Context _get_ctx (ctx)
 
Context get_ctx (ctx)
 
 set_param (*args, **kws)
 
None reset_params ()
 
 set_option (*args, **kws)
 
 get_param (name)
 
bool is_ast (Any a)
 
bool eq (AstRef a, AstRef b)
 
int _ast_kind (Context ctx, Any a)
 
 _ctx_from_ast_arg_list (args, default_ctx=None)
 
 _ctx_from_ast_args (*args)
 
 _to_func_decl_array (args)
 
 _to_ast_array (args)
 
 _to_ref_array (ref, args)
 
 _to_ast_ref (a, ctx)
 
 _sort_kind (ctx, s)
 Sorts.
 
bool is_sort (Any s)
 
 _to_sort_ref (s, ctx)
 
SortRef _sort (Context ctx, Any a)
 
SortRef DeclareSort (name, ctx=None)
 
 DeclareTypeVar (name, ctx=None)
 
 is_func_decl (a)
 
 Function (name, *sig)
 
 FreshFunction (*sig)
 
 _to_func_decl_ref (a, ctx)
 
 RecFunction (name, *sig)
 
 RecAddDefinition (f, args, body)
 
 deserialize (st)
 
 _to_expr_ref (a, ctx)
 
 _coerce_expr_merge (s, a)
 
 _check_same_sort (a, b, ctx=None)
 
 _coerce_exprs (a, b, ctx=None)
 
 _reduce (func, sequence, initial)
 
 _coerce_expr_list (alist, ctx=None)
 
 is_expr (a)
 
 is_app (a)
 
 is_const (a)
 
 is_var (a)
 
 get_var_index (a)
 
 is_app_of (a, k)
 
 If (a, b, c, ctx=None)
 
 Distinct (*args)
 
 _mk_bin (f, a, b)
 
 Const (name, sort)
 
 Consts (names, sort)
 
 FreshConst (sort, prefix="c")
 
ExprRef Var (int idx, SortRef s)
 
ExprRef RealVar (int idx, ctx=None)
 
 RealVarVector (int n, ctx=None)
 
bool is_bool (Any a)
 
bool is_true (Any a)
 
bool is_false (Any a)
 
bool is_and (Any a)
 
bool is_or (Any a)
 
bool is_implies (Any a)
 
bool is_not (Any a)
 
bool is_eq (Any a)
 
bool is_distinct (Any a)
 
 BoolSort (ctx=None)
 
 BoolVal (val, ctx=None)
 
 Bool (name, ctx=None)
 
 Bools (names, ctx=None)
 
 BoolVector (prefix, sz, ctx=None)
 
 FreshBool (prefix="b", ctx=None)
 
 Implies (a, b, ctx=None)
 
 Xor (a, b, ctx=None)
 
 Not (a, ctx=None)
 
 mk_not (a)
 
 _has_probe (args)
 
 And (*args)
 
 Or (*args)
 
 is_pattern (a)
 
 MultiPattern (*args)
 
 _to_pattern (arg)
 
 is_quantifier (a)
 
 _mk_quantifier (is_forall, vs, body, weight=1, qid="", skid="", patterns=[], no_patterns=[])
 
 ForAll (vs, body, weight=1, qid="", skid="", patterns=[], no_patterns=[])
 
 Exists (vs, body, weight=1, qid="", skid="", patterns=[], no_patterns=[])
 
 Lambda (vs, body)
 
bool is_arith_sort (Any s)
 
 is_arith (a)
 
bool is_int (a)
 
 is_real (a)
 
 _is_numeral (ctx, a)
 
 _is_algebraic (ctx, a)
 
 is_int_value (a)
 
 is_rational_value (a)
 
 is_algebraic_value (a)
 
bool is_add (Any a)
 
bool is_mul (Any a)
 
bool is_sub (Any a)
 
bool is_div (Any a)
 
bool is_idiv (Any a)
 
bool is_mod (Any a)
 
bool is_le (Any a)
 
bool is_lt (Any a)
 
bool is_ge (Any a)
 
bool is_gt (Any a)
 
bool is_is_int (Any a)
 
bool is_to_real (Any a)
 
bool is_to_int (Any a)
 
 _py2expr (a, ctx=None)
 
 IntSort (ctx=None)
 
 RealSort (ctx=None)
 
 _to_int_str (val)
 
 IntVal (val, ctx=None)
 
 RealVal (val, ctx=None)
 
 RatVal (a, b, ctx=None)
 
 Q (a, b, ctx=None)
 
 Int (name, ctx=None)
 
 Ints (names, ctx=None)
 
 IntVector (prefix, sz, ctx=None)
 
 FreshInt (prefix="x", ctx=None)
 
 Real (name, ctx=None)
 
 Reals (names, ctx=None)
 
 RealVector (prefix, sz, ctx=None)
 
 FreshReal (prefix="b", ctx=None)
 
 ToReal (a)
 
 ToInt (a)
 
 IsInt (a)
 
 Sqrt (a, ctx=None)
 
 Cbrt (a, ctx=None)
 
 is_bv_sort (s)
 
 is_bv (a)
 
 is_bv_value (a)
 
 BV2Int (a, is_signed=False)
 
 Int2BV (a, num_bits)
 
 BitVecSort (sz, ctx=None)
 
 BitVecVal (val, bv, ctx=None)
 
 BitVec (name, bv, ctx=None)
 
 BitVecs (names, bv, ctx=None)
 
 Concat (*args)
 
 Extract (high, low, a)
 
 _check_bv_args (a, b)
 
 ULE (a, b)
 
 ULT (a, b)
 
 UGE (a, b)
 
 UGT (a, b)
 
 UDiv (a, b)
 
 URem (a, b)
 
 SRem (a, b)
 
 LShR (a, b)
 
 RotateLeft (a, b)
 
 RotateRight (a, b)
 
 SignExt (n, a)
 
 ZeroExt (n, a)
 
 RepeatBitVec (n, a)
 
 BVRedAnd (a)
 
 BVRedOr (a)
 
 BvNand (a, b)
 
 BvNor (a, b)
 
 BvXnor (a, b)
 
 BVAddNoOverflow (a, b, signed)
 
 BVAddNoUnderflow (a, b)
 
 BVSubNoOverflow (a, b)
 
 BVSubNoUnderflow (a, b, signed)
 
 BVSDivNoOverflow (a, b)
 
 BVSNegNoOverflow (a)
 
 BVMulNoOverflow (a, b, signed)
 
 BVMulNoUnderflow (a, b)
 
 _array_select (ar, arg)
 
 is_array_sort (a)
 
bool is_array (Any a)
 
 is_const_array (a)
 
 is_K (a)
 
 is_map (a)
 
 is_default (a)
 
 get_map_func (a)
 
 ArraySort (*sig)
 
 Array (name, *sorts)
 
 Update (a, *args)
 
 Default (a)
 
 Store (a, *args)
 
 Select (a, *args)
 
 Map (f, *args)
 
 K (dom, v)
 
 Ext (a, b)
 
 AsArray (f)
 
 is_select (a)
 
 is_store (a)
 
 SetSort (s)
 Sets.
 
 EmptySet (s)
 
 FullSet (s)
 
 SetUnion (*args)
 
 SetIntersect (*args)
 
 SetAdd (s, e)
 
 SetDel (s, e)
 
 SetComplement (s)
 
 SetDifference (a, b)
 
 IsMember (e, s)
 
 IsSubset (a, b)
 
 is_finite_set (a)
 
 is_finite_set_sort (s)
 
 FiniteSetSort (elem_sort)
 
 FiniteSetEmpty (set_sort)
 
 Singleton (elem)
 
 FiniteSetUnion (s1, s2)
 
 FiniteSetIntersect (s1, s2)
 
 FiniteSetDifference (s1, s2)
 
 FiniteSetMember (elem, set)
 
 In (elem, set)
 
 FiniteSetSize (set)
 
 FiniteSetSubset (s1, s2)
 
 FiniteSetMap (f, set)
 
 FiniteSetFilter (f, set)
 
 FiniteSetRange (low, high)
 
 _valid_accessor (acc)
 Datatypes.
 
 CreateDatatypes (*ds)
 
 CreatePolymorphicDatatype (d, type_params)
 
 DatatypeSort (name, params=None, ctx=None)
 
 TupleSort (name, sorts, ctx=None)
 
 DisjointSum (name, sorts, ctx=None)
 
 EnumSort (name, values, ctx=None)
 
 args2params (arguments, keywords, ctx=None)
 
 Model (ctx=None, eval={})
 
 is_as_array (n)
 
 get_as_array_func (n)
 
 SolverFor (logic, ctx=None, logFile=None)
 
 SimpleSolver (ctx=None, logFile=None)
 
 FiniteDomainSort (name, sz, ctx=None)
 
 is_finite_domain_sort (s)
 
 is_finite_domain (a)
 
 FiniteDomainVal (val, sort, ctx=None)
 
 is_finite_domain_value (a)
 
 _global_on_model (ctx)
 
 num_simplifiers (ctx=None)
 
 simplifier_name (i, ctx=None)
 
 simplifier_description (name, ctx=None)
 
 _to_goal (a)
 
 _to_tactic (t, ctx=None)
 
 _and_then (t1, t2, ctx=None)
 
 _or_else (t1, t2, ctx=None)
 
 AndThen (*ts, **ks)
 
 Then (*ts, **ks)
 
 OrElse (*ts, **ks)
 
 ParOr (*ts, **ks)
 
 ParThen (t1, t2, ctx=None)
 
 ParAndThen (t1, t2, ctx=None)
 
 With (t, *args, **keys)
 
 WithParams (t, p)
 
 Repeat (t, max=4294967295, ctx=None)
 
 TryFor (t, ms, ctx=None)
 
 tactics (ctx=None)
 
 tactic_description (name, ctx=None)
 
 describe_tactics ()
 
 is_probe (p)
 
 _to_probe (p, ctx=None)
 
 probes (ctx=None)
 
 probe_description (name, ctx=None)
 
 describe_probes ()
 
 _probe_nary (f, args, ctx)
 
 _probe_and (args, ctx)
 
 _probe_or (args, ctx)
 
 FailIf (p, ctx=None)
 
 When (p, t, ctx=None)
 
 Cond (p, t1, t2, ctx=None)
 
 simplify (a, *arguments, **keywords)
 Utils.
 
 help_simplify ()
 
 simplify_param_descrs ()
 
 substitute (t, *m)
 
 substitute_vars (t, *m)
 
 substitute_funs (t, *m)
 
 Sum (*args)
 
 Product (*args)
 
 Abs (arg)
 
 AtMost (*args)
 
 AtLeast (*args)
 
 _reorder_pb_arg (arg)
 
 _pb_args_coeffs (args, default_ctx=None)
 
 PbLe (args, k)
 
 PbGe (args, k)
 
 PbEq (args, k, ctx=None)
 
 solve (*args, **keywords)
 
 solve_using (s, *args, **keywords)
 
 prove (claim, show=False, **keywords)
 
 _solve_html (*args, **keywords)
 
 _solve_using_html (s, *args, **keywords)
 
 _prove_html (claim, show=False, **keywords)
 
 _dict2sarray (sorts, ctx)
 
 _dict2darray (decls, ctx)
 
 parse_smt2_string (s, sorts={}, decls={}, ctx=None)
 
 parse_smt2_file (f, sorts={}, decls={}, ctx=None)
 
 get_default_rounding_mode (ctx=None)
 
 set_default_rounding_mode (rm, ctx=None)
 
 get_default_fp_sort (ctx=None)
 
 set_default_fp_sort (ebits, sbits, ctx=None)
 
 _dflt_rm (ctx=None)
 
 _dflt_fps (ctx=None)
 
 _coerce_fp_expr_list (alist, ctx)
 
 Float16 (ctx=None)
 
 FloatHalf (ctx=None)
 
 Float32 (ctx=None)
 
 FloatSingle (ctx=None)
 
 Float64 (ctx=None)
 
 FloatDouble (ctx=None)
 
 Float128 (ctx=None)
 
 FloatQuadruple (ctx=None)
 
 is_fp_sort (s)
 
 is_fprm_sort (s)
 
 RoundNearestTiesToEven (ctx=None)
 
 RNE (ctx=None)
 
 RoundNearestTiesToAway (ctx=None)
 
 RNA (ctx=None)
 
 RoundTowardPositive (ctx=None)
 
 RTP (ctx=None)
 
 RoundTowardNegative (ctx=None)
 
 RTN (ctx=None)
 
 RoundTowardZero (ctx=None)
 
 RTZ (ctx=None)
 
 is_fprm (a)
 
 is_fprm_value (a)
 
 is_fp (a)
 
 is_fp_value (a)
 
 FPSort (ebits, sbits, ctx=None)
 
 _to_float_str (val, exp=0)
 
 fpNaN (s)
 
 fpPlusInfinity (s)
 
 fpMinusInfinity (s)
 
 fpInfinity (s, negative)
 
 fpPlusZero (s)
 
 fpMinusZero (s)
 
 fpZero (s, negative)
 
 FPVal (sig, exp=None, fps=None, ctx=None)
 
 FP (name, fpsort, ctx=None)
 
 FPs (names, fpsort, ctx=None)
 
 fpAbs (a, ctx=None)
 
 fpNeg (a, ctx=None)
 
 _mk_fp_unary (f, rm, a, ctx)
 
 _mk_fp_unary_pred (f, a, ctx)
 
 _mk_fp_bin (f, rm, a, b, ctx)
 
 _mk_fp_bin_norm (f, a, b, ctx)
 
 _mk_fp_bin_pred (f, a, b, ctx)
 
 _mk_fp_tern (f, rm, a, b, c, ctx)
 
 fpAdd (rm, a, b, ctx=None)
 
 fpSub (rm, a, b, ctx=None)
 
 fpMul (rm, a, b, ctx=None)
 
 fpDiv (rm, a, b, ctx=None)
 
 fpRem (a, b, ctx=None)
 
 fpMin (a, b, ctx=None)
 
 fpMax (a, b, ctx=None)
 
 fpFMA (rm, a, b, c, ctx=None)
 
 fpSqrt (rm, a, ctx=None)
 
 fpRoundToIntegral (rm, a, ctx=None)
 
 fpIsNaN (a, ctx=None)
 
 fpIsInf (a, ctx=None)
 
 fpIsZero (a, ctx=None)
 
 fpIsNormal (a, ctx=None)
 
 fpIsSubnormal (a, ctx=None)
 
 fpIsNegative (a, ctx=None)
 
 fpIsPositive (a, ctx=None)
 
 _check_fp_args (a, b)
 
 fpLT (a, b, ctx=None)
 
 fpLEQ (a, b, ctx=None)
 
 fpGT (a, b, ctx=None)
 
 fpGEQ (a, b, ctx=None)
 
 fpEQ (a, b, ctx=None)
 
 fpNEQ (a, b, ctx=None)
 
 fpFP (sgn, exp, sig, ctx=None)
 
 fpToFP (a1, a2=None, a3=None, ctx=None)
 
 fpBVToFP (v, sort, ctx=None)
 
 fpFPToFP (rm, v, sort, ctx=None)
 
 fpRealToFP (rm, v, sort, ctx=None)
 
 fpSignedToFP (rm, v, sort, ctx=None)
 
 fpUnsignedToFP (rm, v, sort, ctx=None)
 
 fpToFPUnsigned (rm, x, s, ctx=None)
 
 fpToSBV (rm, x, s, ctx=None)
 
 fpToUBV (rm, x, s, ctx=None)
 
 fpToReal (x, ctx=None)
 
 fpToIEEEBV (x, ctx=None)
 
 StringSort (ctx=None)
 
 CharSort (ctx=None)
 
 SeqSort (s)
 
 _coerce_char (ch, ctx=None)
 
 CharVal (ch, ctx=None)
 
 CharFromBv (bv)
 
 CharToBv (ch, ctx=None)
 
 CharToInt (ch, ctx=None)
 
 CharIsDigit (ch, ctx=None)
 
 _coerce_seq (s, ctx=None)
 
 _get_ctx2 (a, b, ctx=None)
 
 is_seq (a)
 
bool is_string (Any a)
 
bool is_string_value (Any a)
 
 StringVal (s, ctx=None)
 
 String (name, ctx=None)
 
 Strings (names, ctx=None)
 
 SubString (s, offset, length)
 
 SubSeq (s, offset, length)
 
 Empty (s)
 
 Full (s)
 
 Unit (a)
 
 PrefixOf (a, b)
 
 SuffixOf (a, b)
 
 Contains (a, b)
 
 Replace (s, src, dst)
 
 IndexOf (s, substr, offset=None)
 
 LastIndexOf (s, substr)
 
 Length (s)
 
 SeqPower (s, n)
 
 SeqMap (f, s)
 
 SeqMapI (f, i, s)
 
 SeqFoldLeft (f, a, s)
 
 SeqFoldLeftI (f, i, a, s)
 
 StrToInt (s)
 
 IntToStr (s)
 
 StrToCode (s)
 
 StrFromCode (c)
 
 Re (s, ctx=None)
 
 ReSort (s)
 
 is_re (s)
 
 InRe (s, re)
 
 Union (*args)
 
 Intersect (*args)
 
 Plus (re)
 
 Option (re)
 
 Complement (re)
 
 Star (re)
 
 Loop (re, lo, hi=0)
 
 Range (lo, hi, ctx=None)
 
 Diff (a, b, ctx=None)
 
 AllChar (regex_sort, ctx=None)
 
 PartialOrder (a, index)
 
 LinearOrder (a, index)
 
 TreeOrder (a, index)
 
 PiecewiseLinearOrder (a, index)
 
 TransitiveClosure (f)
 
 to_Ast (ptr)
 
 to_ContextObj (ptr)
 
 to_AstVectorObj (ptr)
 
 on_clause_eh (ctx, p, n, dep, clause)
 
 ensure_prop_closures ()
 
 user_prop_push (ctx, cb)
 
 user_prop_pop (ctx, cb, num_scopes)
 
 user_prop_fresh (ctx, _new_ctx)
 
 user_prop_fixed (ctx, cb, id, value)
 
 user_prop_created (ctx, cb, id)
 
 user_prop_final (ctx, cb)
 
 user_prop_eq (ctx, cb, x, y)
 
 user_prop_diseq (ctx, cb, x, y)
 
 user_prop_decide (ctx, cb, t_ref, idx, phase)
 
 user_prop_binding (ctx, cb, q_ref, inst_ref)
 
 PropagateFunction (name, *sig)
 

Variables

 Z3_DEBUG = __debug__
 
 _main_ctx = None
 
 sat = CheckSatResult(Z3_L_TRUE)
 
 unsat = CheckSatResult(Z3_L_FALSE)
 
 unknown = CheckSatResult(Z3_L_UNDEF)
 
dict _on_models = {}
 
 _on_model_eh = on_model_eh_type(_global_on_model)
 
 _dflt_rounding_mode = Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN
 Floating-Point Arithmetic.
 
int _dflt_fpsort_ebits = 11
 
int _dflt_fpsort_sbits = 53
 
 _ROUNDING_MODES
 
 _my_hacky_class = None
 
 _on_clause_eh = Z3_on_clause_eh(on_clause_eh)
 
 _prop_closures = None
 
 _user_prop_push = Z3_push_eh(user_prop_push)
 
 _user_prop_pop = Z3_pop_eh(user_prop_pop)
 
 _user_prop_fresh = Z3_fresh_eh(user_prop_fresh)
 
 _user_prop_fixed = Z3_fixed_eh(user_prop_fixed)
 
 _user_prop_created = Z3_created_eh(user_prop_created)
 
 _user_prop_final = Z3_final_eh(user_prop_final)
 
 _user_prop_eq = Z3_eq_eh(user_prop_eq)
 
 _user_prop_diseq = Z3_eq_eh(user_prop_diseq)
 
 _user_prop_decide = Z3_decide_eh(user_prop_decide)
 
 _user_prop_binding = Z3_on_binding_eh(user_prop_binding)
 

Function Documentation

◆ _and_then()

_and_then (   t1,
  t2,
  ctx = None 
)
protected

Definition at line 9100 of file z3py.py.

9100def _and_then(t1, t2, ctx=None):
9101 t1 = _to_tactic(t1, ctx)
9102 t2 = _to_tactic(t2, ctx)
9103 if z3_debug():
9104 _z3_assert(t1.ctx == t2.ctx, "Context mismatch")
9105 return Tactic(Z3_tactic_and_then(t1.ctx.ref(), t1.tactic, t2.tactic), t1.ctx)
9106
9107
Z3_tactic Z3_API Z3_tactic_and_then(Z3_context c, Z3_tactic t1, Z3_tactic t2)
Return a tactic that applies t1 to a given goal and t2 to every subgoal produced by t1.

◆ _array_select()

_array_select (   ar,
  arg 
)
protected

Definition at line 4833 of file z3py.py.

4833def _array_select(ar, arg):
4834 if isinstance(arg, tuple):
4835 args = [ar.sort().domain_n(i).cast(arg[i]) for i in range(len(arg))]
4836 _args, sz = _to_ast_array(args)
4837 return _to_expr_ref(Z3_mk_select_n(ar.ctx_ref(), ar.as_ast(), sz, _args), ar.ctx)
4838 arg = ar.sort().domain().cast(arg)
4839 return _to_expr_ref(Z3_mk_select(ar.ctx_ref(), ar.as_ast(), arg.as_ast()), ar.ctx)
4840
4841
Z3_ast Z3_API Z3_mk_select(Z3_context c, Z3_ast a, Z3_ast i)
Array read. The argument a is the array and i is the index of the array that gets read.
Z3_ast Z3_API Z3_mk_select_n(Z3_context c, Z3_ast a, unsigned n, Z3_ast const *idxs)
n-ary Array read. The argument a is the array and idxs are the indices of the array that gets read.

Referenced by QuantifierRef.__getitem__(), and ArrayRef.__getitem__().

◆ _ast_kind()

int _ast_kind ( Context  ctx,
Any  a 
)
protected

Definition at line 522 of file z3py.py.

522def _ast_kind(ctx : Context, a : Any) -> int:
523 if is_ast(a):
524 a = a.as_ast()
525 return Z3_get_ast_kind(ctx.ref(), a)
526
527
Z3_ast_kind Z3_API Z3_get_ast_kind(Z3_context c, Z3_ast a)
Return the kind of the given AST.

Referenced by _to_ast_ref(), is_app(), and is_var().

◆ _check_bv_args()

_check_bv_args (   a,
  b 
)
protected

Definition at line 4355 of file z3py.py.

4355def _check_bv_args(a, b):
4356 if z3_debug():
4357 _z3_assert(is_bv(a) or is_bv(b), "First or second argument must be a Z3 bit-vector expression")
4358
4359

Referenced by BVAddNoOverflow(), BVAddNoUnderflow(), BVMulNoOverflow(), BVMulNoUnderflow(), BvNand(), BvNor(), BVSDivNoOverflow(), BVSubNoOverflow(), BVSubNoUnderflow(), BvXnor(), LShR(), RotateLeft(), RotateRight(), SRem(), UDiv(), UGE(), UGT(), ULE(), ULT(), and URem().

◆ _check_fp_args()

_check_fp_args (   a,
  b 
)
protected

Definition at line 11212 of file z3py.py.

11212def _check_fp_args(a, b):
11213 if z3_debug():
11214 _z3_assert(is_fp(a) or is_fp(b), "First or second argument must be a Z3 floating-point expression")
11215
11216

◆ _check_same_sort()

_check_same_sort (   a,
  b,
  ctx = None 
)
protected

Definition at line 1295 of file z3py.py.

1295def _check_same_sort(a, b, ctx=None):
1296 if not isinstance(a, ExprRef):
1297 return False
1298 if not isinstance(b, ExprRef):
1299 return False
1300 if ctx is None:
1301 ctx = a.ctx
1302
1303 a_sort = Z3_get_sort(ctx.ctx, a.ast)
1304 b_sort = Z3_get_sort(ctx.ctx, b.ast)
1305 return Z3_is_eq_sort(ctx.ctx, a_sort, b_sort)
1306
1307
bool Z3_API Z3_is_eq_sort(Z3_context c, Z3_sort s1, Z3_sort s2)
compare sorts.
Z3_sort Z3_API Z3_get_sort(Z3_context c, Z3_ast a)
Return the sort of an AST node.

Referenced by _coerce_exprs().

◆ _coerce_char()

_coerce_char (   ch,
  ctx = None 
)
protected

Definition at line 11658 of file z3py.py.

11658def _coerce_char(ch, ctx=None):
11659 if isinstance(ch, str):
11660 ctx = _get_ctx(ctx)
11661 ch = CharVal(ch, ctx)
11662 if not is_expr(ch):
11663 raise Z3Exception("Character expression expected")
11664 return ch
11665

◆ _coerce_expr_list()

_coerce_expr_list (   alist,
  ctx = None 
)
protected

Definition at line 1339 of file z3py.py.

1339def _coerce_expr_list(alist, ctx=None):
1340 has_expr = False
1341 for a in alist:
1342 if is_expr(a):
1343 has_expr = True
1344 break
1345 if not has_expr:
1346 alist = [_py2expr(a, ctx) for a in alist]
1347 s = _reduce(_coerce_expr_merge, alist, None)
1348 return [s.cast(a) for a in alist]
1349
1350

Referenced by And(), Distinct(), and Or().

◆ _coerce_expr_merge()

_coerce_expr_merge (   s,
  a 
)
protected

Definition at line 1277 of file z3py.py.

1277def _coerce_expr_merge(s, a):
1278 if is_expr(a):
1279 s1 = a.sort()
1280 if s is None:
1281 return s1
1282 if s1.eq(s):
1283 return s
1284 elif s.subsort(s1):
1285 return s1
1286 elif s1.subsort(s):
1287 return s
1288 else:
1289 if z3_debug():
1290 _z3_assert(s1.ctx == s.ctx, "context mismatch")
1291 _z3_assert(False, "sort mismatch")
1292 else:
1293 return s
1294

Referenced by _coerce_exprs().

◆ _coerce_exprs()

_coerce_exprs (   a,
  b,
  ctx = None 
)
protected

Definition at line 1308 of file z3py.py.

1308def _coerce_exprs(a, b, ctx=None):
1309 if not is_expr(a) and not is_expr(b):
1310 a = _py2expr(a, ctx)
1311 b = _py2expr(b, ctx)
1312 if isinstance(a, str) and isinstance(b, SeqRef):
1313 a = StringVal(a, b.ctx)
1314 if isinstance(b, str) and isinstance(a, SeqRef):
1315 b = StringVal(b, a.ctx)
1316 if isinstance(a, float) and isinstance(b, ArithRef):
1317 a = RealVal(a, b.ctx)
1318 if isinstance(b, float) and isinstance(a, ArithRef):
1319 b = RealVal(b, a.ctx)
1320
1321 if _check_same_sort(a, b, ctx):
1322 return (a, b)
1323
1324 s = None
1325 s = _coerce_expr_merge(s, a)
1326 s = _coerce_expr_merge(s, b)
1327 a = s.cast(a)
1328 b = s.cast(b)
1329 return (a, b)
1330
1331

Referenced by ArithRef.__add__(), BitVecRef.__add__(), BitVecRef.__and__(), ArithRef.__div__(), BitVecRef.__div__(), ExprRef.__eq__(), ArithRef.__ge__(), BitVecRef.__ge__(), ArithRef.__gt__(), BitVecRef.__gt__(), ArithRef.__le__(), BitVecRef.__le__(), BitVecRef.__lshift__(), ArithRef.__lt__(), BitVecRef.__lt__(), ArithRef.__mod__(), BitVecRef.__mod__(), ArithRef.__mul__(), BitVecRef.__mul__(), ExprRef.__ne__(), BitVecRef.__or__(), ArithRef.__pow__(), ArithRef.__radd__(), BitVecRef.__radd__(), BitVecRef.__rand__(), ArithRef.__rdiv__(), BitVecRef.__rdiv__(), BitVecRef.__rlshift__(), ArithRef.__rmod__(), BitVecRef.__rmod__(), ArithRef.__rmul__(), BitVecRef.__rmul__(), BitVecRef.__ror__(), ArithRef.__rpow__(), BitVecRef.__rrshift__(), BitVecRef.__rshift__(), ArithRef.__rsub__(), BitVecRef.__rsub__(), BitVecRef.__rxor__(), ArithRef.__sub__(), BitVecRef.__sub__(), BitVecRef.__xor__(), BVAddNoOverflow(), BVAddNoUnderflow(), BVMulNoOverflow(), BVMulNoUnderflow(), BvNand(), BvNor(), BVSDivNoOverflow(), BVSubNoOverflow(), BVSubNoUnderflow(), BvXnor(), Extract(), If(), LShR(), RotateLeft(), RotateRight(), SRem(), UDiv(), UGE(), UGT(), ULE(), ULT(), and URem().

◆ _coerce_fp_expr_list()

_coerce_fp_expr_list (   alist,
  ctx 
)
protected

Definition at line 10161 of file z3py.py.

10161def _coerce_fp_expr_list(alist, ctx):
10162 first_fp_sort = None
10163 for a in alist:
10164 if is_fp(a):
10165 if first_fp_sort is None:
10166 first_fp_sort = a.sort()
10167 elif first_fp_sort == a.sort():
10168 pass # OK, same as before
10169 else:
10170 # we saw at least 2 different float sorts; something will
10171 # throw a sort mismatch later, for now assume None.
10172 first_fp_sort = None
10173 break
10174
10175 r = []
10176 for i in range(len(alist)):
10177 a = alist[i]
10178 is_repr = isinstance(a, str) and a.contains("2**(") and a.endswith(")")
10179 if is_repr or _is_int(a) or isinstance(a, (float, bool)):
10180 r.append(FPVal(a, None, first_fp_sort, ctx))
10181 else:
10182 r.append(a)
10183 return _coerce_expr_list(r, ctx)
10184
10185
10186# FP Sorts
10187

◆ _coerce_seq()

_coerce_seq (   s,
  ctx = None 
)
protected

Definition at line 11708 of file z3py.py.

11708def _coerce_seq(s, ctx=None):
11709 if isinstance(s, str):
11710 ctx = _get_ctx(ctx)
11711 s = StringVal(s, ctx)
11712 if not is_expr(s):
11713 raise Z3Exception("Non-expression passed as a sequence")
11714 if not is_seq(s):
11715 raise Z3Exception("Non-sequence passed as a sequence")
11716 return s
11717
11718

Referenced by Concat().

◆ _ctx_from_ast_arg_list()

_ctx_from_ast_arg_list (   args,
  default_ctx = None 
)
protected

Definition at line 528 of file z3py.py.

528def _ctx_from_ast_arg_list(args, default_ctx=None):
529 ctx = None
530 for a in args:
531 if is_ast(a) or is_probe(a):
532 if ctx is None:
533 ctx = a.ctx
534 else:
535 if z3_debug():
536 _z3_assert(ctx == a.ctx, "Context mismatch")
537 if ctx is None:
538 ctx = default_ctx
539 return ctx
540
541

Referenced by _ctx_from_ast_args(), And(), Distinct(), FiniteSetDifference(), FiniteSetFilter(), FiniteSetIntersect(), FiniteSetMap(), FiniteSetMember(), FiniteSetRange(), FiniteSetSubset(), FiniteSetUnion(), If(), Implies(), IsMember(), IsSubset(), Not(), Or(), SetAdd(), SetDel(), SetDifference(), SetIntersect(), SetUnion(), and Xor().

◆ _ctx_from_ast_args()

_ctx_from_ast_args ( *  args)
protected

Definition at line 542 of file z3py.py.

542def _ctx_from_ast_args(*args):
543 return _ctx_from_ast_arg_list(args)
544
545

◆ _dflt_fps()

_dflt_fps (   ctx = None)
protected

Definition at line 10157 of file z3py.py.

10157def _dflt_fps(ctx=None):
10158 return get_default_fp_sort(ctx)
10159
10160

◆ _dflt_rm()

_dflt_rm (   ctx = None)
protected

Definition at line 10153 of file z3py.py.

10153def _dflt_rm(ctx=None):
10154 return get_default_rounding_mode(ctx)
10155
10156

◆ _dict2darray()

_dict2darray (   decls,
  ctx 
)
protected

Definition at line 10026 of file z3py.py.

10026def _dict2darray(decls, ctx):
10027 sz = len(decls)
10028 _names = (Symbol * sz)()
10029 _decls = (FuncDecl * sz)()
10030 i = 0
10031 for k in decls:
10032 v = decls[k]
10033 if z3_debug():
10034 _z3_assert(isinstance(k, str), "String expected")
10035 _z3_assert(is_func_decl(v) or is_const(v), "Z3 declaration or constant expected")
10036 _names[i] = to_symbol(k, ctx)
10037 if is_const(v):
10038 _decls[i] = v.decl().ast
10039 else:
10040 _decls[i] = v.ast
10041 i = i + 1
10042 return sz, _names, _decls
10043

◆ _dict2sarray()

_dict2sarray (   sorts,
  ctx 
)
protected

Definition at line 10010 of file z3py.py.

10010def _dict2sarray(sorts, ctx):
10011 sz = len(sorts)
10012 _names = (Symbol * sz)()
10013 _sorts = (Sort * sz)()
10014 i = 0
10015 for k in sorts:
10016 v = sorts[k]
10017 if z3_debug():
10018 _z3_assert(isinstance(k, str), "String expected")
10019 _z3_assert(is_sort(v), "Z3 sort expected")
10020 _names[i] = to_symbol(k, ctx)
10021 _sorts[i] = v.ast
10022 i = i + 1
10023 return sz, _names, _sorts
10024
10025

◆ _get_args()

_get_args (   args)
protected

Definition at line 152 of file z3py.py.

152def _get_args(args):
153 try:
154 if len(args) == 1 and (isinstance(args[0], tuple) or isinstance(args[0], list)):
155 return args[0]
156 elif len(args) == 1 and (isinstance(args[0], set) or isinstance(args[0], AstVector)):
157 return [arg for arg in args[0]]
158 elif len(args) == 1 and isinstance(args[0], Iterator):
159 return list(args[0])
160 else:
161 return args
162 except TypeError: # len is not necessarily defined when args is not a sequence (use reflection?)
163 return args
164
165# Use this when function takes multiple arguments
166
167

Referenced by FuncDeclRef.__call__(), And(), ArraySort(), Goal.assert_exprs(), Solver.assert_exprs(), Solver.check(), Concat(), CreateDatatypes(), Distinct(), FreshFunction(), Function(), Map(), Or(), RecAddDefinition(), RecFunction(), Select(), SetIntersect(), SetUnion(), and Update().

◆ _get_args_ast_list()

_get_args_ast_list (   args)
protected

Definition at line 168 of file z3py.py.

168def _get_args_ast_list(args):
169 try:
170 if isinstance(args, (set, AstVector, tuple)):
171 return [arg for arg in args]
172 else:
173 return args
174 except Exception:
175 return args
176
177

◆ _get_ctx()

Context _get_ctx (   ctx)
protected

Definition at line 287 of file z3py.py.

287def _get_ctx(ctx) -> Context:
288 if ctx is None:
289 return main_ctx()
290 else:
291 return ctx
292
293

Referenced by And(), BitVec(), BitVecs(), BitVecSort(), BitVecVal(), Bool(), Bools(), BoolSort(), BoolVal(), Cbrt(), DatatypeSort(), DeclareSort(), DeclareTypeVar(), EnumSort(), FreshBool(), FreshConst(), FreshInt(), FreshReal(), get_ctx(), If(), Implies(), Int(), Ints(), IntSort(), IntVal(), IntVector(), Model(), Not(), Or(), Real(), Reals(), RealSort(), RealVal(), RealVector(), Sqrt(), to_symbol(), and Xor().

◆ _get_ctx2()

_get_ctx2 (   a,
  b,
  ctx = None 
)
protected

Definition at line 11719 of file z3py.py.

11719def _get_ctx2(a, b, ctx=None):
11720 if is_expr(a):
11721 return a.ctx
11722 if is_expr(b):
11723 return b.ctx
11724 if ctx is None:
11725 ctx = main_ctx()
11726 return ctx
11727
11728

◆ _global_on_model()

_global_on_model (   ctx)
protected

Definition at line 8571 of file z3py.py.

8571def _global_on_model(ctx):
8572 (fn, mdl) = _on_models[ctx]
8573 fn(mdl)
8574
8575

◆ _has_probe()

_has_probe (   args)
protected
Return `True` if one of the elements of the given collection is a Z3 probe.

Definition at line 1980 of file z3py.py.

1980def _has_probe(args):
1981 """Return `True` if one of the elements of the given collection is a Z3 probe."""
1982 for arg in args:
1983 if is_probe(arg):
1984 return True
1985 return False
1986
1987

Referenced by And(), and Or().

◆ _is_algebraic()

_is_algebraic (   ctx,
  a 
)
protected

Definition at line 2888 of file z3py.py.

2888def _is_algebraic(ctx, a):
2889 return Z3_is_algebraic_number(ctx.ref(), a)
2890
2891
bool Z3_API Z3_is_algebraic_number(Z3_context c, Z3_ast a)
Return true if the given AST is a real algebraic number.

Referenced by _to_expr_ref(), and is_algebraic_value().

◆ _is_int()

_is_int (   v)
protected

Definition at line 76 of file z3py.py.

76 def _is_int(v):
77 return isinstance(v, (int, long))

Referenced by ParamDescrsRef.__getitem__(), ModelRef.__getitem__(), _py2expr(), Extract(), RatVal(), RepeatBitVec(), ParamsRef.set(), SignExt(), to_symbol(), and ZeroExt().

◆ _is_numeral()

_is_numeral (   ctx,
  a 
)
protected

Definition at line 2884 of file z3py.py.

2884def _is_numeral(ctx, a):
2885 return Z3_is_numeral_ast(ctx.ref(), a)
2886
2887
bool Z3_API Z3_is_numeral_ast(Z3_context c, Z3_ast a)

Referenced by _to_expr_ref(), is_bv_value(), is_int_value(), and is_rational_value().

◆ _mk_bin()

_mk_bin (   f,
  a,
  b 
)
protected

Definition at line 1537 of file z3py.py.

1537def _mk_bin(f, a, b):
1538 args = (Ast * 2)()
1539 if z3_debug():
1540 _z3_assert(a.ctx == b.ctx, "Context mismatch")
1541 args[0] = a.as_ast()
1542 args[1] = b.as_ast()
1543 return f(a.ctx.ref(), 2, args)
1544
1545

Referenced by ArithRef.__add__(), ArithRef.__mul__(), ArithRef.__radd__(), ArithRef.__rmul__(), ArithRef.__rsub__(), and ArithRef.__sub__().

◆ _mk_fp_bin()

_mk_fp_bin (   f,
  rm,
  a,
  b,
  ctx 
)
protected

Definition at line 11000 of file z3py.py.

11000def _mk_fp_bin(f, rm, a, b, ctx):
11001 ctx = _get_ctx(ctx)
11002 [a, b] = _coerce_fp_expr_list([a, b], ctx)
11003 if z3_debug():
11004 _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
11005 _z3_assert(is_fp(a) or is_fp(b), "Second or third argument must be a Z3 floating-point expression")
11006 return FPRef(f(ctx.ref(), rm.as_ast(), a.as_ast(), b.as_ast()), ctx)
11007
11008

◆ _mk_fp_bin_norm()

_mk_fp_bin_norm (   f,
  a,
  b,
  ctx 
)
protected

Definition at line 11009 of file z3py.py.

11009def _mk_fp_bin_norm(f, a, b, ctx):
11010 ctx = _get_ctx(ctx)
11011 [a, b] = _coerce_fp_expr_list([a, b], ctx)
11012 if z3_debug():
11013 _z3_assert(is_fp(a) or is_fp(b), "First or second argument must be a Z3 floating-point expression")
11014 return FPRef(f(ctx.ref(), a.as_ast(), b.as_ast()), ctx)
11015
11016

◆ _mk_fp_bin_pred()

_mk_fp_bin_pred (   f,
  a,
  b,
  ctx 
)
protected

Definition at line 11017 of file z3py.py.

11017def _mk_fp_bin_pred(f, a, b, ctx):
11018 ctx = _get_ctx(ctx)
11019 [a, b] = _coerce_fp_expr_list([a, b], ctx)
11020 if z3_debug():
11021 _z3_assert(is_fp(a) or is_fp(b), "First or second argument must be a Z3 floating-point expression")
11022 return BoolRef(f(ctx.ref(), a.as_ast(), b.as_ast()), ctx)
11023
11024

◆ _mk_fp_tern()

_mk_fp_tern (   f,
  rm,
  a,
  b,
  c,
  ctx 
)
protected

Definition at line 11025 of file z3py.py.

11025def _mk_fp_tern(f, rm, a, b, c, ctx):
11026 ctx = _get_ctx(ctx)
11027 [a, b, c] = _coerce_fp_expr_list([a, b, c], ctx)
11028 if z3_debug():
11029 _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
11030 _z3_assert(is_fp(a) or is_fp(b) or is_fp(
11031 c), "Second, third or fourth argument must be a Z3 floating-point expression")
11032 return FPRef(f(ctx.ref(), rm.as_ast(), a.as_ast(), b.as_ast(), c.as_ast()), ctx)
11033
11034

◆ _mk_fp_unary()

_mk_fp_unary (   f,
  rm,
  a,
  ctx 
)
protected

Definition at line 10983 of file z3py.py.

10983def _mk_fp_unary(f, rm, a, ctx):
10984 ctx = _get_ctx(ctx)
10985 [a] = _coerce_fp_expr_list([a], ctx)
10986 if z3_debug():
10987 _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
10988 _z3_assert(is_fp(a), "Second argument must be a Z3 floating-point expression")
10989 return FPRef(f(ctx.ref(), rm.as_ast(), a.as_ast()), ctx)
10990
10991

◆ _mk_fp_unary_pred()

_mk_fp_unary_pred (   f,
  a,
  ctx 
)
protected

Definition at line 10992 of file z3py.py.

10992def _mk_fp_unary_pred(f, a, ctx):
10993 ctx = _get_ctx(ctx)
10994 [a] = _coerce_fp_expr_list([a], ctx)
10995 if z3_debug():
10996 _z3_assert(is_fp(a), "First argument must be a Z3 floating-point expression")
10997 return BoolRef(f(ctx.ref(), a.as_ast()), ctx)
10998
10999

◆ _mk_quantifier()

_mk_quantifier (   is_forall,
  vs,
  body,
  weight = 1,
  qid = "",
  skid = "",
  patterns = [],
  no_patterns = [] 
)
protected

Definition at line 2336 of file z3py.py.

2336def _mk_quantifier(is_forall, vs, body, weight=1, qid="", skid="", patterns=[], no_patterns=[]):
2337 if z3_debug():
2338 _z3_assert(is_bool(body) or is_app(vs) or (len(vs) > 0 and is_app(vs[0])), "Z3 expression expected")
2339 _z3_assert(is_const(vs) or (len(vs) > 0 and all([is_const(v) for v in vs])), "Invalid bounded variable(s)")
2340 _z3_assert(all([is_pattern(a) or is_expr(a) for a in patterns]), "Z3 patterns expected")
2341 _z3_assert(all([is_expr(p) for p in no_patterns]), "no patterns are Z3 expressions")
2342 if is_app(vs):
2343 ctx = vs.ctx
2344 vs = [vs]
2345 else:
2346 ctx = vs[0].ctx
2347 if not is_expr(body):
2348 body = BoolVal(body, ctx)
2349 num_vars = len(vs)
2350 if num_vars == 0:
2351 return body
2352 _vs = (Ast * num_vars)()
2353 for i in range(num_vars):
2354 # TODO: Check if is constant
2355 _vs[i] = vs[i].as_ast()
2356 patterns = [_to_pattern(p) for p in patterns]
2357 num_pats = len(patterns)
2358 _pats = (Pattern * num_pats)()
2359 for i in range(num_pats):
2360 _pats[i] = patterns[i].ast
2361 _no_pats, num_no_pats = _to_ast_array(no_patterns)
2362 qid = to_symbol(qid, ctx)
2363 skid = to_symbol(skid, ctx)
2364 return QuantifierRef(Z3_mk_quantifier_const_ex(ctx.ref(), is_forall, weight, qid, skid,
2365 num_vars, _vs,
2366 num_pats, _pats,
2367 num_no_pats, _no_pats,
2368 body.as_ast()), ctx)
2369
2370
Z3_ast Z3_API Z3_mk_quantifier_const_ex(Z3_context c, bool is_forall, unsigned weight, Z3_symbol quantifier_id, Z3_symbol skolem_id, unsigned num_bound, Z3_app const bound[], unsigned num_patterns, Z3_pattern const patterns[], unsigned num_no_patterns, Z3_ast const no_patterns[], Z3_ast body)
Create a universal or existential quantifier using a list of constants that will form the set of boun...

Referenced by Exists(), and ForAll().

◆ _or_else()

_or_else (   t1,
  t2,
  ctx = None 
)
protected

Definition at line 9108 of file z3py.py.

9108def _or_else(t1, t2, ctx=None):
9109 t1 = _to_tactic(t1, ctx)
9110 t2 = _to_tactic(t2, ctx)
9111 if z3_debug():
9112 _z3_assert(t1.ctx == t2.ctx, "Context mismatch")
9113 return Tactic(Z3_tactic_or_else(t1.ctx.ref(), t1.tactic, t2.tactic), t1.ctx)
9114
9115
Z3_tactic Z3_API Z3_tactic_or_else(Z3_context c, Z3_tactic t1, Z3_tactic t2)
Return a tactic that first applies t1 to a given goal, if it fails then returns the result of t2 appl...

◆ _pb_args_coeffs()

_pb_args_coeffs (   args,
  default_ctx = None 
)
protected

Definition at line 9799 of file z3py.py.

9799def _pb_args_coeffs(args, default_ctx=None):
9800 args = _get_args_ast_list(args)
9801 if len(args) == 0:
9802 return _get_ctx(default_ctx), 0, (Ast * 0)(), (ctypes.c_int * 0)()
9803 args = [_reorder_pb_arg(arg) for arg in args]
9804 args, coeffs = zip(*args)
9805 if z3_debug():
9806 _z3_assert(len(args) > 0, "Non empty list of arguments expected")
9807 ctx = _ctx_from_ast_arg_list(args)
9808 if z3_debug():
9809 _z3_assert(ctx is not None, "At least one of the arguments must be a Z3 expression")
9810 args = _coerce_expr_list(args, ctx)
9811 _args, sz = _to_ast_array(args)
9812 _coeffs = (ctypes.c_int * len(coeffs))()
9813 for i in range(len(coeffs)):
9814 _z3_check_cint_overflow(coeffs[i], "coefficient")
9815 _coeffs[i] = coeffs[i]
9816 return ctx, sz, _args, _coeffs, args
9817
9818

◆ _probe_and()

_probe_and (   args,
  ctx 
)
protected

Definition at line 9523 of file z3py.py.

9523def _probe_and(args, ctx):
9524 return _probe_nary(Z3_probe_and, args, ctx)
9525
9526

Referenced by And().

◆ _probe_nary()

_probe_nary (   f,
  args,
  ctx 
)
protected

Definition at line 9513 of file z3py.py.

9513def _probe_nary(f, args, ctx):
9514 if z3_debug():
9515 _z3_assert(len(args) > 0, "At least one argument expected")
9516 num = len(args)
9517 r = _to_probe(args[0], ctx)
9518 for i in range(num - 1):
9519 r = Probe(f(ctx.ref(), r.probe, _to_probe(args[i + 1], ctx).probe), ctx)
9520 return r
9521
9522

◆ _probe_or()

_probe_or (   args,
  ctx 
)
protected

Definition at line 9527 of file z3py.py.

9527def _probe_or(args, ctx):
9528 return _probe_nary(Z3_probe_or, args, ctx)
9529
9530

Referenced by Or().

◆ _prove_html()

_prove_html (   claim,
  show = False,
**  keywords 
)
protected
Version of function `prove` that renders HTML.

Definition at line 9990 of file z3py.py.

9990def _prove_html(claim, show=False, **keywords):
9991 """Version of function `prove` that renders HTML."""
9992 if z3_debug():
9993 _z3_assert(is_bool(claim), "Z3 Boolean expression expected")
9994 s = Solver()
9995 s.set(**keywords)
9996 s.add(Not(claim))
9997 if show:
9998 print(s)
9999 r = s.check()
10000 if r == unsat:
10001 print("<b>proved</b>")
10002 elif r == unknown:
10003 print("<b>failed to prove</b>")
10004 print(s.model())
10005 else:
10006 print("<b>counterexample</b>")
10007 print(s.model())
10008
10009

◆ _py2expr()

_py2expr (   a,
  ctx = None 
)
protected

Definition at line 3289 of file z3py.py.

3289def _py2expr(a, ctx=None):
3290 if isinstance(a, bool):
3291 return BoolVal(a, ctx)
3292 if _is_int(a):
3293 return IntVal(a, ctx)
3294 if isinstance(a, float):
3295 return RealVal(a, ctx)
3296 if isinstance(a, str):
3297 return StringVal(a, ctx)
3298 if is_expr(a):
3299 return a
3300 if z3_debug():
3301 _z3_assert(False, "Python bool, int, long or float expected")
3302
3303

Referenced by _coerce_expr_list(), _coerce_exprs(), FiniteSetSortRef.cast(), IsMember(), K(), SetAdd(), SetDel(), and ModelRef.update_value().

◆ _reduce()

_reduce (   func,
  sequence,
  initial 
)
protected

Definition at line 1332 of file z3py.py.

1332def _reduce(func, sequence, initial):
1333 result = initial
1334 for element in sequence:
1335 result = func(result, element)
1336 return result
1337
1338

Referenced by _coerce_expr_list().

◆ _reorder_pb_arg()

_reorder_pb_arg (   arg)
protected

Definition at line 9792 of file z3py.py.

9792def _reorder_pb_arg(arg):
9793 a, b = arg
9794 if not _is_int(b) and _is_int(a):
9795 return b, a
9796 return arg
9797
9798

◆ _solve_html()

_solve_html ( *  args,
**  keywords 
)
protected
Version of function `solve` that renders HTML output.

Definition at line 9941 of file z3py.py.

9941def _solve_html(*args, **keywords):
9942 """Version of function `solve` that renders HTML output."""
9943 show = keywords.pop("show", False)
9944 s = Solver()
9945 s.set(**keywords)
9946 s.add(*args)
9947 if show:
9948 print("<b>Problem:</b>")
9949 print(s)
9950 r = s.check()
9951 if r == unsat:
9952 print("<b>no solution</b>")
9953 elif r == unknown:
9954 print("<b>failed to solve</b>")
9955 try:
9956 print(s.model())
9957 except Z3Exception:
9958 return
9959 else:
9960 if show:
9961 print("<b>Solution:</b>")
9962 print(s.model())
9963
9964

◆ _solve_using_html()

_solve_using_html (   s,
*  args,
**  keywords 
)
protected
Version of function `solve_using` that renders HTML.

Definition at line 9965 of file z3py.py.

9965def _solve_using_html(s, *args, **keywords):
9966 """Version of function `solve_using` that renders HTML."""
9967 show = keywords.pop("show", False)
9968 if z3_debug():
9969 _z3_assert(isinstance(s, Solver), "Solver object expected")
9970 s.set(**keywords)
9971 s.add(*args)
9972 if show:
9973 print("<b>Problem:</b>")
9974 print(s)
9975 r = s.check()
9976 if r == unsat:
9977 print("<b>no solution</b>")
9978 elif r == unknown:
9979 print("<b>failed to solve</b>")
9980 try:
9981 print(s.model())
9982 except Z3Exception:
9983 return
9984 else:
9985 if show:
9986 print("<b>Solution:</b>")
9987 print(s.model())
9988
9989

◆ _sort()

SortRef _sort ( Context  ctx,
Any  a 
)
protected

Definition at line 728 of file z3py.py.

728def _sort(ctx : Context, a : Any) -> SortRef:
729 return _to_sort_ref(Z3_get_sort(ctx.ref(), a), ctx)
730
731

◆ _sort_kind()

_sort_kind (   ctx,
  s 
)
protected

Sorts.

Definition at line 586 of file z3py.py.

586def _sort_kind(ctx, s):
587 return Z3_get_sort_kind(ctx.ref(), s)
588
589
Z3_sort_kind Z3_API Z3_get_sort_kind(Z3_context c, Z3_sort t)
Return the sort kind (e.g., array, tuple, int, bool, etc).

Referenced by _to_sort_ref().

◆ _symbol2py()

_symbol2py (   ctx,
  s 
)
protected
Convert a Z3 symbol back into a Python object. 

Definition at line 140 of file z3py.py.

140def _symbol2py(ctx, s):
141 """Convert a Z3 symbol back into a Python object. """
142 if Z3_get_symbol_kind(ctx.ref(), s) == Z3_INT_SYMBOL:
143 return "k!%s" % Z3_get_symbol_int(ctx.ref(), s)
144 else:
145 return Z3_get_symbol_string(ctx.ref(), s)
146
147# Hack for having nary functions that can receive one argument that is the
148# list of arguments.
149# Use this when function takes a single list of arguments
150
151
int Z3_API Z3_get_symbol_int(Z3_context c, Z3_symbol s)
Return the symbol int value.
Z3_symbol_kind Z3_API Z3_get_symbol_kind(Z3_context c, Z3_symbol s)
Return Z3_INT_SYMBOL if the symbol was constructed using Z3_mk_int_symbol, and Z3_STRING_SYMBOL if th...
Z3_string Z3_API Z3_get_symbol_string(Z3_context c, Z3_symbol s)
Return the symbol name.

Referenced by ParamDescrsRef.get_name(), SortRef.name(), FuncDeclRef.params(), QuantifierRef.qid(), QuantifierRef.skolem_id(), and QuantifierRef.var_name().

◆ _to_ast_array()

_to_ast_array (   args)
protected

Definition at line 554 of file z3py.py.

554def _to_ast_array(args):
555 sz = len(args)
556 _args = (Ast * sz)()
557 for i in range(sz):
558 _args[i] = args[i].as_ast()
559 return _args, sz
560
561

Referenced by ExprRef.__ne__(), _array_select(), _mk_quantifier(), And(), Distinct(), Map(), MultiPattern(), Or(), SetIntersect(), SetUnion(), and Update().

◆ _to_ast_ref()

_to_ast_ref (   a,
  ctx 
)
protected

Definition at line 570 of file z3py.py.

570def _to_ast_ref(a, ctx):
571 k = _ast_kind(ctx, a)
572 if k == Z3_SORT_AST:
573 return _to_sort_ref(a, ctx)
574 elif k == Z3_FUNC_DECL_AST:
575 return _to_func_decl_ref(a, ctx)
576 else:
577 return _to_expr_ref(a, ctx)
578
579

Referenced by AstRef.__deepcopy__(), AstVector.__getitem__(), AstMap.__getitem__(), and AstRef.translate().

◆ _to_expr_ref()

_to_expr_ref (   a,
  ctx 
)
protected

Definition at line 1223 of file z3py.py.

1223def _to_expr_ref(a, ctx):
1224 if isinstance(a, Pattern):
1225 return PatternRef(a, ctx)
1226 ctx_ref = ctx.ref()
1227 k = Z3_get_ast_kind(ctx_ref, a)
1228 if k == Z3_QUANTIFIER_AST:
1229 return QuantifierRef(a, ctx)
1230 # Check for finite set sort before checking sort kind
1231 s = Z3_get_sort(ctx_ref, a)
1232 if Z3_is_finite_set_sort(ctx_ref, s):
1233 return FiniteSetRef(a, ctx)
1234 sk = Z3_get_sort_kind(ctx_ref, s)
1235 if sk == Z3_BOOL_SORT:
1236 return BoolRef(a, ctx)
1237 if sk == Z3_INT_SORT:
1238 if k == Z3_NUMERAL_AST:
1239 return IntNumRef(a, ctx)
1240 return ArithRef(a, ctx)
1241 if sk == Z3_REAL_SORT:
1242 if k == Z3_NUMERAL_AST:
1243 return RatNumRef(a, ctx)
1244 if _is_algebraic(ctx, a):
1245 return AlgebraicNumRef(a, ctx)
1246 return ArithRef(a, ctx)
1247 if sk == Z3_BV_SORT:
1248 if k == Z3_NUMERAL_AST:
1249 return BitVecNumRef(a, ctx)
1250 else:
1251 return BitVecRef(a, ctx)
1252 if sk == Z3_ARRAY_SORT:
1253 return ArrayRef(a, ctx)
1254 if sk == Z3_DATATYPE_SORT:
1255 return DatatypeRef(a, ctx)
1256 if sk == Z3_FLOATING_POINT_SORT:
1257 if k == Z3_APP_AST and _is_numeral(ctx, a):
1258 return FPNumRef(a, ctx)
1259 else:
1260 return FPRef(a, ctx)
1261 if sk == Z3_FINITE_DOMAIN_SORT:
1262 if k == Z3_NUMERAL_AST:
1263 return FiniteDomainNumRef(a, ctx)
1264 else:
1265 return FiniteDomainRef(a, ctx)
1266 if sk == Z3_ROUNDING_MODE_SORT:
1267 return FPRMRef(a, ctx)
1268 if sk == Z3_SEQ_SORT:
1269 return SeqRef(a, ctx)
1270 if sk == Z3_CHAR_SORT:
1271 return CharRef(a, ctx)
1272 if sk == Z3_RE_SORT:
1273 return ReRef(a, ctx)
1274 return ExprRef(a, ctx)
1275
1276
bool Z3_API Z3_is_finite_set_sort(Z3_context c, Z3_sort s)
Check if a sort is a finite set sort.

Referenced by FuncDeclRef.__call__(), _array_select(), _to_ast_ref(), ExprRef.arg(), FuncEntry.arg_value(), QuantifierRef.body(), Const(), ArrayRef.default(), FuncInterp.else_value(), ModelRef.eval(), Ext(), FreshConst(), Goal.get(), ModelRef.get_interp(), If(), QuantifierRef.no_pattern(), ModelRef.project(), ModelRef.project_with_witness(), Update(), ExprRef.update(), DatatypeRef.update_field(), FuncEntry.value(), and Var().

◆ _to_float_str()

_to_float_str (   val,
  exp = 0 
)
protected

Definition at line 10745 of file z3py.py.

10745def _to_float_str(val, exp=0):
10746 if isinstance(val, float):
10747 if math.isnan(val):
10748 res = "NaN"
10749 elif val == 0.0:
10750 sone = math.copysign(1.0, val)
10751 if sone < 0.0:
10752 return "-0.0"
10753 else:
10754 return "+0.0"
10755 elif val == float("+inf"):
10756 res = "+oo"
10757 elif val == float("-inf"):
10758 res = "-oo"
10759 else:
10760 v = val.as_integer_ratio()
10761 num = v[0]
10762 den = v[1]
10763 rvs = str(num) + "/" + str(den)
10764 res = rvs + "p" + _to_int_str(exp)
10765 elif isinstance(val, bool):
10766 if val:
10767 res = "1.0"
10768 else:
10769 res = "0.0"
10770 elif _is_int(val):
10771 res = str(val)
10772 elif isinstance(val, str):
10773 inx = val.find("*(2**")
10774 if inx == -1:
10775 res = val
10776 elif val[-1] == ")":
10777 res = val[0:inx]
10778 exp = str(int(val[inx + 5:-1]) + int(exp))
10779 else:
10780 _z3_assert(False, "String does not have floating-point numeral form.")
10781 elif z3_debug():
10782 _z3_assert(False, "Python value cannot be used to create floating-point numerals.")
10783 if exp == 0:
10784 return res
10785 else:
10786 return res + "p" + exp
10787
10788

◆ _to_func_decl_array()

_to_func_decl_array (   args)
protected

Definition at line 546 of file z3py.py.

546def _to_func_decl_array(args):
547 sz = len(args)
548 _args = (FuncDecl * sz)()
549 for i in range(sz):
550 _args[i] = args[i].as_func_decl()
551 return _args, sz
552
553

◆ _to_func_decl_ref()

_to_func_decl_ref (   a,
  ctx 
)
protected

Definition at line 964 of file z3py.py.

964def _to_func_decl_ref(a, ctx):
965 return FuncDeclRef(a, ctx)
966
967

Referenced by _to_ast_ref().

◆ _to_goal()

_to_goal (   a)
protected

Definition at line 9084 of file z3py.py.

9084def _to_goal(a):
9085 if isinstance(a, BoolRef):
9086 goal = Goal(ctx=a.ctx)
9087 goal.add(a)
9088 return goal
9089 else:
9090 return a
9091
9092

◆ _to_int_str()

_to_int_str (   val)
protected

Definition at line 3338 of file z3py.py.

3338def _to_int_str(val):
3339 if isinstance(val, float):
3340 return str(int(val))
3341 elif isinstance(val, bool):
3342 if val:
3343 return "1"
3344 else:
3345 return "0"
3346 else:
3347 return str(val)
3348
3349

Referenced by BitVecVal(), and IntVal().

◆ _to_param_value()

_to_param_value (   val)
protected

Definition at line 178 of file z3py.py.

178def _to_param_value(val):
179 if isinstance(val, bool):
180 return "true" if val else "false"
181 return str(val)
182
183

Referenced by Context.__init__(), and set_param().

◆ _to_pattern()

_to_pattern (   arg)
protected

Definition at line 2114 of file z3py.py.

2114def _to_pattern(arg):
2115 if is_pattern(arg):
2116 return arg
2117 else:
2118 return MultiPattern(arg)
2119

Referenced by _mk_quantifier().

◆ _to_probe()

_to_probe (   p,
  ctx = None 
)
protected

Definition at line 9467 of file z3py.py.

9467def _to_probe(p, ctx=None):
9468 if is_probe(p):
9469 return p
9470 else:
9471 return Probe(p, ctx)
9472
9473

◆ _to_ref_array()

_to_ref_array (   ref,
  args 
)
protected

Definition at line 562 of file z3py.py.

562def _to_ref_array(ref, args):
563 sz = len(args)
564 _args = (ref * sz)()
565 for i in range(sz):
566 _args[i] = args[i].as_ast()
567 return _args, sz
568
569

◆ _to_sort_ref()

_to_sort_ref (   s,
  ctx 
)
protected

Definition at line 695 of file z3py.py.

695def _to_sort_ref(s, ctx):
696 if z3_debug():
697 _z3_assert(isinstance(s, Sort), "Z3 Sort expected")
698 if Z3_is_finite_set_sort(ctx.ref(), s):
699 return FiniteSetSortRef(s, ctx)
700 k = _sort_kind(ctx, s)
701 if k == Z3_BOOL_SORT:
702 return BoolSortRef(s, ctx)
703 elif k == Z3_INT_SORT or k == Z3_REAL_SORT:
704 return ArithSortRef(s, ctx)
705 elif k == Z3_BV_SORT:
706 return BitVecSortRef(s, ctx)
707 elif k == Z3_ARRAY_SORT:
708 return ArraySortRef(s, ctx)
709 elif k == Z3_DATATYPE_SORT:
710 return DatatypeSortRef(s, ctx)
711 elif k == Z3_FINITE_DOMAIN_SORT:
712 return FiniteDomainSortRef(s, ctx)
713 elif k == Z3_FLOATING_POINT_SORT:
714 return FPSortRef(s, ctx)
715 elif k == Z3_ROUNDING_MODE_SORT:
716 return FPRMSortRef(s, ctx)
717 elif k == Z3_RE_SORT:
718 return ReSortRef(s, ctx)
719 elif k == Z3_SEQ_SORT:
720 return SeqSortRef(s, ctx)
721 elif k == Z3_CHAR_SORT:
722 return CharSortRef(s, ctx)
723 elif k == Z3_TYPE_VAR:
724 return TypeVarRef(s, ctx)
725 return SortRef(s, ctx)
726
727

Referenced by _sort(), _to_ast_ref(), FuncDeclRef.domain(), ArraySortRef.domain_n(), ModelRef.get_sort(), FuncDeclRef.range(), ArraySortRef.range(), and QuantifierRef.var_sort().

◆ _to_tactic()

_to_tactic (   t,
  ctx = None 
)
protected

Definition at line 9093 of file z3py.py.

9093def _to_tactic(t, ctx=None):
9094 if isinstance(t, Tactic):
9095 return t
9096 else:
9097 return Tactic(t, ctx)
9098
9099

◆ _valid_accessor()

_valid_accessor (   acc)
protected

Datatypes.

Return `True` if acc is pair of the form (String, Datatype or Sort). 

Definition at line 5521 of file z3py.py.

5521def _valid_accessor(acc):
5522 """Return `True` if acc is pair of the form (String, Datatype or Sort). """
5523 if not isinstance(acc, tuple):
5524 return False
5525 if len(acc) != 2:
5526 return False
5527 return isinstance(acc[0], str) and (isinstance(acc[1], Datatype) or is_sort(acc[1]))
5528
5529

Referenced by Datatype.declare_core().

◆ _z3_assert()

_z3_assert (   cond,
  msg 
)
protected

Definition at line 113 of file z3py.py.

113def _z3_assert(cond, msg):
114 if not cond:
115 raise Z3Exception(msg)
116
117

Referenced by QuantifierRef.__getitem__(), ModelRef.__getitem__(), Context.__init__(), ParamDescrsRef.__init__(), Goal.__init__(), ArithRef.__mod__(), ArithRef.__rmod__(), _check_bv_args(), _coerce_expr_merge(), _ctx_from_ast_arg_list(), _mk_bin(), _mk_quantifier(), _py2expr(), _to_sort_ref(), _z3_check_cint_overflow(), DatatypeSortRef.accessor(), And(), ExprRef.arg(), args2params(), ArraySort(), IntNumRef.as_long(), RatNumRef.as_long(), AsArray(), Solver.assert_and_track(), BV2Int(), BVRedAnd(), BVRedOr(), BVSNegNoOverflow(), SortRef.cast(), FiniteSetSortRef.cast(), Concat(), Const(), DatatypeSortRef.constructor(), Goal.convert_model(), CreateDatatypes(), CreatePolymorphicDatatype(), ExprRef.decl(), Datatype.declare(), Datatype.declare_core(), Default(), Distinct(), EnumSort(), eq(), AstRef.eq(), Ext(), Extract(), FreshConst(), FreshFunction(), Function(), get_as_array_func(), ModelRef.get_interp(), get_map_func(), ModelRef.get_universe(), get_var_index(), If(), IsInt(), K(), ExprRef.kind(), Map(), MultiPattern(), QuantifierRef.no_pattern(), ExprRef.num_args(), Or(), QuantifierRef.pattern(), RatVal(), RecFunction(), DatatypeSortRef.recognizer(), RepeatBitVec(), Select(), ParamsRef.set(), set_param(), SignExt(), ToInt(), ToReal(), AstRef.translate(), Goal.translate(), ModelRef.translate(), Update(), ExprRef.update(), DatatypeRef.update_field(), ParamsRef.validate(), Var(), QuantifierRef.var_name(), QuantifierRef.var_sort(), and ZeroExt().

◆ _z3_check_cint_overflow()

_z3_check_cint_overflow (   n,
  name 
)
protected

Definition at line 118 of file z3py.py.

118def _z3_check_cint_overflow(n, name):
119 _z3_assert(ctypes.c_int(n).value == n, name + " is too large")
120
121

◆ Abs()

Abs (   arg)
Create the absolute value of an arithmetic expression

Definition at line 9751 of file z3py.py.

9751def Abs(arg):
9752 """Create the absolute value of an arithmetic expression"""
9753 return If(arg > 0, arg, -arg)
9754
9755

Referenced by ArithRef.__abs__().

◆ AllChar()

AllChar (   regex_sort,
  ctx = None 
)
Create a regular expression that accepts all single character strings

Definition at line 12217 of file z3py.py.

12217def AllChar(regex_sort, ctx=None):
12218 """Create a regular expression that accepts all single character strings
12219 """
12220 return ReRef(Z3_mk_re_allchar(regex_sort.ctx_ref(), regex_sort.ast), regex_sort.ctx)
12221
12222# Special Relations
12223
12224
Z3_ast Z3_API Z3_mk_re_allchar(Z3_context c, Z3_sort regex_sort)
Create a regular expression that accepts all singleton sequences of the regular expression sort.

◆ And()

And ( *  args)
Create a Z3 and-expression or and-probe.

>>> p, q, r = Bools('p q r')
>>> And(p, q, r)
And(p, q, r)
>>> P = BoolVector('p', 5)
>>> And(P)
And(p__0, p__1, p__2, p__3, p__4)

Definition at line 1988 of file z3py.py.

1988def And(*args):
1989 """Create a Z3 and-expression or and-probe.
1990
1991 >>> p, q, r = Bools('p q r')
1992 >>> And(p, q, r)
1993 And(p, q, r)
1994 >>> P = BoolVector('p', 5)
1995 >>> And(P)
1996 And(p__0, p__1, p__2, p__3, p__4)
1997 """
1998 last_arg = None
1999 if len(args) > 0:
2000 last_arg = args[len(args) - 1]
2001 if isinstance(last_arg, Context):
2002 ctx = args[len(args) - 1]
2003 args = args[:len(args) - 1]
2004 elif len(args) == 1 and isinstance(args[0], AstVector):
2005 ctx = args[0].ctx
2006 args = [a for a in args[0]]
2007 else:
2008 ctx = None
2009 args = _get_args(args)
2010 ctx = _get_ctx(_ctx_from_ast_arg_list(args, ctx))
2011 if z3_debug():
2012 _z3_assert(ctx is not None, "At least one of the arguments must be a Z3 expression or probe")
2013 if _has_probe(args):
2014 return _probe_and(args, ctx)
2015 else:
2016 args = _coerce_expr_list(args, ctx)
2017 _args, sz = _to_ast_array(args)
2018 return BoolRef(Z3_mk_and(ctx.ref(), sz, _args), ctx)
2019
2020
Z3_ast Z3_API Z3_mk_and(Z3_context c, unsigned num_args, Z3_ast const args[])
Create an AST node representing args[0] and ... and args[num_args-1].

Referenced by BoolRef.__and__(), and Goal.as_expr().

◆ AndThen()

AndThen ( *  ts,
**  ks 
)
Return a tactic that applies the tactics in `*ts` in sequence.

>>> x, y = Ints('x y')
>>> t = AndThen(Tactic('simplify'), Tactic('solve-eqs'))
>>> t(And(x == 0, y > x + 1))
[[Not(y <= 1)]]
>>> t(And(x == 0, y > x + 1)).as_expr()
Not(y <= 1)

Definition at line 9116 of file z3py.py.

9116def AndThen(*ts, **ks):
9117 """Return a tactic that applies the tactics in `*ts` in sequence.
9118
9119 >>> x, y = Ints('x y')
9120 >>> t = AndThen(Tactic('simplify'), Tactic('solve-eqs'))
9121 >>> t(And(x == 0, y > x + 1))
9122 [[Not(y <= 1)]]
9123 >>> t(And(x == 0, y > x + 1)).as_expr()
9124 Not(y <= 1)
9125 """
9126 if z3_debug():
9127 _z3_assert(len(ts) >= 2, "At least two arguments expected")
9128 ctx = ks.get("ctx", None)
9129 num = len(ts)
9130 r = ts[0]
9131 for i in range(num - 1):
9132 r = _and_then(r, ts[i + 1], ctx)
9133 return r
9134
9135

◆ append_log()

append_log (   s)
Append user-defined string to interaction log. 

Definition at line 127 of file z3py.py.

127def append_log(s):
128 """Append user-defined string to interaction log. """
130
131
void Z3_API Z3_append_log(Z3_string string)
Append user-defined string to interaction log.

◆ args2params()

args2params (   arguments,
  keywords,
  ctx = None 
)
Convert python arguments into a Z3_params object.
A ':' is added to the keywords, and '_' is replaced with '-'

>>> args2params(['model', True, 'relevancy', 2], {'elim_and' : True})
(params model true relevancy 2 elim_and true)

Definition at line 6080 of file z3py.py.

6080def args2params(arguments, keywords, ctx=None):
6081 """Convert python arguments into a Z3_params object.
6082 A ':' is added to the keywords, and '_' is replaced with '-'
6083
6084 >>> args2params(['model', True, 'relevancy', 2], {'elim_and' : True})
6085 (params model true relevancy 2 elim_and true)
6086 """
6087 if z3_debug():
6088 _z3_assert(len(arguments) % 2 == 0, "Argument list must have an even number of elements.")
6089 prev = None
6090 r = ParamsRef(ctx)
6091 for a in arguments:
6092 if prev is None:
6093 prev = a
6094 else:
6095 r.set(prev, a)
6096 prev = None
6097 for k in keywords:
6098 v = keywords[k]
6099 r.set(k, v)
6100 return r
6101
6102

Referenced by Solver.set().

◆ Array()

Array (   name,
*  sorts 
)
Return an array constant named `name` with the given domain and range sorts.

>>> a = Array('a', IntSort(), IntSort())
>>> a.sort()
Array(Int, Int)
>>> a[0]
a[0]

Definition at line 4970 of file z3py.py.

4970def Array(name, *sorts):
4971 """Return an array constant named `name` with the given domain and range sorts.
4972
4973 >>> a = Array('a', IntSort(), IntSort())
4974 >>> a.sort()
4975 Array(Int, Int)
4976 >>> a[0]
4977 a[0]
4978 """
4979 s = ArraySort(sorts)
4980 ctx = s.ctx
4981 return ArrayRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), s.ast), ctx)
4982
4983
Z3_ast Z3_API Z3_mk_const(Z3_context c, Z3_symbol s, Z3_sort ty)
Declare and create a constant.

◆ ArraySort()

ArraySort ( *  sig)
Return the Z3 array sort with the given domain and range sorts.

>>> A = ArraySort(IntSort(), BoolSort())
>>> A
Array(Int, Bool)
>>> A.domain()
Int
>>> A.range()
Bool
>>> AA = ArraySort(IntSort(), A)
>>> AA
Array(Int, Array(Int, Bool))
>>> ArraySort(IntSort(), BoolSort(), RealSort())
Array(Int, Bool, Real)

Definition at line 4935 of file z3py.py.

4935def ArraySort(*sig):
4936 """Return the Z3 array sort with the given domain and range sorts.
4937
4938 >>> A = ArraySort(IntSort(), BoolSort())
4939 >>> A
4940 Array(Int, Bool)
4941 >>> A.domain()
4942 Int
4943 >>> A.range()
4944 Bool
4945 >>> AA = ArraySort(IntSort(), A)
4946 >>> AA
4947 Array(Int, Array(Int, Bool))
4948 >>> ArraySort(IntSort(), BoolSort(), RealSort())
4949 Array(Int, Bool, Real)
4950 """
4951 sig = _get_args(sig)
4952 if z3_debug():
4953 _z3_assert(len(sig) > 1, "At least two arguments expected")
4954 arity = len(sig) - 1
4955 r = sig[arity]
4956 d = sig[0]
4957 if z3_debug():
4958 for s in sig:
4959 _z3_assert(is_sort(s), "Z3 sort expected")
4960 _z3_assert(s.ctx == r.ctx, "Context mismatch")
4961 ctx = d.ctx
4962 if len(sig) == 2:
4963 return ArraySortRef(Z3_mk_array_sort(ctx.ref(), d.ast, r.ast), ctx)
4964 dom = (Sort * arity)()
4965 for i in range(arity):
4966 dom[i] = sig[i].ast
4967 return ArraySortRef(Z3_mk_array_sort_n(ctx.ref(), arity, dom, r.ast), ctx)
4968
4969
Z3_sort Z3_API Z3_mk_array_sort_n(Z3_context c, unsigned n, Z3_sort const *domain, Z3_sort range)
Create an array type with N arguments.
Z3_sort Z3_API Z3_mk_array_sort(Z3_context c, Z3_sort domain, Z3_sort range)
Create an array type.

Referenced by SortRef.__gt__(), Array(), and SetSort().

◆ AsArray()

AsArray (   f)
Return a Z3 as-array expression for the given function declaration.

>>> f = Function('f', IntSort(), IntSort())
>>> a = AsArray(f)
>>> a.sort()
Array(Int, Int)
>>> is_as_array(a)
True
>>> get_as_array_func(a) == f
True

Definition at line 5117 of file z3py.py.

5117def AsArray(f):
5118 """Return a Z3 as-array expression for the given function declaration.
5119
5120 >>> f = Function('f', IntSort(), IntSort())
5121 >>> a = AsArray(f)
5122 >>> a.sort()
5123 Array(Int, Int)
5124 >>> is_as_array(a)
5125 True
5126 >>> get_as_array_func(a) == f
5127 True
5128 """
5129 if z3_debug():
5130 _z3_assert(isinstance(f, FuncDeclRef), "function declaration expected")
5131 ctx = f.ctx
5132 return ArrayRef(Z3_mk_as_array(ctx.ref(), f.ast), ctx)
5133
5134
Z3_ast Z3_API Z3_mk_as_array(Z3_context c, Z3_func_decl f)
Create array with the same interpretation as a function. The array satisfies the property (f x) = (se...

Referenced by FiniteSetFilter(), and FiniteSetMap().

◆ AtLeast()

AtLeast ( *  args)
Create an at-least Pseudo-Boolean k constraint.

>>> a, b, c = Bools('a b c')
>>> f = AtLeast(a, b, c, 2)

Definition at line 9774 of file z3py.py.

9774def AtLeast(*args):
9775 """Create an at-least Pseudo-Boolean k constraint.
9776
9777 >>> a, b, c = Bools('a b c')
9778 >>> f = AtLeast(a, b, c, 2)
9779 """
9780 args = _get_args(args)
9781 if z3_debug():
9782 _z3_assert(len(args) > 1, "Non empty list of arguments expected")
9783 ctx = _ctx_from_ast_arg_list(args)
9784 if z3_debug():
9785 _z3_assert(ctx is not None, "At least one of the arguments must be a Z3 expression")
9786 args1 = _coerce_expr_list(args[:-1], ctx)
9787 k = args[-1]
9788 _args, sz = _to_ast_array(args1)
9789 return BoolRef(Z3_mk_atleast(ctx.ref(), sz, _args, k), ctx)
9790
9791
Z3_ast Z3_API Z3_mk_atleast(Z3_context c, unsigned num_args, Z3_ast const args[], unsigned k)
Pseudo-Boolean relations.

◆ AtMost()

AtMost ( *  args)
Create an at-most Pseudo-Boolean k constraint.

>>> a, b, c = Bools('a b c')
>>> f = AtMost(a, b, c, 2)

Definition at line 9756 of file z3py.py.

9756def AtMost(*args):
9757 """Create an at-most Pseudo-Boolean k constraint.
9758
9759 >>> a, b, c = Bools('a b c')
9760 >>> f = AtMost(a, b, c, 2)
9761 """
9762 args = _get_args(args)
9763 if z3_debug():
9764 _z3_assert(len(args) > 1, "Non empty list of arguments expected")
9765 ctx = _ctx_from_ast_arg_list(args)
9766 if z3_debug():
9767 _z3_assert(ctx is not None, "At least one of the arguments must be a Z3 expression")
9768 args1 = _coerce_expr_list(args[:-1], ctx)
9769 k = args[-1]
9770 _args, sz = _to_ast_array(args1)
9771 return BoolRef(Z3_mk_atmost(ctx.ref(), sz, _args, k), ctx)
9772
9773
Z3_ast Z3_API Z3_mk_atmost(Z3_context c, unsigned num_args, Z3_ast const args[], unsigned k)
Pseudo-Boolean relations.

◆ BitVec()

BitVec (   name,
  bv,
  ctx = None 
)
Return a bit-vector constant named `name`. `bv` may be the number of bits of a bit-vector sort.
If `ctx=None`, then the global context is used.

>>> x  = BitVec('x', 16)
>>> is_bv(x)
True
>>> x.size()
16
>>> x.sort()
BitVec(16)
>>> word = BitVecSort(16)
>>> x2 = BitVec('x', word)
>>> eq(x, x2)
True

Definition at line 4210 of file z3py.py.

4210def BitVec(name, bv, ctx=None):
4211 """Return a bit-vector constant named `name`. `bv` may be the number of bits of a bit-vector sort.
4212 If `ctx=None`, then the global context is used.
4213
4214 >>> x = BitVec('x', 16)
4215 >>> is_bv(x)
4216 True
4217 >>> x.size()
4218 16
4219 >>> x.sort()
4220 BitVec(16)
4221 >>> word = BitVecSort(16)
4222 >>> x2 = BitVec('x', word)
4223 >>> eq(x, x2)
4224 True
4225 """
4226 if isinstance(bv, BitVecSortRef):
4227 ctx = bv.ctx
4228 else:
4229 ctx = _get_ctx(ctx)
4230 bv = BitVecSort(bv, ctx)
4231 return BitVecRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), bv.ast), ctx)
4232
4233

Referenced by BitVecs().

◆ BitVecs()

BitVecs (   names,
  bv,
  ctx = None 
)
Return a tuple of bit-vector constants of size bv.

>>> x, y, z = BitVecs('x y z', 16)
>>> x.size()
16
>>> x.sort()
BitVec(16)
>>> Sum(x, y, z)
0 + x + y + z
>>> Product(x, y, z)
1*x*y*z
>>> simplify(Product(x, y, z))
x*y*z

Definition at line 4234 of file z3py.py.

4234def BitVecs(names, bv, ctx=None):
4235 """Return a tuple of bit-vector constants of size bv.
4236
4237 >>> x, y, z = BitVecs('x y z', 16)
4238 >>> x.size()
4239 16
4240 >>> x.sort()
4241 BitVec(16)
4242 >>> Sum(x, y, z)
4243 0 + x + y + z
4244 >>> Product(x, y, z)
4245 1*x*y*z
4246 >>> simplify(Product(x, y, z))
4247 x*y*z
4248 """
4249 ctx = _get_ctx(ctx)
4250 if isinstance(names, str):
4251 names = names.split(" ")
4252 return [BitVec(name, bv, ctx) for name in names]
4253
4254

◆ BitVecSort()

BitVecSort (   sz,
  ctx = None 
)
Return a Z3 bit-vector sort of the given size. If `ctx=None`, then the global context is used.

>>> Byte = BitVecSort(8)
>>> Word = BitVecSort(16)
>>> Byte
BitVec(8)
>>> x = Const('x', Byte)
>>> eq(x, BitVec('x', 8))
True

Definition at line 4178 of file z3py.py.

4178def BitVecSort(sz, ctx=None):
4179 """Return a Z3 bit-vector sort of the given size. If `ctx=None`, then the global context is used.
4180
4181 >>> Byte = BitVecSort(8)
4182 >>> Word = BitVecSort(16)
4183 >>> Byte
4184 BitVec(8)
4185 >>> x = Const('x', Byte)
4186 >>> eq(x, BitVec('x', 8))
4187 True
4188 """
4189 ctx = _get_ctx(ctx)
4190 return BitVecSortRef(Z3_mk_bv_sort(ctx.ref(), sz), ctx)
4191
4192
Z3_sort Z3_API Z3_mk_bv_sort(Z3_context c, unsigned sz)
Create a bit-vector type of the given size.

Referenced by BitVec(), and BitVecVal().

◆ BitVecVal()

BitVecVal (   val,
  bv,
  ctx = None 
)
Return a bit-vector value with the given number of bits. If `ctx=None`, then the global context is used.

>>> v = BitVecVal(10, 32)
>>> v
10
>>> print("0x%.8x" % v.as_long())
0x0000000a

Definition at line 4193 of file z3py.py.

4193def BitVecVal(val, bv, ctx=None):
4194 """Return a bit-vector value with the given number of bits. If `ctx=None`, then the global context is used.
4195
4196 >>> v = BitVecVal(10, 32)
4197 >>> v
4198 10
4199 >>> print("0x%.8x" % v.as_long())
4200 0x0000000a
4201 """
4202 if is_bv_sort(bv):
4203 ctx = bv.ctx
4204 return BitVecNumRef(Z3_mk_numeral(ctx.ref(), _to_int_str(val), bv.ast), ctx)
4205 else:
4206 ctx = _get_ctx(ctx)
4207 return BitVecNumRef(Z3_mk_numeral(ctx.ref(), _to_int_str(val), BitVecSort(bv, ctx).ast), ctx)
4208
4209
Z3_ast Z3_API Z3_mk_numeral(Z3_context c, Z3_string numeral, Z3_sort ty)
Create a numeral of a given sort.

◆ Bool()

Bool (   name,
  ctx = None 
)
Return a Boolean constant named `name`. If `ctx=None`, then the global context is used.

>>> p = Bool('p')
>>> q = Bool('q')
>>> And(p, q)
And(p, q)

Definition at line 1867 of file z3py.py.

1867def Bool(name, ctx=None):
1868 """Return a Boolean constant named `name`. If `ctx=None`, then the global context is used.
1869
1870 >>> p = Bool('p')
1871 >>> q = Bool('q')
1872 >>> And(p, q)
1873 And(p, q)
1874 """
1875 ctx = _get_ctx(ctx)
1876 return BoolRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), BoolSort(ctx).ast), ctx)
1877
1878

Referenced by Solver.assert_and_track(), Bools(), and BoolVector().

◆ Bools()

Bools (   names,
  ctx = None 
)
Return a tuple of Boolean constants.

`names` is a single string containing all names separated by blank spaces.
If `ctx=None`, then the global context is used.

>>> p, q, r = Bools('p q r')
>>> And(p, Or(q, r))
And(p, Or(q, r))

Definition at line 1879 of file z3py.py.

1879def Bools(names, ctx=None):
1880 """Return a tuple of Boolean constants.
1881
1882 `names` is a single string containing all names separated by blank spaces.
1883 If `ctx=None`, then the global context is used.
1884
1885 >>> p, q, r = Bools('p q r')
1886 >>> And(p, Or(q, r))
1887 And(p, Or(q, r))
1888 """
1889 ctx = _get_ctx(ctx)
1890 if isinstance(names, str):
1891 names = names.split(" ")
1892 return [Bool(name, ctx) for name in names]
1893
1894

◆ BoolSort()

BoolSort (   ctx = None)
Return the Boolean Z3 sort. If `ctx=None`, then the global context is used.

>>> BoolSort()
Bool
>>> p = Const('p', BoolSort())
>>> is_bool(p)
True
>>> r = Function('r', IntSort(), IntSort(), BoolSort())
>>> r(0, 1)
r(0, 1)
>>> is_bool(r(0, 1))
True

Definition at line 1830 of file z3py.py.

1830def BoolSort(ctx=None):
1831 """Return the Boolean Z3 sort. If `ctx=None`, then the global context is used.
1832
1833 >>> BoolSort()
1834 Bool
1835 >>> p = Const('p', BoolSort())
1836 >>> is_bool(p)
1837 True
1838 >>> r = Function('r', IntSort(), IntSort(), BoolSort())
1839 >>> r(0, 1)
1840 r(0, 1)
1841 >>> is_bool(r(0, 1))
1842 True
1843 """
1844 ctx = _get_ctx(ctx)
1845 return BoolSortRef(Z3_mk_bool_sort(ctx.ref()), ctx)
1846
1847
Z3_sort Z3_API Z3_mk_bool_sort(Z3_context c)
Create the Boolean type.

Referenced by Goal.assert_exprs(), Solver.assert_exprs(), Bool(), Solver.check(), FreshBool(), If(), Implies(), Not(), SetSort(), and Xor().

◆ BoolVal()

BoolVal (   val,
  ctx = None 
)
Return the Boolean value `True` or `False`. If `ctx=None`, then the global context is used.

>>> BoolVal(True)
True
>>> is_true(BoolVal(True))
True
>>> is_true(True)
False
>>> is_false(BoolVal(False))
True

Definition at line 1848 of file z3py.py.

1848def BoolVal(val, ctx=None):
1849 """Return the Boolean value `True` or `False`. If `ctx=None`, then the global context is used.
1850
1851 >>> BoolVal(True)
1852 True
1853 >>> is_true(BoolVal(True))
1854 True
1855 >>> is_true(True)
1856 False
1857 >>> is_false(BoolVal(False))
1858 True
1859 """
1860 ctx = _get_ctx(ctx)
1861 if val:
1862 return BoolRef(Z3_mk_true(ctx.ref()), ctx)
1863 else:
1864 return BoolRef(Z3_mk_false(ctx.ref()), ctx)
1865
1866
Z3_ast Z3_API Z3_mk_true(Z3_context c)
Create an AST node representing true.
Z3_ast Z3_API Z3_mk_false(Z3_context c)
Create an AST node representing false.

Referenced by _mk_quantifier(), _py2expr(), and Goal.as_expr().

◆ BoolVector()

BoolVector (   prefix,
  sz,
  ctx = None 
)
Return a list of Boolean constants of size `sz`.

The constants are named using the given prefix.
If `ctx=None`, then the global context is used.

>>> P = BoolVector('p', 3)
>>> P
[p__0, p__1, p__2]
>>> And(P)
And(p__0, p__1, p__2)

Definition at line 1895 of file z3py.py.

1895def BoolVector(prefix, sz, ctx=None):
1896 """Return a list of Boolean constants of size `sz`.
1897
1898 The constants are named using the given prefix.
1899 If `ctx=None`, then the global context is used.
1900
1901 >>> P = BoolVector('p', 3)
1902 >>> P
1903 [p__0, p__1, p__2]
1904 >>> And(P)
1905 And(p__0, p__1, p__2)
1906 """
1907 return [Bool("%s__%s" % (prefix, i)) for i in range(sz)]
1908
1909

◆ BV2Int()

BV2Int (   a,
  is_signed = False 
)
Return the Z3 expression BV2Int(a).

>>> b = BitVec('b', 3)
>>> BV2Int(b).sort()
Int
>>> x = Int('x')
>>> x > BV2Int(b)
x > BV2Int(b)
>>> x > BV2Int(b, is_signed=False)
x > BV2Int(b)
>>> x > BV2Int(b, is_signed=True)
x > If(b < 0, BV2Int(b) - 8, BV2Int(b))
>>> solve(x > BV2Int(b), b == 1, x < 3)
[x = 2, b = 1]

Definition at line 4146 of file z3py.py.

4146def BV2Int(a, is_signed=False):
4147 """Return the Z3 expression BV2Int(a).
4148
4149 >>> b = BitVec('b', 3)
4150 >>> BV2Int(b).sort()
4151 Int
4152 >>> x = Int('x')
4153 >>> x > BV2Int(b)
4154 x > BV2Int(b)
4155 >>> x > BV2Int(b, is_signed=False)
4156 x > BV2Int(b)
4157 >>> x > BV2Int(b, is_signed=True)
4158 x > If(b < 0, BV2Int(b) - 8, BV2Int(b))
4159 >>> solve(x > BV2Int(b), b == 1, x < 3)
4160 [x = 2, b = 1]
4161 """
4162 if z3_debug():
4163 _z3_assert(is_bv(a), "First argument must be a Z3 bit-vector expression")
4164 ctx = a.ctx
4165 # investigate problem with bv2int
4166 return ArithRef(Z3_mk_bv2int(ctx.ref(), a.as_ast(), is_signed), ctx)
4167
4168
Z3_ast Z3_API Z3_mk_bv2int(Z3_context c, Z3_ast t1, bool is_signed)
Create an integer from the bit-vector argument t1. If is_signed is false, then the bit-vector t1 is t...

◆ BVAddNoOverflow()

BVAddNoOverflow (   a,
  b,
  signed 
)
A predicate the determines that bit-vector addition does not overflow

Definition at line 4694 of file z3py.py.

4694def BVAddNoOverflow(a, b, signed):
4695 """A predicate the determines that bit-vector addition does not overflow"""
4696 _check_bv_args(a, b)
4697 a, b = _coerce_exprs(a, b)
4698 return BoolRef(Z3_mk_bvadd_no_overflow(a.ctx_ref(), a.as_ast(), b.as_ast(), signed), a.ctx)
4699
4700
Z3_ast Z3_API Z3_mk_bvadd_no_overflow(Z3_context c, Z3_ast t1, Z3_ast t2, bool is_signed)
Create a predicate that checks that the bit-wise addition of t1 and t2 does not overflow.

◆ BVAddNoUnderflow()

BVAddNoUnderflow (   a,
  b 
)
A predicate the determines that signed bit-vector addition does not underflow

Definition at line 4701 of file z3py.py.

4701def BVAddNoUnderflow(a, b):
4702 """A predicate the determines that signed bit-vector addition does not underflow"""
4703 _check_bv_args(a, b)
4704 a, b = _coerce_exprs(a, b)
4705 return BoolRef(Z3_mk_bvadd_no_underflow(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4706
4707
Z3_ast Z3_API Z3_mk_bvadd_no_underflow(Z3_context c, Z3_ast t1, Z3_ast t2)
Create a predicate that checks that the bit-wise signed addition of t1 and t2 does not underflow.

◆ BVMulNoOverflow()

BVMulNoOverflow (   a,
  b,
  signed 
)
A predicate the determines that bit-vector multiplication does not overflow

Definition at line 4736 of file z3py.py.

4736def BVMulNoOverflow(a, b, signed):
4737 """A predicate the determines that bit-vector multiplication does not overflow"""
4738 _check_bv_args(a, b)
4739 a, b = _coerce_exprs(a, b)
4740 return BoolRef(Z3_mk_bvmul_no_overflow(a.ctx_ref(), a.as_ast(), b.as_ast(), signed), a.ctx)
4741
4742
Z3_ast Z3_API Z3_mk_bvmul_no_overflow(Z3_context c, Z3_ast t1, Z3_ast t2, bool is_signed)
Create a predicate that checks that the bit-wise multiplication of t1 and t2 does not overflow.

◆ BVMulNoUnderflow()

BVMulNoUnderflow (   a,
  b 
)
A predicate the determines that bit-vector signed multiplication does not underflow

Definition at line 4743 of file z3py.py.

4743def BVMulNoUnderflow(a, b):
4744 """A predicate the determines that bit-vector signed multiplication does not underflow"""
4745 _check_bv_args(a, b)
4746 a, b = _coerce_exprs(a, b)
4747 return BoolRef(Z3_mk_bvmul_no_underflow(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4748
4749
Z3_ast Z3_API Z3_mk_bvmul_no_underflow(Z3_context c, Z3_ast t1, Z3_ast t2)
Create a predicate that checks that the bit-wise signed multiplication of t1 and t2 does not underflo...

◆ BvNand()

BvNand (   a,
  b 
)
Return the bitwise NAND of `a` and `b`.

>>> x = BitVec('x', 8)
>>> y = BitVec('y', 8)
>>> BvNand(x, y)
bvnand(x, y)

Definition at line 4655 of file z3py.py.

4655def BvNand(a, b):
4656 """Return the bitwise NAND of `a` and `b`.
4657
4658 >>> x = BitVec('x', 8)
4659 >>> y = BitVec('y', 8)
4660 >>> BvNand(x, y)
4661 bvnand(x, y)
4662 """
4663 _check_bv_args(a, b)
4664 a, b = _coerce_exprs(a, b)
4665 return BitVecRef(Z3_mk_bvnand(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4666
4667
Z3_ast Z3_API Z3_mk_bvnand(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise nand.

◆ BvNor()

BvNor (   a,
  b 
)
Return the bitwise NOR of `a` and `b`.

>>> x = BitVec('x', 8)
>>> y = BitVec('y', 8)
>>> BvNor(x, y)
bvnor(x, y)

Definition at line 4668 of file z3py.py.

4668def BvNor(a, b):
4669 """Return the bitwise NOR of `a` and `b`.
4670
4671 >>> x = BitVec('x', 8)
4672 >>> y = BitVec('y', 8)
4673 >>> BvNor(x, y)
4674 bvnor(x, y)
4675 """
4676 _check_bv_args(a, b)
4677 a, b = _coerce_exprs(a, b)
4678 return BitVecRef(Z3_mk_bvnor(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4679
4680
Z3_ast Z3_API Z3_mk_bvnor(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise nor.

◆ BVRedAnd()

BVRedAnd (   a)
Return the reduction-and expression of `a`.

Definition at line 4641 of file z3py.py.

4641def BVRedAnd(a):
4642 """Return the reduction-and expression of `a`."""
4643 if z3_debug():
4644 _z3_assert(is_bv(a), "First argument must be a Z3 bit-vector expression")
4645 return BitVecRef(Z3_mk_bvredand(a.ctx_ref(), a.as_ast()), a.ctx)
4646
4647
Z3_ast Z3_API Z3_mk_bvredand(Z3_context c, Z3_ast t1)
Take conjunction of bits in vector, return vector of length 1.

◆ BVRedOr()

BVRedOr (   a)
Return the reduction-or expression of `a`.

Definition at line 4648 of file z3py.py.

4648def BVRedOr(a):
4649 """Return the reduction-or expression of `a`."""
4650 if z3_debug():
4651 _z3_assert(is_bv(a), "First argument must be a Z3 bit-vector expression")
4652 return BitVecRef(Z3_mk_bvredor(a.ctx_ref(), a.as_ast()), a.ctx)
4653
4654
Z3_ast Z3_API Z3_mk_bvredor(Z3_context c, Z3_ast t1)
Take disjunction of bits in vector, return vector of length 1.

◆ BVSDivNoOverflow()

BVSDivNoOverflow (   a,
  b 
)
A predicate the determines that bit-vector signed division does not overflow

Definition at line 4722 of file z3py.py.

4722def BVSDivNoOverflow(a, b):
4723 """A predicate the determines that bit-vector signed division does not overflow"""
4724 _check_bv_args(a, b)
4725 a, b = _coerce_exprs(a, b)
4726 return BoolRef(Z3_mk_bvsdiv_no_overflow(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4727
4728
Z3_ast Z3_API Z3_mk_bvsdiv_no_overflow(Z3_context c, Z3_ast t1, Z3_ast t2)
Create a predicate that checks that the bit-wise signed division of t1 and t2 does not overflow.

◆ BVSNegNoOverflow()

BVSNegNoOverflow (   a)
A predicate the determines that bit-vector unary negation does not overflow

Definition at line 4729 of file z3py.py.

4729def BVSNegNoOverflow(a):
4730 """A predicate the determines that bit-vector unary negation does not overflow"""
4731 if z3_debug():
4732 _z3_assert(is_bv(a), "First argument must be a Z3 bit-vector expression")
4733 return BoolRef(Z3_mk_bvneg_no_overflow(a.ctx_ref(), a.as_ast()), a.ctx)
4734
4735
Z3_ast Z3_API Z3_mk_bvneg_no_overflow(Z3_context c, Z3_ast t1)
Check that bit-wise negation does not overflow when t1 is interpreted as a signed bit-vector.

◆ BVSubNoOverflow()

BVSubNoOverflow (   a,
  b 
)
A predicate the determines that bit-vector subtraction does not overflow

Definition at line 4708 of file z3py.py.

4708def BVSubNoOverflow(a, b):
4709 """A predicate the determines that bit-vector subtraction does not overflow"""
4710 _check_bv_args(a, b)
4711 a, b = _coerce_exprs(a, b)
4712 return BoolRef(Z3_mk_bvsub_no_overflow(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4713
4714
Z3_ast Z3_API Z3_mk_bvsub_no_overflow(Z3_context c, Z3_ast t1, Z3_ast t2)
Create a predicate that checks that the bit-wise signed subtraction of t1 and t2 does not overflow.

◆ BVSubNoUnderflow()

BVSubNoUnderflow (   a,
  b,
  signed 
)
A predicate the determines that bit-vector subtraction does not underflow

Definition at line 4715 of file z3py.py.

4715def BVSubNoUnderflow(a, b, signed):
4716 """A predicate the determines that bit-vector subtraction does not underflow"""
4717 _check_bv_args(a, b)
4718 a, b = _coerce_exprs(a, b)
4719 return BoolRef(Z3_mk_bvsub_no_underflow(a.ctx_ref(), a.as_ast(), b.as_ast(), signed), a.ctx)
4720
4721
Z3_ast Z3_API Z3_mk_bvsub_no_underflow(Z3_context c, Z3_ast t1, Z3_ast t2, bool is_signed)
Create a predicate that checks that the bit-wise subtraction of t1 and t2 does not underflow.

◆ BvXnor()

BvXnor (   a,
  b 
)
Return the bitwise XNOR of `a` and `b`.

>>> x = BitVec('x', 8)
>>> y = BitVec('y', 8)
>>> BvXnor(x, y)
bvxnor(x, y)

Definition at line 4681 of file z3py.py.

4681def BvXnor(a, b):
4682 """Return the bitwise XNOR of `a` and `b`.
4683
4684 >>> x = BitVec('x', 8)
4685 >>> y = BitVec('y', 8)
4686 >>> BvXnor(x, y)
4687 bvxnor(x, y)
4688 """
4689 _check_bv_args(a, b)
4690 a, b = _coerce_exprs(a, b)
4691 return BitVecRef(Z3_mk_bvxnor(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4692
4693
Z3_ast Z3_API Z3_mk_bvxnor(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise xnor.

◆ Cbrt()

Cbrt (   a,
  ctx = None 
)
 Return a Z3 expression which represents the cubic root of a.

>>> x = Real('x')
>>> Cbrt(x)
x**(1/3)

Definition at line 3592 of file z3py.py.

3592def Cbrt(a, ctx=None):
3593 """ Return a Z3 expression which represents the cubic root of a.
3594
3595 >>> x = Real('x')
3596 >>> Cbrt(x)
3597 x**(1/3)
3598 """
3599 if not is_expr(a):
3600 ctx = _get_ctx(ctx)
3601 a = RealVal(a, ctx)
3602 return a ** "1/3"
3603

◆ CharFromBv()

CharFromBv (   bv)

Definition at line 11691 of file z3py.py.

11691def CharFromBv(bv):
11692 if not is_expr(bv):
11693 raise Z3Exception("Bit-vector expression needed")
11694 return _to_expr_ref(Z3_mk_char_from_bv(bv.ctx_ref(), bv.as_ast()), bv.ctx)
11695
Z3_ast Z3_API Z3_mk_char_from_bv(Z3_context c, Z3_ast bv)
Create a character from a bit-vector (code point).

◆ CharIsDigit()

CharIsDigit (   ch,
  ctx = None 
)

Definition at line 11704 of file z3py.py.

11704def CharIsDigit(ch, ctx=None):
11705 ch = _coerce_char(ch, ctx)
11706 return ch.is_digit()
11707

◆ CharSort()

CharSort (   ctx = None)
Create a character sort
>>> ch = CharSort()
>>> print(ch)
Char

Definition at line 11584 of file z3py.py.

11584def CharSort(ctx=None):
11585 """Create a character sort
11586 >>> ch = CharSort()
11587 >>> print(ch)
11588 Char
11589 """
11590 ctx = _get_ctx(ctx)
11591 return CharSortRef(Z3_mk_char_sort(ctx.ref()), ctx)
11592
11593
Z3_sort Z3_API Z3_mk_char_sort(Z3_context c)
Create a sort for unicode characters.

◆ CharToBv()

CharToBv (   ch,
  ctx = None 
)

Definition at line 11696 of file z3py.py.

11696def CharToBv(ch, ctx=None):
11697 ch = _coerce_char(ch, ctx)
11698 return ch.to_bv()
11699

◆ CharToInt()

CharToInt (   ch,
  ctx = None 
)

Definition at line 11700 of file z3py.py.

11700def CharToInt(ch, ctx=None):
11701 ch = _coerce_char(ch, ctx)
11702 return ch.to_int()
11703

◆ CharVal()

CharVal (   ch,
  ctx = None 
)

Definition at line 11683 of file z3py.py.

11683def CharVal(ch, ctx=None):
11684 ctx = _get_ctx(ctx)
11685 if isinstance(ch, str):
11686 ch = ord(ch)
11687 if not isinstance(ch, int):
11688 raise Z3Exception("character value should be an ordinal")
11689 return _to_expr_ref(Z3_mk_char(ctx.ref(), ch), ctx)
11690
Z3_ast Z3_API Z3_mk_char(Z3_context c, unsigned ch)
Create a character literal.

◆ Complement()

Complement (   re)
Create the complement regular expression.

Definition at line 12159 of file z3py.py.

12159def Complement(re):
12160 """Create the complement regular expression."""
12161 return ReRef(Z3_mk_re_complement(re.ctx_ref(), re.as_ast()), re.ctx)
12162
12163
Z3_ast Z3_API Z3_mk_re_complement(Z3_context c, Z3_ast re)
Create the complement of the regular language re.

◆ Concat()

Concat ( *  args)
Create a Z3 bit-vector concatenation expression.

>>> v = BitVecVal(1, 4)
>>> Concat(v, v+1, v)
Concat(Concat(1, 1 + 1), 1)
>>> simplify(Concat(v, v+1, v))
289
>>> print("%.3x" % simplify(Concat(v, v+1, v)).as_long())
121

Definition at line 4255 of file z3py.py.

4255def Concat(*args):
4256 """Create a Z3 bit-vector concatenation expression.
4257
4258 >>> v = BitVecVal(1, 4)
4259 >>> Concat(v, v+1, v)
4260 Concat(Concat(1, 1 + 1), 1)
4261 >>> simplify(Concat(v, v+1, v))
4262 289
4263 >>> print("%.3x" % simplify(Concat(v, v+1, v)).as_long())
4264 121
4265 """
4266 args = _get_args(args)
4267 sz = len(args)
4268 if z3_debug():
4269 _z3_assert(sz >= 2, "At least two arguments expected.")
4270
4271 ctx = None
4272 for a in args:
4273 if is_expr(a):
4274 ctx = a.ctx
4275 break
4276 if is_seq(args[0]) or isinstance(args[0], str):
4277 args = [_coerce_seq(s, ctx) for s in args]
4278 if z3_debug():
4279 _z3_assert(all([is_seq(a) for a in args]), "All arguments must be sequence expressions.")
4280 v = (Ast * sz)()
4281 for i in range(sz):
4282 v[i] = args[i].as_ast()
4283 return SeqRef(Z3_mk_seq_concat(ctx.ref(), sz, v), ctx)
4284
4285 if is_re(args[0]):
4286 if z3_debug():
4287 _z3_assert(all([is_re(a) for a in args]), "All arguments must be regular expressions.")
4288 v = (Ast * sz)()
4289 for i in range(sz):
4290 v[i] = args[i].as_ast()
4291 return ReRef(Z3_mk_re_concat(ctx.ref(), sz, v), ctx)
4292
4293 if z3_debug():
4294 _z3_assert(all([is_bv(a) for a in args]), "All arguments must be Z3 bit-vector expressions.")
4295 r = args[0]
4296 for i in range(sz - 1):
4297 r = BitVecRef(Z3_mk_concat(ctx.ref(), r.as_ast(), args[i + 1].as_ast()), ctx)
4298 return r
4299
4300
Z3_ast Z3_API Z3_mk_seq_concat(Z3_context c, unsigned n, Z3_ast const args[])
Concatenate sequences.
Z3_ast Z3_API Z3_mk_re_concat(Z3_context c, unsigned n, Z3_ast const args[])
Create the concatenation of the regular languages.
Z3_ast Z3_API Z3_mk_concat(Z3_context c, Z3_ast t1, Z3_ast t2)
Concatenate the given bit-vectors.

◆ Cond()

Cond (   p,
  t1,
  t2,
  ctx = None 
)
Return a tactic that applies tactic `t1` to a goal if probe `p` evaluates to true, and `t2` otherwise.

>>> t = Cond(Probe('is-qfnra'), Tactic('qfnra'), Tactic('smt'))

Definition at line 9573 of file z3py.py.

9573def Cond(p, t1, t2, ctx=None):
9574 """Return a tactic that applies tactic `t1` to a goal if probe `p` evaluates to true, and `t2` otherwise.
9575
9576 >>> t = Cond(Probe('is-qfnra'), Tactic('qfnra'), Tactic('smt'))
9577 """
9578 p = _to_probe(p, ctx)
9579 t1 = _to_tactic(t1, ctx)
9580 t2 = _to_tactic(t2, ctx)
9581 return Tactic(Z3_tactic_cond(t1.ctx.ref(), p.probe, t1.tactic, t2.tactic), t1.ctx)
9582
Z3_tactic Z3_API Z3_tactic_cond(Z3_context c, Z3_probe p, Z3_tactic t1, Z3_tactic t2)
Return a tactic that applies t1 to a given goal if the probe p evaluates to true, and t2 if p evaluat...

Referenced by If().

◆ Const()

Const (   name,
  sort 
)
Create a constant of the given sort.

>>> Const('x', IntSort())
x

Definition at line 1546 of file z3py.py.

1546def Const(name, sort):
1547 """Create a constant of the given sort.
1548
1549 >>> Const('x', IntSort())
1550 x
1551 """
1552 if z3_debug():
1553 _z3_assert(isinstance(sort, SortRef), "Z3 sort expected")
1554 ctx = sort.ctx
1555 return _to_expr_ref(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), sort.ast), ctx)
1556
1557

Referenced by Consts().

◆ Consts()

Consts (   names,
  sort 
)
Create several constants of the given sort.

`names` is a string containing the names of all constants to be created.
Blank spaces separate the names of different constants.

>>> x, y, z = Consts('x y z', IntSort())
>>> x + y + z
x + y + z

Definition at line 1558 of file z3py.py.

1558def Consts(names, sort):
1559 """Create several constants of the given sort.
1560
1561 `names` is a string containing the names of all constants to be created.
1562 Blank spaces separate the names of different constants.
1563
1564 >>> x, y, z = Consts('x y z', IntSort())
1565 >>> x + y + z
1566 x + y + z
1567 """
1568 if isinstance(names, str):
1569 names = names.split(" ")
1570 return [Const(name, sort) for name in names]
1571
1572

◆ Contains()

Contains (   a,
  b 
)
Check if 'a' contains 'b'
>>> s1 = Contains("abc", "ab")
>>> simplify(s1)
True
>>> s2 = Contains("abc", "bc")
>>> simplify(s2)
True
>>> x, y, z = Strings('x y z')
>>> s3 = Contains(Concat(x,y,z), y)
>>> simplify(s3)
True

Definition at line 11878 of file z3py.py.

11878def Contains(a, b):
11879 """Check if 'a' contains 'b'
11880 >>> s1 = Contains("abc", "ab")
11881 >>> simplify(s1)
11882 True
11883 >>> s2 = Contains("abc", "bc")
11884 >>> simplify(s2)
11885 True
11886 >>> x, y, z = Strings('x y z')
11887 >>> s3 = Contains(Concat(x,y,z), y)
11888 >>> simplify(s3)
11889 True
11890 """
11891 ctx = _get_ctx2(a, b)
11892 a = _coerce_seq(a, ctx)
11893 b = _coerce_seq(b, ctx)
11894 return BoolRef(Z3_mk_seq_contains(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
11895
11896
Z3_ast Z3_API Z3_mk_seq_contains(Z3_context c, Z3_ast container, Z3_ast containee)
Check if container contains containee.

◆ CreateDatatypes()

CreateDatatypes ( *  ds)
Create mutually recursive Z3 datatypes using 1 or more Datatype helper objects.

In the following example we define a Tree-List using two mutually recursive datatypes.

>>> TreeList = Datatype('TreeList')
>>> Tree     = Datatype('Tree')
>>> # Tree has two constructors: leaf and node
>>> Tree.declare('leaf', ('val', IntSort()))
>>> # a node contains a list of trees
>>> Tree.declare('node', ('children', TreeList))
>>> TreeList.declare('nil')
>>> TreeList.declare('cons', ('car', Tree), ('cdr', TreeList))
>>> Tree, TreeList = CreateDatatypes(Tree, TreeList)
>>> Tree.val(Tree.leaf(10))
val(leaf(10))
>>> simplify(Tree.val(Tree.leaf(10)))
10
>>> n1 = Tree.node(TreeList.cons(Tree.leaf(10), TreeList.cons(Tree.leaf(20), TreeList.nil)))
>>> n1
node(cons(leaf(10), cons(leaf(20), nil)))
>>> n2 = Tree.node(TreeList.cons(n1, TreeList.nil))
>>> simplify(n2 == n1)
False
>>> simplify(TreeList.car(Tree.children(n2)) == n1)
True

Definition at line 5656 of file z3py.py.

5656def CreateDatatypes(*ds):
5657 """Create mutually recursive Z3 datatypes using 1 or more Datatype helper objects.
5658
5659 In the following example we define a Tree-List using two mutually recursive datatypes.
5660
5661 >>> TreeList = Datatype('TreeList')
5662 >>> Tree = Datatype('Tree')
5663 >>> # Tree has two constructors: leaf and node
5664 >>> Tree.declare('leaf', ('val', IntSort()))
5665 >>> # a node contains a list of trees
5666 >>> Tree.declare('node', ('children', TreeList))
5667 >>> TreeList.declare('nil')
5668 >>> TreeList.declare('cons', ('car', Tree), ('cdr', TreeList))
5669 >>> Tree, TreeList = CreateDatatypes(Tree, TreeList)
5670 >>> Tree.val(Tree.leaf(10))
5671 val(leaf(10))
5672 >>> simplify(Tree.val(Tree.leaf(10)))
5673 10
5674 >>> n1 = Tree.node(TreeList.cons(Tree.leaf(10), TreeList.cons(Tree.leaf(20), TreeList.nil)))
5675 >>> n1
5676 node(cons(leaf(10), cons(leaf(20), nil)))
5677 >>> n2 = Tree.node(TreeList.cons(n1, TreeList.nil))
5678 >>> simplify(n2 == n1)
5679 False
5680 >>> simplify(TreeList.car(Tree.children(n2)) == n1)
5681 True
5682 """
5683 ds = _get_args(ds)
5684 if z3_debug():
5685 _z3_assert(len(ds) > 0, "At least one Datatype must be specified")
5686 _z3_assert(all([isinstance(d, Datatype) for d in ds]), "Arguments must be Datatypes")
5687 _z3_assert(all([d.ctx == ds[0].ctx for d in ds]), "Context mismatch")
5688 _z3_assert(all([d.constructors != [] for d in ds]), "Non-empty Datatypes expected")
5689 ctx = ds[0].ctx
5690 num = len(ds)
5691 names = (Symbol * num)()
5692 out = (Sort * num)()
5693 clists = (ConstructorList * num)()
5694 to_delete = []
5695 for i in range(num):
5696 d = ds[i]
5697 names[i] = to_symbol(d.name, ctx)
5698 num_cs = len(d.constructors)
5699 cs = (Constructor * num_cs)()
5700 for j in range(num_cs):
5701 c = d.constructors[j]
5702 cname = to_symbol(c[0], ctx)
5703 rname = to_symbol(c[1], ctx)
5704 fs = c[2]
5705 num_fs = len(fs)
5706 fnames = (Symbol * num_fs)()
5707 sorts = (Sort * num_fs)()
5708 refs = (ctypes.c_uint * num_fs)()
5709 for k in range(num_fs):
5710 fname = fs[k][0]
5711 ftype = fs[k][1]
5712 fnames[k] = to_symbol(fname, ctx)
5713 if isinstance(ftype, Datatype):
5714 if z3_debug():
5715 _z3_assert(
5716 ds.count(ftype) == 1,
5717 "One and only one occurrence of each datatype is expected",
5718 )
5719 sorts[k] = None
5720 refs[k] = ds.index(ftype)
5721 else:
5722 if z3_debug():
5723 _z3_assert(is_sort(ftype), "Z3 sort expected")
5724 sorts[k] = ftype.ast
5725 refs[k] = 0
5726 cs[j] = Z3_mk_constructor(ctx.ref(), cname, rname, num_fs, fnames, sorts, refs)
5727 to_delete.append(ScopedConstructor(cs[j], ctx))
5728 clists[i] = Z3_mk_constructor_list(ctx.ref(), num_cs, cs)
5729 to_delete.append(ScopedConstructorList(clists[i], ctx))
5730 Z3_mk_datatypes(ctx.ref(), num, names, out, clists)
5731 result = []
5732 # Create a field for every constructor, recognizer and accessor
5733 for i in range(num):
5734 dref = DatatypeSortRef(out[i], ctx)
5735 num_cs = dref.num_constructors()
5736 for j in range(num_cs):
5737 cref = dref.constructor(j)
5738 cref_name = cref.name()
5739 cref_arity = cref.arity()
5740 if cref.arity() == 0:
5741 cref = cref()
5742 setattr(dref, cref_name, cref)
5743 rref = dref.recognizer(j)
5744 setattr(dref, "is_" + cref_name, rref)
5745 for k in range(cref_arity):
5746 aref = dref.accessor(j, k)
5747 setattr(dref, aref.name(), aref)
5748 result.append(dref)
5749 return tuple(result)
5750
5751
void Z3_API Z3_mk_datatypes(Z3_context c, unsigned num_sorts, Z3_symbol const sort_names[], Z3_sort sorts[], Z3_constructor_list constructor_lists[])
Create mutually recursive datatypes.
Z3_constructor_list Z3_API Z3_mk_constructor_list(Z3_context c, unsigned num_constructors, Z3_constructor const constructors[])
Create list of constructors.
Z3_constructor Z3_API Z3_mk_constructor(Z3_context c, Z3_symbol name, Z3_symbol recognizer, unsigned num_fields, Z3_symbol const field_names[], Z3_sort const sorts[], unsigned sort_refs[])
Create a constructor.

Referenced by Datatype.create().

◆ CreatePolymorphicDatatype()

CreatePolymorphicDatatype (   d,
  type_params 
)
Create a single polymorphic Z3 datatype with explicit type parameters.

`d` is a `Datatype` helper object whose constructors have been declared.
`type_params` is a list of type variables created with `DeclareTypeVar`.
Constructor field sorts may reference these type variables, and self-recursive
fields may reference `d` directly.

>>> A = DeclareTypeVar('A')
>>> Pair = Datatype('Pair')
>>> Pair.declare('pair', ('fst', A), ('snd', A))
>>> Pair = CreatePolymorphicDatatype(Pair, [A])

Definition at line 5752 of file z3py.py.

5752def CreatePolymorphicDatatype(d, type_params):
5753 """Create a single polymorphic Z3 datatype with explicit type parameters.
5754
5755 `d` is a `Datatype` helper object whose constructors have been declared.
5756 `type_params` is a list of type variables created with `DeclareTypeVar`.
5757 Constructor field sorts may reference these type variables, and self-recursive
5758 fields may reference `d` directly.
5759
5760 >>> A = DeclareTypeVar('A')
5761 >>> Pair = Datatype('Pair')
5762 >>> Pair.declare('pair', ('fst', A), ('snd', A))
5763 >>> Pair = CreatePolymorphicDatatype(Pair, [A])
5764 """
5765 if z3_debug():
5766 _z3_assert(isinstance(d, Datatype), "Datatype expected")
5767 _z3_assert(d.constructors != [], "Non-empty Datatype expected")
5768 ctx = d.ctx
5769 name = to_symbol(d.name, ctx)
5770 num_params = len(type_params)
5771 params_arr = (Sort * num_params)()
5772 for i, p in enumerate(type_params):
5773 if z3_debug():
5774 _z3_assert(is_sort(p), "Z3 sort expected for type parameter")
5775 params_arr[i] = p.ast
5776 num_cs = len(d.constructors)
5777 cs = (Constructor * num_cs)()
5778 to_delete = []
5779 for j in range(num_cs):
5780 c = d.constructors[j]
5781 cname = to_symbol(c[0], ctx)
5782 rname = to_symbol(c[1], ctx)
5783 fs = c[2]
5784 num_fs = len(fs)
5785 fnames = (Symbol * num_fs)()
5786 sorts = (Sort * num_fs)()
5787 refs = (ctypes.c_uint * num_fs)()
5788 for k in range(num_fs):
5789 fname = fs[k][0]
5790 ftype = fs[k][1]
5791 fnames[k] = to_symbol(fname, ctx)
5792 if isinstance(ftype, Datatype):
5793 if z3_debug():
5794 _z3_assert(ftype is d, "Only self-recursive references are supported in polymorphic datatypes. Use CreateDatatypes for mutually recursive datatypes.")
5795 sorts[k] = None
5796 refs[k] = 0
5797 else:
5798 if z3_debug():
5799 _z3_assert(is_sort(ftype), "Z3 sort expected")
5800 sorts[k] = ftype.ast
5801 refs[k] = 0
5802 cs[j] = Z3_mk_constructor(ctx.ref(), cname, rname, num_fs, fnames, sorts, refs)
5803 to_delete.append(ScopedConstructor(cs[j], ctx))
5804 out = Z3_mk_polymorphic_datatype(ctx.ref(), name, num_params, params_arr, num_cs, cs)
5805 dref = DatatypeSortRef(out, ctx)
5806 num_cs_actual = dref.num_constructors()
5807 for j in range(num_cs_actual):
5808 cref = dref.constructor(j)
5809 cref_name = cref.name()
5810 cref_arity = cref.arity()
5811 if cref_arity == 0:
5812 cref = cref()
5813 setattr(dref, cref_name, cref)
5814 rref = dref.recognizer(j)
5815 setattr(dref, "is_" + cref_name, rref)
5816 for k in range(cref_arity):
5817 aref = dref.accessor(j, k)
5818 setattr(dref, aref.name(), aref)
5819 return dref
5820
5821
Z3_sort Z3_API Z3_mk_polymorphic_datatype(Z3_context c, Z3_symbol name, unsigned num_parameters, Z3_sort parameters[], unsigned num_constructors, Z3_constructor constructors[])
Create a parametric datatype with explicit type parameters.

Referenced by Datatype.create_polymorphic().

◆ DatatypeSort()

DatatypeSort (   name,
  params = None,
  ctx = None 
)
Create a reference to a sort that was declared, or will be declared, as a recursive datatype.

Args:
    name: name of the datatype sort
    params: optional list/tuple of sort parameters for parametric datatypes
    ctx: Z3 context (optional)

Example:
    >>> # Non-parametric datatype
    >>> TreeRef = DatatypeSort('Tree')
    >>> # Parametric datatype with one parameter
    >>> ListIntRef = DatatypeSort('List', [IntSort()])
    >>> # Parametric datatype with multiple parameters
    >>> PairRef = DatatypeSort('Pair', [IntSort(), BoolSort()])

Definition at line 5952 of file z3py.py.

5952def DatatypeSort(name, params=None, ctx=None):
5953 """Create a reference to a sort that was declared, or will be declared, as a recursive datatype.
5954
5955 Args:
5956 name: name of the datatype sort
5957 params: optional list/tuple of sort parameters for parametric datatypes
5958 ctx: Z3 context (optional)
5959
5960 Example:
5961 >>> # Non-parametric datatype
5962 >>> TreeRef = DatatypeSort('Tree')
5963 >>> # Parametric datatype with one parameter
5964 >>> ListIntRef = DatatypeSort('List', [IntSort()])
5965 >>> # Parametric datatype with multiple parameters
5966 >>> PairRef = DatatypeSort('Pair', [IntSort(), BoolSort()])
5967 """
5968 ctx = _get_ctx(ctx)
5969 if params is None or len(params) == 0:
5970 return DatatypeSortRef(Z3_mk_datatype_sort(ctx.ref(), to_symbol(name, ctx), 0, (Sort * 0)()), ctx)
5971 else:
5972 _params = (Sort * len(params))()
5973 for i in range(len(params)):
5974 _params[i] = params[i].ast
5975 return DatatypeSortRef(Z3_mk_datatype_sort(ctx.ref(), to_symbol(name, ctx), len(params), _params), ctx)
5976
Z3_sort Z3_API Z3_mk_datatype_sort(Z3_context c, Z3_symbol name, unsigned num_params, Z3_sort const params[])
create a forward reference to a recursive datatype being declared. The forward reference can be used ...

◆ DeclareSort()

SortRef DeclareSort (   name,
  ctx = None 
)
Create a new uninterpreted sort named `name`.

If `ctx=None`, then the new sort is declared in the global Z3Py context.

>>> A = DeclareSort('A')
>>> a = Const('a', A)
>>> b = Const('b', A)
>>> a.sort() == A
True
>>> b.sort() == A
True
>>> a == b
a == b

Definition at line 732 of file z3py.py.

732def DeclareSort(name, ctx= None) -> SortRef:
733 """Create a new uninterpreted sort named `name`.
734
735 If `ctx=None`, then the new sort is declared in the global Z3Py context.
736
737 >>> A = DeclareSort('A')
738 >>> a = Const('a', A)
739 >>> b = Const('b', A)
740 >>> a.sort() == A
741 True
742 >>> b.sort() == A
743 True
744 >>> a == b
745 a == b
746 """
747 ctx = _get_ctx(ctx)
748 return SortRef(Z3_mk_uninterpreted_sort(ctx.ref(), to_symbol(name, ctx)), ctx)
749
Z3_sort Z3_API Z3_mk_uninterpreted_sort(Z3_context c, Z3_symbol s)
Create a free (uninterpreted) type using the given name (symbol).

◆ DeclareTypeVar()

DeclareTypeVar (   name,
  ctx = None 
)
Create a new type variable named `name`.

If `ctx=None`, then the new sort is declared in the global Z3Py context.

Definition at line 760 of file z3py.py.

760def DeclareTypeVar(name, ctx=None):
761 """Create a new type variable named `name`.
762
763 If `ctx=None`, then the new sort is declared in the global Z3Py context.
764
765 """
766 ctx = _get_ctx(ctx)
767 return TypeVarRef(Z3_mk_type_variable(ctx.ref(), to_symbol(name, ctx)), ctx)
768
769
Z3_sort Z3_API Z3_mk_type_variable(Z3_context c, Z3_symbol s)
Create a type variable.

◆ Default()

Default (   a)
 Return a default value for array expression.
>>> b = K(IntSort(), 1)
>>> prove(Default(b) == 1)
proved

Definition at line 5016 of file z3py.py.

5016def Default(a):
5017 """ Return a default value for array expression.
5018 >>> b = K(IntSort(), 1)
5019 >>> prove(Default(b) == 1)
5020 proved
5021 """
5022 if z3_debug():
5023 _z3_assert(is_array_sort(a), "First argument must be a Z3 array expression")
5024 return a.default()
5025
5026

◆ describe_probes()

describe_probes ( )
Display a (tabular) description of all available probes in Z3.

Definition at line 9494 of file z3py.py.

9494def describe_probes():
9495 """Display a (tabular) description of all available probes in Z3."""
9496 if in_html_mode():
9497 even = True
9498 print('<table border="1" cellpadding="2" cellspacing="0">')
9499 for p in probes():
9500 if even:
9501 print('<tr style="background-color:#CFCFCF">')
9502 even = False
9503 else:
9504 print("<tr>")
9505 even = True
9506 print("<td>%s</td><td>%s</td></tr>" % (p, insert_line_breaks(probe_description(p), 40)))
9507 print("</table>")
9508 else:
9509 for p in probes():
9510 print("%s : %s" % (p, probe_description(p)))
9511
9512

◆ describe_tactics()

describe_tactics ( )
Display a (tabular) description of all available tactics in Z3.

Definition at line 9288 of file z3py.py.

9288def describe_tactics():
9289 """Display a (tabular) description of all available tactics in Z3."""
9290 if in_html_mode():
9291 even = True
9292 print('<table border="1" cellpadding="2" cellspacing="0">')
9293 for t in tactics():
9294 if even:
9295 print('<tr style="background-color:#CFCFCF">')
9296 even = False
9297 else:
9298 print("<tr>")
9299 even = True
9300 print("<td>%s</td><td>%s</td></tr>" % (t, insert_line_breaks(tactic_description(t), 40)))
9301 print("</table>")
9302 else:
9303 for t in tactics():
9304 print("%s : %s" % (t, tactic_description(t)))
9305
9306

◆ deserialize()

deserialize (   st)
inverse function to the serialize method on ExprRef.
It is made available to make it easier for users to serialize expressions back and forth between
strings. Solvers can be serialized using the 'sexpr()' method.

Definition at line 1209 of file z3py.py.

1209def deserialize(st):
1210 """inverse function to the serialize method on ExprRef.
1211 It is made available to make it easier for users to serialize expressions back and forth between
1212 strings. Solvers can be serialized using the 'sexpr()' method.
1213 """
1214 s = Solver()
1215 s.from_string(st)
1216 if len(s.assertions()) != 1:
1217 raise Z3Exception("single assertion expected")
1218 fml = s.assertions()[0]
1219 if fml.num_args() != 1:
1220 raise Z3Exception("dummy function 'F' expected")
1221 return fml.arg(0)
1222

◆ Diff()

Diff (   a,
  b,
  ctx = None 
)
Create the difference regular expression

Definition at line 12209 of file z3py.py.

12209def Diff(a, b, ctx=None):
12210 """Create the difference regular expression
12211 """
12212 if z3_debug():
12213 _z3_assert(is_expr(a), "expression expected")
12214 _z3_assert(is_expr(b), "expression expected")
12215 return ReRef(Z3_mk_re_diff(a.ctx_ref(), a.ast, b.ast), a.ctx)
12216
Z3_ast Z3_API Z3_mk_re_diff(Z3_context c, Z3_ast re1, Z3_ast re2)
Create the difference of regular expressions.

◆ disable_trace()

disable_trace (   msg)

Definition at line 87 of file z3py.py.

87def disable_trace(msg):
89
90
void Z3_API Z3_disable_trace(Z3_string tag)
Disable tracing messages tagged as tag when Z3 is compiled in debug mode. It is a NOOP otherwise.

◆ DisjointSum()

DisjointSum (   name,
  sorts,
  ctx = None 
)
Create a named tagged union sort base on a set of underlying sorts
Example:
    >>> sum, ((inject0, extract0), (inject1, extract1)) = DisjointSum("+", [IntSort(), StringSort()])

Definition at line 5989 of file z3py.py.

5989def DisjointSum(name, sorts, ctx=None):
5990 """Create a named tagged union sort base on a set of underlying sorts
5991 Example:
5992 >>> sum, ((inject0, extract0), (inject1, extract1)) = DisjointSum("+", [IntSort(), StringSort()])
5993 """
5994 sum = Datatype(name, ctx)
5995 for i in range(len(sorts)):
5996 sum.declare("inject%d" % i, ("project%d" % i, sorts[i]))
5997 sum = sum.create()
5998 return sum, [(sum.constructor(i), sum.accessor(i, 0)) for i in range(len(sorts))]
5999
6000

◆ Distinct()

Distinct ( *  args)
Create a Z3 distinct expression.

>>> x = Int('x')
>>> y = Int('y')
>>> Distinct(x, y)
x != y
>>> z = Int('z')
>>> Distinct(x, y, z)
Distinct(x, y, z)
>>> simplify(Distinct(x, y, z))
Distinct(x, y, z)
>>> simplify(Distinct(x, y, z), blast_distinct=True)
And(Not(x == y), Not(x == z), Not(y == z))

Definition at line 1513 of file z3py.py.

1513def Distinct(*args):
1514 """Create a Z3 distinct expression.
1515
1516 >>> x = Int('x')
1517 >>> y = Int('y')
1518 >>> Distinct(x, y)
1519 x != y
1520 >>> z = Int('z')
1521 >>> Distinct(x, y, z)
1522 Distinct(x, y, z)
1523 >>> simplify(Distinct(x, y, z))
1524 Distinct(x, y, z)
1525 >>> simplify(Distinct(x, y, z), blast_distinct=True)
1526 And(Not(x == y), Not(x == z), Not(y == z))
1527 """
1528 args = _get_args(args)
1529 ctx = _ctx_from_ast_arg_list(args)
1530 if z3_debug():
1531 _z3_assert(ctx is not None, "At least one of the arguments must be a Z3 expression")
1532 args = _coerce_expr_list(args, ctx)
1533 _args, sz = _to_ast_array(args)
1534 return BoolRef(Z3_mk_distinct(ctx.ref(), sz, _args), ctx)
1535
1536
Z3_ast Z3_API Z3_mk_distinct(Z3_context c, unsigned num_args, Z3_ast const args[])
Create an AST node representing distinct(args[0], ..., args[num_args-1]).

◆ Empty()

Empty (   s)
Create the empty sequence of the given sort
>>> e = Empty(StringSort())
>>> e2 = StringVal("")
>>> print(e.eq(e2))
True
>>> e3 = Empty(SeqSort(IntSort()))
>>> print(e3)
Empty(Seq(Int))
>>> e4 = Empty(ReSort(SeqSort(IntSort())))
>>> print(e4)
Empty(ReSort(Seq(Int)))

Definition at line 11808 of file z3py.py.

11808def Empty(s):
11809 """Create the empty sequence of the given sort
11810 >>> e = Empty(StringSort())
11811 >>> e2 = StringVal("")
11812 >>> print(e.eq(e2))
11813 True
11814 >>> e3 = Empty(SeqSort(IntSort()))
11815 >>> print(e3)
11816 Empty(Seq(Int))
11817 >>> e4 = Empty(ReSort(SeqSort(IntSort())))
11818 >>> print(e4)
11819 Empty(ReSort(Seq(Int)))
11820 """
11821 if isinstance(s, SeqSortRef):
11822 return SeqRef(Z3_mk_seq_empty(s.ctx_ref(), s.ast), s.ctx)
11823 if isinstance(s, ReSortRef):
11824 return ReRef(Z3_mk_re_empty(s.ctx_ref(), s.ast), s.ctx)
11825 raise Z3Exception("Non-sequence, non-regular expression sort passed to Empty")
11826
11827
Z3_ast Z3_API Z3_mk_seq_empty(Z3_context c, Z3_sort seq)
Create an empty sequence of the sequence sort seq.
Z3_ast Z3_API Z3_mk_re_empty(Z3_context c, Z3_sort re)
Create an empty regular expression of sort re.

◆ EmptySet()

EmptySet (   s)
Create the empty set
>>> EmptySet(IntSort())
K(Int, False)

Definition at line 5171 of file z3py.py.

5171def EmptySet(s):
5172 """Create the empty set
5173 >>> EmptySet(IntSort())
5174 K(Int, False)
5175 """
5176 ctx = s.ctx
5177 if is_finite_set_sort(s):
5178 return FiniteSetEmpty(s)
5179 return ArrayRef(Z3_mk_empty_set(ctx.ref(), s.ast), ctx)
5180
5181
Z3_ast Z3_API Z3_mk_empty_set(Z3_context c, Z3_sort domain)
Create the empty set.

◆ enable_trace()

enable_trace (   msg)

Definition at line 83 of file z3py.py.

83def enable_trace(msg):
85
86
void Z3_API Z3_enable_trace(Z3_string tag)
Enable tracing messages tagged as tag when Z3 is compiled in debug mode. It is a NOOP otherwise.

◆ ensure_prop_closures()

ensure_prop_closures ( )

Definition at line 12328 of file z3py.py.

12328def ensure_prop_closures():
12329 global _prop_closures
12330 if _prop_closures is None:
12331 _prop_closures = PropClosures()
12332
12333

◆ EnumSort()

EnumSort (   name,
  values,
  ctx = None 
)
Return a new enumeration sort named `name` containing the given values.

The result is a pair (sort, list of constants).
Example:
    >>> Color, (red, green, blue) = EnumSort('Color', ['red', 'green', 'blue'])

Definition at line 6001 of file z3py.py.

6001def EnumSort(name, values, ctx=None):
6002 """Return a new enumeration sort named `name` containing the given values.
6003
6004 The result is a pair (sort, list of constants).
6005 Example:
6006 >>> Color, (red, green, blue) = EnumSort('Color', ['red', 'green', 'blue'])
6007 """
6008 if z3_debug():
6009 _z3_assert(isinstance(name, str), "Name must be a string")
6010 _z3_assert(all([isinstance(v, str) for v in values]), "Enumeration sort values must be strings")
6011 _z3_assert(len(values) > 0, "At least one value expected")
6012 ctx = _get_ctx(ctx)
6013 num = len(values)
6014 _val_names = (Symbol * num)()
6015 for i in range(num):
6016 _val_names[i] = to_symbol(values[i], ctx)
6017 _values = (FuncDecl * num)()
6018 _testers = (FuncDecl * num)()
6019 name = to_symbol(name, ctx)
6020 S = DatatypeSortRef(Z3_mk_enumeration_sort(ctx.ref(), name, num, _val_names, _values, _testers), ctx)
6021 V = []
6022 for i in range(num):
6023 V.append(FuncDeclRef(_values[i], ctx))
6024 V = [a() for a in V]
6025 return S, V
6026
Z3_sort Z3_API Z3_mk_enumeration_sort(Z3_context c, Z3_symbol name, unsigned n, Z3_symbol const enum_names[], Z3_func_decl enum_consts[], Z3_func_decl enum_testers[])
Create a enumeration sort.

◆ eq()

bool eq ( AstRef  a,
AstRef  b 
)
Return `True` if `a` and `b` are structurally identical AST nodes.

>>> x = Int('x')
>>> y = Int('y')
>>> eq(x, y)
False
>>> eq(x + 1, x + 1)
True
>>> eq(x + 1, 1 + x)
False
>>> eq(simplify(x + 1), simplify(1 + x))
True

Definition at line 503 of file z3py.py.

503def eq(a : AstRef, b : AstRef) -> bool:
504 """Return `True` if `a` and `b` are structurally identical AST nodes.
505
506 >>> x = Int('x')
507 >>> y = Int('y')
508 >>> eq(x, y)
509 False
510 >>> eq(x + 1, x + 1)
511 True
512 >>> eq(x + 1, 1 + x)
513 False
514 >>> eq(simplify(x + 1), simplify(1 + x))
515 True
516 """
517 if z3_debug():
518 _z3_assert(is_ast(a) and is_ast(b), "Z3 ASTs expected")
519 return a.eq(b)
520
521

◆ Exists()

Exists (   vs,
  body,
  weight = 1,
  qid = "",
  skid = "",
  patterns = [],
  no_patterns = [] 
)
Create a Z3 exists formula.

The parameters `weight`, `qif`, `skid`, `patterns` and `no_patterns` are optional annotations.


>>> f = Function('f', IntSort(), IntSort(), IntSort())
>>> x = Int('x')
>>> y = Int('y')
>>> q = Exists([x, y], f(x, y) >= x, skid="foo")
>>> q
Exists([x, y], f(x, y) >= x)
>>> is_quantifier(q)
True
>>> r = Tactic('nnf')(q).as_expr()
>>> is_quantifier(r)
False

Definition at line 2389 of file z3py.py.

2389def Exists(vs, body, weight=1, qid="", skid="", patterns=[], no_patterns=[]):
2390 """Create a Z3 exists formula.
2391
2392 The parameters `weight`, `qif`, `skid`, `patterns` and `no_patterns` are optional annotations.
2393
2394
2395 >>> f = Function('f', IntSort(), IntSort(), IntSort())
2396 >>> x = Int('x')
2397 >>> y = Int('y')
2398 >>> q = Exists([x, y], f(x, y) >= x, skid="foo")
2399 >>> q
2400 Exists([x, y], f(x, y) >= x)
2401 >>> is_quantifier(q)
2402 True
2403 >>> r = Tactic('nnf')(q).as_expr()
2404 >>> is_quantifier(r)
2405 False
2406 """
2407 return _mk_quantifier(False, vs, body, weight, qid, skid, patterns, no_patterns)
2408
2409

◆ Ext()

Ext (   a,
  b 
)
Return extensionality index for one-dimensional arrays.
>> a, b = Consts('a b', SetSort(IntSort()))
>> Ext(a, b)
Ext(a, b)

Definition at line 5105 of file z3py.py.

5105def Ext(a, b):
5106 """Return extensionality index for one-dimensional arrays.
5107 >> a, b = Consts('a b', SetSort(IntSort()))
5108 >> Ext(a, b)
5109 Ext(a, b)
5110 """
5111 ctx = a.ctx
5112 if z3_debug():
5113 _z3_assert(is_array_sort(a) and (is_array(b) or b.is_lambda()), "arguments must be arrays")
5114 return _to_expr_ref(Z3_mk_array_ext(ctx.ref(), a.as_ast(), b.as_ast()), ctx)
5115
5116
Z3_ast Z3_API Z3_mk_array_ext(Z3_context c, Z3_ast arg1, Z3_ast arg2)
Create array extensionality index given two arrays with the same sort. The meaning is given by the ax...

◆ Extract()

Extract (   high,
  low,
  a 
)
Create a Z3 bit-vector extraction expression or sequence extraction expression.

Extract is overloaded to work with both bit-vectors and sequences:

**Bit-vector extraction**: Extract(high, low, bitvector)
    Extracts bits from position `high` down to position `low` (both inclusive).
    - high: int - the highest bit position to extract (0-indexed from right)
    - low: int - the lowest bit position to extract (0-indexed from right)  
    - bitvector: BitVecRef - the bit-vector to extract from
    Returns a new bit-vector containing bits [high:low]

**Sequence extraction**: Extract(sequence, offset, length)
    Extracts a subsequence starting at the given offset with the specified length.
    The functions SubString and SubSeq are redirected to this form of Extract.
    - sequence: SeqRef or str - the sequence to extract from
    - offset: int - the starting position (0-indexed)
    - length: int - the number of elements to extract
    Returns a new sequence containing the extracted subsequence

>>> # Bit-vector extraction examples
>>> x = BitVec('x', 8)
>>> Extract(6, 2, x)  # Extract bits 6 down to 2 (5 bits total)
Extract(6, 2, x)
>>> Extract(6, 2, x).sort()  # Result is a 5-bit vector
BitVec(5)
>>> Extract(7, 0, x)  # Extract all 8 bits
Extract(7, 0, x)
>>> Extract(3, 3, x)  # Extract single bit at position 3
Extract(3, 3, x)

>>> # Sequence extraction examples  
>>> s = StringVal("hello")
>>> Extract(s, 1, 3)  # Extract 3 characters starting at position 1
str.substr("hello", 1, 3)
>>> simplify(Extract(StringVal("abcd"), 2, 1))  # Extract 1 character at position 2
"c"
>>> simplify(Extract(StringVal("abcd"), 0, 2))  # Extract first 2 characters  
"ab"

Definition at line 4301 of file z3py.py.

4301def Extract(high, low, a):
4302 """Create a Z3 bit-vector extraction expression or sequence extraction expression.
4303
4304 Extract is overloaded to work with both bit-vectors and sequences:
4305
4306 **Bit-vector extraction**: Extract(high, low, bitvector)
4307 Extracts bits from position `high` down to position `low` (both inclusive).
4308 - high: int - the highest bit position to extract (0-indexed from right)
4309 - low: int - the lowest bit position to extract (0-indexed from right)
4310 - bitvector: BitVecRef - the bit-vector to extract from
4311 Returns a new bit-vector containing bits [high:low]
4312
4313 **Sequence extraction**: Extract(sequence, offset, length)
4314 Extracts a subsequence starting at the given offset with the specified length.
4315 The functions SubString and SubSeq are redirected to this form of Extract.
4316 - sequence: SeqRef or str - the sequence to extract from
4317 - offset: int - the starting position (0-indexed)
4318 - length: int - the number of elements to extract
4319 Returns a new sequence containing the extracted subsequence
4320
4321 >>> # Bit-vector extraction examples
4322 >>> x = BitVec('x', 8)
4323 >>> Extract(6, 2, x) # Extract bits 6 down to 2 (5 bits total)
4324 Extract(6, 2, x)
4325 >>> Extract(6, 2, x).sort() # Result is a 5-bit vector
4326 BitVec(5)
4327 >>> Extract(7, 0, x) # Extract all 8 bits
4328 Extract(7, 0, x)
4329 >>> Extract(3, 3, x) # Extract single bit at position 3
4330 Extract(3, 3, x)
4331
4332 >>> # Sequence extraction examples
4333 >>> s = StringVal("hello")
4334 >>> Extract(s, 1, 3) # Extract 3 characters starting at position 1
4335 str.substr("hello", 1, 3)
4336 >>> simplify(Extract(StringVal("abcd"), 2, 1)) # Extract 1 character at position 2
4337 "c"
4338 >>> simplify(Extract(StringVal("abcd"), 0, 2)) # Extract first 2 characters
4339 "ab"
4340 """
4341 if isinstance(high, str):
4342 high = StringVal(high)
4343 if is_seq(high):
4344 s = high
4345 offset, length = _coerce_exprs(low, a, s.ctx)
4346 return SeqRef(Z3_mk_seq_extract(s.ctx_ref(), s.as_ast(), offset.as_ast(), length.as_ast()), s.ctx)
4347 if z3_debug():
4348 _z3_assert(low <= high, "First argument must be greater than or equal to second argument")
4349 _z3_assert(_is_int(high) and high >= 0 and _is_int(low) and low >= 0,
4350 "First and second arguments must be non negative integers")
4351 _z3_assert(is_bv(a), "Third argument must be a Z3 bit-vector expression")
4352 return BitVecRef(Z3_mk_extract(a.ctx_ref(), high, low, a.as_ast()), a.ctx)
4353
4354
Z3_ast Z3_API Z3_mk_extract(Z3_context c, unsigned high, unsigned low, Z3_ast t1)
Extract the bits high down to low from a bit-vector of size m to yield a new bit-vector of size n,...
Z3_ast Z3_API Z3_mk_seq_extract(Z3_context c, Z3_ast s, Z3_ast offset, Z3_ast length)
Extract subsequence starting at offset of length.

◆ FailIf()

FailIf (   p,
  ctx = None 
)
Return a tactic that fails if the probe `p` evaluates to true.
Otherwise, it returns the input goal unmodified.

In the following example, the tactic applies 'simplify' if and only if there are
more than 2 constraints in the goal.

>>> t = OrElse(FailIf(Probe('size') > 2), Tactic('simplify'))
>>> x, y = Ints('x y')
>>> g = Goal()
>>> g.add(x > 0)
>>> g.add(y > 0)
>>> t(g)
[[x > 0, y > 0]]
>>> g.add(x == y + 1)
>>> t(g)
[[Not(x <= 0), Not(y <= 0), x == 1 + y]]

Definition at line 9531 of file z3py.py.

9531def FailIf(p, ctx=None):
9532 """Return a tactic that fails if the probe `p` evaluates to true.
9533 Otherwise, it returns the input goal unmodified.
9534
9535 In the following example, the tactic applies 'simplify' if and only if there are
9536 more than 2 constraints in the goal.
9537
9538 >>> t = OrElse(FailIf(Probe('size') > 2), Tactic('simplify'))
9539 >>> x, y = Ints('x y')
9540 >>> g = Goal()
9541 >>> g.add(x > 0)
9542 >>> g.add(y > 0)
9543 >>> t(g)
9544 [[x > 0, y > 0]]
9545 >>> g.add(x == y + 1)
9546 >>> t(g)
9547 [[Not(x <= 0), Not(y <= 0), x == 1 + y]]
9548 """
9549 p = _to_probe(p, ctx)
9550 return Tactic(Z3_tactic_fail_if(p.ctx.ref(), p.probe), p.ctx)
9551
9552
Z3_tactic Z3_API Z3_tactic_fail_if(Z3_context c, Z3_probe p)
Return a tactic that fails if the probe p evaluates to false.

◆ FiniteDomainSort()

FiniteDomainSort (   name,
  sz,
  ctx = None 
)
Create a named finite domain sort of a given size sz

Definition at line 8429 of file z3py.py.

8429def FiniteDomainSort(name, sz, ctx=None):
8430 """Create a named finite domain sort of a given size sz"""
8431 if not isinstance(name, Symbol):
8432 name = to_symbol(name)
8433 ctx = _get_ctx(ctx)
8434 return FiniteDomainSortRef(Z3_mk_finite_domain_sort(ctx.ref(), name, sz), ctx)
8435
8436
Z3_sort Z3_API Z3_mk_finite_domain_sort(Z3_context c, Z3_symbol name, uint64_t size)
Create a named finite domain sort.

◆ FiniteDomainVal()

FiniteDomainVal (   val,
  sort,
  ctx = None 
)
Return a Z3 finite-domain value. If `ctx=None`, then the global context is used.

>>> s = FiniteDomainSort('S', 256)
>>> FiniteDomainVal(255, s)
255
>>> FiniteDomainVal('100', s)
100

Definition at line 8499 of file z3py.py.

8499def FiniteDomainVal(val, sort, ctx=None):
8500 """Return a Z3 finite-domain value. If `ctx=None`, then the global context is used.
8501
8502 >>> s = FiniteDomainSort('S', 256)
8503 >>> FiniteDomainVal(255, s)
8504 255
8505 >>> FiniteDomainVal('100', s)
8506 100
8507 """
8508 if z3_debug():
8509 _z3_assert(is_finite_domain_sort(sort), "Expected finite-domain sort")
8510 ctx = sort.ctx
8511 return FiniteDomainNumRef(Z3_mk_numeral(ctx.ref(), _to_int_str(val), sort.ast), ctx)
8512
8513

◆ FiniteSetDifference()

FiniteSetDifference (   s1,
  s2 
)
Create the set difference of two finite sets.
>>> a = Const('a', FiniteSetSort(IntSort()))
>>> b = Const('b', FiniteSetSort(IntSort()))
>>> FiniteSetDifference(a, b)
set.difference(a, b)

Definition at line 5436 of file z3py.py.

5436def FiniteSetDifference(s1, s2):
5437 """Create the set difference of two finite sets.
5438 >>> a = Const('a', FiniteSetSort(IntSort()))
5439 >>> b = Const('b', FiniteSetSort(IntSort()))
5440 >>> FiniteSetDifference(a, b)
5441 set.difference(a, b)
5442 """
5443 ctx = _ctx_from_ast_arg_list([s1, s2])
5444 return FiniteSetRef(Z3_mk_finite_set_difference(ctx.ref(), s1.as_ast(), s2.as_ast()), ctx)
5445
5446
Z3_ast Z3_API Z3_mk_finite_set_difference(Z3_context c, Z3_ast s1, Z3_ast s2)
Create the set difference of two finite sets.

Referenced by FiniteSetRef.__sub__(), and SetDifference().

◆ FiniteSetEmpty()

FiniteSetEmpty (   set_sort)
Create an empty finite set of the given sort.
>>> s = FiniteSetSort(IntSort())
>>> FiniteSetEmpty(s)
set.empty

Definition at line 5395 of file z3py.py.

5395def FiniteSetEmpty(set_sort):
5396 """Create an empty finite set of the given sort.
5397 >>> s = FiniteSetSort(IntSort())
5398 >>> FiniteSetEmpty(s)
5399 set.empty
5400 """
5401 ctx = set_sort.ctx
5402 return FiniteSetRef(Z3_mk_finite_set_empty(ctx.ref(), set_sort.ast), ctx)
5403
5404
Z3_ast Z3_API Z3_mk_finite_set_empty(Z3_context c, Z3_sort set_sort)
Create an empty finite set of the given sort.

Referenced by FiniteSetSortRef.cast(), and EmptySet().

◆ FiniteSetFilter()

FiniteSetFilter (   f,
  set 
)
Filter a finite set using predicate f.
>>> f = Array('f', IntSort(), BoolSort())
>>> a = Const('a', FiniteSetSort(IntSort()))
>>> FiniteSetFilter(f, a)
set.filter(f, a)

Definition at line 5493 of file z3py.py.

5493def FiniteSetFilter(f, set):
5494 """Filter a finite set using predicate f.
5495 >>> f = Array('f', IntSort(), BoolSort())
5496 >>> a = Const('a', FiniteSetSort(IntSort()))
5497 >>> FiniteSetFilter(f, a)
5498 set.filter(f, a)
5499 """
5500 if isinstance(f, FuncDeclRef):
5501 f = AsArray(f)
5502 ctx = _ctx_from_ast_arg_list([f, set])
5503 return FiniteSetRef(Z3_mk_finite_set_filter(ctx.ref(), f.as_ast(), set.as_ast()), ctx)
5504
5505
Z3_ast Z3_API Z3_mk_finite_set_filter(Z3_context c, Z3_ast f, Z3_ast set)
Filter a finite set using a predicate.

◆ FiniteSetIntersect()

FiniteSetIntersect (   s1,
  s2 
)
Create the intersection of two finite sets.
>>> a = Const('a', FiniteSetSort(IntSort()))
>>> b = Const('b', FiniteSetSort(IntSort()))
>>> FiniteSetIntersect(a, b)
set.intersect(a, b)

Definition at line 5425 of file z3py.py.

5425def FiniteSetIntersect(s1, s2):
5426 """Create the intersection of two finite sets.
5427 >>> a = Const('a', FiniteSetSort(IntSort()))
5428 >>> b = Const('b', FiniteSetSort(IntSort()))
5429 >>> FiniteSetIntersect(a, b)
5430 set.intersect(a, b)
5431 """
5432 ctx = _ctx_from_ast_arg_list([s1, s2])
5433 return FiniteSetRef(Z3_mk_finite_set_intersect(ctx.ref(), s1.as_ast(), s2.as_ast()), ctx)
5434
5435
Z3_ast Z3_API Z3_mk_finite_set_intersect(Z3_context c, Z3_ast s1, Z3_ast s2)
Create the intersection of two finite sets.

Referenced by FiniteSetRef.__and__().

◆ FiniteSetMap()

FiniteSetMap (   f,
  set 
)
Apply function f to all elements of the finite set.
>>> f = Array('f', IntSort(), IntSort())
>>> a = Const('a', FiniteSetSort(IntSort()))
>>> FiniteSetMap(f, a)
set.map(f, a)

Definition at line 5480 of file z3py.py.

5480def FiniteSetMap(f, set):
5481 """Apply function f to all elements of the finite set.
5482 >>> f = Array('f', IntSort(), IntSort())
5483 >>> a = Const('a', FiniteSetSort(IntSort()))
5484 >>> FiniteSetMap(f, a)
5485 set.map(f, a)
5486 """
5487 if isinstance(f, FuncDeclRef):
5488 f = AsArray(f)
5489 ctx = _ctx_from_ast_arg_list([f, set])
5490 return FiniteSetRef(Z3_mk_finite_set_map(ctx.ref(), f.as_ast(), set.as_ast()), ctx)
5491
5492
Z3_ast Z3_API Z3_mk_finite_set_map(Z3_context c, Z3_ast f, Z3_ast set)
Apply a function to all elements of a finite set.

◆ FiniteSetMember()

FiniteSetMember (   elem,
  set 
)
Check if elem is a member of the finite set.
>>> a = Const('a', FiniteSetSort(IntSort()))
>>> FiniteSetMember(IntVal(1), a)
set.in(1, a)

Definition at line 5447 of file z3py.py.

5447def FiniteSetMember(elem, set):
5448 """Check if elem is a member of the finite set.
5449 >>> a = Const('a', FiniteSetSort(IntSort()))
5450 >>> FiniteSetMember(IntVal(1), a)
5451 set.in(1, a)
5452 """
5453 ctx = _ctx_from_ast_arg_list([elem, set])
5454 return BoolRef(Z3_mk_finite_set_member(ctx.ref(), elem.as_ast(), set.as_ast()), ctx)
5455
Z3_ast Z3_API Z3_mk_finite_set_member(Z3_context c, Z3_ast elem, Z3_ast set)
Check if an element is a member of a finite set.

Referenced by In().

◆ FiniteSetRange()

FiniteSetRange (   low,
  high 
)
Create a finite set of integers in the range [low, high).
>>> FiniteSetRange(IntVal(0), IntVal(5))
set.range(0, 5)

Definition at line 5506 of file z3py.py.

5506def FiniteSetRange(low, high):
5507 """Create a finite set of integers in the range [low, high).
5508 >>> FiniteSetRange(IntVal(0), IntVal(5))
5509 set.range(0, 5)
5510 """
5511 ctx = _ctx_from_ast_arg_list([low, high])
5512 return FiniteSetRef(Z3_mk_finite_set_range(ctx.ref(), low.as_ast(), high.as_ast()), ctx)
5513
5514
Z3_ast Z3_API Z3_mk_finite_set_range(Z3_context c, Z3_ast low, Z3_ast high)
Create a finite set of integers in the range [low, high].

◆ FiniteSetSize()

FiniteSetSize (   set)
Get the size (cardinality) of a finite set.
>>> a = Const('a', FiniteSetSort(IntSort()))
>>> FiniteSetSize(a)
set.size(a)

Definition at line 5459 of file z3py.py.

5459def FiniteSetSize(set):
5460 """Get the size (cardinality) of a finite set.
5461 >>> a = Const('a', FiniteSetSort(IntSort()))
5462 >>> FiniteSetSize(a)
5463 set.size(a)
5464 """
5465 ctx = set.ctx
5466 return ArithRef(Z3_mk_finite_set_size(ctx.ref(), set.as_ast()), ctx)
5467
5468
Z3_ast Z3_API Z3_mk_finite_set_size(Z3_context c, Z3_ast set)
Get the size (cardinality) of a finite set.

◆ FiniteSetSort()

FiniteSetSort (   elem_sort)
Create a finite set sort over element sort elem_sort.
>>> s = FiniteSetSort(IntSort())
>>> s
FiniteSet(Int)

Definition at line 5386 of file z3py.py.

5386def FiniteSetSort(elem_sort):
5387 """Create a finite set sort over element sort elem_sort.
5388 >>> s = FiniteSetSort(IntSort())
5389 >>> s
5390 FiniteSet(Int)
5391 """
5392 return FiniteSetSortRef(Z3_mk_finite_set_sort(elem_sort.ctx_ref(), elem_sort.ast), elem_sort.ctx)
5393
5394
Z3_sort Z3_API Z3_mk_finite_set_sort(Z3_context c, Z3_sort elem_sort)
Create a finite set sort.

◆ FiniteSetSubset()

FiniteSetSubset (   s1,
  s2 
)
Check if s1 is a subset of s2.
>>> a = Const('a', FiniteSetSort(IntSort()))
>>> b = Const('b', FiniteSetSort(IntSort()))
>>> FiniteSetSubset(a, b)
set.subset(a, b)

Definition at line 5469 of file z3py.py.

5469def FiniteSetSubset(s1, s2):
5470 """Check if s1 is a subset of s2.
5471 >>> a = Const('a', FiniteSetSort(IntSort()))
5472 >>> b = Const('b', FiniteSetSort(IntSort()))
5473 >>> FiniteSetSubset(a, b)
5474 set.subset(a, b)
5475 """
5476 ctx = _ctx_from_ast_arg_list([s1, s2])
5477 return BoolRef(Z3_mk_finite_set_subset(ctx.ref(), s1.as_ast(), s2.as_ast()), ctx)
5478
5479
Z3_ast Z3_API Z3_mk_finite_set_subset(Z3_context c, Z3_ast s1, Z3_ast s2)
Check if one finite set is a subset of another.

◆ FiniteSetUnion()

FiniteSetUnion (   s1,
  s2 
)
Create the union of two finite sets.
>>> a = Const('a', FiniteSetSort(IntSort()))
>>> b = Const('b', FiniteSetSort(IntSort()))
>>> FiniteSetUnion(a, b)
set.union(a, b)

Definition at line 5414 of file z3py.py.

5414def FiniteSetUnion(s1, s2):
5415 """Create the union of two finite sets.
5416 >>> a = Const('a', FiniteSetSort(IntSort()))
5417 >>> b = Const('b', FiniteSetSort(IntSort()))
5418 >>> FiniteSetUnion(a, b)
5419 set.union(a, b)
5420 """
5421 ctx = _ctx_from_ast_arg_list([s1, s2])
5422 return FiniteSetRef(Z3_mk_finite_set_union(ctx.ref(), s1.as_ast(), s2.as_ast()), ctx)
5423
5424
Z3_ast Z3_API Z3_mk_finite_set_union(Z3_context c, Z3_ast s1, Z3_ast s2)
Create the union of two finite sets.

Referenced by FiniteSetRef.__or__(), and FiniteSetSortRef.cast().

◆ Float128()

Float128 (   ctx = None)
Floating-point 128-bit (quadruple) sort.

Definition at line 10259 of file z3py.py.

10259def Float128(ctx=None):
10260 """Floating-point 128-bit (quadruple) sort."""
10261 ctx = _get_ctx(ctx)
10262 return FPSortRef(Z3_mk_fpa_sort_128(ctx.ref()), ctx)
10263
10264
Z3_sort Z3_API Z3_mk_fpa_sort_128(Z3_context c)
Create the quadruple-precision (128-bit) FloatingPoint sort.

◆ Float16()

Float16 (   ctx = None)
Floating-point 16-bit (half) sort.

Definition at line 10223 of file z3py.py.

10223def Float16(ctx=None):
10224 """Floating-point 16-bit (half) sort."""
10225 ctx = _get_ctx(ctx)
10226 return FPSortRef(Z3_mk_fpa_sort_16(ctx.ref()), ctx)
10227
10228
Z3_sort Z3_API Z3_mk_fpa_sort_16(Z3_context c)
Create the half-precision (16-bit) FloatingPoint sort.

◆ Float32()

Float32 (   ctx = None)
Floating-point 32-bit (single) sort.

Definition at line 10235 of file z3py.py.

10235def Float32(ctx=None):
10236 """Floating-point 32-bit (single) sort."""
10237 ctx = _get_ctx(ctx)
10238 return FPSortRef(Z3_mk_fpa_sort_32(ctx.ref()), ctx)
10239
10240
Z3_sort Z3_API Z3_mk_fpa_sort_32(Z3_context c)
Create the single-precision (32-bit) FloatingPoint sort.

◆ Float64()

Float64 (   ctx = None)
Floating-point 64-bit (double) sort.

Definition at line 10247 of file z3py.py.

10247def Float64(ctx=None):
10248 """Floating-point 64-bit (double) sort."""
10249 ctx = _get_ctx(ctx)
10250 return FPSortRef(Z3_mk_fpa_sort_64(ctx.ref()), ctx)
10251
10252
Z3_sort Z3_API Z3_mk_fpa_sort_64(Z3_context c)
Create the double-precision (64-bit) FloatingPoint sort.

◆ FloatDouble()

FloatDouble (   ctx = None)
Floating-point 64-bit (double) sort.

Definition at line 10253 of file z3py.py.

10253def FloatDouble(ctx=None):
10254 """Floating-point 64-bit (double) sort."""
10255 ctx = _get_ctx(ctx)
10256 return FPSortRef(Z3_mk_fpa_sort_double(ctx.ref()), ctx)
10257
10258
Z3_sort Z3_API Z3_mk_fpa_sort_double(Z3_context c)
Create the double-precision (64-bit) FloatingPoint sort.

◆ FloatHalf()

FloatHalf (   ctx = None)
Floating-point 16-bit (half) sort.

Definition at line 10229 of file z3py.py.

10229def FloatHalf(ctx=None):
10230 """Floating-point 16-bit (half) sort."""
10231 ctx = _get_ctx(ctx)
10232 return FPSortRef(Z3_mk_fpa_sort_half(ctx.ref()), ctx)
10233
10234
Z3_sort Z3_API Z3_mk_fpa_sort_half(Z3_context c)
Create the half-precision (16-bit) FloatingPoint sort.

◆ FloatQuadruple()

FloatQuadruple (   ctx = None)
Floating-point 128-bit (quadruple) sort.

Definition at line 10265 of file z3py.py.

10265def FloatQuadruple(ctx=None):
10266 """Floating-point 128-bit (quadruple) sort."""
10267 ctx = _get_ctx(ctx)
10268 return FPSortRef(Z3_mk_fpa_sort_quadruple(ctx.ref()), ctx)
10269
10270
Z3_sort Z3_API Z3_mk_fpa_sort_quadruple(Z3_context c)
Create the quadruple-precision (128-bit) FloatingPoint sort.

◆ FloatSingle()

FloatSingle (   ctx = None)
Floating-point 32-bit (single) sort.

Definition at line 10241 of file z3py.py.

10241def FloatSingle(ctx=None):
10242 """Floating-point 32-bit (single) sort."""
10243 ctx = _get_ctx(ctx)
10244 return FPSortRef(Z3_mk_fpa_sort_single(ctx.ref()), ctx)
10245
10246
Z3_sort Z3_API Z3_mk_fpa_sort_single(Z3_context c)
Create the single-precision (32-bit) FloatingPoint sort.

◆ ForAll()

ForAll (   vs,
  body,
  weight = 1,
  qid = "",
  skid = "",
  patterns = [],
  no_patterns = [] 
)
Create a Z3 forall formula.

The parameters `weight`, `qid`, `skid`, `patterns` and `no_patterns` are optional annotations.

>>> f = Function('f', IntSort(), IntSort(), IntSort())
>>> x = Int('x')
>>> y = Int('y')
>>> ForAll([x, y], f(x, y) >= x)
ForAll([x, y], f(x, y) >= x)
>>> ForAll([x, y], f(x, y) >= x, patterns=[ f(x, y) ])
ForAll([x, y], f(x, y) >= x)
>>> ForAll([x, y], f(x, y) >= x, weight=10)
ForAll([x, y], f(x, y) >= x)

Definition at line 2371 of file z3py.py.

2371def ForAll(vs, body, weight=1, qid="", skid="", patterns=[], no_patterns=[]):
2372 """Create a Z3 forall formula.
2373
2374 The parameters `weight`, `qid`, `skid`, `patterns` and `no_patterns` are optional annotations.
2375
2376 >>> f = Function('f', IntSort(), IntSort(), IntSort())
2377 >>> x = Int('x')
2378 >>> y = Int('y')
2379 >>> ForAll([x, y], f(x, y) >= x)
2380 ForAll([x, y], f(x, y) >= x)
2381 >>> ForAll([x, y], f(x, y) >= x, patterns=[ f(x, y) ])
2382 ForAll([x, y], f(x, y) >= x)
2383 >>> ForAll([x, y], f(x, y) >= x, weight=10)
2384 ForAll([x, y], f(x, y) >= x)
2385 """
2386 return _mk_quantifier(True, vs, body, weight, qid, skid, patterns, no_patterns)
2387
2388

◆ FP()

FP (   name,
  fpsort,
  ctx = None 
)
Return a floating-point constant named `name`.
`fpsort` is the floating-point sort.
If `ctx=None`, then the global context is used.

>>> x  = FP('x', FPSort(8, 24))
>>> is_fp(x)
True
>>> x.ebits()
8
>>> x.sort()
FPSort(8, 24)
>>> word = FPSort(8, 24)
>>> x2 = FP('x', word)
>>> eq(x, x2)
True

Definition at line 10901 of file z3py.py.

10901def FP(name, fpsort, ctx=None):
10902 """Return a floating-point constant named `name`.
10903 `fpsort` is the floating-point sort.
10904 If `ctx=None`, then the global context is used.
10905
10906 >>> x = FP('x', FPSort(8, 24))
10907 >>> is_fp(x)
10908 True
10909 >>> x.ebits()
10910 8
10911 >>> x.sort()
10912 FPSort(8, 24)
10913 >>> word = FPSort(8, 24)
10914 >>> x2 = FP('x', word)
10915 >>> eq(x, x2)
10916 True
10917 """
10918 if isinstance(fpsort, FPSortRef) and ctx is None:
10919 ctx = fpsort.ctx
10920 else:
10921 ctx = _get_ctx(ctx)
10922 return FPRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), fpsort.ast), ctx)
10923
10924

◆ fpAbs()

fpAbs (   a,
  ctx = None 
)
Create a Z3 floating-point absolute value expression.

>>> s = FPSort(8, 24)
>>> rm = RNE()
>>> x = FPVal(1.0, s)
>>> fpAbs(x)
fpAbs(1)
>>> y = FPVal(-20.0, s)
>>> y
-1.25*(2**4)
>>> fpAbs(y)
fpAbs(-1.25*(2**4))
>>> fpAbs(-1.25*(2**4))
fpAbs(-1.25*(2**4))
>>> fpAbs(x).sort()
FPSort(8, 24)

Definition at line 10944 of file z3py.py.

10944def fpAbs(a, ctx=None):
10945 """Create a Z3 floating-point absolute value expression.
10946
10947 >>> s = FPSort(8, 24)
10948 >>> rm = RNE()
10949 >>> x = FPVal(1.0, s)
10950 >>> fpAbs(x)
10951 fpAbs(1)
10952 >>> y = FPVal(-20.0, s)
10953 >>> y
10954 -1.25*(2**4)
10955 >>> fpAbs(y)
10956 fpAbs(-1.25*(2**4))
10957 >>> fpAbs(-1.25*(2**4))
10958 fpAbs(-1.25*(2**4))
10959 >>> fpAbs(x).sort()
10960 FPSort(8, 24)
10961 """
10962 ctx = _get_ctx(ctx)
10963 [a] = _coerce_fp_expr_list([a], ctx)
10964 return FPRef(Z3_mk_fpa_abs(ctx.ref(), a.as_ast()), ctx)
10965
10966
Z3_ast Z3_API Z3_mk_fpa_abs(Z3_context c, Z3_ast t)
Floating-point absolute value.

◆ fpAdd()

fpAdd (   rm,
  a,
  b,
  ctx = None 
)
Create a Z3 floating-point addition expression.

>>> s = FPSort(8, 24)
>>> rm = RNE()
>>> x = FP('x', s)
>>> y = FP('y', s)
>>> fpAdd(rm, x, y)
x + y
>>> fpAdd(RTZ(), x, y) # default rounding mode is RTZ
fpAdd(RTZ(), x, y)
>>> fpAdd(rm, x, y).sort()
FPSort(8, 24)

Definition at line 11035 of file z3py.py.

11035def fpAdd(rm, a, b, ctx=None):
11036 """Create a Z3 floating-point addition expression.
11037
11038 >>> s = FPSort(8, 24)
11039 >>> rm = RNE()
11040 >>> x = FP('x', s)
11041 >>> y = FP('y', s)
11042 >>> fpAdd(rm, x, y)
11043 x + y
11044 >>> fpAdd(RTZ(), x, y) # default rounding mode is RTZ
11045 fpAdd(RTZ(), x, y)
11046 >>> fpAdd(rm, x, y).sort()
11047 FPSort(8, 24)
11048 """
11049 return _mk_fp_bin(Z3_mk_fpa_add, rm, a, b, ctx)
11050
11051

◆ fpBVToFP()

fpBVToFP (   v,
  sort,
  ctx = None 
)
Create a Z3 floating-point conversion expression that represents the
conversion from a bit-vector term to a floating-point term.

>>> x_bv = BitVecVal(0x3F800000, 32)
>>> x_fp = fpBVToFP(x_bv, Float32())
>>> x_fp
fpToFP(1065353216)
>>> simplify(x_fp)
1

Definition at line 11357 of file z3py.py.

11357def fpBVToFP(v, sort, ctx=None):
11358 """Create a Z3 floating-point conversion expression that represents the
11359 conversion from a bit-vector term to a floating-point term.
11360
11361 >>> x_bv = BitVecVal(0x3F800000, 32)
11362 >>> x_fp = fpBVToFP(x_bv, Float32())
11363 >>> x_fp
11364 fpToFP(1065353216)
11365 >>> simplify(x_fp)
11366 1
11367 """
11368 _z3_assert(is_bv(v), "First argument must be a Z3 bit-vector expression")
11369 _z3_assert(is_fp_sort(sort), "Second argument must be a Z3 floating-point sort.")
11370 ctx = _get_ctx(ctx)
11371 return FPRef(Z3_mk_fpa_to_fp_bv(ctx.ref(), v.ast, sort.ast), ctx)
11372
11373
Z3_ast Z3_API Z3_mk_fpa_to_fp_bv(Z3_context c, Z3_ast bv, Z3_sort s)
Conversion of a single IEEE 754-2008 bit-vector into a floating-point number.

◆ fpDiv()

fpDiv (   rm,
  a,
  b,
  ctx = None 
)
Create a Z3 floating-point division expression.

>>> s = FPSort(8, 24)
>>> rm = RNE()
>>> x = FP('x', s)
>>> y = FP('y', s)
>>> fpDiv(rm, x, y)
x / y
>>> fpDiv(rm, x, y).sort()
FPSort(8, 24)

Definition at line 11082 of file z3py.py.

11082def fpDiv(rm, a, b, ctx=None):
11083 """Create a Z3 floating-point division expression.
11084
11085 >>> s = FPSort(8, 24)
11086 >>> rm = RNE()
11087 >>> x = FP('x', s)
11088 >>> y = FP('y', s)
11089 >>> fpDiv(rm, x, y)
11090 x / y
11091 >>> fpDiv(rm, x, y).sort()
11092 FPSort(8, 24)
11093 """
11094 return _mk_fp_bin(Z3_mk_fpa_div, rm, a, b, ctx)
11095
11096

◆ fpEQ()

fpEQ (   a,
  b,
  ctx = None 
)
Create the Z3 floating-point expression `fpEQ(other, self)`.

>>> x, y = FPs('x y', FPSort(8, 24))
>>> fpEQ(x, y)
fpEQ(x, y)
>>> fpEQ(x, y).sexpr()
'(fp.eq x y)'

Definition at line 11265 of file z3py.py.

11265def fpEQ(a, b, ctx=None):
11266 """Create the Z3 floating-point expression `fpEQ(other, self)`.
11267
11268 >>> x, y = FPs('x y', FPSort(8, 24))
11269 >>> fpEQ(x, y)
11270 fpEQ(x, y)
11271 >>> fpEQ(x, y).sexpr()
11272 '(fp.eq x y)'
11273 """
11274 return _mk_fp_bin_pred(Z3_mk_fpa_eq, a, b, ctx)
11275
11276

◆ fpFMA()

fpFMA (   rm,
  a,
  b,
  c,
  ctx = None 
)
Create a Z3 floating-point fused multiply-add expression.

Definition at line 11141 of file z3py.py.

11141def fpFMA(rm, a, b, c, ctx=None):
11142 """Create a Z3 floating-point fused multiply-add expression.
11143 """
11144 return _mk_fp_tern(Z3_mk_fpa_fma, rm, a, b, c, ctx)
11145
11146

◆ fpFP()

fpFP (   sgn,
  exp,
  sig,
  ctx = None 
)
Create the Z3 floating-point value `fpFP(sgn, sig, exp)` from the three bit-vectors sgn, sig, and exp.

>>> s = FPSort(8, 24)
>>> x = fpFP(BitVecVal(1, 1), BitVecVal(2**7-1, 8), BitVecVal(2**22, 23))
>>> print(x)
fpFP(1, 127, 4194304)
>>> xv = FPVal(-1.5, s)
>>> print(xv)
-1.5
>>> slvr = Solver()
>>> slvr.add(fpEQ(x, xv))
>>> slvr.check()
sat
>>> xv = FPVal(+1.5, s)
>>> print(xv)
1.5
>>> slvr = Solver()
>>> slvr.add(fpEQ(x, xv))
>>> slvr.check()
unsat

Definition at line 11289 of file z3py.py.

11289def fpFP(sgn, exp, sig, ctx=None):
11290 """Create the Z3 floating-point value `fpFP(sgn, sig, exp)` from the three bit-vectors sgn, sig, and exp.
11291
11292 >>> s = FPSort(8, 24)
11293 >>> x = fpFP(BitVecVal(1, 1), BitVecVal(2**7-1, 8), BitVecVal(2**22, 23))
11294 >>> print(x)
11295 fpFP(1, 127, 4194304)
11296 >>> xv = FPVal(-1.5, s)
11297 >>> print(xv)
11298 -1.5
11299 >>> slvr = Solver()
11300 >>> slvr.add(fpEQ(x, xv))
11301 >>> slvr.check()
11302 sat
11303 >>> xv = FPVal(+1.5, s)
11304 >>> print(xv)
11305 1.5
11306 >>> slvr = Solver()
11307 >>> slvr.add(fpEQ(x, xv))
11308 >>> slvr.check()
11309 unsat
11310 """
11311 _z3_assert(is_bv(sgn) and is_bv(exp) and is_bv(sig), "sort mismatch")
11312 _z3_assert(sgn.sort().size() == 1, "sort mismatch")
11313 ctx = _get_ctx(ctx)
11314 _z3_assert(ctx == sgn.ctx == exp.ctx == sig.ctx, "context mismatch")
11315 return FPRef(Z3_mk_fpa_fp(ctx.ref(), sgn.ast, exp.ast, sig.ast), ctx)
11316
11317
Z3_ast Z3_API Z3_mk_fpa_fp(Z3_context c, Z3_ast sgn, Z3_ast exp, Z3_ast sig)
Create an expression of FloatingPoint sort from three bit-vector expressions.

◆ fpFPToFP()

fpFPToFP (   rm,
  v,
  sort,
  ctx = None 
)
Create a Z3 floating-point conversion expression that represents the
conversion from a floating-point term to a floating-point term of different precision.

>>> x_sgl = FPVal(1.0, Float32())
>>> x_dbl = fpFPToFP(RNE(), x_sgl, Float64())
>>> x_dbl
fpToFP(RNE(), 1)
>>> simplify(x_dbl)
1
>>> x_dbl.sort()
FPSort(11, 53)

Definition at line 11374 of file z3py.py.

11374def fpFPToFP(rm, v, sort, ctx=None):
11375 """Create a Z3 floating-point conversion expression that represents the
11376 conversion from a floating-point term to a floating-point term of different precision.
11377
11378 >>> x_sgl = FPVal(1.0, Float32())
11379 >>> x_dbl = fpFPToFP(RNE(), x_sgl, Float64())
11380 >>> x_dbl
11381 fpToFP(RNE(), 1)
11382 >>> simplify(x_dbl)
11383 1
11384 >>> x_dbl.sort()
11385 FPSort(11, 53)
11386 """
11387 _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression.")
11388 _z3_assert(is_fp(v), "Second argument must be a Z3 floating-point expression.")
11389 _z3_assert(is_fp_sort(sort), "Third argument must be a Z3 floating-point sort.")
11390 ctx = _get_ctx(ctx)
11391 return FPRef(Z3_mk_fpa_to_fp_float(ctx.ref(), rm.ast, v.ast, sort.ast), ctx)
11392
11393
Z3_ast Z3_API Z3_mk_fpa_to_fp_float(Z3_context c, Z3_ast rm, Z3_ast t, Z3_sort s)
Conversion of a FloatingPoint term into another term of different FloatingPoint sort.

◆ fpGEQ()

fpGEQ (   a,
  b,
  ctx = None 
)
Create the Z3 floating-point expression `other >= self`.

>>> x, y = FPs('x y', FPSort(8, 24))
>>> fpGEQ(x, y)
x >= y
>>> (x >= y).sexpr()
'(fp.geq x y)'

Definition at line 11253 of file z3py.py.

11253def fpGEQ(a, b, ctx=None):
11254 """Create the Z3 floating-point expression `other >= self`.
11255
11256 >>> x, y = FPs('x y', FPSort(8, 24))
11257 >>> fpGEQ(x, y)
11258 x >= y
11259 >>> (x >= y).sexpr()
11260 '(fp.geq x y)'
11261 """
11262 return _mk_fp_bin_pred(Z3_mk_fpa_geq, a, b, ctx)
11263
11264

◆ fpGT()

fpGT (   a,
  b,
  ctx = None 
)
Create the Z3 floating-point expression `other > self`.

>>> x, y = FPs('x y', FPSort(8, 24))
>>> fpGT(x, y)
x > y
>>> (x > y).sexpr()
'(fp.gt x y)'

Definition at line 11241 of file z3py.py.

11241def fpGT(a, b, ctx=None):
11242 """Create the Z3 floating-point expression `other > self`.
11243
11244 >>> x, y = FPs('x y', FPSort(8, 24))
11245 >>> fpGT(x, y)
11246 x > y
11247 >>> (x > y).sexpr()
11248 '(fp.gt x y)'
11249 """
11250 return _mk_fp_bin_pred(Z3_mk_fpa_gt, a, b, ctx)
11251
11252

◆ fpInfinity()

fpInfinity (   s,
  negative 
)
Create a Z3 floating-point +oo or -oo term.

Definition at line 10829 of file z3py.py.

10829def fpInfinity(s, negative):
10830 """Create a Z3 floating-point +oo or -oo term."""
10831 _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
10832 _z3_assert(isinstance(negative, bool), "expected Boolean flag")
10833 return FPNumRef(Z3_mk_fpa_inf(s.ctx_ref(), s.ast, negative), s.ctx)
10834
10835
Z3_ast Z3_API Z3_mk_fpa_inf(Z3_context c, Z3_sort s, bool negative)
Create a floating-point infinity of sort s.

◆ fpIsInf()

fpIsInf (   a,
  ctx = None 
)
Create a Z3 floating-point isInfinite expression.

>>> s = FPSort(8, 24)
>>> x = FP('x', s)
>>> fpIsInf(x)
fpIsInf(x)

Definition at line 11171 of file z3py.py.

11171def fpIsInf(a, ctx=None):
11172 """Create a Z3 floating-point isInfinite expression.
11173
11174 >>> s = FPSort(8, 24)
11175 >>> x = FP('x', s)
11176 >>> fpIsInf(x)
11177 fpIsInf(x)
11178 """
11179 return _mk_fp_unary_pred(Z3_mk_fpa_is_infinite, a, ctx)
11180
11181

◆ fpIsNaN()

fpIsNaN (   a,
  ctx = None 
)
Create a Z3 floating-point isNaN expression.

>>> s = FPSort(8, 24)
>>> x = FP('x', s)
>>> y = FP('y', s)
>>> fpIsNaN(x)
fpIsNaN(x)

Definition at line 11159 of file z3py.py.

11159def fpIsNaN(a, ctx=None):
11160 """Create a Z3 floating-point isNaN expression.
11161
11162 >>> s = FPSort(8, 24)
11163 >>> x = FP('x', s)
11164 >>> y = FP('y', s)
11165 >>> fpIsNaN(x)
11166 fpIsNaN(x)
11167 """
11168 return _mk_fp_unary_pred(Z3_mk_fpa_is_nan, a, ctx)
11169
11170

◆ fpIsNegative()

fpIsNegative (   a,
  ctx = None 
)
Create a Z3 floating-point isNegative expression.

Definition at line 11200 of file z3py.py.

11200def fpIsNegative(a, ctx=None):
11201 """Create a Z3 floating-point isNegative expression.
11202 """
11203 return _mk_fp_unary_pred(Z3_mk_fpa_is_negative, a, ctx)
11204
11205

◆ fpIsNormal()

fpIsNormal (   a,
  ctx = None 
)
Create a Z3 floating-point isNormal expression.

Definition at line 11188 of file z3py.py.

11188def fpIsNormal(a, ctx=None):
11189 """Create a Z3 floating-point isNormal expression.
11190 """
11191 return _mk_fp_unary_pred(Z3_mk_fpa_is_normal, a, ctx)
11192
11193

◆ fpIsPositive()

fpIsPositive (   a,
  ctx = None 
)
Create a Z3 floating-point isPositive expression.

Definition at line 11206 of file z3py.py.

11206def fpIsPositive(a, ctx=None):
11207 """Create a Z3 floating-point isPositive expression.
11208 """
11209 return _mk_fp_unary_pred(Z3_mk_fpa_is_positive, a, ctx)
11210
11211

◆ fpIsSubnormal()

fpIsSubnormal (   a,
  ctx = None 
)
Create a Z3 floating-point isSubnormal expression.

Definition at line 11194 of file z3py.py.

11194def fpIsSubnormal(a, ctx=None):
11195 """Create a Z3 floating-point isSubnormal expression.
11196 """
11197 return _mk_fp_unary_pred(Z3_mk_fpa_is_subnormal, a, ctx)
11198
11199

◆ fpIsZero()

fpIsZero (   a,
  ctx = None 
)
Create a Z3 floating-point isZero expression.

Definition at line 11182 of file z3py.py.

11182def fpIsZero(a, ctx=None):
11183 """Create a Z3 floating-point isZero expression.
11184 """
11185 return _mk_fp_unary_pred(Z3_mk_fpa_is_zero, a, ctx)
11186
11187

◆ fpLEQ()

fpLEQ (   a,
  b,
  ctx = None 
)
Create the Z3 floating-point expression `other <= self`.

>>> x, y = FPs('x y', FPSort(8, 24))
>>> fpLEQ(x, y)
x <= y
>>> (x <= y).sexpr()
'(fp.leq x y)'

Definition at line 11229 of file z3py.py.

11229def fpLEQ(a, b, ctx=None):
11230 """Create the Z3 floating-point expression `other <= self`.
11231
11232 >>> x, y = FPs('x y', FPSort(8, 24))
11233 >>> fpLEQ(x, y)
11234 x <= y
11235 >>> (x <= y).sexpr()
11236 '(fp.leq x y)'
11237 """
11238 return _mk_fp_bin_pred(Z3_mk_fpa_leq, a, b, ctx)
11239
11240

◆ fpLT()

fpLT (   a,
  b,
  ctx = None 
)
Create the Z3 floating-point expression `other < self`.

>>> x, y = FPs('x y', FPSort(8, 24))
>>> fpLT(x, y)
x < y
>>> (x < y).sexpr()
'(fp.lt x y)'

Definition at line 11217 of file z3py.py.

11217def fpLT(a, b, ctx=None):
11218 """Create the Z3 floating-point expression `other < self`.
11219
11220 >>> x, y = FPs('x y', FPSort(8, 24))
11221 >>> fpLT(x, y)
11222 x < y
11223 >>> (x < y).sexpr()
11224 '(fp.lt x y)'
11225 """
11226 return _mk_fp_bin_pred(Z3_mk_fpa_lt, a, b, ctx)
11227
11228

◆ fpMax()

fpMax (   a,
  b,
  ctx = None 
)
Create a Z3 floating-point maximum expression.

>>> s = FPSort(8, 24)
>>> rm = RNE()
>>> x = FP('x', s)
>>> y = FP('y', s)
>>> fpMax(x, y)
fpMax(x, y)
>>> fpMax(x, y).sort()
FPSort(8, 24)

Definition at line 11126 of file z3py.py.

11126def fpMax(a, b, ctx=None):
11127 """Create a Z3 floating-point maximum expression.
11128
11129 >>> s = FPSort(8, 24)
11130 >>> rm = RNE()
11131 >>> x = FP('x', s)
11132 >>> y = FP('y', s)
11133 >>> fpMax(x, y)
11134 fpMax(x, y)
11135 >>> fpMax(x, y).sort()
11136 FPSort(8, 24)
11137 """
11138 return _mk_fp_bin_norm(Z3_mk_fpa_max, a, b, ctx)
11139
11140

◆ fpMin()

fpMin (   a,
  b,
  ctx = None 
)
Create a Z3 floating-point minimum expression.

>>> s = FPSort(8, 24)
>>> rm = RNE()
>>> x = FP('x', s)
>>> y = FP('y', s)
>>> fpMin(x, y)
fpMin(x, y)
>>> fpMin(x, y).sort()
FPSort(8, 24)

Definition at line 11111 of file z3py.py.

11111def fpMin(a, b, ctx=None):
11112 """Create a Z3 floating-point minimum expression.
11113
11114 >>> s = FPSort(8, 24)
11115 >>> rm = RNE()
11116 >>> x = FP('x', s)
11117 >>> y = FP('y', s)
11118 >>> fpMin(x, y)
11119 fpMin(x, y)
11120 >>> fpMin(x, y).sort()
11121 FPSort(8, 24)
11122 """
11123 return _mk_fp_bin_norm(Z3_mk_fpa_min, a, b, ctx)
11124
11125

◆ fpMinusInfinity()

fpMinusInfinity (   s)
Create a Z3 floating-point -oo term.

Definition at line 10823 of file z3py.py.

10823def fpMinusInfinity(s):
10824 """Create a Z3 floating-point -oo term."""
10825 _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
10826 return FPNumRef(Z3_mk_fpa_inf(s.ctx_ref(), s.ast, True), s.ctx)
10827
10828

◆ fpMinusZero()

fpMinusZero (   s)
Create a Z3 floating-point -0.0 term.

Definition at line 10842 of file z3py.py.

10842def fpMinusZero(s):
10843 """Create a Z3 floating-point -0.0 term."""
10844 _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
10845 return FPNumRef(Z3_mk_fpa_zero(s.ctx_ref(), s.ast, True), s.ctx)
10846
10847
Z3_ast Z3_API Z3_mk_fpa_zero(Z3_context c, Z3_sort s, bool negative)
Create a floating-point zero of sort s.

◆ fpMul()

fpMul (   rm,
  a,
  b,
  ctx = None 
)
Create a Z3 floating-point multiplication expression.

>>> s = FPSort(8, 24)
>>> rm = RNE()
>>> x = FP('x', s)
>>> y = FP('y', s)
>>> fpMul(rm, x, y)
x * y
>>> fpMul(rm, x, y).sort()
FPSort(8, 24)

Definition at line 11067 of file z3py.py.

11067def fpMul(rm, a, b, ctx=None):
11068 """Create a Z3 floating-point multiplication expression.
11069
11070 >>> s = FPSort(8, 24)
11071 >>> rm = RNE()
11072 >>> x = FP('x', s)
11073 >>> y = FP('y', s)
11074 >>> fpMul(rm, x, y)
11075 x * y
11076 >>> fpMul(rm, x, y).sort()
11077 FPSort(8, 24)
11078 """
11079 return _mk_fp_bin(Z3_mk_fpa_mul, rm, a, b, ctx)
11080
11081

◆ fpNaN()

fpNaN (   s)
Create a Z3 floating-point NaN term.

>>> s = FPSort(8, 24)
>>> set_fpa_pretty(True)
>>> fpNaN(s)
NaN
>>> pb = get_fpa_pretty()
>>> set_fpa_pretty(False)
>>> fpNaN(s)
fpNaN(FPSort(8, 24))
>>> set_fpa_pretty(pb)

Definition at line 10789 of file z3py.py.

10789def fpNaN(s):
10790 """Create a Z3 floating-point NaN term.
10791
10792 >>> s = FPSort(8, 24)
10793 >>> set_fpa_pretty(True)
10794 >>> fpNaN(s)
10795 NaN
10796 >>> pb = get_fpa_pretty()
10797 >>> set_fpa_pretty(False)
10798 >>> fpNaN(s)
10799 fpNaN(FPSort(8, 24))
10800 >>> set_fpa_pretty(pb)
10801 """
10802 _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
10803 return FPNumRef(Z3_mk_fpa_nan(s.ctx_ref(), s.ast), s.ctx)
10804
10805
Z3_ast Z3_API Z3_mk_fpa_nan(Z3_context c, Z3_sort s)
Create a floating-point NaN of sort s.

◆ fpNeg()

fpNeg (   a,
  ctx = None 
)
Create a Z3 floating-point addition expression.

>>> s = FPSort(8, 24)
>>> rm = RNE()
>>> x = FP('x', s)
>>> fpNeg(x)
-x
>>> fpNeg(x).sort()
FPSort(8, 24)

Definition at line 10967 of file z3py.py.

10967def fpNeg(a, ctx=None):
10968 """Create a Z3 floating-point addition expression.
10969
10970 >>> s = FPSort(8, 24)
10971 >>> rm = RNE()
10972 >>> x = FP('x', s)
10973 >>> fpNeg(x)
10974 -x
10975 >>> fpNeg(x).sort()
10976 FPSort(8, 24)
10977 """
10978 ctx = _get_ctx(ctx)
10979 [a] = _coerce_fp_expr_list([a], ctx)
10980 return FPRef(Z3_mk_fpa_neg(ctx.ref(), a.as_ast()), ctx)
10981
10982
Z3_ast Z3_API Z3_mk_fpa_neg(Z3_context c, Z3_ast t)
Floating-point negation.

◆ fpNEQ()

fpNEQ (   a,
  b,
  ctx = None 
)
Create the Z3 floating-point expression `Not(fpEQ(other, self))`.

>>> x, y = FPs('x y', FPSort(8, 24))
>>> fpNEQ(x, y)
Not(fpEQ(x, y))
>>> (x != y).sexpr()
'(distinct x y)'

Definition at line 11277 of file z3py.py.

11277def fpNEQ(a, b, ctx=None):
11278 """Create the Z3 floating-point expression `Not(fpEQ(other, self))`.
11279
11280 >>> x, y = FPs('x y', FPSort(8, 24))
11281 >>> fpNEQ(x, y)
11282 Not(fpEQ(x, y))
11283 >>> (x != y).sexpr()
11284 '(distinct x y)'
11285 """
11286 return Not(fpEQ(a, b, ctx))
11287
11288

◆ fpPlusInfinity()

fpPlusInfinity (   s)
Create a Z3 floating-point +oo term.

>>> s = FPSort(8, 24)
>>> pb = get_fpa_pretty()
>>> set_fpa_pretty(True)
>>> fpPlusInfinity(s)
+oo
>>> set_fpa_pretty(False)
>>> fpPlusInfinity(s)
fpPlusInfinity(FPSort(8, 24))
>>> set_fpa_pretty(pb)

Definition at line 10806 of file z3py.py.

10806def fpPlusInfinity(s):
10807 """Create a Z3 floating-point +oo term.
10808
10809 >>> s = FPSort(8, 24)
10810 >>> pb = get_fpa_pretty()
10811 >>> set_fpa_pretty(True)
10812 >>> fpPlusInfinity(s)
10813 +oo
10814 >>> set_fpa_pretty(False)
10815 >>> fpPlusInfinity(s)
10816 fpPlusInfinity(FPSort(8, 24))
10817 >>> set_fpa_pretty(pb)
10818 """
10819 _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
10820 return FPNumRef(Z3_mk_fpa_inf(s.ctx_ref(), s.ast, False), s.ctx)
10821
10822

◆ fpPlusZero()

fpPlusZero (   s)
Create a Z3 floating-point +0.0 term.

Definition at line 10836 of file z3py.py.

10836def fpPlusZero(s):
10837 """Create a Z3 floating-point +0.0 term."""
10838 _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
10839 return FPNumRef(Z3_mk_fpa_zero(s.ctx_ref(), s.ast, False), s.ctx)
10840
10841

◆ fpRealToFP()

fpRealToFP (   rm,
  v,
  sort,
  ctx = None 
)
Create a Z3 floating-point conversion expression that represents the
conversion from a real term to a floating-point term.

>>> x_r = RealVal(1.5)
>>> x_fp = fpRealToFP(RNE(), x_r, Float32())
>>> x_fp
fpToFP(RNE(), 3/2)
>>> simplify(x_fp)
1.5

Definition at line 11394 of file z3py.py.

11394def fpRealToFP(rm, v, sort, ctx=None):
11395 """Create a Z3 floating-point conversion expression that represents the
11396 conversion from a real term to a floating-point term.
11397
11398 >>> x_r = RealVal(1.5)
11399 >>> x_fp = fpRealToFP(RNE(), x_r, Float32())
11400 >>> x_fp
11401 fpToFP(RNE(), 3/2)
11402 >>> simplify(x_fp)
11403 1.5
11404 """
11405 _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression.")
11406 _z3_assert(is_real(v), "Second argument must be a Z3 expression or real sort.")
11407 _z3_assert(is_fp_sort(sort), "Third argument must be a Z3 floating-point sort.")
11408 ctx = _get_ctx(ctx)
11409 return FPRef(Z3_mk_fpa_to_fp_real(ctx.ref(), rm.ast, v.ast, sort.ast), ctx)
11410
11411
Z3_ast Z3_API Z3_mk_fpa_to_fp_real(Z3_context c, Z3_ast rm, Z3_ast t, Z3_sort s)
Conversion of a term of real sort into a term of FloatingPoint sort.

◆ fpRem()

fpRem (   a,
  b,
  ctx = None 
)
Create a Z3 floating-point remainder expression.

>>> s = FPSort(8, 24)
>>> x = FP('x', s)
>>> y = FP('y', s)
>>> fpRem(x, y)
fpRem(x, y)
>>> fpRem(x, y).sort()
FPSort(8, 24)

Definition at line 11097 of file z3py.py.

11097def fpRem(a, b, ctx=None):
11098 """Create a Z3 floating-point remainder expression.
11099
11100 >>> s = FPSort(8, 24)
11101 >>> x = FP('x', s)
11102 >>> y = FP('y', s)
11103 >>> fpRem(x, y)
11104 fpRem(x, y)
11105 >>> fpRem(x, y).sort()
11106 FPSort(8, 24)
11107 """
11108 return _mk_fp_bin_norm(Z3_mk_fpa_rem, a, b, ctx)
11109
11110

◆ fpRoundToIntegral()

fpRoundToIntegral (   rm,
  a,
  ctx = None 
)
Create a Z3 floating-point roundToIntegral expression.

Definition at line 11153 of file z3py.py.

11153def fpRoundToIntegral(rm, a, ctx=None):
11154 """Create a Z3 floating-point roundToIntegral expression.
11155 """
11156 return _mk_fp_unary(Z3_mk_fpa_round_to_integral, rm, a, ctx)
11157
11158

◆ FPs()

FPs (   names,
  fpsort,
  ctx = None 
)
Return an array of floating-point constants.

>>> x, y, z = FPs('x y z', FPSort(8, 24))
>>> x.sort()
FPSort(8, 24)
>>> x.sbits()
24
>>> x.ebits()
8
>>> fpMul(RNE(), fpAdd(RNE(), x, y), z)
(x + y) * z

Definition at line 10925 of file z3py.py.

10925def FPs(names, fpsort, ctx=None):
10926 """Return an array of floating-point constants.
10927
10928 >>> x, y, z = FPs('x y z', FPSort(8, 24))
10929 >>> x.sort()
10930 FPSort(8, 24)
10931 >>> x.sbits()
10932 24
10933 >>> x.ebits()
10934 8
10935 >>> fpMul(RNE(), fpAdd(RNE(), x, y), z)
10936 (x + y) * z
10937 """
10938 ctx = _get_ctx(ctx)
10939 if isinstance(names, str):
10940 names = names.split(" ")
10941 return [FP(name, fpsort, ctx) for name in names]
10942
10943

◆ fpSignedToFP()

fpSignedToFP (   rm,
  v,
  sort,
  ctx = None 
)
Create a Z3 floating-point conversion expression that represents the
conversion from a signed bit-vector term (encoding an integer) to a floating-point term.

>>> x_signed = BitVecVal(-5, BitVecSort(32))
>>> x_fp = fpSignedToFP(RNE(), x_signed, Float32())
>>> x_fp
fpToFP(RNE(), 4294967291)
>>> simplify(x_fp)
-1.25*(2**2)

Definition at line 11412 of file z3py.py.

11412def fpSignedToFP(rm, v, sort, ctx=None):
11413 """Create a Z3 floating-point conversion expression that represents the
11414 conversion from a signed bit-vector term (encoding an integer) to a floating-point term.
11415
11416 >>> x_signed = BitVecVal(-5, BitVecSort(32))
11417 >>> x_fp = fpSignedToFP(RNE(), x_signed, Float32())
11418 >>> x_fp
11419 fpToFP(RNE(), 4294967291)
11420 >>> simplify(x_fp)
11421 -1.25*(2**2)
11422 """
11423 _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression.")
11424 _z3_assert(is_bv(v), "Second argument must be a Z3 bit-vector expression")
11425 _z3_assert(is_fp_sort(sort), "Third argument must be a Z3 floating-point sort.")
11426 ctx = _get_ctx(ctx)
11427 return FPRef(Z3_mk_fpa_to_fp_signed(ctx.ref(), rm.ast, v.ast, sort.ast), ctx)
11428
11429
Z3_ast Z3_API Z3_mk_fpa_to_fp_signed(Z3_context c, Z3_ast rm, Z3_ast t, Z3_sort s)
Conversion of a 2's complement signed bit-vector term into a term of FloatingPoint sort.

◆ FPSort()

FPSort (   ebits,
  sbits,
  ctx = None 
)
Return a Z3 floating-point sort of the given sizes. If `ctx=None`, then the global context is used.

>>> Single = FPSort(8, 24)
>>> Double = FPSort(11, 53)
>>> Single
FPSort(8, 24)
>>> x = Const('x', Single)
>>> eq(x, FP('x', FPSort(8, 24)))
True

Definition at line 10730 of file z3py.py.

10730def FPSort(ebits, sbits, ctx=None):
10731 """Return a Z3 floating-point sort of the given sizes. If `ctx=None`, then the global context is used.
10732
10733 >>> Single = FPSort(8, 24)
10734 >>> Double = FPSort(11, 53)
10735 >>> Single
10736 FPSort(8, 24)
10737 >>> x = Const('x', Single)
10738 >>> eq(x, FP('x', FPSort(8, 24)))
10739 True
10740 """
10741 ctx = _get_ctx(ctx)
10742 return FPSortRef(Z3_mk_fpa_sort(ctx.ref(), ebits, sbits), ctx)
10743
10744
Z3_sort Z3_API Z3_mk_fpa_sort(Z3_context c, unsigned ebits, unsigned sbits)
Create a FloatingPoint sort.

◆ fpSqrt()

fpSqrt (   rm,
  a,
  ctx = None 
)
Create a Z3 floating-point square root expression.

Definition at line 11147 of file z3py.py.

11147def fpSqrt(rm, a, ctx=None):
11148 """Create a Z3 floating-point square root expression.
11149 """
11150 return _mk_fp_unary(Z3_mk_fpa_sqrt, rm, a, ctx)
11151
11152

◆ fpSub()

fpSub (   rm,
  a,
  b,
  ctx = None 
)
Create a Z3 floating-point subtraction expression.

>>> s = FPSort(8, 24)
>>> rm = RNE()
>>> x = FP('x', s)
>>> y = FP('y', s)
>>> fpSub(rm, x, y)
x - y
>>> fpSub(rm, x, y).sort()
FPSort(8, 24)

Definition at line 11052 of file z3py.py.

11052def fpSub(rm, a, b, ctx=None):
11053 """Create a Z3 floating-point subtraction expression.
11054
11055 >>> s = FPSort(8, 24)
11056 >>> rm = RNE()
11057 >>> x = FP('x', s)
11058 >>> y = FP('y', s)
11059 >>> fpSub(rm, x, y)
11060 x - y
11061 >>> fpSub(rm, x, y).sort()
11062 FPSort(8, 24)
11063 """
11064 return _mk_fp_bin(Z3_mk_fpa_sub, rm, a, b, ctx)
11065
11066

◆ fpToFP()

fpToFP (   a1,
  a2 = None,
  a3 = None,
  ctx = None 
)
Create a Z3 floating-point conversion expression from other term sorts
to floating-point.

From a bit-vector term in IEEE 754-2008 format:
>>> x = FPVal(1.0, Float32())
>>> x_bv = fpToIEEEBV(x)
>>> simplify(fpToFP(x_bv, Float32()))
1

From a floating-point term with different precision:
>>> x = FPVal(1.0, Float32())
>>> x_db = fpToFP(RNE(), x, Float64())
>>> x_db.sort()
FPSort(11, 53)

From a real term:
>>> x_r = RealVal(1.5)
>>> simplify(fpToFP(RNE(), x_r, Float32()))
1.5

From a signed bit-vector term:
>>> x_signed = BitVecVal(-5, BitVecSort(32))
>>> simplify(fpToFP(RNE(), x_signed, Float32()))
-1.25*(2**2)

Definition at line 11318 of file z3py.py.

11318def fpToFP(a1, a2=None, a3=None, ctx=None):
11319 """Create a Z3 floating-point conversion expression from other term sorts
11320 to floating-point.
11321
11322 From a bit-vector term in IEEE 754-2008 format:
11323 >>> x = FPVal(1.0, Float32())
11324 >>> x_bv = fpToIEEEBV(x)
11325 >>> simplify(fpToFP(x_bv, Float32()))
11326 1
11327
11328 From a floating-point term with different precision:
11329 >>> x = FPVal(1.0, Float32())
11330 >>> x_db = fpToFP(RNE(), x, Float64())
11331 >>> x_db.sort()
11332 FPSort(11, 53)
11333
11334 From a real term:
11335 >>> x_r = RealVal(1.5)
11336 >>> simplify(fpToFP(RNE(), x_r, Float32()))
11337 1.5
11338
11339 From a signed bit-vector term:
11340 >>> x_signed = BitVecVal(-5, BitVecSort(32))
11341 >>> simplify(fpToFP(RNE(), x_signed, Float32()))
11342 -1.25*(2**2)
11343 """
11344 ctx = _get_ctx(ctx)
11345 if is_bv(a1) and is_fp_sort(a2):
11346 return FPRef(Z3_mk_fpa_to_fp_bv(ctx.ref(), a1.ast, a2.ast), ctx)
11347 elif is_fprm(a1) and is_fp(a2) and is_fp_sort(a3):
11348 return FPRef(Z3_mk_fpa_to_fp_float(ctx.ref(), a1.ast, a2.ast, a3.ast), ctx)
11349 elif is_fprm(a1) and is_real(a2) and is_fp_sort(a3):
11350 return FPRef(Z3_mk_fpa_to_fp_real(ctx.ref(), a1.ast, a2.ast, a3.ast), ctx)
11351 elif is_fprm(a1) and is_bv(a2) and is_fp_sort(a3):
11352 return FPRef(Z3_mk_fpa_to_fp_signed(ctx.ref(), a1.ast, a2.ast, a3.ast), ctx)
11353 else:
11354 raise Z3Exception("Unsupported combination of arguments for conversion to floating-point term.")
11355
11356

◆ fpToFPUnsigned()

fpToFPUnsigned (   rm,
  x,
  s,
  ctx = None 
)
Create a Z3 floating-point conversion expression, from unsigned bit-vector to floating-point expression.

Definition at line 11448 of file z3py.py.

11448def fpToFPUnsigned(rm, x, s, ctx=None):
11449 """Create a Z3 floating-point conversion expression, from unsigned bit-vector to floating-point expression."""
11450 if z3_debug():
11451 _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
11452 _z3_assert(is_bv(x), "Second argument must be a Z3 bit-vector expression")
11453 _z3_assert(is_fp_sort(s), "Third argument must be Z3 floating-point sort")
11454 ctx = _get_ctx(ctx)
11455 return FPRef(Z3_mk_fpa_to_fp_unsigned(ctx.ref(), rm.ast, x.ast, s.ast), ctx)
11456
11457
Z3_ast Z3_API Z3_mk_fpa_to_fp_unsigned(Z3_context c, Z3_ast rm, Z3_ast t, Z3_sort s)
Conversion of a 2's complement unsigned bit-vector term into a term of FloatingPoint sort.

◆ fpToIEEEBV()

fpToIEEEBV (   x,
  ctx = None 
)
\brief Conversion of a floating-point term into a bit-vector term in IEEE 754-2008 format.

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.

>>> x = FP('x', FPSort(8, 24))
>>> y = fpToIEEEBV(x)
>>> print(is_fp(x))
True
>>> print(is_bv(y))
True
>>> print(is_fp(y))
False
>>> print(is_bv(x))
False

Definition at line 11522 of file z3py.py.

11522def fpToIEEEBV(x, ctx=None):
11523 """\brief Conversion of a floating-point term into a bit-vector term in IEEE 754-2008 format.
11524
11525 The size of the resulting bit-vector is automatically determined.
11526
11527 Note that IEEE 754-2008 allows multiple different representations of NaN. This conversion
11528 knows only one NaN and it will always produce the same bit-vector representation of
11529 that NaN.
11530
11531 >>> x = FP('x', FPSort(8, 24))
11532 >>> y = fpToIEEEBV(x)
11533 >>> print(is_fp(x))
11534 True
11535 >>> print(is_bv(y))
11536 True
11537 >>> print(is_fp(y))
11538 False
11539 >>> print(is_bv(x))
11540 False
11541 """
11542 if z3_debug():
11543 _z3_assert(is_fp(x), "First argument must be a Z3 floating-point expression")
11544 ctx = _get_ctx(ctx)
11545 return BitVecRef(Z3_mk_fpa_to_ieee_bv(ctx.ref(), x.ast), ctx)
11546
11547
Z3_ast Z3_API Z3_mk_fpa_to_ieee_bv(Z3_context c, Z3_ast t)
Conversion of a floating-point term into a bit-vector term in IEEE 754-2008 format.

◆ fpToReal()

fpToReal (   x,
  ctx = None 
)
Create a Z3 floating-point conversion expression, from floating-point expression to real.

>>> x = FP('x', FPSort(8, 24))
>>> y = fpToReal(x)
>>> print(is_fp(x))
True
>>> print(is_real(y))
True
>>> print(is_fp(y))
False
>>> print(is_real(x))
False

Definition at line 11502 of file z3py.py.

11502def fpToReal(x, ctx=None):
11503 """Create a Z3 floating-point conversion expression, from floating-point expression to real.
11504
11505 >>> x = FP('x', FPSort(8, 24))
11506 >>> y = fpToReal(x)
11507 >>> print(is_fp(x))
11508 True
11509 >>> print(is_real(y))
11510 True
11511 >>> print(is_fp(y))
11512 False
11513 >>> print(is_real(x))
11514 False
11515 """
11516 if z3_debug():
11517 _z3_assert(is_fp(x), "First argument must be a Z3 floating-point expression")
11518 ctx = _get_ctx(ctx)
11519 return ArithRef(Z3_mk_fpa_to_real(ctx.ref(), x.ast), ctx)
11520
11521
Z3_ast Z3_API Z3_mk_fpa_to_real(Z3_context c, Z3_ast t)
Conversion of a floating-point term into a real-numbered term.

◆ fpToSBV()

fpToSBV (   rm,
  x,
  s,
  ctx = None 
)
Create a Z3 floating-point conversion expression, from floating-point expression to signed bit-vector.

>>> x = FP('x', FPSort(8, 24))
>>> y = fpToSBV(RTZ(), x, BitVecSort(32))
>>> print(is_fp(x))
True
>>> print(is_bv(y))
True
>>> print(is_fp(y))
False
>>> print(is_bv(x))
False

Definition at line 11458 of file z3py.py.

11458def fpToSBV(rm, x, s, ctx=None):
11459 """Create a Z3 floating-point conversion expression, from floating-point expression to signed bit-vector.
11460
11461 >>> x = FP('x', FPSort(8, 24))
11462 >>> y = fpToSBV(RTZ(), x, BitVecSort(32))
11463 >>> print(is_fp(x))
11464 True
11465 >>> print(is_bv(y))
11466 True
11467 >>> print(is_fp(y))
11468 False
11469 >>> print(is_bv(x))
11470 False
11471 """
11472 if z3_debug():
11473 _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
11474 _z3_assert(is_fp(x), "Second argument must be a Z3 floating-point expression")
11475 _z3_assert(is_bv_sort(s), "Third argument must be Z3 bit-vector sort")
11476 ctx = _get_ctx(ctx)
11477 return BitVecRef(Z3_mk_fpa_to_sbv(ctx.ref(), rm.ast, x.ast, s.size()), ctx)
11478
11479
Z3_ast Z3_API Z3_mk_fpa_to_sbv(Z3_context c, Z3_ast rm, Z3_ast t, unsigned sz)
Conversion of a floating-point term into a signed bit-vector.

◆ fpToUBV()

fpToUBV (   rm,
  x,
  s,
  ctx = None 
)
Create a Z3 floating-point conversion expression, from floating-point expression to unsigned bit-vector.

>>> x = FP('x', FPSort(8, 24))
>>> y = fpToUBV(RTZ(), x, BitVecSort(32))
>>> print(is_fp(x))
True
>>> print(is_bv(y))
True
>>> print(is_fp(y))
False
>>> print(is_bv(x))
False

Definition at line 11480 of file z3py.py.

11480def fpToUBV(rm, x, s, ctx=None):
11481 """Create a Z3 floating-point conversion expression, from floating-point expression to unsigned bit-vector.
11482
11483 >>> x = FP('x', FPSort(8, 24))
11484 >>> y = fpToUBV(RTZ(), x, BitVecSort(32))
11485 >>> print(is_fp(x))
11486 True
11487 >>> print(is_bv(y))
11488 True
11489 >>> print(is_fp(y))
11490 False
11491 >>> print(is_bv(x))
11492 False
11493 """
11494 if z3_debug():
11495 _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
11496 _z3_assert(is_fp(x), "Second argument must be a Z3 floating-point expression")
11497 _z3_assert(is_bv_sort(s), "Third argument must be Z3 bit-vector sort")
11498 ctx = _get_ctx(ctx)
11499 return BitVecRef(Z3_mk_fpa_to_ubv(ctx.ref(), rm.ast, x.ast, s.size()), ctx)
11500
11501
Z3_ast Z3_API Z3_mk_fpa_to_ubv(Z3_context c, Z3_ast rm, Z3_ast t, unsigned sz)
Conversion of a floating-point term into an unsigned bit-vector.

◆ fpUnsignedToFP()

fpUnsignedToFP (   rm,
  v,
  sort,
  ctx = None 
)
Create a Z3 floating-point conversion expression that represents the
conversion from an unsigned bit-vector term (encoding an integer) to a floating-point term.

>>> x_signed = BitVecVal(-5, BitVecSort(32))
>>> x_fp = fpUnsignedToFP(RNE(), x_signed, Float32())
>>> x_fp
fpToFPUnsigned(RNE(), 4294967291)
>>> simplify(x_fp)
1*(2**32)

Definition at line 11430 of file z3py.py.

11430def fpUnsignedToFP(rm, v, sort, ctx=None):
11431 """Create a Z3 floating-point conversion expression that represents the
11432 conversion from an unsigned bit-vector term (encoding an integer) to a floating-point term.
11433
11434 >>> x_signed = BitVecVal(-5, BitVecSort(32))
11435 >>> x_fp = fpUnsignedToFP(RNE(), x_signed, Float32())
11436 >>> x_fp
11437 fpToFPUnsigned(RNE(), 4294967291)
11438 >>> simplify(x_fp)
11439 1*(2**32)
11440 """
11441 _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression.")
11442 _z3_assert(is_bv(v), "Second argument must be a Z3 bit-vector expression")
11443 _z3_assert(is_fp_sort(sort), "Third argument must be a Z3 floating-point sort.")
11444 ctx = _get_ctx(ctx)
11445 return FPRef(Z3_mk_fpa_to_fp_unsigned(ctx.ref(), rm.ast, v.ast, sort.ast), ctx)
11446
11447

◆ FPVal()

FPVal (   sig,
  exp = None,
  fps = None,
  ctx = None 
)
Return a floating-point value of value `val` and sort `fps`.
If `ctx=None`, then the global context is used.

>>> v = FPVal(20.0, FPSort(8, 24))
>>> v
1.25*(2**4)
>>> print("0x%.8x" % v.exponent_as_long(False))
0x00000004
>>> v = FPVal(2.25, FPSort(8, 24))
>>> v
1.125*(2**1)
>>> v = FPVal(-2.25, FPSort(8, 24))
>>> v
-1.125*(2**1)
>>> FPVal(-0.0, FPSort(8, 24))
-0.0
>>> FPVal(0.0, FPSort(8, 24))
+0.0
>>> FPVal(+0.0, FPSort(8, 24))
+0.0

Definition at line 10855 of file z3py.py.

10855def FPVal(sig, exp=None, fps=None, ctx=None):
10856 """Return a floating-point value of value `val` and sort `fps`.
10857 If `ctx=None`, then the global context is used.
10858
10859 >>> v = FPVal(20.0, FPSort(8, 24))
10860 >>> v
10861 1.25*(2**4)
10862 >>> print("0x%.8x" % v.exponent_as_long(False))
10863 0x00000004
10864 >>> v = FPVal(2.25, FPSort(8, 24))
10865 >>> v
10866 1.125*(2**1)
10867 >>> v = FPVal(-2.25, FPSort(8, 24))
10868 >>> v
10869 -1.125*(2**1)
10870 >>> FPVal(-0.0, FPSort(8, 24))
10871 -0.0
10872 >>> FPVal(0.0, FPSort(8, 24))
10873 +0.0
10874 >>> FPVal(+0.0, FPSort(8, 24))
10875 +0.0
10876 """
10877 ctx = _get_ctx(ctx)
10878 if is_fp_sort(exp):
10879 fps = exp
10880 exp = None
10881 elif fps is None:
10882 fps = _dflt_fps(ctx)
10883 _z3_assert(is_fp_sort(fps), "sort mismatch")
10884 if exp is None:
10885 exp = 0
10886 val = _to_float_str(sig)
10887 if val == "NaN" or val == "nan":
10888 return fpNaN(fps)
10889 elif val == "-0.0":
10890 return fpMinusZero(fps)
10891 elif val == "0.0" or val == "+0.0":
10892 return fpPlusZero(fps)
10893 elif val == "+oo" or val == "+inf" or val == "+Inf":
10894 return fpPlusInfinity(fps)
10895 elif val == "-oo" or val == "-inf" or val == "-Inf":
10896 return fpMinusInfinity(fps)
10897 else:
10898 return FPNumRef(Z3_mk_numeral(ctx.ref(), val, fps.ast), ctx)
10899
10900

◆ fpZero()

fpZero (   s,
  negative 
)
Create a Z3 floating-point +0.0 or -0.0 term.

Definition at line 10848 of file z3py.py.

10848def fpZero(s, negative):
10849 """Create a Z3 floating-point +0.0 or -0.0 term."""
10850 _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
10851 _z3_assert(isinstance(negative, bool), "expected Boolean flag")
10852 return FPNumRef(Z3_mk_fpa_zero(s.ctx_ref(), s.ast, negative), s.ctx)
10853
10854

◆ FreshBool()

FreshBool (   prefix = "b",
  ctx = None 
)
Return a fresh Boolean constant in the given context using the given prefix.

If `ctx=None`, then the global context is used.

>>> b1 = FreshBool()
>>> b2 = FreshBool()
>>> eq(b1, b2)
False

Definition at line 1910 of file z3py.py.

1910def FreshBool(prefix="b", ctx=None):
1911 """Return a fresh Boolean constant in the given context using the given prefix.
1912
1913 If `ctx=None`, then the global context is used.
1914
1915 >>> b1 = FreshBool()
1916 >>> b2 = FreshBool()
1917 >>> eq(b1, b2)
1918 False
1919 """
1920 ctx = _get_ctx(ctx)
1921 return BoolRef(Z3_mk_fresh_const(ctx.ref(), prefix, BoolSort(ctx).ast), ctx)
1922
1923
Z3_ast Z3_API Z3_mk_fresh_const(Z3_context c, Z3_string prefix, Z3_sort ty)
Declare and create a fresh constant.

◆ FreshConst()

FreshConst (   sort,
  prefix = "c" 
)
Create a fresh constant of a specified sort

Definition at line 1573 of file z3py.py.

1573def FreshConst(sort, prefix="c"):
1574 """Create a fresh constant of a specified sort"""
1575 if z3_debug():
1576 _z3_assert(is_sort(sort), f"Z3 sort expected, got {type(sort)}")
1577 ctx = _get_ctx(sort.ctx)
1578 return _to_expr_ref(Z3_mk_fresh_const(ctx.ref(), prefix, sort.ast), ctx)
1579
1580

◆ FreshFunction()

FreshFunction ( *  sig)
Create a new fresh Z3 uninterpreted function with the given sorts.

Definition at line 945 of file z3py.py.

945def FreshFunction(*sig):
946 """Create a new fresh Z3 uninterpreted function with the given sorts.
947 """
948 sig = _get_args(sig)
949 if z3_debug():
950 _z3_assert(len(sig) > 0, "At least two arguments expected")
951 arity = len(sig) - 1
952 rng = sig[arity]
953 if z3_debug():
954 _z3_assert(is_sort(rng), "Z3 sort expected")
955 dom = (z3.Sort * arity)()
956 for i in range(arity):
957 if z3_debug():
958 _z3_assert(is_sort(sig[i]), "Z3 sort expected")
959 dom[i] = sig[i].ast
960 ctx = rng.ctx
961 return FuncDeclRef(Z3_mk_fresh_func_decl(ctx.ref(), "f", arity, dom, rng.ast), ctx)
962
963
Z3_func_decl Z3_API Z3_mk_fresh_func_decl(Z3_context c, Z3_string prefix, unsigned domain_size, Z3_sort const domain[], Z3_sort range)
Declare a fresh constant or function.

◆ FreshInt()

FreshInt (   prefix = "x",
  ctx = None 
)
Return a fresh integer constant in the given context using the given prefix.

>>> x = FreshInt()
>>> y = FreshInt()
>>> eq(x, y)
False
>>> x.sort()
Int

Definition at line 3453 of file z3py.py.

3453def FreshInt(prefix="x", ctx=None):
3454 """Return a fresh integer constant in the given context using the given prefix.
3455
3456 >>> x = FreshInt()
3457 >>> y = FreshInt()
3458 >>> eq(x, y)
3459 False
3460 >>> x.sort()
3461 Int
3462 """
3463 ctx = _get_ctx(ctx)
3464 return ArithRef(Z3_mk_fresh_const(ctx.ref(), prefix, IntSort(ctx).ast), ctx)
3465
3466

◆ FreshReal()

FreshReal (   prefix = "b",
  ctx = None 
)
Return a fresh real constant in the given context using the given prefix.

>>> x = FreshReal()
>>> y = FreshReal()
>>> eq(x, y)
False
>>> x.sort()
Real

Definition at line 3510 of file z3py.py.

3510def FreshReal(prefix="b", ctx=None):
3511 """Return a fresh real constant in the given context using the given prefix.
3512
3513 >>> x = FreshReal()
3514 >>> y = FreshReal()
3515 >>> eq(x, y)
3516 False
3517 >>> x.sort()
3518 Real
3519 """
3520 ctx = _get_ctx(ctx)
3521 return ArithRef(Z3_mk_fresh_const(ctx.ref(), prefix, RealSort(ctx).ast), ctx)
3522
3523

◆ Full()

Full (   s)
Create the regular expression that accepts the universal language
>>> e = Full(ReSort(SeqSort(IntSort())))
>>> print(e)
Full(ReSort(Seq(Int)))
>>> e1 = Full(ReSort(StringSort()))
>>> print(e1)
Full(ReSort(String))

Definition at line 11828 of file z3py.py.

11828def Full(s):
11829 """Create the regular expression that accepts the universal language
11830 >>> e = Full(ReSort(SeqSort(IntSort())))
11831 >>> print(e)
11832 Full(ReSort(Seq(Int)))
11833 >>> e1 = Full(ReSort(StringSort()))
11834 >>> print(e1)
11835 Full(ReSort(String))
11836 """
11837 if isinstance(s, ReSortRef):
11838 return ReRef(Z3_mk_re_full(s.ctx_ref(), s.ast), s.ctx)
11839 raise Z3Exception("Non-sequence, non-regular expression sort passed to Full")
11840
11841
11842
Z3_ast Z3_API Z3_mk_re_full(Z3_context c, Z3_sort re)
Create an universal regular expression of sort re.

◆ FullSet()

FullSet (   s)
Create the full set
>>> FullSet(IntSort())
K(Int, True)

Definition at line 5182 of file z3py.py.

5182def FullSet(s):
5183 """Create the full set
5184 >>> FullSet(IntSort())
5185 K(Int, True)
5186 """
5187 ctx = s.ctx
5188 return ArrayRef(Z3_mk_full_set(ctx.ref(), s.ast), ctx)
5189
5190
Z3_ast Z3_API Z3_mk_full_set(Z3_context c, Z3_sort domain)
Create the full set.

◆ Function()

Function (   name,
*  sig 
)
Create a new Z3 uninterpreted function with the given sorts.

>>> f = Function('f', IntSort(), IntSort())
>>> f(f(0))
f(f(0))

Definition at line 922 of file z3py.py.

922def Function(name, *sig):
923 """Create a new Z3 uninterpreted function with the given sorts.
924
925 >>> f = Function('f', IntSort(), IntSort())
926 >>> f(f(0))
927 f(f(0))
928 """
929 sig = _get_args(sig)
930 if z3_debug():
931 _z3_assert(len(sig) > 0, "At least two arguments expected")
932 arity = len(sig) - 1
933 rng = sig[arity]
934 if z3_debug():
935 _z3_assert(is_sort(rng), "Z3 sort expected")
936 dom = (Sort * arity)()
937 for i in range(arity):
938 if z3_debug():
939 _z3_assert(is_sort(sig[i]), "Z3 sort expected")
940 dom[i] = sig[i].ast
941 ctx = rng.ctx
942 return FuncDeclRef(Z3_mk_func_decl(ctx.ref(), to_symbol(name, ctx), arity, dom, rng.ast), ctx)
943
944
Z3_func_decl Z3_API Z3_mk_func_decl(Z3_context c, Z3_symbol s, unsigned domain_size, Z3_sort const domain[], Z3_sort range)
Declare a constant or function.

◆ get_as_array_func()

get_as_array_func (   n)
Return the function declaration f associated with a Z3 expression of the form (_ as-array f).

Definition at line 7346 of file z3py.py.

7346def get_as_array_func(n):
7347 """Return the function declaration f associated with a Z3 expression of the form (_ as-array f)."""
7348 if z3_debug():
7349 _z3_assert(is_as_array(n), "as-array Z3 expression expected.")
7350 return FuncDeclRef(Z3_get_as_array_func_decl(n.ctx.ref(), n.as_ast()), n.ctx)
7351
Z3_func_decl Z3_API Z3_get_as_array_func_decl(Z3_context c, Z3_ast a)
Return the function declaration f associated with a (_ as_array f) node.

Referenced by ModelRef.get_interp().

◆ get_ctx()

Context get_ctx (   ctx)

Definition at line 294 of file z3py.py.

294def get_ctx(ctx) -> Context:
295 return _get_ctx(ctx)
296
297

◆ get_default_fp_sort()

get_default_fp_sort (   ctx = None)

Definition at line 10142 of file z3py.py.

10142def get_default_fp_sort(ctx=None):
10143 return FPSort(_dflt_fpsort_ebits, _dflt_fpsort_sbits, ctx)
10144
10145

◆ get_default_rounding_mode()

get_default_rounding_mode (   ctx = None)
Retrieves the global default rounding mode.

Definition at line 10109 of file z3py.py.

10109def get_default_rounding_mode(ctx=None):
10110 """Retrieves the global default rounding mode."""
10111 global _dflt_rounding_mode
10112 if _dflt_rounding_mode == Z3_OP_FPA_RM_TOWARD_ZERO:
10113 return RTZ(ctx)
10114 elif _dflt_rounding_mode == Z3_OP_FPA_RM_TOWARD_NEGATIVE:
10115 return RTN(ctx)
10116 elif _dflt_rounding_mode == Z3_OP_FPA_RM_TOWARD_POSITIVE:
10117 return RTP(ctx)
10118 elif _dflt_rounding_mode == Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN:
10119 return RNE(ctx)
10120 elif _dflt_rounding_mode == Z3_OP_FPA_RM_NEAREST_TIES_TO_AWAY:
10121 return RNA(ctx)
10122
10123

◆ get_full_version()

get_full_version ( )

Definition at line 109 of file z3py.py.

109def get_full_version():
110 return Z3_get_full_version()
111
112
Z3_string Z3_API Z3_get_full_version(void)
Return a string that fully describes the version of Z3 in use.

◆ get_map_func()

get_map_func (   a)
Return the function declaration associated with a Z3 map array expression.

>>> f = Function('f', IntSort(), IntSort())
>>> b = Array('b', IntSort(), IntSort())
>>> a  = Map(f, b)
>>> eq(f, get_map_func(a))
True
>>> get_map_func(a)
f
>>> get_map_func(a)(0)
f(0)

Definition at line 4911 of file z3py.py.

4911def get_map_func(a):
4912 """Return the function declaration associated with a Z3 map array expression.
4913
4914 >>> f = Function('f', IntSort(), IntSort())
4915 >>> b = Array('b', IntSort(), IntSort())
4916 >>> a = Map(f, b)
4917 >>> eq(f, get_map_func(a))
4918 True
4919 >>> get_map_func(a)
4920 f
4921 >>> get_map_func(a)(0)
4922 f(0)
4923 """
4924 if z3_debug():
4925 _z3_assert(is_map(a), "Z3 array map expression expected.")
4926 return FuncDeclRef(
4928 a.ctx_ref(),
4929 Z3_get_decl_ast_parameter(a.ctx_ref(), a.decl().ast, 0),
4930 ),
4931 ctx=a.ctx,
4932 )
4933
4934
Z3_func_decl Z3_API Z3_to_func_decl(Z3_context c, Z3_ast a)
Convert an AST into a FUNC_DECL_AST. This is just type casting.
Z3_ast Z3_API Z3_get_decl_ast_parameter(Z3_context c, Z3_func_decl d, unsigned idx)
Return the expression value associated with an expression parameter.

◆ get_param()

get_param (   name)
Return the value of a Z3 global (or module) parameter

>>> get_param('nlsat.reorder')
'true'

Definition at line 334 of file z3py.py.

334def get_param(name):
335 """Return the value of a Z3 global (or module) parameter
336
337 >>> get_param('nlsat.reorder')
338 'true'
339 """
340 ptr = (ctypes.c_char_p * 1)()
341 if Z3_global_param_get(str(name), ptr):
342 r = z3core._to_pystr(ptr[0])
343 return r
344 raise Z3Exception("failed to retrieve value for '%s'" % name)
345
bool Z3_API Z3_global_param_get(Z3_string param_id, Z3_string_ptr param_value)
Get a global (or module) parameter.

◆ get_var_index()

get_var_index (   a)
Return the de-Bruijn index of the Z3 bounded variable `a`.

>>> x = Int('x')
>>> y = Int('y')
>>> is_var(x)
False
>>> is_const(x)
True
>>> f = Function('f', IntSort(), IntSort(), IntSort())
>>> # Z3 replaces x and y with bound variables when ForAll is executed.
>>> q = ForAll([x, y], f(x, y) == x + y)
>>> q.body()
f(Var(1), Var(0)) == Var(1) + Var(0)
>>> b = q.body()
>>> b.arg(0)
f(Var(1), Var(0))
>>> v1 = b.arg(0).arg(0)
>>> v2 = b.arg(0).arg(1)
>>> v1
Var(1)
>>> v2
Var(0)
>>> get_var_index(v1)
1
>>> get_var_index(v2)
0

Definition at line 1444 of file z3py.py.

1444def get_var_index(a):
1445 """Return the de-Bruijn index of the Z3 bounded variable `a`.
1446
1447 >>> x = Int('x')
1448 >>> y = Int('y')
1449 >>> is_var(x)
1450 False
1451 >>> is_const(x)
1452 True
1453 >>> f = Function('f', IntSort(), IntSort(), IntSort())
1454 >>> # Z3 replaces x and y with bound variables when ForAll is executed.
1455 >>> q = ForAll([x, y], f(x, y) == x + y)
1456 >>> q.body()
1457 f(Var(1), Var(0)) == Var(1) + Var(0)
1458 >>> b = q.body()
1459 >>> b.arg(0)
1460 f(Var(1), Var(0))
1461 >>> v1 = b.arg(0).arg(0)
1462 >>> v2 = b.arg(0).arg(1)
1463 >>> v1
1464 Var(1)
1465 >>> v2
1466 Var(0)
1467 >>> get_var_index(v1)
1468 1
1469 >>> get_var_index(v2)
1470 0
1471 """
1472 if z3_debug():
1473 _z3_assert(is_var(a), "Z3 bound variable expected")
1474 return int(Z3_get_index_value(a.ctx.ref(), a.as_ast()))
1475
1476
unsigned Z3_API Z3_get_index_value(Z3_context c, Z3_ast a)
Return index of de-Bruijn bound variable.

◆ get_version()

get_version ( )

Definition at line 100 of file z3py.py.

100def get_version():
101 major = ctypes.c_uint(0)
102 minor = ctypes.c_uint(0)
103 build = ctypes.c_uint(0)
104 rev = ctypes.c_uint(0)
105 Z3_get_version(major, minor, build, rev)
106 return (major.value, minor.value, build.value, rev.value)
107
108
void Z3_API Z3_get_version(unsigned *major, unsigned *minor, unsigned *build_number, unsigned *revision_number)
Return Z3 version number information.

◆ get_version_string()

get_version_string ( )

Definition at line 91 of file z3py.py.

91def get_version_string():
92 major = ctypes.c_uint(0)
93 minor = ctypes.c_uint(0)
94 build = ctypes.c_uint(0)
95 rev = ctypes.c_uint(0)
96 Z3_get_version(major, minor, build, rev)
97 return "%s.%s.%s" % (major.value, minor.value, build.value)
98
99

◆ help_simplify()

help_simplify ( )
Return a string describing all options available for Z3 `simplify` procedure.

Definition at line 9615 of file z3py.py.

9615def help_simplify():
9616 """Return a string describing all options available for Z3 `simplify` procedure."""
9617 print(Z3_simplify_get_help(main_ctx().ref()))
9618
9619
Z3_string Z3_API Z3_simplify_get_help(Z3_context c)
Return a string describing all available parameters.

◆ If()

If (   a,
  b,
  c,
  ctx = None 
)
Create a Z3 if-then-else expression.

>>> x = Int('x')
>>> y = Int('y')
>>> max = If(x > y, x, y)
>>> max
If(x > y, x, y)
>>> simplify(max)
If(x <= y, y, x)

Definition at line 1490 of file z3py.py.

1490def If(a, b, c, ctx=None):
1491 """Create a Z3 if-then-else expression.
1492
1493 >>> x = Int('x')
1494 >>> y = Int('y')
1495 >>> max = If(x > y, x, y)
1496 >>> max
1497 If(x > y, x, y)
1498 >>> simplify(max)
1499 If(x <= y, y, x)
1500 """
1501 if isinstance(a, Probe) or isinstance(b, Tactic) or isinstance(c, Tactic):
1502 return Cond(a, b, c, ctx)
1503 else:
1504 ctx = _get_ctx(_ctx_from_ast_arg_list([a, b, c], ctx))
1505 s = BoolSort(ctx)
1506 a = s.cast(a)
1507 b, c = _coerce_exprs(b, c, ctx)
1508 if z3_debug():
1509 _z3_assert(a.ctx == b.ctx, "Context mismatch")
1510 return _to_expr_ref(Z3_mk_ite(ctx.ref(), a.as_ast(), b.as_ast(), c.as_ast()), ctx)
1511
1512
Z3_ast Z3_API Z3_mk_ite(Z3_context c, Z3_ast t1, Z3_ast t2, Z3_ast t3)
Create an AST node representing an if-then-else: ite(t1, t2, t3).

Referenced by BoolRef.__add__(), BoolRef.__mul__(), ArithRef.__mul__(), and ToReal().

◆ Implies()

Implies (   a,
  b,
  ctx = None 
)
Create a Z3 implies expression.

>>> p, q = Bools('p q')
>>> Implies(p, q)
Implies(p, q)

Definition at line 1924 of file z3py.py.

1924def Implies(a, b, ctx=None):
1925 """Create a Z3 implies expression.
1926
1927 >>> p, q = Bools('p q')
1928 >>> Implies(p, q)
1929 Implies(p, q)
1930 """
1931 ctx = _get_ctx(_ctx_from_ast_arg_list([a, b], ctx))
1932 s = BoolSort(ctx)
1933 a = s.cast(a)
1934 b = s.cast(b)
1935 return BoolRef(Z3_mk_implies(ctx.ref(), a.as_ast(), b.as_ast()), ctx)
1936
1937
Z3_ast Z3_API Z3_mk_implies(Z3_context c, Z3_ast t1, Z3_ast t2)
Create an AST node representing t1 implies t2.

◆ In()

In (   elem,
  set 
)

Definition at line 5456 of file z3py.py.

5456def In(elem, set):
5457 return FiniteSetMember(elem, set)
5458

◆ IndexOf()

IndexOf (   s,
  substr,
  offset = None 
)
Retrieve the index of substring within a string starting at a specified offset.
>>> simplify(IndexOf("abcabc", "bc", 0))
1
>>> simplify(IndexOf("abcabc", "bc", 2))
4

Definition at line 11912 of file z3py.py.

11912def IndexOf(s, substr, offset=None):
11913 """Retrieve the index of substring within a string starting at a specified offset.
11914 >>> simplify(IndexOf("abcabc", "bc", 0))
11915 1
11916 >>> simplify(IndexOf("abcabc", "bc", 2))
11917 4
11918 """
11919 if offset is None:
11920 offset = IntVal(0)
11921 ctx = None
11922 if is_expr(offset):
11923 ctx = offset.ctx
11924 ctx = _get_ctx2(s, substr, ctx)
11925 s = _coerce_seq(s, ctx)
11926 substr = _coerce_seq(substr, ctx)
11927 if _is_int(offset):
11928 offset = IntVal(offset, ctx)
11929 return ArithRef(Z3_mk_seq_index(s.ctx_ref(), s.as_ast(), substr.as_ast(), offset.as_ast()), s.ctx)
11930
11931
Z3_ast Z3_API Z3_mk_seq_index(Z3_context c, Z3_ast s, Z3_ast substr, Z3_ast offset)
Return index of the first occurrence of substr in s starting from offset offset. If s does not contai...

◆ InRe()

InRe (   s,
  re 
)
Create regular expression membership test
>>> re = Union(Re("a"),Re("b"))
>>> print (simplify(InRe("a", re)))
True
>>> print (simplify(InRe("b", re)))
True
>>> print (simplify(InRe("c", re)))
False

Definition at line 12061 of file z3py.py.

12061def InRe(s, re):
12062 """Create regular expression membership test
12063 >>> re = Union(Re("a"),Re("b"))
12064 >>> print (simplify(InRe("a", re)))
12065 True
12066 >>> print (simplify(InRe("b", re)))
12067 True
12068 >>> print (simplify(InRe("c", re)))
12069 False
12070 """
12071 s = _coerce_seq(s, re.ctx)
12072 return BoolRef(Z3_mk_seq_in_re(s.ctx_ref(), s.as_ast(), re.as_ast()), s.ctx)
12073
12074
Z3_ast Z3_API Z3_mk_seq_in_re(Z3_context c, Z3_ast seq, Z3_ast re)
Check if seq is in the language generated by the regular expression re.

◆ Int()

Int (   name,
  ctx = None 
)
Return an integer constant named `name`. If `ctx=None`, then the global context is used.

>>> x = Int('x')
>>> is_int(x)
True
>>> is_int(x + 1)
True

Definition at line 3414 of file z3py.py.

3414def Int(name, ctx=None):
3415 """Return an integer constant named `name`. If `ctx=None`, then the global context is used.
3416
3417 >>> x = Int('x')
3418 >>> is_int(x)
3419 True
3420 >>> is_int(x + 1)
3421 True
3422 """
3423 ctx = _get_ctx(ctx)
3424 return ArithRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), IntSort(ctx).ast), ctx)
3425
3426

Referenced by Ints(), and IntVector().

◆ Int2BV()

Int2BV (   a,
  num_bits 
)
Return the z3 expression Int2BV(a, num_bits).
It is a bit-vector of width num_bits and represents the
modulo of a by 2^num_bits

Definition at line 4169 of file z3py.py.

4169def Int2BV(a, num_bits):
4170 """Return the z3 expression Int2BV(a, num_bits).
4171 It is a bit-vector of width num_bits and represents the
4172 modulo of a by 2^num_bits
4173 """
4174 ctx = a.ctx
4175 return BitVecRef(Z3_mk_int2bv(ctx.ref(), num_bits, a.as_ast()), ctx)
4176
4177
Z3_ast Z3_API Z3_mk_int2bv(Z3_context c, unsigned n, Z3_ast t1)
Create an n bit bit-vector from the integer argument t1.

◆ Intersect()

Intersect ( *  args)
Create intersection of regular expressions.
>>> re = Intersect(Re("a"), Re("b"), Re("c"))

Definition at line 12103 of file z3py.py.

12103def Intersect(*args):
12104 """Create intersection of regular expressions.
12105 >>> re = Intersect(Re("a"), Re("b"), Re("c"))
12106 """
12107 args = _get_args(args)
12108 sz = len(args)
12109 if z3_debug():
12110 _z3_assert(sz > 0, "At least one argument expected.")
12111 arg0 = args[0]
12112 if is_finite_set(arg0):
12113 for a in args[1:]:
12114 if not is_finite_set(a):
12115 raise Z3Exception("All arguments must be regular expressions or finite sets.")
12116 arg0 = arg0 & a
12117 return arg0
12118 if z3_debug():
12119 _z3_assert(all([is_re(a) for a in args]), "All arguments must be regular expressions.")
12120 if sz == 1:
12121 return args[0]
12122 ctx = args[0].ctx
12123 v = (Ast * sz)()
12124 for i in range(sz):
12125 v[i] = args[i].as_ast()
12126 return ReRef(Z3_mk_re_intersect(ctx.ref(), sz, v), ctx)
12127
12128
Z3_ast Z3_API Z3_mk_re_intersect(Z3_context c, unsigned n, Z3_ast const args[])
Create the intersection of the regular languages.

◆ Ints()

Ints (   names,
  ctx = None 
)
Return a tuple of Integer constants.

>>> x, y, z = Ints('x y z')
>>> Sum(x, y, z)
x + y + z

Definition at line 3427 of file z3py.py.

3427def Ints(names, ctx=None):
3428 """Return a tuple of Integer constants.
3429
3430 >>> x, y, z = Ints('x y z')
3431 >>> Sum(x, y, z)
3432 x + y + z
3433 """
3434 ctx = _get_ctx(ctx)
3435 if isinstance(names, str):
3436 names = names.split(" ")
3437 return [Int(name, ctx) for name in names]
3438
3439

◆ IntSort()

IntSort (   ctx = None)
Return the integer sort in the given context. If `ctx=None`, then the global context is used.

>>> IntSort()
Int
>>> x = Const('x', IntSort())
>>> is_int(x)
True
>>> x.sort() == IntSort()
True
>>> x.sort() == BoolSort()
False

Definition at line 3304 of file z3py.py.

3304def IntSort(ctx=None):
3305 """Return the integer sort in the given context. If `ctx=None`, then the global context is used.
3306
3307 >>> IntSort()
3308 Int
3309 >>> x = Const('x', IntSort())
3310 >>> is_int(x)
3311 True
3312 >>> x.sort() == IntSort()
3313 True
3314 >>> x.sort() == BoolSort()
3315 False
3316 """
3317 ctx = _get_ctx(ctx)
3318 return ArithSortRef(Z3_mk_int_sort(ctx.ref()), ctx)
3319
3320
Z3_sort Z3_API Z3_mk_int_sort(Z3_context c)
Create the integer type.

Referenced by FreshInt(), Int(), and IntVal().

◆ IntToStr()

IntToStr (   s)
Convert integer expression to string

Definition at line 12003 of file z3py.py.

12003def IntToStr(s):
12004 """Convert integer expression to string"""
12005 if not is_expr(s):
12006 s = _py2expr(s)
12007 return SeqRef(Z3_mk_int_to_str(s.ctx_ref(), s.as_ast()), s.ctx)
12008
12009
Z3_ast Z3_API Z3_mk_int_to_str(Z3_context c, Z3_ast s)
Integer to string conversion.

◆ IntVal()

IntVal (   val,
  ctx = None 
)
Return a Z3 integer value. If `ctx=None`, then the global context is used.

>>> IntVal(1)
1
>>> IntVal("100")
100

Definition at line 3350 of file z3py.py.

3350def IntVal(val, ctx=None):
3351 """Return a Z3 integer value. If `ctx=None`, then the global context is used.
3352
3353 >>> IntVal(1)
3354 1
3355 >>> IntVal("100")
3356 100
3357 """
3358 ctx = _get_ctx(ctx)
3359 return IntNumRef(Z3_mk_numeral(ctx.ref(), _to_int_str(val), IntSort(ctx).ast), ctx)
3360
3361

Referenced by BoolRef.__mul__(), and _py2expr().

◆ IntVector()

IntVector (   prefix,
  sz,
  ctx = None 
)
Return a list of integer constants of size `sz`.

>>> X = IntVector('x', 3)
>>> X
[x__0, x__1, x__2]
>>> Sum(X)
x__0 + x__1 + x__2

Definition at line 3440 of file z3py.py.

3440def IntVector(prefix, sz, ctx=None):
3441 """Return a list of integer constants of size `sz`.
3442
3443 >>> X = IntVector('x', 3)
3444 >>> X
3445 [x__0, x__1, x__2]
3446 >>> Sum(X)
3447 x__0 + x__1 + x__2
3448 """
3449 ctx = _get_ctx(ctx)
3450 return [Int("%s__%s" % (prefix, i), ctx) for i in range(sz)]
3451
3452

◆ is_add()

bool is_add ( Any  a)
Return `True` if `a` is an expression of the form b + c.

>>> x, y = Ints('x y')
>>> is_add(x + y)
True
>>> is_add(x - y)
False

Definition at line 2952 of file z3py.py.

2952def is_add(a : Any) -> bool:
2953 """Return `True` if `a` is an expression of the form b + c.
2954
2955 >>> x, y = Ints('x y')
2956 >>> is_add(x + y)
2957 True
2958 >>> is_add(x - y)
2959 False
2960 """
2961 return is_app_of(a, Z3_OP_ADD)
2962
2963

◆ is_algebraic_value()

is_algebraic_value (   a)
Return `True` if `a` is an algebraic value of sort Real.

>>> is_algebraic_value(RealVal("3/5"))
False
>>> n = simplify(Sqrt(2))
>>> n
1.4142135623?
>>> is_algebraic_value(n)
True

Definition at line 2938 of file z3py.py.

2938def is_algebraic_value(a):
2939 """Return `True` if `a` is an algebraic value of sort Real.
2940
2941 >>> is_algebraic_value(RealVal("3/5"))
2942 False
2943 >>> n = simplify(Sqrt(2))
2944 >>> n
2945 1.4142135623?
2946 >>> is_algebraic_value(n)
2947 True
2948 """
2949 return is_arith(a) and a.is_real() and _is_algebraic(a.ctx, a.as_ast())
2950
2951

◆ is_and()

bool is_and ( Any  a)
Return `True` if `a` is a Z3 and expression.

>>> p, q = Bools('p q')
>>> is_and(And(p, q))
True
>>> is_and(Or(p, q))
False

Definition at line 1760 of file z3py.py.

1760def is_and(a : Any) -> bool:
1761 """Return `True` if `a` is a Z3 and expression.
1762
1763 >>> p, q = Bools('p q')
1764 >>> is_and(And(p, q))
1765 True
1766 >>> is_and(Or(p, q))
1767 False
1768 """
1769 return is_app_of(a, Z3_OP_AND)
1770
1771

◆ is_app()

is_app (   a)
Return `True` if `a` is a Z3 function application.

Note that, constants are function applications with 0 arguments.

>>> a = Int('a')
>>> is_app(a)
True
>>> is_app(a + 1)
True
>>> is_app(IntSort())
False
>>> is_app(1)
False
>>> is_app(IntVal(1))
True
>>> x = Int('x')
>>> is_app(ForAll(x, x >= 0))
False

Definition at line 1374 of file z3py.py.

1374def is_app(a):
1375 """Return `True` if `a` is a Z3 function application.
1376
1377 Note that, constants are function applications with 0 arguments.
1378
1379 >>> a = Int('a')
1380 >>> is_app(a)
1381 True
1382 >>> is_app(a + 1)
1383 True
1384 >>> is_app(IntSort())
1385 False
1386 >>> is_app(1)
1387 False
1388 >>> is_app(IntVal(1))
1389 True
1390 >>> x = Int('x')
1391 >>> is_app(ForAll(x, x >= 0))
1392 False
1393 """
1394 if not isinstance(a, ExprRef):
1395 return False
1396 k = _ast_kind(a.ctx, a)
1397 return k == Z3_NUMERAL_AST or k == Z3_APP_AST
1398
1399

Referenced by _mk_quantifier(), ExprRef.arg(), ExprRef.children(), ExprRef.decl(), is_app_of(), is_const(), ExprRef.kind(), Lambda(), ExprRef.num_args(), RecAddDefinition(), and ExprRef.update().

◆ is_app_of()

is_app_of (   a,
  k 
)
Return `True` if `a` is an application of the given kind `k`.

>>> x = Int('x')
>>> n = x + 1
>>> is_app_of(n, Z3_OP_ADD)
True
>>> is_app_of(n, Z3_OP_MUL)
False

Definition at line 1477 of file z3py.py.

1477def is_app_of(a, k):
1478 """Return `True` if `a` is an application of the given kind `k`.
1479
1480 >>> x = Int('x')
1481 >>> n = x + 1
1482 >>> is_app_of(n, Z3_OP_ADD)
1483 True
1484 >>> is_app_of(n, Z3_OP_MUL)
1485 False
1486 """
1487 return is_app(a) and a.kind() == k
1488
1489

Referenced by is_add(), is_and(), is_const_array(), is_default(), is_distinct(), is_div(), is_eq(), is_false(), is_ge(), is_gt(), is_idiv(), is_implies(), is_is_int(), is_K(), is_le(), is_lt(), is_map(), is_mod(), is_mul(), is_not(), is_or(), is_select(), is_store(), is_sub(), is_to_int(), is_to_real(), and is_true().

◆ is_arith()

is_arith (   a)
Return `True` if `a` is an arithmetical expression.

>>> x = Int('x')
>>> is_arith(x)
True
>>> is_arith(x + 1)
True
>>> is_arith(1)
False
>>> is_arith(IntVal(1))
True
>>> y = Real('y')
>>> is_arith(y)
True
>>> is_arith(y + 1)
True

Definition at line 2825 of file z3py.py.

2825def is_arith(a):
2826 """Return `True` if `a` is an arithmetical expression.
2827
2828 >>> x = Int('x')
2829 >>> is_arith(x)
2830 True
2831 >>> is_arith(x + 1)
2832 True
2833 >>> is_arith(1)
2834 False
2835 >>> is_arith(IntVal(1))
2836 True
2837 >>> y = Real('y')
2838 >>> is_arith(y)
2839 True
2840 >>> is_arith(y + 1)
2841 True
2842 """
2843 return isinstance(a, ArithRef)
2844
2845

Referenced by is_algebraic_value(), is_int(), is_int_value(), is_rational_value(), and is_real().

◆ is_arith_sort()

bool is_arith_sort ( Any  s)
Return `True` if s is an arithmetical sort (type).

>>> is_arith_sort(IntSort())
True
>>> is_arith_sort(RealSort())
True
>>> is_arith_sort(BoolSort())
False
>>> n = Int('x') + 1
>>> is_arith_sort(n.sort())
True

Definition at line 2513 of file z3py.py.

2513def is_arith_sort(s : Any) -> bool:
2514 """Return `True` if s is an arithmetical sort (type).
2515
2516 >>> is_arith_sort(IntSort())
2517 True
2518 >>> is_arith_sort(RealSort())
2519 True
2520 >>> is_arith_sort(BoolSort())
2521 False
2522 >>> n = Int('x') + 1
2523 >>> is_arith_sort(n.sort())
2524 True
2525 """
2526 return isinstance(s, ArithSortRef)
2527
2528

Referenced by ArithSortRef.subsort().

◆ is_array()

bool is_array ( Any  a)
Return `True` if `a` is a Z3 array expression.

>>> a = Array('a', IntSort(), IntSort())
>>> is_array(a)
True
>>> is_array(Store(a, 0, 1))
True
>>> is_array(a[0])
False

Definition at line 4846 of file z3py.py.

4846def is_array(a : Any) -> bool:
4847 """Return `True` if `a` is a Z3 array expression.
4848
4849 >>> a = Array('a', IntSort(), IntSort())
4850 >>> is_array(a)
4851 True
4852 >>> is_array(Store(a, 0, 1))
4853 True
4854 >>> is_array(a[0])
4855 False
4856 """
4857 return isinstance(a, ArrayRef)
4858
4859

Referenced by Ext(), and Map().

◆ is_array_sort()

is_array_sort (   a)

Definition at line 4842 of file z3py.py.

4842def is_array_sort(a):
4843 return Z3_get_sort_kind(a.ctx.ref(), Z3_get_sort(a.ctx.ref(), a.ast)) == Z3_ARRAY_SORT
4844
4845

Referenced by Default(), Ext(), Select(), and Update().

◆ is_as_array()

is_as_array (   n)
Return true if n is a Z3 expression of the form (_ as-array f).

Definition at line 7341 of file z3py.py.

7341def is_as_array(n):
7342 """Return true if n is a Z3 expression of the form (_ as-array f)."""
7343 return isinstance(n, ExprRef) and Z3_is_as_array(n.ctx.ref(), n.as_ast())
7344
7345
bool Z3_API Z3_is_as_array(Z3_context c, Z3_ast a)
The (_ as-array f) AST node is a construct for assigning interpretations for arrays in Z3....

Referenced by get_as_array_func(), and ModelRef.get_interp().

◆ is_ast()

bool is_ast ( Any  a)
Return `True` if `a` is an AST node.

>>> is_ast(10)
False
>>> is_ast(IntVal(10))
True
>>> is_ast(Int('x'))
True
>>> is_ast(BoolSort())
True
>>> is_ast(Function('f', IntSort(), IntSort()))
True
>>> is_ast("x")
False
>>> is_ast(Solver())
False

Definition at line 482 of file z3py.py.

482def is_ast(a : Any) -> bool:
483 """Return `True` if `a` is an AST node.
484
485 >>> is_ast(10)
486 False
487 >>> is_ast(IntVal(10))
488 True
489 >>> is_ast(Int('x'))
490 True
491 >>> is_ast(BoolSort())
492 True
493 >>> is_ast(Function('f', IntSort(), IntSort()))
494 True
495 >>> is_ast("x")
496 False
497 >>> is_ast(Solver())
498 False
499 """
500 return isinstance(a, AstRef)
501
502

Referenced by _ast_kind(), _ctx_from_ast_arg_list(), eq(), and AstRef.eq().

◆ is_bool()

bool is_bool ( Any  a)
Return `True` if `a` is a Z3 Boolean expression.

>>> p = Bool('p')
>>> is_bool(p)
True
>>> q = Bool('q')
>>> is_bool(And(p, q))
True
>>> x = Real('x')
>>> is_bool(x)
False
>>> is_bool(x == 0)
True

Definition at line 1710 of file z3py.py.

1710def is_bool(a : Any) -> bool:
1711 """Return `True` if `a` is a Z3 Boolean expression.
1712
1713 >>> p = Bool('p')
1714 >>> is_bool(p)
1715 True
1716 >>> q = Bool('q')
1717 >>> is_bool(And(p, q))
1718 True
1719 >>> x = Real('x')
1720 >>> is_bool(x)
1721 False
1722 >>> is_bool(x == 0)
1723 True
1724 """
1725 return isinstance(a, BoolRef)
1726
1727

Referenced by _mk_quantifier().

◆ is_bv()

is_bv (   a)
Return `True` if `a` is a Z3 bit-vector expression.

>>> b = BitVec('b', 32)
>>> is_bv(b)
True
>>> is_bv(b + 10)
True
>>> is_bv(Int('x'))
False

Definition at line 4117 of file z3py.py.

4117def is_bv(a):
4118 """Return `True` if `a` is a Z3 bit-vector expression.
4119
4120 >>> b = BitVec('b', 32)
4121 >>> is_bv(b)
4122 True
4123 >>> is_bv(b + 10)
4124 True
4125 >>> is_bv(Int('x'))
4126 False
4127 """
4128 return isinstance(a, BitVecRef)
4129
4130

Referenced by _check_bv_args(), BV2Int(), BVRedAnd(), BVRedOr(), BVSNegNoOverflow(), Concat(), Extract(), is_bv_value(), RepeatBitVec(), SignExt(), and ZeroExt().

◆ is_bv_sort()

is_bv_sort (   s)
Return True if `s` is a Z3 bit-vector sort.

>>> is_bv_sort(BitVecSort(32))
True
>>> is_bv_sort(IntSort())
False

Definition at line 3644 of file z3py.py.

3644def is_bv_sort(s):
3645 """Return True if `s` is a Z3 bit-vector sort.
3646
3647 >>> is_bv_sort(BitVecSort(32))
3648 True
3649 >>> is_bv_sort(IntSort())
3650 False
3651 """
3652 return isinstance(s, BitVecSortRef)
3653
3654

Referenced by BitVecVal(), and BitVecSortRef.subsort().

◆ is_bv_value()

is_bv_value (   a)
Return `True` if `a` is a Z3 bit-vector numeral value.

>>> b = BitVec('b', 32)
>>> is_bv_value(b)
False
>>> b = BitVecVal(10, 32)
>>> b
10
>>> is_bv_value(b)
True

Definition at line 4131 of file z3py.py.

4131def is_bv_value(a):
4132 """Return `True` if `a` is a Z3 bit-vector numeral value.
4133
4134 >>> b = BitVec('b', 32)
4135 >>> is_bv_value(b)
4136 False
4137 >>> b = BitVecVal(10, 32)
4138 >>> b
4139 10
4140 >>> is_bv_value(b)
4141 True
4142 """
4143 return is_bv(a) and _is_numeral(a.ctx, a.as_ast())
4144
4145

◆ is_const()

is_const (   a)
Return `True` if `a` is Z3 constant/variable expression.

>>> a = Int('a')
>>> is_const(a)
True
>>> is_const(a + 1)
False
>>> is_const(1)
False
>>> is_const(IntVal(1))
True
>>> x = Int('x')
>>> is_const(ForAll(x, x >= 0))
False

Definition at line 1400 of file z3py.py.

1400def is_const(a):
1401 """Return `True` if `a` is Z3 constant/variable expression.
1402
1403 >>> a = Int('a')
1404 >>> is_const(a)
1405 True
1406 >>> is_const(a + 1)
1407 False
1408 >>> is_const(1)
1409 False
1410 >>> is_const(IntVal(1))
1411 True
1412 >>> x = Int('x')
1413 >>> is_const(ForAll(x, x >= 0))
1414 False
1415 """
1416 return is_app(a) and a.num_args() == 0
1417
1418

Referenced by ModelRef.__getitem__(), _mk_quantifier(), Solver.assert_and_track(), and ModelRef.get_interp().

◆ is_const_array()

is_const_array (   a)
Return `True` if `a` is a Z3 constant array.

>>> a = K(IntSort(), 10)
>>> is_const_array(a)
True
>>> a = Array('a', IntSort(), IntSort())
>>> is_const_array(a)
False

Definition at line 4860 of file z3py.py.

4860def is_const_array(a):
4861 """Return `True` if `a` is a Z3 constant array.
4862
4863 >>> a = K(IntSort(), 10)
4864 >>> is_const_array(a)
4865 True
4866 >>> a = Array('a', IntSort(), IntSort())
4867 >>> is_const_array(a)
4868 False
4869 """
4870 return is_app_of(a, Z3_OP_CONST_ARRAY)
4871
4872

◆ is_default()

is_default (   a)
Return `True` if `a` is a Z3 default array expression.
>>> d = Default(K(IntSort(), 10))
>>> is_default(d)
True

Definition at line 4902 of file z3py.py.

4902def is_default(a):
4903 """Return `True` if `a` is a Z3 default array expression.
4904 >>> d = Default(K(IntSort(), 10))
4905 >>> is_default(d)
4906 True
4907 """
4908 return is_app_of(a, Z3_OP_ARRAY_DEFAULT)
4909
4910

◆ is_distinct()

bool is_distinct ( Any  a)
Return `True` if `a` is a Z3 distinct expression.

>>> x, y, z = Ints('x y z')
>>> is_distinct(x == y)
False
>>> is_distinct(Distinct(x, y, z))
True

Definition at line 1818 of file z3py.py.

1818def is_distinct(a : Any) -> bool:
1819 """Return `True` if `a` is a Z3 distinct expression.
1820
1821 >>> x, y, z = Ints('x y z')
1822 >>> is_distinct(x == y)
1823 False
1824 >>> is_distinct(Distinct(x, y, z))
1825 True
1826 """
1827 return is_app_of(a, Z3_OP_DISTINCT)
1828
1829

◆ is_div()

bool is_div ( Any  a)
Return `True` if `a` is an expression of the form b / c.

>>> x, y = Reals('x y')
>>> is_div(x / y)
True
>>> is_div(x + y)
False
>>> x, y = Ints('x y')
>>> is_div(x / y)
False
>>> is_idiv(x / y)
True

Definition at line 2988 of file z3py.py.

2988def is_div(a : Any) -> bool:
2989 """Return `True` if `a` is an expression of the form b / c.
2990
2991 >>> x, y = Reals('x y')
2992 >>> is_div(x / y)
2993 True
2994 >>> is_div(x + y)
2995 False
2996 >>> x, y = Ints('x y')
2997 >>> is_div(x / y)
2998 False
2999 >>> is_idiv(x / y)
3000 True
3001 """
3002 return is_app_of(a, Z3_OP_DIV)
3003
3004

◆ is_eq()

bool is_eq ( Any  a)
Return `True` if `a` is a Z3 equality expression.

>>> x, y = Ints('x y')
>>> is_eq(x == y)
True

Definition at line 1808 of file z3py.py.

1808def is_eq(a : Any) -> bool:
1809 """Return `True` if `a` is a Z3 equality expression.
1810
1811 >>> x, y = Ints('x y')
1812 >>> is_eq(x == y)
1813 True
1814 """
1815 return is_app_of(a, Z3_OP_EQ)
1816
1817

Referenced by AstRef.__bool__().

◆ is_expr()

is_expr (   a)
Return `True` if `a` is a Z3 expression.

>>> a = Int('a')
>>> is_expr(a)
True
>>> is_expr(a + 1)
True
>>> is_expr(IntSort())
False
>>> is_expr(1)
False
>>> is_expr(IntVal(1))
True
>>> x = Int('x')
>>> is_expr(ForAll(x, x >= 0))
True
>>> is_expr(FPVal(1.0))
True

Definition at line 1351 of file z3py.py.

1351def is_expr(a):
1352 """Return `True` if `a` is a Z3 expression.
1353
1354 >>> a = Int('a')
1355 >>> is_expr(a)
1356 True
1357 >>> is_expr(a + 1)
1358 True
1359 >>> is_expr(IntSort())
1360 False
1361 >>> is_expr(1)
1362 False
1363 >>> is_expr(IntVal(1))
1364 True
1365 >>> x = Int('x')
1366 >>> is_expr(ForAll(x, x >= 0))
1367 True
1368 >>> is_expr(FPVal(1.0))
1369 True
1370 """
1371 return isinstance(a, ExprRef)
1372
1373

Referenced by _coerce_expr_list(), _coerce_expr_merge(), _coerce_exprs(), _mk_quantifier(), _py2expr(), SortRef.cast(), ArithSortRef.cast(), BitVecSortRef.cast(), FiniteSetSortRef.cast(), Cbrt(), Concat(), is_var(), K(), MultiPattern(), Sqrt(), ExprRef.update(), DatatypeRef.update_field(), and ModelRef.update_value().

◆ is_false()

bool is_false ( Any  a)
Return `True` if `a` is the Z3 false expression.

>>> p = Bool('p')
>>> is_false(p)
False
>>> is_false(False)
False
>>> is_false(BoolVal(False))
True

Definition at line 1746 of file z3py.py.

1746def is_false(a : Any) -> bool:
1747 """Return `True` if `a` is the Z3 false expression.
1748
1749 >>> p = Bool('p')
1750 >>> is_false(p)
1751 False
1752 >>> is_false(False)
1753 False
1754 >>> is_false(BoolVal(False))
1755 True
1756 """
1757 return is_app_of(a, Z3_OP_FALSE)
1758
1759

Referenced by AstRef.__bool__(), and BoolRef.py_value().

◆ is_finite_domain()

is_finite_domain (   a)
Return `True` if `a` is a Z3 finite-domain expression.

>>> s = FiniteDomainSort('S', 100)
>>> b = Const('b', s)
>>> is_finite_domain(b)
True
>>> is_finite_domain(Int('x'))
False

Definition at line 8460 of file z3py.py.

8460def is_finite_domain(a):
8461 """Return `True` if `a` is a Z3 finite-domain expression.
8462
8463 >>> s = FiniteDomainSort('S', 100)
8464 >>> b = Const('b', s)
8465 >>> is_finite_domain(b)
8466 True
8467 >>> is_finite_domain(Int('x'))
8468 False
8469 """
8470 return isinstance(a, FiniteDomainRef)
8471
8472

◆ is_finite_domain_sort()

is_finite_domain_sort (   s)
Return True if `s` is a Z3 finite-domain sort.

>>> is_finite_domain_sort(FiniteDomainSort('S', 100))
True
>>> is_finite_domain_sort(IntSort())
False

Definition at line 8437 of file z3py.py.

8437def is_finite_domain_sort(s):
8438 """Return True if `s` is a Z3 finite-domain sort.
8439
8440 >>> is_finite_domain_sort(FiniteDomainSort('S', 100))
8441 True
8442 >>> is_finite_domain_sort(IntSort())
8443 False
8444 """
8445 return isinstance(s, FiniteDomainSortRef)
8446
8447

◆ is_finite_domain_value()

is_finite_domain_value (   a)
Return `True` if `a` is a Z3 finite-domain value.

>>> s = FiniteDomainSort('S', 100)
>>> b = Const('b', s)
>>> is_finite_domain_value(b)
False
>>> b = FiniteDomainVal(10, s)
>>> b
10
>>> is_finite_domain_value(b)
True

Definition at line 8514 of file z3py.py.

8514def is_finite_domain_value(a):
8515 """Return `True` if `a` is a Z3 finite-domain value.
8516
8517 >>> s = FiniteDomainSort('S', 100)
8518 >>> b = Const('b', s)
8519 >>> is_finite_domain_value(b)
8520 False
8521 >>> b = FiniteDomainVal(10, s)
8522 >>> b
8523 10
8524 >>> is_finite_domain_value(b)
8525 True
8526 """
8527 return is_finite_domain(a) and _is_numeral(a.ctx, a.as_ast())
8528
8529

◆ is_finite_set()

is_finite_set (   a)
Return True if a is a Z3 finite set expression.
>>> s = FiniteSetSort(IntSort())
>>> is_finite_set(FiniteSetEmpty(s))
True
>>> is_finite_set(IntVal(1))
False

Definition at line 5346 of file z3py.py.

5346def is_finite_set(a):
5347 """Return True if a is a Z3 finite set expression.
5348 >>> s = FiniteSetSort(IntSort())
5349 >>> is_finite_set(FiniteSetEmpty(s))
5350 True
5351 >>> is_finite_set(IntVal(1))
5352 False
5353 """
5354 return isinstance(a, FiniteSetRef)
5355
5356

Referenced by IsMember(), IsSubset(), SetAdd(), SetDel(), SetDifference(), SetIntersect(), and SetUnion().

◆ is_finite_set_sort()

is_finite_set_sort (   s)
Return True if s is a Z3 finite set sort.
>>> is_finite_set_sort(FiniteSetSort(IntSort()))
True
>>> is_finite_set_sort(IntSort())
False

Definition at line 5357 of file z3py.py.

5357def is_finite_set_sort(s):
5358 """Return True if s is a Z3 finite set sort.
5359 >>> is_finite_set_sort(FiniteSetSort(IntSort()))
5360 True
5361 >>> is_finite_set_sort(IntSort())
5362 False
5363 """
5364 return isinstance(s, FiniteSetSortRef)
5365
5366

Referenced by EmptySet().

◆ is_fp()

is_fp (   a)
Return `True` if `a` is a Z3 floating-point expression.

>>> b = FP('b', FPSort(8, 24))
>>> is_fp(b)
True
>>> is_fp(b + 1.0)
True
>>> is_fp(Int('x'))
False

Definition at line 10701 of file z3py.py.

10701def is_fp(a):
10702 """Return `True` if `a` is a Z3 floating-point expression.
10703
10704 >>> b = FP('b', FPSort(8, 24))
10705 >>> is_fp(b)
10706 True
10707 >>> is_fp(b + 1.0)
10708 True
10709 >>> is_fp(Int('x'))
10710 False
10711 """
10712 return isinstance(a, FPRef)
10713
10714

◆ is_fp_sort()

is_fp_sort (   s)
Return True if `s` is a Z3 floating-point sort.

>>> is_fp_sort(FPSort(8, 24))
True
>>> is_fp_sort(IntSort())
False

Definition at line 10275 of file z3py.py.

10275def is_fp_sort(s):
10276 """Return True if `s` is a Z3 floating-point sort.
10277
10278 >>> is_fp_sort(FPSort(8, 24))
10279 True
10280 >>> is_fp_sort(IntSort())
10281 False
10282 """
10283 return isinstance(s, FPSortRef)
10284
10285

◆ is_fp_value()

is_fp_value (   a)
Return `True` if `a` is a Z3 floating-point numeral value.

>>> b = FP('b', FPSort(8, 24))
>>> is_fp_value(b)
False
>>> b = FPVal(1.0, FPSort(8, 24))
>>> b
1
>>> is_fp_value(b)
True

Definition at line 10715 of file z3py.py.

10715def is_fp_value(a):
10716 """Return `True` if `a` is a Z3 floating-point numeral value.
10717
10718 >>> b = FP('b', FPSort(8, 24))
10719 >>> is_fp_value(b)
10720 False
10721 >>> b = FPVal(1.0, FPSort(8, 24))
10722 >>> b
10723 1
10724 >>> is_fp_value(b)
10725 True
10726 """
10727 return is_fp(a) and _is_numeral(a.ctx, a.ast)
10728
10729

◆ is_fprm()

is_fprm (   a)
Return `True` if `a` is a Z3 floating-point rounding mode expression.

>>> rm = RNE()
>>> is_fprm(rm)
True
>>> rm = 1.0
>>> is_fprm(rm)
False

Definition at line 10535 of file z3py.py.

10535def is_fprm(a):
10536 """Return `True` if `a` is a Z3 floating-point rounding mode expression.
10537
10538 >>> rm = RNE()
10539 >>> is_fprm(rm)
10540 True
10541 >>> rm = 1.0
10542 >>> is_fprm(rm)
10543 False
10544 """
10545 return isinstance(a, FPRMRef)
10546
10547

◆ is_fprm_sort()

is_fprm_sort (   s)
Return True if `s` is a Z3 floating-point rounding mode sort.

>>> is_fprm_sort(FPSort(8, 24))
False
>>> is_fprm_sort(RNE().sort())
True

Definition at line 10286 of file z3py.py.

10286def is_fprm_sort(s):
10287 """Return True if `s` is a Z3 floating-point rounding mode sort.
10288
10289 >>> is_fprm_sort(FPSort(8, 24))
10290 False
10291 >>> is_fprm_sort(RNE().sort())
10292 True
10293 """
10294 return isinstance(s, FPRMSortRef)
10295
10296# FP Expressions
10297
10298

◆ is_fprm_value()

is_fprm_value (   a)
Return `True` if `a` is a Z3 floating-point rounding mode numeral value.

Definition at line 10548 of file z3py.py.

10548def is_fprm_value(a):
10549 """Return `True` if `a` is a Z3 floating-point rounding mode numeral value."""
10550 return is_fprm(a) and _is_numeral(a.ctx, a.ast)
10551
10552# FP Numerals
10553
10554

◆ is_func_decl()

is_func_decl (   a)
Return `True` if `a` is a Z3 function declaration.

>>> f = Function('f', IntSort(), IntSort())
>>> is_func_decl(f)
True
>>> x = Real('x')
>>> is_func_decl(x)
False

Definition at line 909 of file z3py.py.

909def is_func_decl(a):
910 """Return `True` if `a` is a Z3 function declaration.
911
912 >>> f = Function('f', IntSort(), IntSort())
913 >>> is_func_decl(f)
914 True
915 >>> x = Real('x')
916 >>> is_func_decl(x)
917 False
918 """
919 return isinstance(a, FuncDeclRef)
920
921

Referenced by Map(), DatatypeRef.update_field(), and ModelRef.update_value().

◆ is_ge()

bool is_ge ( Any  a)
Return `True` if `a` is an expression of the form b >= c.

>>> x, y = Ints('x y')
>>> is_ge(x >= y)
True
>>> is_ge(x == y)
False

Definition at line 3053 of file z3py.py.

3053def is_ge(a : Any) -> bool:
3054 """Return `True` if `a` is an expression of the form b >= c.
3055
3056 >>> x, y = Ints('x y')
3057 >>> is_ge(x >= y)
3058 True
3059 >>> is_ge(x == y)
3060 False
3061 """
3062 return is_app_of(a, Z3_OP_GE)
3063
3064

◆ is_gt()

bool is_gt ( Any  a)
Return `True` if `a` is an expression of the form b > c.

>>> x, y = Ints('x y')
>>> is_gt(x > y)
True
>>> is_gt(x == y)
False

Definition at line 3065 of file z3py.py.

3065def is_gt(a : Any) -> bool:
3066 """Return `True` if `a` is an expression of the form b > c.
3067
3068 >>> x, y = Ints('x y')
3069 >>> is_gt(x > y)
3070 True
3071 >>> is_gt(x == y)
3072 False
3073 """
3074 return is_app_of(a, Z3_OP_GT)
3075
3076

◆ is_idiv()

bool is_idiv ( Any  a)
Return `True` if `a` is an expression of the form b div c.

>>> x, y = Ints('x y')
>>> is_idiv(x / y)
True
>>> is_idiv(x + y)
False

Definition at line 3005 of file z3py.py.

3005def is_idiv(a : Any) -> bool:
3006 """Return `True` if `a` is an expression of the form b div c.
3007
3008 >>> x, y = Ints('x y')
3009 >>> is_idiv(x / y)
3010 True
3011 >>> is_idiv(x + y)
3012 False
3013 """
3014 return is_app_of(a, Z3_OP_IDIV)
3015
3016

◆ is_implies()

bool is_implies ( Any  a)
Return `True` if `a` is a Z3 implication expression.

>>> p, q = Bools('p q')
>>> is_implies(Implies(p, q))
True
>>> is_implies(And(p, q))
False

Definition at line 1784 of file z3py.py.

1784def is_implies(a : Any) -> bool:
1785 """Return `True` if `a` is a Z3 implication expression.
1786
1787 >>> p, q = Bools('p q')
1788 >>> is_implies(Implies(p, q))
1789 True
1790 >>> is_implies(And(p, q))
1791 False
1792 """
1793 return is_app_of(a, Z3_OP_IMPLIES)
1794
1795

◆ is_int()

bool is_int (   a)
Return `True` if `a` is an integer expression.

>>> x = Int('x')
>>> is_int(x + 1)
True
>>> is_int(1)
False
>>> is_int(IntVal(1))
True
>>> y = Real('y')
>>> is_int(y)
False
>>> is_int(y + 1)
False

Definition at line 2846 of file z3py.py.

2846def is_int(a) -> bool:
2847 """Return `True` if `a` is an integer expression.
2848
2849 >>> x = Int('x')
2850 >>> is_int(x + 1)
2851 True
2852 >>> is_int(1)
2853 False
2854 >>> is_int(IntVal(1))
2855 True
2856 >>> y = Real('y')
2857 >>> is_int(y)
2858 False
2859 >>> is_int(y + 1)
2860 False
2861 """
2862 return is_arith(a) and a.is_int()
2863
2864

◆ is_int_value()

is_int_value (   a)
Return `True` if `a` is an integer value of sort Int.

>>> is_int_value(IntVal(1))
True
>>> is_int_value(1)
False
>>> is_int_value(Int('x'))
False
>>> n = Int('x') + 1
>>> n
x + 1
>>> n.arg(1)
1
>>> is_int_value(n.arg(1))
True
>>> is_int_value(RealVal("1/3"))
False
>>> is_int_value(RealVal(1))
False

Definition at line 2892 of file z3py.py.

2892def is_int_value(a):
2893 """Return `True` if `a` is an integer value of sort Int.
2894
2895 >>> is_int_value(IntVal(1))
2896 True
2897 >>> is_int_value(1)
2898 False
2899 >>> is_int_value(Int('x'))
2900 False
2901 >>> n = Int('x') + 1
2902 >>> n
2903 x + 1
2904 >>> n.arg(1)
2905 1
2906 >>> is_int_value(n.arg(1))
2907 True
2908 >>> is_int_value(RealVal("1/3"))
2909 False
2910 >>> is_int_value(RealVal(1))
2911 False
2912 """
2913 return is_arith(a) and a.is_int() and _is_numeral(a.ctx, a.as_ast())
2914
2915

◆ is_is_int()

bool is_is_int ( Any  a)
Return `True` if `a` is an expression of the form IsInt(b).

>>> x = Real('x')
>>> is_is_int(IsInt(x))
True
>>> is_is_int(x)
False

Definition at line 3077 of file z3py.py.

3077def is_is_int(a : Any) -> bool:
3078 """Return `True` if `a` is an expression of the form IsInt(b).
3079
3080 >>> x = Real('x')
3081 >>> is_is_int(IsInt(x))
3082 True
3083 >>> is_is_int(x)
3084 False
3085 """
3086 return is_app_of(a, Z3_OP_IS_INT)
3087
3088

◆ is_K()

is_K (   a)
Return `True` if `a` is a Z3 constant array.

>>> a = K(IntSort(), 10)
>>> is_K(a)
True
>>> a = Array('a', IntSort(), IntSort())
>>> is_K(a)
False

Definition at line 4873 of file z3py.py.

4873def is_K(a):
4874 """Return `True` if `a` is a Z3 constant array.
4875
4876 >>> a = K(IntSort(), 10)
4877 >>> is_K(a)
4878 True
4879 >>> a = Array('a', IntSort(), IntSort())
4880 >>> is_K(a)
4881 False
4882 """
4883 return is_app_of(a, Z3_OP_CONST_ARRAY)
4884
4885

◆ is_le()

bool is_le ( Any  a)
Return `True` if `a` is an expression of the form b <= c.

>>> x, y = Ints('x y')
>>> is_le(x <= y)
True
>>> is_le(x < y)
False

Definition at line 3029 of file z3py.py.

3029def is_le(a : Any) -> bool:
3030 """Return `True` if `a` is an expression of the form b <= c.
3031
3032 >>> x, y = Ints('x y')
3033 >>> is_le(x <= y)
3034 True
3035 >>> is_le(x < y)
3036 False
3037 """
3038 return is_app_of(a, Z3_OP_LE)
3039
3040

◆ is_lt()

bool is_lt ( Any  a)
Return `True` if `a` is an expression of the form b < c.

>>> x, y = Ints('x y')
>>> is_lt(x < y)
True
>>> is_lt(x == y)
False

Definition at line 3041 of file z3py.py.

3041def is_lt(a : Any) -> bool:
3042 """Return `True` if `a` is an expression of the form b < c.
3043
3044 >>> x, y = Ints('x y')
3045 >>> is_lt(x < y)
3046 True
3047 >>> is_lt(x == y)
3048 False
3049 """
3050 return is_app_of(a, Z3_OP_LT)
3051
3052

◆ is_map()

is_map (   a)
Return `True` if `a` is a Z3 map array expression.

>>> f = Function('f', IntSort(), IntSort())
>>> b = Array('b', IntSort(), IntSort())
>>> a  = Map(f, b)
>>> a
Map(f, b)
>>> is_map(a)
True
>>> is_map(b)
False

Definition at line 4886 of file z3py.py.

4886def is_map(a):
4887 """Return `True` if `a` is a Z3 map array expression.
4888
4889 >>> f = Function('f', IntSort(), IntSort())
4890 >>> b = Array('b', IntSort(), IntSort())
4891 >>> a = Map(f, b)
4892 >>> a
4893 Map(f, b)
4894 >>> is_map(a)
4895 True
4896 >>> is_map(b)
4897 False
4898 """
4899 return is_app_of(a, Z3_OP_ARRAY_MAP)
4900
4901

Referenced by get_map_func().

◆ is_mod()

bool is_mod ( Any  a)
Return `True` if `a` is an expression of the form b % c.

>>> x, y = Ints('x y')
>>> is_mod(x % y)
True
>>> is_mod(x + y)
False

Definition at line 3017 of file z3py.py.

3017def is_mod(a : Any) -> bool:
3018 """Return `True` if `a` is an expression of the form b % c.
3019
3020 >>> x, y = Ints('x y')
3021 >>> is_mod(x % y)
3022 True
3023 >>> is_mod(x + y)
3024 False
3025 """
3026 return is_app_of(a, Z3_OP_MOD)
3027
3028

◆ is_mul()

bool is_mul ( Any  a)
Return `True` if `a` is an expression of the form b * c.

>>> x, y = Ints('x y')
>>> is_mul(x * y)
True
>>> is_mul(x - y)
False

Definition at line 2964 of file z3py.py.

2964def is_mul(a : Any) -> bool:
2965 """Return `True` if `a` is an expression of the form b * c.
2966
2967 >>> x, y = Ints('x y')
2968 >>> is_mul(x * y)
2969 True
2970 >>> is_mul(x - y)
2971 False
2972 """
2973 return is_app_of(a, Z3_OP_MUL)
2974
2975

◆ is_not()

bool is_not ( Any  a)
Return `True` if `a` is a Z3 not expression.

>>> p = Bool('p')
>>> is_not(p)
False
>>> is_not(Not(p))
True

Definition at line 1796 of file z3py.py.

1796def is_not(a : Any) -> bool:
1797 """Return `True` if `a` is a Z3 not expression.
1798
1799 >>> p = Bool('p')
1800 >>> is_not(p)
1801 False
1802 >>> is_not(Not(p))
1803 True
1804 """
1805 return is_app_of(a, Z3_OP_NOT)
1806
1807

Referenced by mk_not().

◆ is_or()

bool is_or ( Any  a)
Return `True` if `a` is a Z3 or expression.

>>> p, q = Bools('p q')
>>> is_or(Or(p, q))
True
>>> is_or(And(p, q))
False

Definition at line 1772 of file z3py.py.

1772def is_or(a : Any) -> bool:
1773 """Return `True` if `a` is a Z3 or expression.
1774
1775 >>> p, q = Bools('p q')
1776 >>> is_or(Or(p, q))
1777 True
1778 >>> is_or(And(p, q))
1779 False
1780 """
1781 return is_app_of(a, Z3_OP_OR)
1782
1783

◆ is_pattern()

is_pattern (   a)
Return `True` if `a` is a Z3 pattern (hint for quantifier instantiation.

>>> f = Function('f', IntSort(), IntSort())
>>> x = Int('x')
>>> q = ForAll(x, f(x) == 0, patterns = [ f(x) ])
>>> q
ForAll(x, f(x) == 0)
>>> q.num_patterns()
1
>>> is_pattern(q.pattern(0))
True
>>> q.pattern(0)
f(Var(0))

Definition at line 2072 of file z3py.py.

2072def is_pattern(a):
2073 """Return `True` if `a` is a Z3 pattern (hint for quantifier instantiation.
2074
2075 >>> f = Function('f', IntSort(), IntSort())
2076 >>> x = Int('x')
2077 >>> q = ForAll(x, f(x) == 0, patterns = [ f(x) ])
2078 >>> q
2079 ForAll(x, f(x) == 0)
2080 >>> q.num_patterns()
2081 1
2082 >>> is_pattern(q.pattern(0))
2083 True
2084 >>> q.pattern(0)
2085 f(Var(0))
2086 """
2087 return isinstance(a, PatternRef)
2088
2089

Referenced by _mk_quantifier(), and _to_pattern().

◆ is_probe()

is_probe (   p)
Return `True` if `p` is a Z3 probe.

>>> is_probe(Int('x'))
False
>>> is_probe(Probe('memory'))
True

Definition at line 9456 of file z3py.py.

9456def is_probe(p):
9457 """Return `True` if `p` is a Z3 probe.
9458
9459 >>> is_probe(Int('x'))
9460 False
9461 >>> is_probe(Probe('memory'))
9462 True
9463 """
9464 return isinstance(p, Probe)
9465
9466

Referenced by _ctx_from_ast_arg_list(), _has_probe(), and Not().

◆ is_quantifier()

is_quantifier (   a)
Return `True` if `a` is a Z3 quantifier.

>>> f = Function('f', IntSort(), IntSort())
>>> x = Int('x')
>>> q = ForAll(x, f(x) == 0)
>>> is_quantifier(q)
True
>>> is_quantifier(f(x))
False

Definition at line 2322 of file z3py.py.

2322def is_quantifier(a):
2323 """Return `True` if `a` is a Z3 quantifier.
2324
2325 >>> f = Function('f', IntSort(), IntSort())
2326 >>> x = Int('x')
2327 >>> q = ForAll(x, f(x) == 0)
2328 >>> is_quantifier(q)
2329 True
2330 >>> is_quantifier(f(x))
2331 False
2332 """
2333 return isinstance(a, QuantifierRef)
2334
2335

◆ is_rational_value()

is_rational_value (   a)
Return `True` if `a` is rational value of sort Real.

>>> is_rational_value(RealVal(1))
True
>>> is_rational_value(RealVal("3/5"))
True
>>> is_rational_value(IntVal(1))
False
>>> is_rational_value(1)
False
>>> n = Real('x') + 1
>>> n.arg(1)
1
>>> is_rational_value(n.arg(1))
True
>>> is_rational_value(Real('x'))
False

Definition at line 2916 of file z3py.py.

2916def is_rational_value(a):
2917 """Return `True` if `a` is rational value of sort Real.
2918
2919 >>> is_rational_value(RealVal(1))
2920 True
2921 >>> is_rational_value(RealVal("3/5"))
2922 True
2923 >>> is_rational_value(IntVal(1))
2924 False
2925 >>> is_rational_value(1)
2926 False
2927 >>> n = Real('x') + 1
2928 >>> n.arg(1)
2929 1
2930 >>> is_rational_value(n.arg(1))
2931 True
2932 >>> is_rational_value(Real('x'))
2933 False
2934 """
2935 return is_arith(a) and a.is_real() and _is_numeral(a.ctx, a.as_ast())
2936
2937

◆ is_re()

is_re (   s)

Definition at line 12057 of file z3py.py.

12057def is_re(s):
12058 return isinstance(s, ReRef)
12059
12060

Referenced by Concat().

◆ is_real()

is_real (   a)
Return `True` if `a` is a real expression.

>>> x = Int('x')
>>> is_real(x + 1)
False
>>> y = Real('y')
>>> is_real(y)
True
>>> is_real(y + 1)
True
>>> is_real(1)
False
>>> is_real(RealVal(1))
True

Definition at line 2865 of file z3py.py.

2865def is_real(a):
2866 """Return `True` if `a` is a real expression.
2867
2868 >>> x = Int('x')
2869 >>> is_real(x + 1)
2870 False
2871 >>> y = Real('y')
2872 >>> is_real(y)
2873 True
2874 >>> is_real(y + 1)
2875 True
2876 >>> is_real(1)
2877 False
2878 >>> is_real(RealVal(1))
2879 True
2880 """
2881 return is_arith(a) and a.is_real()
2882
2883

◆ is_select()

is_select (   a)
Return `True` if `a` is a Z3 array select application.

>>> a = Array('a', IntSort(), IntSort())
>>> is_select(a)
False
>>> i = Int('i')
>>> is_select(a[i])
True

Definition at line 5135 of file z3py.py.

5135def is_select(a):
5136 """Return `True` if `a` is a Z3 array select application.
5137
5138 >>> a = Array('a', IntSort(), IntSort())
5139 >>> is_select(a)
5140 False
5141 >>> i = Int('i')
5142 >>> is_select(a[i])
5143 True
5144 """
5145 return is_app_of(a, Z3_OP_SELECT)
5146
5147

◆ is_seq()

is_seq (   a)
Return `True` if `a` is a Z3 sequence expression.
>>> print (is_seq(Unit(IntVal(0))))
True
>>> print (is_seq(StringVal("abc")))
True

Definition at line 11729 of file z3py.py.

11729def is_seq(a):
11730 """Return `True` if `a` is a Z3 sequence expression.
11731 >>> print (is_seq(Unit(IntVal(0))))
11732 True
11733 >>> print (is_seq(StringVal("abc")))
11734 True
11735 """
11736 return isinstance(a, SeqRef)
11737
11738

Referenced by Concat(), and Extract().

◆ is_sort()

bool is_sort ( Any  s)
Return `True` if `s` is a Z3 sort.

>>> is_sort(IntSort())
True
>>> is_sort(Int('x'))
False
>>> is_expr(Int('x'))
True

Definition at line 682 of file z3py.py.

682def is_sort(s : Any) -> bool:
683 """Return `True` if `s` is a Z3 sort.
684
685 >>> is_sort(IntSort())
686 True
687 >>> is_sort(Int('x'))
688 False
689 >>> is_expr(Int('x'))
690 True
691 """
692 return isinstance(s, SortRef)
693
694

Referenced by _valid_accessor(), ArraySort(), CreateDatatypes(), CreatePolymorphicDatatype(), FreshConst(), FreshFunction(), Function(), K(), RecFunction(), and Var().

◆ is_store()

is_store (   a)
Return `True` if `a` is a Z3 array store application.

>>> a = Array('a', IntSort(), IntSort())
>>> is_store(a)
False
>>> is_store(Store(a, 0, 1))
True

Definition at line 5148 of file z3py.py.

5148def is_store(a):
5149 """Return `True` if `a` is a Z3 array store application.
5150
5151 >>> a = Array('a', IntSort(), IntSort())
5152 >>> is_store(a)
5153 False
5154 >>> is_store(Store(a, 0, 1))
5155 True
5156 """
5157 return is_app_of(a, Z3_OP_STORE)
5158

◆ is_string()

bool is_string ( Any  a)
Return `True` if `a` is a Z3 string expression.
>>> print (is_string(StringVal("ab")))
True

Definition at line 11739 of file z3py.py.

11739def is_string(a: Any) -> bool:
11740 """Return `True` if `a` is a Z3 string expression.
11741 >>> print (is_string(StringVal("ab")))
11742 True
11743 """
11744 return isinstance(a, SeqRef) and a.is_string()
11745
11746

◆ is_string_value()

bool is_string_value ( Any  a)
return 'True' if 'a' is a Z3 string constant expression.
>>> print (is_string_value(StringVal("a")))
True
>>> print (is_string_value(StringVal("a") + StringVal("b")))
False

Definition at line 11747 of file z3py.py.

11747def is_string_value(a: Any) -> bool:
11748 """return 'True' if 'a' is a Z3 string constant expression.
11749 >>> print (is_string_value(StringVal("a")))
11750 True
11751 >>> print (is_string_value(StringVal("a") + StringVal("b")))
11752 False
11753 """
11754 return isinstance(a, SeqRef) and a.is_string_value()
11755

◆ is_sub()

bool is_sub ( Any  a)
Return `True` if `a` is an expression of the form b - c.

>>> x, y = Ints('x y')
>>> is_sub(x - y)
True
>>> is_sub(x + y)
False

Definition at line 2976 of file z3py.py.

2976def is_sub(a : Any) -> bool:
2977 """Return `True` if `a` is an expression of the form b - c.
2978
2979 >>> x, y = Ints('x y')
2980 >>> is_sub(x - y)
2981 True
2982 >>> is_sub(x + y)
2983 False
2984 """
2985 return is_app_of(a, Z3_OP_SUB)
2986
2987

◆ is_to_int()

bool is_to_int ( Any  a)
Return `True` if `a` is an expression of the form ToInt(b).

>>> x = Real('x')
>>> n = ToInt(x)
>>> n
ToInt(x)
>>> is_to_int(n)
True
>>> is_to_int(x)
False

Definition at line 3104 of file z3py.py.

3104def is_to_int(a : Any) -> bool:
3105 """Return `True` if `a` is an expression of the form ToInt(b).
3106
3107 >>> x = Real('x')
3108 >>> n = ToInt(x)
3109 >>> n
3110 ToInt(x)
3111 >>> is_to_int(n)
3112 True
3113 >>> is_to_int(x)
3114 False
3115 """
3116 return is_app_of(a, Z3_OP_TO_INT)
3117
3118

◆ is_to_real()

bool is_to_real ( Any  a)
Return `True` if `a` is an expression of the form ToReal(b).

>>> x = Int('x')
>>> n = ToReal(x)
>>> n
ToReal(x)
>>> is_to_real(n)
True
>>> is_to_real(x)
False

Definition at line 3089 of file z3py.py.

3089def is_to_real(a : Any) -> bool:
3090 """Return `True` if `a` is an expression of the form ToReal(b).
3091
3092 >>> x = Int('x')
3093 >>> n = ToReal(x)
3094 >>> n
3095 ToReal(x)
3096 >>> is_to_real(n)
3097 True
3098 >>> is_to_real(x)
3099 False
3100 """
3101 return is_app_of(a, Z3_OP_TO_REAL)
3102
3103

◆ is_true()

bool is_true ( Any  a)
Return `True` if `a` is the Z3 true expression.

>>> p = Bool('p')
>>> is_true(p)
False
>>> is_true(simplify(p == p))
True
>>> x = Real('x')
>>> is_true(x == 0)
False
>>> # True is a Python Boolean expression
>>> is_true(True)
False

Definition at line 1728 of file z3py.py.

1728def is_true(a : Any) -> bool:
1729 """Return `True` if `a` is the Z3 true expression.
1730
1731 >>> p = Bool('p')
1732 >>> is_true(p)
1733 False
1734 >>> is_true(simplify(p == p))
1735 True
1736 >>> x = Real('x')
1737 >>> is_true(x == 0)
1738 False
1739 >>> # True is a Python Boolean expression
1740 >>> is_true(True)
1741 False
1742 """
1743 return is_app_of(a, Z3_OP_TRUE)
1744
1745

Referenced by AstRef.__bool__(), and BoolRef.py_value().

◆ is_var()

is_var (   a)
Return `True` if `a` is variable.

Z3 uses de-Bruijn indices for representing bound variables in
quantifiers.

>>> x = Int('x')
>>> is_var(x)
False
>>> is_const(x)
True
>>> f = Function('f', IntSort(), IntSort())
>>> # Z3 replaces x with bound variables when ForAll is executed.
>>> q = ForAll(x, f(x) == x)
>>> b = q.body()
>>> b
f(Var(0)) == Var(0)
>>> b.arg(1)
Var(0)
>>> is_var(b.arg(1))
True

Definition at line 1419 of file z3py.py.

1419def is_var(a):
1420 """Return `True` if `a` is variable.
1421
1422 Z3 uses de-Bruijn indices for representing bound variables in
1423 quantifiers.
1424
1425 >>> x = Int('x')
1426 >>> is_var(x)
1427 False
1428 >>> is_const(x)
1429 True
1430 >>> f = Function('f', IntSort(), IntSort())
1431 >>> # Z3 replaces x with bound variables when ForAll is executed.
1432 >>> q = ForAll(x, f(x) == x)
1433 >>> b = q.body()
1434 >>> b
1435 f(Var(0)) == Var(0)
1436 >>> b.arg(1)
1437 Var(0)
1438 >>> is_var(b.arg(1))
1439 True
1440 """
1441 return is_expr(a) and _ast_kind(a.ctx, a) == Z3_VAR_AST
1442
1443

Referenced by get_var_index().

◆ IsInt()

IsInt (   a)
 Return the Z3 predicate IsInt(a).

>>> x = Real('x')
>>> IsInt(x + "1/2")
IsInt(x + 1/2)
>>> solve(IsInt(x + "1/2"), x > 0, x < 1)
[x = 1/2]
>>> solve(IsInt(x + "1/2"), x > 0, x < 1, x != "1/2")
no solution

Definition at line 3562 of file z3py.py.

3562def IsInt(a):
3563 """ Return the Z3 predicate IsInt(a).
3564
3565 >>> x = Real('x')
3566 >>> IsInt(x + "1/2")
3567 IsInt(x + 1/2)
3568 >>> solve(IsInt(x + "1/2"), x > 0, x < 1)
3569 [x = 1/2]
3570 >>> solve(IsInt(x + "1/2"), x > 0, x < 1, x != "1/2")
3571 no solution
3572 """
3573 if z3_debug():
3574 _z3_assert(a.is_real(), "Z3 real expression expected.")
3575 ctx = a.ctx
3576 return BoolRef(Z3_mk_is_int(ctx.ref(), a.as_ast()), ctx)
3577
3578
Z3_ast Z3_API Z3_mk_is_int(Z3_context c, Z3_ast t1)
Check if a real number is an integer.

◆ IsMember()

IsMember (   e,
  s 
)
 Check if e is a member of set s
>>> a = Const('a', SetSort(IntSort()))
>>> IsMember(1, a)
a[1]

Definition at line 5272 of file z3py.py.

5272def IsMember(e, s):
5273 """ Check if e is a member of set s
5274 >>> a = Const('a', SetSort(IntSort()))
5275 >>> IsMember(1, a)
5276 a[1]
5277 """
5278 ctx = _ctx_from_ast_arg_list([s, e])
5279 e = _py2expr(e, ctx)
5280 if is_finite_set(s):
5281 return FiniteSetIsMember(e, s)
5282 return BoolRef(Z3_mk_set_member(ctx.ref(), e.as_ast(), s.as_ast()), ctx)
5283
5284
Z3_ast Z3_API Z3_mk_set_member(Z3_context c, Z3_ast elem, Z3_ast set)
Check for set membership.

◆ IsSubset()

IsSubset (   a,
  b 
)
 Check if a is a subset of b
>>> a = Const('a', SetSort(IntSort()))
>>> b = Const('b', SetSort(IntSort()))
>>> IsSubset(a, b)
subset(a, b)

Definition at line 5285 of file z3py.py.

5285def IsSubset(a, b):
5286 """ Check if a is a subset of b
5287 >>> a = Const('a', SetSort(IntSort()))
5288 >>> b = Const('b', SetSort(IntSort()))
5289 >>> IsSubset(a, b)
5290 subset(a, b)
5291 """
5292 ctx = _ctx_from_ast_arg_list([a, b])
5293 if is_finite_set(a):
5294 return FiniteSetIsSubset(a, b)
5295 return BoolRef(Z3_mk_set_subset(ctx.ref(), a.as_ast(), b.as_ast()), ctx)
5296
5297
Z3_ast Z3_API Z3_mk_set_subset(Z3_context c, Z3_ast arg1, Z3_ast arg2)
Check for subsetness of sets.

◆ K()

K (   dom,
  v 
)
Return a Z3 constant array expression.

>>> a = K(IntSort(), 10)
>>> a
K(Int, 10)
>>> a.sort()
Array(Int, Int)
>>> i = Int('i')
>>> a[i]
K(Int, 10)[i]
>>> simplify(a[i])
10

Definition at line 5083 of file z3py.py.

5083def K(dom, v):
5084 """Return a Z3 constant array expression.
5085
5086 >>> a = K(IntSort(), 10)
5087 >>> a
5088 K(Int, 10)
5089 >>> a.sort()
5090 Array(Int, Int)
5091 >>> i = Int('i')
5092 >>> a[i]
5093 K(Int, 10)[i]
5094 >>> simplify(a[i])
5095 10
5096 """
5097 if z3_debug():
5098 _z3_assert(is_sort(dom), "Z3 sort expected")
5099 ctx = dom.ctx
5100 if not is_expr(v):
5101 v = _py2expr(v, ctx)
5102 return ArrayRef(Z3_mk_const_array(ctx.ref(), dom.ast, v.as_ast()), ctx)
5103
5104
Z3_ast Z3_API Z3_mk_const_array(Z3_context c, Z3_sort domain, Z3_ast v)
Create the constant array.

Referenced by ModelRef.get_interp().

◆ Lambda()

Lambda (   vs,
  body 
)
Create a Z3 lambda expression.

>>> f = Function('f', IntSort(), IntSort(), IntSort())
>>> mem0 = Array('mem0', IntSort(), IntSort())
>>> lo, hi, e, i = Ints('lo hi e i')
>>> mem1 = Lambda([i], If(And(lo <= i, i <= hi), e, mem0[i]))
>>> mem1
Lambda(i, If(And(lo <= i, i <= hi), e, mem0[i]))

Definition at line 2410 of file z3py.py.

2410def Lambda(vs, body):
2411 """Create a Z3 lambda expression.
2412
2413 >>> f = Function('f', IntSort(), IntSort(), IntSort())
2414 >>> mem0 = Array('mem0', IntSort(), IntSort())
2415 >>> lo, hi, e, i = Ints('lo hi e i')
2416 >>> mem1 = Lambda([i], If(And(lo <= i, i <= hi), e, mem0[i]))
2417 >>> mem1
2418 Lambda(i, If(And(lo <= i, i <= hi), e, mem0[i]))
2419 """
2420 ctx = body.ctx
2421 if is_app(vs):
2422 vs = [vs]
2423 num_vars = len(vs)
2424 _vs = (Ast * num_vars)()
2425 for i in range(num_vars):
2426 # TODO: Check if is constant
2427 _vs[i] = vs[i].as_ast()
2428 return QuantifierRef(Z3_mk_lambda_const(ctx.ref(), num_vars, _vs, body.as_ast()), ctx)
2429
Z3_ast Z3_API Z3_mk_lambda_const(Z3_context c, unsigned num_bound, Z3_app const bound[], Z3_ast body)
Create a lambda expression using a list of constants that form the set of bound variables.

◆ LastIndexOf()

LastIndexOf (   s,
  substr 
)
Retrieve the last index of substring within a string

Definition at line 11932 of file z3py.py.

11932def LastIndexOf(s, substr):
11933 """Retrieve the last index of substring within a string"""
11934 ctx = None
11935 ctx = _get_ctx2(s, substr, ctx)
11936 s = _coerce_seq(s, ctx)
11937 substr = _coerce_seq(substr, ctx)
11938 return ArithRef(Z3_mk_seq_last_index(s.ctx_ref(), s.as_ast(), substr.as_ast()), s.ctx)
11939
11940
Z3_ast Z3_API Z3_mk_seq_last_index(Z3_context c, Z3_ast s, Z3_ast substr)
Return index of the last occurrence of substr in s. If s does not contain substr, then the value is -...

◆ Length()

Length (   s)
Obtain the length of a sequence 's'
>>> l = Length(StringVal("abc"))
>>> simplify(l)
3

Definition at line 11941 of file z3py.py.

11941def Length(s):
11942 """Obtain the length of a sequence 's'
11943 >>> l = Length(StringVal("abc"))
11944 >>> simplify(l)
11945 3
11946 """
11947 s = _coerce_seq(s)
11948 return ArithRef(Z3_mk_seq_length(s.ctx_ref(), s.as_ast()), s.ctx)
11949
Z3_ast Z3_API Z3_mk_seq_length(Z3_context c, Z3_ast s)
Return the length of the sequence s.

◆ LinearOrder()

LinearOrder (   a,
  index 
)

Definition at line 12229 of file z3py.py.

12229def LinearOrder(a, index):
12230 return FuncDeclRef(Z3_mk_linear_order(a.ctx_ref(), a.ast, index), a.ctx)
12231
12232
Z3_func_decl Z3_API Z3_mk_linear_order(Z3_context c, Z3_sort a, unsigned id)
create a linear ordering relation over signature a. The relation is identified by the index id.

◆ Loop()

Loop (   re,
  lo,
  hi = 0 
)
Create the regular expression accepting between a lower and upper bound repetitions
>>> re = Loop(Re("a"), 1, 3)
>>> print(simplify(InRe("aa", re)))
True
>>> print(simplify(InRe("aaaa", re)))
False
>>> print(simplify(InRe("", re)))
False

Definition at line 12179 of file z3py.py.

12179def Loop(re, lo, hi=0):
12180 """Create the regular expression accepting between a lower and upper bound repetitions
12181 >>> re = Loop(Re("a"), 1, 3)
12182 >>> print(simplify(InRe("aa", re)))
12183 True
12184 >>> print(simplify(InRe("aaaa", re)))
12185 False
12186 >>> print(simplify(InRe("", re)))
12187 False
12188 """
12189 if z3_debug():
12190 _z3_assert(is_expr(re), "expression expected")
12191 return ReRef(Z3_mk_re_loop(re.ctx_ref(), re.as_ast(), lo, hi), re.ctx)
12192
12193
Z3_ast Z3_API Z3_mk_re_loop(Z3_context c, Z3_ast r, unsigned lo, unsigned hi)
Create a regular expression loop. The supplied regular expression r is repeated between lo and hi tim...

◆ LShR()

LShR (   a,
  b 
)
Create the Z3 expression logical right shift.

Use the operator >> for the arithmetical right shift.

>>> x, y = BitVecs('x y', 32)
>>> LShR(x, y)
LShR(x, y)
>>> (x >> y).sexpr()
'(bvashr x y)'
>>> LShR(x, y).sexpr()
'(bvlshr x y)'
>>> BitVecVal(4, 3)
4
>>> BitVecVal(4, 3).as_signed_long()
-4
>>> simplify(BitVecVal(4, 3) >> 1).as_signed_long()
-2
>>> simplify(BitVecVal(4, 3) >> 1)
6
>>> simplify(LShR(BitVecVal(4, 3), 1))
2
>>> simplify(BitVecVal(2, 3) >> 1)
1
>>> simplify(LShR(BitVecVal(2, 3), 1))
1

Definition at line 4495 of file z3py.py.

4495def LShR(a, b):
4496 """Create the Z3 expression logical right shift.
4497
4498 Use the operator >> for the arithmetical right shift.
4499
4500 >>> x, y = BitVecs('x y', 32)
4501 >>> LShR(x, y)
4502 LShR(x, y)
4503 >>> (x >> y).sexpr()
4504 '(bvashr x y)'
4505 >>> LShR(x, y).sexpr()
4506 '(bvlshr x y)'
4507 >>> BitVecVal(4, 3)
4508 4
4509 >>> BitVecVal(4, 3).as_signed_long()
4510 -4
4511 >>> simplify(BitVecVal(4, 3) >> 1).as_signed_long()
4512 -2
4513 >>> simplify(BitVecVal(4, 3) >> 1)
4514 6
4515 >>> simplify(LShR(BitVecVal(4, 3), 1))
4516 2
4517 >>> simplify(BitVecVal(2, 3) >> 1)
4518 1
4519 >>> simplify(LShR(BitVecVal(2, 3), 1))
4520 1
4521 """
4522 _check_bv_args(a, b)
4523 a, b = _coerce_exprs(a, b)
4524 return BitVecRef(Z3_mk_bvlshr(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4525
4526
Z3_ast Z3_API Z3_mk_bvlshr(Z3_context c, Z3_ast t1, Z3_ast t2)
Logical shift right.

◆ main_ctx()

Context main_ctx ( )
Return a reference to the global Z3 context.

>>> x = Real('x')
>>> x.ctx == main_ctx()
True
>>> c = Context()
>>> c == main_ctx()
False
>>> x2 = Real('x', c)
>>> x2.ctx == c
True
>>> eq(x, x2)
False

Definition at line 266 of file z3py.py.

266def main_ctx() -> Context:
267 """Return a reference to the global Z3 context.
268
269 >>> x = Real('x')
270 >>> x.ctx == main_ctx()
271 True
272 >>> c = Context()
273 >>> c == main_ctx()
274 False
275 >>> x2 = Real('x', c)
276 >>> x2.ctx == c
277 True
278 >>> eq(x, x2)
279 False
280 """
281 global _main_ctx
282 if _main_ctx is None:
283 _main_ctx = Context()
284 return _main_ctx
285
286

Referenced by _get_ctx().

◆ Map()

Map (   f,
*  args 
)
Return a Z3 map array expression.

>>> f = Function('f', IntSort(), IntSort(), IntSort())
>>> a1 = Array('a1', IntSort(), IntSort())
>>> a2 = Array('a2', IntSort(), IntSort())
>>> b  = Map(f, a1, a2)
>>> b
Map(f, a1, a2)
>>> prove(b[0] == f(a1[0], a2[0]))
proved

Definition at line 5060 of file z3py.py.

5060def Map(f, *args):
5061 """Return a Z3 map array expression.
5062
5063 >>> f = Function('f', IntSort(), IntSort(), IntSort())
5064 >>> a1 = Array('a1', IntSort(), IntSort())
5065 >>> a2 = Array('a2', IntSort(), IntSort())
5066 >>> b = Map(f, a1, a2)
5067 >>> b
5068 Map(f, a1, a2)
5069 >>> prove(b[0] == f(a1[0], a2[0]))
5070 proved
5071 """
5072 args = _get_args(args)
5073 if z3_debug():
5074 _z3_assert(len(args) > 0, "At least one Z3 array expression expected")
5075 _z3_assert(is_func_decl(f), "First argument must be a Z3 function declaration")
5076 _z3_assert(all([is_array(a) for a in args]), "Z3 array expected expected")
5077 _z3_assert(len(args) == f.arity(), "Number of arguments mismatch")
5078 _args, sz = _to_ast_array(args)
5079 ctx = f.ctx
5080 return ArrayRef(Z3_mk_map(ctx.ref(), f.ast, sz, _args), ctx)
5081
5082
Z3_ast Z3_API Z3_mk_map(Z3_context c, Z3_func_decl f, unsigned n, Z3_ast const *args)
Map f on the argument arrays.

◆ mk_not()

mk_not (   a)

Definition at line 1973 of file z3py.py.

1973def mk_not(a):
1974 if is_not(a):
1975 return a.arg(0)
1976 else:
1977 return Not(a)
1978
1979

◆ Model()

Model (   ctx = None,
  eval = {} 
)

Definition at line 7333 of file z3py.py.

7333def Model(ctx=None, eval = {}):
7334 ctx = _get_ctx(ctx)
7335 mdl = ModelRef(Z3_mk_model(ctx.ref()), ctx)
7336 for k, v in eval.items():
7337 mdl.update_value(k, v)
7338 return mdl
7339
7340
Z3_model Z3_API Z3_mk_model(Z3_context c)
Create a fresh model object. It has reference count 0.

◆ MultiPattern()

MultiPattern ( *  args)
Create a Z3 multi-pattern using the given expressions `*args`

>>> f = Function('f', IntSort(), IntSort())
>>> g = Function('g', IntSort(), IntSort())
>>> x = Int('x')
>>> q = ForAll(x, f(x) != g(x), patterns = [ MultiPattern(f(x), g(x)) ])
>>> q
ForAll(x, f(x) != g(x))
>>> q.num_patterns()
1
>>> is_pattern(q.pattern(0))
True
>>> q.pattern(0)
MultiPattern(f(Var(0)), g(Var(0)))

Definition at line 2090 of file z3py.py.

2090def MultiPattern(*args):
2091 """Create a Z3 multi-pattern using the given expressions `*args`
2092
2093 >>> f = Function('f', IntSort(), IntSort())
2094 >>> g = Function('g', IntSort(), IntSort())
2095 >>> x = Int('x')
2096 >>> q = ForAll(x, f(x) != g(x), patterns = [ MultiPattern(f(x), g(x)) ])
2097 >>> q
2098 ForAll(x, f(x) != g(x))
2099 >>> q.num_patterns()
2100 1
2101 >>> is_pattern(q.pattern(0))
2102 True
2103 >>> q.pattern(0)
2104 MultiPattern(f(Var(0)), g(Var(0)))
2105 """
2106 if z3_debug():
2107 _z3_assert(len(args) > 0, "At least one argument expected")
2108 _z3_assert(all([is_expr(a) for a in args]), "Z3 expressions expected")
2109 ctx = args[0].ctx
2110 args, sz = _to_ast_array(args)
2111 return PatternRef(Z3_mk_pattern(ctx.ref(), sz, args), ctx)
2112
2113
Z3_pattern Z3_API Z3_mk_pattern(Z3_context c, unsigned num_patterns, Z3_ast const terms[])
Create a pattern for quantifier instantiation.

Referenced by _to_pattern().

◆ Not()

Not (   a,
  ctx = None 
)
Create a Z3 not expression or probe.

>>> p = Bool('p')
>>> Not(Not(p))
Not(Not(p))
>>> simplify(Not(Not(p)))
p

Definition at line 1954 of file z3py.py.

1954def Not(a, ctx=None):
1955 """Create a Z3 not expression or probe.
1956
1957 >>> p = Bool('p')
1958 >>> Not(Not(p))
1959 Not(Not(p))
1960 >>> simplify(Not(Not(p)))
1961 p
1962 """
1963 ctx = _get_ctx(_ctx_from_ast_arg_list([a], ctx))
1964 if is_probe(a):
1965 # Not is also used to build probes
1966 return Probe(Z3_probe_not(ctx.ref(), a.probe), ctx)
1967 else:
1968 s = BoolSort(ctx)
1969 a = s.cast(a)
1970 return BoolRef(Z3_mk_not(ctx.ref(), a.as_ast()), ctx)
1971
1972
Z3_probe Z3_API Z3_probe_not(Z3_context x, Z3_probe p)
Return a probe that evaluates to "true" when p does not evaluate to true.
Z3_ast Z3_API Z3_mk_not(Z3_context c, Z3_ast a)
Create an AST node representing not(a).

Referenced by BoolRef.__invert__(), and mk_not().

◆ num_simplifiers()

num_simplifiers (   ctx = None)
Return the number of simplifiers supported by the given context.

Definition at line 8930 of file z3py.py.

8930def num_simplifiers(ctx=None):
8931 """Return the number of simplifiers supported by the given context."""
8932 return Z3_get_num_simplifiers(_get_ctx(ctx).ref())
8933
8934
unsigned Z3_API Z3_get_num_simplifiers(Z3_context c)
Return the number of builtin simplifiers available in Z3.

◆ on_clause_eh()

on_clause_eh (   ctx,
  p,
  n,
  dep,
  clause 
)

Definition at line 12269 of file z3py.py.

12269def on_clause_eh(ctx, p, n, dep, clause):
12270 onc = _my_hacky_class
12271 p = _to_expr_ref(to_Ast(p), onc.ctx)
12272 clause = AstVector(to_AstVectorObj(clause), onc.ctx)
12273 deps = [dep[i] for i in range(n)]
12274 onc.on_clause(p, deps, clause)
12275

◆ open_log()

open_log (   fname)
Log interaction to a file. This function must be invoked immediately after init(). 

Definition at line 122 of file z3py.py.

122def open_log(fname):
123 """Log interaction to a file. This function must be invoked immediately after init(). """
124 Z3_open_log(fname)
125
126
bool Z3_API Z3_open_log(Z3_string filename)
Log interaction to a file.

◆ Option()

Option (   re)
Create the regular expression that optionally accepts the argument.
>>> re = Option(Re("a"))
>>> print(simplify(InRe("a", re)))
True
>>> print(simplify(InRe("", re)))
True
>>> print(simplify(InRe("aa", re)))
False

Definition at line 12144 of file z3py.py.

12144def Option(re):
12145 """Create the regular expression that optionally accepts the argument.
12146 >>> re = Option(Re("a"))
12147 >>> print(simplify(InRe("a", re)))
12148 True
12149 >>> print(simplify(InRe("", re)))
12150 True
12151 >>> print(simplify(InRe("aa", re)))
12152 False
12153 """
12154 if z3_debug():
12155 _z3_assert(is_expr(re), "expression expected")
12156 return ReRef(Z3_mk_re_option(re.ctx_ref(), re.as_ast()), re.ctx)
12157
12158
Z3_ast Z3_API Z3_mk_re_option(Z3_context c, Z3_ast re)
Create the regular language [re].

◆ Or()

Or ( *  args)
Create a Z3 or-expression or or-probe.

>>> p, q, r = Bools('p q r')
>>> Or(p, q, r)
Or(p, q, r)
>>> P = BoolVector('p', 5)
>>> Or(P)
Or(p__0, p__1, p__2, p__3, p__4)

Definition at line 2021 of file z3py.py.

2021def Or(*args):
2022 """Create a Z3 or-expression or or-probe.
2023
2024 >>> p, q, r = Bools('p q r')
2025 >>> Or(p, q, r)
2026 Or(p, q, r)
2027 >>> P = BoolVector('p', 5)
2028 >>> Or(P)
2029 Or(p__0, p__1, p__2, p__3, p__4)
2030 """
2031 last_arg = None
2032 if len(args) > 0:
2033 last_arg = args[len(args) - 1]
2034 if isinstance(last_arg, Context):
2035 ctx = args[len(args) - 1]
2036 args = args[:len(args) - 1]
2037 elif len(args) == 1 and isinstance(args[0], AstVector):
2038 ctx = args[0].ctx
2039 args = [a for a in args[0]]
2040 else:
2041 ctx = None
2042 args = _get_args(args)
2043 ctx = _get_ctx(_ctx_from_ast_arg_list(args, ctx))
2044 if z3_debug():
2045 _z3_assert(ctx is not None, "At least one of the arguments must be a Z3 expression or probe")
2046 if _has_probe(args):
2047 return _probe_or(args, ctx)
2048 else:
2049 args = _coerce_expr_list(args, ctx)
2050 _args, sz = _to_ast_array(args)
2051 return BoolRef(Z3_mk_or(ctx.ref(), sz, _args), ctx)
2052
Z3_ast Z3_API Z3_mk_or(Z3_context c, unsigned num_args, Z3_ast const args[])
Create an AST node representing args[0] or ... or args[num_args-1].

Referenced by BoolRef.__or__().

◆ OrElse()

OrElse ( *  ts,
**  ks 
)
Return a tactic that applies the tactics in `*ts` until one of them succeeds (it doesn't fail).

>>> x = Int('x')
>>> t = OrElse(Tactic('split-clause'), Tactic('skip'))
>>> # Tactic split-clause fails if there is no clause in the given goal.
>>> t(x == 0)
[[x == 0]]
>>> t(Or(x == 0, x == 1))
[[x == 0], [x == 1]]

Definition at line 9149 of file z3py.py.

9149def OrElse(*ts, **ks):
9150 """Return a tactic that applies the tactics in `*ts` until one of them succeeds (it doesn't fail).
9151
9152 >>> x = Int('x')
9153 >>> t = OrElse(Tactic('split-clause'), Tactic('skip'))
9154 >>> # Tactic split-clause fails if there is no clause in the given goal.
9155 >>> t(x == 0)
9156 [[x == 0]]
9157 >>> t(Or(x == 0, x == 1))
9158 [[x == 0], [x == 1]]
9159 """
9160 if z3_debug():
9161 _z3_assert(len(ts) >= 2, "At least two arguments expected")
9162 ctx = ks.get("ctx", None)
9163 num = len(ts)
9164 r = ts[0]
9165 for i in range(num - 1):
9166 r = _or_else(r, ts[i + 1], ctx)
9167 return r
9168
9169

◆ ParAndThen()

ParAndThen (   t1,
  t2,
  ctx = None 
)
Alias for ParThen(t1, t2, ctx).

Definition at line 9205 of file z3py.py.

9205def ParAndThen(t1, t2, ctx=None):
9206 """Alias for ParThen(t1, t2, ctx)."""
9207 return ParThen(t1, t2, ctx)
9208
9209

◆ ParOr()

ParOr ( *  ts,
**  ks 
)
Return a tactic that applies the tactics in `*ts` in parallel until one of them succeeds (it doesn't fail).

>>> x = Int('x')
>>> t = ParOr(Tactic('simplify'), Tactic('fail'))
>>> t(x + 1 == 2)
[[x == 1]]

Definition at line 9170 of file z3py.py.

9170def ParOr(*ts, **ks):
9171 """Return a tactic that applies the tactics in `*ts` in parallel until one of them succeeds (it doesn't fail).
9172
9173 >>> x = Int('x')
9174 >>> t = ParOr(Tactic('simplify'), Tactic('fail'))
9175 >>> t(x + 1 == 2)
9176 [[x == 1]]
9177 """
9178 if z3_debug():
9179 _z3_assert(len(ts) >= 2, "At least two arguments expected")
9180 ctx = _get_ctx(ks.get("ctx", None))
9181 ts = [_to_tactic(t, ctx) for t in ts]
9182 sz = len(ts)
9183 _args = (TacticObj * sz)()
9184 for i in range(sz):
9185 _args[i] = ts[i].tactic
9186 return Tactic(Z3_tactic_par_or(ctx.ref(), sz, _args), ctx)
9187
9188
Z3_tactic Z3_API Z3_tactic_par_or(Z3_context c, unsigned num, Z3_tactic const ts[])
Return a tactic that applies the given tactics in parallel.

◆ parse_smt2_file()

parse_smt2_file (   f,
  sorts = {},
  decls = {},
  ctx = None 
)
Parse a file in SMT 2.0 format using the given sorts and decls.

This function is similar to parse_smt2_string().

Definition at line 10085 of file z3py.py.

10085def parse_smt2_file(f, sorts={}, decls={}, ctx=None):
10086 """Parse a file in SMT 2.0 format using the given sorts and decls.
10087
10088 This function is similar to parse_smt2_string().
10089 """
10090 ctx = _get_ctx(ctx)
10091 ssz, snames, ssorts = _dict2sarray(sorts, ctx)
10092 dsz, dnames, ddecls = _dict2darray(decls, ctx)
10093 return AstVector(Z3_parse_smtlib2_file(ctx.ref(), f, ssz, snames, ssorts, dsz, dnames, ddecls), ctx)
10094
10095
Z3_ast_vector Z3_API Z3_parse_smtlib2_file(Z3_context c, Z3_string file_name, unsigned num_sorts, Z3_symbol const sort_names[], Z3_sort const sorts[], unsigned num_decls, Z3_symbol const decl_names[], Z3_func_decl const decls[])
Similar to Z3_parse_smtlib2_string, but reads the benchmark from a file.

◆ parse_smt2_string()

parse_smt2_string (   s,
  sorts = {},
  decls = {},
  ctx = None 
)
Parse a string in SMT 2.0 format using the given sorts and decls.

The arguments sorts and decls are Python dictionaries used to initialize
the symbol table used for the SMT 2.0 parser.

>>> parse_smt2_string('(declare-const x Int) (assert (> x 0)) (assert (< x 10))')
[x > 0, x < 10]
>>> x, y = Ints('x y')
>>> f = Function('f', IntSort(), IntSort())
>>> parse_smt2_string('(assert (> (+ foo (g bar)) 0))', decls={ 'foo' : x, 'bar' : y, 'g' : f})
[x + f(y) > 0]
>>> parse_smt2_string('(declare-const a U) (assert (> a 0))', sorts={ 'U' : IntSort() })
[a > 0]

Definition at line 10064 of file z3py.py.

10064def parse_smt2_string(s, sorts={}, decls={}, ctx=None):
10065 """Parse a string in SMT 2.0 format using the given sorts and decls.
10066
10067 The arguments sorts and decls are Python dictionaries used to initialize
10068 the symbol table used for the SMT 2.0 parser.
10069
10070 >>> parse_smt2_string('(declare-const x Int) (assert (> x 0)) (assert (< x 10))')
10071 [x > 0, x < 10]
10072 >>> x, y = Ints('x y')
10073 >>> f = Function('f', IntSort(), IntSort())
10074 >>> parse_smt2_string('(assert (> (+ foo (g bar)) 0))', decls={ 'foo' : x, 'bar' : y, 'g' : f})
10075 [x + f(y) > 0]
10076 >>> parse_smt2_string('(declare-const a U) (assert (> a 0))', sorts={ 'U' : IntSort() })
10077 [a > 0]
10078 """
10079 ctx = _get_ctx(ctx)
10080 ssz, snames, ssorts = _dict2sarray(sorts, ctx)
10081 dsz, dnames, ddecls = _dict2darray(decls, ctx)
10082 return AstVector(Z3_parse_smtlib2_string(ctx.ref(), s, ssz, snames, ssorts, dsz, dnames, ddecls), ctx)
10083
10084
Z3_ast_vector Z3_API Z3_parse_smtlib2_string(Z3_context c, Z3_string str, unsigned num_sorts, Z3_symbol const sort_names[], Z3_sort const sorts[], unsigned num_decls, Z3_symbol const decl_names[], Z3_func_decl const decls[])
Parse the given string using the SMT-LIB2 parser.

◆ ParThen()

ParThen (   t1,
  t2,
  ctx = None 
)
Return a tactic that applies t1 and then t2 to every subgoal produced by t1.
The subgoals are processed in parallel.

>>> x, y = Ints('x y')
>>> t = ParThen(Tactic('split-clause'), Tactic('propagate-values'))
>>> t(And(Or(x == 1, x == 2), y == x + 1))
[[x == 1, y == 2], [x == 2, y == 3]]

Definition at line 9189 of file z3py.py.

9189def ParThen(t1, t2, ctx=None):
9190 """Return a tactic that applies t1 and then t2 to every subgoal produced by t1.
9191 The subgoals are processed in parallel.
9192
9193 >>> x, y = Ints('x y')
9194 >>> t = ParThen(Tactic('split-clause'), Tactic('propagate-values'))
9195 >>> t(And(Or(x == 1, x == 2), y == x + 1))
9196 [[x == 1, y == 2], [x == 2, y == 3]]
9197 """
9198 t1 = _to_tactic(t1, ctx)
9199 t2 = _to_tactic(t2, ctx)
9200 if z3_debug():
9201 _z3_assert(t1.ctx == t2.ctx, "Context mismatch")
9202 return Tactic(Z3_tactic_par_and_then(t1.ctx.ref(), t1.tactic, t2.tactic), t1.ctx)
9203
9204
Z3_tactic Z3_API Z3_tactic_par_and_then(Z3_context c, Z3_tactic t1, Z3_tactic t2)
Return a tactic that applies t1 to a given goal and then t2 to every subgoal produced by t1....

◆ PartialOrder()

PartialOrder (   a,
  index 
)

Definition at line 12225 of file z3py.py.

12225def PartialOrder(a, index):
12226 return FuncDeclRef(Z3_mk_partial_order(a.ctx_ref(), a.ast, index), a.ctx)
12227
12228
Z3_func_decl Z3_API Z3_mk_partial_order(Z3_context c, Z3_sort a, unsigned id)
create a partial ordering relation over signature a and index id.

◆ PbEq()

PbEq (   args,
  k,
  ctx = None 
)
Create a Pseudo-Boolean equality k constraint.

>>> a, b, c = Bools('a b c')
>>> f = PbEq(((a,1),(b,3),(c,2)), 3)

Definition at line 9841 of file z3py.py.

9841def PbEq(args, k, ctx=None):
9842 """Create a Pseudo-Boolean equality k constraint.
9843
9844 >>> a, b, c = Bools('a b c')
9845 >>> f = PbEq(((a,1),(b,3),(c,2)), 3)
9846 """
9847 _z3_check_cint_overflow(k, "k")
9848 ctx, sz, _args, _coeffs, args = _pb_args_coeffs(args)
9849 return BoolRef(Z3_mk_pbeq(ctx.ref(), sz, _args, _coeffs, k), ctx)
9850
9851
Z3_ast Z3_API Z3_mk_pbeq(Z3_context c, unsigned num_args, Z3_ast const args[], int const coeffs[], int k)
Pseudo-Boolean relations.

◆ PbGe()

PbGe (   args,
  k 
)
Create a Pseudo-Boolean inequality k constraint.

>>> a, b, c = Bools('a b c')
>>> f = PbGe(((a,1),(b,3),(c,2)), 3)

Definition at line 9830 of file z3py.py.

9830def PbGe(args, k):
9831 """Create a Pseudo-Boolean inequality k constraint.
9832
9833 >>> a, b, c = Bools('a b c')
9834 >>> f = PbGe(((a,1),(b,3),(c,2)), 3)
9835 """
9836 _z3_check_cint_overflow(k, "k")
9837 ctx, sz, _args, _coeffs, args = _pb_args_coeffs(args)
9838 return BoolRef(Z3_mk_pbge(ctx.ref(), sz, _args, _coeffs, k), ctx)
9839
9840
Z3_ast Z3_API Z3_mk_pbge(Z3_context c, unsigned num_args, Z3_ast const args[], int const coeffs[], int k)
Pseudo-Boolean relations.

◆ PbLe()

PbLe (   args,
  k 
)
Create a Pseudo-Boolean inequality k constraint.

>>> a, b, c = Bools('a b c')
>>> f = PbLe(((a,1),(b,3),(c,2)), 3)

Definition at line 9819 of file z3py.py.

9819def PbLe(args, k):
9820 """Create a Pseudo-Boolean inequality k constraint.
9821
9822 >>> a, b, c = Bools('a b c')
9823 >>> f = PbLe(((a,1),(b,3),(c,2)), 3)
9824 """
9825 _z3_check_cint_overflow(k, "k")
9826 ctx, sz, _args, _coeffs, args = _pb_args_coeffs(args)
9827 return BoolRef(Z3_mk_pble(ctx.ref(), sz, _args, _coeffs, k), ctx)
9828
9829
Z3_ast Z3_API Z3_mk_pble(Z3_context c, unsigned num_args, Z3_ast const args[], int const coeffs[], int k)
Pseudo-Boolean relations.

◆ PiecewiseLinearOrder()

PiecewiseLinearOrder (   a,
  index 
)

Definition at line 12237 of file z3py.py.

12237def PiecewiseLinearOrder(a, index):
12238 return FuncDeclRef(Z3_mk_piecewise_linear_order(a.ctx_ref(), a.ast, index), a.ctx)
12239
12240
Z3_func_decl Z3_API Z3_mk_piecewise_linear_order(Z3_context c, Z3_sort a, unsigned id)
create a piecewise linear ordering relation over signature a and index id.

◆ Plus()

Plus (   re)
Create the regular expression accepting one or more repetitions of argument.
>>> re = Plus(Re("a"))
>>> print(simplify(InRe("aa", re)))
True
>>> print(simplify(InRe("ab", re)))
False
>>> print(simplify(InRe("", re)))
False

Definition at line 12129 of file z3py.py.

12129def Plus(re):
12130 """Create the regular expression accepting one or more repetitions of argument.
12131 >>> re = Plus(Re("a"))
12132 >>> print(simplify(InRe("aa", re)))
12133 True
12134 >>> print(simplify(InRe("ab", re)))
12135 False
12136 >>> print(simplify(InRe("", re)))
12137 False
12138 """
12139 if z3_debug():
12140 _z3_assert(is_expr(re), "expression expected")
12141 return ReRef(Z3_mk_re_plus(re.ctx_ref(), re.as_ast()), re.ctx)
12142
12143
Z3_ast Z3_API Z3_mk_re_plus(Z3_context c, Z3_ast re)
Create the regular language re+.

◆ PrefixOf()

PrefixOf (   a,
  b 
)
Check if 'a' is a prefix of 'b'
>>> s1 = PrefixOf("ab", "abc")
>>> simplify(s1)
True
>>> s2 = PrefixOf("bc", "abc")
>>> simplify(s2)
False

Definition at line 11848 of file z3py.py.

11848def PrefixOf(a, b):
11849 """Check if 'a' is a prefix of 'b'
11850 >>> s1 = PrefixOf("ab", "abc")
11851 >>> simplify(s1)
11852 True
11853 >>> s2 = PrefixOf("bc", "abc")
11854 >>> simplify(s2)
11855 False
11856 """
11857 ctx = _get_ctx2(a, b)
11858 a = _coerce_seq(a, ctx)
11859 b = _coerce_seq(b, ctx)
11860 return BoolRef(Z3_mk_seq_prefix(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
11861
11862
Z3_ast Z3_API Z3_mk_seq_prefix(Z3_context c, Z3_ast prefix, Z3_ast s)
Check if prefix is a prefix of s.

◆ probe_description()

probe_description (   name,
  ctx = None 
)
Return a short description for the probe named `name`.

>>> d = probe_description('memory')

Definition at line 9485 of file z3py.py.

9485def probe_description(name, ctx=None):
9486 """Return a short description for the probe named `name`.
9487
9488 >>> d = probe_description('memory')
9489 """
9490 ctx = _get_ctx(ctx)
9491 return Z3_probe_get_descr(ctx.ref(), name)
9492
9493
Z3_string Z3_API Z3_probe_get_descr(Z3_context c, Z3_string name)
Return a string containing a description of the probe with the given name.

◆ probes()

probes (   ctx = None)
Return a list of all available probes in Z3.

>>> l = probes()
>>> l.count('memory') == 1
True

Definition at line 9474 of file z3py.py.

9474def probes(ctx=None):
9475 """Return a list of all available probes in Z3.
9476
9477 >>> l = probes()
9478 >>> l.count('memory') == 1
9479 True
9480 """
9481 ctx = _get_ctx(ctx)
9482 return [Z3_get_probe_name(ctx.ref(), i) for i in range(Z3_get_num_probes(ctx.ref()))]
9483
9484
unsigned Z3_API Z3_get_num_probes(Z3_context c)
Return the number of builtin probes available in Z3.
Z3_string Z3_API Z3_get_probe_name(Z3_context c, unsigned i)
Return the name of the i probe.

◆ Product()

Product ( *  args)
Create the product of the Z3 expressions.

>>> a, b, c = Ints('a b c')
>>> Product(a, b, c)
a*b*c
>>> Product([a, b, c])
a*b*c
>>> A = IntVector('a', 5)
>>> Product(A)
a__0*a__1*a__2*a__3*a__4

Definition at line 9726 of file z3py.py.

9726def Product(*args):
9727 """Create the product of the Z3 expressions.
9728
9729 >>> a, b, c = Ints('a b c')
9730 >>> Product(a, b, c)
9731 a*b*c
9732 >>> Product([a, b, c])
9733 a*b*c
9734 >>> A = IntVector('a', 5)
9735 >>> Product(A)
9736 a__0*a__1*a__2*a__3*a__4
9737 """
9738 args = _get_args(args)
9739 if len(args) == 0:
9740 return 1
9741 ctx = _ctx_from_ast_arg_list(args)
9742 if ctx is None:
9743 return _reduce(lambda a, b: a * b, args, 1)
9744 args = _coerce_expr_list(args, ctx)
9745 if is_bv(args[0]):
9746 return _reduce(lambda a, b: a * b, args, 1)
9747 else:
9748 _args, sz = _to_ast_array(args)
9749 return ArithRef(Z3_mk_mul(ctx.ref(), sz, _args), ctx)
9750
Z3_ast Z3_API Z3_mk_mul(Z3_context c, unsigned num_args, Z3_ast const args[])
Create an AST node representing args[0] * ... * args[num_args-1].

◆ PropagateFunction()

PropagateFunction (   name,
*  sig 
)
Create a function that gets tracked by user propagator.
   Every term headed by this function symbol is tracked.
   If a term is fixed and the fixed callback is registered a
   callback is invoked that the term headed by this function is fixed.

Definition at line 12434 of file z3py.py.

12434def PropagateFunction(name, *sig):
12435 """Create a function that gets tracked by user propagator.
12436 Every term headed by this function symbol is tracked.
12437 If a term is fixed and the fixed callback is registered a
12438 callback is invoked that the term headed by this function is fixed.
12439 """
12440 sig = _get_args(sig)
12441 if z3_debug():
12442 _z3_assert(len(sig) > 0, "At least two arguments expected")
12443 arity = len(sig) - 1
12444 rng = sig[arity]
12445 if z3_debug():
12446 _z3_assert(is_sort(rng), "Z3 sort expected")
12447 dom = (Sort * arity)()
12448 for i in range(arity):
12449 if z3_debug():
12450 _z3_assert(is_sort(sig[i]), "Z3 sort expected")
12451 dom[i] = sig[i].ast
12452 ctx = rng.ctx
12453 return FuncDeclRef(Z3_solver_propagate_declare(ctx.ref(), to_symbol(name, ctx), arity, dom, rng.ast), ctx)
12454
12455
12456
Z3_func_decl Z3_API Z3_solver_propagate_declare(Z3_context c, Z3_symbol name, unsigned n, Z3_sort *domain, Z3_sort range)

◆ prove()

prove (   claim,
  show = False,
**  keywords 
)
Try to prove the given claim.

This is a simple function for creating demonstrations.  It tries to prove
`claim` by showing the negation is unsatisfiable.

>>> p, q = Bools('p q')
>>> prove(Not(And(p, q)) == Or(Not(p), Not(q)))
proved

Definition at line 9913 of file z3py.py.

9913def prove(claim, show=False, **keywords):
9914 """Try to prove the given claim.
9915
9916 This is a simple function for creating demonstrations. It tries to prove
9917 `claim` by showing the negation is unsatisfiable.
9918
9919 >>> p, q = Bools('p q')
9920 >>> prove(Not(And(p, q)) == Or(Not(p), Not(q)))
9921 proved
9922 """
9923 if z3_debug():
9924 _z3_assert(is_bool(claim), "Z3 Boolean expression expected")
9925 s = Solver()
9926 s.set(**keywords)
9927 s.add(Not(claim))
9928 if show:
9929 print(s)
9930 r = s.check()
9931 if r == unsat:
9932 print("proved")
9933 elif r == unknown:
9934 print("failed to prove")
9935 print(s.model())
9936 else:
9937 print("counterexample")
9938 print(s.model())
9939
9940

◆ Q()

Q (   a,
  b,
  ctx = None 
)
Return a Z3 rational a/b.

If `ctx=None`, then the global context is used.

>>> Q(3,5)
3/5
>>> Q(3,5).sort()
Real

Definition at line 3401 of file z3py.py.

3401def Q(a, b, ctx=None):
3402 """Return a Z3 rational a/b.
3403
3404 If `ctx=None`, then the global context is used.
3405
3406 >>> Q(3,5)
3407 3/5
3408 >>> Q(3,5).sort()
3409 Real
3410 """
3411 return simplify(RatVal(a, b, ctx=ctx))
3412
3413

◆ Range()

Range (   lo,
  hi,
  ctx = None 
)
Create the range regular expression over two sequences of length 1
>>> range = Range("a","z")
>>> print(simplify(InRe("b", range)))
True
>>> print(simplify(InRe("bb", range)))
False

Definition at line 12194 of file z3py.py.

12194def Range(lo, hi, ctx=None):
12195 """Create the range regular expression over two sequences of length 1
12196 >>> range = Range("a","z")
12197 >>> print(simplify(InRe("b", range)))
12198 True
12199 >>> print(simplify(InRe("bb", range)))
12200 False
12201 """
12202 lo = _coerce_seq(lo, ctx)
12203 hi = _coerce_seq(hi, ctx)
12204 if z3_debug():
12205 _z3_assert(is_expr(lo), "expression expected")
12206 _z3_assert(is_expr(hi), "expression expected")
12207 return ReRef(Z3_mk_re_range(lo.ctx_ref(), lo.ast, hi.ast), lo.ctx)
12208
Z3_ast Z3_API Z3_mk_re_range(Z3_context c, Z3_ast lo, Z3_ast hi)
Create the range regular expression over two sequences of length 1.

◆ RatVal()

RatVal (   a,
  b,
  ctx = None 
)
Return a Z3 rational a/b.

If `ctx=None`, then the global context is used.

Note: Division by zero (b == 0) is allowed in Z3 symbolic expressions.
Z3 can reason about such expressions symbolically.

>>> RatVal(3,5)
3/5
>>> RatVal(3,5).sort()
Real

Definition at line 3381 of file z3py.py.

3381def RatVal(a, b, ctx=None):
3382 """Return a Z3 rational a/b.
3383
3384 If `ctx=None`, then the global context is used.
3385
3386 Note: Division by zero (b == 0) is allowed in Z3 symbolic expressions.
3387 Z3 can reason about such expressions symbolically.
3388
3389 >>> RatVal(3,5)
3390 3/5
3391 >>> RatVal(3,5).sort()
3392 Real
3393 """
3394 if z3_debug():
3395 _z3_assert(_is_int(a) or isinstance(a, str), "First argument cannot be converted into an integer")
3396 _z3_assert(_is_int(b) or isinstance(b, str), "Second argument cannot be converted into an integer")
3397 # Division by 0 is intentionally allowed - Z3 handles it symbolically
3398 return simplify(RealVal(a, ctx) / RealVal(b, ctx))
3399
3400

Referenced by Q().

◆ Re()

Re (   s,
  ctx = None 
)
The regular expression that accepts sequence 's'
>>> s1 = Re("ab")
>>> s2 = Re(StringVal("ab"))
>>> s3 = Re(Unit(BoolVal(True)))

Definition at line 12022 of file z3py.py.

12022def Re(s, ctx=None):
12023 """The regular expression that accepts sequence 's'
12024 >>> s1 = Re("ab")
12025 >>> s2 = Re(StringVal("ab"))
12026 >>> s3 = Re(Unit(BoolVal(True)))
12027 """
12028 s = _coerce_seq(s, ctx)
12029 return ReRef(Z3_mk_seq_to_re(s.ctx_ref(), s.as_ast()), s.ctx)
12030
12031
12032# Regular expressions
12033
Z3_ast Z3_API Z3_mk_seq_to_re(Z3_context c, Z3_ast seq)
Create a regular expression that accepts the sequence seq.

◆ Real()

Real (   name,
  ctx = None 
)
Return a real constant named `name`. If `ctx=None`, then the global context is used.

>>> x = Real('x')
>>> is_real(x)
True
>>> is_real(x + 1)
True

Definition at line 3467 of file z3py.py.

3467def Real(name, ctx=None):
3468 """Return a real constant named `name`. If `ctx=None`, then the global context is used.
3469
3470 >>> x = Real('x')
3471 >>> is_real(x)
3472 True
3473 >>> is_real(x + 1)
3474 True
3475 """
3476 ctx = _get_ctx(ctx)
3477 return ArithRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), RealSort(ctx).ast), ctx)
3478
3479

Referenced by Reals(), and RealVector().

◆ Reals()

Reals (   names,
  ctx = None 
)
Return a tuple of real constants.

>>> x, y, z = Reals('x y z')
>>> Sum(x, y, z)
x + y + z
>>> Sum(x, y, z).sort()
Real

Definition at line 3480 of file z3py.py.

3480def Reals(names, ctx=None):
3481 """Return a tuple of real constants.
3482
3483 >>> x, y, z = Reals('x y z')
3484 >>> Sum(x, y, z)
3485 x + y + z
3486 >>> Sum(x, y, z).sort()
3487 Real
3488 """
3489 ctx = _get_ctx(ctx)
3490 if isinstance(names, str):
3491 names = names.split(" ")
3492 return [Real(name, ctx) for name in names]
3493
3494

◆ RealSort()

RealSort (   ctx = None)
Return the real sort in the given context. If `ctx=None`, then the global context is used.

>>> RealSort()
Real
>>> x = Const('x', RealSort())
>>> is_real(x)
True
>>> is_int(x)
False
>>> x.sort() == RealSort()
True

Definition at line 3321 of file z3py.py.

3321def RealSort(ctx=None):
3322 """Return the real sort in the given context. If `ctx=None`, then the global context is used.
3323
3324 >>> RealSort()
3325 Real
3326 >>> x = Const('x', RealSort())
3327 >>> is_real(x)
3328 True
3329 >>> is_int(x)
3330 False
3331 >>> x.sort() == RealSort()
3332 True
3333 """
3334 ctx = _get_ctx(ctx)
3335 return ArithSortRef(Z3_mk_real_sort(ctx.ref()), ctx)
3336
3337
Z3_sort Z3_API Z3_mk_real_sort(Z3_context c)
Create the real type.

Referenced by FreshReal(), Real(), RealVal(), and RealVar().

◆ RealVal()

RealVal (   val,
  ctx = None 
)
Return a Z3 real value.

`val` may be a Python int, long, float or string representing a number in decimal or rational notation.
If `ctx=None`, then the global context is used.

>>> RealVal(1)
1
>>> RealVal(1).sort()
Real
>>> RealVal("3/5")
3/5
>>> RealVal("1.5")
3/2

Definition at line 3362 of file z3py.py.

3362def RealVal(val, ctx=None):
3363 """Return a Z3 real value.
3364
3365 `val` may be a Python int, long, float or string representing a number in decimal or rational notation.
3366 If `ctx=None`, then the global context is used.
3367
3368 >>> RealVal(1)
3369 1
3370 >>> RealVal(1).sort()
3371 Real
3372 >>> RealVal("3/5")
3373 3/5
3374 >>> RealVal("1.5")
3375 3/2
3376 """
3377 ctx = _get_ctx(ctx)
3378 return RatNumRef(Z3_mk_numeral(ctx.ref(), str(val), RealSort(ctx).ast), ctx)
3379
3380

Referenced by _coerce_exprs(), _py2expr(), Cbrt(), RatVal(), Sqrt(), and ToReal().

◆ RealVar()

ExprRef RealVar ( int  idx,
  ctx = None 
)
Create a real free variable. Free variables are used to create quantified formulas.
They are also used to create polynomials.

>>> RealVar(0)
Var(0)

Definition at line 1596 of file z3py.py.

1596def RealVar(idx: int, ctx=None) -> ExprRef:
1597 """
1598 Create a real free variable. Free variables are used to create quantified formulas.
1599 They are also used to create polynomials.
1600
1601 >>> RealVar(0)
1602 Var(0)
1603 """
1604 return Var(idx, RealSort(ctx))
1605

Referenced by RealVarVector().

◆ RealVarVector()

RealVarVector ( int  n,
  ctx = None 
)
Create a list of Real free variables.
The variables have ids: 0, 1, ..., n-1

>>> x0, x1, x2, x3 = RealVarVector(4)
>>> x2
Var(2)

Definition at line 1606 of file z3py.py.

1606def RealVarVector(n: int, ctx= None):
1607 """
1608 Create a list of Real free variables.
1609 The variables have ids: 0, 1, ..., n-1
1610
1611 >>> x0, x1, x2, x3 = RealVarVector(4)
1612 >>> x2
1613 Var(2)
1614 """
1615 return [RealVar(i, ctx) for i in range(n)]
1616

◆ RealVector()

RealVector (   prefix,
  sz,
  ctx = None 
)
Return a list of real constants of size `sz`.

>>> X = RealVector('x', 3)
>>> X
[x__0, x__1, x__2]
>>> Sum(X)
x__0 + x__1 + x__2
>>> Sum(X).sort()
Real

Definition at line 3495 of file z3py.py.

3495def RealVector(prefix, sz, ctx=None):
3496 """Return a list of real constants of size `sz`.
3497
3498 >>> X = RealVector('x', 3)
3499 >>> X
3500 [x__0, x__1, x__2]
3501 >>> Sum(X)
3502 x__0 + x__1 + x__2
3503 >>> Sum(X).sort()
3504 Real
3505 """
3506 ctx = _get_ctx(ctx)
3507 return [Real("%s__%s" % (prefix, i), ctx) for i in range(sz)]
3508
3509

◆ RecAddDefinition()

RecAddDefinition (   f,
  args,
  body 
)
Set the body of a recursive function.
   Recursive definitions can be simplified if they are applied to ground
   arguments.
>>> ctx = Context()
>>> fac = RecFunction('fac', IntSort(ctx), IntSort(ctx))
>>> n = Int('n', ctx)
>>> RecAddDefinition(fac, n, If(n == 0, 1, n*fac(n-1)))
>>> simplify(fac(5))
120
>>> s = Solver(ctx=ctx)
>>> s.add(fac(n) < 3)
>>> s.check()
sat
>>> s.model().eval(fac(5))
120

Definition at line 986 of file z3py.py.

986def RecAddDefinition(f, args, body):
987 """Set the body of a recursive function.
988 Recursive definitions can be simplified if they are applied to ground
989 arguments.
990 >>> ctx = Context()
991 >>> fac = RecFunction('fac', IntSort(ctx), IntSort(ctx))
992 >>> n = Int('n', ctx)
993 >>> RecAddDefinition(fac, n, If(n == 0, 1, n*fac(n-1)))
994 >>> simplify(fac(5))
995 120
996 >>> s = Solver(ctx=ctx)
997 >>> s.add(fac(n) < 3)
998 >>> s.check()
999 sat
1000 >>> s.model().eval(fac(5))
1001 120
1002 """
1003 if is_app(args):
1004 args = [args]
1005 ctx = body.ctx
1006 args = _get_args(args)
1007 n = len(args)
1008 _args = (Ast * n)()
1009 for i in range(n):
1010 _args[i] = args[i].ast
1011 Z3_add_rec_def(ctx.ref(), f.ast, n, _args, body.ast)
1012
void Z3_API Z3_add_rec_def(Z3_context c, Z3_func_decl f, unsigned n, Z3_ast args[], Z3_ast body)
Define the body of a recursive function.

◆ RecFunction()

RecFunction (   name,
*  sig 
)
Create a new Z3 recursive with the given sorts.

Definition at line 968 of file z3py.py.

968def RecFunction(name, *sig):
969 """Create a new Z3 recursive with the given sorts."""
970 sig = _get_args(sig)
971 if z3_debug():
972 _z3_assert(len(sig) > 0, "At least two arguments expected")
973 arity = len(sig) - 1
974 rng = sig[arity]
975 if z3_debug():
976 _z3_assert(is_sort(rng), "Z3 sort expected")
977 dom = (Sort * arity)()
978 for i in range(arity):
979 if z3_debug():
980 _z3_assert(is_sort(sig[i]), "Z3 sort expected")
981 dom[i] = sig[i].ast
982 ctx = rng.ctx
983 return FuncDeclRef(Z3_mk_rec_func_decl(ctx.ref(), to_symbol(name, ctx), arity, dom, rng.ast), ctx)
984
985
Z3_func_decl Z3_API Z3_mk_rec_func_decl(Z3_context c, Z3_symbol s, unsigned domain_size, Z3_sort const domain[], Z3_sort range)
Declare a recursive function.

◆ Repeat()

Repeat (   t,
  max = 4294967295,
  ctx = None 
)
Return a tactic that keeps applying `t` until the goal is not modified anymore
or the maximum number of iterations `max` is reached.

>>> x, y = Ints('x y')
>>> c = And(Or(x == 0, x == 1), Or(y == 0, y == 1), x > y)
>>> t = Repeat(OrElse(Tactic('split-clause'), Tactic('skip')))
>>> r = t(c)
>>> for subgoal in r: print(subgoal)
[x == 0, y == 0, x > y]
[x == 0, y == 1, x > y]
[x == 1, y == 0, x > y]
[x == 1, y == 1, x > y]
>>> t = Then(t, Tactic('propagate-values'))
>>> t(c)
[[x == 1, y == 0]]

Definition at line 9238 of file z3py.py.

9238def Repeat(t, max=4294967295, ctx=None):
9239 """Return a tactic that keeps applying `t` until the goal is not modified anymore
9240 or the maximum number of iterations `max` is reached.
9241
9242 >>> x, y = Ints('x y')
9243 >>> c = And(Or(x == 0, x == 1), Or(y == 0, y == 1), x > y)
9244 >>> t = Repeat(OrElse(Tactic('split-clause'), Tactic('skip')))
9245 >>> r = t(c)
9246 >>> for subgoal in r: print(subgoal)
9247 [x == 0, y == 0, x > y]
9248 [x == 0, y == 1, x > y]
9249 [x == 1, y == 0, x > y]
9250 [x == 1, y == 1, x > y]
9251 >>> t = Then(t, Tactic('propagate-values'))
9252 >>> t(c)
9253 [[x == 1, y == 0]]
9254 """
9255 t = _to_tactic(t, ctx)
9256 return Tactic(Z3_tactic_repeat(t.ctx.ref(), t.tactic, max), t.ctx)
9257
9258
Z3_tactic Z3_API Z3_tactic_repeat(Z3_context c, Z3_tactic t, unsigned max)
Return a tactic that keeps applying t until the goal is not modified anymore or the maximum number of...

◆ RepeatBitVec()

RepeatBitVec (   n,
  a 
)
Return an expression representing `n` copies of `a`.

>>> x = BitVec('x', 8)
>>> n = RepeatBitVec(4, x)
>>> n
RepeatBitVec(4, x)
>>> n.size()
32
>>> v0 = BitVecVal(10, 4)
>>> print("%.x" % v0.as_long())
a
>>> v = simplify(RepeatBitVec(4, v0))
>>> v.size()
16
>>> print("%.x" % v.as_long())
aaaa

Definition at line 4617 of file z3py.py.

4617def RepeatBitVec(n, a):
4618 """Return an expression representing `n` copies of `a`.
4619
4620 >>> x = BitVec('x', 8)
4621 >>> n = RepeatBitVec(4, x)
4622 >>> n
4623 RepeatBitVec(4, x)
4624 >>> n.size()
4625 32
4626 >>> v0 = BitVecVal(10, 4)
4627 >>> print("%.x" % v0.as_long())
4628 a
4629 >>> v = simplify(RepeatBitVec(4, v0))
4630 >>> v.size()
4631 16
4632 >>> print("%.x" % v.as_long())
4633 aaaa
4634 """
4635 if z3_debug():
4636 _z3_assert(_is_int(n), "First argument must be an integer")
4637 _z3_assert(is_bv(a), "Second argument must be a Z3 bit-vector expression")
4638 return BitVecRef(Z3_mk_repeat(a.ctx_ref(), n, a.as_ast()), a.ctx)
4639
4640
Z3_ast Z3_API Z3_mk_repeat(Z3_context c, unsigned i, Z3_ast t1)
Repeat the given bit-vector up length i.

◆ Replace()

Replace (   s,
  src,
  dst 
)
Replace the first occurrence of 'src' by 'dst' in 's'
>>> r = Replace("aaa", "a", "b")
>>> simplify(r)
"baa"

Definition at line 11897 of file z3py.py.

11897def Replace(s, src, dst):
11898 """Replace the first occurrence of 'src' by 'dst' in 's'
11899 >>> r = Replace("aaa", "a", "b")
11900 >>> simplify(r)
11901 "baa"
11902 """
11903 ctx = _get_ctx2(dst, s)
11904 if ctx is None and is_expr(src):
11905 ctx = src.ctx
11906 src = _coerce_seq(src, ctx)
11907 dst = _coerce_seq(dst, ctx)
11908 s = _coerce_seq(s, ctx)
11909 return SeqRef(Z3_mk_seq_replace(src.ctx_ref(), s.as_ast(), src.as_ast(), dst.as_ast()), s.ctx)
11910
11911
Z3_ast Z3_API Z3_mk_seq_replace(Z3_context c, Z3_ast s, Z3_ast src, Z3_ast dst)
Replace the first occurrence of src with dst in s.

◆ reset_params()

None reset_params ( )
Reset all global (or module) parameters.

Definition at line 322 of file z3py.py.

322def reset_params() -> None:
323 """Reset all global (or module) parameters.
324 """
326
327
void Z3_API Z3_global_param_reset_all(void)
Restore the value of all global (and module) parameters. This command will not affect already created...

◆ ReSort()

ReSort (   s)

Definition at line 12041 of file z3py.py.

12041def ReSort(s):
12042 if is_ast(s):
12043 return ReSortRef(Z3_mk_re_sort(s.ctx.ref(), s.ast), s.ctx)
12044 if s is None or isinstance(s, Context):
12045 ctx = _get_ctx(s)
12046 return ReSortRef(Z3_mk_re_sort(ctx.ref(), Z3_mk_string_sort(ctx.ref())), s.ctx)
12047 raise Z3Exception("Regular expression sort constructor expects either a string or a context or no argument")
12048
12049
Z3_sort Z3_API Z3_mk_re_sort(Z3_context c, Z3_sort seq)
Create a regular expression sort out of a sequence sort.
Z3_sort Z3_API Z3_mk_string_sort(Z3_context c)
Create a sort for unicode strings.

◆ RNA()

RNA (   ctx = None)

Definition at line 10500 of file z3py.py.

10500def RNA(ctx=None):
10501 ctx = _get_ctx(ctx)
10502 return FPRMRef(Z3_mk_fpa_round_nearest_ties_to_away(ctx.ref()), ctx)
10503
10504
Z3_ast Z3_API Z3_mk_fpa_round_nearest_ties_to_away(Z3_context c)
Create a numeral of RoundingMode sort which represents the NearestTiesToAway rounding mode.

◆ RNE()

RNE (   ctx = None)

Definition at line 10490 of file z3py.py.

10490def RNE(ctx=None):
10491 ctx = _get_ctx(ctx)
10492 return FPRMRef(Z3_mk_fpa_round_nearest_ties_to_even(ctx.ref()), ctx)
10493
10494
Z3_ast Z3_API Z3_mk_fpa_round_nearest_ties_to_even(Z3_context c)
Create a numeral of RoundingMode sort which represents the NearestTiesToEven rounding mode.

◆ RotateLeft()

RotateLeft (   a,
  b 
)
Return an expression representing `a` rotated to the left `b` times.

>>> a, b = BitVecs('a b', 16)
>>> RotateLeft(a, b)
RotateLeft(a, b)
>>> simplify(RotateLeft(a, 0))
a
>>> simplify(RotateLeft(a, 16))
a

Definition at line 4527 of file z3py.py.

4527def RotateLeft(a, b):
4528 """Return an expression representing `a` rotated to the left `b` times.
4529
4530 >>> a, b = BitVecs('a b', 16)
4531 >>> RotateLeft(a, b)
4532 RotateLeft(a, b)
4533 >>> simplify(RotateLeft(a, 0))
4534 a
4535 >>> simplify(RotateLeft(a, 16))
4536 a
4537 """
4538 _check_bv_args(a, b)
4539 a, b = _coerce_exprs(a, b)
4540 return BitVecRef(Z3_mk_ext_rotate_left(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4541
4542
Z3_ast Z3_API Z3_mk_ext_rotate_left(Z3_context c, Z3_ast t1, Z3_ast t2)
Rotate bits of t1 to the left t2 times.

◆ RotateRight()

RotateRight (   a,
  b 
)
Return an expression representing `a` rotated to the right `b` times.

>>> a, b = BitVecs('a b', 16)
>>> RotateRight(a, b)
RotateRight(a, b)
>>> simplify(RotateRight(a, 0))
a
>>> simplify(RotateRight(a, 16))
a

Definition at line 4543 of file z3py.py.

4543def RotateRight(a, b):
4544 """Return an expression representing `a` rotated to the right `b` times.
4545
4546 >>> a, b = BitVecs('a b', 16)
4547 >>> RotateRight(a, b)
4548 RotateRight(a, b)
4549 >>> simplify(RotateRight(a, 0))
4550 a
4551 >>> simplify(RotateRight(a, 16))
4552 a
4553 """
4554 _check_bv_args(a, b)
4555 a, b = _coerce_exprs(a, b)
4556 return BitVecRef(Z3_mk_ext_rotate_right(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4557
4558
Z3_ast Z3_API Z3_mk_ext_rotate_right(Z3_context c, Z3_ast t1, Z3_ast t2)
Rotate bits of t1 to the right t2 times.

◆ RoundNearestTiesToAway()

RoundNearestTiesToAway (   ctx = None)

Definition at line 10495 of file z3py.py.

10495def RoundNearestTiesToAway(ctx=None):
10496 ctx = _get_ctx(ctx)
10497 return FPRMRef(Z3_mk_fpa_round_nearest_ties_to_away(ctx.ref()), ctx)
10498
10499

◆ RoundNearestTiesToEven()

RoundNearestTiesToEven (   ctx = None)

Definition at line 10485 of file z3py.py.

10485def RoundNearestTiesToEven(ctx=None):
10486 ctx = _get_ctx(ctx)
10487 return FPRMRef(Z3_mk_fpa_round_nearest_ties_to_even(ctx.ref()), ctx)
10488
10489

◆ RoundTowardNegative()

RoundTowardNegative (   ctx = None)

Definition at line 10515 of file z3py.py.

10515def RoundTowardNegative(ctx=None):
10516 ctx = _get_ctx(ctx)
10517 return FPRMRef(Z3_mk_fpa_round_toward_negative(ctx.ref()), ctx)
10518
10519
Z3_ast Z3_API Z3_mk_fpa_round_toward_negative(Z3_context c)
Create a numeral of RoundingMode sort which represents the TowardNegative rounding mode.

◆ RoundTowardPositive()

RoundTowardPositive (   ctx = None)

Definition at line 10505 of file z3py.py.

10505def RoundTowardPositive(ctx=None):
10506 ctx = _get_ctx(ctx)
10507 return FPRMRef(Z3_mk_fpa_round_toward_positive(ctx.ref()), ctx)
10508
10509
Z3_ast Z3_API Z3_mk_fpa_round_toward_positive(Z3_context c)
Create a numeral of RoundingMode sort which represents the TowardPositive rounding mode.

◆ RoundTowardZero()

RoundTowardZero (   ctx = None)

Definition at line 10525 of file z3py.py.

10525def RoundTowardZero(ctx=None):
10526 ctx = _get_ctx(ctx)
10527 return FPRMRef(Z3_mk_fpa_round_toward_zero(ctx.ref()), ctx)
10528
10529
Z3_ast Z3_API Z3_mk_fpa_round_toward_zero(Z3_context c)
Create a numeral of RoundingMode sort which represents the TowardZero rounding mode.

◆ RTN()

RTN (   ctx = None)

Definition at line 10520 of file z3py.py.

10520def RTN(ctx=None):
10521 ctx = _get_ctx(ctx)
10522 return FPRMRef(Z3_mk_fpa_round_toward_negative(ctx.ref()), ctx)
10523
10524

◆ RTP()

RTP (   ctx = None)

Definition at line 10510 of file z3py.py.

10510def RTP(ctx=None):
10511 ctx = _get_ctx(ctx)
10512 return FPRMRef(Z3_mk_fpa_round_toward_positive(ctx.ref()), ctx)
10513
10514

◆ RTZ()

RTZ (   ctx = None)

Definition at line 10530 of file z3py.py.

10530def RTZ(ctx=None):
10531 ctx = _get_ctx(ctx)
10532 return FPRMRef(Z3_mk_fpa_round_toward_zero(ctx.ref()), ctx)
10533
10534

◆ Select()

Select (   a,
*  args 
)
Return a Z3 select array expression.

>>> a = Array('a', IntSort(), IntSort())
>>> i = Int('i')
>>> Select(a, i)
a[i]
>>> eq(Select(a, i), a[i])
True

Definition at line 5044 of file z3py.py.

5044def Select(a, *args):
5045 """Return a Z3 select array expression.
5046
5047 >>> a = Array('a', IntSort(), IntSort())
5048 >>> i = Int('i')
5049 >>> Select(a, i)
5050 a[i]
5051 >>> eq(Select(a, i), a[i])
5052 True
5053 """
5054 args = _get_args(args)
5055 if z3_debug():
5056 _z3_assert(is_array_sort(a), "First argument must be a Z3 array expression")
5057 return a[args]
5058
5059

◆ SeqFoldLeft()

SeqFoldLeft (   f,
  a,
  s 
)

Definition at line 11974 of file z3py.py.

11974def SeqFoldLeft(f, a, s):
11975 ctx = _get_ctx2(f, s)
11976 s = _coerce_seq(s, ctx)
11977 a = _py2expr(a)
11978 return _to_expr_ref(Z3_mk_seq_foldl(s.ctx_ref(), f.as_ast(), a.as_ast(), s.as_ast()), ctx)
11979
Z3_ast Z3_API Z3_mk_seq_foldl(Z3_context c, Z3_ast f, Z3_ast a, Z3_ast s)
Create a fold of the function f over the sequence s with accumulator a.

◆ SeqFoldLeftI()

SeqFoldLeftI (   f,
  i,
  a,
  s 
)

Definition at line 11980 of file z3py.py.

11980def SeqFoldLeftI(f, i, a, s):
11981 ctx = _get_ctx2(f, s)
11982 s = _coerce_seq(s, ctx)
11983 a = _py2expr(a)
11984 i = _py2expr(i)
11985 return _to_expr_ref(Z3_mk_seq_foldli(s.ctx_ref(), f.as_ast(), i.as_ast(), a.as_ast(), s.as_ast()), ctx)
11986
Z3_ast Z3_API Z3_mk_seq_foldli(Z3_context c, Z3_ast f, Z3_ast i, Z3_ast a, Z3_ast s)
Create a fold with index tracking of the function f over the sequence s with accumulator a starting a...

◆ SeqMap()

SeqMap (   f,
  s 
)
Map function 'f' over sequence 's'

Definition at line 11960 of file z3py.py.

11960def SeqMap(f, s):
11961 """Map function 'f' over sequence 's'"""
11962 ctx = _get_ctx2(f, s)
11963 s = _coerce_seq(s, ctx)
11964 return _to_expr_ref(Z3_mk_seq_map(s.ctx_ref(), f.as_ast(), s.as_ast()), ctx)
11965
Z3_ast Z3_API Z3_mk_seq_map(Z3_context c, Z3_ast f, Z3_ast s)
Create a map of the function f over the sequence s.

◆ SeqMapI()

SeqMapI (   f,
  i,
  s 
)
Map function 'f' over sequence 's' at index 'i'

Definition at line 11966 of file z3py.py.

11966def SeqMapI(f, i, s):
11967 """Map function 'f' over sequence 's' at index 'i'"""
11968 ctx = _get_ctx2(f, s)
11969 s = _coerce_seq(s, ctx)
11970 if not is_expr(i):
11971 i = _py2expr(i)
11972 return _to_expr_ref(Z3_mk_seq_mapi(s.ctx_ref(), f.as_ast(), i.as_ast(), s.as_ast()), ctx)
11973
Z3_ast Z3_API Z3_mk_seq_mapi(Z3_context c, Z3_ast f, Z3_ast i, Z3_ast s)
Create a map of the function f over the sequence s starting at index i.

◆ SeqPower()

SeqPower (   s,
  n 
)
Concatenate the sequence 's' with itself 'n' times. It is the empty sequence for n <= 0
>>> p = SeqPower(StringVal("ab"), 2)
>>> simplify(p)
"abab"

Definition at line 11950 of file z3py.py.

11950def SeqPower(s, n):
11951 """Concatenate the sequence 's' with itself 'n' times. It is the empty sequence for n <= 0
11952 >>> p = SeqPower(StringVal("ab"), 2)
11953 >>> simplify(p)
11954 "abab"
11955 """
11956 s = _coerce_seq(s)
11957 n = _py2expr(n, s.ctx)
11958 return SeqRef(Z3_mk_seq_power(s.ctx_ref(), s.as_ast(), n.as_ast()), s.ctx)
11959
Z3_ast Z3_API Z3_mk_seq_power(Z3_context c, Z3_ast s, Z3_ast n)
Create the sequence s concatenated n times with itself. The result is the empty sequence when n is no...

◆ SeqSort()

SeqSort (   s)
Create a sequence sort over elements provided in the argument
>>> s = SeqSort(IntSort())
>>> s == Unit(IntVal(1)).sort()
True

Definition at line 11594 of file z3py.py.

11594def SeqSort(s):
11595 """Create a sequence sort over elements provided in the argument
11596 >>> s = SeqSort(IntSort())
11597 >>> s == Unit(IntVal(1)).sort()
11598 True
11599 """
11600 return SeqSortRef(Z3_mk_seq_sort(s.ctx_ref(), s.ast), s.ctx)
11601
11602
Z3_sort Z3_API Z3_mk_seq_sort(Z3_context c, Z3_sort s)
Create a sequence sort out of the sort for the elements.

◆ set_default_fp_sort()

set_default_fp_sort (   ebits,
  sbits,
  ctx = None 
)

Definition at line 10146 of file z3py.py.

10146def set_default_fp_sort(ebits, sbits, ctx=None):
10147 global _dflt_fpsort_ebits
10148 global _dflt_fpsort_sbits
10149 _dflt_fpsort_ebits = ebits
10150 _dflt_fpsort_sbits = sbits
10151
10152

◆ set_default_rounding_mode()

set_default_rounding_mode (   rm,
  ctx = None 
)

Definition at line 10133 of file z3py.py.

10133def set_default_rounding_mode(rm, ctx=None):
10134 global _dflt_rounding_mode
10135 if is_fprm_value(rm):
10136 _dflt_rounding_mode = rm.kind()
10137 else:
10138 _z3_assert(_dflt_rounding_mode in _ROUNDING_MODES, "illegal rounding mode")
10139 _dflt_rounding_mode = rm
10140
10141

◆ set_option()

set_option ( *  args,
**  kws 
)
Alias for 'set_param' for backward compatibility.

Definition at line 328 of file z3py.py.

328def set_option(*args, **kws):
329 """Alias for 'set_param' for backward compatibility.
330 """
331 return set_param(*args, **kws)
332
333

◆ set_param()

set_param ( *  args,
**  kws 
)
Set Z3 global (or module) parameters.

>>> set_param(precision=10)

Definition at line 298 of file z3py.py.

298def set_param(*args, **kws):
299 """Set Z3 global (or module) parameters.
300
301 >>> set_param(precision=10)
302 """
303 if z3_debug():
304 _z3_assert(len(args) % 2 == 0, "Argument list must have an even number of elements.")
305 new_kws = {}
306 for k in kws:
307 v = kws[k]
308 if not set_pp_option(k, v):
309 new_kws[k] = v
310 for key in new_kws:
311 value = new_kws[key]
312 Z3_global_param_set(str(key).upper(), _to_param_value(value))
313 prev = None
314 for a in args:
315 if prev is None:
316 prev = a
317 else:
318 Z3_global_param_set(str(prev), _to_param_value(a))
319 prev = None
320
321
void Z3_API Z3_global_param_set(Z3_string param_id, Z3_string param_value)
Set a global (or module) parameter. This setting is shared by all Z3 contexts.

Referenced by set_option().

◆ SetAdd()

SetAdd (   s,
  e 
)
 Add element e to set s
>>> a = Const('a', SetSort(IntSort()))
>>> SetAdd(a, 1)
Store(a, 1, True)

Definition at line 5223 of file z3py.py.

5223def SetAdd(s, e):
5224 """ Add element e to set s
5225 >>> a = Const('a', SetSort(IntSort()))
5226 >>> SetAdd(a, 1)
5227 Store(a, 1, True)
5228 """
5229 ctx = _ctx_from_ast_arg_list([s, e])
5230 e = _py2expr(e, ctx)
5231 if is_finite_set(s):
5232 return FiniteSetSingleton(e) | s
5233 return ArrayRef(Z3_mk_set_add(ctx.ref(), s.as_ast(), e.as_ast()), ctx)
5234
5235
Z3_ast Z3_API Z3_mk_set_add(Z3_context c, Z3_ast set, Z3_ast elem)
Add an element to a set.

◆ SetComplement()

SetComplement (   s)
 The complement of set s
>>> a = Const('a', SetSort(IntSort()))
>>> SetComplement(a)
complement(a)

Definition at line 5249 of file z3py.py.

5249def SetComplement(s):
5250 """ The complement of set s
5251 >>> a = Const('a', SetSort(IntSort()))
5252 >>> SetComplement(a)
5253 complement(a)
5254 """
5255 ctx = s.ctx
5256 return ArrayRef(Z3_mk_set_complement(ctx.ref(), s.as_ast()), ctx)
5257
5258
Z3_ast Z3_API Z3_mk_set_complement(Z3_context c, Z3_ast arg)
Take the complement of a set.

◆ SetDel()

SetDel (   s,
  e 
)
 Remove element e to set s
>>> a = Const('a', SetSort(IntSort()))
>>> SetDel(a, 1)
Store(a, 1, False)

Definition at line 5236 of file z3py.py.

5236def SetDel(s, e):
5237 """ Remove element e to set s
5238 >>> a = Const('a', SetSort(IntSort()))
5239 >>> SetDel(a, 1)
5240 Store(a, 1, False)
5241 """
5242 ctx = _ctx_from_ast_arg_list([s, e])
5243 e = _py2expr(e, ctx)
5244 if is_finite_set(s):
5245 return s - FiniteSetSingleton(e)
5246 return ArrayRef(Z3_mk_set_del(ctx.ref(), s.as_ast(), e.as_ast()), ctx)
5247
5248
Z3_ast Z3_API Z3_mk_set_del(Z3_context c, Z3_ast set, Z3_ast elem)
Remove an element to a set.

◆ SetDifference()

SetDifference (   a,
  b 
)
 The set difference of a and b
>>> a = Const('a', SetSort(IntSort()))
>>> b = Const('b', SetSort(IntSort()))
>>> SetDifference(a, b)
setminus(a, b)

Definition at line 5259 of file z3py.py.

5259def SetDifference(a, b):
5260 """ The set difference of a and b
5261 >>> a = Const('a', SetSort(IntSort()))
5262 >>> b = Const('b', SetSort(IntSort()))
5263 >>> SetDifference(a, b)
5264 setminus(a, b)
5265 """
5266 ctx = _ctx_from_ast_arg_list([a, b])
5267 if is_finite_set(a):
5268 return FiniteSetDifference(a, b)
5269 return ArrayRef(Z3_mk_set_difference(ctx.ref(), a.as_ast(), b.as_ast()), ctx)
5270
5271
Z3_ast Z3_API Z3_mk_set_difference(Z3_context c, Z3_ast arg1, Z3_ast arg2)
Take the set difference between two sets.

◆ SetIntersect()

SetIntersect ( *  args)
 Take the union of sets
>>> a = Const('a', SetSort(IntSort()))
>>> b = Const('b', SetSort(IntSort()))
>>> SetIntersect(a, b)
intersection(a, b)

Definition at line 5207 of file z3py.py.

5207def SetIntersect(*args):
5208 """ Take the union of sets
5209 >>> a = Const('a', SetSort(IntSort()))
5210 >>> b = Const('b', SetSort(IntSort()))
5211 >>> SetIntersect(a, b)
5212 intersection(a, b)
5213 """
5214 args = _get_args(args)
5215 ctx = _ctx_from_ast_arg_list(args)
5216 if len(args) > 0 and is_finite_set(args[0]):
5217 from functools import reduce
5218 return reduce(FiniteSetIntersect, args)
5219 _args, sz = _to_ast_array(args)
5220 return ArrayRef(Z3_mk_set_intersect(ctx.ref(), sz, _args), ctx)
5221
5222
Z3_ast Z3_API Z3_mk_set_intersect(Z3_context c, unsigned num_args, Z3_ast const args[])
Take the intersection of a list of sets.

◆ SetSort()

SetSort (   s)

Sets.

 Create a set sort over element sort s

Definition at line 5166 of file z3py.py.

5166def SetSort(s):
5167 """ Create a set sort over element sort s"""
5168 return ArraySort(s, BoolSort())
5169
5170

◆ SetUnion()

SetUnion ( *  args)
 Take the union of sets
>>> a = Const('a', SetSort(IntSort()))
>>> b = Const('b', SetSort(IntSort()))
>>> SetUnion(a, b)
union(a, b)

Definition at line 5191 of file z3py.py.

5191def SetUnion(*args):
5192 """ Take the union of sets
5193 >>> a = Const('a', SetSort(IntSort()))
5194 >>> b = Const('b', SetSort(IntSort()))
5195 >>> SetUnion(a, b)
5196 union(a, b)
5197 """
5198 args = _get_args(args)
5199 if len(args) > 0 and is_finite_set(args[0]):
5200 from functools import reduce
5201 return reduce(FiniteSetUnion, args)
5202 ctx = _ctx_from_ast_arg_list(args)
5203 _args, sz = _to_ast_array(args)
5204 return ArrayRef(Z3_mk_set_union(ctx.ref(), sz, _args), ctx)
5205
5206
Z3_ast Z3_API Z3_mk_set_union(Z3_context c, unsigned num_args, Z3_ast const args[])
Take the union of a list of sets.

◆ SignExt()

SignExt (   n,
  a 
)
Return a bit-vector expression with `n` extra sign-bits.

>>> x = BitVec('x', 16)
>>> n = SignExt(8, x)
>>> n.size()
24
>>> n
SignExt(8, x)
>>> n.sort()
BitVec(24)
>>> v0 = BitVecVal(2, 2)
>>> v0
2
>>> v0.size()
2
>>> v  = simplify(SignExt(6, v0))
>>> v
254
>>> v.size()
8
>>> print("%.x" % v.as_long())
fe

Definition at line 4559 of file z3py.py.

4559def SignExt(n, a):
4560 """Return a bit-vector expression with `n` extra sign-bits.
4561
4562 >>> x = BitVec('x', 16)
4563 >>> n = SignExt(8, x)
4564 >>> n.size()
4565 24
4566 >>> n
4567 SignExt(8, x)
4568 >>> n.sort()
4569 BitVec(24)
4570 >>> v0 = BitVecVal(2, 2)
4571 >>> v0
4572 2
4573 >>> v0.size()
4574 2
4575 >>> v = simplify(SignExt(6, v0))
4576 >>> v
4577 254
4578 >>> v.size()
4579 8
4580 >>> print("%.x" % v.as_long())
4581 fe
4582 """
4583 if z3_debug():
4584 _z3_assert(_is_int(n), "First argument must be an integer")
4585 _z3_assert(is_bv(a), "Second argument must be a Z3 bit-vector expression")
4586 return BitVecRef(Z3_mk_sign_ext(a.ctx_ref(), n, a.as_ast()), a.ctx)
4587
4588
Z3_ast Z3_API Z3_mk_sign_ext(Z3_context c, unsigned i, Z3_ast t1)
Sign-extend of the given bit-vector to the (signed) equivalent bit-vector of size m+i,...

◆ SimpleSolver()

SimpleSolver (   ctx = None,
  logFile = None 
)
Return a simple general purpose solver with limited amount of preprocessing.

>>> s = SimpleSolver()
>>> x = Int('x')
>>> s.add(x > 0)
>>> s.check()
sat

Definition at line 8132 of file z3py.py.

8132def SimpleSolver(ctx=None, logFile=None):
8133 """Return a simple general purpose solver with limited amount of preprocessing.
8134
8135 >>> s = SimpleSolver()
8136 >>> x = Int('x')
8137 >>> s.add(x > 0)
8138 >>> s.check()
8139 sat
8140 """
8141 ctx = _get_ctx(ctx)
8142 return Solver(Z3_mk_simple_solver(ctx.ref()), ctx, logFile)
8143
Z3_solver Z3_API Z3_mk_simple_solver(Z3_context c)
Create a new incremental solver.

◆ simplifier_description()

simplifier_description (   name,
  ctx = None 
)
Return the description of the simplifier identified by name.

Definition at line 8940 of file z3py.py.

8940def simplifier_description(name, ctx=None):
8941 """Return the description of the simplifier identified by name."""
8942 return Z3_simplifier_get_descr(_get_ctx(ctx).ref(), name)
8943
8944
Z3_string Z3_API Z3_simplifier_get_descr(Z3_context c, Z3_string name)
Return a string containing a description of the simplifier with the given name.

◆ simplifier_name()

simplifier_name (   i,
  ctx = None 
)
Return the name of the i-th simplifier supported by the given context.

Definition at line 8935 of file z3py.py.

8935def simplifier_name(i, ctx=None):
8936 """Return the name of the i-th simplifier supported by the given context."""
8937 return Z3_get_simplifier_name(_get_ctx(ctx).ref(), i)
8938
8939
Z3_string Z3_API Z3_get_simplifier_name(Z3_context c, unsigned i)
Return the name of the idx simplifier.

◆ simplify()

simplify (   a,
*  arguments,
**  keywords 
)

Utils.

Simplify the expression `a` using the given options.

This function has many options. Use `help_simplify` to obtain the complete list.

>>> x = Int('x')
>>> y = Int('y')
>>> simplify(x + 1 + y + x + 1)
2 + 2*x + y
>>> simplify((x + 1)*(y + 1), som=True)
1 + x + y + x*y
>>> simplify(Distinct(x, y, 1), blast_distinct=True)
And(Not(x == y), Not(x == 1), Not(y == 1))
>>> simplify(And(x == 0, y == 1), elim_and=True)
Not(Or(Not(x == 0), Not(y == 1)))

Definition at line 9590 of file z3py.py.

9590def simplify(a, *arguments, **keywords):
9591 """Simplify the expression `a` using the given options.
9592
9593 This function has many options. Use `help_simplify` to obtain the complete list.
9594
9595 >>> x = Int('x')
9596 >>> y = Int('y')
9597 >>> simplify(x + 1 + y + x + 1)
9598 2 + 2*x + y
9599 >>> simplify((x + 1)*(y + 1), som=True)
9600 1 + x + y + x*y
9601 >>> simplify(Distinct(x, y, 1), blast_distinct=True)
9602 And(Not(x == y), Not(x == 1), Not(y == 1))
9603 >>> simplify(And(x == 0, y == 1), elim_and=True)
9604 Not(Or(Not(x == 0), Not(y == 1)))
9605 """
9606 if z3_debug():
9607 _z3_assert(is_expr(a), "Z3 expression expected")
9608 if len(arguments) > 0 or len(keywords) > 0:
9609 p = args2params(arguments, keywords, a.ctx)
9610 return _to_expr_ref(Z3_simplify_ex(a.ctx_ref(), a.as_ast(), p.params), a.ctx)
9611 else:
9612 return _to_expr_ref(Z3_simplify(a.ctx_ref(), a.as_ast()), a.ctx)
9613
9614
Z3_ast Z3_API Z3_simplify(Z3_context c, Z3_ast a)
Interface to simplifier.
Z3_ast Z3_API Z3_simplify_ex(Z3_context c, Z3_ast a, Z3_params p)
Interface to simplifier.

Referenced by Q(), and RatVal().

◆ simplify_param_descrs()

simplify_param_descrs ( )
Return the set of parameter descriptions for Z3 `simplify` procedure.

Definition at line 9620 of file z3py.py.

9620def simplify_param_descrs():
9621 """Return the set of parameter descriptions for Z3 `simplify` procedure."""
9622 return ParamDescrsRef(Z3_simplify_get_param_descrs(main_ctx().ref()), main_ctx())
9623
9624
Z3_param_descrs Z3_API Z3_simplify_get_param_descrs(Z3_context c)
Return the parameter description set for the simplify procedure.

◆ Singleton()

Singleton (   elem)
Create a singleton finite set containing elem.
>>> Singleton(IntVal(1))
set.singleton(1)

Definition at line 5405 of file z3py.py.

5405def Singleton(elem):
5406 """Create a singleton finite set containing elem.
5407 >>> Singleton(IntVal(1))
5408 set.singleton(1)
5409 """
5410 ctx = elem.ctx
5411 return FiniteSetRef(Z3_mk_finite_set_singleton(ctx.ref(), elem.as_ast()), ctx)
5412
5413
Z3_ast Z3_API Z3_mk_finite_set_singleton(Z3_context c, Z3_ast elem)
Create a singleton finite set.

Referenced by FiniteSetSortRef.cast().

◆ solve()

solve ( *  args,
**  keywords 
)
Solve the constraints `*args`.

This is a simple function for creating demonstrations. It creates a solver,
configure it using the options in `keywords`, adds the constraints
in `args`, and invokes check.

>>> a = Int('a')
>>> solve(a > 0, a < 2)
[a = 1]

Definition at line 9852 of file z3py.py.

9852def solve(*args, **keywords):
9853 """Solve the constraints `*args`.
9854
9855 This is a simple function for creating demonstrations. It creates a solver,
9856 configure it using the options in `keywords`, adds the constraints
9857 in `args`, and invokes check.
9858
9859 >>> a = Int('a')
9860 >>> solve(a > 0, a < 2)
9861 [a = 1]
9862 """
9863 show = keywords.pop("show", False)
9864 s = Solver()
9865 s.set(**keywords)
9866 s.add(*args)
9867 if show:
9868 print(s)
9869 r = s.check()
9870 if r == unsat:
9871 print("no solution")
9872 elif r == unknown:
9873 print("failed to solve")
9874 try:
9875 print(s.model())
9876 except Z3Exception:
9877 return
9878 else:
9879 print(s.model())
9880
9881

◆ solve_using()

solve_using (   s,
*  args,
**  keywords 
)
Solve the constraints `*args` using solver `s`.

This is a simple function for creating demonstrations. It is similar to `solve`,
but it uses the given solver `s`.
It configures solver `s` using the options in `keywords`, adds the constraints
in `args`, and invokes check.

Definition at line 9882 of file z3py.py.

9882def solve_using(s, *args, **keywords):
9883 """Solve the constraints `*args` using solver `s`.
9884
9885 This is a simple function for creating demonstrations. It is similar to `solve`,
9886 but it uses the given solver `s`.
9887 It configures solver `s` using the options in `keywords`, adds the constraints
9888 in `args`, and invokes check.
9889 """
9890 show = keywords.pop("show", False)
9891 if z3_debug():
9892 _z3_assert(isinstance(s, Solver), "Solver object expected")
9893 s.set(**keywords)
9894 s.add(*args)
9895 if show:
9896 print("Problem:")
9897 print(s)
9898 r = s.check()
9899 if r == unsat:
9900 print("no solution")
9901 elif r == unknown:
9902 print("failed to solve")
9903 try:
9904 print(s.model())
9905 except Z3Exception:
9906 return
9907 else:
9908 if show:
9909 print("Solution:")
9910 print(s.model())
9911
9912

◆ SolverFor()

SolverFor (   logic,
  ctx = None,
  logFile = None 
)
Create a solver customized for the given logic.

The parameter `logic` is a string. It should be contains
the name of a SMT-LIB logic.
See http://www.smtlib.org/ for the name of all available logics.

>>> s = SolverFor("QF_LIA")
>>> x = Int('x')
>>> s.add(x > 0)
>>> s.add(x < 2)
>>> s.check()
sat
>>> s.model()
[x = 1]

Definition at line 8111 of file z3py.py.

8111def SolverFor(logic, ctx=None, logFile=None):
8112 """Create a solver customized for the given logic.
8113
8114 The parameter `logic` is a string. It should be contains
8115 the name of a SMT-LIB logic.
8116 See http://www.smtlib.org/ for the name of all available logics.
8117
8118 >>> s = SolverFor("QF_LIA")
8119 >>> x = Int('x')
8120 >>> s.add(x > 0)
8121 >>> s.add(x < 2)
8122 >>> s.check()
8123 sat
8124 >>> s.model()
8125 [x = 1]
8126 """
8127 ctx = _get_ctx(ctx)
8128 logic = to_symbol(logic)
8129 return Solver(Z3_mk_solver_for_logic(ctx.ref(), logic), ctx, logFile)
8130
8131
Z3_solver Z3_API Z3_mk_solver_for_logic(Z3_context c, Z3_symbol logic)
Create a new solver customized for the given logic. It behaves like Z3_mk_solver if the logic is unkn...

◆ Sqrt()

Sqrt (   a,
  ctx = None 
)
 Return a Z3 expression which represents the square root of a.

>>> x = Real('x')
>>> Sqrt(x)
x**(1/2)

Definition at line 3579 of file z3py.py.

3579def Sqrt(a, ctx=None):
3580 """ Return a Z3 expression which represents the square root of a.
3581
3582 >>> x = Real('x')
3583 >>> Sqrt(x)
3584 x**(1/2)
3585 """
3586 if not is_expr(a):
3587 ctx = _get_ctx(ctx)
3588 a = RealVal(a, ctx)
3589 return a ** "1/2"
3590
3591

◆ SRem()

SRem (   a,
  b 
)
Create the Z3 expression signed remainder.

Use the operator % for signed modulus, and URem() for unsigned remainder.

>>> x = BitVec('x', 32)
>>> y = BitVec('y', 32)
>>> SRem(x, y)
SRem(x, y)
>>> SRem(x, y).sort()
BitVec(32)
>>> (x % y).sexpr()
'(bvsmod x y)'
>>> SRem(x, y).sexpr()
'(bvsrem x y)'

Definition at line 4474 of file z3py.py.

4474def SRem(a, b):
4475 """Create the Z3 expression signed remainder.
4476
4477 Use the operator % for signed modulus, and URem() for unsigned remainder.
4478
4479 >>> x = BitVec('x', 32)
4480 >>> y = BitVec('y', 32)
4481 >>> SRem(x, y)
4482 SRem(x, y)
4483 >>> SRem(x, y).sort()
4484 BitVec(32)
4485 >>> (x % y).sexpr()
4486 '(bvsmod x y)'
4487 >>> SRem(x, y).sexpr()
4488 '(bvsrem x y)'
4489 """
4490 _check_bv_args(a, b)
4491 a, b = _coerce_exprs(a, b)
4492 return BitVecRef(Z3_mk_bvsrem(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4493
4494
Z3_ast Z3_API Z3_mk_bvsrem(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed remainder (sign follows dividend).

◆ Star()

Star (   re)
Create the regular expression accepting zero or more repetitions of argument.
>>> re = Star(Re("a"))
>>> print(simplify(InRe("aa", re)))
True
>>> print(simplify(InRe("ab", re)))
False
>>> print(simplify(InRe("", re)))
True

Definition at line 12164 of file z3py.py.

12164def Star(re):
12165 """Create the regular expression accepting zero or more repetitions of argument.
12166 >>> re = Star(Re("a"))
12167 >>> print(simplify(InRe("aa", re)))
12168 True
12169 >>> print(simplify(InRe("ab", re)))
12170 False
12171 >>> print(simplify(InRe("", re)))
12172 True
12173 """
12174 if z3_debug():
12175 _z3_assert(is_expr(re), "expression expected")
12176 return ReRef(Z3_mk_re_star(re.ctx_ref(), re.as_ast()), re.ctx)
12177
12178
Z3_ast Z3_API Z3_mk_re_star(Z3_context c, Z3_ast re)
Create the regular language re*.

◆ Store()

Store (   a,
*  args 
)
Return a Z3 store array expression.

>>> a    = Array('a', IntSort(), IntSort())
>>> i, v = Ints('i v')
>>> s    = Store(a, i, v)
>>> s.sort()
Array(Int, Int)
>>> prove(s[i] == v)
proved
>>> j    = Int('j')
>>> prove(Implies(i != j, s[j] == a[j]))
proved

Definition at line 5027 of file z3py.py.

5027def Store(a, *args):
5028 """Return a Z3 store array expression.
5029
5030 >>> a = Array('a', IntSort(), IntSort())
5031 >>> i, v = Ints('i v')
5032 >>> s = Store(a, i, v)
5033 >>> s.sort()
5034 Array(Int, Int)
5035 >>> prove(s[i] == v)
5036 proved
5037 >>> j = Int('j')
5038 >>> prove(Implies(i != j, s[j] == a[j]))
5039 proved
5040 """
5041 return Update(a, args)
5042
5043

Referenced by ModelRef.get_interp().

◆ StrFromCode()

StrFromCode (   c)
Convert code to a string

Definition at line 12016 of file z3py.py.

12016def StrFromCode(c):
12017 """Convert code to a string"""
12018 if not is_expr(c):
12019 c = _py2expr(c)
12020 return SeqRef(Z3_mk_string_from_code(c.ctx_ref(), c.as_ast()), c.ctx)
12021
Z3_ast Z3_API Z3_mk_string_from_code(Z3_context c, Z3_ast a)
Code to string conversion.

◆ String()

String (   name,
  ctx = None 
)
Return a string constant named `name`. If `ctx=None`, then the global context is used.

>>> x = String('x')

Definition at line 11763 of file z3py.py.

11763def String(name, ctx=None):
11764 """Return a string constant named `name`. If `ctx=None`, then the global context is used.
11765
11766 >>> x = String('x')
11767 """
11768 ctx = _get_ctx(ctx)
11769 return SeqRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), StringSort(ctx).ast), ctx)
11770
11771

◆ Strings()

Strings (   names,
  ctx = None 
)
Return a tuple of String constants. 

Definition at line 11772 of file z3py.py.

11772def Strings(names, ctx=None):
11773 """Return a tuple of String constants. """
11774 ctx = _get_ctx(ctx)
11775 if isinstance(names, str):
11776 names = names.split(" ")
11777 return [String(name, ctx) for name in names]
11778
11779

◆ StringSort()

StringSort (   ctx = None)
Create a string sort
>>> s = StringSort()
>>> print(s)
String

Definition at line 11575 of file z3py.py.

11575def StringSort(ctx=None):
11576 """Create a string sort
11577 >>> s = StringSort()
11578 >>> print(s)
11579 String
11580 """
11581 ctx = _get_ctx(ctx)
11582 return SeqSortRef(Z3_mk_string_sort(ctx.ref()), ctx)
11583

◆ StringVal()

StringVal (   s,
  ctx = None 
)
create a string expression

Definition at line 11756 of file z3py.py.

11756def StringVal(s, ctx=None):
11757 """create a string expression"""
11758 s = "".join(str(ch) if 32 <= ord(ch) and ord(ch) < 127 else "\\u{%x}" % (ord(ch)) for ch in s)
11759 ctx = _get_ctx(ctx)
11760 return SeqRef(Z3_mk_string(ctx.ref(), s), ctx)
11761
11762
Z3_ast Z3_API Z3_mk_string(Z3_context c, Z3_string s)
Create a string constant out of the string that is passed in The string may contain escape encoding f...

Referenced by _coerce_exprs(), _py2expr(), and Extract().

◆ StrToCode()

StrToCode (   s)
Convert a unit length string to integer code

Definition at line 12010 of file z3py.py.

12010def StrToCode(s):
12011 """Convert a unit length string to integer code"""
12012 if not is_expr(s):
12013 s = _py2expr(s)
12014 return ArithRef(Z3_mk_string_to_code(s.ctx_ref(), s.as_ast()), s.ctx)
12015
Z3_ast Z3_API Z3_mk_string_to_code(Z3_context c, Z3_ast a)
String to code conversion.

◆ StrToInt()

StrToInt (   s)
Convert string expression to integer
>>> a = StrToInt("1")
>>> simplify(1 == a)
True
>>> b = StrToInt("2")
>>> simplify(1 == b)
False
>>> c = StrToInt(IntToStr(2))
>>> simplify(1 == c)
False

Definition at line 11987 of file z3py.py.

11987def StrToInt(s):
11988 """Convert string expression to integer
11989 >>> a = StrToInt("1")
11990 >>> simplify(1 == a)
11991 True
11992 >>> b = StrToInt("2")
11993 >>> simplify(1 == b)
11994 False
11995 >>> c = StrToInt(IntToStr(2))
11996 >>> simplify(1 == c)
11997 False
11998 """
11999 s = _coerce_seq(s)
12000 return ArithRef(Z3_mk_str_to_int(s.ctx_ref(), s.as_ast()), s.ctx)
12001
12002
Z3_ast Z3_API Z3_mk_str_to_int(Z3_context c, Z3_ast s)
Convert string to integer.

◆ SubSeq()

SubSeq (   s,
  offset,
  length 
)
Extract substring or subsequence starting at offset.

This is a convenience function that redirects to Extract(s, offset, length).

>>> s = StringVal("hello world")
>>> SubSeq(s, 0, 5)  # Extract "hello"  
str.substr("hello world", 0, 5)
>>> simplify(SubSeq(StringVal("testing"), 2, 4))
"stin"

Definition at line 11794 of file z3py.py.

11794def SubSeq(s, offset, length):
11795 """Extract substring or subsequence starting at offset.
11796
11797 This is a convenience function that redirects to Extract(s, offset, length).
11798
11799 >>> s = StringVal("hello world")
11800 >>> SubSeq(s, 0, 5) # Extract "hello"
11801 str.substr("hello world", 0, 5)
11802 >>> simplify(SubSeq(StringVal("testing"), 2, 4))
11803 "stin"
11804 """
11805 return Extract(s, offset, length)
11806
11807

◆ substitute()

substitute (   t,
*  m 
)
Apply substitution m on t, m is a list of pairs of the form (from, to).
Every occurrence in t of from is replaced with to.

>>> x = Int('x')
>>> y = Int('y')
>>> substitute(x + 1, (x, y + 1))
y + 1 + 1
>>> f = Function('f', IntSort(), IntSort())
>>> substitute(f(x) + f(y), (f(x), IntVal(1)), (f(y), IntVal(1)))
1 + 1

Definition at line 9625 of file z3py.py.

9625def substitute(t, *m):
9626 """Apply substitution m on t, m is a list of pairs of the form (from, to).
9627 Every occurrence in t of from is replaced with to.
9628
9629 >>> x = Int('x')
9630 >>> y = Int('y')
9631 >>> substitute(x + 1, (x, y + 1))
9632 y + 1 + 1
9633 >>> f = Function('f', IntSort(), IntSort())
9634 >>> substitute(f(x) + f(y), (f(x), IntVal(1)), (f(y), IntVal(1)))
9635 1 + 1
9636 """
9637 if isinstance(m, tuple):
9638 m1 = _get_args(m)
9639 if isinstance(m1, list) and all(isinstance(p, tuple) for p in m1):
9640 m = m1
9641 if z3_debug():
9642 _z3_assert(is_expr(t), "Z3 expression expected")
9643 _z3_assert(
9644 all([isinstance(p, tuple) and is_expr(p[0]) and is_expr(p[1]) for p in m]),
9645 "Z3 invalid substitution, expression pairs expected.")
9646 _z3_assert(
9647 all([p[0].sort().eq(p[1].sort()) for p in m]),
9648 'Z3 invalid substitution, mismatching "from" and "to" sorts.')
9649 num = len(m)
9650 _from = (Ast * num)()
9651 _to = (Ast * num)()
9652 for i in range(num):
9653 _from[i] = m[i][0].as_ast()
9654 _to[i] = m[i][1].as_ast()
9655 return _to_expr_ref(Z3_substitute(t.ctx.ref(), t.as_ast(), num, _from, _to), t.ctx)
9656
9657
Z3_ast Z3_API Z3_substitute(Z3_context c, Z3_ast a, unsigned num_exprs, Z3_ast const from[], Z3_ast const to[])
Substitute every occurrence of from[i] in a with to[i], for i smaller than num_exprs....

◆ substitute_funs()

substitute_funs (   t,
*  m 
)
Apply substitution m on t, m is a list of pairs of a function and expression (from, to)
Every occurrence in to of the function from is replaced with the expression to.
The expression to can have free variables, that refer to the arguments of from.
For examples, see 

Definition at line 9678 of file z3py.py.

9678def substitute_funs(t, *m):
9679 """Apply substitution m on t, m is a list of pairs of a function and expression (from, to)
9680 Every occurrence in to of the function from is replaced with the expression to.
9681 The expression to can have free variables, that refer to the arguments of from.
9682 For examples, see
9683 """
9684 if isinstance(m, tuple):
9685 m1 = _get_args(m)
9686 if isinstance(m1, list) and all(isinstance(p, tuple) for p in m1):
9687 m = m1
9688 if z3_debug():
9689 _z3_assert(is_expr(t), "Z3 expression expected")
9690 _z3_assert(all([isinstance(p, tuple) and is_func_decl(p[0]) and is_expr(p[1]) for p in m]), "Z3 invalid substitution, function pairs expected.")
9691 num = len(m)
9692 _from = (FuncDecl * num)()
9693 _to = (Ast * num)()
9694 for i in range(num):
9695 _from[i] = m[i][0].as_func_decl()
9696 _to[i] = m[i][1].as_ast()
9697 return _to_expr_ref(Z3_substitute_funs(t.ctx.ref(), t.as_ast(), num, _from, _to), t.ctx)
9698
9699
Z3_ast Z3_API Z3_substitute_funs(Z3_context c, Z3_ast a, unsigned num_funs, Z3_func_decl const from[], Z3_ast const to[])
Substitute functions in from with new expressions in to.

◆ substitute_vars()

substitute_vars (   t,
*  m 
)
Substitute the free variables in t with the expression in m.

>>> v0 = Var(0, IntSort())
>>> v1 = Var(1, IntSort())
>>> x  = Int('x')
>>> f  = Function('f', IntSort(), IntSort(), IntSort())
>>> # replace v0 with x+1 and v1 with x
>>> substitute_vars(f(v0, v1), x + 1, x)
f(x + 1, x)

Definition at line 9658 of file z3py.py.

9658def substitute_vars(t, *m):
9659 """Substitute the free variables in t with the expression in m.
9660
9661 >>> v0 = Var(0, IntSort())
9662 >>> v1 = Var(1, IntSort())
9663 >>> x = Int('x')
9664 >>> f = Function('f', IntSort(), IntSort(), IntSort())
9665 >>> # replace v0 with x+1 and v1 with x
9666 >>> substitute_vars(f(v0, v1), x + 1, x)
9667 f(x + 1, x)
9668 """
9669 if z3_debug():
9670 _z3_assert(is_expr(t), "Z3 expression expected")
9671 _z3_assert(all([is_expr(n) for n in m]), "Z3 invalid substitution, list of expressions expected.")
9672 num = len(m)
9673 _to = (Ast * num)()
9674 for i in range(num):
9675 _to[i] = m[i].as_ast()
9676 return _to_expr_ref(Z3_substitute_vars(t.ctx.ref(), t.as_ast(), num, _to), t.ctx)
9677
Z3_ast Z3_API Z3_substitute_vars(Z3_context c, Z3_ast a, unsigned num_exprs, Z3_ast const to[])
Substitute the variables in a with the expressions in to. For every i smaller than num_exprs,...

◆ SubString()

SubString (   s,
  offset,
  length 
)
Extract substring or subsequence starting at offset.

This is a convenience function that redirects to Extract(s, offset, length).

>>> s = StringVal("hello world") 
>>> SubString(s, 6, 5)  # Extract "world"
str.substr("hello world", 6, 5)
>>> simplify(SubString(StringVal("hello"), 1, 3))
"ell"

Definition at line 11780 of file z3py.py.

11780def SubString(s, offset, length):
11781 """Extract substring or subsequence starting at offset.
11782
11783 This is a convenience function that redirects to Extract(s, offset, length).
11784
11785 >>> s = StringVal("hello world")
11786 >>> SubString(s, 6, 5) # Extract "world"
11787 str.substr("hello world", 6, 5)
11788 >>> simplify(SubString(StringVal("hello"), 1, 3))
11789 "ell"
11790 """
11791 return Extract(s, offset, length)
11792
11793

◆ SuffixOf()

SuffixOf (   a,
  b 
)
Check if 'a' is a suffix of 'b'
>>> s1 = SuffixOf("ab", "abc")
>>> simplify(s1)
False
>>> s2 = SuffixOf("bc", "abc")
>>> simplify(s2)
True

Definition at line 11863 of file z3py.py.

11863def SuffixOf(a, b):
11864 """Check if 'a' is a suffix of 'b'
11865 >>> s1 = SuffixOf("ab", "abc")
11866 >>> simplify(s1)
11867 False
11868 >>> s2 = SuffixOf("bc", "abc")
11869 >>> simplify(s2)
11870 True
11871 """
11872 ctx = _get_ctx2(a, b)
11873 a = _coerce_seq(a, ctx)
11874 b = _coerce_seq(b, ctx)
11875 return BoolRef(Z3_mk_seq_suffix(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
11876
11877
Z3_ast Z3_API Z3_mk_seq_suffix(Z3_context c, Z3_ast suffix, Z3_ast s)
Check if suffix is a suffix of s.

◆ Sum()

Sum ( *  args)
Create the sum of the Z3 expressions.

>>> a, b, c = Ints('a b c')
>>> Sum(a, b, c)
a + b + c
>>> Sum([a, b, c])
a + b + c
>>> A = IntVector('a', 5)
>>> Sum(A)
a__0 + a__1 + a__2 + a__3 + a__4

Definition at line 9700 of file z3py.py.

9700def Sum(*args):
9701 """Create the sum of the Z3 expressions.
9702
9703 >>> a, b, c = Ints('a b c')
9704 >>> Sum(a, b, c)
9705 a + b + c
9706 >>> Sum([a, b, c])
9707 a + b + c
9708 >>> A = IntVector('a', 5)
9709 >>> Sum(A)
9710 a__0 + a__1 + a__2 + a__3 + a__4
9711 """
9712 args = _get_args(args)
9713 if len(args) == 0:
9714 return 0
9715 ctx = _ctx_from_ast_arg_list(args)
9716 if ctx is None:
9717 return _reduce(lambda a, b: a + b, args, 0)
9718 args = _coerce_expr_list(args, ctx)
9719 if is_bv(args[0]):
9720 return _reduce(lambda a, b: a + b, args, 0)
9721 else:
9722 _args, sz = _to_ast_array(args)
9723 return ArithRef(Z3_mk_add(ctx.ref(), sz, _args), ctx)
9724
9725
Z3_ast Z3_API Z3_mk_add(Z3_context c, unsigned num_args, Z3_ast const args[])
Create an AST node representing args[0] + ... + args[num_args-1].

◆ tactic_description()

tactic_description (   name,
  ctx = None 
)
Return a short description for the tactic named `name`.

>>> d = tactic_description('simplify')

Definition at line 9279 of file z3py.py.

9279def tactic_description(name, ctx=None):
9280 """Return a short description for the tactic named `name`.
9281
9282 >>> d = tactic_description('simplify')
9283 """
9284 ctx = _get_ctx(ctx)
9285 return Z3_tactic_get_descr(ctx.ref(), name)
9286
9287
Z3_string Z3_API Z3_tactic_get_descr(Z3_context c, Z3_string name)
Return a string containing a description of the tactic with the given name.

◆ tactics()

tactics (   ctx = None)
Return a list of all available tactics in Z3.

>>> l = tactics()
>>> l.count('simplify') == 1
True

Definition at line 9268 of file z3py.py.

9268def tactics(ctx=None):
9269 """Return a list of all available tactics in Z3.
9270
9271 >>> l = tactics()
9272 >>> l.count('simplify') == 1
9273 True
9274 """
9275 ctx = _get_ctx(ctx)
9276 return [Z3_get_tactic_name(ctx.ref(), i) for i in range(Z3_get_num_tactics(ctx.ref()))]
9277
9278
unsigned Z3_API Z3_get_num_tactics(Z3_context c)
Return the number of builtin tactics available in Z3.
Z3_string Z3_API Z3_get_tactic_name(Z3_context c, unsigned i)
Return the name of the idx tactic.

◆ Then()

Then ( *  ts,
**  ks 
)
Return a tactic that applies the tactics in `*ts` in sequence. Shorthand for AndThen(*ts, **ks).

>>> x, y = Ints('x y')
>>> t = Then(Tactic('simplify'), Tactic('solve-eqs'))
>>> t(And(x == 0, y > x + 1))
[[Not(y <= 1)]]
>>> t(And(x == 0, y > x + 1)).as_expr()
Not(y <= 1)

Definition at line 9136 of file z3py.py.

9136def Then(*ts, **ks):
9137 """Return a tactic that applies the tactics in `*ts` in sequence. Shorthand for AndThen(*ts, **ks).
9138
9139 >>> x, y = Ints('x y')
9140 >>> t = Then(Tactic('simplify'), Tactic('solve-eqs'))
9141 >>> t(And(x == 0, y > x + 1))
9142 [[Not(y <= 1)]]
9143 >>> t(And(x == 0, y > x + 1)).as_expr()
9144 Not(y <= 1)
9145 """
9146 return AndThen(*ts, **ks)
9147
9148

◆ to_Ast()

to_Ast (   ptr)

Definition at line 12248 of file z3py.py.

12248def to_Ast(ptr,):
12249 ast = Ast(ptr)
12250 super(ctypes.c_void_p, ast).__init__(ptr)
12251 return ast
12252

◆ to_AstVectorObj()

to_AstVectorObj (   ptr)

Definition at line 12258 of file z3py.py.

12258def to_AstVectorObj(ptr,):
12259 v = AstVectorObj(ptr)
12260 super(ctypes.c_void_p, v).__init__(ptr)
12261 return v
12262
12263# NB. my-hacky-class only works for a single instance of OnClause
12264# it should be replaced with a proper correlation between OnClause
12265# and object references that can be passed over the FFI.
12266# for UserPropagator we use a global dictionary, which isn't great code.
12267

◆ to_ContextObj()

to_ContextObj (   ptr)

Definition at line 12253 of file z3py.py.

12253def to_ContextObj(ptr,):
12254 ctx = ContextObj(ptr)
12255 super(ctypes.c_void_p, ctx).__init__(ptr)
12256 return ctx
12257

◆ to_symbol()

to_symbol (   s,
  ctx = None 
)
Convert an integer or string into a Z3 symbol.

Definition at line 132 of file z3py.py.

132def to_symbol(s, ctx = None):
133 """Convert an integer or string into a Z3 symbol."""
134 if _is_int(s):
135 return Z3_mk_int_symbol(_get_ctx(ctx).ref(), s)
136 else:
137 return Z3_mk_string_symbol(_get_ctx(ctx).ref(), s)
138
139
Z3_symbol Z3_API Z3_mk_string_symbol(Z3_context c, Z3_string s)
Create a Z3 symbol using a C string.
Z3_symbol Z3_API Z3_mk_int_symbol(Z3_context c, int i)
Create a Z3 symbol using an integer.

Referenced by _mk_quantifier(), Array(), BitVec(), Bool(), Const(), CreateDatatypes(), CreatePolymorphicDatatype(), DatatypeSort(), DeclareSort(), DeclareTypeVar(), EnumSort(), Function(), ParamDescrsRef.get_documentation(), ParamDescrsRef.get_kind(), Int(), Real(), RecFunction(), and ParamsRef.set().

◆ ToInt()

ToInt (   a)
 Return the Z3 expression ToInt(a).

>>> x = Real('x')
>>> x.sort()
Real
>>> n = ToInt(x)
>>> n
ToInt(x)
>>> n.sort()
Int

Definition at line 3544 of file z3py.py.

3544def ToInt(a):
3545 """ Return the Z3 expression ToInt(a).
3546
3547 >>> x = Real('x')
3548 >>> x.sort()
3549 Real
3550 >>> n = ToInt(x)
3551 >>> n
3552 ToInt(x)
3553 >>> n.sort()
3554 Int
3555 """
3556 if z3_debug():
3557 _z3_assert(a.is_real(), "Z3 real expression expected.")
3558 ctx = a.ctx
3559 return ArithRef(Z3_mk_real2int(ctx.ref(), a.as_ast()), ctx)
3560
3561
Z3_ast Z3_API Z3_mk_real2int(Z3_context c, Z3_ast t1)
Coerce a real to an integer.

◆ ToReal()

ToReal (   a)
 Return the Z3 expression ToReal(a).

>>> x = Int('x')
>>> x.sort()
Int
>>> n = ToReal(x)
>>> n
ToReal(x)
>>> n.sort()
Real

Definition at line 3524 of file z3py.py.

3524def ToReal(a):
3525 """ Return the Z3 expression ToReal(a).
3526
3527 >>> x = Int('x')
3528 >>> x.sort()
3529 Int
3530 >>> n = ToReal(x)
3531 >>> n
3532 ToReal(x)
3533 >>> n.sort()
3534 Real
3535 """
3536 ctx = a.ctx
3537 if isinstance(a, BoolRef):
3538 return If(a, RealVal(1, ctx), RealVal(0, ctx))
3539 if z3_debug():
3540 _z3_assert(a.is_int(), "Z3 integer expression expected.")
3541 return ArithRef(Z3_mk_int2real(ctx.ref(), a.as_ast()), ctx)
3542
3543
Z3_ast Z3_API Z3_mk_int2real(Z3_context c, Z3_ast t1)
Coerce an integer to a real.

◆ TransitiveClosure()

TransitiveClosure (   f)
Given a binary relation R, such that the two arguments have the same sort
create the transitive closure relation R+.
The transitive closure R+ is a new relation.

Definition at line 12241 of file z3py.py.

12241def TransitiveClosure(f):
12242 """Given a binary relation R, such that the two arguments have the same sort
12243 create the transitive closure relation R+.
12244 The transitive closure R+ is a new relation.
12245 """
12246 return FuncDeclRef(Z3_mk_transitive_closure(f.ctx_ref(), f.ast), f.ctx)
12247
Z3_func_decl Z3_API Z3_mk_transitive_closure(Z3_context c, Z3_func_decl f)
create transitive closure of binary relation.

◆ TreeOrder()

TreeOrder (   a,
  index 
)

Definition at line 12233 of file z3py.py.

12233def TreeOrder(a, index):
12234 return FuncDeclRef(Z3_mk_tree_order(a.ctx_ref(), a.ast, index), a.ctx)
12235
12236
Z3_func_decl Z3_API Z3_mk_tree_order(Z3_context c, Z3_sort a, unsigned id)
create a tree ordering relation over signature a identified using index id.

◆ TryFor()

TryFor (   t,
  ms,
  ctx = None 
)
Return a tactic that applies `t` to a given goal for `ms` milliseconds.

If `t` does not terminate in `ms` milliseconds, then it fails.

Definition at line 9259 of file z3py.py.

9259def TryFor(t, ms, ctx=None):
9260 """Return a tactic that applies `t` to a given goal for `ms` milliseconds.
9261
9262 If `t` does not terminate in `ms` milliseconds, then it fails.
9263 """
9264 t = _to_tactic(t, ctx)
9265 return Tactic(Z3_tactic_try_for(t.ctx.ref(), t.tactic, ms), t.ctx)
9266
9267
Z3_tactic Z3_API Z3_tactic_try_for(Z3_context c, Z3_tactic t, unsigned ms)
Return a tactic that applies t to a given goal for ms milliseconds. If t does not terminate in ms mil...

◆ TupleSort()

TupleSort (   name,
  sorts,
  ctx = None 
)
Create a named tuple sort base on a set of underlying sorts
Example:
    >>> pair, mk_pair, (first, second) = TupleSort("pair", [IntSort(), StringSort()])

Definition at line 5977 of file z3py.py.

5977def TupleSort(name, sorts, ctx=None):
5978 """Create a named tuple sort base on a set of underlying sorts
5979 Example:
5980 >>> pair, mk_pair, (first, second) = TupleSort("pair", [IntSort(), StringSort()])
5981 """
5982 tuple = Datatype(name, ctx)
5983 projects = [("project%d" % i, sorts[i]) for i in range(len(sorts))]
5984 tuple.declare(name, *projects)
5985 tuple = tuple.create()
5986 return tuple, tuple.constructor(0), [tuple.accessor(0, i) for i in range(len(sorts))]
5987
5988

◆ UDiv()

UDiv (   a,
  b 
)
Create the Z3 expression (unsigned) division `self / other`.

Use the operator / for signed division.

>>> x = BitVec('x', 32)
>>> y = BitVec('y', 32)
>>> UDiv(x, y)
UDiv(x, y)
>>> UDiv(x, y).sort()
BitVec(32)
>>> (x / y).sexpr()
'(bvsdiv x y)'
>>> UDiv(x, y).sexpr()
'(bvudiv x y)'

Definition at line 4432 of file z3py.py.

4432def UDiv(a, b):
4433 """Create the Z3 expression (unsigned) division `self / other`.
4434
4435 Use the operator / for signed division.
4436
4437 >>> x = BitVec('x', 32)
4438 >>> y = BitVec('y', 32)
4439 >>> UDiv(x, y)
4440 UDiv(x, y)
4441 >>> UDiv(x, y).sort()
4442 BitVec(32)
4443 >>> (x / y).sexpr()
4444 '(bvsdiv x y)'
4445 >>> UDiv(x, y).sexpr()
4446 '(bvudiv x y)'
4447 """
4448 _check_bv_args(a, b)
4449 a, b = _coerce_exprs(a, b)
4450 return BitVecRef(Z3_mk_bvudiv(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4451
4452
Z3_ast Z3_API Z3_mk_bvudiv(Z3_context c, Z3_ast t1, Z3_ast t2)
Unsigned division.

◆ UGE()

UGE (   a,
  b 
)
Create the Z3 expression (unsigned) `other >= self`.

Use the operator >= for signed greater than or equal to.

>>> x, y = BitVecs('x y', 32)
>>> UGE(x, y)
UGE(x, y)
>>> (x >= y).sexpr()
'(bvsge x y)'
>>> UGE(x, y).sexpr()
'(bvuge x y)'

Definition at line 4396 of file z3py.py.

4396def UGE(a, b):
4397 """Create the Z3 expression (unsigned) `other >= self`.
4398
4399 Use the operator >= for signed greater than or equal to.
4400
4401 >>> x, y = BitVecs('x y', 32)
4402 >>> UGE(x, y)
4403 UGE(x, y)
4404 >>> (x >= y).sexpr()
4405 '(bvsge x y)'
4406 >>> UGE(x, y).sexpr()
4407 '(bvuge x y)'
4408 """
4409 _check_bv_args(a, b)
4410 a, b = _coerce_exprs(a, b)
4411 return BoolRef(Z3_mk_bvuge(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4412
4413
Z3_ast Z3_API Z3_mk_bvuge(Z3_context c, Z3_ast t1, Z3_ast t2)
Unsigned greater than or equal to.

◆ UGT()

UGT (   a,
  b 
)
Create the Z3 expression (unsigned) `other > self`.

Use the operator > for signed greater than.

>>> x, y = BitVecs('x y', 32)
>>> UGT(x, y)
UGT(x, y)
>>> (x > y).sexpr()
'(bvsgt x y)'
>>> UGT(x, y).sexpr()
'(bvugt x y)'

Definition at line 4414 of file z3py.py.

4414def UGT(a, b):
4415 """Create the Z3 expression (unsigned) `other > self`.
4416
4417 Use the operator > for signed greater than.
4418
4419 >>> x, y = BitVecs('x y', 32)
4420 >>> UGT(x, y)
4421 UGT(x, y)
4422 >>> (x > y).sexpr()
4423 '(bvsgt x y)'
4424 >>> UGT(x, y).sexpr()
4425 '(bvugt x y)'
4426 """
4427 _check_bv_args(a, b)
4428 a, b = _coerce_exprs(a, b)
4429 return BoolRef(Z3_mk_bvugt(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4430
4431
Z3_ast Z3_API Z3_mk_bvugt(Z3_context c, Z3_ast t1, Z3_ast t2)
Unsigned greater than.

◆ ULE()

ULE (   a,
  b 
)
Create the Z3 expression (unsigned) `other <= self`.

Use the operator <= for signed less than or equal to.

>>> x, y = BitVecs('x y', 32)
>>> ULE(x, y)
ULE(x, y)
>>> (x <= y).sexpr()
'(bvsle x y)'
>>> ULE(x, y).sexpr()
'(bvule x y)'

Definition at line 4360 of file z3py.py.

4360def ULE(a, b):
4361 """Create the Z3 expression (unsigned) `other <= self`.
4362
4363 Use the operator <= for signed less than or equal to.
4364
4365 >>> x, y = BitVecs('x y', 32)
4366 >>> ULE(x, y)
4367 ULE(x, y)
4368 >>> (x <= y).sexpr()
4369 '(bvsle x y)'
4370 >>> ULE(x, y).sexpr()
4371 '(bvule x y)'
4372 """
4373 _check_bv_args(a, b)
4374 a, b = _coerce_exprs(a, b)
4375 return BoolRef(Z3_mk_bvule(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4376
4377
Z3_ast Z3_API Z3_mk_bvule(Z3_context c, Z3_ast t1, Z3_ast t2)
Unsigned less than or equal to.

◆ ULT()

ULT (   a,
  b 
)
Create the Z3 expression (unsigned) `other < self`.

Use the operator < for signed less than.

>>> x, y = BitVecs('x y', 32)
>>> ULT(x, y)
ULT(x, y)
>>> (x < y).sexpr()
'(bvslt x y)'
>>> ULT(x, y).sexpr()
'(bvult x y)'

Definition at line 4378 of file z3py.py.

4378def ULT(a, b):
4379 """Create the Z3 expression (unsigned) `other < self`.
4380
4381 Use the operator < for signed less than.
4382
4383 >>> x, y = BitVecs('x y', 32)
4384 >>> ULT(x, y)
4385 ULT(x, y)
4386 >>> (x < y).sexpr()
4387 '(bvslt x y)'
4388 >>> ULT(x, y).sexpr()
4389 '(bvult x y)'
4390 """
4391 _check_bv_args(a, b)
4392 a, b = _coerce_exprs(a, b)
4393 return BoolRef(Z3_mk_bvult(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4394
4395
Z3_ast Z3_API Z3_mk_bvult(Z3_context c, Z3_ast t1, Z3_ast t2)
Unsigned less than.

◆ Union()

Union ( *  args)
Create union of regular expressions.
>>> re = Union(Re("a"), Re("b"), Re("c"))
>>> print (simplify(InRe("d", re)))
False

Definition at line 12075 of file z3py.py.

12075def Union(*args):
12076 """Create union of regular expressions.
12077 >>> re = Union(Re("a"), Re("b"), Re("c"))
12078 >>> print (simplify(InRe("d", re)))
12079 False
12080 """
12081 args = _get_args(args)
12082 sz = len(args)
12083 if z3_debug():
12084 _z3_assert(sz > 0, "At least one argument expected.")
12085 arg0 = args[0]
12086 if is_finite_set(arg0):
12087 for a in args[1:]:
12088 if not is_finite_set(a):
12089 raise Z3Exception("All arguments must be regular expressions or finite sets.")
12090 arg0 = arg0 | a
12091 return arg0
12092 if z3_debug():
12093 _z3_assert(all([is_re(a) for a in args]), "All arguments must be regular expressions.")
12094 if sz == 1:
12095 return args[0]
12096 ctx = args[0].ctx
12097 v = (Ast * sz)()
12098 for i in range(sz):
12099 v[i] = args[i].as_ast()
12100 return ReRef(Z3_mk_re_union(ctx.ref(), sz, v), ctx)
12101
12102
Z3_ast Z3_API Z3_mk_re_union(Z3_context c, unsigned n, Z3_ast const args[])
Create the union of the regular languages.

◆ Unit()

Unit (   a)
Create a singleton sequence

Definition at line 11843 of file z3py.py.

11843def Unit(a):
11844 """Create a singleton sequence"""
11845 return SeqRef(Z3_mk_seq_unit(a.ctx_ref(), a.as_ast()), a.ctx)
11846
11847
Z3_ast Z3_API Z3_mk_seq_unit(Z3_context c, Z3_ast a)
Create a unit sequence of a.

◆ Update()

Update (   a,
*  args 
)
Return a Z3 store array expression.

>>> a    = Array('a', IntSort(), IntSort())
>>> i, v = Ints('i v')
>>> s    = Update(a, i, v)
>>> s.sort()
Array(Int, Int)
>>> prove(s[i] == v)
proved
>>> j    = Int('j')
>>> prove(Implies(i != j, s[j] == a[j]))
proved

Definition at line 4984 of file z3py.py.

4984def Update(a, *args):
4985 """Return a Z3 store array expression.
4986
4987 >>> a = Array('a', IntSort(), IntSort())
4988 >>> i, v = Ints('i v')
4989 >>> s = Update(a, i, v)
4990 >>> s.sort()
4991 Array(Int, Int)
4992 >>> prove(s[i] == v)
4993 proved
4994 >>> j = Int('j')
4995 >>> prove(Implies(i != j, s[j] == a[j]))
4996 proved
4997 """
4998 if z3_debug():
4999 _z3_assert(is_array_sort(a), "First argument must be a Z3 array expression")
5000 args = _get_args(args)
5001 ctx = a.ctx
5002 if len(args) <= 1:
5003 raise Z3Exception("array update requires index and value arguments")
5004 if len(args) == 2:
5005 i = args[0]
5006 v = args[1]
5007 i = a.sort().domain().cast(i)
5008 v = a.sort().range().cast(v)
5009 return _to_expr_ref(Z3_mk_store(ctx.ref(), a.as_ast(), i.as_ast(), v.as_ast()), ctx)
5010 v = a.sort().range().cast(args[-1])
5011 idxs = [a.sort().domain_n(i).cast(args[i]) for i in range(len(args)-1)]
5012 _args, sz = _to_ast_array(idxs)
5013 return _to_expr_ref(Z3_mk_store_n(ctx.ref(), a.as_ast(), sz, _args, v.as_ast()), ctx)
5014
5015
Z3_ast Z3_API Z3_mk_store(Z3_context c, Z3_ast a, Z3_ast i, Z3_ast v)
Array update.
Z3_ast Z3_API Z3_mk_store_n(Z3_context c, Z3_ast a, unsigned n, Z3_ast const *idxs, Z3_ast v)
n-ary Array update.

Referenced by Store().

◆ URem()

URem (   a,
  b 
)
Create the Z3 expression (unsigned) remainder `self % other`.

Use the operator % for signed modulus, and SRem() for signed remainder.

>>> x = BitVec('x', 32)
>>> y = BitVec('y', 32)
>>> URem(x, y)
URem(x, y)
>>> URem(x, y).sort()
BitVec(32)
>>> (x % y).sexpr()
'(bvsmod x y)'
>>> URem(x, y).sexpr()
'(bvurem x y)'

Definition at line 4453 of file z3py.py.

4453def URem(a, b):
4454 """Create the Z3 expression (unsigned) remainder `self % other`.
4455
4456 Use the operator % for signed modulus, and SRem() for signed remainder.
4457
4458 >>> x = BitVec('x', 32)
4459 >>> y = BitVec('y', 32)
4460 >>> URem(x, y)
4461 URem(x, y)
4462 >>> URem(x, y).sort()
4463 BitVec(32)
4464 >>> (x % y).sexpr()
4465 '(bvsmod x y)'
4466 >>> URem(x, y).sexpr()
4467 '(bvurem x y)'
4468 """
4469 _check_bv_args(a, b)
4470 a, b = _coerce_exprs(a, b)
4471 return BitVecRef(Z3_mk_bvurem(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4472
4473
Z3_ast Z3_API Z3_mk_bvurem(Z3_context c, Z3_ast t1, Z3_ast t2)
Unsigned remainder.

◆ user_prop_binding()

user_prop_binding (   ctx,
  cb,
  q_ref,
  inst_ref 
)

Definition at line 12411 of file z3py.py.

12411def user_prop_binding(ctx, cb, q_ref, inst_ref):
12412 prop = _prop_closures.get(ctx)
12413 old_cb = prop.cb
12414 prop.cb = cb
12415 q = _to_expr_ref(to_Ast(q_ref), prop.ctx())
12416 inst = _to_expr_ref(to_Ast(inst_ref), prop.ctx())
12417 r = prop.binding(q, inst)
12418 prop.cb = old_cb
12419 return r
12420
12421

◆ user_prop_created()

user_prop_created (   ctx,
  cb,
  id 
)

Definition at line 12369 of file z3py.py.

12369def user_prop_created(ctx, cb, id):
12370 prop = _prop_closures.get(ctx)
12371 old_cb = prop.cb
12372 prop.cb = cb
12373 id = _to_expr_ref(to_Ast(id), prop.ctx())
12374 prop.created(id)
12375 prop.cb = old_cb
12376
12377

◆ user_prop_decide()

user_prop_decide (   ctx,
  cb,
  t_ref,
  idx,
  phase 
)

Definition at line 12403 of file z3py.py.

12403def user_prop_decide(ctx, cb, t_ref, idx, phase):
12404 prop = _prop_closures.get(ctx)
12405 old_cb = prop.cb
12406 prop.cb = cb
12407 t = _to_expr_ref(to_Ast(t_ref), prop.ctx())
12408 prop.decide(t, idx, phase)
12409 prop.cb = old_cb
12410

◆ user_prop_diseq()

user_prop_diseq (   ctx,
  cb,
  x,
  y 
)

Definition at line 12394 of file z3py.py.

12394def user_prop_diseq(ctx, cb, x, y):
12395 prop = _prop_closures.get(ctx)
12396 old_cb = prop.cb
12397 prop.cb = cb
12398 x = _to_expr_ref(to_Ast(x), prop.ctx())
12399 y = _to_expr_ref(to_Ast(y), prop.ctx())
12400 prop.diseq(x, y)
12401 prop.cb = old_cb
12402

◆ user_prop_eq()

user_prop_eq (   ctx,
  cb,
  x,
  y 
)

Definition at line 12385 of file z3py.py.

12385def user_prop_eq(ctx, cb, x, y):
12386 prop = _prop_closures.get(ctx)
12387 old_cb = prop.cb
12388 prop.cb = cb
12389 x = _to_expr_ref(to_Ast(x), prop.ctx())
12390 y = _to_expr_ref(to_Ast(y), prop.ctx())
12391 prop.eq(x, y)
12392 prop.cb = old_cb
12393

◆ user_prop_final()

user_prop_final (   ctx,
  cb 
)

Definition at line 12378 of file z3py.py.

12378def user_prop_final(ctx, cb):
12379 prop = _prop_closures.get(ctx)
12380 old_cb = prop.cb
12381 prop.cb = cb
12382 prop.final()
12383 prop.cb = old_cb
12384

◆ user_prop_fixed()

user_prop_fixed (   ctx,
  cb,
  id,
  value 
)

Definition at line 12360 of file z3py.py.

12360def user_prop_fixed(ctx, cb, id, value):
12361 prop = _prop_closures.get(ctx)
12362 old_cb = prop.cb
12363 prop.cb = cb
12364 id = _to_expr_ref(to_Ast(id), prop.ctx())
12365 value = _to_expr_ref(to_Ast(value), prop.ctx())
12366 prop.fixed(id, value)
12367 prop.cb = old_cb
12368

◆ user_prop_fresh()

user_prop_fresh (   ctx,
  _new_ctx 
)

Definition at line 12346 of file z3py.py.

12346def user_prop_fresh(ctx, _new_ctx):
12347 _prop_closures.set_threaded()
12348 prop = _prop_closures.get(ctx)
12349 nctx = Context()
12350 Z3_del_context(nctx.ctx)
12351 new_ctx = to_ContextObj(_new_ctx)
12352 nctx.ctx = new_ctx
12353 nctx.eh = Z3_set_error_handler(new_ctx, z3_error_handler)
12354 nctx.owner = False
12355 new_prop = prop.fresh(nctx)
12356 _prop_closures.set(new_prop.id, new_prop)
12357 return new_prop.id
12358
12359
void Z3_API Z3_del_context(Z3_context c)
Delete the given logical context.
void Z3_API Z3_set_error_handler(Z3_context c, Z3_error_handler h)
Register a Z3 error handler.

◆ user_prop_pop()

user_prop_pop (   ctx,
  cb,
  num_scopes 
)

Definition at line 12340 of file z3py.py.

12340def user_prop_pop(ctx, cb, num_scopes):
12341 prop = _prop_closures.get(ctx)
12342 prop.cb = cb
12343 prop.pop(num_scopes)
12344
12345

◆ user_prop_push()

user_prop_push (   ctx,
  cb 
)

Definition at line 12334 of file z3py.py.

12334def user_prop_push(ctx, cb):
12335 prop = _prop_closures.get(ctx)
12336 prop.cb = cb
12337 prop.push()
12338
12339

◆ Var()

ExprRef Var ( int  idx,
SortRef  s 
)
Create a Z3 free variable. Free variables are used to create quantified formulas.
A free variable with index n is bound when it occurs within the scope of n+1 quantified
declarations.

>>> Var(0, IntSort())
Var(0)
>>> eq(Var(0, IntSort()), Var(0, BoolSort()))
False

Definition at line 1581 of file z3py.py.

1581def Var(idx : int, s : SortRef) -> ExprRef:
1582 """Create a Z3 free variable. Free variables are used to create quantified formulas.
1583 A free variable with index n is bound when it occurs within the scope of n+1 quantified
1584 declarations.
1585
1586 >>> Var(0, IntSort())
1587 Var(0)
1588 >>> eq(Var(0, IntSort()), Var(0, BoolSort()))
1589 False
1590 """
1591 if z3_debug():
1592 _z3_assert(is_sort(s), "Z3 sort expected")
1593 return _to_expr_ref(Z3_mk_bound(s.ctx_ref(), idx, s.ast), s.ctx)
1594
1595
Z3_ast Z3_API Z3_mk_bound(Z3_context c, unsigned index, Z3_sort ty)
Create a variable.

Referenced by RealVar().

◆ When()

When (   p,
  t,
  ctx = None 
)
Return a tactic that applies tactic `t` only if probe `p` evaluates to true.
Otherwise, it returns the input goal unmodified.

>>> t = When(Probe('size') > 2, Tactic('simplify'))
>>> x, y = Ints('x y')
>>> g = Goal()
>>> g.add(x > 0)
>>> g.add(y > 0)
>>> t(g)
[[x > 0, y > 0]]
>>> g.add(x == y + 1)
>>> t(g)
[[Not(x <= 0), Not(y <= 0), x == 1 + y]]

Definition at line 9553 of file z3py.py.

9553def When(p, t, ctx=None):
9554 """Return a tactic that applies tactic `t` only if probe `p` evaluates to true.
9555 Otherwise, it returns the input goal unmodified.
9556
9557 >>> t = When(Probe('size') > 2, Tactic('simplify'))
9558 >>> x, y = Ints('x y')
9559 >>> g = Goal()
9560 >>> g.add(x > 0)
9561 >>> g.add(y > 0)
9562 >>> t(g)
9563 [[x > 0, y > 0]]
9564 >>> g.add(x == y + 1)
9565 >>> t(g)
9566 [[Not(x <= 0), Not(y <= 0), x == 1 + y]]
9567 """
9568 p = _to_probe(p, ctx)
9569 t = _to_tactic(t, ctx)
9570 return Tactic(Z3_tactic_when(t.ctx.ref(), p.probe, t.tactic), t.ctx)
9571
9572
Z3_tactic Z3_API Z3_tactic_when(Z3_context c, Z3_probe p, Z3_tactic t)
Return a tactic that applies t to a given goal is the probe p evaluates to true. If p evaluates to fa...

◆ With()

With (   t,
*  args,
**  keys 
)
Return a tactic that applies tactic `t` using the given configuration options.

>>> x, y = Ints('x y')
>>> t = With(Tactic('simplify'), som=True)
>>> t((x + 1)*(y + 2) == 0)
[[2*x + y + x*y == -2]]

Definition at line 9210 of file z3py.py.

9210def With(t, *args, **keys):
9211 """Return a tactic that applies tactic `t` using the given configuration options.
9212
9213 >>> x, y = Ints('x y')
9214 >>> t = With(Tactic('simplify'), som=True)
9215 >>> t((x + 1)*(y + 2) == 0)
9216 [[2*x + y + x*y == -2]]
9217 """
9218 ctx = keys.pop("ctx", None)
9219 t = _to_tactic(t, ctx)
9220 p = args2params(args, keys, t.ctx)
9221 return Tactic(Z3_tactic_using_params(t.ctx.ref(), t.tactic, p.params), t.ctx)
9222
9223
Z3_tactic Z3_API Z3_tactic_using_params(Z3_context c, Z3_tactic t, Z3_params p)
Return a tactic that applies t using the given set of parameters.

◆ WithParams()

WithParams (   t,
  p 
)
Return a tactic that applies tactic `t` using the given configuration options.

>>> x, y = Ints('x y')
>>> p = ParamsRef()
>>> p.set("som", True)
>>> t = WithParams(Tactic('simplify'), p)
>>> t((x + 1)*(y + 2) == 0)
[[2*x + y + x*y == -2]]

Definition at line 9224 of file z3py.py.

9224def WithParams(t, p):
9225 """Return a tactic that applies tactic `t` using the given configuration options.
9226
9227 >>> x, y = Ints('x y')
9228 >>> p = ParamsRef()
9229 >>> p.set("som", True)
9230 >>> t = WithParams(Tactic('simplify'), p)
9231 >>> t((x + 1)*(y + 2) == 0)
9232 [[2*x + y + x*y == -2]]
9233 """
9234 t = _to_tactic(t, None)
9235 return Tactic(Z3_tactic_using_params(t.ctx.ref(), t.tactic, p.params), t.ctx)
9236
9237

◆ Xor()

Xor (   a,
  b,
  ctx = None 
)
Create a Z3 Xor expression.

>>> p, q = Bools('p q')
>>> Xor(p, q)
Xor(p, q)
>>> simplify(Xor(p, q))
Not(p == q)

Definition at line 1938 of file z3py.py.

1938def Xor(a, b, ctx=None):
1939 """Create a Z3 Xor expression.
1940
1941 >>> p, q = Bools('p q')
1942 >>> Xor(p, q)
1943 Xor(p, q)
1944 >>> simplify(Xor(p, q))
1945 Not(p == q)
1946 """
1947 ctx = _get_ctx(_ctx_from_ast_arg_list([a, b], ctx))
1948 s = BoolSort(ctx)
1949 a = s.cast(a)
1950 b = s.cast(b)
1951 return BoolRef(Z3_mk_xor(ctx.ref(), a.as_ast(), b.as_ast()), ctx)
1952
1953
Z3_ast Z3_API Z3_mk_xor(Z3_context c, Z3_ast t1, Z3_ast t2)
Create an AST node representing t1 xor t2.

Referenced by BoolRef.__xor__().

◆ z3_debug()

z3_debug ( )

◆ z3_error_handler()

z3_error_handler (   c,
  e 
)

Definition at line 184 of file z3py.py.

184def z3_error_handler(c, e):
185 # Do nothing error handler, just avoid exit(0)
186 # The wrappers in z3core.py will raise a Z3Exception if an error is detected
187 return
188
189

◆ ZeroExt()

ZeroExt (   n,
  a 
)
Return a bit-vector expression with `n` extra zero-bits.

>>> x = BitVec('x', 16)
>>> n = ZeroExt(8, x)
>>> n.size()
24
>>> n
ZeroExt(8, x)
>>> n.sort()
BitVec(24)
>>> v0 = BitVecVal(2, 2)
>>> v0
2
>>> v0.size()
2
>>> v  = simplify(ZeroExt(6, v0))
>>> v
2
>>> v.size()
8

Definition at line 4589 of file z3py.py.

4589def ZeroExt(n, a):
4590 """Return a bit-vector expression with `n` extra zero-bits.
4591
4592 >>> x = BitVec('x', 16)
4593 >>> n = ZeroExt(8, x)
4594 >>> n.size()
4595 24
4596 >>> n
4597 ZeroExt(8, x)
4598 >>> n.sort()
4599 BitVec(24)
4600 >>> v0 = BitVecVal(2, 2)
4601 >>> v0
4602 2
4603 >>> v0.size()
4604 2
4605 >>> v = simplify(ZeroExt(6, v0))
4606 >>> v
4607 2
4608 >>> v.size()
4609 8
4610 """
4611 if z3_debug():
4612 _z3_assert(_is_int(n), "First argument must be an integer")
4613 _z3_assert(is_bv(a), "Second argument must be a Z3 bit-vector expression")
4614 return BitVecRef(Z3_mk_zero_ext(a.ctx_ref(), n, a.as_ast()), a.ctx)
4615
4616
Z3_ast Z3_API Z3_mk_zero_ext(Z3_context c, unsigned i, Z3_ast t1)
Extend the given bit-vector with zeros to the (unsigned) equivalent bit-vector of size m+i,...

Variable Documentation

◆ _dflt_fpsort_ebits

int _dflt_fpsort_ebits = 11
protected

Definition at line 10105 of file z3py.py.

◆ _dflt_fpsort_sbits

int _dflt_fpsort_sbits = 53
protected

Definition at line 10106 of file z3py.py.

◆ _dflt_rounding_mode

_dflt_rounding_mode = Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN
protected

Floating-Point Arithmetic.

Definition at line 10104 of file z3py.py.

◆ _main_ctx

_main_ctx = None
protected

Definition at line 263 of file z3py.py.

◆ _my_hacky_class

_my_hacky_class = None
protected

Definition at line 12268 of file z3py.py.

◆ _on_clause_eh

_on_clause_eh = Z3_on_clause_eh(on_clause_eh)
protected

Definition at line 12276 of file z3py.py.

◆ _on_model_eh

_on_model_eh = on_model_eh_type(_global_on_model)
protected

Definition at line 8576 of file z3py.py.

◆ _on_models

dict _on_models = {}
protected

Definition at line 8568 of file z3py.py.

◆ _prop_closures

_prop_closures = None
protected

Definition at line 12325 of file z3py.py.

◆ _ROUNDING_MODES

_ROUNDING_MODES
protected
Initial value:
1= frozenset({
2 Z3_OP_FPA_RM_TOWARD_ZERO,
3 Z3_OP_FPA_RM_TOWARD_NEGATIVE,
4 Z3_OP_FPA_RM_TOWARD_POSITIVE,
5 Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN,
6 Z3_OP_FPA_RM_NEAREST_TIES_TO_AWAY
7})

Definition at line 10124 of file z3py.py.

◆ _user_prop_binding

_user_prop_binding = Z3_on_binding_eh(user_prop_binding)
protected

Definition at line 12431 of file z3py.py.

◆ _user_prop_created

_user_prop_created = Z3_created_eh(user_prop_created)
protected

Definition at line 12426 of file z3py.py.

◆ _user_prop_decide

_user_prop_decide = Z3_decide_eh(user_prop_decide)
protected

Definition at line 12430 of file z3py.py.

◆ _user_prop_diseq

_user_prop_diseq = Z3_eq_eh(user_prop_diseq)
protected

Definition at line 12429 of file z3py.py.

◆ _user_prop_eq

_user_prop_eq = Z3_eq_eh(user_prop_eq)
protected

Definition at line 12428 of file z3py.py.

◆ _user_prop_final

_user_prop_final = Z3_final_eh(user_prop_final)
protected

Definition at line 12427 of file z3py.py.

◆ _user_prop_fixed

_user_prop_fixed = Z3_fixed_eh(user_prop_fixed)
protected

Definition at line 12425 of file z3py.py.

◆ _user_prop_fresh

_user_prop_fresh = Z3_fresh_eh(user_prop_fresh)
protected

Definition at line 12424 of file z3py.py.

◆ _user_prop_pop

_user_prop_pop = Z3_pop_eh(user_prop_pop)
protected

Definition at line 12423 of file z3py.py.

◆ _user_prop_push

_user_prop_push = Z3_push_eh(user_prop_push)
protected

Definition at line 12422 of file z3py.py.

◆ sat

Definition at line 7539 of file z3py.py.

◆ unknown

Definition at line 7541 of file z3py.py.

◆ unsat

Definition at line 7540 of file z3py.py.

◆ Z3_DEBUG

Z3_DEBUG = __debug__

Definition at line 67 of file z3py.py.