Z3
Data Structures | Functions | Variables
z3py Namespace Reference

Data Structures

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

Functions

def z3_debug ()
 
def enable_trace (msg)
 
def disable_trace (msg)
 
def get_version_string ()
 
def get_version ()
 
def get_full_version ()
 
def open_log (fname)
 
def append_log (s)
 
def to_symbol (s, ctx=None)
 
def z3_error_handler (c, e)
 
def main_ctx ()
 
def get_ctx (ctx)
 
def set_param (*args, **kws)
 
def reset_params ()
 
def set_option (*args, **kws)
 
def get_param (name)
 
def is_ast (a)
 
def eq (a, b)
 
def is_sort (s)
 
def DeclareSort (name, ctx=None)
 
def is_func_decl (a)
 
def Function (name, *sig)
 
def FreshFunction (*sig)
 
def RecFunction (name, *sig)
 
def RecAddDefinition (f, args, body)
 
def is_expr (a)
 
def is_app (a)
 
def is_const (a)
 
def is_var (a)
 
def get_var_index (a)
 
def is_app_of (a, k)
 
def If (a, b, c, ctx=None)
 
def Distinct (*args)
 
def Const (name, sort)
 
def Consts (names, sort)
 
def FreshConst (sort, prefix="c")
 
def Var (idx, s)
 
def RealVar (idx, ctx=None)
 
def RealVarVector (n, ctx=None)
 
def is_bool (a)
 
def is_true (a)
 
def is_false (a)
 
def is_and (a)
 
def is_or (a)
 
def is_implies (a)
 
def is_not (a)
 
def is_eq (a)
 
def is_distinct (a)
 
def BoolSort (ctx=None)
 
def BoolVal (val, ctx=None)
 
def Bool (name, ctx=None)
 
def Bools (names, ctx=None)
 
def BoolVector (prefix, sz, ctx=None)
 
def FreshBool (prefix="b", ctx=None)
 
def Implies (a, b, ctx=None)
 
def Xor (a, b, ctx=None)
 
def Not (a, ctx=None)
 
def mk_not (a)
 
def And (*args)
 
def Or (*args)
 
def is_pattern (a)
 
def MultiPattern (*args)
 
def is_quantifier (a)
 
def ForAll (vs, body, weight=1, qid="", skid="", patterns=[], no_patterns=[])
 
def Exists (vs, body, weight=1, qid="", skid="", patterns=[], no_patterns=[])
 
def Lambda (vs, body)
 
def is_arith_sort (s)
 
def is_arith (a)
 
def is_int (a)
 
def is_real (a)
 
def is_int_value (a)
 
def is_rational_value (a)
 
def is_algebraic_value (a)
 
def is_add (a)
 
def is_mul (a)
 
def is_sub (a)
 
def is_div (a)
 
def is_idiv (a)
 
def is_mod (a)
 
def is_le (a)
 
def is_lt (a)
 
def is_ge (a)
 
def is_gt (a)
 
def is_is_int (a)
 
def is_to_real (a)
 
def is_to_int (a)
 
def IntSort (ctx=None)
 
def RealSort (ctx=None)
 
def IntVal (val, ctx=None)
 
def RealVal (val, ctx=None)
 
def RatVal (a, b, ctx=None)
 
def Q (a, b, ctx=None)
 
def Int (name, ctx=None)
 
def Ints (names, ctx=None)
 
def IntVector (prefix, sz, ctx=None)
 
def FreshInt (prefix="x", ctx=None)
 
def Real (name, ctx=None)
 
def Reals (names, ctx=None)
 
def RealVector (prefix, sz, ctx=None)
 
def FreshReal (prefix="b", ctx=None)
 
def ToReal (a)
 
def ToInt (a)
 
def IsInt (a)
 
def Sqrt (a, ctx=None)
 
def Cbrt (a, ctx=None)
 
def is_bv_sort (s)
 
def is_bv (a)
 
def is_bv_value (a)
 
def BV2Int (a, is_signed=False)
 
def Int2BV (a, num_bits)
 
def BitVecSort (sz, ctx=None)
 
def BitVecVal (val, bv, ctx=None)
 
def BitVec (name, bv, ctx=None)
 
def BitVecs (names, bv, ctx=None)
 
def Concat (*args)
 
def Extract (high, low, a)
 
def ULE (a, b)
 
def ULT (a, b)
 
def UGE (a, b)
 
def UGT (a, b)
 
def UDiv (a, b)
 
def URem (a, b)
 
def SRem (a, b)
 
def LShR (a, b)
 
def RotateLeft (a, b)
 
def RotateRight (a, b)
 
def SignExt (n, a)
 
def ZeroExt (n, a)
 
def RepeatBitVec (n, a)
 
def BVRedAnd (a)
 
def BVRedOr (a)
 
def BVAddNoOverflow (a, b, signed)
 
def BVAddNoUnderflow (a, b)
 
def BVSubNoOverflow (a, b)
 
def BVSubNoUnderflow (a, b, signed)
 
def BVSDivNoOverflow (a, b)
 
def BVSNegNoOverflow (a)
 
def BVMulNoOverflow (a, b, signed)
 
def BVMulNoUnderflow (a, b)
 
def is_array_sort (a)
 
def is_array (a)
 
def is_const_array (a)
 
def is_K (a)
 
def is_map (a)
 
def is_default (a)
 
def get_map_func (a)
 
def ArraySort (*sig)
 
def Array (name, dom, rng)
 
def Update (a, i, v)
 
def Default (a)
 
def Store (a, i, v)
 
def Select (a, i)
 
def Map (f, *args)
 
def K (dom, v)
 
def Ext (a, b)
 
def SetHasSize (a, k)
 
def is_select (a)
 
def is_store (a)
 
def SetSort (s)
 Sets. More...
 
def EmptySet (s)
 
def FullSet (s)
 
def SetUnion (*args)
 
def SetIntersect (*args)
 
def SetAdd (s, e)
 
def SetDel (s, e)
 
def SetComplement (s)
 
def SetDifference (a, b)
 
def IsMember (e, s)
 
def IsSubset (a, b)
 
def CreateDatatypes (*ds)
 
def TupleSort (name, sorts, ctx=None)
 
def DisjointSum (name, sorts, ctx=None)
 
def EnumSort (name, values, ctx=None)
 
def args2params (arguments, keywords, ctx=None)
 
def Model (ctx=None)
 
def is_as_array (n)
 
def get_as_array_func (n)
 
def SolverFor (logic, ctx=None, logFile=None)
 
def SimpleSolver (ctx=None, logFile=None)
 
def FiniteDomainSort (name, sz, ctx=None)
 
def is_finite_domain_sort (s)
 
def is_finite_domain (a)
 
def FiniteDomainVal (val, sort, ctx=None)
 
def is_finite_domain_value (a)
 
def AndThen (*ts, **ks)
 
def Then (*ts, **ks)
 
def OrElse (*ts, **ks)
 
def ParOr (*ts, **ks)
 
def ParThen (t1, t2, ctx=None)
 
def ParAndThen (t1, t2, ctx=None)
 
def With (t, *args, **keys)
 
def WithParams (t, p)
 
def Repeat (t, max=4294967295, ctx=None)
 
def TryFor (t, ms, ctx=None)
 
def tactics (ctx=None)
 
def tactic_description (name, ctx=None)
 
def describe_tactics ()
 
def is_probe (p)
 
def probes (ctx=None)
 
def probe_description (name, ctx=None)
 
def describe_probes ()
 
def FailIf (p, ctx=None)
 
def When (p, t, ctx=None)
 
def Cond (p, t1, t2, ctx=None)
 
def simplify (a, *arguments, **keywords)
 Utils. More...
 
def help_simplify ()
 
def simplify_param_descrs ()
 
def substitute (t, *m)
 
def substitute_vars (t, *m)
 
def Sum (*args)
 
def Product (*args)
 
def AtMost (*args)
 
def AtLeast (*args)
 
def PbLe (args, k)
 
def PbGe (args, k)
 
def PbEq (args, k, ctx=None)
 
def solve (*args, **keywords)
 
def solve_using (s, *args, **keywords)
 
def prove (claim, show=False, **keywords)
 
def parse_smt2_string (s, sorts={}, decls={}, ctx=None)
 
def parse_smt2_file (f, sorts={}, decls={}, ctx=None)
 
def get_default_rounding_mode (ctx=None)
 
def set_default_rounding_mode (rm, ctx=None)
 
def get_default_fp_sort (ctx=None)
 
def set_default_fp_sort (ebits, sbits, ctx=None)
 
def Float16 (ctx=None)
 
def FloatHalf (ctx=None)
 
def Float32 (ctx=None)
 
def FloatSingle (ctx=None)
 
def Float64 (ctx=None)
 
def FloatDouble (ctx=None)
 
def Float128 (ctx=None)
 
def FloatQuadruple (ctx=None)
 
def is_fp_sort (s)
 
def is_fprm_sort (s)
 
def RoundNearestTiesToEven (ctx=None)
 
def RNE (ctx=None)
 
def RoundNearestTiesToAway (ctx=None)
 
def RNA (ctx=None)
 
def RoundTowardPositive (ctx=None)
 
def RTP (ctx=None)
 
def RoundTowardNegative (ctx=None)
 
def RTN (ctx=None)
 
def RoundTowardZero (ctx=None)
 
def RTZ (ctx=None)
 
def is_fprm (a)
 
def is_fprm_value (a)
 
def is_fp (a)
 
def is_fp_value (a)
 
def FPSort (ebits, sbits, ctx=None)
 
def fpNaN (s)
 
def fpPlusInfinity (s)
 
def fpMinusInfinity (s)
 
def fpInfinity (s, negative)
 
def fpPlusZero (s)
 
def fpMinusZero (s)
 
def fpZero (s, negative)
 
def FPVal (sig, exp=None, fps=None, ctx=None)
 
def FP (name, fpsort, ctx=None)
 
def FPs (names, fpsort, ctx=None)
 
def fpAbs (a, ctx=None)
 
def fpNeg (a, ctx=None)
 
def fpAdd (rm, a, b, ctx=None)
 
def fpSub (rm, a, b, ctx=None)
 
def fpMul (rm, a, b, ctx=None)
 
def fpDiv (rm, a, b, ctx=None)
 
def fpRem (a, b, ctx=None)
 
def fpMin (a, b, ctx=None)
 
def fpMax (a, b, ctx=None)
 
def fpFMA (rm, a, b, c, ctx=None)
 
def fpSqrt (rm, a, ctx=None)
 
def fpRoundToIntegral (rm, a, ctx=None)
 
def fpIsNaN (a, ctx=None)
 
def fpIsInf (a, ctx=None)
 
def fpIsZero (a, ctx=None)
 
def fpIsNormal (a, ctx=None)
 
def fpIsSubnormal (a, ctx=None)
 
def fpIsNegative (a, ctx=None)
 
def fpIsPositive (a, ctx=None)
 
def fpLT (a, b, ctx=None)
 
def fpLEQ (a, b, ctx=None)
 
def fpGT (a, b, ctx=None)
 
def fpGEQ (a, b, ctx=None)
 
def fpEQ (a, b, ctx=None)
 
def fpNEQ (a, b, ctx=None)
 
def fpFP (sgn, exp, sig, ctx=None)
 
def fpToFP (a1, a2=None, a3=None, ctx=None)
 
def fpBVToFP (v, sort, ctx=None)
 
def fpFPToFP (rm, v, sort, ctx=None)
 
def fpRealToFP (rm, v, sort, ctx=None)
 
def fpSignedToFP (rm, v, sort, ctx=None)
 
def fpUnsignedToFP (rm, v, sort, ctx=None)
 
def fpToFPUnsigned (rm, x, s, ctx=None)
 
def fpToSBV (rm, x, s, ctx=None)
 
def fpToUBV (rm, x, s, ctx=None)
 
def fpToReal (x, ctx=None)
 
def fpToIEEEBV (x, ctx=None)
 
def StringSort (ctx=None)
 
def SeqSort (s)
 
def is_seq (a)
 
def is_string (a)
 
def is_string_value (a)
 
def StringVal (s, ctx=None)
 
def String (name, ctx=None)
 
def Strings (names, ctx=None)
 
def SubString (s, offset, length)
 
def SubSeq (s, offset, length)
 
def Empty (s)
 
def Full (s)
 
def Unit (a)
 
def PrefixOf (a, b)
 
def SuffixOf (a, b)
 
def Contains (a, b)
 
def Replace (s, src, dst)
 
def IndexOf (s, substr, offset=None)
 
def LastIndexOf (s, substr)
 
def Length (s)
 
def StrToInt (s)
 
def IntToStr (s)
 
def Re (s, ctx=None)
 
def ReSort (s)
 
def is_re (s)
 
def InRe (s, re)
 
def Union (*args)
 
def Intersect (*args)
 
def Plus (re)
 
def Option (re)
 
def Complement (re)
 
def Star (re)
 
def Loop (re, lo, hi=0)
 
def Range (lo, hi, ctx=None)
 
def PartialOrder (a, index)
 
def LinearOrder (a, index)
 
def TreeOrder (a, index)
 
def PiecewiseLinearOrder (a, index)
 
def TransitiveClosure (f)
 
def ensure_prop_closures ()
 
def user_prop_push (ctx)
 
def user_prop_pop (ctx, num_scopes)
 
def user_prop_fresh (id, ctx)
 
def user_prop_fixed (ctx, cb, id, value)
 
def user_prop_final (ctx, cb)
 
def user_prop_eq (ctx, cb, x, y)
 
def user_prop_diseq (ctx, cb, x, y)
 

Variables

 Z3_DEBUG = __debug__
 
 sat = CheckSatResult(Z3_L_TRUE)
 
 unsat = CheckSatResult(Z3_L_FALSE)
 
 unknown = CheckSatResult(Z3_L_UNDEF)
 

Function Documentation

◆ And()

def z3py.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 1813 of file z3py.py.

1813 def And(*args):
1814  """Create a Z3 and-expression or and-probe.
1815 
1816  >>> p, q, r = Bools('p q r')
1817  >>> And(p, q, r)
1818  And(p, q, r)
1819  >>> P = BoolVector('p', 5)
1820  >>> And(P)
1821  And(p__0, p__1, p__2, p__3, p__4)
1822  """
1823  last_arg = None
1824  if len(args) > 0:
1825  last_arg = args[len(args) - 1]
1826  if isinstance(last_arg, Context):
1827  ctx = args[len(args) - 1]
1828  args = args[:len(args) - 1]
1829  elif len(args) == 1 and isinstance(args[0], AstVector):
1830  ctx = args[0].ctx
1831  args = [a for a in args[0]]
1832  else:
1833  ctx = None
1834  args = _get_args(args)
1835  ctx = _get_ctx(_ctx_from_ast_arg_list(args, ctx))
1836  if z3_debug():
1837  _z3_assert(ctx is not None, "At least one of the arguments must be a Z3 expression or probe")
1838  if _has_probe(args):
1839  return _probe_and(args, ctx)
1840  else:
1841  args = _coerce_expr_list(args, ctx)
1842  _args, sz = _to_ast_array(args)
1843  return BoolRef(Z3_mk_and(ctx.ref(), sz, _args), ctx)
1844 
1845 
def z3_debug()
Definition: z3py.py:64
def And(*args)
Definition: z3py.py:1813
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 Fixedpoint.add_rule(), Goal.as_expr(), Fixedpoint.query(), Fixedpoint.query_from_lvl(), and Fixedpoint.update_rule().

◆ AndThen()

def z3py.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 8171 of file z3py.py.

8171 def AndThen(*ts, **ks):
8172  """Return a tactic that applies the tactics in `*ts` in sequence.
8173 
8174  >>> x, y = Ints('x y')
8175  >>> t = AndThen(Tactic('simplify'), Tactic('solve-eqs'))
8176  >>> t(And(x == 0, y > x + 1))
8177  [[Not(y <= 1)]]
8178  >>> t(And(x == 0, y > x + 1)).as_expr()
8179  Not(y <= 1)
8180  """
8181  if z3_debug():
8182  _z3_assert(len(ts) >= 2, "At least two arguments expected")
8183  ctx = ks.get("ctx", None)
8184  num = len(ts)
8185  r = ts[0]
8186  for i in range(num - 1):
8187  r = _and_then(r, ts[i + 1], ctx)
8188  return r
8189 
8190 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3725
def AndThen(*ts, **ks)
Definition: z3py.py:8171

Referenced by Then().

◆ append_log()

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

Definition at line 124 of file z3py.py.

124 def append_log(s):
125  """Append user-defined string to interaction log. """
126  Z3_append_log(s)
127 
128 
def append_log(s)
Definition: z3py.py:124
void Z3_API Z3_append_log(Z3_string string)
Append user-defined string to interaction log.

◆ args2params()

def z3py.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 5396 of file z3py.py.

5396 def args2params(arguments, keywords, ctx=None):
5397  """Convert python arguments into a Z3_params object.
5398  A ':' is added to the keywords, and '_' is replaced with '-'
5399 
5400  >>> args2params(['model', True, 'relevancy', 2], {'elim_and' : True})
5401  (params model true relevancy 2 elim_and true)
5402  """
5403  if z3_debug():
5404  _z3_assert(len(arguments) % 2 == 0, "Argument list must have an even number of elements.")
5405  prev = None
5406  r = ParamsRef(ctx)
5407  for a in arguments:
5408  if prev is None:
5409  prev = a
5410  else:
5411  r.set(prev, a)
5412  prev = None
5413  for k in keywords:
5414  v = keywords[k]
5415  r.set(k, v)
5416  return r
5417 
5418 
def args2params(arguments, keywords, ctx=None)
Definition: z3py.py:5396

Referenced by Tactic.apply(), Solver.set(), Fixedpoint.set(), Optimize.set(), simplify(), and With().

◆ Array()

def z3py.Array (   name,
  dom,
  rng 
)
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 4678 of file z3py.py.

4678 def Array(name, dom, rng):
4679  """Return an array constant named `name` with the given domain and range sorts.
4680 
4681  >>> a = Array('a', IntSort(), IntSort())
4682  >>> a.sort()
4683  Array(Int, Int)
4684  >>> a[0]
4685  a[0]
4686  """
4687  s = ArraySort(dom, rng)
4688  ctx = s.ctx
4689  return ArrayRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), s.ast), ctx)
4690 
4691 
def ArraySort(*sig)
Definition: z3py.py:4645
def to_symbol(s, ctx=None)
Definition: z3py.py:129
def Array(name, dom, rng)
Definition: z3py.py:4678
Z3_ast Z3_API Z3_mk_const(Z3_context c, Z3_symbol s, Z3_sort ty)
Declare and create a constant.

◆ ArraySort()

def z3py.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))

Definition at line 4645 of file z3py.py.

4645 def ArraySort(*sig):
4646  """Return the Z3 array sort with the given domain and range sorts.
4647 
4648  >>> A = ArraySort(IntSort(), BoolSort())
4649  >>> A
4650  Array(Int, Bool)
4651  >>> A.domain()
4652  Int
4653  >>> A.range()
4654  Bool
4655  >>> AA = ArraySort(IntSort(), A)
4656  >>> AA
4657  Array(Int, Array(Int, Bool))
4658  """
4659  sig = _get_args(sig)
4660  if z3_debug():
4661  _z3_assert(len(sig) > 1, "At least two arguments expected")
4662  arity = len(sig) - 1
4663  r = sig[arity]
4664  d = sig[0]
4665  if z3_debug():
4666  for s in sig:
4667  _z3_assert(is_sort(s), "Z3 sort expected")
4668  _z3_assert(s.ctx == r.ctx, "Context mismatch")
4669  ctx = d.ctx
4670  if len(sig) == 2:
4671  return ArraySortRef(Z3_mk_array_sort(ctx.ref(), d.ast, r.ast), ctx)
4672  dom = (Sort * arity)()
4673  for i in range(arity):
4674  dom[i] = sig[i].ast
4675  return ArraySortRef(Z3_mk_array_sort_n(ctx.ref(), arity, dom, r.ast), ctx)
4676 
4677 
def is_sort(s)
Definition: z3py.py:646
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 Array(), and SetSort().

◆ AtLeast()

def z3py.AtLeast ( args)
Create an at-most Pseudo-Boolean k constraint.

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

Definition at line 8800 of file z3py.py.

8800 def AtLeast(*args):
8801  """Create an at-most Pseudo-Boolean k constraint.
8802 
8803  >>> a, b, c = Bools('a b c')
8804  >>> f = AtLeast(a, b, c, 2)
8805  """
8806  args = _get_args(args)
8807  if z3_debug():
8808  _z3_assert(len(args) > 1, "Non empty list of arguments expected")
8809  ctx = _ctx_from_ast_arg_list(args)
8810  if z3_debug():
8811  _z3_assert(ctx is not None, "At least one of the arguments must be a Z3 expression")
8812  args1 = _coerce_expr_list(args[:-1], ctx)
8813  k = args[-1]
8814  _args, sz = _to_ast_array(args1)
8815  return BoolRef(Z3_mk_atleast(ctx.ref(), sz, _args, k), ctx)
8816 
8817 
def AtLeast(*args)
Definition: z3py.py:8800
Z3_ast Z3_API Z3_mk_atleast(Z3_context c, unsigned num_args, Z3_ast const args[], unsigned k)
Pseudo-Boolean relations.

◆ AtMost()

def z3py.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 8782 of file z3py.py.

8782 def AtMost(*args):
8783  """Create an at-most Pseudo-Boolean k constraint.
8784 
8785  >>> a, b, c = Bools('a b c')
8786  >>> f = AtMost(a, b, c, 2)
8787  """
8788  args = _get_args(args)
8789  if z3_debug():
8790  _z3_assert(len(args) > 1, "Non empty list of arguments expected")
8791  ctx = _ctx_from_ast_arg_list(args)
8792  if z3_debug():
8793  _z3_assert(ctx is not None, "At least one of the arguments must be a Z3 expression")
8794  args1 = _coerce_expr_list(args[:-1], ctx)
8795  k = args[-1]
8796  _args, sz = _to_ast_array(args1)
8797  return BoolRef(Z3_mk_atmost(ctx.ref(), sz, _args, k), ctx)
8798 
8799 
def AtMost(*args)
Definition: z3py.py:8782
Z3_ast Z3_API Z3_mk_atmost(Z3_context c, unsigned num_args, Z3_ast const args[], unsigned k)
Pseudo-Boolean relations.

◆ BitVec()

def z3py.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 3999 of file z3py.py.

3999 def BitVec(name, bv, ctx=None):
4000  """Return a bit-vector constant named `name`. `bv` may be the number of bits of a bit-vector sort.
4001  If `ctx=None`, then the global context is used.
4002 
4003  >>> x = BitVec('x', 16)
4004  >>> is_bv(x)
4005  True
4006  >>> x.size()
4007  16
4008  >>> x.sort()
4009  BitVec(16)
4010  >>> word = BitVecSort(16)
4011  >>> x2 = BitVec('x', word)
4012  >>> eq(x, x2)
4013  True
4014  """
4015  if isinstance(bv, BitVecSortRef):
4016  ctx = bv.ctx
4017  else:
4018  ctx = _get_ctx(ctx)
4019  bv = BitVecSort(bv, ctx)
4020  return BitVecRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), bv.ast), ctx)
4021 
4022 
def BitVec(name, bv, ctx=None)
Definition: z3py.py:3999
def BitVecSort(sz, ctx=None)
Definition: z3py.py:3967

Referenced by BitVecs().

◆ BitVecs()

def z3py.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 4023 of file z3py.py.

4023 def BitVecs(names, bv, ctx=None):
4024  """Return a tuple of bit-vector constants of size bv.
4025 
4026  >>> x, y, z = BitVecs('x y z', 16)
4027  >>> x.size()
4028  16
4029  >>> x.sort()
4030  BitVec(16)
4031  >>> Sum(x, y, z)
4032  0 + x + y + z
4033  >>> Product(x, y, z)
4034  1*x*y*z
4035  >>> simplify(Product(x, y, z))
4036  x*y*z
4037  """
4038  ctx = _get_ctx(ctx)
4039  if isinstance(names, str):
4040  names = names.split(" ")
4041  return [BitVec(name, bv, ctx) for name in names]
4042 
4043 
def BitVecs(names, bv, ctx=None)
Definition: z3py.py:4023

◆ BitVecSort()

def z3py.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 3967 of file z3py.py.

3967 def BitVecSort(sz, ctx=None):
3968  """Return a Z3 bit-vector sort of the given size. If `ctx=None`, then the global context is used.
3969 
3970  >>> Byte = BitVecSort(8)
3971  >>> Word = BitVecSort(16)
3972  >>> Byte
3973  BitVec(8)
3974  >>> x = Const('x', Byte)
3975  >>> eq(x, BitVec('x', 8))
3976  True
3977  """
3978  ctx = _get_ctx(ctx)
3979  return BitVecSortRef(Z3_mk_bv_sort(ctx.ref(), sz), ctx)
3980 
3981 
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()

def z3py.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 3982 of file z3py.py.

3982 def BitVecVal(val, bv, ctx=None):
3983  """Return a bit-vector value with the given number of bits. If `ctx=None`, then the global context is used.
3984 
3985  >>> v = BitVecVal(10, 32)
3986  >>> v
3987  10
3988  >>> print("0x%.8x" % v.as_long())
3989  0x0000000a
3990  """
3991  if is_bv_sort(bv):
3992  ctx = bv.ctx
3993  return BitVecNumRef(Z3_mk_numeral(ctx.ref(), _to_int_str(val), bv.ast), ctx)
3994  else:
3995  ctx = _get_ctx(ctx)
3996  return BitVecNumRef(Z3_mk_numeral(ctx.ref(), _to_int_str(val), BitVecSort(bv, ctx).ast), ctx)
3997 
3998 
def is_bv_sort(s)
Definition: z3py.py:3438
def BitVecVal(val, bv, ctx=None)
Definition: z3py.py:3982
Z3_ast Z3_API Z3_mk_numeral(Z3_context c, Z3_string numeral, Z3_sort ty)
Create a numeral of a given sort.

◆ Bool()

def z3py.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 1692 of file z3py.py.

1692 def Bool(name, ctx=None):
1693  """Return a Boolean constant named `name`. If `ctx=None`, then the global context is used.
1694 
1695  >>> p = Bool('p')
1696  >>> q = Bool('q')
1697  >>> And(p, q)
1698  And(p, q)
1699  """
1700  ctx = _get_ctx(ctx)
1701  return BoolRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), BoolSort(ctx).ast), ctx)
1702 
1703 
def BoolSort(ctx=None)
Definition: z3py.py:1655
def Bool(name, ctx=None)
Definition: z3py.py:1692

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

◆ Bools()

def z3py.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 1704 of file z3py.py.

1704 def Bools(names, ctx=None):
1705  """Return a tuple of Boolean constants.
1706 
1707  `names` is a single string containing all names separated by blank spaces.
1708  If `ctx=None`, then the global context is used.
1709 
1710  >>> p, q, r = Bools('p q r')
1711  >>> And(p, Or(q, r))
1712  And(p, Or(q, r))
1713  """
1714  ctx = _get_ctx(ctx)
1715  if isinstance(names, str):
1716  names = names.split(" ")
1717  return [Bool(name, ctx) for name in names]
1718 
1719 
def Bools(names, ctx=None)
Definition: z3py.py:1704

◆ BoolSort()

def z3py.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 1655 of file z3py.py.

1655 def BoolSort(ctx=None):
1656  """Return the Boolean Z3 sort. If `ctx=None`, then the global context is used.
1657 
1658  >>> BoolSort()
1659  Bool
1660  >>> p = Const('p', BoolSort())
1661  >>> is_bool(p)
1662  True
1663  >>> r = Function('r', IntSort(), IntSort(), BoolSort())
1664  >>> r(0, 1)
1665  r(0, 1)
1666  >>> is_bool(r(0, 1))
1667  True
1668  """
1669  ctx = _get_ctx(ctx)
1670  return BoolSortRef(Z3_mk_bool_sort(ctx.ref()), ctx)
1671 
1672 
Z3_sort Z3_API Z3_mk_bool_sort(Z3_context c)
Create the Boolean type.

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

◆ BoolVal()

def z3py.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 1673 of file z3py.py.

1673 def BoolVal(val, ctx=None):
1674  """Return the Boolean value `True` or `False`. If `ctx=None`, then the global context is used.
1675 
1676  >>> BoolVal(True)
1677  True
1678  >>> is_true(BoolVal(True))
1679  True
1680  >>> is_true(True)
1681  False
1682  >>> is_false(BoolVal(False))
1683  True
1684  """
1685  ctx = _get_ctx(ctx)
1686  if val:
1687  return BoolRef(Z3_mk_true(ctx.ref()), ctx)
1688  else:
1689  return BoolRef(Z3_mk_false(ctx.ref()), ctx)
1690 
1691 
def BoolVal(val, ctx=None)
Definition: z3py.py:1673
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 Goal.as_expr(), ApplyResult.as_expr(), BoolSortRef.cast(), UserPropagateBase.conflict(), AlgebraicNumRef.index(), is_quantifier(), and Solver.to_smt2().

◆ BoolVector()

def z3py.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 1720 of file z3py.py.

1720 def BoolVector(prefix, sz, ctx=None):
1721  """Return a list of Boolean constants of size `sz`.
1722 
1723  The constants are named using the given prefix.
1724  If `ctx=None`, then the global context is used.
1725 
1726  >>> P = BoolVector('p', 3)
1727  >>> P
1728  [p__0, p__1, p__2]
1729  >>> And(P)
1730  And(p__0, p__1, p__2)
1731  """
1732  return [Bool("%s__%s" % (prefix, i)) for i in range(sz)]
1733 
1734 
def BoolVector(prefix, sz, ctx=None)
Definition: z3py.py:1720

◆ BV2Int()

def z3py.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 3935 of file z3py.py.

3935 def BV2Int(a, is_signed=False):
3936  """Return the Z3 expression BV2Int(a).
3937 
3938  >>> b = BitVec('b', 3)
3939  >>> BV2Int(b).sort()
3940  Int
3941  >>> x = Int('x')
3942  >>> x > BV2Int(b)
3943  x > BV2Int(b)
3944  >>> x > BV2Int(b, is_signed=False)
3945  x > BV2Int(b)
3946  >>> x > BV2Int(b, is_signed=True)
3947  x > If(b < 0, BV2Int(b) - 8, BV2Int(b))
3948  >>> solve(x > BV2Int(b), b == 1, x < 3)
3949  [x = 2, b = 1]
3950  """
3951  if z3_debug():
3952  _z3_assert(is_bv(a), "First argument must be a Z3 bit-vector expression")
3953  ctx = a.ctx
3954  # investigate problem with bv2int
3955  return ArithRef(Z3_mk_bv2int(ctx.ref(), a.as_ast(), is_signed), ctx)
3956 
3957 
def is_bv(a)
Definition: z3py.py:3906
def BV2Int(a, is_signed=False)
Definition: z3py.py:3935
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()

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

Definition at line 4421 of file z3py.py.

4421 def BVAddNoOverflow(a, b, signed):
4422  """A predicate the determines that bit-vector addition does not overflow"""
4423  _check_bv_args(a, b)
4424  a, b = _coerce_exprs(a, b)
4425  return BoolRef(Z3_mk_bvadd_no_overflow(a.ctx_ref(), a.as_ast(), b.as_ast(), signed), a.ctx)
4426 
4427 
def BVAddNoOverflow(a, b, signed)
Definition: z3py.py:4421
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()

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

Definition at line 4428 of file z3py.py.

4428 def BVAddNoUnderflow(a, b):
4429  """A predicate the determines that signed bit-vector addition does not underflow"""
4430  _check_bv_args(a, b)
4431  a, b = _coerce_exprs(a, b)
4432  return BoolRef(Z3_mk_bvadd_no_underflow(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4433 
4434 
def BVAddNoUnderflow(a, b)
Definition: z3py.py:4428
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()

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

Definition at line 4463 of file z3py.py.

4463 def BVMulNoOverflow(a, b, signed):
4464  """A predicate the determines that bit-vector multiplication does not overflow"""
4465  _check_bv_args(a, b)
4466  a, b = _coerce_exprs(a, b)
4467  return BoolRef(Z3_mk_bvmul_no_overflow(a.ctx_ref(), a.as_ast(), b.as_ast(), signed), a.ctx)
4468 
4469 
def BVMulNoOverflow(a, b, signed)
Definition: z3py.py:4463
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()

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

Definition at line 4470 of file z3py.py.

4470 def BVMulNoUnderflow(a, b):
4471  """A predicate the determines that bit-vector signed multiplication does not underflow"""
4472  _check_bv_args(a, b)
4473  a, b = _coerce_exprs(a, b)
4474  return BoolRef(Z3_mk_bvmul_no_underflow(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4475 
4476 
def BVMulNoUnderflow(a, b)
Definition: z3py.py:4470
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...

◆ BVRedAnd()

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

Definition at line 4407 of file z3py.py.

4407 def BVRedAnd(a):
4408  """Return the reduction-and expression of `a`."""
4409  if z3_debug():
4410  _z3_assert(is_bv(a), "First argument must be a Z3 bit-vector expression")
4411  return BitVecRef(Z3_mk_bvredand(a.ctx_ref(), a.as_ast()), a.ctx)
4412 
4413 
def BVRedAnd(a)
Definition: z3py.py:4407
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()

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

Definition at line 4414 of file z3py.py.

4414 def BVRedOr(a):
4415  """Return the reduction-or expression of `a`."""
4416  if z3_debug():
4417  _z3_assert(is_bv(a), "First argument must be a Z3 bit-vector expression")
4418  return BitVecRef(Z3_mk_bvredor(a.ctx_ref(), a.as_ast()), a.ctx)
4419 
4420 
def BVRedOr(a)
Definition: z3py.py:4414
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()

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

Definition at line 4449 of file z3py.py.

4449 def BVSDivNoOverflow(a, b):
4450  """A predicate the determines that bit-vector signed division does not overflow"""
4451  _check_bv_args(a, b)
4452  a, b = _coerce_exprs(a, b)
4453  return BoolRef(Z3_mk_bvsdiv_no_overflow(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4454 
4455 
def BVSDivNoOverflow(a, b)
Definition: z3py.py:4449
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()

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

Definition at line 4456 of file z3py.py.

4456 def BVSNegNoOverflow(a):
4457  """A predicate the determines that bit-vector unary negation does not overflow"""
4458  if z3_debug():
4459  _z3_assert(is_bv(a), "First argument must be a Z3 bit-vector expression")
4460  return BoolRef(Z3_mk_bvneg_no_overflow(a.ctx_ref(), a.as_ast()), a.ctx)
4461 
4462 
def BVSNegNoOverflow(a)
Definition: z3py.py:4456
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()

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

Definition at line 4435 of file z3py.py.

4435 def BVSubNoOverflow(a, b):
4436  """A predicate the determines that bit-vector subtraction does not overflow"""
4437  _check_bv_args(a, b)
4438  a, b = _coerce_exprs(a, b)
4439  return BoolRef(Z3_mk_bvsub_no_overflow(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4440 
4441 
def BVSubNoOverflow(a, b)
Definition: z3py.py:4435
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()

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

Definition at line 4442 of file z3py.py.

4442 def BVSubNoUnderflow(a, b, signed):
4443  """A predicate the determines that bit-vector subtraction does not underflow"""
4444  _check_bv_args(a, b)
4445  a, b = _coerce_exprs(a, b)
4446  return BoolRef(Z3_mk_bvsub_no_underflow(a.ctx_ref(), a.as_ast(), b.as_ast(), signed), a.ctx)
4447 
4448 
def BVSubNoUnderflow(a, b, signed)
Definition: z3py.py:4442
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.

◆ Cbrt()

def z3py.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 3386 of file z3py.py.

3386 def Cbrt(a, ctx=None):
3387  """ Return a Z3 expression which represents the cubic root of a.
3388 
3389  >>> x = Real('x')
3390  >>> Cbrt(x)
3391  x**(1/3)
3392  """
3393  if not is_expr(a):
3394  ctx = _get_ctx(ctx)
3395  a = RealVal(a, ctx)
3396  return a ** "1/3"
3397 
def is_expr(a)
Definition: z3py.py:1210
def Cbrt(a, ctx=None)
Definition: z3py.py:3386
def RealVal(val, ctx=None)
Definition: z3py.py:3162

◆ Complement()

def z3py.Complement (   re)
Create the complement regular expression.

Definition at line 11002 of file z3py.py.

11002 def Complement(re):
11003  """Create the complement regular expression."""
11004  return ReRef(Z3_mk_re_complement(re.ctx_ref(), re.as_ast()), re.ctx)
11005 
11006 
def Complement(re)
Definition: z3py.py:11002
Z3_ast Z3_API Z3_mk_re_complement(Z3_context c, Z3_ast re)
Create the complement of the regular language re.

◆ Concat()

def z3py.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 4044 of file z3py.py.

4044 def Concat(*args):
4045  """Create a Z3 bit-vector concatenation expression.
4046 
4047  >>> v = BitVecVal(1, 4)
4048  >>> Concat(v, v+1, v)
4049  Concat(Concat(1, 1 + 1), 1)
4050  >>> simplify(Concat(v, v+1, v))
4051  289
4052  >>> print("%.3x" % simplify(Concat(v, v+1, v)).as_long())
4053  121
4054  """
4055  args = _get_args(args)
4056  sz = len(args)
4057  if z3_debug():
4058  _z3_assert(sz >= 2, "At least two arguments expected.")
4059 
4060  ctx = None
4061  for a in args:
4062  if is_expr(a):
4063  ctx = a.ctx
4064  break
4065  if is_seq(args[0]) or isinstance(args[0], str):
4066  args = [_coerce_seq(s, ctx) for s in args]
4067  if z3_debug():
4068  _z3_assert(all([is_seq(a) for a in args]), "All arguments must be sequence expressions.")
4069  v = (Ast * sz)()
4070  for i in range(sz):
4071  v[i] = args[i].as_ast()
4072  return SeqRef(Z3_mk_seq_concat(ctx.ref(), sz, v), ctx)
4073 
4074  if is_re(args[0]):
4075  if z3_debug():
4076  _z3_assert(all([is_re(a) for a in args]), "All arguments must be regular expressions.")
4077  v = (Ast * sz)()
4078  for i in range(sz):
4079  v[i] = args[i].as_ast()
4080  return ReRef(Z3_mk_re_concat(ctx.ref(), sz, v), ctx)
4081 
4082  if z3_debug():
4083  _z3_assert(all([is_bv(a) for a in args]), "All arguments must be Z3 bit-vector expressions.")
4084  r = args[0]
4085  for i in range(sz - 1):
4086  r = BitVecRef(Z3_mk_concat(ctx.ref(), r.as_ast(), args[i + 1].as_ast()), ctx)
4087  return r
4088 
4089 
def Concat(*args)
Definition: z3py.py:4044
def is_seq(a)
Definition: z3py.py:10658
def is_re(s)
Definition: z3py.py:10920
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.

Referenced by SeqRef.__add__(), and SeqRef.__radd__().

◆ Cond()

def z3py.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 8628 of file z3py.py.

8628 def Cond(p, t1, t2, ctx=None):
8629  """Return a tactic that applies tactic `t1` to a goal if probe `p` evaluates to true, and `t2` otherwise.
8630 
8631  >>> t = Cond(Probe('is-qfnra'), Tactic('qfnra'), Tactic('smt'))
8632  """
8633  p = _to_probe(p, ctx)
8634  t1 = _to_tactic(t1, ctx)
8635  t2 = _to_tactic(t2, ctx)
8636  return Tactic(Z3_tactic_cond(t1.ctx.ref(), p.probe, t1.tactic, t2.tactic), t1.ctx)
8637 
def Cond(p, t1, t2, ctx=None)
Definition: z3py.py:8628
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()

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

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

Definition at line 1405 of file z3py.py.

1405 def Const(name, sort):
1406  """Create a constant of the given sort.
1407 
1408  >>> Const('x', IntSort())
1409  x
1410  """
1411  if z3_debug():
1412  _z3_assert(isinstance(sort, SortRef), "Z3 sort expected")
1413  ctx = sort.ctx
1414  return _to_expr_ref(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), sort.ast), ctx)
1415 
1416 
def Const(name, sort)
Definition: z3py.py:1405

Referenced by Consts().

◆ Consts()

def z3py.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 1417 of file z3py.py.

1417 def Consts(names, sort):
1418  """Create several constants of the given sort.
1419 
1420  `names` is a string containing the names of all constants to be created.
1421  Blank spaces separate the names of different constants.
1422 
1423  >>> x, y, z = Consts('x y z', IntSort())
1424  >>> x + y + z
1425  x + y + z
1426  """
1427  if isinstance(names, str):
1428  names = names.split(" ")
1429  return [Const(name, sort) for name in names]
1430 
1431 
def Consts(names, sort)
Definition: z3py.py:1417

◆ Contains()

def z3py.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 10789 of file z3py.py.

10789 def Contains(a, b):
10790  """Check if 'a' contains 'b'
10791  >>> s1 = Contains("abc", "ab")
10792  >>> simplify(s1)
10793  True
10794  >>> s2 = Contains("abc", "bc")
10795  >>> simplify(s2)
10796  True
10797  >>> x, y, z = Strings('x y z')
10798  >>> s3 = Contains(Concat(x,y,z), y)
10799  >>> simplify(s3)
10800  True
10801  """
10802  ctx = _get_ctx2(a, b)
10803  a = _coerce_seq(a, ctx)
10804  b = _coerce_seq(b, ctx)
10805  return BoolRef(Z3_mk_seq_contains(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
10806 
10807 
def Contains(a, b)
Definition: z3py.py:10789
Z3_ast Z3_API Z3_mk_seq_contains(Z3_context c, Z3_ast container, Z3_ast containee)
Check if container contains containee.

◆ CreateDatatypes()

def z3py.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 5092 of file z3py.py.

5092 def CreateDatatypes(*ds):
5093  """Create mutually recursive Z3 datatypes using 1 or more Datatype helper objects.
5094 
5095  In the following example we define a Tree-List using two mutually recursive datatypes.
5096 
5097  >>> TreeList = Datatype('TreeList')
5098  >>> Tree = Datatype('Tree')
5099  >>> # Tree has two constructors: leaf and node
5100  >>> Tree.declare('leaf', ('val', IntSort()))
5101  >>> # a node contains a list of trees
5102  >>> Tree.declare('node', ('children', TreeList))
5103  >>> TreeList.declare('nil')
5104  >>> TreeList.declare('cons', ('car', Tree), ('cdr', TreeList))
5105  >>> Tree, TreeList = CreateDatatypes(Tree, TreeList)
5106  >>> Tree.val(Tree.leaf(10))
5107  val(leaf(10))
5108  >>> simplify(Tree.val(Tree.leaf(10)))
5109  10
5110  >>> n1 = Tree.node(TreeList.cons(Tree.leaf(10), TreeList.cons(Tree.leaf(20), TreeList.nil)))
5111  >>> n1
5112  node(cons(leaf(10), cons(leaf(20), nil)))
5113  >>> n2 = Tree.node(TreeList.cons(n1, TreeList.nil))
5114  >>> simplify(n2 == n1)
5115  False
5116  >>> simplify(TreeList.car(Tree.children(n2)) == n1)
5117  True
5118  """
5119  ds = _get_args(ds)
5120  if z3_debug():
5121  _z3_assert(len(ds) > 0, "At least one Datatype must be specified")
5122  _z3_assert(all([isinstance(d, Datatype) for d in ds]), "Arguments must be Datatypes")
5123  _z3_assert(all([d.ctx == ds[0].ctx for d in ds]), "Context mismatch")
5124  _z3_assert(all([d.constructors != [] for d in ds]), "Non-empty Datatypes expected")
5125  ctx = ds[0].ctx
5126  num = len(ds)
5127  names = (Symbol * num)()
5128  out = (Sort * num)()
5129  clists = (ConstructorList * num)()
5130  to_delete = []
5131  for i in range(num):
5132  d = ds[i]
5133  names[i] = to_symbol(d.name, ctx)
5134  num_cs = len(d.constructors)
5135  cs = (Constructor * num_cs)()
5136  for j in range(num_cs):
5137  c = d.constructors[j]
5138  cname = to_symbol(c[0], ctx)
5139  rname = to_symbol(c[1], ctx)
5140  fs = c[2]
5141  num_fs = len(fs)
5142  fnames = (Symbol * num_fs)()
5143  sorts = (Sort * num_fs)()
5144  refs = (ctypes.c_uint * num_fs)()
5145  for k in range(num_fs):
5146  fname = fs[k][0]
5147  ftype = fs[k][1]
5148  fnames[k] = to_symbol(fname, ctx)
5149  if isinstance(ftype, Datatype):
5150  if z3_debug():
5151  _z3_assert(
5152  ds.count(ftype) == 1,
5153  "One and only one occurrence of each datatype is expected",
5154  )
5155  sorts[k] = None
5156  refs[k] = ds.index(ftype)
5157  else:
5158  if z3_debug():
5159  _z3_assert(is_sort(ftype), "Z3 sort expected")
5160  sorts[k] = ftype.ast
5161  refs[k] = 0
5162  cs[j] = Z3_mk_constructor(ctx.ref(), cname, rname, num_fs, fnames, sorts, refs)
5163  to_delete.append(ScopedConstructor(cs[j], ctx))
5164  clists[i] = Z3_mk_constructor_list(ctx.ref(), num_cs, cs)
5165  to_delete.append(ScopedConstructorList(clists[i], ctx))
5166  Z3_mk_datatypes(ctx.ref(), num, names, out, clists)
5167  result = []
5168  # Create a field for every constructor, recognizer and accessor
5169  for i in range(num):
5170  dref = DatatypeSortRef(out[i], ctx)
5171  num_cs = dref.num_constructors()
5172  for j in range(num_cs):
5173  cref = dref.constructor(j)
5174  cref_name = cref.name()
5175  cref_arity = cref.arity()
5176  if cref.arity() == 0:
5177  cref = cref()
5178  setattr(dref, cref_name, cref)
5179  rref = dref.recognizer(j)
5180  setattr(dref, "is_" + cref_name, rref)
5181  for k in range(cref_arity):
5182  aref = dref.accessor(j, k)
5183  setattr(dref, aref.name(), aref)
5184  result.append(dref)
5185  return tuple(result)
5186 
5187 
def CreateDatatypes(*ds)
Definition: z3py.py:5092
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_opt const sorts[], unsigned sort_refs[])
Create a constructor.
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.

Referenced by Datatype.create().

◆ DeclareSort()

def z3py.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 690 of file z3py.py.

690 def DeclareSort(name, ctx=None):
691  """Create a new uninterpreted sort named `name`.
692 
693  If `ctx=None`, then the new sort is declared in the global Z3Py context.
694 
695  >>> A = DeclareSort('A')
696  >>> a = Const('a', A)
697  >>> b = Const('b', A)
698  >>> a.sort() == A
699  True
700  >>> b.sort() == A
701  True
702  >>> a == b
703  a == b
704  """
705  ctx = _get_ctx(ctx)
706  return SortRef(Z3_mk_uninterpreted_sort(ctx.ref(), to_symbol(name, ctx)), ctx)
707 
def DeclareSort(name, ctx=None)
Definition: z3py.py:690
Z3_sort Z3_API Z3_mk_uninterpreted_sort(Z3_context c, Z3_symbol s)
Create a free (uninterpreted) type using the given name (symbol).

◆ Default()

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

Definition at line 4714 of file z3py.py.

4714 def Default(a):
4715  """ Return a default value for array expression.
4716  >>> b = K(IntSort(), 1)
4717  >>> prove(Default(b) == 1)
4718  proved
4719  """
4720  if z3_debug():
4721  _z3_assert(is_array_sort(a), "First argument must be a Z3 array expression")
4722  return a.default()
4723 
4724 
def is_array_sort(a)
Definition: z3py.py:4552
def Default(a)
Definition: z3py.py:4714

◆ describe_probes()

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

Definition at line 8549 of file z3py.py.

8549 def describe_probes():
8550  """Display a (tabular) description of all available probes in Z3."""
8551  if in_html_mode():
8552  even = True
8553  print('<table border="1" cellpadding="2" cellspacing="0">')
8554  for p in probes():
8555  if even:
8556  print('<tr style="background-color:#CFCFCF">')
8557  even = False
8558  else:
8559  print("<tr>")
8560  even = True
8561  print("<td>%s</td><td>%s</td></tr>" % (p, insert_line_breaks(probe_description(p), 40)))
8562  print("</table>")
8563  else:
8564  for p in probes():
8565  print("%s : %s" % (p, probe_description(p)))
8566 
8567 
def probe_description(name, ctx=None)
Definition: z3py.py:8540
def describe_probes()
Definition: z3py.py:8549
def probes(ctx=None)
Definition: z3py.py:8529

◆ describe_tactics()

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

Definition at line 8343 of file z3py.py.

8343 def describe_tactics():
8344  """Display a (tabular) description of all available tactics in Z3."""
8345  if in_html_mode():
8346  even = True
8347  print('<table border="1" cellpadding="2" cellspacing="0">')
8348  for t in tactics():
8349  if even:
8350  print('<tr style="background-color:#CFCFCF">')
8351  even = False
8352  else:
8353  print("<tr>")
8354  even = True
8355  print("<td>%s</td><td>%s</td></tr>" % (t, insert_line_breaks(tactic_description(t), 40)))
8356  print("</table>")
8357  else:
8358  for t in tactics():
8359  print("%s : %s" % (t, tactic_description(t)))
8360 
8361 
def tactics(ctx=None)
Definition: z3py.py:8323
def tactic_description(name, ctx=None)
Definition: z3py.py:8334
def describe_tactics()
Definition: z3py.py:8343

◆ disable_trace()

def z3py.disable_trace (   msg)

Definition at line 81 of file z3py.py.

81 def disable_trace(msg):
82  Z3_disable_trace(msg)
83 
84 
def disable_trace(msg)
Definition: z3py.py:81
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()

def z3py.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 5305 of file z3py.py.

5305 def DisjointSum(name, sorts, ctx=None):
5306  """Create a named tagged union sort base on a set of underlying sorts
5307  Example:
5308  >>> sum, ((inject0, extract0), (inject1, extract1)) = DisjointSum("+", [IntSort(), StringSort()])
5309  """
5310  sum = Datatype(name, ctx)
5311  for i in range(len(sorts)):
5312  sum.declare("inject%d" % i, ("project%d" % i, sorts[i]))
5313  sum = sum.create()
5314  return sum, [(sum.constructor(i), sum.accessor(i, 0)) for i in range(len(sorts))]
5315 
5316 
def DisjointSum(name, sorts, ctx=None)
Definition: z3py.py:5305

◆ Distinct()

def z3py.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 1372 of file z3py.py.

1372 def Distinct(*args):
1373  """Create a Z3 distinct expression.
1374 
1375  >>> x = Int('x')
1376  >>> y = Int('y')
1377  >>> Distinct(x, y)
1378  x != y
1379  >>> z = Int('z')
1380  >>> Distinct(x, y, z)
1381  Distinct(x, y, z)
1382  >>> simplify(Distinct(x, y, z))
1383  Distinct(x, y, z)
1384  >>> simplify(Distinct(x, y, z), blast_distinct=True)
1385  And(Not(x == y), Not(x == z), Not(y == z))
1386  """
1387  args = _get_args(args)
1388  ctx = _ctx_from_ast_arg_list(args)
1389  if z3_debug():
1390  _z3_assert(ctx is not None, "At least one of the arguments must be a Z3 expression")
1391  args = _coerce_expr_list(args, ctx)
1392  _args, sz = _to_ast_array(args)
1393  return BoolRef(Z3_mk_distinct(ctx.ref(), sz, _args), ctx)
1394 
1395 
def Distinct(*args)
Definition: z3py.py:1372
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()

def z3py.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 10720 of file z3py.py.

10720 def Empty(s):
10721  """Create the empty sequence of the given sort
10722  >>> e = Empty(StringSort())
10723  >>> e2 = StringVal("")
10724  >>> print(e.eq(e2))
10725  True
10726  >>> e3 = Empty(SeqSort(IntSort()))
10727  >>> print(e3)
10728  Empty(Seq(Int))
10729  >>> e4 = Empty(ReSort(SeqSort(IntSort())))
10730  >>> print(e4)
10731  Empty(ReSort(Seq(Int)))
10732  """
10733  if isinstance(s, SeqSortRef):
10734  return SeqRef(Z3_mk_seq_empty(s.ctx_ref(), s.ast), s.ctx)
10735  if isinstance(s, ReSortRef):
10736  return ReRef(Z3_mk_re_empty(s.ctx_ref(), s.ast), s.ctx)
10737  raise Z3Exception("Non-sequence, non-regular expression sort passed to Empty")
10738 
10739 
def Empty(s)
Definition: z3py.py:10720
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()

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

Definition at line 4856 of file z3py.py.

4856 def EmptySet(s):
4857  """Create the empty set
4858  >>> EmptySet(IntSort())
4859  K(Int, False)
4860  """
4861  ctx = s.ctx
4862  return ArrayRef(Z3_mk_empty_set(ctx.ref(), s.ast), ctx)
4863 
4864 
def EmptySet(s)
Definition: z3py.py:4856
Z3_ast Z3_API Z3_mk_empty_set(Z3_context c, Z3_sort domain)
Create the empty set.

◆ enable_trace()

def z3py.enable_trace (   msg)

Definition at line 77 of file z3py.py.

77 def enable_trace(msg):
78  Z3_enable_trace(msg)
79 
80 
def enable_trace(msg)
Definition: z3py.py:77
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()

def z3py.ensure_prop_closures ( )

Definition at line 11110 of file z3py.py.

11110 def ensure_prop_closures():
11111  global _prop_closures
11112  if _prop_closures is None:
11113  _prop_closures = PropClosures()
11114 
11115 
def ensure_prop_closures()
Definition: z3py.py:11110

Referenced by UserPropagateBase.__init__().

◆ EnumSort()

def z3py.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 5317 of file z3py.py.

5317 def EnumSort(name, values, ctx=None):
5318  """Return a new enumeration sort named `name` containing the given values.
5319 
5320  The result is a pair (sort, list of constants).
5321  Example:
5322  >>> Color, (red, green, blue) = EnumSort('Color', ['red', 'green', 'blue'])
5323  """
5324  if z3_debug():
5325  _z3_assert(isinstance(name, str), "Name must be a string")
5326  _z3_assert(all([isinstance(v, str) for v in values]), "Eumeration sort values must be strings")
5327  _z3_assert(len(values) > 0, "At least one value expected")
5328  ctx = _get_ctx(ctx)
5329  num = len(values)
5330  _val_names = (Symbol * num)()
5331  for i in range(num):
5332  _val_names[i] = to_symbol(values[i])
5333  _values = (FuncDecl * num)()
5334  _testers = (FuncDecl * num)()
5335  name = to_symbol(name)
5336  S = DatatypeSortRef(Z3_mk_enumeration_sort(ctx.ref(), name, num, _val_names, _values, _testers), ctx)
5337  V = []
5338  for i in range(num):
5339  V.append(FuncDeclRef(_values[i], ctx))
5340  V = [a() for a in V]
5341  return S, V
5342 
def EnumSort(name, values, ctx=None)
Definition: z3py.py:5317
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()

def z3py.eq (   a,
  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 471 of file z3py.py.

471 def eq(a, b):
472  """Return `True` if `a` and `b` are structurally identical AST nodes.
473 
474  >>> x = Int('x')
475  >>> y = Int('y')
476  >>> eq(x, y)
477  False
478  >>> eq(x + 1, x + 1)
479  True
480  >>> eq(x + 1, 1 + x)
481  False
482  >>> eq(simplify(x + 1), simplify(1 + x))
483  True
484  """
485  if z3_debug():
486  _z3_assert(is_ast(a) and is_ast(b), "Z3 ASTs expected")
487  return a.eq(b)
488 
489 
def is_ast(a)
Definition: z3py.py:450
def eq(a, b)
Definition: z3py.py:471

Referenced by substitute().

◆ Exists()

def z3py.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 2205 of file z3py.py.

2205 def Exists(vs, body, weight=1, qid="", skid="", patterns=[], no_patterns=[]):
2206  """Create a Z3 exists formula.
2207 
2208  The parameters `weight`, `qif`, `skid`, `patterns` and `no_patterns` are optional annotations.
2209 
2210 
2211  >>> f = Function('f', IntSort(), IntSort(), IntSort())
2212  >>> x = Int('x')
2213  >>> y = Int('y')
2214  >>> q = Exists([x, y], f(x, y) >= x, skid="foo")
2215  >>> q
2216  Exists([x, y], f(x, y) >= x)
2217  >>> is_quantifier(q)
2218  True
2219  >>> r = Tactic('nnf')(q).as_expr()
2220  >>> is_quantifier(r)
2221  False
2222  """
2223  return _mk_quantifier(False, vs, body, weight, qid, skid, patterns, no_patterns)
2224 
2225 
def Exists(vs, body, weight=1, qid="", skid="", patterns=[], no_patterns=[])
Definition: z3py.py:2205

Referenced by Fixedpoint.abstract().

◆ Ext()

def z3py.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 4802 of file z3py.py.

4802 def Ext(a, b):
4803  """Return extensionality index for one-dimensional arrays.
4804  >> a, b = Consts('a b', SetSort(IntSort()))
4805  >> Ext(a, b)
4806  Ext(a, b)
4807  """
4808  ctx = a.ctx
4809  if z3_debug():
4810  _z3_assert(is_array_sort(a) and is_array(b), "arguments must be arrays")
4811  return _to_expr_ref(Z3_mk_array_ext(ctx.ref(), a.as_ast(), b.as_ast()), ctx)
4812 
4813 
def is_array(a)
Definition: z3py.py:4556
def Ext(a, b)
Definition: z3py.py:4802
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()

def z3py.Extract (   high,
  low,
  a 
)
Create a Z3 bit-vector extraction expression.
Extract is overloaded to also work on sequence extraction.
The functions SubString and SubSeq are redirected to Extract.
For this case, the arguments are reinterpreted as:
    high - is a sequence (string)
    low  - is an offset
    a    - is the length to be extracted

>>> x = BitVec('x', 8)
>>> Extract(6, 2, x)
Extract(6, 2, x)
>>> Extract(6, 2, x).sort()
BitVec(5)
>>> simplify(Extract(StringVal("abcd"),2,1))
"c"

Definition at line 4090 of file z3py.py.

4090 def Extract(high, low, a):
4091  """Create a Z3 bit-vector extraction expression.
4092  Extract is overloaded to also work on sequence extraction.
4093  The functions SubString and SubSeq are redirected to Extract.
4094  For this case, the arguments are reinterpreted as:
4095  high - is a sequence (string)
4096  low - is an offset
4097  a - is the length to be extracted
4098 
4099  >>> x = BitVec('x', 8)
4100  >>> Extract(6, 2, x)
4101  Extract(6, 2, x)
4102  >>> Extract(6, 2, x).sort()
4103  BitVec(5)
4104  >>> simplify(Extract(StringVal("abcd"),2,1))
4105  "c"
4106  """
4107  if isinstance(high, str):
4108  high = StringVal(high)
4109  if is_seq(high):
4110  s = high
4111  offset, length = _coerce_exprs(low, a, s.ctx)
4112  return SeqRef(Z3_mk_seq_extract(s.ctx_ref(), s.as_ast(), offset.as_ast(), length.as_ast()), s.ctx)
4113  if z3_debug():
4114  _z3_assert(low <= high, "First argument must be greater than or equal to second argument")
4115  _z3_assert(_is_int(high) and high >= 0 and _is_int(low) and low >= 0,
4116  "First and second arguments must be non negative integers")
4117  _z3_assert(is_bv(a), "Third argument must be a Z3 bit-vector expression")
4118  return BitVecRef(Z3_mk_extract(a.ctx_ref(), high, low, a.as_ast()), a.ctx)
4119 
4120 
def Extract(high, low, a)
Definition: z3py.py:4090
def StringVal(s, ctx=None)
Definition: z3py.py:10686
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.

Referenced by SubSeq(), and SubString().

◆ FailIf()

def z3py.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 8586 of file z3py.py.

8586 def FailIf(p, ctx=None):
8587  """Return a tactic that fails if the probe `p` evaluates to true.
8588  Otherwise, it returns the input goal unmodified.
8589 
8590  In the following example, the tactic applies 'simplify' if and only if there are
8591  more than 2 constraints in the goal.
8592 
8593  >>> t = OrElse(FailIf(Probe('size') > 2), Tactic('simplify'))
8594  >>> x, y = Ints('x y')
8595  >>> g = Goal()
8596  >>> g.add(x > 0)
8597  >>> g.add(y > 0)
8598  >>> t(g)
8599  [[x > 0, y > 0]]
8600  >>> g.add(x == y + 1)
8601  >>> t(g)
8602  [[Not(x <= 0), Not(y <= 0), x == 1 + y]]
8603  """
8604  p = _to_probe(p, ctx)
8605  return Tactic(Z3_tactic_fail_if(p.ctx.ref(), p.probe), p.ctx)
8606 
8607 
def FailIf(p, ctx=None)
Definition: z3py.py:8586
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()

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

Definition at line 7590 of file z3py.py.

7590 def FiniteDomainSort(name, sz, ctx=None):
7591  """Create a named finite domain sort of a given size sz"""
7592  if not isinstance(name, Symbol):
7593  name = to_symbol(name)
7594  ctx = _get_ctx(ctx)
7595  return FiniteDomainSortRef(Z3_mk_finite_domain_sort(ctx.ref(), name, sz), ctx)
7596 
7597 
def FiniteDomainSort(name, sz, ctx=None)
Definition: z3py.py:7590
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()

def z3py.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 7660 of file z3py.py.

7660 def FiniteDomainVal(val, sort, ctx=None):
7661  """Return a Z3 finite-domain value. If `ctx=None`, then the global context is used.
7662 
7663  >>> s = FiniteDomainSort('S', 256)
7664  >>> FiniteDomainVal(255, s)
7665  255
7666  >>> FiniteDomainVal('100', s)
7667  100
7668  """
7669  if z3_debug():
7670  _z3_assert(is_finite_domain_sort(sort), "Expected finite-domain sort")
7671  ctx = sort.ctx
7672  return FiniteDomainNumRef(Z3_mk_numeral(ctx.ref(), _to_int_str(val), sort.ast), ctx)
7673 
7674 
def FiniteDomainVal(val, sort, ctx=None)
Definition: z3py.py:7660
def is_finite_domain_sort(s)
Definition: z3py.py:7598

◆ Float128()

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

Definition at line 9266 of file z3py.py.

9266 def Float128(ctx=None):
9267  """Floating-point 128-bit (quadruple) sort."""
9268  ctx = _get_ctx(ctx)
9269  return FPSortRef(Z3_mk_fpa_sort_128(ctx.ref()), ctx)
9270 
9271 
def Float128(ctx=None)
Definition: z3py.py:9266
Z3_sort Z3_API Z3_mk_fpa_sort_128(Z3_context c)
Create the quadruple-precision (128-bit) FloatingPoint sort.

◆ Float16()

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

Definition at line 9230 of file z3py.py.

9230 def Float16(ctx=None):
9231  """Floating-point 16-bit (half) sort."""
9232  ctx = _get_ctx(ctx)
9233  return FPSortRef(Z3_mk_fpa_sort_16(ctx.ref()), ctx)
9234 
9235 
def Float16(ctx=None)
Definition: z3py.py:9230
Z3_sort Z3_API Z3_mk_fpa_sort_16(Z3_context c)
Create the half-precision (16-bit) FloatingPoint sort.

◆ Float32()

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

Definition at line 9242 of file z3py.py.

9242 def Float32(ctx=None):
9243  """Floating-point 32-bit (single) sort."""
9244  ctx = _get_ctx(ctx)
9245  return FPSortRef(Z3_mk_fpa_sort_32(ctx.ref()), ctx)
9246 
9247 
def Float32(ctx=None)
Definition: z3py.py:9242
Z3_sort Z3_API Z3_mk_fpa_sort_32(Z3_context c)
Create the single-precision (32-bit) FloatingPoint sort.

◆ Float64()

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

Definition at line 9254 of file z3py.py.

9254 def Float64(ctx=None):
9255  """Floating-point 64-bit (double) sort."""
9256  ctx = _get_ctx(ctx)
9257  return FPSortRef(Z3_mk_fpa_sort_64(ctx.ref()), ctx)
9258 
9259 
def Float64(ctx=None)
Definition: z3py.py:9254
Z3_sort Z3_API Z3_mk_fpa_sort_64(Z3_context c)
Create the double-precision (64-bit) FloatingPoint sort.

◆ FloatDouble()

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

Definition at line 9260 of file z3py.py.

9260 def FloatDouble(ctx=None):
9261  """Floating-point 64-bit (double) sort."""
9262  ctx = _get_ctx(ctx)
9263  return FPSortRef(Z3_mk_fpa_sort_double(ctx.ref()), ctx)
9264 
9265 
def FloatDouble(ctx=None)
Definition: z3py.py:9260
Z3_sort Z3_API Z3_mk_fpa_sort_double(Z3_context c)
Create the double-precision (64-bit) FloatingPoint sort.

◆ FloatHalf()

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

Definition at line 9236 of file z3py.py.

9236 def FloatHalf(ctx=None):
9237  """Floating-point 16-bit (half) sort."""
9238  ctx = _get_ctx(ctx)
9239  return FPSortRef(Z3_mk_fpa_sort_half(ctx.ref()), ctx)
9240 
9241 
def FloatHalf(ctx=None)
Definition: z3py.py:9236
Z3_sort Z3_API Z3_mk_fpa_sort_half(Z3_context c)
Create the half-precision (16-bit) FloatingPoint sort.

◆ FloatQuadruple()

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

Definition at line 9272 of file z3py.py.

9272 def FloatQuadruple(ctx=None):
9273  """Floating-point 128-bit (quadruple) sort."""
9274  ctx = _get_ctx(ctx)
9275  return FPSortRef(Z3_mk_fpa_sort_quadruple(ctx.ref()), ctx)
9276 
9277 
def FloatQuadruple(ctx=None)
Definition: z3py.py:9272
Z3_sort Z3_API Z3_mk_fpa_sort_quadruple(Z3_context c)
Create the quadruple-precision (128-bit) FloatingPoint sort.

◆ FloatSingle()

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

Definition at line 9248 of file z3py.py.

9248 def FloatSingle(ctx=None):
9249  """Floating-point 32-bit (single) sort."""
9250  ctx = _get_ctx(ctx)
9251  return FPSortRef(Z3_mk_fpa_sort_single(ctx.ref()), ctx)
9252 
9253 
def FloatSingle(ctx=None)
Definition: z3py.py:9248
Z3_sort Z3_API Z3_mk_fpa_sort_single(Z3_context c)
Create the single-precision (32-bit) FloatingPoint sort.

◆ ForAll()

def z3py.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 2187 of file z3py.py.

2187 def ForAll(vs, body, weight=1, qid="", skid="", patterns=[], no_patterns=[]):
2188  """Create a Z3 forall formula.
2189 
2190  The parameters `weight`, `qid`, `skid`, `patterns` and `no_patterns` are optional annotations.
2191 
2192  >>> f = Function('f', IntSort(), IntSort(), IntSort())
2193  >>> x = Int('x')
2194  >>> y = Int('y')
2195  >>> ForAll([x, y], f(x, y) >= x)
2196  ForAll([x, y], f(x, y) >= x)
2197  >>> ForAll([x, y], f(x, y) >= x, patterns=[ f(x, y) ])
2198  ForAll([x, y], f(x, y) >= x)
2199  >>> ForAll([x, y], f(x, y) >= x, weight=10)
2200  ForAll([x, y], f(x, y) >= x)
2201  """
2202  return _mk_quantifier(True, vs, body, weight, qid, skid, patterns, no_patterns)
2203 
2204 
def ForAll(vs, body, weight=1, qid="", skid="", patterns=[], no_patterns=[])
Definition: z3py.py:2187

Referenced by Fixedpoint.abstract().

◆ FP()

def z3py.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 9898 of file z3py.py.

9898 def FP(name, fpsort, ctx=None):
9899  """Return a floating-point constant named `name`.
9900  `fpsort` is the floating-point sort.
9901  If `ctx=None`, then the global context is used.
9902 
9903  >>> x = FP('x', FPSort(8, 24))
9904  >>> is_fp(x)
9905  True
9906  >>> x.ebits()
9907  8
9908  >>> x.sort()
9909  FPSort(8, 24)
9910  >>> word = FPSort(8, 24)
9911  >>> x2 = FP('x', word)
9912  >>> eq(x, x2)
9913  True
9914  """
9915  if isinstance(fpsort, FPSortRef) and ctx is None:
9916  ctx = fpsort.ctx
9917  else:
9918  ctx = _get_ctx(ctx)
9919  return FPRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), fpsort.ast), ctx)
9920 
9921 
def FP(name, fpsort, ctx=None)
Definition: z3py.py:9898

Referenced by FPs().

◆ fpAbs()

def z3py.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 9941 of file z3py.py.

9941 def fpAbs(a, ctx=None):
9942  """Create a Z3 floating-point absolute value expression.
9943 
9944  >>> s = FPSort(8, 24)
9945  >>> rm = RNE()
9946  >>> x = FPVal(1.0, s)
9947  >>> fpAbs(x)
9948  fpAbs(1)
9949  >>> y = FPVal(-20.0, s)
9950  >>> y
9951  -1.25*(2**4)
9952  >>> fpAbs(y)
9953  fpAbs(-1.25*(2**4))
9954  >>> fpAbs(-1.25*(2**4))
9955  fpAbs(-1.25*(2**4))
9956  >>> fpAbs(x).sort()
9957  FPSort(8, 24)
9958  """
9959  ctx = _get_ctx(ctx)
9960  [a] = _coerce_fp_expr_list([a], ctx)
9961  return FPRef(Z3_mk_fpa_abs(ctx.ref(), a.as_ast()), ctx)
9962 
9963 
def fpAbs(a, ctx=None)
Definition: z3py.py:9941
Z3_ast Z3_API Z3_mk_fpa_abs(Z3_context c, Z3_ast t)
Floating-point absolute value.

◆ fpAdd()

def z3py.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)
fpAdd(RNE(), x, y)
>>> fpAdd(RTZ(), x, y) # default rounding mode is RTZ
x + y
>>> fpAdd(rm, x, y).sort()
FPSort(8, 24)

Definition at line 10032 of file z3py.py.

10032 def fpAdd(rm, a, b, ctx=None):
10033  """Create a Z3 floating-point addition expression.
10034 
10035  >>> s = FPSort(8, 24)
10036  >>> rm = RNE()
10037  >>> x = FP('x', s)
10038  >>> y = FP('y', s)
10039  >>> fpAdd(rm, x, y)
10040  fpAdd(RNE(), x, y)
10041  >>> fpAdd(RTZ(), x, y) # default rounding mode is RTZ
10042  x + y
10043  >>> fpAdd(rm, x, y).sort()
10044  FPSort(8, 24)
10045  """
10046  return _mk_fp_bin(Z3_mk_fpa_add, rm, a, b, ctx)
10047 
10048 
def fpAdd(rm, a, b, ctx=None)
Definition: z3py.py:10032

Referenced by FPRef.__add__(), and FPRef.__radd__().

◆ fpBVToFP()

def z3py.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 10354 of file z3py.py.

10354 def fpBVToFP(v, sort, ctx=None):
10355  """Create a Z3 floating-point conversion expression that represents the
10356  conversion from a bit-vector term to a floating-point term.
10357 
10358  >>> x_bv = BitVecVal(0x3F800000, 32)
10359  >>> x_fp = fpBVToFP(x_bv, Float32())
10360  >>> x_fp
10361  fpToFP(1065353216)
10362  >>> simplify(x_fp)
10363  1
10364  """
10365  _z3_assert(is_bv(v), "First argument must be a Z3 bit-vector expression")
10366  _z3_assert(is_fp_sort(sort), "Second argument must be a Z3 floating-point sort.")
10367  ctx = _get_ctx(ctx)
10368  return FPRef(Z3_mk_fpa_to_fp_bv(ctx.ref(), v.ast, sort.ast), ctx)
10369 
10370 
def is_fp_sort(s)
Definition: z3py.py:9282
def fpBVToFP(v, sort, ctx=None)
Definition: z3py.py:10354
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()

def z3py.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)
fpDiv(RNE(), x, y)
>>> fpDiv(rm, x, y).sort()
FPSort(8, 24)

Definition at line 10079 of file z3py.py.

10079 def fpDiv(rm, a, b, ctx=None):
10080  """Create a Z3 floating-point division expression.
10081 
10082  >>> s = FPSort(8, 24)
10083  >>> rm = RNE()
10084  >>> x = FP('x', s)
10085  >>> y = FP('y', s)
10086  >>> fpDiv(rm, x, y)
10087  fpDiv(RNE(), x, y)
10088  >>> fpDiv(rm, x, y).sort()
10089  FPSort(8, 24)
10090  """
10091  return _mk_fp_bin(Z3_mk_fpa_div, rm, a, b, ctx)
10092 
10093 
def fpDiv(rm, a, b, ctx=None)
Definition: z3py.py:10079

Referenced by FPRef.__div__(), and FPRef.__rdiv__().

◆ fpEQ()

def z3py.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 10262 of file z3py.py.

10262 def fpEQ(a, b, ctx=None):
10263  """Create the Z3 floating-point expression `fpEQ(other, self)`.
10264 
10265  >>> x, y = FPs('x y', FPSort(8, 24))
10266  >>> fpEQ(x, y)
10267  fpEQ(x, y)
10268  >>> fpEQ(x, y).sexpr()
10269  '(fp.eq x y)'
10270  """
10271  return _mk_fp_bin_pred(Z3_mk_fpa_eq, a, b, ctx)
10272 
10273 
def fpEQ(a, b, ctx=None)
Definition: z3py.py:10262

Referenced by fpNEQ().

◆ fpFMA()

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

Definition at line 10138 of file z3py.py.

10138 def fpFMA(rm, a, b, c, ctx=None):
10139  """Create a Z3 floating-point fused multiply-add expression.
10140  """
10141  return _mk_fp_tern(Z3_mk_fpa_fma, rm, a, b, c, ctx)
10142 
10143 
def fpFMA(rm, a, b, c, ctx=None)
Definition: z3py.py:10138

◆ fpFP()

def z3py.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 10286 of file z3py.py.

10286 def fpFP(sgn, exp, sig, ctx=None):
10287  """Create the Z3 floating-point value `fpFP(sgn, sig, exp)` from the three bit-vectors sgn, sig, and exp.
10288 
10289  >>> s = FPSort(8, 24)
10290  >>> x = fpFP(BitVecVal(1, 1), BitVecVal(2**7-1, 8), BitVecVal(2**22, 23))
10291  >>> print(x)
10292  fpFP(1, 127, 4194304)
10293  >>> xv = FPVal(-1.5, s)
10294  >>> print(xv)
10295  -1.5
10296  >>> slvr = Solver()
10297  >>> slvr.add(fpEQ(x, xv))
10298  >>> slvr.check()
10299  sat
10300  >>> xv = FPVal(+1.5, s)
10301  >>> print(xv)
10302  1.5
10303  >>> slvr = Solver()
10304  >>> slvr.add(fpEQ(x, xv))
10305  >>> slvr.check()
10306  unsat
10307  """
10308  _z3_assert(is_bv(sgn) and is_bv(exp) and is_bv(sig), "sort mismatch")
10309  _z3_assert(sgn.sort().size() == 1, "sort mismatch")
10310  ctx = _get_ctx(ctx)
10311  _z3_assert(ctx == sgn.ctx == exp.ctx == sig.ctx, "context mismatch")
10312  return FPRef(Z3_mk_fpa_fp(ctx.ref(), sgn.ast, exp.ast, sig.ast), ctx)
10313 
10314 
def fpFP(sgn, exp, sig, ctx=None)
Definition: z3py.py:10286
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()

def z3py.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 10371 of file z3py.py.

10371 def fpFPToFP(rm, v, sort, ctx=None):
10372  """Create a Z3 floating-point conversion expression that represents the
10373  conversion from a floating-point term to a floating-point term of different precision.
10374 
10375  >>> x_sgl = FPVal(1.0, Float32())
10376  >>> x_dbl = fpFPToFP(RNE(), x_sgl, Float64())
10377  >>> x_dbl
10378  fpToFP(RNE(), 1)
10379  >>> simplify(x_dbl)
10380  1
10381  >>> x_dbl.sort()
10382  FPSort(11, 53)
10383  """
10384  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression.")
10385  _z3_assert(is_fp(v), "Second argument must be a Z3 floating-point expression.")
10386  _z3_assert(is_fp_sort(sort), "Third argument must be a Z3 floating-point sort.")
10387  ctx = _get_ctx(ctx)
10388  return FPRef(Z3_mk_fpa_to_fp_float(ctx.ref(), rm.ast, v.ast, sort.ast), ctx)
10389 
10390 
def fpFPToFP(rm, v, sort, ctx=None)
Definition: z3py.py:10371
def is_fprm(a)
Definition: z3py.py:9542
def is_fp(a)
Definition: z3py.py:9698
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()

def z3py.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 10250 of file z3py.py.

10250 def fpGEQ(a, b, ctx=None):
10251  """Create the Z3 floating-point expression `other >= self`.
10252 
10253  >>> x, y = FPs('x y', FPSort(8, 24))
10254  >>> fpGEQ(x, y)
10255  x >= y
10256  >>> (x >= y).sexpr()
10257  '(fp.geq x y)'
10258  """
10259  return _mk_fp_bin_pred(Z3_mk_fpa_geq, a, b, ctx)
10260 
10261 
def fpGEQ(a, b, ctx=None)
Definition: z3py.py:10250

Referenced by FPRef.__ge__().

◆ fpGT()

def z3py.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 10238 of file z3py.py.

10238 def fpGT(a, b, ctx=None):
10239  """Create the Z3 floating-point expression `other > self`.
10240 
10241  >>> x, y = FPs('x y', FPSort(8, 24))
10242  >>> fpGT(x, y)
10243  x > y
10244  >>> (x > y).sexpr()
10245  '(fp.gt x y)'
10246  """
10247  return _mk_fp_bin_pred(Z3_mk_fpa_gt, a, b, ctx)
10248 
10249 
def fpGT(a, b, ctx=None)
Definition: z3py.py:10238

Referenced by FPRef.__gt__().

◆ fpInfinity()

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

Definition at line 9826 of file z3py.py.

9826 def fpInfinity(s, negative):
9827  """Create a Z3 floating-point +oo or -oo term."""
9828  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
9829  _z3_assert(isinstance(negative, bool), "expected Boolean flag")
9830  return FPNumRef(Z3_mk_fpa_inf(s.ctx_ref(), s.ast, negative), s.ctx)
9831 
9832 
def fpInfinity(s, negative)
Definition: z3py.py:9826
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()

def z3py.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 10168 of file z3py.py.

10168 def fpIsInf(a, ctx=None):
10169  """Create a Z3 floating-point isInfinite expression.
10170 
10171  >>> s = FPSort(8, 24)
10172  >>> x = FP('x', s)
10173  >>> fpIsInf(x)
10174  fpIsInf(x)
10175  """
10176  return _mk_fp_unary_pred(Z3_mk_fpa_is_infinite, a, ctx)
10177 
10178 
def fpIsInf(a, ctx=None)
Definition: z3py.py:10168

◆ fpIsNaN()

def z3py.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 10156 of file z3py.py.

10156 def fpIsNaN(a, ctx=None):
10157  """Create a Z3 floating-point isNaN expression.
10158 
10159  >>> s = FPSort(8, 24)
10160  >>> x = FP('x', s)
10161  >>> y = FP('y', s)
10162  >>> fpIsNaN(x)
10163  fpIsNaN(x)
10164  """
10165  return _mk_fp_unary_pred(Z3_mk_fpa_is_nan, a, ctx)
10166 
10167 
def fpIsNaN(a, ctx=None)
Definition: z3py.py:10156

◆ fpIsNegative()

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

Definition at line 10197 of file z3py.py.

10197 def fpIsNegative(a, ctx=None):
10198  """Create a Z3 floating-point isNegative expression.
10199  """
10200  return _mk_fp_unary_pred(Z3_mk_fpa_is_negative, a, ctx)
10201 
10202 
def fpIsNegative(a, ctx=None)
Definition: z3py.py:10197

◆ fpIsNormal()

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

Definition at line 10185 of file z3py.py.

10185 def fpIsNormal(a, ctx=None):
10186  """Create a Z3 floating-point isNormal expression.
10187  """
10188  return _mk_fp_unary_pred(Z3_mk_fpa_is_normal, a, ctx)
10189 
10190 
def fpIsNormal(a, ctx=None)
Definition: z3py.py:10185

◆ fpIsPositive()

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

Definition at line 10203 of file z3py.py.

10203 def fpIsPositive(a, ctx=None):
10204  """Create a Z3 floating-point isPositive expression.
10205  """
10206  return _mk_fp_unary_pred(Z3_mk_fpa_is_positive, a, ctx)
10207 
10208 
def fpIsPositive(a, ctx=None)
Definition: z3py.py:10203

◆ fpIsSubnormal()

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

Definition at line 10191 of file z3py.py.

10191 def fpIsSubnormal(a, ctx=None):
10192  """Create a Z3 floating-point isSubnormal expression.
10193  """
10194  return _mk_fp_unary_pred(Z3_mk_fpa_is_subnormal, a, ctx)
10195 
10196 
def fpIsSubnormal(a, ctx=None)
Definition: z3py.py:10191

◆ fpIsZero()

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

Definition at line 10179 of file z3py.py.

10179 def fpIsZero(a, ctx=None):
10180  """Create a Z3 floating-point isZero expression.
10181  """
10182  return _mk_fp_unary_pred(Z3_mk_fpa_is_zero, a, ctx)
10183 
10184 
def fpIsZero(a, ctx=None)
Definition: z3py.py:10179

◆ fpLEQ()

def z3py.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 10226 of file z3py.py.

10226 def fpLEQ(a, b, ctx=None):
10227  """Create the Z3 floating-point expression `other <= self`.
10228 
10229  >>> x, y = FPs('x y', FPSort(8, 24))
10230  >>> fpLEQ(x, y)
10231  x <= y
10232  >>> (x <= y).sexpr()
10233  '(fp.leq x y)'
10234  """
10235  return _mk_fp_bin_pred(Z3_mk_fpa_leq, a, b, ctx)
10236 
10237 
def fpLEQ(a, b, ctx=None)
Definition: z3py.py:10226

Referenced by FPRef.__le__().

◆ fpLT()

def z3py.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 10214 of file z3py.py.

10214 def fpLT(a, b, ctx=None):
10215  """Create the Z3 floating-point expression `other < self`.
10216 
10217  >>> x, y = FPs('x y', FPSort(8, 24))
10218  >>> fpLT(x, y)
10219  x < y
10220  >>> (x < y).sexpr()
10221  '(fp.lt x y)'
10222  """
10223  return _mk_fp_bin_pred(Z3_mk_fpa_lt, a, b, ctx)
10224 
10225 
def fpLT(a, b, ctx=None)
Definition: z3py.py:10214

Referenced by FPRef.__lt__().

◆ fpMax()

def z3py.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 10123 of file z3py.py.

10123 def fpMax(a, b, ctx=None):
10124  """Create a Z3 floating-point maximum expression.
10125 
10126  >>> s = FPSort(8, 24)
10127  >>> rm = RNE()
10128  >>> x = FP('x', s)
10129  >>> y = FP('y', s)
10130  >>> fpMax(x, y)
10131  fpMax(x, y)
10132  >>> fpMax(x, y).sort()
10133  FPSort(8, 24)
10134  """
10135  return _mk_fp_bin_norm(Z3_mk_fpa_max, a, b, ctx)
10136 
10137 
def fpMax(a, b, ctx=None)
Definition: z3py.py:10123

◆ fpMin()

def z3py.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 10108 of file z3py.py.

10108 def fpMin(a, b, ctx=None):
10109  """Create a Z3 floating-point minimum expression.
10110 
10111  >>> s = FPSort(8, 24)
10112  >>> rm = RNE()
10113  >>> x = FP('x', s)
10114  >>> y = FP('y', s)
10115  >>> fpMin(x, y)
10116  fpMin(x, y)
10117  >>> fpMin(x, y).sort()
10118  FPSort(8, 24)
10119  """
10120  return _mk_fp_bin_norm(Z3_mk_fpa_min, a, b, ctx)
10121 
10122 
def fpMin(a, b, ctx=None)
Definition: z3py.py:10108

◆ fpMinusInfinity()

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

Definition at line 9820 of file z3py.py.

9820 def fpMinusInfinity(s):
9821  """Create a Z3 floating-point -oo term."""
9822  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
9823  return FPNumRef(Z3_mk_fpa_inf(s.ctx_ref(), s.ast, True), s.ctx)
9824 
9825 
def fpMinusInfinity(s)
Definition: z3py.py:9820

Referenced by FPVal().

◆ fpMinusZero()

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

Definition at line 9839 of file z3py.py.

9839 def fpMinusZero(s):
9840  """Create a Z3 floating-point -0.0 term."""
9841  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
9842  return FPNumRef(Z3_mk_fpa_zero(s.ctx_ref(), s.ast, True), s.ctx)
9843 
9844 
def fpMinusZero(s)
Definition: z3py.py:9839
Z3_ast Z3_API Z3_mk_fpa_zero(Z3_context c, Z3_sort s, bool negative)
Create a floating-point zero of sort s.

Referenced by FPVal().

◆ fpMul()

def z3py.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)
fpMul(RNE(), x, y)
>>> fpMul(rm, x, y).sort()
FPSort(8, 24)

Definition at line 10064 of file z3py.py.

10064 def fpMul(rm, a, b, ctx=None):
10065  """Create a Z3 floating-point multiplication expression.
10066 
10067  >>> s = FPSort(8, 24)
10068  >>> rm = RNE()
10069  >>> x = FP('x', s)
10070  >>> y = FP('y', s)
10071  >>> fpMul(rm, x, y)
10072  fpMul(RNE(), x, y)
10073  >>> fpMul(rm, x, y).sort()
10074  FPSort(8, 24)
10075  """
10076  return _mk_fp_bin(Z3_mk_fpa_mul, rm, a, b, ctx)
10077 
10078 
def fpMul(rm, a, b, ctx=None)
Definition: z3py.py:10064

Referenced by FPRef.__mul__(), and FPRef.__rmul__().

◆ fpNaN()

def z3py.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 9786 of file z3py.py.

9786 def fpNaN(s):
9787  """Create a Z3 floating-point NaN term.
9788 
9789  >>> s = FPSort(8, 24)
9790  >>> set_fpa_pretty(True)
9791  >>> fpNaN(s)
9792  NaN
9793  >>> pb = get_fpa_pretty()
9794  >>> set_fpa_pretty(False)
9795  >>> fpNaN(s)
9796  fpNaN(FPSort(8, 24))
9797  >>> set_fpa_pretty(pb)
9798  """
9799  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
9800  return FPNumRef(Z3_mk_fpa_nan(s.ctx_ref(), s.ast), s.ctx)
9801 
9802 
def fpNaN(s)
Definition: z3py.py:9786
Z3_ast Z3_API Z3_mk_fpa_nan(Z3_context c, Z3_sort s)
Create a floating-point NaN of sort s.

Referenced by FPVal().

◆ fpNeg()

def z3py.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 9964 of file z3py.py.

9964 def fpNeg(a, ctx=None):
9965  """Create a Z3 floating-point addition expression.
9966 
9967  >>> s = FPSort(8, 24)
9968  >>> rm = RNE()
9969  >>> x = FP('x', s)
9970  >>> fpNeg(x)
9971  -x
9972  >>> fpNeg(x).sort()
9973  FPSort(8, 24)
9974  """
9975  ctx = _get_ctx(ctx)
9976  [a] = _coerce_fp_expr_list([a], ctx)
9977  return FPRef(Z3_mk_fpa_neg(ctx.ref(), a.as_ast()), ctx)
9978 
9979 
def fpNeg(a, ctx=None)
Definition: z3py.py:9964
Z3_ast Z3_API Z3_mk_fpa_neg(Z3_context c, Z3_ast t)
Floating-point negation.

Referenced by FPRef.__neg__().

◆ fpNEQ()

def z3py.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 10274 of file z3py.py.

10274 def fpNEQ(a, b, ctx=None):
10275  """Create the Z3 floating-point expression `Not(fpEQ(other, self))`.
10276 
10277  >>> x, y = FPs('x y', FPSort(8, 24))
10278  >>> fpNEQ(x, y)
10279  Not(fpEQ(x, y))
10280  >>> (x != y).sexpr()
10281  '(distinct x y)'
10282  """
10283  return Not(fpEQ(a, b, ctx))
10284 
10285 
def Not(a, ctx=None)
Definition: z3py.py:1779
def fpNEQ(a, b, ctx=None)
Definition: z3py.py:10274

◆ fpPlusInfinity()

def z3py.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 9803 of file z3py.py.

9803 def fpPlusInfinity(s):
9804  """Create a Z3 floating-point +oo term.
9805 
9806  >>> s = FPSort(8, 24)
9807  >>> pb = get_fpa_pretty()
9808  >>> set_fpa_pretty(True)
9809  >>> fpPlusInfinity(s)
9810  +oo
9811  >>> set_fpa_pretty(False)
9812  >>> fpPlusInfinity(s)
9813  fpPlusInfinity(FPSort(8, 24))
9814  >>> set_fpa_pretty(pb)
9815  """
9816  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
9817  return FPNumRef(Z3_mk_fpa_inf(s.ctx_ref(), s.ast, False), s.ctx)
9818 
9819 
def fpPlusInfinity(s)
Definition: z3py.py:9803

Referenced by FPVal().

◆ fpPlusZero()

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

Definition at line 9833 of file z3py.py.

9833 def fpPlusZero(s):
9834  """Create a Z3 floating-point +0.0 term."""
9835  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
9836  return FPNumRef(Z3_mk_fpa_zero(s.ctx_ref(), s.ast, False), s.ctx)
9837 
9838 
def fpPlusZero(s)
Definition: z3py.py:9833

Referenced by FPVal().

◆ fpRealToFP()

def z3py.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 10391 of file z3py.py.

10391 def fpRealToFP(rm, v, sort, ctx=None):
10392  """Create a Z3 floating-point conversion expression that represents the
10393  conversion from a real term to a floating-point term.
10394 
10395  >>> x_r = RealVal(1.5)
10396  >>> x_fp = fpRealToFP(RNE(), x_r, Float32())
10397  >>> x_fp
10398  fpToFP(RNE(), 3/2)
10399  >>> simplify(x_fp)
10400  1.5
10401  """
10402  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression.")
10403  _z3_assert(is_real(v), "Second argument must be a Z3 expression or real sort.")
10404  _z3_assert(is_fp_sort(sort), "Third argument must be a Z3 floating-point sort.")
10405  ctx = _get_ctx(ctx)
10406  return FPRef(Z3_mk_fpa_to_fp_real(ctx.ref(), rm.ast, v.ast, sort.ast), ctx)
10407 
10408 
def fpRealToFP(rm, v, sort, ctx=None)
Definition: z3py.py:10391
def is_real(a)
Definition: z3py.py:2667
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()

def z3py.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 10094 of file z3py.py.

10094 def fpRem(a, b, ctx=None):
10095  """Create a Z3 floating-point remainder expression.
10096 
10097  >>> s = FPSort(8, 24)
10098  >>> x = FP('x', s)
10099  >>> y = FP('y', s)
10100  >>> fpRem(x, y)
10101  fpRem(x, y)
10102  >>> fpRem(x, y).sort()
10103  FPSort(8, 24)
10104  """
10105  return _mk_fp_bin_norm(Z3_mk_fpa_rem, a, b, ctx)
10106 
10107 
def fpRem(a, b, ctx=None)
Definition: z3py.py:10094

Referenced by FPRef.__mod__(), and FPRef.__rmod__().

◆ fpRoundToIntegral()

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

Definition at line 10150 of file z3py.py.

10150 def fpRoundToIntegral(rm, a, ctx=None):
10151  """Create a Z3 floating-point roundToIntegral expression.
10152  """
10153  return _mk_fp_unary(Z3_mk_fpa_round_to_integral, rm, a, ctx)
10154 
10155 
def fpRoundToIntegral(rm, a, ctx=None)
Definition: z3py.py:10150

◆ FPs()

def z3py.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)
fpMul(RNE(), fpAdd(RNE(), x, y), z)

Definition at line 9922 of file z3py.py.

9922 def FPs(names, fpsort, ctx=None):
9923  """Return an array of floating-point constants.
9924 
9925  >>> x, y, z = FPs('x y z', FPSort(8, 24))
9926  >>> x.sort()
9927  FPSort(8, 24)
9928  >>> x.sbits()
9929  24
9930  >>> x.ebits()
9931  8
9932  >>> fpMul(RNE(), fpAdd(RNE(), x, y), z)
9933  fpMul(RNE(), fpAdd(RNE(), x, y), z)
9934  """
9935  ctx = _get_ctx(ctx)
9936  if isinstance(names, str):
9937  names = names.split(" ")
9938  return [FP(name, fpsort, ctx) for name in names]
9939 
9940 
def FPs(names, fpsort, ctx=None)
Definition: z3py.py:9922

◆ fpSignedToFP()

def z3py.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 10409 of file z3py.py.

10409 def fpSignedToFP(rm, v, sort, ctx=None):
10410  """Create a Z3 floating-point conversion expression that represents the
10411  conversion from a signed bit-vector term (encoding an integer) to a floating-point term.
10412 
10413  >>> x_signed = BitVecVal(-5, BitVecSort(32))
10414  >>> x_fp = fpSignedToFP(RNE(), x_signed, Float32())
10415  >>> x_fp
10416  fpToFP(RNE(), 4294967291)
10417  >>> simplify(x_fp)
10418  -1.25*(2**2)
10419  """
10420  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression.")
10421  _z3_assert(is_bv(v), "Second argument must be a Z3 bit-vector expression")
10422  _z3_assert(is_fp_sort(sort), "Third argument must be a Z3 floating-point sort.")
10423  ctx = _get_ctx(ctx)
10424  return FPRef(Z3_mk_fpa_to_fp_signed(ctx.ref(), rm.ast, v.ast, sort.ast), ctx)
10425 
10426 
def fpSignedToFP(rm, v, sort, ctx=None)
Definition: z3py.py:10409
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()

def z3py.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 9727 of file z3py.py.

9727 def FPSort(ebits, sbits, ctx=None):
9728  """Return a Z3 floating-point sort of the given sizes. If `ctx=None`, then the global context is used.
9729 
9730  >>> Single = FPSort(8, 24)
9731  >>> Double = FPSort(11, 53)
9732  >>> Single
9733  FPSort(8, 24)
9734  >>> x = Const('x', Single)
9735  >>> eq(x, FP('x', FPSort(8, 24)))
9736  True
9737  """
9738  ctx = _get_ctx(ctx)
9739  return FPSortRef(Z3_mk_fpa_sort(ctx.ref(), ebits, sbits), ctx)
9740 
9741 
def FPSort(ebits, sbits, ctx=None)
Definition: z3py.py:9727
Z3_sort Z3_API Z3_mk_fpa_sort(Z3_context c, unsigned ebits, unsigned sbits)
Create a FloatingPoint sort.

Referenced by get_default_fp_sort().

◆ fpSqrt()

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

Definition at line 10144 of file z3py.py.

10144 def fpSqrt(rm, a, ctx=None):
10145  """Create a Z3 floating-point square root expression.
10146  """
10147  return _mk_fp_unary(Z3_mk_fpa_sqrt, rm, a, ctx)
10148 
10149 
def fpSqrt(rm, a, ctx=None)
Definition: z3py.py:10144

◆ fpSub()

def z3py.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)
fpSub(RNE(), x, y)
>>> fpSub(rm, x, y).sort()
FPSort(8, 24)

Definition at line 10049 of file z3py.py.

10049 def fpSub(rm, a, b, ctx=None):
10050  """Create a Z3 floating-point subtraction expression.
10051 
10052  >>> s = FPSort(8, 24)
10053  >>> rm = RNE()
10054  >>> x = FP('x', s)
10055  >>> y = FP('y', s)
10056  >>> fpSub(rm, x, y)
10057  fpSub(RNE(), x, y)
10058  >>> fpSub(rm, x, y).sort()
10059  FPSort(8, 24)
10060  """
10061  return _mk_fp_bin(Z3_mk_fpa_sub, rm, a, b, ctx)
10062 
10063 
def fpSub(rm, a, b, ctx=None)
Definition: z3py.py:10049

Referenced by FPRef.__rsub__(), and FPRef.__sub__().

◆ fpToFP()

def z3py.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 10315 of file z3py.py.

10315 def fpToFP(a1, a2=None, a3=None, ctx=None):
10316  """Create a Z3 floating-point conversion expression from other term sorts
10317  to floating-point.
10318 
10319  From a bit-vector term in IEEE 754-2008 format:
10320  >>> x = FPVal(1.0, Float32())
10321  >>> x_bv = fpToIEEEBV(x)
10322  >>> simplify(fpToFP(x_bv, Float32()))
10323  1
10324 
10325  From a floating-point term with different precision:
10326  >>> x = FPVal(1.0, Float32())
10327  >>> x_db = fpToFP(RNE(), x, Float64())
10328  >>> x_db.sort()
10329  FPSort(11, 53)
10330 
10331  From a real term:
10332  >>> x_r = RealVal(1.5)
10333  >>> simplify(fpToFP(RNE(), x_r, Float32()))
10334  1.5
10335 
10336  From a signed bit-vector term:
10337  >>> x_signed = BitVecVal(-5, BitVecSort(32))
10338  >>> simplify(fpToFP(RNE(), x_signed, Float32()))
10339  -1.25*(2**2)
10340  """
10341  ctx = _get_ctx(ctx)
10342  if is_bv(a1) and is_fp_sort(a2):
10343  return FPRef(Z3_mk_fpa_to_fp_bv(ctx.ref(), a1.ast, a2.ast), ctx)
10344  elif is_fprm(a1) and is_fp(a2) and is_fp_sort(a3):
10345  return FPRef(Z3_mk_fpa_to_fp_float(ctx.ref(), a1.ast, a2.ast, a3.ast), ctx)
10346  elif is_fprm(a1) and is_real(a2) and is_fp_sort(a3):
10347  return FPRef(Z3_mk_fpa_to_fp_real(ctx.ref(), a1.ast, a2.ast, a3.ast), ctx)
10348  elif is_fprm(a1) and is_bv(a2) and is_fp_sort(a3):
10349  return FPRef(Z3_mk_fpa_to_fp_signed(ctx.ref(), a1.ast, a2.ast, a3.ast), ctx)
10350  else:
10351  raise Z3Exception("Unsupported combination of arguments for conversion to floating-point term.")
10352 
10353 
def fpToFP(a1, a2=None, a3=None, ctx=None)
Definition: z3py.py:10315

◆ fpToFPUnsigned()

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

Definition at line 10445 of file z3py.py.

10445 def fpToFPUnsigned(rm, x, s, ctx=None):
10446  """Create a Z3 floating-point conversion expression, from unsigned bit-vector to floating-point expression."""
10447  if z3_debug():
10448  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
10449  _z3_assert(is_bv(x), "Second argument must be a Z3 bit-vector expression")
10450  _z3_assert(is_fp_sort(s), "Third argument must be Z3 floating-point sort")
10451  ctx = _get_ctx(ctx)
10452  return FPRef(Z3_mk_fpa_to_fp_unsigned(ctx.ref(), rm.ast, x.ast, s.ast), ctx)
10453 
10454 
def fpToFPUnsigned(rm, x, s, ctx=None)
Definition: z3py.py:10445
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()

def z3py.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 10519 of file z3py.py.

10519 def fpToIEEEBV(x, ctx=None):
10520  """\brief Conversion of a floating-point term into a bit-vector term in IEEE 754-2008 format.
10521 
10522  The size of the resulting bit-vector is automatically determined.
10523 
10524  Note that IEEE 754-2008 allows multiple different representations of NaN. This conversion
10525  knows only one NaN and it will always produce the same bit-vector representation of
10526  that NaN.
10527 
10528  >>> x = FP('x', FPSort(8, 24))
10529  >>> y = fpToIEEEBV(x)
10530  >>> print(is_fp(x))
10531  True
10532  >>> print(is_bv(y))
10533  True
10534  >>> print(is_fp(y))
10535  False
10536  >>> print(is_bv(x))
10537  False
10538  """
10539  if z3_debug():
10540  _z3_assert(is_fp(x), "First argument must be a Z3 floating-point expression")
10541  ctx = _get_ctx(ctx)
10542  return BitVecRef(Z3_mk_fpa_to_ieee_bv(ctx.ref(), x.ast), ctx)
10543 
10544 
def fpToIEEEBV(x, ctx=None)
Definition: z3py.py:10519
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()

def z3py.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 10499 of file z3py.py.

10499 def fpToReal(x, ctx=None):
10500  """Create a Z3 floating-point conversion expression, from floating-point expression to real.
10501 
10502  >>> x = FP('x', FPSort(8, 24))
10503  >>> y = fpToReal(x)
10504  >>> print(is_fp(x))
10505  True
10506  >>> print(is_real(y))
10507  True
10508  >>> print(is_fp(y))
10509  False
10510  >>> print(is_real(x))
10511  False
10512  """
10513  if z3_debug():
10514  _z3_assert(is_fp(x), "First argument must be a Z3 floating-point expression")
10515  ctx = _get_ctx(ctx)
10516  return ArithRef(Z3_mk_fpa_to_real(ctx.ref(), x.ast), ctx)
10517 
10518 
def fpToReal(x, ctx=None)
Definition: z3py.py:10499
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()

def z3py.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 10455 of file z3py.py.

10455 def fpToSBV(rm, x, s, ctx=None):
10456  """Create a Z3 floating-point conversion expression, from floating-point expression to signed bit-vector.
10457 
10458  >>> x = FP('x', FPSort(8, 24))
10459  >>> y = fpToSBV(RTZ(), x, BitVecSort(32))
10460  >>> print(is_fp(x))
10461  True
10462  >>> print(is_bv(y))
10463  True
10464  >>> print(is_fp(y))
10465  False
10466  >>> print(is_bv(x))
10467  False
10468  """
10469  if z3_debug():
10470  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
10471  _z3_assert(is_fp(x), "Second argument must be a Z3 floating-point expression")
10472  _z3_assert(is_bv_sort(s), "Third argument must be Z3 bit-vector sort")
10473  ctx = _get_ctx(ctx)
10474  return BitVecRef(Z3_mk_fpa_to_sbv(ctx.ref(), rm.ast, x.ast, s.size()), ctx)
10475 
10476 
def fpToSBV(rm, x, s, ctx=None)
Definition: z3py.py:10455
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()

def z3py.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 10477 of file z3py.py.

10477 def fpToUBV(rm, x, s, ctx=None):
10478  """Create a Z3 floating-point conversion expression, from floating-point expression to unsigned bit-vector.
10479 
10480  >>> x = FP('x', FPSort(8, 24))
10481  >>> y = fpToUBV(RTZ(), x, BitVecSort(32))
10482  >>> print(is_fp(x))
10483  True
10484  >>> print(is_bv(y))
10485  True
10486  >>> print(is_fp(y))
10487  False
10488  >>> print(is_bv(x))
10489  False
10490  """
10491  if z3_debug():
10492  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
10493  _z3_assert(is_fp(x), "Second argument must be a Z3 floating-point expression")
10494  _z3_assert(is_bv_sort(s), "Third argument must be Z3 bit-vector sort")
10495  ctx = _get_ctx(ctx)
10496  return BitVecRef(Z3_mk_fpa_to_ubv(ctx.ref(), rm.ast, x.ast, s.size()), ctx)
10497 
10498 
def fpToUBV(rm, x, s, ctx=None)
Definition: z3py.py:10477
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()

def z3py.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 10427 of file z3py.py.

10427 def fpUnsignedToFP(rm, v, sort, ctx=None):
10428  """Create a Z3 floating-point conversion expression that represents the
10429  conversion from an unsigned bit-vector term (encoding an integer) to a floating-point term.
10430 
10431  >>> x_signed = BitVecVal(-5, BitVecSort(32))
10432  >>> x_fp = fpUnsignedToFP(RNE(), x_signed, Float32())
10433  >>> x_fp
10434  fpToFPUnsigned(RNE(), 4294967291)
10435  >>> simplify(x_fp)
10436  1*(2**32)
10437  """
10438  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression.")
10439  _z3_assert(is_bv(v), "Second argument must be a Z3 bit-vector expression")
10440  _z3_assert(is_fp_sort(sort), "Third argument must be a Z3 floating-point sort.")
10441  ctx = _get_ctx(ctx)
10442  return FPRef(Z3_mk_fpa_to_fp_unsigned(ctx.ref(), rm.ast, v.ast, sort.ast), ctx)
10443 
10444 
def fpUnsignedToFP(rm, v, sort, ctx=None)
Definition: z3py.py:10427

◆ FPVal()

def z3py.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 9852 of file z3py.py.

9852 def FPVal(sig, exp=None, fps=None, ctx=None):
9853  """Return a floating-point value of value `val` and sort `fps`.
9854  If `ctx=None`, then the global context is used.
9855 
9856  >>> v = FPVal(20.0, FPSort(8, 24))
9857  >>> v
9858  1.25*(2**4)
9859  >>> print("0x%.8x" % v.exponent_as_long(False))
9860  0x00000004
9861  >>> v = FPVal(2.25, FPSort(8, 24))
9862  >>> v
9863  1.125*(2**1)
9864  >>> v = FPVal(-2.25, FPSort(8, 24))
9865  >>> v
9866  -1.125*(2**1)
9867  >>> FPVal(-0.0, FPSort(8, 24))
9868  -0.0
9869  >>> FPVal(0.0, FPSort(8, 24))
9870  +0.0
9871  >>> FPVal(+0.0, FPSort(8, 24))
9872  +0.0
9873  """
9874  ctx = _get_ctx(ctx)
9875  if is_fp_sort(exp):
9876  fps = exp
9877  exp = None
9878  elif fps is None:
9879  fps = _dflt_fps(ctx)
9880  _z3_assert(is_fp_sort(fps), "sort mismatch")
9881  if exp is None:
9882  exp = 0
9883  val = _to_float_str(sig)
9884  if val == "NaN" or val == "nan":
9885  return fpNaN(fps)
9886  elif val == "-0.0":
9887  return fpMinusZero(fps)
9888  elif val == "0.0" or val == "+0.0":
9889  return fpPlusZero(fps)
9890  elif val == "+oo" or val == "+inf" or val == "+Inf":
9891  return fpPlusInfinity(fps)
9892  elif val == "-oo" or val == "-inf" or val == "-Inf":
9893  return fpMinusInfinity(fps)
9894  else:
9895  return FPNumRef(Z3_mk_numeral(ctx.ref(), val, fps.ast), ctx)
9896 
9897 
def FPVal(sig, exp=None, fps=None, ctx=None)
Definition: z3py.py:9852

Referenced by set_default_fp_sort().

◆ fpZero()

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

Definition at line 9845 of file z3py.py.

9845 def fpZero(s, negative):
9846  """Create a Z3 floating-point +0.0 or -0.0 term."""
9847  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
9848  _z3_assert(isinstance(negative, bool), "expected Boolean flag")
9849  return FPNumRef(Z3_mk_fpa_zero(s.ctx_ref(), s.ast, negative), s.ctx)
9850 
9851 
def fpZero(s, negative)
Definition: z3py.py:9845

◆ FreshBool()

def z3py.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 1735 of file z3py.py.

1735 def FreshBool(prefix="b", ctx=None):
1736  """Return a fresh Boolean constant in the given context using the given prefix.
1737 
1738  If `ctx=None`, then the global context is used.
1739 
1740  >>> b1 = FreshBool()
1741  >>> b2 = FreshBool()
1742  >>> eq(b1, b2)
1743  False
1744  """
1745  ctx = _get_ctx(ctx)
1746  return BoolRef(Z3_mk_fresh_const(ctx.ref(), prefix, BoolSort(ctx).ast), ctx)
1747 
1748 
def FreshBool(prefix="b", ctx=None)
Definition: z3py.py:1735
Z3_ast Z3_API Z3_mk_fresh_const(Z3_context c, Z3_string prefix, Z3_sort ty)
Declare and create a fresh constant.

◆ FreshConst()

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

Definition at line 1432 of file z3py.py.

1432 def FreshConst(sort, prefix="c"):
1433  """Create a fresh constant of a specified sort"""
1434  ctx = _get_ctx(sort.ctx)
1435  return _to_expr_ref(Z3_mk_fresh_const(ctx.ref(), prefix, sort.ast), ctx)
1436 
1437 
def FreshConst(sort, prefix="c")
Definition: z3py.py:1432

◆ FreshFunction()

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

Definition at line 883 of file z3py.py.

883 def FreshFunction(*sig):
884  """Create a new fresh Z3 uninterpreted function with the given sorts.
885  """
886  sig = _get_args(sig)
887  if z3_debug():
888  _z3_assert(len(sig) > 0, "At least two arguments expected")
889  arity = len(sig) - 1
890  rng = sig[arity]
891  if z3_debug():
892  _z3_assert(is_sort(rng), "Z3 sort expected")
893  dom = (z3.Sort * arity)()
894  for i in range(arity):
895  if z3_debug():
896  _z3_assert(is_sort(sig[i]), "Z3 sort expected")
897  dom[i] = sig[i].ast
898  ctx = rng.ctx
899  return FuncDeclRef(Z3_mk_fresh_func_decl(ctx.ref(), "f", arity, dom, rng.ast), ctx)
900 
901 
def FreshFunction(*sig)
Definition: z3py.py:883
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()

def z3py.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 3249 of file z3py.py.

3249 def FreshInt(prefix="x", ctx=None):
3250  """Return a fresh integer constant in the given context using the given prefix.
3251 
3252  >>> x = FreshInt()
3253  >>> y = FreshInt()
3254  >>> eq(x, y)
3255  False
3256  >>> x.sort()
3257  Int
3258  """
3259  ctx = _get_ctx(ctx)
3260  return ArithRef(Z3_mk_fresh_const(ctx.ref(), prefix, IntSort(ctx).ast), ctx)
3261 
3262 
def IntSort(ctx=None)
Definition: z3py.py:3100
def FreshInt(prefix="x", ctx=None)
Definition: z3py.py:3249

◆ FreshReal()

def z3py.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 3306 of file z3py.py.

3306 def FreshReal(prefix="b", ctx=None):
3307  """Return a fresh real constant in the given context using the given prefix.
3308 
3309  >>> x = FreshReal()
3310  >>> y = FreshReal()
3311  >>> eq(x, y)
3312  False
3313  >>> x.sort()
3314  Real
3315  """
3316  ctx = _get_ctx(ctx)
3317  return ArithRef(Z3_mk_fresh_const(ctx.ref(), prefix, RealSort(ctx).ast), ctx)
3318 
3319 
def RealSort(ctx=None)
Definition: z3py.py:3117
def FreshReal(prefix="b", ctx=None)
Definition: z3py.py:3306

◆ Full()

def z3py.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 10740 of file z3py.py.

10740 def Full(s):
10741  """Create the regular expression that accepts the universal language
10742  >>> e = Full(ReSort(SeqSort(IntSort())))
10743  >>> print(e)
10744  Full(ReSort(Seq(Int)))
10745  >>> e1 = Full(ReSort(StringSort()))
10746  >>> print(e1)
10747  Full(ReSort(String))
10748  """
10749  if isinstance(s, ReSortRef):
10750  return ReRef(Z3_mk_re_full(s.ctx_ref(), s.ast), s.ctx)
10751  raise Z3Exception("Non-sequence, non-regular expression sort passed to Full")
10752 
10753 
def Full(s)
Definition: z3py.py:10740
Z3_ast Z3_API Z3_mk_re_full(Z3_context c, Z3_sort re)
Create an universal regular expression of sort re.

◆ FullSet()

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

Definition at line 4865 of file z3py.py.

4865 def FullSet(s):
4866  """Create the full set
4867  >>> FullSet(IntSort())
4868  K(Int, True)
4869  """
4870  ctx = s.ctx
4871  return ArrayRef(Z3_mk_full_set(ctx.ref(), s.ast), ctx)
4872 
4873 
def FullSet(s)
Definition: z3py.py:4865
Z3_ast Z3_API Z3_mk_full_set(Z3_context c, Z3_sort domain)
Create the full set.

◆ Function()

def z3py.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 860 of file z3py.py.

860 def Function(name, *sig):
861  """Create a new Z3 uninterpreted function with the given sorts.
862 
863  >>> f = Function('f', IntSort(), IntSort())
864  >>> f(f(0))
865  f(f(0))
866  """
867  sig = _get_args(sig)
868  if z3_debug():
869  _z3_assert(len(sig) > 0, "At least two arguments expected")
870  arity = len(sig) - 1
871  rng = sig[arity]
872  if z3_debug():
873  _z3_assert(is_sort(rng), "Z3 sort expected")
874  dom = (Sort * arity)()
875  for i in range(arity):
876  if z3_debug():
877  _z3_assert(is_sort(sig[i]), "Z3 sort expected")
878  dom[i] = sig[i].ast
879  ctx = rng.ctx
880  return FuncDeclRef(Z3_mk_func_decl(ctx.ref(), to_symbol(name, ctx), arity, dom, rng.ast), ctx)
881 
882 
def Function(name, *sig)
Definition: z3py.py:860
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()

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

Definition at line 6589 of file z3py.py.

6589 def get_as_array_func(n):
6590  """Return the function declaration f associated with a Z3 expression of the form (_ as-array f)."""
6591  if z3_debug():
6592  _z3_assert(is_as_array(n), "as-array Z3 expression expected.")
6593  return FuncDeclRef(Z3_get_as_array_func_decl(n.ctx.ref(), n.as_ast()), n.ctx)
6594 
def is_as_array(n)
Definition: z3py.py:6584
def get_as_array_func(n)
Definition: z3py.py:6589
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()

def z3py.get_ctx (   ctx)

Definition at line 266 of file z3py.py.

266 def get_ctx(ctx):
267  return _get_ctx(ctx)
268 
269 
def get_ctx(ctx)
Definition: z3py.py:266

◆ get_default_fp_sort()

def z3py.get_default_fp_sort (   ctx = None)

Definition at line 9149 of file z3py.py.

9149 def get_default_fp_sort(ctx=None):
9150  return FPSort(_dflt_fpsort_ebits, _dflt_fpsort_sbits, ctx)
9151 
9152 
def get_default_fp_sort(ctx=None)
Definition: z3py.py:9149

Referenced by set_default_fp_sort().

◆ get_default_rounding_mode()

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

Definition at line 9116 of file z3py.py.

9116 def get_default_rounding_mode(ctx=None):
9117  """Retrieves the global default rounding mode."""
9118  global _dflt_rounding_mode
9119  if _dflt_rounding_mode == Z3_OP_FPA_RM_TOWARD_ZERO:
9120  return RTZ(ctx)
9121  elif _dflt_rounding_mode == Z3_OP_FPA_RM_TOWARD_NEGATIVE:
9122  return RTN(ctx)
9123  elif _dflt_rounding_mode == Z3_OP_FPA_RM_TOWARD_POSITIVE:
9124  return RTP(ctx)
9125  elif _dflt_rounding_mode == Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN:
9126  return RNE(ctx)
9127  elif _dflt_rounding_mode == Z3_OP_FPA_RM_NEAREST_TIES_TO_AWAY:
9128  return RNA(ctx)
9129 
9130 
def RNE(ctx=None)
Definition: z3py.py:9497
def get_default_rounding_mode(ctx=None)
Definition: z3py.py:9116
def RTZ(ctx=None)
Definition: z3py.py:9537
def RTN(ctx=None)
Definition: z3py.py:9527
def RTP(ctx=None)
Definition: z3py.py:9517
def RNA(ctx=None)
Definition: z3py.py:9507

Referenced by set_default_fp_sort().

◆ get_full_version()

def z3py.get_full_version ( )

Definition at line 103 of file z3py.py.

103 def get_full_version():
104  return Z3_get_full_version()
105 
106 # We use _z3_assert instead of the assert command because we want to
107 # produce nice error messages in Z3Py at rise4fun.com
108 
109 
def get_full_version()
Definition: z3py.py:103
Z3_string Z3_API Z3_get_full_version(void)
Return a string that fully describes the version of Z3 in use.

◆ get_map_func()

def z3py.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 4621 of file z3py.py.

4621 def get_map_func(a):
4622  """Return the function declaration associated with a Z3 map array expression.
4623 
4624  >>> f = Function('f', IntSort(), IntSort())
4625  >>> b = Array('b', IntSort(), IntSort())
4626  >>> a = Map(f, b)
4627  >>> eq(f, get_map_func(a))
4628  True
4629  >>> get_map_func(a)
4630  f
4631  >>> get_map_func(a)(0)
4632  f(0)
4633  """
4634  if z3_debug():
4635  _z3_assert(is_map(a), "Z3 array map expression expected.")
4636  return FuncDeclRef(
4638  a.ctx_ref(),
4639  Z3_get_decl_ast_parameter(a.ctx_ref(), a.decl().ast, 0),
4640  ),
4641  ctx=a.ctx,
4642  )
4643 
4644 
def is_map(a)
Definition: z3py.py:4596
def get_map_func(a)
Definition: z3py.py:4621
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()

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

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

Definition at line 306 of file z3py.py.

306 def get_param(name):
307  """Return the value of a Z3 global (or module) parameter
308 
309  >>> get_param('nlsat.reorder')
310  'true'
311  """
312  ptr = (ctypes.c_char_p * 1)()
313  if Z3_global_param_get(str(name), ptr):
314  r = z3core._to_pystr(ptr[0])
315  return r
316  raise Z3Exception("failed to retrieve value for '%s'" % name)
317 
def get_param(name)
Definition: z3py.py:306
Z3_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()

def z3py.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 1303 of file z3py.py.

1303 def get_var_index(a):
1304  """Return the de-Bruijn index of the Z3 bounded variable `a`.
1305 
1306  >>> x = Int('x')
1307  >>> y = Int('y')
1308  >>> is_var(x)
1309  False
1310  >>> is_const(x)
1311  True
1312  >>> f = Function('f', IntSort(), IntSort(), IntSort())
1313  >>> # Z3 replaces x and y with bound variables when ForAll is executed.
1314  >>> q = ForAll([x, y], f(x, y) == x + y)
1315  >>> q.body()
1316  f(Var(1), Var(0)) == Var(1) + Var(0)
1317  >>> b = q.body()
1318  >>> b.arg(0)
1319  f(Var(1), Var(0))
1320  >>> v1 = b.arg(0).arg(0)
1321  >>> v2 = b.arg(0).arg(1)
1322  >>> v1
1323  Var(1)
1324  >>> v2
1325  Var(0)
1326  >>> get_var_index(v1)
1327  1
1328  >>> get_var_index(v2)
1329  0
1330  """
1331  if z3_debug():
1332  _z3_assert(is_var(a), "Z3 bound variable expected")
1333  return int(Z3_get_index_value(a.ctx.ref(), a.as_ast()))
1334 
1335 
def is_var(a)
Definition: z3py.py:1278
def get_var_index(a)
Definition: z3py.py:1303
unsigned Z3_API Z3_get_index_value(Z3_context c, Z3_ast a)
Return index of de-Bruijn bound variable.

◆ get_version()

def z3py.get_version ( )

Definition at line 94 of file z3py.py.

94 def get_version():
95  major = ctypes.c_uint(0)
96  minor = ctypes.c_uint(0)
97  build = ctypes.c_uint(0)
98  rev = ctypes.c_uint(0)
99  Z3_get_version(major, minor, build, rev)
100  return (major.value, minor.value, build.value, rev.value)
101 
102 
def get_version()
Definition: z3py.py:94
void Z3_API Z3_get_version(unsigned *major, unsigned *minor, unsigned *build_number, unsigned *revision_number)
Return Z3 version number information.

◆ get_version_string()

def z3py.get_version_string ( )

Definition at line 85 of file z3py.py.

85 def get_version_string():
86  major = ctypes.c_uint(0)
87  minor = ctypes.c_uint(0)
88  build = ctypes.c_uint(0)
89  rev = ctypes.c_uint(0)
90  Z3_get_version(major, minor, build, rev)
91  return "%s.%s.%s" % (major.value, minor.value, build.value)
92 
93 
def get_version_string()
Definition: z3py.py:85

◆ help_simplify()

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

Definition at line 8670 of file z3py.py.

8670 def help_simplify():
8671  """Return a string describing all options available for Z3 `simplify` procedure."""
8672  print(Z3_simplify_get_help(main_ctx().ref()))
8673 
8674 
def help_simplify()
Definition: z3py.py:8670
def main_ctx()
Definition: z3py.py:238
Z3_string Z3_API Z3_simplify_get_help(Z3_context c)
Return a string describing all available parameters.

◆ If()

def z3py.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 1349 of file z3py.py.

1349 def If(a, b, c, ctx=None):
1350  """Create a Z3 if-then-else expression.
1351 
1352  >>> x = Int('x')
1353  >>> y = Int('y')
1354  >>> max = If(x > y, x, y)
1355  >>> max
1356  If(x > y, x, y)
1357  >>> simplify(max)
1358  If(x <= y, y, x)
1359  """
1360  if isinstance(a, Probe) or isinstance(b, Tactic) or isinstance(c, Tactic):
1361  return Cond(a, b, c, ctx)
1362  else:
1363  ctx = _get_ctx(_ctx_from_ast_arg_list([a, b, c], ctx))
1364  s = BoolSort(ctx)
1365  a = s.cast(a)
1366  b, c = _coerce_exprs(b, c, ctx)
1367  if z3_debug():
1368  _z3_assert(a.ctx == b.ctx, "Context mismatch")
1369  return _to_expr_ref(Z3_mk_ite(ctx.ref(), a.as_ast(), b.as_ast(), c.as_ast()), ctx)
1370 
1371 
def If(a, b, c, ctx=None)
Definition: z3py.py:1349
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.__mul__(), and ArithRef.__mul__().

◆ Implies()

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

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

Definition at line 1749 of file z3py.py.

1749 def Implies(a, b, ctx=None):
1750  """Create a Z3 implies expression.
1751 
1752  >>> p, q = Bools('p q')
1753  >>> Implies(p, q)
1754  Implies(p, q)
1755  """
1756  ctx = _get_ctx(_ctx_from_ast_arg_list([a, b], ctx))
1757  s = BoolSort(ctx)
1758  a = s.cast(a)
1759  b = s.cast(b)
1760  return BoolRef(Z3_mk_implies(ctx.ref(), a.as_ast(), b.as_ast()), ctx)
1761 
1762 
def Implies(a, b, ctx=None)
Definition: z3py.py:1749
Z3_ast Z3_API Z3_mk_implies(Z3_context c, Z3_ast t1, Z3_ast t2)
Create an AST node representing t1 implies t2.

Referenced by Fixedpoint.add_rule(), and Fixedpoint.update_rule().

◆ IndexOf()

def z3py.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 10823 of file z3py.py.

10823 def IndexOf(s, substr, offset=None):
10824  """Retrieve the index of substring within a string starting at a specified offset.
10825  >>> simplify(IndexOf("abcabc", "bc", 0))
10826  1
10827  >>> simplify(IndexOf("abcabc", "bc", 2))
10828  4
10829  """
10830  if offset is None:
10831  offset = IntVal(0)
10832  ctx = None
10833  if is_expr(offset):
10834  ctx = offset.ctx
10835  ctx = _get_ctx2(s, substr, ctx)
10836  s = _coerce_seq(s, ctx)
10837  substr = _coerce_seq(substr, ctx)
10838  if _is_int(offset):
10839  offset = IntVal(offset, ctx)
10840  return ArithRef(Z3_mk_seq_index(s.ctx_ref(), s.as_ast(), substr.as_ast(), offset.as_ast()), s.ctx)
10841 
10842 
def IndexOf(s, substr, offset=None)
Definition: z3py.py:10823
def IntVal(val, ctx=None)
Definition: z3py.py:3150
Z3_ast Z3_API Z3_mk_seq_index(Z3_context c, Z3_ast s, Z3_ast substr, Z3_ast offset)
Return index of first occurrence of substr in s starting from offset offset. If s does not contain su...

◆ InRe()

def z3py.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 10924 of file z3py.py.

10924 def InRe(s, re):
10925  """Create regular expression membership test
10926  >>> re = Union(Re("a"),Re("b"))
10927  >>> print (simplify(InRe("a", re)))
10928  True
10929  >>> print (simplify(InRe("b", re)))
10930  True
10931  >>> print (simplify(InRe("c", re)))
10932  False
10933  """
10934  s = _coerce_seq(s, re.ctx)
10935  return BoolRef(Z3_mk_seq_in_re(s.ctx_ref(), s.as_ast(), re.as_ast()), s.ctx)
10936 
10937 
def InRe(s, re)
Definition: z3py.py:10924
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()

def z3py.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 3210 of file z3py.py.

3210 def Int(name, ctx=None):
3211  """Return an integer constant named `name`. If `ctx=None`, then the global context is used.
3212 
3213  >>> x = Int('x')
3214  >>> is_int(x)
3215  True
3216  >>> is_int(x + 1)
3217  True
3218  """
3219  ctx = _get_ctx(ctx)
3220  return ArithRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), IntSort(ctx).ast), ctx)
3221 
3222 
def Int(name, ctx=None)
Definition: z3py.py:3210

Referenced by Ints(), and IntVector().

◆ Int2BV()

def z3py.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 3958 of file z3py.py.

3958 def Int2BV(a, num_bits):
3959  """Return the z3 expression Int2BV(a, num_bits).
3960  It is a bit-vector of width num_bits and represents the
3961  modulo of a by 2^num_bits
3962  """
3963  ctx = a.ctx
3964  return BitVecRef(Z3_mk_int2bv(ctx.ref(), num_bits, a.as_ast()), ctx)
3965 
3966 
def Int2BV(a, num_bits)
Definition: z3py.py:3958
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()

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

Definition at line 10958 of file z3py.py.

10958 def Intersect(*args):
10959  """Create intersection of regular expressions.
10960  >>> re = Intersect(Re("a"), Re("b"), Re("c"))
10961  """
10962  args = _get_args(args)
10963  sz = len(args)
10964  if z3_debug():
10965  _z3_assert(sz > 0, "At least one argument expected.")
10966  _z3_assert(all([is_re(a) for a in args]), "All arguments must be regular expressions.")
10967  if sz == 1:
10968  return args[0]
10969  ctx = args[0].ctx
10970  v = (Ast * sz)()
10971  for i in range(sz):
10972  v[i] = args[i].as_ast()
10973  return ReRef(Z3_mk_re_intersect(ctx.ref(), sz, v), ctx)
10974 
10975 
def Intersect(*args)
Definition: z3py.py:10958
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()

def z3py.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 3223 of file z3py.py.

3223 def Ints(names, ctx=None):
3224  """Return a tuple of Integer constants.
3225 
3226  >>> x, y, z = Ints('x y z')
3227  >>> Sum(x, y, z)
3228  x + y + z
3229  """
3230  ctx = _get_ctx(ctx)
3231  if isinstance(names, str):
3232  names = names.split(" ")
3233  return [Int(name, ctx) for name in names]
3234 
3235 
def Ints(names, ctx=None)
Definition: z3py.py:3223

◆ IntSort()

def z3py.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 3100 of file z3py.py.

3100 def IntSort(ctx=None):
3101  """Return the integer sort in the given context. If `ctx=None`, then the global context is used.
3102 
3103  >>> IntSort()
3104  Int
3105  >>> x = Const('x', IntSort())
3106  >>> is_int(x)
3107  True
3108  >>> x.sort() == IntSort()
3109  True
3110  >>> x.sort() == BoolSort()
3111  False
3112  """
3113  ctx = _get_ctx(ctx)
3114  return ArithSortRef(Z3_mk_int_sort(ctx.ref()), ctx)
3115 
3116 
Z3_sort Z3_API Z3_mk_int_sort(Z3_context c)
Create the integer type.

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

◆ IntToStr()

def z3py.IntToStr (   s)
Convert integer expression to string

Definition at line 10878 of file z3py.py.

10878 def IntToStr(s):
10879  """Convert integer expression to string"""
10880  if not is_expr(s):
10881  s = _py2expr(s)
10882  return SeqRef(Z3_mk_int_to_str(s.ctx_ref(), s.as_ast()), s.ctx)
10883 
10884 
def IntToStr(s)
Definition: z3py.py:10878
Z3_ast Z3_API Z3_mk_int_to_str(Z3_context c, Z3_ast s)
Integer to string conversion.

◆ IntVal()

def z3py.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 3150 of file z3py.py.

3150 def IntVal(val, ctx=None):
3151  """Return a Z3 integer value. If `ctx=None`, then the global context is used.
3152 
3153  >>> IntVal(1)
3154  1
3155  >>> IntVal("100")
3156  100
3157  """
3158  ctx = _get_ctx(ctx)
3159  return IntNumRef(Z3_mk_numeral(ctx.ref(), _to_int_str(val), IntSort(ctx).ast), ctx)
3160 
3161 

Referenced by SeqRef.__getitem__(), SeqRef.at(), AlgebraicNumRef.index(), and IndexOf().

◆ IntVector()

def z3py.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 3236 of file z3py.py.

3236 def IntVector(prefix, sz, ctx=None):
3237  """Return a list of integer constants of size `sz`.
3238 
3239  >>> X = IntVector('x', 3)
3240  >>> X
3241  [x__0, x__1, x__2]
3242  >>> Sum(X)
3243  x__0 + x__1 + x__2
3244  """
3245  ctx = _get_ctx(ctx)
3246  return [Int("%s__%s" % (prefix, i), ctx) for i in range(sz)]
3247 
3248 
def IntVector(prefix, sz, ctx=None)
Definition: z3py.py:3236

◆ is_add()

def z3py.is_add (   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 2754 of file z3py.py.

2754 def is_add(a):
2755  """Return `True` if `a` is an expression of the form b + c.
2756 
2757  >>> x, y = Ints('x y')
2758  >>> is_add(x + y)
2759  True
2760  >>> is_add(x - y)
2761  False
2762  """
2763  return is_app_of(a, Z3_OP_ADD)
2764 
2765 
def is_add(a)
Definition: z3py.py:2754
def is_app_of(a, k)
Definition: z3py.py:1336

◆ is_algebraic_value()

def z3py.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 2740 of file z3py.py.

2740 def is_algebraic_value(a):
2741  """Return `True` if `a` is an algebraic value of sort Real.
2742 
2743  >>> is_algebraic_value(RealVal("3/5"))
2744  False
2745  >>> n = simplify(Sqrt(2))
2746  >>> n
2747  1.4142135623?
2748  >>> is_algebraic_value(n)
2749  True
2750  """
2751  return is_arith(a) and a.is_real() and _is_algebraic(a.ctx, a.as_ast())
2752 
2753 
def is_algebraic_value(a)
Definition: z3py.py:2740
def is_arith(a)
Definition: z3py.py:2627

◆ is_and()

def z3py.is_and (   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 1585 of file z3py.py.

1585 def is_and(a):
1586  """Return `True` if `a` is a Z3 and expression.
1587 
1588  >>> p, q = Bools('p q')
1589  >>> is_and(And(p, q))
1590  True
1591  >>> is_and(Or(p, q))
1592  False
1593  """
1594  return is_app_of(a, Z3_OP_AND)
1595 
1596 
def is_and(a)
Definition: z3py.py:1585

◆ is_app()

def z3py.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 1233 of file z3py.py.

1233 def is_app(a):
1234  """Return `True` if `a` is a Z3 function application.
1235 
1236  Note that, constants are function applications with 0 arguments.
1237 
1238  >>> a = Int('a')
1239  >>> is_app(a)
1240  True
1241  >>> is_app(a + 1)
1242  True
1243  >>> is_app(IntSort())
1244  False
1245  >>> is_app(1)
1246  False
1247  >>> is_app(IntVal(1))
1248  True
1249  >>> x = Int('x')
1250  >>> is_app(ForAll(x, x >= 0))
1251  False
1252  """
1253  if not isinstance(a, ExprRef):
1254  return False
1255  k = _ast_kind(a.ctx, a)
1256  return k == Z3_NUMERAL_AST or k == Z3_APP_AST
1257 
1258 
def is_app(a)
Definition: z3py.py:1233

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

◆ is_app_of()

def z3py.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 1336 of file z3py.py.

1336 def is_app_of(a, k):
1337  """Return `True` if `a` is an application of the given kind `k`.
1338 
1339  >>> x = Int('x')
1340  >>> n = x + 1
1341  >>> is_app_of(n, Z3_OP_ADD)
1342  True
1343  >>> is_app_of(n, Z3_OP_MUL)
1344  False
1345  """
1346  return is_app(a) and a.decl().kind() == k
1347 
1348 

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

def z3py.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 2627 of file z3py.py.

2627 def is_arith(a):
2628  """Return `True` if `a` is an arithmetical expression.
2629 
2630  >>> x = Int('x')
2631  >>> is_arith(x)
2632  True
2633  >>> is_arith(x + 1)
2634  True
2635  >>> is_arith(1)
2636  False
2637  >>> is_arith(IntVal(1))
2638  True
2639  >>> y = Real('y')
2640  >>> is_arith(y)
2641  True
2642  >>> is_arith(y + 1)
2643  True
2644  """
2645  return isinstance(a, ArithRef)
2646 
2647 

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

◆ is_arith_sort()

def z3py.is_arith_sort (   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 2326 of file z3py.py.

2326 def is_arith_sort(s):
2327  """Return `True` if s is an arithmetical sort (type).
2328 
2329  >>> is_arith_sort(IntSort())
2330  True
2331  >>> is_arith_sort(RealSort())
2332  True
2333  >>> is_arith_sort(BoolSort())
2334  False
2335  >>> n = Int('x') + 1
2336  >>> is_arith_sort(n.sort())
2337  True
2338  """
2339  return isinstance(s, ArithSortRef)
2340 
2341 
def is_arith_sort(s)
Definition: z3py.py:2326

Referenced by ArithSortRef.subsort().

◆ is_array()

def z3py.is_array (   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 4556 of file z3py.py.

4556 def is_array(a):
4557  """Return `True` if `a` is a Z3 array expression.
4558 
4559  >>> a = Array('a', IntSort(), IntSort())
4560  >>> is_array(a)
4561  True
4562  >>> is_array(Store(a, 0, 1))
4563  True
4564  >>> is_array(a[0])
4565  False
4566  """
4567  return isinstance(a, ArrayRef)
4568 
4569 

Referenced by Ext(), and Map().

◆ is_array_sort()

def z3py.is_array_sort (   a)

Definition at line 4552 of file z3py.py.

4552 def is_array_sort(a):
4553  return Z3_get_sort_kind(a.ctx.ref(), Z3_get_sort(a.ctx.ref(), a.ast)) == Z3_ARRAY_SORT
4554 
4555 
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).
Z3_sort Z3_API Z3_get_sort(Z3_context c, Z3_ast a)
Return the sort of an AST node.

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

◆ is_as_array()

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

Definition at line 6584 of file z3py.py.

6584 def is_as_array(n):
6585  """Return true if n is a Z3 expression of the form (_ as-array f)."""
6586  return isinstance(n, ExprRef) and Z3_is_as_array(n.ctx.ref(), n.as_ast())
6587 
6588 
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()

def z3py.is_ast (   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 450 of file z3py.py.

450 def is_ast(a):
451  """Return `True` if `a` is an AST node.
452 
453  >>> is_ast(10)
454  False
455  >>> is_ast(IntVal(10))
456  True
457  >>> is_ast(Int('x'))
458  True
459  >>> is_ast(BoolSort())
460  True
461  >>> is_ast(Function('f', IntSort(), IntSort()))
462  True
463  >>> is_ast("x")
464  False
465  >>> is_ast(Solver())
466  False
467  """
468  return isinstance(a, AstRef)
469 
470 

Referenced by eq(), AstRef.eq(), and ReSort().

◆ is_bool()

def z3py.is_bool (   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 1535 of file z3py.py.

1535 def is_bool(a):
1536  """Return `True` if `a` is a Z3 Boolean expression.
1537 
1538  >>> p = Bool('p')
1539  >>> is_bool(p)
1540  True
1541  >>> q = Bool('q')
1542  >>> is_bool(And(p, q))
1543  True
1544  >>> x = Real('x')
1545  >>> is_bool(x)
1546  False
1547  >>> is_bool(x == 0)
1548  True
1549  """
1550  return isinstance(a, BoolRef)
1551 
1552 
def is_bool(a)
Definition: z3py.py:1535

Referenced by is_quantifier(), and prove().

◆ is_bv()

def z3py.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 3906 of file z3py.py.

3906 def is_bv(a):
3907  """Return `True` if `a` is a Z3 bit-vector expression.
3908 
3909  >>> b = BitVec('b', 32)
3910  >>> is_bv(b)
3911  True
3912  >>> is_bv(b + 10)
3913  True
3914  >>> is_bv(Int('x'))
3915  False
3916  """
3917  return isinstance(a, BitVecRef)
3918 
3919 

Referenced by BV2Int(), BVRedAnd(), BVRedOr(), BVSNegNoOverflow(), Concat(), Extract(), fpBVToFP(), fpFP(), fpSignedToFP(), fpToFP(), fpToFPUnsigned(), fpUnsignedToFP(), is_bv_value(), Product(), RepeatBitVec(), SignExt(), Sum(), and ZeroExt().

◆ is_bv_sort()

def z3py.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 3438 of file z3py.py.

3438 def is_bv_sort(s):
3439  """Return True if `s` is a Z3 bit-vector sort.
3440 
3441  >>> is_bv_sort(BitVecSort(32))
3442  True
3443  >>> is_bv_sort(IntSort())
3444  False
3445  """
3446  return isinstance(s, BitVecSortRef)
3447 
3448 

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

◆ is_bv_value()

def z3py.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 3920 of file z3py.py.

3920 def is_bv_value(a):
3921  """Return `True` if `a` is a Z3 bit-vector numeral value.
3922 
3923  >>> b = BitVec('b', 32)
3924  >>> is_bv_value(b)
3925  False
3926  >>> b = BitVecVal(10, 32)
3927  >>> b
3928  10
3929  >>> is_bv_value(b)
3930  True
3931  """
3932  return is_bv(a) and _is_numeral(a.ctx, a.as_ast())
3933 
3934 
def is_bv_value(a)
Definition: z3py.py:3920

◆ is_const()

def z3py.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 1259 of file z3py.py.

1259 def is_const(a):
1260  """Return `True` if `a` is Z3 constant/variable expression.
1261 
1262  >>> a = Int('a')
1263  >>> is_const(a)
1264  True
1265  >>> is_const(a + 1)
1266  False
1267  >>> is_const(1)
1268  False
1269  >>> is_const(IntVal(1))
1270  True
1271  >>> x = Int('x')
1272  >>> is_const(ForAll(x, x >= 0))
1273  False
1274  """
1275  return is_app(a) and a.num_args() == 0
1276 
1277 
def is_const(a)
Definition: z3py.py:1259

Referenced by ModelRef.__getitem__(), Solver.assert_and_track(), Optimize.assert_and_track(), ModelRef.get_interp(), is_quantifier(), and prove().

◆ is_const_array()

def z3py.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 4570 of file z3py.py.

4570 def is_const_array(a):
4571  """Return `True` if `a` is a Z3 constant array.
4572 
4573  >>> a = K(IntSort(), 10)
4574  >>> is_const_array(a)
4575  True
4576  >>> a = Array('a', IntSort(), IntSort())
4577  >>> is_const_array(a)
4578  False
4579  """
4580  return is_app_of(a, Z3_OP_CONST_ARRAY)
4581 
4582 
def is_const_array(a)
Definition: z3py.py:4570

◆ is_default()

def z3py.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 4612 of file z3py.py.

4612 def is_default(a):
4613  """Return `True` if `a` is a Z3 default array expression.
4614  >>> d = Default(K(IntSort(), 10))
4615  >>> is_default(d)
4616  True
4617  """
4618  return is_app_of(a, Z3_OP_ARRAY_DEFAULT)
4619 
4620 
def is_default(a)
Definition: z3py.py:4612

◆ is_distinct()

def z3py.is_distinct (   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 1643 of file z3py.py.

1643 def is_distinct(a):
1644  """Return `True` if `a` is a Z3 distinct expression.
1645 
1646  >>> x, y, z = Ints('x y z')
1647  >>> is_distinct(x == y)
1648  False
1649  >>> is_distinct(Distinct(x, y, z))
1650  True
1651  """
1652  return is_app_of(a, Z3_OP_DISTINCT)
1653 
1654 
def is_distinct(a)
Definition: z3py.py:1643

◆ is_div()

def z3py.is_div (   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 2790 of file z3py.py.

2790 def is_div(a):
2791  """Return `True` if `a` is an expression of the form b / c.
2792 
2793  >>> x, y = Reals('x y')
2794  >>> is_div(x / y)
2795  True
2796  >>> is_div(x + y)
2797  False
2798  >>> x, y = Ints('x y')
2799  >>> is_div(x / y)
2800  False
2801  >>> is_idiv(x / y)
2802  True
2803  """
2804  return is_app_of(a, Z3_OP_DIV)
2805 
2806 
def is_div(a)
Definition: z3py.py:2790

◆ is_eq()

def z3py.is_eq (   a)
Return `True` if `a` is a Z3 equality expression.

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

Definition at line 1633 of file z3py.py.

1633 def is_eq(a):
1634  """Return `True` if `a` is a Z3 equality expression.
1635 
1636  >>> x, y = Ints('x y')
1637  >>> is_eq(x == y)
1638  True
1639  """
1640  return is_app_of(a, Z3_OP_EQ)
1641 
1642 
def is_eq(a)
Definition: z3py.py:1633

Referenced by AstRef.__bool__().

◆ is_expr()

def z3py.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 1210 of file z3py.py.

1210 def is_expr(a):
1211  """Return `True` if `a` is a Z3 expression.
1212 
1213  >>> a = Int('a')
1214  >>> is_expr(a)
1215  True
1216  >>> is_expr(a + 1)
1217  True
1218  >>> is_expr(IntSort())
1219  False
1220  >>> is_expr(1)
1221  False
1222  >>> is_expr(IntVal(1))
1223  True
1224  >>> x = Int('x')
1225  >>> is_expr(ForAll(x, x >= 0))
1226  True
1227  >>> is_expr(FPVal(1.0))
1228  True
1229  """
1230  return isinstance(a, ExprRef)
1231 
1232 

Referenced by SeqRef.__gt__(), SortRef.cast(), BoolSortRef.cast(), ArithSortRef.cast(), BitVecSortRef.cast(), FPSortRef.cast(), Cbrt(), ExprRef.children(), Concat(), AlgebraicNumRef.index(), IndexOf(), IntToStr(), is_quantifier(), is_var(), K(), MultiPattern(), Replace(), simplify(), Sqrt(), substitute(), and substitute_vars().

◆ is_false()

def z3py.is_false (   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 1571 of file z3py.py.

1571 def is_false(a):
1572  """Return `True` if `a` is the Z3 false expression.
1573 
1574  >>> p = Bool('p')
1575  >>> is_false(p)
1576  False
1577  >>> is_false(False)
1578  False
1579  >>> is_false(BoolVal(False))
1580  True
1581  """
1582  return is_app_of(a, Z3_OP_FALSE)
1583 
1584 
def is_false(a)
Definition: z3py.py:1571

Referenced by AstRef.__bool__().

◆ is_finite_domain()

def z3py.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 7621 of file z3py.py.

7621 def is_finite_domain(a):
7622  """Return `True` if `a` is a Z3 finite-domain expression.
7623 
7624  >>> s = FiniteDomainSort('S', 100)
7625  >>> b = Const('b', s)
7626  >>> is_finite_domain(b)
7627  True
7628  >>> is_finite_domain(Int('x'))
7629  False
7630  """
7631  return isinstance(a, FiniteDomainRef)
7632 
7633 
def is_finite_domain(a)
Definition: z3py.py:7621

Referenced by is_finite_domain_value().

◆ is_finite_domain_sort()

def z3py.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 7598 of file z3py.py.

7598 def is_finite_domain_sort(s):
7599  """Return True if `s` is a Z3 finite-domain sort.
7600 
7601  >>> is_finite_domain_sort(FiniteDomainSort('S', 100))
7602  True
7603  >>> is_finite_domain_sort(IntSort())
7604  False
7605  """
7606  return isinstance(s, FiniteDomainSortRef)
7607 
7608 

Referenced by FiniteDomainVal().

◆ is_finite_domain_value()

def z3py.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 7675 of file z3py.py.

7675 def is_finite_domain_value(a):
7676  """Return `True` if `a` is a Z3 finite-domain value.
7677 
7678  >>> s = FiniteDomainSort('S', 100)
7679  >>> b = Const('b', s)
7680  >>> is_finite_domain_value(b)
7681  False
7682  >>> b = FiniteDomainVal(10, s)
7683  >>> b
7684  10
7685  >>> is_finite_domain_value(b)
7686  True
7687  """
7688  return is_finite_domain(a) and _is_numeral(a.ctx, a.as_ast())
7689 
7690 
def is_finite_domain_value(a)
Definition: z3py.py:7675

◆ is_fp()

def z3py.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 9698 of file z3py.py.

9698 def is_fp(a):
9699  """Return `True` if `a` is a Z3 floating-point expression.
9700 
9701  >>> b = FP('b', FPSort(8, 24))
9702  >>> is_fp(b)
9703  True
9704  >>> is_fp(b + 1.0)
9705  True
9706  >>> is_fp(Int('x'))
9707  False
9708  """
9709  return isinstance(a, FPRef)
9710 
9711 

Referenced by fpFPToFP(), fpIsPositive(), fpNeg(), fpToFP(), fpToIEEEBV(), fpToReal(), fpToSBV(), fpToUBV(), is_fp_value(), and set_default_fp_sort().

◆ is_fp_sort()

def z3py.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 9282 of file z3py.py.

9282 def is_fp_sort(s):
9283  """Return True if `s` is a Z3 floating-point sort.
9284 
9285  >>> is_fp_sort(FPSort(8, 24))
9286  True
9287  >>> is_fp_sort(IntSort())
9288  False
9289  """
9290  return isinstance(s, FPSortRef)
9291 
9292 

Referenced by fpBVToFP(), fpFPToFP(), fpRealToFP(), fpSignedToFP(), fpToFP(), fpToFPUnsigned(), fpUnsignedToFP(), and FPVal().

◆ is_fp_value()

def z3py.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 9712 of file z3py.py.

9712 def is_fp_value(a):
9713  """Return `True` if `a` is a Z3 floating-point numeral value.
9714 
9715  >>> b = FP('b', FPSort(8, 24))
9716  >>> is_fp_value(b)
9717  False
9718  >>> b = FPVal(1.0, FPSort(8, 24))
9719  >>> b
9720  1
9721  >>> is_fp_value(b)
9722  True
9723  """
9724  return is_fp(a) and _is_numeral(a.ctx, a.ast)
9725 
9726 
def is_fp_value(a)
Definition: z3py.py:9712

◆ is_fprm()

def z3py.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 9542 of file z3py.py.

9542 def is_fprm(a):
9543  """Return `True` if `a` is a Z3 floating-point rounding mode expression.
9544 
9545  >>> rm = RNE()
9546  >>> is_fprm(rm)
9547  True
9548  >>> rm = 1.0
9549  >>> is_fprm(rm)
9550  False
9551  """
9552  return isinstance(a, FPRMRef)
9553 
9554 

Referenced by fpFPToFP(), fpNeg(), fpRealToFP(), fpSignedToFP(), fpToFP(), fpToFPUnsigned(), fpToSBV(), fpToUBV(), fpUnsignedToFP(), and is_fprm_value().

◆ is_fprm_sort()

def z3py.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 9293 of file z3py.py.

9293 def is_fprm_sort(s):
9294  """Return True if `s` is a Z3 floating-point rounding mode sort.
9295 
9296  >>> is_fprm_sort(FPSort(8, 24))
9297  False
9298  >>> is_fprm_sort(RNE().sort())
9299  True
9300  """
9301  return isinstance(s, FPRMSortRef)
9302 
9303 # FP Expressions
9304 
9305 
def is_fprm_sort(s)
Definition: z3py.py:9293

◆ is_fprm_value()

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

Definition at line 9555 of file z3py.py.

9555 def is_fprm_value(a):
9556  """Return `True` if `a` is a Z3 floating-point rounding mode numeral value."""
9557  return is_fprm(a) and _is_numeral(a.ctx, a.ast)
9558 
9559 # FP Numerals
9560 
9561 
def is_fprm_value(a)
Definition: z3py.py:9555

Referenced by set_default_rounding_mode().

◆ is_func_decl()

def z3py.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 847 of file z3py.py.

847 def is_func_decl(a):
848  """Return `True` if `a` is a Z3 function declaration.
849 
850  >>> f = Function('f', IntSort(), IntSort())
851  >>> is_func_decl(f)
852  True
853  >>> x = Real('x')
854  >>> is_func_decl(x)
855  False
856  """
857  return isinstance(a, FuncDeclRef)
858 
859 
def is_func_decl(a)
Definition: z3py.py:847

Referenced by Map(), and prove().

◆ is_ge()

def z3py.is_ge (   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 2855 of file z3py.py.

2855 def is_ge(a):
2856  """Return `True` if `a` is an expression of the form b >= c.
2857 
2858  >>> x, y = Ints('x y')
2859  >>> is_ge(x >= y)
2860  True
2861  >>> is_ge(x == y)
2862  False
2863  """
2864  return is_app_of(a, Z3_OP_GE)
2865 
2866 
def is_ge(a)
Definition: z3py.py:2855

◆ is_gt()

def z3py.is_gt (   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 2867 of file z3py.py.

2867 def is_gt(a):
2868  """Return `True` if `a` is an expression of the form b > c.
2869 
2870  >>> x, y = Ints('x y')
2871  >>> is_gt(x > y)
2872  True
2873  >>> is_gt(x == y)
2874  False
2875  """
2876  return is_app_of(a, Z3_OP_GT)
2877 
2878 
def is_gt(a)
Definition: z3py.py:2867

◆ is_idiv()

def z3py.is_idiv (   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 2807 of file z3py.py.

2807 def is_idiv(a):
2808  """Return `True` if `a` is an expression of the form b div c.
2809 
2810  >>> x, y = Ints('x y')
2811  >>> is_idiv(x / y)
2812  True
2813  >>> is_idiv(x + y)
2814  False
2815  """
2816  return is_app_of(a, Z3_OP_IDIV)
2817 
2818 
def is_idiv(a)
Definition: z3py.py:2807

◆ is_implies()

def z3py.is_implies (   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 1609 of file z3py.py.

1609 def is_implies(a):
1610  """Return `True` if `a` is a Z3 implication expression.
1611 
1612  >>> p, q = Bools('p q')
1613  >>> is_implies(Implies(p, q))
1614  True
1615  >>> is_implies(And(p, q))
1616  False
1617  """
1618  return is_app_of(a, Z3_OP_IMPLIES)
1619 
1620 
def is_implies(a)
Definition: z3py.py:1609

◆ is_int()

def z3py.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 2648 of file z3py.py.

2648 def is_int(a):
2649  """Return `True` if `a` is an integer expression.
2650 
2651  >>> x = Int('x')
2652  >>> is_int(x + 1)
2653  True
2654  >>> is_int(1)
2655  False
2656  >>> is_int(IntVal(1))
2657  True
2658  >>> y = Real('y')
2659  >>> is_int(y)
2660  False
2661  >>> is_int(y + 1)
2662  False
2663  """
2664  return is_arith(a) and a.is_int()
2665 
2666 
def is_int(a)
Definition: z3py.py:2648

◆ is_int_value()

def z3py.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 2694 of file z3py.py.

2694 def is_int_value(a):
2695  """Return `True` if `a` is an integer value of sort Int.
2696 
2697  >>> is_int_value(IntVal(1))
2698  True
2699  >>> is_int_value(1)
2700  False
2701  >>> is_int_value(Int('x'))
2702  False
2703  >>> n = Int('x') + 1
2704  >>> n
2705  x + 1
2706  >>> n.arg(1)
2707  1
2708  >>> is_int_value(n.arg(1))
2709  True
2710  >>> is_int_value(RealVal("1/3"))
2711  False
2712  >>> is_int_value(RealVal(1))
2713  False
2714  """
2715  return is_arith(a) and a.is_int() and _is_numeral(a.ctx, a.as_ast())
2716 
2717 
def is_int_value(a)
Definition: z3py.py:2694

◆ is_is_int()

def z3py.is_is_int (   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 2879 of file z3py.py.

2879 def is_is_int(a):
2880  """Return `True` if `a` is an expression of the form IsInt(b).
2881 
2882  >>> x = Real('x')
2883  >>> is_is_int(IsInt(x))
2884  True
2885  >>> is_is_int(x)
2886  False
2887  """
2888  return is_app_of(a, Z3_OP_IS_INT)
2889 
2890 
def is_is_int(a)
Definition: z3py.py:2879

◆ is_K()

def z3py.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 4583 of file z3py.py.

4583 def is_K(a):
4584  """Return `True` if `a` is a Z3 constant array.
4585 
4586  >>> a = K(IntSort(), 10)
4587  >>> is_K(a)
4588  True
4589  >>> a = Array('a', IntSort(), IntSort())
4590  >>> is_K(a)
4591  False
4592  """
4593  return is_app_of(a, Z3_OP_CONST_ARRAY)
4594 
4595 
def is_K(a)
Definition: z3py.py:4583

◆ is_le()

def z3py.is_le (   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 2831 of file z3py.py.

2831 def is_le(a):
2832  """Return `True` if `a` is an expression of the form b <= c.
2833 
2834  >>> x, y = Ints('x y')
2835  >>> is_le(x <= y)
2836  True
2837  >>> is_le(x < y)
2838  False
2839  """
2840  return is_app_of(a, Z3_OP_LE)
2841 
2842 
def is_le(a)
Definition: z3py.py:2831

◆ is_lt()

def z3py.is_lt (   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 2843 of file z3py.py.

2843 def is_lt(a):
2844  """Return `True` if `a` is an expression of the form b < c.
2845 
2846  >>> x, y = Ints('x y')
2847  >>> is_lt(x < y)
2848  True
2849  >>> is_lt(x == y)
2850  False
2851  """
2852  return is_app_of(a, Z3_OP_LT)
2853 
2854 
def is_lt(a)
Definition: z3py.py:2843

◆ is_map()

def z3py.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 4596 of file z3py.py.

4596 def is_map(a):
4597  """Return `True` if `a` is a Z3 map array expression.
4598 
4599  >>> f = Function('f', IntSort(), IntSort())
4600  >>> b = Array('b', IntSort(), IntSort())
4601  >>> a = Map(f, b)
4602  >>> a
4603  Map(f, b)
4604  >>> is_map(a)
4605  True
4606  >>> is_map(b)
4607  False
4608  """
4609  return is_app_of(a, Z3_OP_ARRAY_MAP)
4610 
4611 

Referenced by get_map_func().

◆ is_mod()

def z3py.is_mod (   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 2819 of file z3py.py.

2819 def is_mod(a):
2820  """Return `True` if `a` is an expression of the form b % c.
2821 
2822  >>> x, y = Ints('x y')
2823  >>> is_mod(x % y)
2824  True
2825  >>> is_mod(x + y)
2826  False
2827  """
2828  return is_app_of(a, Z3_OP_MOD)
2829 
2830 
def is_mod(a)
Definition: z3py.py:2819

◆ is_mul()

def z3py.is_mul (   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 2766 of file z3py.py.

2766 def is_mul(a):
2767  """Return `True` if `a` is an expression of the form b * c.
2768 
2769  >>> x, y = Ints('x y')
2770  >>> is_mul(x * y)
2771  True
2772  >>> is_mul(x - y)
2773  False
2774  """
2775  return is_app_of(a, Z3_OP_MUL)
2776 
2777 
def is_mul(a)
Definition: z3py.py:2766

◆ is_not()

def z3py.is_not (   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 1621 of file z3py.py.

1621 def is_not(a):
1622  """Return `True` if `a` is a Z3 not expression.
1623 
1624  >>> p = Bool('p')
1625  >>> is_not(p)
1626  False
1627  >>> is_not(Not(p))
1628  True
1629  """
1630  return is_app_of(a, Z3_OP_NOT)
1631 
1632 
def is_not(a)
Definition: z3py.py:1621

Referenced by mk_not().

◆ is_or()

def z3py.is_or (   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 1597 of file z3py.py.

1597 def is_or(a):
1598  """Return `True` if `a` is a Z3 or expression.
1599 
1600  >>> p, q = Bools('p q')
1601  >>> is_or(Or(p, q))
1602  True
1603  >>> is_or(And(p, q))
1604  False
1605  """
1606  return is_app_of(a, Z3_OP_OR)
1607 
1608 
def is_or(a)
Definition: z3py.py:1597

◆ is_pattern()

def z3py.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 1897 of file z3py.py.

1897 def is_pattern(a):
1898  """Return `True` if `a` is a Z3 pattern (hint for quantifier instantiation.
1899 
1900  >>> f = Function('f', IntSort(), IntSort())
1901  >>> x = Int('x')
1902  >>> q = ForAll(x, f(x) == 0, patterns = [ f(x) ])
1903  >>> q
1904  ForAll(x, f(x) == 0)
1905  >>> q.num_patterns()
1906  1
1907  >>> is_pattern(q.pattern(0))
1908  True
1909  >>> q.pattern(0)
1910  f(Var(0))
1911  """
1912  return isinstance(a, PatternRef)
1913 
1914 
def is_pattern(a)
Definition: z3py.py:1897

Referenced by is_quantifier(), and MultiPattern().

◆ is_probe()

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

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

Definition at line 8511 of file z3py.py.

8511 def is_probe(p):
8512  """Return `True` if `p` is a Z3 probe.
8513 
8514  >>> is_probe(Int('x'))
8515  False
8516  >>> is_probe(Probe('memory'))
8517  True
8518  """
8519  return isinstance(p, Probe)
8520 
8521 
def is_probe(p)
Definition: z3py.py:8511

Referenced by eq(), mk_not(), and Not().

◆ is_quantifier()

def z3py.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 2138 of file z3py.py.

2138 def is_quantifier(a):
2139  """Return `True` if `a` is a Z3 quantifier.
2140 
2141  >>> f = Function('f', IntSort(), IntSort())
2142  >>> x = Int('x')
2143  >>> q = ForAll(x, f(x) == 0)
2144  >>> is_quantifier(q)
2145  True
2146  >>> is_quantifier(f(x))
2147  False
2148  """
2149  return isinstance(a, QuantifierRef)
2150 
2151 
def is_quantifier(a)
Definition: z3py.py:2138

◆ is_rational_value()

def z3py.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 2718 of file z3py.py.

2718 def is_rational_value(a):
2719  """Return `True` if `a` is rational value of sort Real.
2720 
2721  >>> is_rational_value(RealVal(1))
2722  True
2723  >>> is_rational_value(RealVal("3/5"))
2724  True
2725  >>> is_rational_value(IntVal(1))
2726  False
2727  >>> is_rational_value(1)
2728  False
2729  >>> n = Real('x') + 1
2730  >>> n.arg(1)
2731  1
2732  >>> is_rational_value(n.arg(1))
2733  True
2734  >>> is_rational_value(Real('x'))
2735  False
2736  """
2737  return is_arith(a) and a.is_real() and _is_numeral(a.ctx, a.as_ast())
2738 
2739 
def is_rational_value(a)
Definition: z3py.py:2718

◆ is_re()

def z3py.is_re (   s)

Definition at line 10920 of file z3py.py.

10920 def is_re(s):
10921  return isinstance(s, ReRef)
10922 
10923 

Referenced by Concat(), Intersect(), and Union().

◆ is_real()

def z3py.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 2667 of file z3py.py.

2667 def is_real(a):
2668  """Return `True` if `a` is a real expression.
2669 
2670  >>> x = Int('x')
2671  >>> is_real(x + 1)
2672  False
2673  >>> y = Real('y')
2674  >>> is_real(y)
2675  True
2676  >>> is_real(y + 1)
2677  True
2678  >>> is_real(1)
2679  False
2680  >>> is_real(RealVal(1))
2681  True
2682  """
2683  return is_arith(a) and a.is_real()
2684 
2685 

Referenced by fpRealToFP(), and fpToFP().

◆ is_select()

def z3py.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 4820 of file z3py.py.

4820 def is_select(a):
4821  """Return `True` if `a` is a Z3 array select application.
4822 
4823  >>> a = Array('a', IntSort(), IntSort())
4824  >>> is_select(a)
4825  False
4826  >>> i = Int('i')
4827  >>> is_select(a[i])
4828  True
4829  """
4830  return is_app_of(a, Z3_OP_SELECT)
4831 
4832 
def is_select(a)
Definition: z3py.py:4820

◆ is_seq()

def z3py.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 10658 of file z3py.py.

10658 def is_seq(a):
10659  """Return `True` if `a` is a Z3 sequence expression.
10660  >>> print (is_seq(Unit(IntVal(0))))
10661  True
10662  >>> print (is_seq(StringVal("abc")))
10663  True
10664  """
10665  return isinstance(a, SeqRef)
10666 
10667 

Referenced by SeqRef.__gt__(), Concat(), and Extract().

◆ is_sort()

def z3py.is_sort (   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 646 of file z3py.py.

646 def is_sort(s):
647  """Return `True` if `s` is a Z3 sort.
648 
649  >>> is_sort(IntSort())
650  True
651  >>> is_sort(Int('x'))
652  False
653  >>> is_expr(Int('x'))
654  True
655  """
656  return isinstance(s, SortRef)
657 
658 

Referenced by ArraySort(), CreateDatatypes(), FreshFunction(), Function(), IsSubset(), K(), prove(), RecFunction(), and Var().

◆ is_store()

def z3py.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 4833 of file z3py.py.

4833 def is_store(a):
4834  """Return `True` if `a` is a Z3 array store application.
4835 
4836  >>> a = Array('a', IntSort(), IntSort())
4837  >>> is_store(a)
4838  False
4839  >>> is_store(Store(a, 0, 1))
4840  True
4841  """
4842  return is_app_of(a, Z3_OP_STORE)
4843 
def is_store(a)
Definition: z3py.py:4833

◆ is_string()

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

Definition at line 10668 of file z3py.py.

10668 def is_string(a):
10669  """Return `True` if `a` is a Z3 string expression.
10670  >>> print (is_string(StringVal("ab")))
10671  True
10672  """
10673  return isinstance(a, SeqRef) and a.is_string()
10674 
10675 
def is_string(a)
Definition: z3py.py:10668

◆ is_string_value()

def z3py.is_string_value (   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 10676 of file z3py.py.

10676 def is_string_value(a):
10677  """return 'True' if 'a' is a Z3 string constant expression.
10678  >>> print (is_string_value(StringVal("a")))
10679  True
10680  >>> print (is_string_value(StringVal("a") + StringVal("b")))
10681  False
10682  """
10683  return isinstance(a, SeqRef) and a.is_string_value()
10684 
10685 
def is_string_value(a)
Definition: z3py.py:10676

◆ is_sub()

def z3py.is_sub (   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 2778 of file z3py.py.

2778 def is_sub(a):
2779  """Return `True` if `a` is an expression of the form b - c.
2780 
2781  >>> x, y = Ints('x y')
2782  >>> is_sub(x - y)
2783  True
2784  >>> is_sub(x + y)
2785  False
2786  """
2787  return is_app_of(a, Z3_OP_SUB)
2788 
2789 
def is_sub(a)
Definition: z3py.py:2778

◆ is_to_int()

def z3py.is_to_int (   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 2906 of file z3py.py.

2906 def is_to_int(a):
2907  """Return `True` if `a` is an expression of the form ToInt(b).
2908 
2909  >>> x = Real('x')
2910  >>> n = ToInt(x)
2911  >>> n
2912  ToInt(x)
2913  >>> is_to_int(n)
2914  True
2915  >>> is_to_int(x)
2916  False
2917  """
2918  return is_app_of(a, Z3_OP_TO_INT)
2919 
2920 
def is_to_int(a)
Definition: z3py.py:2906

◆ is_to_real()

def z3py.is_to_real (   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 2891 of file z3py.py.

2891 def is_to_real(a):
2892  """Return `True` if `a` is an expression of the form ToReal(b).
2893 
2894  >>> x = Int('x')
2895  >>> n = ToReal(x)
2896  >>> n
2897  ToReal(x)
2898  >>> is_to_real(n)
2899  True
2900  >>> is_to_real(x)
2901  False
2902  """
2903  return is_app_of(a, Z3_OP_TO_REAL)
2904 
2905 
def is_to_real(a)
Definition: z3py.py:2891

◆ is_true()

def z3py.is_true (   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 1553 of file z3py.py.

1553 def is_true(a):
1554  """Return `True` if `a` is the Z3 true expression.
1555 
1556  >>> p = Bool('p')
1557  >>> is_true(p)
1558  False
1559  >>> is_true(simplify(p == p))
1560  True
1561  >>> x = Real('x')
1562  >>> is_true(x == 0)
1563  False
1564  >>> # True is a Python Boolean expression
1565  >>> is_true(True)
1566  False
1567  """
1568  return is_app_of(a, Z3_OP_TRUE)
1569 
1570 
def is_true(a)
Definition: z3py.py:1553

Referenced by AstRef.__bool__().

◆ is_var()

def z3py.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 1278 of file z3py.py.

1278 def is_var(a):
1279  """Return `True` if `a` is variable.
1280 
1281  Z3 uses de-Bruijn indices for representing bound variables in
1282  quantifiers.
1283 
1284  >>> x = Int('x')
1285  >>> is_var(x)
1286  False
1287  >>> is_const(x)
1288  True
1289  >>> f = Function('f', IntSort(), IntSort())
1290  >>> # Z3 replaces x with bound variables when ForAll is executed.
1291  >>> q = ForAll(x, f(x) == x)
1292  >>> b = q.body()
1293  >>> b
1294  f(Var(0)) == Var(0)
1295  >>> b.arg(1)
1296  Var(0)
1297  >>> is_var(b.arg(1))
1298  True
1299  """
1300  return is_expr(a) and _ast_kind(a.ctx, a) == Z3_VAR_AST
1301 
1302 

Referenced by get_var_index().

◆ IsInt()

def z3py.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 3356 of file z3py.py.

3356 def IsInt(a):
3357  """ Return the Z3 predicate IsInt(a).
3358 
3359  >>> x = Real('x')
3360  >>> IsInt(x + "1/2")
3361  IsInt(x + 1/2)
3362  >>> solve(IsInt(x + "1/2"), x > 0, x < 1)
3363  [x = 1/2]
3364  >>> solve(IsInt(x + "1/2"), x > 0, x < 1, x != "1/2")
3365  no solution
3366  """
3367  if z3_debug():
3368  _z3_assert(a.is_real(), "Z3 real expression expected.")
3369  ctx = a.ctx
3370  return BoolRef(Z3_mk_is_int(ctx.ref(), a.as_ast()), ctx)
3371 
3372 
def IsInt(a)
Definition: z3py.py:3356
Z3_ast Z3_API Z3_mk_is_int(Z3_context c, Z3_ast t1)
Check if a real number is an integer.

◆ IsMember()

def z3py.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 4943 of file z3py.py.

4943 def IsMember(e, s):
4944  """ Check if e is a member of set s
4945  >>> a = Const('a', SetSort(IntSort()))
4946  >>> IsMember(1, a)
4947  a[1]
4948  """
4949  ctx = _ctx_from_ast_arg_list([s, e])
4950  e = _py2expr(e, ctx)
4951  return BoolRef(Z3_mk_set_member(ctx.ref(), e.as_ast(), s.as_ast()), ctx)
4952 
4953 
def IsMember(e, s)
Definition: z3py.py:4943
Z3_ast Z3_API Z3_mk_set_member(Z3_context c, Z3_ast elem, Z3_ast set)
Check for set membership.

◆ IsSubset()

def z3py.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 4954 of file z3py.py.

4954 def IsSubset(a, b):
4955  """ Check if a is a subset of b
4956  >>> a = Const('a', SetSort(IntSort()))
4957  >>> b = Const('b', SetSort(IntSort()))
4958  >>> IsSubset(a, b)
4959  subset(a, b)
4960  """
4961  ctx = _ctx_from_ast_arg_list([a, b])
4962  return BoolRef(Z3_mk_set_subset(ctx.ref(), a.as_ast(), b.as_ast()), ctx)
4963 
4964 
def IsSubset(a, b)
Definition: z3py.py:4954
Z3_ast Z3_API Z3_mk_set_subset(Z3_context c, Z3_ast arg1, Z3_ast arg2)
Check for subsetness of sets.

◆ K()

def z3py.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 4780 of file z3py.py.

4780 def K(dom, v):
4781  """Return a Z3 constant array expression.
4782 
4783  >>> a = K(IntSort(), 10)
4784  >>> a
4785  K(Int, 10)
4786  >>> a.sort()
4787  Array(Int, Int)
4788  >>> i = Int('i')
4789  >>> a[i]
4790  K(Int, 10)[i]
4791  >>> simplify(a[i])
4792  10
4793  """
4794  if z3_debug():
4795  _z3_assert(is_sort(dom), "Z3 sort expected")
4796  ctx = dom.ctx
4797  if not is_expr(v):
4798  v = _py2expr(v, ctx)
4799  return ArrayRef(Z3_mk_const_array(ctx.ref(), dom.ast, v.as_ast()), ctx)
4800 
4801 
def K(dom, v)
Definition: z3py.py:4780
Z3_ast Z3_API Z3_mk_const_array(Z3_context c, Z3_sort domain, Z3_ast v)
Create the constant array.

◆ Lambda()

def z3py.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 2226 of file z3py.py.

2226 def Lambda(vs, body):
2227  """Create a Z3 lambda expression.
2228 
2229  >>> f = Function('f', IntSort(), IntSort(), IntSort())
2230  >>> mem0 = Array('mem0', IntSort(), IntSort())
2231  >>> lo, hi, e, i = Ints('lo hi e i')
2232  >>> mem1 = Lambda([i], If(And(lo <= i, i <= hi), e, mem0[i]))
2233  >>> mem1
2234  Lambda(i, If(And(lo <= i, i <= hi), e, mem0[i]))
2235  """
2236  ctx = body.ctx
2237  if is_app(vs):
2238  vs = [vs]
2239  num_vars = len(vs)
2240  _vs = (Ast * num_vars)()
2241  for i in range(num_vars):
2242  # TODO: Check if is constant
2243  _vs[i] = vs[i].as_ast()
2244  return QuantifierRef(Z3_mk_lambda_const(ctx.ref(), num_vars, _vs, body.as_ast()), ctx)
2245 
def Lambda(vs, body)
Definition: z3py.py:2226
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()

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

Definition at line 10843 of file z3py.py.

10843 def LastIndexOf(s, substr):
10844  """Retrieve the last index of substring within a string"""
10845  ctx = None
10846  ctx = _get_ctx2(s, substr, ctx)
10847  s = _coerce_seq(s, ctx)
10848  substr = _coerce_seq(substr, ctx)
10849  return ArithRef(Z3_mk_seq_last_index(s.ctx_ref(), s.as_ast(), substr.as_ast()), s.ctx)
10850 
10851 
def LastIndexOf(s, substr)
Definition: z3py.py:10843
Z3_ast Z3_API Z3_mk_seq_last_index(Z3_context c, Z3_ast, Z3_ast substr)
Return the last occurrence of substr in s. If s does not contain substr, then the value is -1,...

◆ Length()

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

Definition at line 10852 of file z3py.py.

10852 def Length(s):
10853  """Obtain the length of a sequence 's'
10854  >>> l = Length(StringVal("abc"))
10855  >>> simplify(l)
10856  3
10857  """
10858  s = _coerce_seq(s)
10859  return ArithRef(Z3_mk_seq_length(s.ctx_ref(), s.as_ast()), s.ctx)
10860 
10861 
def Length(s)
Definition: z3py.py:10852
Z3_ast Z3_API Z3_mk_seq_length(Z3_context c, Z3_ast s)
Return the length of the sequence s.

◆ LinearOrder()

def z3py.LinearOrder (   a,
  index 
)

Definition at line 11052 of file z3py.py.

11052 def LinearOrder(a, index):
11053  return FuncDeclRef(Z3_mk_linear_order(a.ctx_ref(), a.ast, index), a.ctx)
11054 
11055 
def LinearOrder(a, index)
Definition: z3py.py:11052
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()

def z3py.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 11020 of file z3py.py.

11020 def Loop(re, lo, hi=0):
11021  """Create the regular expression accepting between a lower and upper bound repetitions
11022  >>> re = Loop(Re("a"), 1, 3)
11023  >>> print(simplify(InRe("aa", re)))
11024  True
11025  >>> print(simplify(InRe("aaaa", re)))
11026  False
11027  >>> print(simplify(InRe("", re)))
11028  False
11029  """
11030  return ReRef(Z3_mk_re_loop(re.ctx_ref(), re.as_ast(), lo, hi), re.ctx)
11031 
11032 
def Loop(re, lo, hi=0)
Definition: z3py.py:11020
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()

def z3py.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 4261 of file z3py.py.

4261 def LShR(a, b):
4262  """Create the Z3 expression logical right shift.
4263 
4264  Use the operator >> for the arithmetical right shift.
4265 
4266  >>> x, y = BitVecs('x y', 32)
4267  >>> LShR(x, y)
4268  LShR(x, y)
4269  >>> (x >> y).sexpr()
4270  '(bvashr x y)'
4271  >>> LShR(x, y).sexpr()
4272  '(bvlshr x y)'
4273  >>> BitVecVal(4, 3)
4274  4
4275  >>> BitVecVal(4, 3).as_signed_long()
4276  -4
4277  >>> simplify(BitVecVal(4, 3) >> 1).as_signed_long()
4278  -2
4279  >>> simplify(BitVecVal(4, 3) >> 1)
4280  6
4281  >>> simplify(LShR(BitVecVal(4, 3), 1))
4282  2
4283  >>> simplify(BitVecVal(2, 3) >> 1)
4284  1
4285  >>> simplify(LShR(BitVecVal(2, 3), 1))
4286  1
4287  """
4288  _check_bv_args(a, b)
4289  a, b = _coerce_exprs(a, b)
4290  return BitVecRef(Z3_mk_bvlshr(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4291 
4292 
def LShR(a, b)
Definition: z3py.py:4261
Z3_ast Z3_API Z3_mk_bvlshr(Z3_context c, Z3_ast t1, Z3_ast t2)
Logical shift right.

◆ main_ctx()

def z3py.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 238 of file z3py.py.

238 def main_ctx():
239  """Return a reference to the global Z3 context.
240 
241  >>> x = Real('x')
242  >>> x.ctx == main_ctx()
243  True
244  >>> c = Context()
245  >>> c == main_ctx()
246  False
247  >>> x2 = Real('x', c)
248  >>> x2.ctx == c
249  True
250  >>> eq(x, x2)
251  False
252  """
253  global _main_ctx
254  if _main_ctx is None:
255  _main_ctx = Context()
256  return _main_ctx
257 
258 

Referenced by SeqRef.__gt__(), help_simplify(), and simplify_param_descrs().

◆ Map()

def z3py.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 4757 of file z3py.py.

4757 def Map(f, *args):
4758  """Return a Z3 map array expression.
4759 
4760  >>> f = Function('f', IntSort(), IntSort(), IntSort())
4761  >>> a1 = Array('a1', IntSort(), IntSort())
4762  >>> a2 = Array('a2', IntSort(), IntSort())
4763  >>> b = Map(f, a1, a2)
4764  >>> b
4765  Map(f, a1, a2)
4766  >>> prove(b[0] == f(a1[0], a2[0]))
4767  proved
4768  """
4769  args = _get_args(args)
4770  if z3_debug():
4771  _z3_assert(len(args) > 0, "At least one Z3 array expression expected")
4772  _z3_assert(is_func_decl(f), "First argument must be a Z3 function declaration")
4773  _z3_assert(all([is_array(a) for a in args]), "Z3 array expected expected")
4774  _z3_assert(len(args) == f.arity(), "Number of arguments mismatch")
4775  _args, sz = _to_ast_array(args)
4776  ctx = f.ctx
4777  return ArrayRef(Z3_mk_map(ctx.ref(), f.ast, sz, _args), ctx)
4778 
4779 
def Map(f, *args)
Definition: z3py.py:4757
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()

def z3py.mk_not (   a)

Definition at line 1798 of file z3py.py.

1798 def mk_not(a):
1799  if is_not(a):
1800  return a.arg(0)
1801  else:
1802  return Not(a)
1803 
1804 
def mk_not(a)
Definition: z3py.py:1798

◆ Model()

def z3py.Model (   ctx = None)

Definition at line 6579 of file z3py.py.

6579 def Model(ctx=None):
6580  ctx = _get_ctx(ctx)
6581  return ModelRef(Z3_mk_model(ctx.ref()), ctx)
6582 
6583 
def Model(ctx=None)
Definition: z3py.py:6579
Z3_model Z3_API Z3_mk_model(Z3_context c)
Create a fresh model object. It has reference count 0.

Referenced by Optimize.set_on_model().

◆ MultiPattern()

def z3py.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 1915 of file z3py.py.

1915 def MultiPattern(*args):
1916  """Create a Z3 multi-pattern using the given expressions `*args`
1917 
1918  >>> f = Function('f', IntSort(), IntSort())
1919  >>> g = Function('g', IntSort(), IntSort())
1920  >>> x = Int('x')
1921  >>> q = ForAll(x, f(x) != g(x), patterns = [ MultiPattern(f(x), g(x)) ])
1922  >>> q
1923  ForAll(x, f(x) != g(x))
1924  >>> q.num_patterns()
1925  1
1926  >>> is_pattern(q.pattern(0))
1927  True
1928  >>> q.pattern(0)
1929  MultiPattern(f(Var(0)), g(Var(0)))
1930  """
1931  if z3_debug():
1932  _z3_assert(len(args) > 0, "At least one argument expected")
1933  _z3_assert(all([is_expr(a) for a in args]), "Z3 expressions expected")
1934  ctx = args[0].ctx
1935  args, sz = _to_ast_array(args)
1936  return PatternRef(Z3_mk_pattern(ctx.ref(), sz, args), ctx)
1937 
1938 
def MultiPattern(*args)
Definition: z3py.py:1915
Z3_pattern Z3_API Z3_mk_pattern(Z3_context c, unsigned num_patterns, Z3_ast const terms[])
Create a pattern for quantifier instantiation.

◆ Not()

def z3py.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 1779 of file z3py.py.

1779 def Not(a, ctx=None):
1780  """Create a Z3 not expression or probe.
1781 
1782  >>> p = Bool('p')
1783  >>> Not(Not(p))
1784  Not(Not(p))
1785  >>> simplify(Not(Not(p)))
1786  p
1787  """
1788  ctx = _get_ctx(_ctx_from_ast_arg_list([a], ctx))
1789  if is_probe(a):
1790  # Not is also used to build probes
1791  return Probe(Z3_probe_not(ctx.ref(), a.probe), ctx)
1792  else:
1793  s = BoolSort(ctx)
1794  a = s.cast(a)
1795  return BoolRef(Z3_mk_not(ctx.ref(), a.as_ast()), ctx)
1796 
1797 
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 fpNEQ(), mk_not(), and prove().

◆ open_log()

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

Definition at line 119 of file z3py.py.

119 def open_log(fname):
120  """Log interaction to a file. This function must be invoked immediately after init(). """
121  Z3_open_log(fname)
122 
123 
def open_log(fname)
Definition: z3py.py:119
bool Z3_API Z3_open_log(Z3_string filename)
Log interaction to a file.

◆ Option()

def z3py.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 10989 of file z3py.py.

10989 def Option(re):
10990  """Create the regular expression that optionally accepts the argument.
10991  >>> re = Option(Re("a"))
10992  >>> print(simplify(InRe("a", re)))
10993  True
10994  >>> print(simplify(InRe("", re)))
10995  True
10996  >>> print(simplify(InRe("aa", re)))
10997  False
10998  """
10999  return ReRef(Z3_mk_re_option(re.ctx_ref(), re.as_ast()), re.ctx)
11000 
11001 
def Option(re)
Definition: z3py.py:10989
Z3_ast Z3_API Z3_mk_re_option(Z3_context c, Z3_ast re)
Create the regular language [re].

◆ Or()

def z3py.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 1846 of file z3py.py.

1846 def Or(*args):
1847  """Create a Z3 or-expression or or-probe.
1848 
1849  >>> p, q, r = Bools('p q r')
1850  >>> Or(p, q, r)
1851  Or(p, q, r)
1852  >>> P = BoolVector('p', 5)
1853  >>> Or(P)
1854  Or(p__0, p__1, p__2, p__3, p__4)
1855  """
1856  last_arg = None
1857  if len(args) > 0:
1858  last_arg = args[len(args) - 1]
1859  if isinstance(last_arg, Context):
1860  ctx = args[len(args) - 1]
1861  args = args[:len(args) - 1]
1862  elif len(args) == 1 and isinstance(args[0], AstVector):
1863  ctx = args[0].ctx
1864  args = [a for a in args[0]]
1865  else:
1866  ctx = None
1867  args = _get_args(args)
1868  ctx = _get_ctx(_ctx_from_ast_arg_list(args, ctx))
1869  if z3_debug():
1870  _z3_assert(ctx is not None, "At least one of the arguments must be a Z3 expression or probe")
1871  if _has_probe(args):
1872  return _probe_or(args, ctx)
1873  else:
1874  args = _coerce_expr_list(args, ctx)
1875  _args, sz = _to_ast_array(args)
1876  return BoolRef(Z3_mk_or(ctx.ref(), sz, _args), ctx)
1877 
def Or(*args)
Definition: z3py.py:1846
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 ApplyResult.as_expr().

◆ OrElse()

def z3py.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 8204 of file z3py.py.

8204 def OrElse(*ts, **ks):
8205  """Return a tactic that applies the tactics in `*ts` until one of them succeeds (it doesn't fail).
8206 
8207  >>> x = Int('x')
8208  >>> t = OrElse(Tactic('split-clause'), Tactic('skip'))
8209  >>> # Tactic split-clause fails if there is no clause in the given goal.
8210  >>> t(x == 0)
8211  [[x == 0]]
8212  >>> t(Or(x == 0, x == 1))
8213  [[x == 0], [x == 1]]
8214  """
8215  if z3_debug():
8216  _z3_assert(len(ts) >= 2, "At least two arguments expected")
8217  ctx = ks.get("ctx", None)
8218  num = len(ts)
8219  r = ts[0]
8220  for i in range(num - 1):
8221  r = _or_else(r, ts[i + 1], ctx)
8222  return r
8223 
8224 
def OrElse(*ts, **ks)
Definition: z3py.py:8204

◆ ParAndThen()

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

Definition at line 8260 of file z3py.py.

8260 def ParAndThen(t1, t2, ctx=None):
8261  """Alias for ParThen(t1, t2, ctx)."""
8262  return ParThen(t1, t2, ctx)
8263 
8264 
def ParThen(t1, t2, ctx=None)
Definition: z3py.py:8244
def ParAndThen(t1, t2, ctx=None)
Definition: z3py.py:8260

◆ ParOr()

def z3py.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 8225 of file z3py.py.

8225 def ParOr(*ts, **ks):
8226  """Return a tactic that applies the tactics in `*ts` in parallel until one of them succeeds (it doesn't fail).
8227 
8228  >>> x = Int('x')
8229  >>> t = ParOr(Tactic('simplify'), Tactic('fail'))
8230  >>> t(x + 1 == 2)
8231  [[x == 1]]
8232  """
8233  if z3_debug():
8234  _z3_assert(len(ts) >= 2, "At least two arguments expected")
8235  ctx = _get_ctx(ks.get("ctx", None))
8236  ts = [_to_tactic(t, ctx) for t in ts]
8237  sz = len(ts)
8238  _args = (TacticObj * sz)()
8239  for i in range(sz):
8240  _args[i] = ts[i].tactic
8241  return Tactic(Z3_tactic_par_or(ctx.ref(), sz, _args), ctx)
8242 
8243 
def ParOr(*ts, **ks)
Definition: z3py.py:8225
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()

def z3py.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 9092 of file z3py.py.

9092 def parse_smt2_file(f, sorts={}, decls={}, ctx=None):
9093  """Parse a file in SMT 2.0 format using the given sorts and decls.
9094 
9095  This function is similar to parse_smt2_string().
9096  """
9097  ctx = _get_ctx(ctx)
9098  ssz, snames, ssorts = _dict2sarray(sorts, ctx)
9099  dsz, dnames, ddecls = _dict2darray(decls, ctx)
9100  return AstVector(Z3_parse_smtlib2_file(ctx.ref(), f, ssz, snames, ssorts, dsz, dnames, ddecls), ctx)
9101 
9102 
def parse_smt2_file(f, sorts={}, decls={}, ctx=None)
Definition: z3py.py:9092
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()

def z3py.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 9071 of file z3py.py.

9071 def parse_smt2_string(s, sorts={}, decls={}, ctx=None):
9072  """Parse a string in SMT 2.0 format using the given sorts and decls.
9073 
9074  The arguments sorts and decls are Python dictionaries used to initialize
9075  the symbol table used for the SMT 2.0 parser.
9076 
9077  >>> parse_smt2_string('(declare-const x Int) (assert (> x 0)) (assert (< x 10))')
9078  [x > 0, x < 10]
9079  >>> x, y = Ints('x y')
9080  >>> f = Function('f', IntSort(), IntSort())
9081  >>> parse_smt2_string('(assert (> (+ foo (g bar)) 0))', decls={ 'foo' : x, 'bar' : y, 'g' : f})
9082  [x + f(y) > 0]
9083  >>> parse_smt2_string('(declare-const a U) (assert (> a 0))', sorts={ 'U' : IntSort() })
9084  [a > 0]
9085  """
9086  ctx = _get_ctx(ctx)
9087  ssz, snames, ssorts = _dict2sarray(sorts, ctx)
9088  dsz, dnames, ddecls = _dict2darray(decls, ctx)
9089  return AstVector(Z3_parse_smtlib2_string(ctx.ref(), s, ssz, snames, ssorts, dsz, dnames, ddecls), ctx)
9090 
9091 
def parse_smt2_string(s, sorts={}, decls={}, ctx=None)
Definition: z3py.py:9071
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()

def z3py.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 8244 of file z3py.py.

8244 def ParThen(t1, t2, ctx=None):
8245  """Return a tactic that applies t1 and then t2 to every subgoal produced by t1.
8246  The subgoals are processed in parallel.
8247 
8248  >>> x, y = Ints('x y')
8249  >>> t = ParThen(Tactic('split-clause'), Tactic('propagate-values'))
8250  >>> t(And(Or(x == 1, x == 2), y == x + 1))
8251  [[x == 1, y == 2], [x == 2, y == 3]]
8252  """
8253  t1 = _to_tactic(t1, ctx)
8254  t2 = _to_tactic(t2, ctx)
8255  if z3_debug():
8256  _z3_assert(t1.ctx == t2.ctx, "Context mismatch")
8257  return Tactic(Z3_tactic_par_and_then(t1.ctx.ref(), t1.tactic, t2.tactic), t1.ctx)
8258 
8259 
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....

Referenced by ParAndThen().

◆ PartialOrder()

def z3py.PartialOrder (   a,
  index 
)

Definition at line 11048 of file z3py.py.

11048 def PartialOrder(a, index):
11049  return FuncDeclRef(Z3_mk_partial_order(a.ctx_ref(), a.ast, index), a.ctx)
11050 
11051 
def PartialOrder(a, index)
Definition: z3py.py:11048
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()

def z3py.PbEq (   args,
  k,
  ctx = None 
)
Create a Pseudo-Boolean inequality k constraint.

>>> a, b, c = Bools('a b c')
>>> f = PbEq(((a,1),(b,3),(c,2)), 3)

Definition at line 8867 of file z3py.py.

8867 def PbEq(args, k, ctx=None):
8868  """Create a Pseudo-Boolean inequality k constraint.
8869 
8870  >>> a, b, c = Bools('a b c')
8871  >>> f = PbEq(((a,1),(b,3),(c,2)), 3)
8872  """
8873  _z3_check_cint_overflow(k, "k")
8874  ctx, sz, _args, _coeffs = _pb_args_coeffs(args)
8875  return BoolRef(Z3_mk_pbeq(ctx.ref(), sz, _args, _coeffs, k), ctx)
8876 
8877 
def PbEq(args, k, ctx=None)
Definition: z3py.py:8867
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()

def z3py.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 8856 of file z3py.py.

8856 def PbGe(args, k):
8857  """Create a Pseudo-Boolean inequality k constraint.
8858 
8859  >>> a, b, c = Bools('a b c')
8860  >>> f = PbGe(((a,1),(b,3),(c,2)), 3)
8861  """
8862  _z3_check_cint_overflow(k, "k")
8863  ctx, sz, _args, _coeffs = _pb_args_coeffs(args)
8864  return BoolRef(Z3_mk_pbge(ctx.ref(), sz, _args, _coeffs, k), ctx)
8865 
8866 
def PbGe(args, k)
Definition: z3py.py:8856
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()

def z3py.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 8845 of file z3py.py.

8845 def PbLe(args, k):
8846  """Create a Pseudo-Boolean inequality k constraint.
8847 
8848  >>> a, b, c = Bools('a b c')
8849  >>> f = PbLe(((a,1),(b,3),(c,2)), 3)
8850  """
8851  _z3_check_cint_overflow(k, "k")
8852  ctx, sz, _args, _coeffs = _pb_args_coeffs(args)
8853  return BoolRef(Z3_mk_pble(ctx.ref(), sz, _args, _coeffs, k), ctx)
8854 
8855 
def PbLe(args, k)
Definition: z3py.py:8845
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()

def z3py.PiecewiseLinearOrder (   a,
  index 
)

Definition at line 11060 of file z3py.py.

11060 def PiecewiseLinearOrder(a, index):
11061  return FuncDeclRef(Z3_mk_piecewise_linear_order(a.ctx_ref(), a.ast, index), a.ctx)
11062 
11063 
def PiecewiseLinearOrder(a, index)
Definition: z3py.py:11060
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()

def z3py.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 10976 of file z3py.py.

10976 def Plus(re):
10977  """Create the regular expression accepting one or more repetitions of argument.
10978  >>> re = Plus(Re("a"))
10979  >>> print(simplify(InRe("aa", re)))
10980  True
10981  >>> print(simplify(InRe("ab", re)))
10982  False
10983  >>> print(simplify(InRe("", re)))
10984  False
10985  """
10986  return ReRef(Z3_mk_re_plus(re.ctx_ref(), re.as_ast()), re.ctx)
10987 
10988 
def Plus(re)
Definition: z3py.py:10976
Z3_ast Z3_API Z3_mk_re_plus(Z3_context c, Z3_ast re)
Create the regular language re+.

◆ PrefixOf()

def z3py.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 10759 of file z3py.py.

10759 def PrefixOf(a, b):
10760  """Check if 'a' is a prefix of 'b'
10761  >>> s1 = PrefixOf("ab", "abc")
10762  >>> simplify(s1)
10763  True
10764  >>> s2 = PrefixOf("bc", "abc")
10765  >>> simplify(s2)
10766  False
10767  """
10768  ctx = _get_ctx2(a, b)
10769  a = _coerce_seq(a, ctx)
10770  b = _coerce_seq(b, ctx)
10771  return BoolRef(Z3_mk_seq_prefix(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
10772 
10773 
def PrefixOf(a, b)
Definition: z3py.py:10759
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()

def z3py.probe_description (   name,
  ctx = None 
)
Return a short description for the probe named `name`.

>>> d = probe_description('memory')

Definition at line 8540 of file z3py.py.

8540 def probe_description(name, ctx=None):
8541  """Return a short description for the probe named `name`.
8542 
8543  >>> d = probe_description('memory')
8544  """
8545  ctx = _get_ctx(ctx)
8546  return Z3_probe_get_descr(ctx.ref(), name)
8547 
8548 
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.

Referenced by describe_probes().

◆ probes()

def z3py.probes (   ctx = None)
Return a list of all available probes in Z3.

>>> l = probes()
>>> l.count('memory') == 1
True

Definition at line 8529 of file z3py.py.

8529 def probes(ctx=None):
8530  """Return a list of all available probes in Z3.
8531 
8532  >>> l = probes()
8533  >>> l.count('memory') == 1
8534  True
8535  """
8536  ctx = _get_ctx(ctx)
8537  return [Z3_get_probe_name(ctx.ref(), i) for i in range(Z3_get_num_probes(ctx.ref()))]
8538 
8539 
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.

Referenced by describe_probes().

◆ Product()

def z3py.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 8756 of file z3py.py.

8756 def Product(*args):
8757  """Create the product of the Z3 expressions.
8758 
8759  >>> a, b, c = Ints('a b c')
8760  >>> Product(a, b, c)
8761  a*b*c
8762  >>> Product([a, b, c])
8763  a*b*c
8764  >>> A = IntVector('a', 5)
8765  >>> Product(A)
8766  a__0*a__1*a__2*a__3*a__4
8767  """
8768  args = _get_args(args)
8769  if len(args) == 0:
8770  return 1
8771  ctx = _ctx_from_ast_arg_list(args)
8772  if ctx is None:
8773  return _reduce(lambda a, b: a * b, args, 1)
8774  args = _coerce_expr_list(args, ctx)
8775  if is_bv(args[0]):
8776  return _reduce(lambda a, b: a * b, args, 1)
8777  else:
8778  _args, sz = _to_ast_array(args)
8779  return ArithRef(Z3_mk_mul(ctx.ref(), sz, _args), ctx)
8780 
8781 
def Product(*args)
Definition: z3py.py:8756
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].

◆ prove()

def z3py.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 8939 of file z3py.py.

8939 def prove(claim, show=False, **keywords):
8940  """Try to prove the given claim.
8941 
8942  This is a simple function for creating demonstrations. It tries to prove
8943  `claim` by showing the negation is unsatisfiable.
8944 
8945  >>> p, q = Bools('p q')
8946  >>> prove(Not(And(p, q)) == Or(Not(p), Not(q)))
8947  proved
8948  """
8949  if z3_debug():
8950  _z3_assert(is_bool(claim), "Z3 Boolean expression expected")
8951  s = Solver()
8952  s.set(**keywords)
8953  s.add(Not(claim))
8954  if show:
8955  print(s)
8956  r = s.check()
8957  if r == unsat:
8958  print("proved")
8959  elif r == unknown:
8960  print("failed to prove")
8961  print(s.model())
8962  else:
8963  print("counterexample")
8964  print(s.model())
8965 
8966 
def prove(claim, show=False, **keywords)
Definition: z3py.py:8939

◆ Q()

def z3py.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 3197 of file z3py.py.

3197 def Q(a, b, ctx=None):
3198  """Return a Z3 rational a/b.
3199 
3200  If `ctx=None`, then the global context is used.
3201 
3202  >>> Q(3,5)
3203  3/5
3204  >>> Q(3,5).sort()
3205  Real
3206  """
3207  return simplify(RatVal(a, b))
3208 
3209 
def simplify(a, *arguments, **keywords)
Utils.
Definition: z3py.py:8645
def Q(a, b, ctx=None)
Definition: z3py.py:3197
def RatVal(a, b, ctx=None)
Definition: z3py.py:3181

◆ Range()

def z3py.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 11033 of file z3py.py.

11033 def Range(lo, hi, ctx=None):
11034  """Create the range regular expression over two sequences of length 1
11035  >>> range = Range("a","z")
11036  >>> print(simplify(InRe("b", range)))
11037  True
11038  >>> print(simplify(InRe("bb", range)))
11039  False
11040  """
11041  lo = _coerce_seq(lo, ctx)
11042  hi = _coerce_seq(hi, ctx)
11043  return ReRef(Z3_mk_re_range(lo.ctx_ref(), lo.ast, hi.ast), lo.ctx)
11044 
11045 # Special Relations
11046 
11047 
def Range(lo, hi, ctx=None)
Definition: z3py.py:11033
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()

def z3py.RatVal (   a,
  b,
  ctx = None 
)
Return a Z3 rational a/b.

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

>>> RatVal(3,5)
3/5
>>> RatVal(3,5).sort()
Real

Definition at line 3181 of file z3py.py.

3181 def RatVal(a, b, ctx=None):
3182  """Return a Z3 rational a/b.
3183 
3184  If `ctx=None`, then the global context is used.
3185 
3186  >>> RatVal(3,5)
3187  3/5
3188  >>> RatVal(3,5).sort()
3189  Real
3190  """
3191  if z3_debug():
3192  _z3_assert(_is_int(a) or isinstance(a, str), "First argument cannot be converted into an integer")
3193  _z3_assert(_is_int(b) or isinstance(b, str), "Second argument cannot be converted into an integer")
3194  return simplify(RealVal(a, ctx) / RealVal(b, ctx))
3195 
3196 

Referenced by Q().

◆ Re()

def z3py.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 10885 of file z3py.py.

10885 def Re(s, ctx=None):
10886  """The regular expression that accepts sequence 's'
10887  >>> s1 = Re("ab")
10888  >>> s2 = Re(StringVal("ab"))
10889  >>> s3 = Re(Unit(BoolVal(True)))
10890  """
10891  s = _coerce_seq(s, ctx)
10892  return ReRef(Z3_mk_seq_to_re(s.ctx_ref(), s.as_ast()), s.ctx)
10893 
10894 
10895 # Regular expressions
10896 
def Re(s, ctx=None)
Definition: z3py.py:10885
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()

def z3py.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 3263 of file z3py.py.

3263 def Real(name, ctx=None):
3264  """Return a real constant named `name`. If `ctx=None`, then the global context is used.
3265 
3266  >>> x = Real('x')
3267  >>> is_real(x)
3268  True
3269  >>> is_real(x + 1)
3270  True
3271  """
3272  ctx = _get_ctx(ctx)
3273  return ArithRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), RealSort(ctx).ast), ctx)
3274 
3275 
def Real(name, ctx=None)
Definition: z3py.py:3263

Referenced by Reals(), and RealVector().

◆ Reals()

def z3py.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 3276 of file z3py.py.

3276 def Reals(names, ctx=None):
3277  """Return a tuple of real constants.
3278 
3279  >>> x, y, z = Reals('x y z')
3280  >>> Sum(x, y, z)
3281  x + y + z
3282  >>> Sum(x, y, z).sort()
3283  Real
3284  """
3285  ctx = _get_ctx(ctx)
3286  if isinstance(names, str):
3287  names = names.split(" ")
3288  return [Real(name, ctx) for name in names]
3289 
3290 
def Reals(names, ctx=None)
Definition: z3py.py:3276

◆ RealSort()

def z3py.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 3117 of file z3py.py.

3117 def RealSort(ctx=None):
3118  """Return the real sort in the given context. If `ctx=None`, then the global context is used.
3119 
3120  >>> RealSort()
3121  Real
3122  >>> x = Const('x', RealSort())
3123  >>> is_real(x)
3124  True
3125  >>> is_int(x)
3126  False
3127  >>> x.sort() == RealSort()
3128  True
3129  """
3130  ctx = _get_ctx(ctx)
3131  return ArithSortRef(Z3_mk_real_sort(ctx.ref()), ctx)
3132 
3133 
Z3_sort Z3_API Z3_mk_real_sort(Z3_context c)
Create the real type.

Referenced by FreshReal(), Real(), RealVal(), and RealVar().

◆ RealVal()

def z3py.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 3162 of file z3py.py.

3162 def RealVal(val, ctx=None):
3163  """Return a Z3 real value.
3164 
3165  `val` may be a Python int, long, float or string representing a number in decimal or rational notation.
3166  If `ctx=None`, then the global context is used.
3167 
3168  >>> RealVal(1)
3169  1
3170  >>> RealVal(1).sort()
3171  Real
3172  >>> RealVal("3/5")
3173  3/5
3174  >>> RealVal("1.5")
3175  3/2
3176  """
3177  ctx = _get_ctx(ctx)
3178  return RatNumRef(Z3_mk_numeral(ctx.ref(), str(val), RealSort(ctx).ast), ctx)
3179 
3180 

Referenced by Cbrt(), AlgebraicNumRef.index(), RatVal(), and Sqrt().

◆ RealVar()

def z3py.RealVar (   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 1451 of file z3py.py.

1451 def RealVar(idx, ctx=None):
1452  """
1453  Create a real free variable. Free variables are used to create quantified formulas.
1454  They are also used to create polynomials.
1455 
1456  >>> RealVar(0)
1457  Var(0)
1458  """
1459  return Var(idx, RealSort(ctx))
1460 
1461 
def Var(idx, s)
Definition: z3py.py:1438
def RealVar(idx, ctx=None)
Definition: z3py.py:1451

Referenced by RealVarVector().

◆ RealVarVector()

def z3py.RealVarVector (   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 1462 of file z3py.py.

1462 def RealVarVector(n, ctx=None):
1463  """
1464  Create a list of Real free variables.
1465  The variables have ids: 0, 1, ..., n-1
1466 
1467  >>> x0, x1, x2, x3 = RealVarVector(4)
1468  >>> x2
1469  Var(2)
1470  """
1471  return [RealVar(i, ctx) for i in range(n)]
1472 
def RealVarVector(n, ctx=None)
Definition: z3py.py:1462

◆ RealVector()

def z3py.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 3291 of file z3py.py.

3291 def RealVector(prefix, sz, ctx=None):
3292  """Return a list of real constants of size `sz`.
3293 
3294  >>> X = RealVector('x', 3)
3295  >>> X
3296  [x__0, x__1, x__2]
3297  >>> Sum(X)
3298  x__0 + x__1 + x__2
3299  >>> Sum(X).sort()
3300  Real
3301  """
3302  ctx = _get_ctx(ctx)
3303  return [Real("%s__%s" % (prefix, i), ctx) for i in range(sz)]
3304 
3305 
def RealVector(prefix, sz, ctx=None)
Definition: z3py.py:3291

◆ RecAddDefinition()

def z3py.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 924 of file z3py.py.

924 def RecAddDefinition(f, args, body):
925  """Set the body of a recursive function.
926  Recursive definitions can be simplified if they are applied to ground
927  arguments.
928  >>> ctx = Context()
929  >>> fac = RecFunction('fac', IntSort(ctx), IntSort(ctx))
930  >>> n = Int('n', ctx)
931  >>> RecAddDefinition(fac, n, If(n == 0, 1, n*fac(n-1)))
932  >>> simplify(fac(5))
933  120
934  >>> s = Solver(ctx=ctx)
935  >>> s.add(fac(n) < 3)
936  >>> s.check()
937  sat
938  >>> s.model().eval(fac(5))
939  120
940  """
941  if is_app(args):
942  args = [args]
943  ctx = body.ctx
944  args = _get_args(args)
945  n = len(args)
946  _args = (Ast * n)()
947  for i in range(n):
948  _args[i] = args[i].ast
949  Z3_add_rec_def(ctx.ref(), f.ast, n, _args, body.ast)
950 
def RecAddDefinition(f, args, body)
Definition: z3py.py:924
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()

def z3py.RecFunction (   name,
sig 
)
Create a new Z3 recursive with the given sorts.

Definition at line 906 of file z3py.py.

906 def RecFunction(name, *sig):
907  """Create a new Z3 recursive with the given sorts."""
908  sig = _get_args(sig)
909  if z3_debug():
910  _z3_assert(len(sig) > 0, "At least two arguments expected")
911  arity = len(sig) - 1
912  rng = sig[arity]
913  if z3_debug():
914  _z3_assert(is_sort(rng), "Z3 sort expected")
915  dom = (Sort * arity)()
916  for i in range(arity):
917  if z3_debug():
918  _z3_assert(is_sort(sig[i]), "Z3 sort expected")
919  dom[i] = sig[i].ast
920  ctx = rng.ctx
921  return FuncDeclRef(Z3_mk_rec_func_decl(ctx.ref(), to_symbol(name, ctx), arity, dom, rng.ast), ctx)
922 
923 
def RecFunction(name, *sig)
Definition: z3py.py:906
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()

def z3py.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 8293 of file z3py.py.

8293 def Repeat(t, max=4294967295, ctx=None):
8294  """Return a tactic that keeps applying `t` until the goal is not modified anymore
8295  or the maximum number of iterations `max` is reached.
8296 
8297  >>> x, y = Ints('x y')
8298  >>> c = And(Or(x == 0, x == 1), Or(y == 0, y == 1), x > y)
8299  >>> t = Repeat(OrElse(Tactic('split-clause'), Tactic('skip')))
8300  >>> r = t(c)
8301  >>> for subgoal in r: print(subgoal)
8302  [x == 0, y == 0, x > y]
8303  [x == 0, y == 1, x > y]
8304  [x == 1, y == 0, x > y]
8305  [x == 1, y == 1, x > y]
8306  >>> t = Then(t, Tactic('propagate-values'))
8307  >>> t(c)
8308  [[x == 1, y == 0]]
8309  """
8310  t = _to_tactic(t, ctx)
8311  return Tactic(Z3_tactic_repeat(t.ctx.ref(), t.tactic, max), t.ctx)
8312 
8313 
def Repeat(t, max=4294967295, ctx=None)
Definition: z3py.py:8293
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()

def z3py.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 4383 of file z3py.py.

4383 def RepeatBitVec(n, a):
4384  """Return an expression representing `n` copies of `a`.
4385 
4386  >>> x = BitVec('x', 8)
4387  >>> n = RepeatBitVec(4, x)
4388  >>> n
4389  RepeatBitVec(4, x)
4390  >>> n.size()
4391  32
4392  >>> v0 = BitVecVal(10, 4)
4393  >>> print("%.x" % v0.as_long())
4394  a
4395  >>> v = simplify(RepeatBitVec(4, v0))
4396  >>> v.size()
4397  16
4398  >>> print("%.x" % v.as_long())
4399  aaaa
4400  """
4401  if z3_debug():
4402  _z3_assert(_is_int(n), "First argument must be an integer")
4403  _z3_assert(is_bv(a), "Second argument must be a Z3 bit-vector expression")
4404  return BitVecRef(Z3_mk_repeat(a.ctx_ref(), n, a.as_ast()), a.ctx)
4405 
4406 
def RepeatBitVec(n, a)
Definition: z3py.py:4383
Z3_ast Z3_API Z3_mk_repeat(Z3_context c, unsigned i, Z3_ast t1)
Repeat the given bit-vector up length i.

◆ Replace()

def z3py.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 10808 of file z3py.py.

10808 def Replace(s, src, dst):
10809  """Replace the first occurrence of 'src' by 'dst' in 's'
10810  >>> r = Replace("aaa", "a", "b")
10811  >>> simplify(r)
10812  "baa"
10813  """
10814  ctx = _get_ctx2(dst, s)
10815  if ctx is None and is_expr(src):
10816  ctx = src.ctx
10817  src = _coerce_seq(src, ctx)
10818  dst = _coerce_seq(dst, ctx)
10819  s = _coerce_seq(s, ctx)
10820  return SeqRef(Z3_mk_seq_replace(src.ctx_ref(), s.as_ast(), src.as_ast(), dst.as_ast()), s.ctx)
10821 
10822 
def Replace(s, src, dst)
Definition: z3py.py:10808
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()

def z3py.reset_params ( )
Reset all global (or module) parameters.

Definition at line 294 of file z3py.py.

294 def reset_params():
295  """Reset all global (or module) parameters.
296  """
298 
299 
def reset_params()
Definition: z3py.py:294
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()

def z3py.ReSort (   s)

Definition at line 10904 of file z3py.py.

10904 def ReSort(s):
10905  if is_ast(s):
10906  return ReSortRef(Z3_mk_re_sort(s.ctx.ref(), s.ast), s.ctx)
10907  if s is None or isinstance(s, Context):
10908  ctx = _get_ctx(s)
10909  return ReSortRef(Z3_mk_re_sort(ctx.ref(), Z3_mk_string_sort(ctx.ref())), s.ctx)
10910  raise Z3Exception("Regular expression sort constructor expects either a string or a context or no argument")
10911 
10912 
def ReSort(s)
Definition: z3py.py:10904
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 8 bit strings.

◆ RNA()

def z3py.RNA (   ctx = None)

Definition at line 9507 of file z3py.py.

9507 def RNA(ctx=None):
9508  ctx = _get_ctx(ctx)
9509  return FPRMRef(Z3_mk_fpa_round_nearest_ties_to_away(ctx.ref()), ctx)
9510 
9511 
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.

Referenced by get_default_rounding_mode().

◆ RNE()

def z3py.RNE (   ctx = None)

Definition at line 9497 of file z3py.py.

9497 def RNE(ctx=None):
9498  ctx = _get_ctx(ctx)
9499  return FPRMRef(Z3_mk_fpa_round_nearest_ties_to_even(ctx.ref()), ctx)
9500 
9501 
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.

Referenced by get_default_rounding_mode().

◆ RotateLeft()

def z3py.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 4293 of file z3py.py.

4293 def RotateLeft(a, b):
4294  """Return an expression representing `a` rotated to the left `b` times.
4295 
4296  >>> a, b = BitVecs('a b', 16)
4297  >>> RotateLeft(a, b)
4298  RotateLeft(a, b)
4299  >>> simplify(RotateLeft(a, 0))
4300  a
4301  >>> simplify(RotateLeft(a, 16))
4302  a
4303  """
4304  _check_bv_args(a, b)
4305  a, b = _coerce_exprs(a, b)
4306  return BitVecRef(Z3_mk_ext_rotate_left(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4307 
4308 
def RotateLeft(a, b)
Definition: z3py.py:4293
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()

def z3py.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 4309 of file z3py.py.

4309 def RotateRight(a, b):
4310  """Return an expression representing `a` rotated to the right `b` times.
4311 
4312  >>> a, b = BitVecs('a b', 16)
4313  >>> RotateRight(a, b)
4314  RotateRight(a, b)
4315  >>> simplify(RotateRight(a, 0))
4316  a
4317  >>> simplify(RotateRight(a, 16))
4318  a
4319  """
4320  _check_bv_args(a, b)
4321  a, b = _coerce_exprs(a, b)
4322  return BitVecRef(Z3_mk_ext_rotate_right(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4323 
4324 
def RotateRight(a, b)
Definition: z3py.py:4309
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()

def z3py.RoundNearestTiesToAway (   ctx = None)

Definition at line 9502 of file z3py.py.

9502 def RoundNearestTiesToAway(ctx=None):
9503  ctx = _get_ctx(ctx)
9504  return FPRMRef(Z3_mk_fpa_round_nearest_ties_to_away(ctx.ref()), ctx)
9505 
9506 
def RoundNearestTiesToAway(ctx=None)
Definition: z3py.py:9502

◆ RoundNearestTiesToEven()

def z3py.RoundNearestTiesToEven (   ctx = None)

Definition at line 9492 of file z3py.py.

9492 def RoundNearestTiesToEven(ctx=None):
9493  ctx = _get_ctx(ctx)
9494  return FPRMRef(Z3_mk_fpa_round_nearest_ties_to_even(ctx.ref()), ctx)
9495 
9496 
def RoundNearestTiesToEven(ctx=None)
Definition: z3py.py:9492

◆ RoundTowardNegative()

def z3py.RoundTowardNegative (   ctx = None)

Definition at line 9522 of file z3py.py.

9522 def RoundTowardNegative(ctx=None):
9523  ctx = _get_ctx(ctx)
9524  return FPRMRef(Z3_mk_fpa_round_toward_negative(ctx.ref()), ctx)
9525 
9526 
def RoundTowardNegative(ctx=None)
Definition: z3py.py:9522
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()

def z3py.RoundTowardPositive (   ctx = None)

Definition at line 9512 of file z3py.py.

9512 def RoundTowardPositive(ctx=None):
9513  ctx = _get_ctx(ctx)
9514  return FPRMRef(Z3_mk_fpa_round_toward_positive(ctx.ref()), ctx)
9515 
9516 
def RoundTowardPositive(ctx=None)
Definition: z3py.py:9512
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()

def z3py.RoundTowardZero (   ctx = None)

Definition at line 9532 of file z3py.py.

9532 def RoundTowardZero(ctx=None):
9533  ctx = _get_ctx(ctx)
9534  return FPRMRef(Z3_mk_fpa_round_toward_zero(ctx.ref()), ctx)
9535 
9536 
def RoundTowardZero(ctx=None)
Definition: z3py.py:9532
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()

def z3py.RTN (   ctx = None)

Definition at line 9527 of file z3py.py.

9527 def RTN(ctx=None):
9528  ctx = _get_ctx(ctx)
9529  return FPRMRef(Z3_mk_fpa_round_toward_negative(ctx.ref()), ctx)
9530 
9531 

Referenced by get_default_rounding_mode().

◆ RTP()

def z3py.RTP (   ctx = None)

Definition at line 9517 of file z3py.py.

9517 def RTP(ctx=None):
9518  ctx = _get_ctx(ctx)
9519  return FPRMRef(Z3_mk_fpa_round_toward_positive(ctx.ref()), ctx)
9520 
9521 

Referenced by get_default_rounding_mode().

◆ RTZ()

def z3py.RTZ (   ctx = None)

Definition at line 9537 of file z3py.py.

9537 def RTZ(ctx=None):
9538  ctx = _get_ctx(ctx)
9539  return FPRMRef(Z3_mk_fpa_round_toward_zero(ctx.ref()), ctx)
9540 
9541 

Referenced by get_default_rounding_mode().

◆ Select()

def z3py.Select (   a,
  i 
)
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 4742 of file z3py.py.

4742 def Select(a, i):
4743  """Return a Z3 select array expression.
4744 
4745  >>> a = Array('a', IntSort(), IntSort())
4746  >>> i = Int('i')
4747  >>> Select(a, i)
4748  a[i]
4749  >>> eq(Select(a, i), a[i])
4750  True
4751  """
4752  if z3_debug():
4753  _z3_assert(is_array_sort(a), "First argument must be a Z3 array expression")
4754  return a[i]
4755 
4756 
def Select(a, i)
Definition: z3py.py:4742

◆ SeqSort()

def z3py.SeqSort (   s)
Create a sequence sort over elements provided in the argument
>>> s = SeqSort(IntSort())
>>> s == Unit(IntVal(1)).sort()
True

Definition at line 10579 of file z3py.py.

10579 def SeqSort(s):
10580  """Create a sequence sort over elements provided in the argument
10581  >>> s = SeqSort(IntSort())
10582  >>> s == Unit(IntVal(1)).sort()
10583  True
10584  """
10585  return SeqSortRef(Z3_mk_seq_sort(s.ctx_ref(), s.ast), s.ctx)
10586 
10587 
def SeqSort(s)
Definition: z3py.py:10579
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()

def z3py.set_default_fp_sort (   ebits,
  sbits,
  ctx = None 
)

Definition at line 9153 of file z3py.py.

9153 def set_default_fp_sort(ebits, sbits, ctx=None):
9154  global _dflt_fpsort_ebits
9155  global _dflt_fpsort_sbits
9156  _dflt_fpsort_ebits = ebits
9157  _dflt_fpsort_sbits = sbits
9158 
9159 
def set_default_fp_sort(ebits, sbits, ctx=None)
Definition: z3py.py:9153

◆ set_default_rounding_mode()

def z3py.set_default_rounding_mode (   rm,
  ctx = None 
)

Definition at line 9140 of file z3py.py.

9140 def set_default_rounding_mode(rm, ctx=None):
9141  global _dflt_rounding_mode
9142  if is_fprm_value(rm):
9143  _dflt_rounding_mode = rm.decl().kind()
9144  else:
9145  _z3_assert(_dflt_rounding_mode in _ROUNDING_MODES, "illegal rounding mode")
9146  _dflt_rounding_mode = rm
9147 
9148 
def set_default_rounding_mode(rm, ctx=None)
Definition: z3py.py:9140

◆ set_option()

def z3py.set_option ( args,
**  kws 
)
Alias for 'set_param' for backward compatibility.

Definition at line 300 of file z3py.py.

300 def set_option(*args, **kws):
301  """Alias for 'set_param' for backward compatibility.
302  """
303  return set_param(*args, **kws)
304 
305 
def set_option(*args, **kws)
Definition: z3py.py:300
def set_param(*args, **kws)
Definition: z3py.py:270

◆ set_param()

def z3py.set_param ( args,
**  kws 
)
Set Z3 global (or module) parameters.

>>> set_param(precision=10)

Definition at line 270 of file z3py.py.

270 def set_param(*args, **kws):
271  """Set Z3 global (or module) parameters.
272 
273  >>> set_param(precision=10)
274  """
275  if z3_debug():
276  _z3_assert(len(args) % 2 == 0, "Argument list must have an even number of elements.")
277  new_kws = {}
278  for k in kws:
279  v = kws[k]
280  if not set_pp_option(k, v):
281  new_kws[k] = v
282  for key in new_kws:
283  value = new_kws[key]
284  Z3_global_param_set(str(key).upper(), _to_param_value(value))
285  prev = None
286  for a in args:
287  if prev is None:
288  prev = a
289  else:
290  Z3_global_param_set(str(prev), _to_param_value(a))
291  prev = None
292 
293 
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()

def z3py.SetAdd (   s,
  e 
)
 Add element e to set s
>>> a = Const('a', SetSort(IntSort()))
>>> SetAdd(a, 1)
Store(a, 1, True)

Definition at line 4900 of file z3py.py.

4900 def SetAdd(s, e):
4901  """ Add element e to set s
4902  >>> a = Const('a', SetSort(IntSort()))
4903  >>> SetAdd(a, 1)
4904  Store(a, 1, True)
4905  """
4906  ctx = _ctx_from_ast_arg_list([s, e])
4907  e = _py2expr(e, ctx)
4908  return ArrayRef(Z3_mk_set_add(ctx.ref(), s.as_ast(), e.as_ast()), ctx)
4909 
4910 
def SetAdd(s, e)
Definition: z3py.py:4900
Z3_ast Z3_API Z3_mk_set_add(Z3_context c, Z3_ast set, Z3_ast elem)
Add an element to a set.

◆ SetComplement()

def z3py.SetComplement (   s)
 The complement of set s
>>> a = Const('a', SetSort(IntSort()))
>>> SetComplement(a)
complement(a)

Definition at line 4922 of file z3py.py.

4922 def SetComplement(s):
4923  """ The complement of set s
4924  >>> a = Const('a', SetSort(IntSort()))
4925  >>> SetComplement(a)
4926  complement(a)
4927  """
4928  ctx = s.ctx
4929  return ArrayRef(Z3_mk_set_complement(ctx.ref(), s.as_ast()), ctx)
4930 
4931 
def SetComplement(s)
Definition: z3py.py:4922
Z3_ast Z3_API Z3_mk_set_complement(Z3_context c, Z3_ast arg)
Take the complement of a set.

◆ SetDel()

def z3py.SetDel (   s,
  e 
)
 Remove element e to set s
>>> a = Const('a', SetSort(IntSort()))
>>> SetDel(a, 1)
Store(a, 1, False)

Definition at line 4911 of file z3py.py.

4911 def SetDel(s, e):
4912  """ Remove element e to set s
4913  >>> a = Const('a', SetSort(IntSort()))
4914  >>> SetDel(a, 1)
4915  Store(a, 1, False)
4916  """
4917  ctx = _ctx_from_ast_arg_list([s, e])
4918  e = _py2expr(e, ctx)
4919  return ArrayRef(Z3_mk_set_del(ctx.ref(), s.as_ast(), e.as_ast()), ctx)
4920 
4921 
def SetDel(s, e)
Definition: z3py.py:4911
Z3_ast Z3_API Z3_mk_set_del(Z3_context c, Z3_ast set, Z3_ast elem)
Remove an element to a set.

◆ SetDifference()

def z3py.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 4932 of file z3py.py.

4932 def SetDifference(a, b):
4933  """ The set difference of a and b
4934  >>> a = Const('a', SetSort(IntSort()))
4935  >>> b = Const('b', SetSort(IntSort()))
4936  >>> SetDifference(a, b)
4937  setminus(a, b)
4938  """
4939  ctx = _ctx_from_ast_arg_list([a, b])
4940  return ArrayRef(Z3_mk_set_difference(ctx.ref(), a.as_ast(), b.as_ast()), ctx)
4941 
4942 
def SetDifference(a, b)
Definition: z3py.py:4932
Z3_ast Z3_API Z3_mk_set_difference(Z3_context c, Z3_ast arg1, Z3_ast arg2)
Take the set difference between two sets.

◆ SetHasSize()

def z3py.SetHasSize (   a,
  k 
)

Definition at line 4814 of file z3py.py.

4814 def SetHasSize(a, k):
4815  ctx = a.ctx
4816  k = _py2expr(k, ctx)
4817  return _to_expr_ref(Z3_mk_set_has_size(ctx.ref(), a.as_ast(), k.as_ast()), ctx)
4818 
4819 
def SetHasSize(a, k)
Definition: z3py.py:4814
Z3_ast Z3_API Z3_mk_set_has_size(Z3_context c, Z3_ast set, Z3_ast k)
Create predicate that holds if Boolean array set has k elements set to true.

◆ SetIntersect()

def z3py.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 4887 of file z3py.py.

4887 def SetIntersect(*args):
4888  """ Take the union of sets
4889  >>> a = Const('a', SetSort(IntSort()))
4890  >>> b = Const('b', SetSort(IntSort()))
4891  >>> SetIntersect(a, b)
4892  intersection(a, b)
4893  """
4894  args = _get_args(args)
4895  ctx = _ctx_from_ast_arg_list(args)
4896  _args, sz = _to_ast_array(args)
4897  return ArrayRef(Z3_mk_set_intersect(ctx.ref(), sz, _args), ctx)
4898 
4899 
def SetIntersect(*args)
Definition: z3py.py:4887
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()

def z3py.SetSort (   s)

Sets.

 Create a set sort over element sort s

Definition at line 4851 of file z3py.py.

4851 def SetSort(s):
4852  """ Create a set sort over element sort s"""
4853  return ArraySort(s, BoolSort())
4854 
4855 
def SetSort(s)
Sets.
Definition: z3py.py:4851

◆ SetUnion()

def z3py.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 4874 of file z3py.py.

4874 def SetUnion(*args):
4875  """ Take the union of sets
4876  >>> a = Const('a', SetSort(IntSort()))
4877  >>> b = Const('b', SetSort(IntSort()))
4878  >>> SetUnion(a, b)
4879  union(a, b)
4880  """
4881  args = _get_args(args)
4882  ctx = _ctx_from_ast_arg_list(args)
4883  _args, sz = _to_ast_array(args)
4884  return ArrayRef(Z3_mk_set_union(ctx.ref(), sz, _args), ctx)
4885 
4886 
def SetUnion(*args)
Definition: z3py.py:4874
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()

def z3py.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 4325 of file z3py.py.

4325 def SignExt(n, a):
4326  """Return a bit-vector expression with `n` extra sign-bits.
4327 
4328  >>> x = BitVec('x', 16)
4329  >>> n = SignExt(8, x)
4330  >>> n.size()
4331  24
4332  >>> n
4333  SignExt(8, x)
4334  >>> n.sort()
4335  BitVec(24)
4336  >>> v0 = BitVecVal(2, 2)
4337  >>> v0
4338  2
4339  >>> v0.size()
4340  2
4341  >>> v = simplify(SignExt(6, v0))
4342  >>> v
4343  254
4344  >>> v.size()
4345  8
4346  >>> print("%.x" % v.as_long())
4347  fe
4348  """
4349  if z3_debug():
4350  _z3_assert(_is_int(n), "First argument must be an integer")
4351  _z3_assert(is_bv(a), "Second argument must be a Z3 bit-vector expression")
4352  return BitVecRef(Z3_mk_sign_ext(a.ctx_ref(), n, a.as_ast()), a.ctx)
4353 
4354 
def SignExt(n, a)
Definition: z3py.py:4325
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()

def z3py.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 7293 of file z3py.py.

7293 def SimpleSolver(ctx=None, logFile=None):
7294  """Return a simple general purpose solver with limited amount of preprocessing.
7295 
7296  >>> s = SimpleSolver()
7297  >>> x = Int('x')
7298  >>> s.add(x > 0)
7299  >>> s.check()
7300  sat
7301  """
7302  ctx = _get_ctx(ctx)
7303  return Solver(Z3_mk_simple_solver(ctx.ref()), ctx, logFile)
7304 
def SimpleSolver(ctx=None, logFile=None)
Definition: z3py.py:7293
Z3_solver Z3_API Z3_mk_simple_solver(Z3_context c)
Create a new incremental solver.

◆ simplify()

def z3py.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 8645 of file z3py.py.

8645 def simplify(a, *arguments, **keywords):
8646  """Simplify the expression `a` using the given options.
8647 
8648  This function has many options. Use `help_simplify` to obtain the complete list.
8649 
8650  >>> x = Int('x')
8651  >>> y = Int('y')
8652  >>> simplify(x + 1 + y + x + 1)
8653  2 + 2*x + y
8654  >>> simplify((x + 1)*(y + 1), som=True)
8655  1 + x + y + x*y
8656  >>> simplify(Distinct(x, y, 1), blast_distinct=True)
8657  And(Not(x == y), Not(x == 1), Not(y == 1))
8658  >>> simplify(And(x == 0, y == 1), elim_and=True)
8659  Not(Or(Not(x == 0), Not(y == 1)))
8660  """
8661  if z3_debug():
8662  _z3_assert(is_expr(a), "Z3 expression expected")
8663  if len(arguments) > 0 or len(keywords) > 0:
8664  p = args2params(arguments, keywords, a.ctx)
8665  return _to_expr_ref(Z3_simplify_ex(a.ctx_ref(), a.as_ast(), p.params), a.ctx)
8666  else:
8667  return _to_expr_ref(Z3_simplify(a.ctx_ref(), a.as_ast()), a.ctx)
8668 
8669 
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()

def z3py.simplify_param_descrs ( )
Return the set of parameter descriptions for Z3 `simplify` procedure.

Definition at line 8675 of file z3py.py.

8675 def simplify_param_descrs():
8676  """Return the set of parameter descriptions for Z3 `simplify` procedure."""
8677  return ParamDescrsRef(Z3_simplify_get_param_descrs(main_ctx().ref()), main_ctx())
8678 
8679 
def simplify_param_descrs()
Definition: z3py.py:8675
Z3_param_descrs Z3_API Z3_simplify_get_param_descrs(Z3_context c)
Return the parameter description set for the simplify procedure.

◆ solve()

def z3py.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 8878 of file z3py.py.

8878 def solve(*args, **keywords):
8879  """Solve the constraints `*args`.
8880 
8881  This is a simple function for creating demonstrations. It creates a solver,
8882  configure it using the options in `keywords`, adds the constraints
8883  in `args`, and invokes check.
8884 
8885  >>> a = Int('a')
8886  >>> solve(a > 0, a < 2)
8887  [a = 1]
8888  """
8889  show = keywords.pop("show", False)
8890  s = Solver()
8891  s.set(**keywords)
8892  s.add(*args)
8893  if show:
8894  print(s)
8895  r = s.check()
8896  if r == unsat:
8897  print("no solution")
8898  elif r == unknown:
8899  print("failed to solve")
8900  try:
8901  print(s.model())
8902  except Z3Exception:
8903  return
8904  else:
8905  print(s.model())
8906 
8907 
def solve(*args, **keywords)
Definition: z3py.py:8878

◆ solve_using()

def z3py.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 8908 of file z3py.py.

8908 def solve_using(s, *args, **keywords):
8909  """Solve the constraints `*args` using solver `s`.
8910 
8911  This is a simple function for creating demonstrations. It is similar to `solve`,
8912  but it uses the given solver `s`.
8913  It configures solver `s` using the options in `keywords`, adds the constraints
8914  in `args`, and invokes check.
8915  """
8916  show = keywords.pop("show", False)
8917  if z3_debug():
8918  _z3_assert(isinstance(s, Solver), "Solver object expected")
8919  s.set(**keywords)
8920  s.add(*args)
8921  if show:
8922  print("Problem:")
8923  print(s)
8924  r = s.check()
8925  if r == unsat:
8926  print("no solution")
8927  elif r == unknown:
8928  print("failed to solve")
8929  try:
8930  print(s.model())
8931  except Z3Exception:
8932  return
8933  else:
8934  if show:
8935  print("Solution:")
8936  print(s.model())
8937 
8938 
def solve_using(s, *args, **keywords)
Definition: z3py.py:8908

◆ SolverFor()

def z3py.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 7272 of file z3py.py.

7272 def SolverFor(logic, ctx=None, logFile=None):
7273  """Create a solver customized for the given logic.
7274 
7275  The parameter `logic` is a string. It should be contains
7276  the name of a SMT-LIB logic.
7277  See http://www.smtlib.org/ for the name of all available logics.
7278 
7279  >>> s = SolverFor("QF_LIA")
7280  >>> x = Int('x')
7281  >>> s.add(x > 0)
7282  >>> s.add(x < 2)
7283  >>> s.check()
7284  sat
7285  >>> s.model()
7286  [x = 1]
7287  """
7288  ctx = _get_ctx(ctx)
7289  logic = to_symbol(logic)
7290  return Solver(Z3_mk_solver_for_logic(ctx.ref(), logic), ctx, logFile)
7291 
7292 
def SolverFor(logic, ctx=None, logFile=None)
Definition: z3py.py:7272
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()

def z3py.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 3373 of file z3py.py.

3373 def Sqrt(a, ctx=None):
3374  """ Return a Z3 expression which represents the square root of a.
3375 
3376  >>> x = Real('x')
3377  >>> Sqrt(x)
3378  x**(1/2)
3379  """
3380  if not is_expr(a):
3381  ctx = _get_ctx(ctx)
3382  a = RealVal(a, ctx)
3383  return a ** "1/2"
3384 
3385 
def Sqrt(a, ctx=None)
Definition: z3py.py:3373

◆ SRem()

def z3py.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 4240 of file z3py.py.

4240 def SRem(a, b):
4241  """Create the Z3 expression signed remainder.
4242 
4243  Use the operator % for signed modulus, and URem() for unsigned remainder.
4244 
4245  >>> x = BitVec('x', 32)
4246  >>> y = BitVec('y', 32)
4247  >>> SRem(x, y)
4248  SRem(x, y)
4249  >>> SRem(x, y).sort()
4250  BitVec(32)
4251  >>> (x % y).sexpr()
4252  '(bvsmod x y)'
4253  >>> SRem(x, y).sexpr()
4254  '(bvsrem x y)'
4255  """
4256  _check_bv_args(a, b)
4257  a, b = _coerce_exprs(a, b)
4258  return BitVecRef(Z3_mk_bvsrem(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4259 
4260 
def SRem(a, b)
Definition: z3py.py:4240
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()

def z3py.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 11007 of file z3py.py.

11007 def Star(re):
11008  """Create the regular expression accepting zero or more repetitions of argument.
11009  >>> re = Star(Re("a"))
11010  >>> print(simplify(InRe("aa", re)))
11011  True
11012  >>> print(simplify(InRe("ab", re)))
11013  False
11014  >>> print(simplify(InRe("", re)))
11015  True
11016  """
11017  return ReRef(Z3_mk_re_star(re.ctx_ref(), re.as_ast()), re.ctx)
11018 
11019 
def Star(re)
Definition: z3py.py:11007
Z3_ast Z3_API Z3_mk_re_star(Z3_context c, Z3_ast re)
Create the regular language re*.

◆ Store()

def z3py.Store (   a,
  i,
  v 
)
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 4725 of file z3py.py.

4725 def Store(a, i, v):
4726  """Return a Z3 store array expression.
4727 
4728  >>> a = Array('a', IntSort(), IntSort())
4729  >>> i, v = Ints('i v')
4730  >>> s = Store(a, i, v)
4731  >>> s.sort()
4732  Array(Int, Int)
4733  >>> prove(s[i] == v)
4734  proved
4735  >>> j = Int('j')
4736  >>> prove(Implies(i != j, s[j] == a[j]))
4737  proved
4738  """
4739  return Update(a, i, v)
4740 
4741 
def Update(a, i, v)
Definition: z3py.py:4692
def Store(a, i, v)
Definition: z3py.py:4725

◆ String()

def z3py.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 10693 of file z3py.py.

10693 def String(name, ctx=None):
10694  """Return a string constant named `name`. If `ctx=None`, then the global context is used.
10695 
10696  >>> x = String('x')
10697  """
10698  ctx = _get_ctx(ctx)
10699  return SeqRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), StringSort(ctx).ast), ctx)
10700 
10701 
def StringSort(ctx=None)
Definition: z3py.py:10569
def String(name, ctx=None)
Definition: z3py.py:10693

Referenced by Strings().

◆ Strings()

def z3py.Strings (   names,
  ctx = None 
)
Return a tuple of String constants. 

Definition at line 10702 of file z3py.py.

10702 def Strings(names, ctx=None):
10703  """Return a tuple of String constants. """
10704  ctx = _get_ctx(ctx)
10705  if isinstance(names, str):
10706  names = names.split(" ")
10707  return [String(name, ctx) for name in names]
10708 
10709 
def Strings(names, ctx=None)
Definition: z3py.py:10702

◆ StringSort()

def z3py.StringSort (   ctx = None)
Create a string sort
>>> s = StringSort()
>>> print(s)
String

Definition at line 10569 of file z3py.py.

10569 def StringSort(ctx=None):
10570  """Create a string sort
10571  >>> s = StringSort()
10572  >>> print(s)
10573  String
10574  """
10575  ctx = _get_ctx(ctx)
10576  return SeqSortRef(Z3_mk_string_sort(ctx.ref()), ctx)
10577 
10578 

Referenced by String().

◆ StringVal()

def z3py.StringVal (   s,
  ctx = None 
)
create a string expression

Definition at line 10686 of file z3py.py.

10686 def StringVal(s, ctx=None):
10687  """create a string expression"""
10688  s = "".join(str(ch) if ord(ch) < 128 else "\\u{%x}" % (ord(ch)) for ch in s)
10689  ctx = _get_ctx(ctx)
10690  return SeqRef(Z3_mk_lstring(ctx.ref(), len(s), s), ctx)
10691 
10692 
Z3_ast Z3_API Z3_mk_lstring(Z3_context c, unsigned len, Z3_string s)
Create a string constant out of the string that is passed in It takes the length of the string as wel...

Referenced by SeqRef.__gt__(), ExprRef.children(), Extract(), and AlgebraicNumRef.index().

◆ StrToInt()

def z3py.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 10862 of file z3py.py.

10862 def StrToInt(s):
10863  """Convert string expression to integer
10864  >>> a = StrToInt("1")
10865  >>> simplify(1 == a)
10866  True
10867  >>> b = StrToInt("2")
10868  >>> simplify(1 == b)
10869  False
10870  >>> c = StrToInt(IntToStr(2))
10871  >>> simplify(1 == c)
10872  False
10873  """
10874  s = _coerce_seq(s)
10875  return ArithRef(Z3_mk_str_to_int(s.ctx_ref(), s.as_ast()), s.ctx)
10876 
10877 
def StrToInt(s)
Definition: z3py.py:10862
Z3_ast Z3_API Z3_mk_str_to_int(Z3_context c, Z3_ast s)
Convert string to integer.

◆ SubSeq()

def z3py.SubSeq (   s,
  offset,
  length 
)
Extract substring or subsequence starting at offset

Definition at line 10715 of file z3py.py.

10715 def SubSeq(s, offset, length):
10716  """Extract substring or subsequence starting at offset"""
10717  return Extract(s, offset, length)
10718 
10719 
def SubSeq(s, offset, length)
Definition: z3py.py:10715

◆ substitute()

def z3py.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 8680 of file z3py.py.

8680 def substitute(t, *m):
8681  """Apply substitution m on t, m is a list of pairs of the form (from, to).
8682  Every occurrence in t of from is replaced with to.
8683 
8684  >>> x = Int('x')
8685  >>> y = Int('y')
8686  >>> substitute(x + 1, (x, y + 1))
8687  y + 1 + 1
8688  >>> f = Function('f', IntSort(), IntSort())
8689  >>> substitute(f(x) + f(y), (f(x), IntVal(1)), (f(y), IntVal(1)))
8690  1 + 1
8691  """
8692  if isinstance(m, tuple):
8693  m1 = _get_args(m)
8694  if isinstance(m1, list) and all(isinstance(p, tuple) for p in m1):
8695  m = m1
8696  if z3_debug():
8697  _z3_assert(is_expr(t), "Z3 expression expected")
8698  _z3_assert(all([isinstance(p, tuple) and is_expr(p[0]) and is_expr(p[1]) and p[0].sort().eq(
8699  p[1].sort()) for p in m]), "Z3 invalid substitution, expression pairs expected.")
8700  num = len(m)
8701  _from = (Ast * num)()
8702  _to = (Ast * num)()
8703  for i in range(num):
8704  _from[i] = m[i][0].as_ast()
8705  _to[i] = m[i][1].as_ast()
8706  return _to_expr_ref(Z3_substitute(t.ctx.ref(), t.as_ast(), num, _from, _to), t.ctx)
8707 
8708 
def substitute(t, *m)
Definition: z3py.py:8680
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_vars()

def z3py.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 8709 of file z3py.py.

8709 def substitute_vars(t, *m):
8710  """Substitute the free variables in t with the expression in m.
8711 
8712  >>> v0 = Var(0, IntSort())
8713  >>> v1 = Var(1, IntSort())
8714  >>> x = Int('x')
8715  >>> f = Function('f', IntSort(), IntSort(), IntSort())
8716  >>> # replace v0 with x+1 and v1 with x
8717  >>> substitute_vars(f(v0, v1), x + 1, x)
8718  f(x + 1, x)
8719  """
8720  if z3_debug():
8721  _z3_assert(is_expr(t), "Z3 expression expected")
8722  _z3_assert(all([is_expr(n) for n in m]), "Z3 invalid substitution, list of expressions expected.")
8723  num = len(m)
8724  _to = (Ast * num)()
8725  for i in range(num):
8726  _to[i] = m[i].as_ast()
8727  return _to_expr_ref(Z3_substitute_vars(t.ctx.ref(), t.as_ast(), num, _to), t.ctx)
8728 
8729 
def substitute_vars(t, *m)
Definition: z3py.py:8709
Z3_ast Z3_API Z3_substitute_vars(Z3_context c, Z3_ast a, unsigned num_exprs, Z3_ast const to[])
Substitute the free variables in a with the expressions in to. For every i smaller than num_exprs,...

◆ SubString()

def z3py.SubString (   s,
  offset,
  length 
)
Extract substring or subsequence starting at offset

Definition at line 10710 of file z3py.py.

10710 def SubString(s, offset, length):
10711  """Extract substring or subsequence starting at offset"""
10712  return Extract(s, offset, length)
10713 
10714 
def SubString(s, offset, length)
Definition: z3py.py:10710

◆ SuffixOf()

def z3py.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 10774 of file z3py.py.

10774 def SuffixOf(a, b):
10775  """Check if 'a' is a suffix of 'b'
10776  >>> s1 = SuffixOf("ab", "abc")
10777  >>> simplify(s1)
10778  False
10779  >>> s2 = SuffixOf("bc", "abc")
10780  >>> simplify(s2)
10781  True
10782  """
10783  ctx = _get_ctx2(a, b)
10784  a = _coerce_seq(a, ctx)
10785  b = _coerce_seq(b, ctx)
10786  return BoolRef(Z3_mk_seq_suffix(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
10787 
10788 
def SuffixOf(a, b)
Definition: z3py.py:10774
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()

def z3py.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 8730 of file z3py.py.

8730 def Sum(*args):
8731  """Create the sum of the Z3 expressions.
8732 
8733  >>> a, b, c = Ints('a b c')
8734  >>> Sum(a, b, c)
8735  a + b + c
8736  >>> Sum([a, b, c])
8737  a + b + c
8738  >>> A = IntVector('a', 5)
8739  >>> Sum(A)
8740  a__0 + a__1 + a__2 + a__3 + a__4
8741  """
8742  args = _get_args(args)
8743  if len(args) == 0:
8744  return 0
8745  ctx = _ctx_from_ast_arg_list(args)
8746  if ctx is None:
8747  return _reduce(lambda a, b: a + b, args, 0)
8748  args = _coerce_expr_list(args, ctx)
8749  if is_bv(args[0]):
8750  return _reduce(lambda a, b: a + b, args, 0)
8751  else:
8752  _args, sz = _to_ast_array(args)
8753  return ArithRef(Z3_mk_add(ctx.ref(), sz, _args), ctx)
8754 
8755 
def Sum(*args)
Definition: z3py.py:8730
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()

def z3py.tactic_description (   name,
  ctx = None 
)
Return a short description for the tactic named `name`.

>>> d = tactic_description('simplify')

Definition at line 8334 of file z3py.py.

8334 def tactic_description(name, ctx=None):
8335  """Return a short description for the tactic named `name`.
8336 
8337  >>> d = tactic_description('simplify')
8338  """
8339  ctx = _get_ctx(ctx)
8340  return Z3_tactic_get_descr(ctx.ref(), name)
8341 
8342 
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.

Referenced by describe_tactics().

◆ tactics()

def z3py.tactics (   ctx = None)
Return a list of all available tactics in Z3.

>>> l = tactics()
>>> l.count('simplify') == 1
True

Definition at line 8323 of file z3py.py.

8323 def tactics(ctx=None):
8324  """Return a list of all available tactics in Z3.
8325 
8326  >>> l = tactics()
8327  >>> l.count('simplify') == 1
8328  True
8329  """
8330  ctx = _get_ctx(ctx)
8331  return [Z3_get_tactic_name(ctx.ref(), i) for i in range(Z3_get_num_tactics(ctx.ref()))]
8332 
8333 
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.

Referenced by describe_tactics().

◆ Then()

def z3py.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 8191 of file z3py.py.

8191 def Then(*ts, **ks):
8192  """Return a tactic that applies the tactics in `*ts` in sequence. Shorthand for AndThen(*ts, **ks).
8193 
8194  >>> x, y = Ints('x y')
8195  >>> t = Then(Tactic('simplify'), Tactic('solve-eqs'))
8196  >>> t(And(x == 0, y > x + 1))
8197  [[Not(y <= 1)]]
8198  >>> t(And(x == 0, y > x + 1)).as_expr()
8199  Not(y <= 1)
8200  """
8201  return AndThen(*ts, **ks)
8202 
8203 
def Then(*ts, **ks)
Definition: z3py.py:8191

◆ to_symbol()

def z3py.to_symbol (   s,
  ctx = None 
)
Convert an integer or string into a Z3 symbol.

Definition at line 129 of file z3py.py.

129 def to_symbol(s, ctx=None):
130  """Convert an integer or string into a Z3 symbol."""
131  if _is_int(s):
132  return Z3_mk_int_symbol(_get_ctx(ctx).ref(), s)
133  else:
134  return Z3_mk_string_symbol(_get_ctx(ctx).ref(), s)
135 
136 
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 Fixedpoint.add_rule(), Optimize.add_soft(), Array(), BitVec(), Bool(), Const(), CreateDatatypes(), DeclareSort(), EnumSort(), FiniteDomainSort(), FP(), Function(), ParamDescrsRef.get_documentation(), ParamDescrsRef.get_kind(), Int(), is_quantifier(), prove(), Real(), RecFunction(), ParamsRef.set(), Fixedpoint.set_predicate_representation(), SolverFor(), String(), and Fixedpoint.update_rule().

◆ ToInt()

def z3py.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 3338 of file z3py.py.

3338 def ToInt(a):
3339  """ Return the Z3 expression ToInt(a).
3340 
3341  >>> x = Real('x')
3342  >>> x.sort()
3343  Real
3344  >>> n = ToInt(x)
3345  >>> n
3346  ToInt(x)
3347  >>> n.sort()
3348  Int
3349  """
3350  if z3_debug():
3351  _z3_assert(a.is_real(), "Z3 real expression expected.")
3352  ctx = a.ctx
3353  return ArithRef(Z3_mk_real2int(ctx.ref(), a.as_ast()), ctx)
3354 
3355 
def ToInt(a)
Definition: z3py.py:3338
Z3_ast Z3_API Z3_mk_real2int(Z3_context c, Z3_ast t1)
Coerce a real to an integer.

◆ ToReal()

def z3py.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 3320 of file z3py.py.

3320 def ToReal(a):
3321  """ Return the Z3 expression ToReal(a).
3322 
3323  >>> x = Int('x')
3324  >>> x.sort()
3325  Int
3326  >>> n = ToReal(x)
3327  >>> n
3328  ToReal(x)
3329  >>> n.sort()
3330  Real
3331  """
3332  if z3_debug():
3333  _z3_assert(a.is_int(), "Z3 integer expression expected.")
3334  ctx = a.ctx
3335  return ArithRef(Z3_mk_int2real(ctx.ref(), a.as_ast()), ctx)
3336 
3337 
def ToReal(a)
Definition: z3py.py:3320
Z3_ast Z3_API Z3_mk_int2real(Z3_context c, Z3_ast t1)
Coerce an integer to a real.

◆ TransitiveClosure()

def z3py.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 11064 of file z3py.py.

11064 def TransitiveClosure(f):
11065  """Given a binary relation R, such that the two arguments have the same sort
11066  create the transitive closure relation R+.
11067  The transitive closure R+ is a new relation.
11068  """
11069  return FuncDeclRef(Z3_mk_transitive_closure(f.ctx_ref(), f.ast), f.ctx)
11070 
11071 
def TransitiveClosure(f)
Definition: z3py.py:11064
Z3_func_decl Z3_API Z3_mk_transitive_closure(Z3_context c, Z3_func_decl f)
create transitive closure of binary relation.

◆ TreeOrder()

def z3py.TreeOrder (   a,
  index 
)

Definition at line 11056 of file z3py.py.

11056 def TreeOrder(a, index):
11057  return FuncDeclRef(Z3_mk_tree_order(a.ctx_ref(), a.ast, index), a.ctx)
11058 
11059 
def TreeOrder(a, index)
Definition: z3py.py:11056
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()

def z3py.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 8314 of file z3py.py.

8314 def TryFor(t, ms, ctx=None):
8315  """Return a tactic that applies `t` to a given goal for `ms` milliseconds.
8316 
8317  If `t` does not terminate in `ms` milliseconds, then it fails.
8318  """
8319  t = _to_tactic(t, ctx)
8320  return Tactic(Z3_tactic_try_for(t.ctx.ref(), t.tactic, ms), t.ctx)
8321 
8322 
def TryFor(t, ms, ctx=None)
Definition: z3py.py:8314
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()

def z3py.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 5293 of file z3py.py.

5293 def TupleSort(name, sorts, ctx=None):
5294  """Create a named tuple sort base on a set of underlying sorts
5295  Example:
5296  >>> pair, mk_pair, (first, second) = TupleSort("pair", [IntSort(), StringSort()])
5297  """
5298  tuple = Datatype(name, ctx)
5299  projects = [("project%d" % i, sorts[i]) for i in range(len(sorts))]
5300  tuple.declare(name, *projects)
5301  tuple = tuple.create()
5302  return tuple, tuple.constructor(0), [tuple.accessor(0, i) for i in range(len(sorts))]
5303 
5304 
def TupleSort(name, sorts, ctx=None)
Definition: z3py.py:5293

◆ UDiv()

def z3py.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 4198 of file z3py.py.

4198 def UDiv(a, b):
4199  """Create the Z3 expression (unsigned) division `self / other`.
4200 
4201  Use the operator / for signed division.
4202 
4203  >>> x = BitVec('x', 32)
4204  >>> y = BitVec('y', 32)
4205  >>> UDiv(x, y)
4206  UDiv(x, y)
4207  >>> UDiv(x, y).sort()
4208  BitVec(32)
4209  >>> (x / y).sexpr()
4210  '(bvsdiv x y)'
4211  >>> UDiv(x, y).sexpr()
4212  '(bvudiv x y)'
4213  """
4214  _check_bv_args(a, b)
4215  a, b = _coerce_exprs(a, b)
4216  return BitVecRef(Z3_mk_bvudiv(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4217 
4218 
def UDiv(a, b)
Definition: z3py.py:4198
Z3_ast Z3_API Z3_mk_bvudiv(Z3_context c, Z3_ast t1, Z3_ast t2)
Unsigned division.

◆ UGE()

def z3py.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 4162 of file z3py.py.

4162 def UGE(a, b):
4163  """Create the Z3 expression (unsigned) `other >= self`.
4164 
4165  Use the operator >= for signed greater than or equal to.
4166 
4167  >>> x, y = BitVecs('x y', 32)
4168  >>> UGE(x, y)
4169  UGE(x, y)
4170  >>> (x >= y).sexpr()
4171  '(bvsge x y)'
4172  >>> UGE(x, y).sexpr()
4173  '(bvuge x y)'
4174  """
4175  _check_bv_args(a, b)
4176  a, b = _coerce_exprs(a, b)
4177  return BoolRef(Z3_mk_bvuge(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4178 
4179 
def UGE(a, b)
Definition: z3py.py:4162
Z3_ast Z3_API Z3_mk_bvuge(Z3_context c, Z3_ast t1, Z3_ast t2)
Unsigned greater than or equal to.

◆ UGT()

def z3py.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 4180 of file z3py.py.

4180 def UGT(a, b):
4181  """Create the Z3 expression (unsigned) `other > self`.
4182 
4183  Use the operator > for signed greater than.
4184 
4185  >>> x, y = BitVecs('x y', 32)
4186  >>> UGT(x, y)
4187  UGT(x, y)
4188  >>> (x > y).sexpr()
4189  '(bvsgt x y)'
4190  >>> UGT(x, y).sexpr()
4191  '(bvugt x y)'
4192  """
4193  _check_bv_args(a, b)
4194  a, b = _coerce_exprs(a, b)
4195  return BoolRef(Z3_mk_bvugt(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4196 
4197 
def UGT(a, b)
Definition: z3py.py:4180
Z3_ast Z3_API Z3_mk_bvugt(Z3_context c, Z3_ast t1, Z3_ast t2)
Unsigned greater than.

◆ ULE()

def z3py.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 4126 of file z3py.py.

4126 def ULE(a, b):
4127  """Create the Z3 expression (unsigned) `other <= self`.
4128 
4129  Use the operator <= for signed less than or equal to.
4130 
4131  >>> x, y = BitVecs('x y', 32)
4132  >>> ULE(x, y)
4133  ULE(x, y)
4134  >>> (x <= y).sexpr()
4135  '(bvsle x y)'
4136  >>> ULE(x, y).sexpr()
4137  '(bvule x y)'
4138  """
4139  _check_bv_args(a, b)
4140  a, b = _coerce_exprs(a, b)
4141  return BoolRef(Z3_mk_bvule(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4142 
4143 
def ULE(a, b)
Definition: z3py.py:4126
Z3_ast Z3_API Z3_mk_bvule(Z3_context c, Z3_ast t1, Z3_ast t2)
Unsigned less than or equal to.

◆ ULT()

def z3py.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 4144 of file z3py.py.

4144 def ULT(a, b):
4145  """Create the Z3 expression (unsigned) `other < self`.
4146 
4147  Use the operator < for signed less than.
4148 
4149  >>> x, y = BitVecs('x y', 32)
4150  >>> ULT(x, y)
4151  ULT(x, y)
4152  >>> (x < y).sexpr()
4153  '(bvslt x y)'
4154  >>> ULT(x, y).sexpr()
4155  '(bvult x y)'
4156  """
4157  _check_bv_args(a, b)
4158  a, b = _coerce_exprs(a, b)
4159  return BoolRef(Z3_mk_bvult(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4160 
4161 
def ULT(a, b)
Definition: z3py.py:4144
Z3_ast Z3_API Z3_mk_bvult(Z3_context c, Z3_ast t1, Z3_ast t2)
Unsigned less than.

◆ Union()

def z3py.Union ( args)
Create union of regular expressions.
>>> re = Union(Re("a"), Re("b"), Re("c"))
>>> print (simplify(InRe("d", re)))
False

Definition at line 10938 of file z3py.py.

10938 def Union(*args):
10939  """Create union of regular expressions.
10940  >>> re = Union(Re("a"), Re("b"), Re("c"))
10941  >>> print (simplify(InRe("d", re)))
10942  False
10943  """
10944  args = _get_args(args)
10945  sz = len(args)
10946  if z3_debug():
10947  _z3_assert(sz > 0, "At least one argument expected.")
10948  _z3_assert(all([is_re(a) for a in args]), "All arguments must be regular expressions.")
10949  if sz == 1:
10950  return args[0]
10951  ctx = args[0].ctx
10952  v = (Ast * sz)()
10953  for i in range(sz):
10954  v[i] = args[i].as_ast()
10955  return ReRef(Z3_mk_re_union(ctx.ref(), sz, v), ctx)
10956 
10957 
def Union(*args)
Definition: z3py.py:10938
Z3_ast Z3_API Z3_mk_re_union(Z3_context c, unsigned n, Z3_ast const args[])
Create the union of the regular languages.

Referenced by ReRef.__add__().

◆ Unit()

def z3py.Unit (   a)
Create a singleton sequence

Definition at line 10754 of file z3py.py.

10754 def Unit(a):
10755  """Create a singleton sequence"""
10756  return SeqRef(Z3_mk_seq_unit(a.ctx_ref(), a.as_ast()), a.ctx)
10757 
10758 
def Unit(a)
Definition: z3py.py:10754
Z3_ast Z3_API Z3_mk_seq_unit(Z3_context c, Z3_ast a)
Create a unit sequence of a.

◆ Update()

def z3py.Update (   a,
  i,
  v 
)
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 4692 of file z3py.py.

4692 def Update(a, i, v):
4693  """Return a Z3 store array expression.
4694 
4695  >>> a = Array('a', IntSort(), IntSort())
4696  >>> i, v = Ints('i v')
4697  >>> s = Update(a, i, v)
4698  >>> s.sort()
4699  Array(Int, Int)
4700  >>> prove(s[i] == v)
4701  proved
4702  >>> j = Int('j')
4703  >>> prove(Implies(i != j, s[j] == a[j]))
4704  proved
4705  """
4706  if z3_debug():
4707  _z3_assert(is_array_sort(a), "First argument must be a Z3 array expression")
4708  i = a.sort().domain().cast(i)
4709  v = a.sort().range().cast(v)
4710  ctx = a.ctx
4711  return _to_expr_ref(Z3_mk_store(ctx.ref(), a.as_ast(), i.as_ast(), v.as_ast()), ctx)
4712 
4713 
Z3_ast Z3_API Z3_mk_store(Z3_context c, Z3_ast a, Z3_ast i, Z3_ast v)
Array update.

Referenced by Store().

◆ URem()

def z3py.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 4219 of file z3py.py.

4219 def URem(a, b):
4220  """Create the Z3 expression (unsigned) remainder `self % other`.
4221 
4222  Use the operator % for signed modulus, and SRem() for signed remainder.
4223 
4224  >>> x = BitVec('x', 32)
4225  >>> y = BitVec('y', 32)
4226  >>> URem(x, y)
4227  URem(x, y)
4228  >>> URem(x, y).sort()
4229  BitVec(32)
4230  >>> (x % y).sexpr()
4231  '(bvsmod x y)'
4232  >>> URem(x, y).sexpr()
4233  '(bvurem x y)'
4234  """
4235  _check_bv_args(a, b)
4236  a, b = _coerce_exprs(a, b)
4237  return BitVecRef(Z3_mk_bvurem(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4238 
4239 
def URem(a, b)
Definition: z3py.py:4219
Z3_ast Z3_API Z3_mk_bvurem(Z3_context c, Z3_ast t1, Z3_ast t2)
Unsigned remainder.

◆ user_prop_diseq()

def z3py.user_prop_diseq (   ctx,
  cb,
  x,
  y 
)

Definition at line 11152 of file z3py.py.

11152 def user_prop_diseq(ctx, cb, x, y):
11153  prop = _prop_closures.get(ctx)
11154  prop.cb = cb
11155  prop.diseq(x, y)
11156  prop.cb = None
11157 
11158 
def user_prop_diseq(ctx, cb, x, y)
Definition: z3py.py:11152

◆ user_prop_eq()

def z3py.user_prop_eq (   ctx,
  cb,
  x,
  y 
)

Definition at line 11145 of file z3py.py.

11145 def user_prop_eq(ctx, cb, x, y):
11146  prop = _prop_closures.get(ctx)
11147  prop.cb = cb
11148  prop.eq(x, y)
11149  prop.cb = None
11150 
11151 
def user_prop_eq(ctx, cb, x, y)
Definition: z3py.py:11145

◆ user_prop_final()

def z3py.user_prop_final (   ctx,
  cb 
)

Definition at line 11138 of file z3py.py.

11138 def user_prop_final(ctx, cb):
11139  prop = _prop_closures.get(ctx)
11140  prop.cb = cb
11141  prop.final()
11142  prop.cb = None
11143 
11144 
def user_prop_final(ctx, cb)
Definition: z3py.py:11138

◆ user_prop_fixed()

def z3py.user_prop_fixed (   ctx,
  cb,
  id,
  value 
)

Definition at line 11131 of file z3py.py.

11131 def user_prop_fixed(ctx, cb, id, value):
11132  prop = _prop_closures.get(ctx)
11133  prop.cb = cb
11134  prop.fixed(id, _to_expr_ref(ctypes.c_void_p(value), prop.ctx()))
11135  prop.cb = None
11136 
11137 
def user_prop_fixed(ctx, cb, id, value)
Definition: z3py.py:11131

◆ user_prop_fresh()

def z3py.user_prop_fresh (   id,
  ctx 
)

Definition at line 11124 of file z3py.py.

11124 def user_prop_fresh(id, ctx):
11125  _prop_closures.set_threaded()
11126  new_prop = UsePropagateBase(None, ctx)
11127  _prop_closures.set(new_prop.id, new_prop.fresh())
11128  return ctypes.c_void_p(new_prop.id)
11129 
11130 
def user_prop_fresh(id, ctx)
Definition: z3py.py:11124

◆ user_prop_pop()

def z3py.user_prop_pop (   ctx,
  num_scopes 
)

Definition at line 11120 of file z3py.py.

11120 def user_prop_pop(ctx, num_scopes):
11121  _prop_closures.get(ctx).pop(num_scopes)
11122 
11123 
def user_prop_pop(ctx, num_scopes)
Definition: z3py.py:11120

◆ user_prop_push()

def z3py.user_prop_push (   ctx)

Definition at line 11116 of file z3py.py.

11116 def user_prop_push(ctx):
11117  _prop_closures.get(ctx).push()
11118 
11119 
def user_prop_push(ctx)
Definition: z3py.py:11116

◆ Var()

def z3py.Var (   idx,
  s 
)
Create a Z3 free variable. Free variables are used to create quantified formulas.

>>> Var(0, IntSort())
Var(0)
>>> eq(Var(0, IntSort()), Var(0, BoolSort()))
False

Definition at line 1438 of file z3py.py.

1438 def Var(idx, s):
1439  """Create a Z3 free variable. Free variables are used to create quantified formulas.
1440 
1441  >>> Var(0, IntSort())
1442  Var(0)
1443  >>> eq(Var(0, IntSort()), Var(0, BoolSort()))
1444  False
1445  """
1446  if z3_debug():
1447  _z3_assert(is_sort(s), "Z3 sort expected")
1448  return _to_expr_ref(Z3_mk_bound(s.ctx_ref(), idx, s.ast), s.ctx)
1449 
1450 
Z3_ast Z3_API Z3_mk_bound(Z3_context c, unsigned index, Z3_sort ty)
Create a bound variable.

Referenced by RealVar().

◆ When()

def z3py.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 8608 of file z3py.py.

8608 def When(p, t, ctx=None):
8609  """Return a tactic that applies tactic `t` only if probe `p` evaluates to true.
8610  Otherwise, it returns the input goal unmodified.
8611 
8612  >>> t = When(Probe('size') > 2, Tactic('simplify'))
8613  >>> x, y = Ints('x y')
8614  >>> g = Goal()
8615  >>> g.add(x > 0)
8616  >>> g.add(y > 0)
8617  >>> t(g)
8618  [[x > 0, y > 0]]
8619  >>> g.add(x == y + 1)
8620  >>> t(g)
8621  [[Not(x <= 0), Not(y <= 0), x == 1 + y]]
8622  """
8623  p = _to_probe(p, ctx)
8624  t = _to_tactic(t, ctx)
8625  return Tactic(Z3_tactic_when(t.ctx.ref(), p.probe, t.tactic), t.ctx)
8626 
8627 
def When(p, t, ctx=None)
Definition: z3py.py:8608
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()

def z3py.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 8265 of file z3py.py.

8265 def With(t, *args, **keys):
8266  """Return a tactic that applies tactic `t` using the given configuration options.
8267 
8268  >>> x, y = Ints('x y')
8269  >>> t = With(Tactic('simplify'), som=True)
8270  >>> t((x + 1)*(y + 2) == 0)
8271  [[2*x + y + x*y == -2]]
8272  """
8273  ctx = keys.pop("ctx", None)
8274  t = _to_tactic(t, ctx)
8275  p = args2params(args, keys, t.ctx)
8276  return Tactic(Z3_tactic_using_params(t.ctx.ref(), t.tactic, p.params), t.ctx)
8277 
8278 
def With(t, *args, **keys)
Definition: z3py.py:8265
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()

def z3py.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 8279 of file z3py.py.

8279 def WithParams(t, p):
8280  """Return a tactic that applies tactic `t` using the given configuration options.
8281 
8282  >>> x, y = Ints('x y')
8283  >>> p = ParamsRef()
8284  >>> p.set("som", True)
8285  >>> t = WithParams(Tactic('simplify'), p)
8286  >>> t((x + 1)*(y + 2) == 0)
8287  [[2*x + y + x*y == -2]]
8288  """
8289  t = _to_tactic(t, None)
8290  return Tactic(Z3_tactic_using_params(t.ctx.ref(), t.tactic, p.params), t.ctx)
8291 
8292 
def WithParams(t, p)
Definition: z3py.py:8279

◆ Xor()

def z3py.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 1763 of file z3py.py.

1763 def Xor(a, b, ctx=None):
1764  """Create a Z3 Xor expression.
1765 
1766  >>> p, q = Bools('p q')
1767  >>> Xor(p, q)
1768  Xor(p, q)
1769  >>> simplify(Xor(p, q))
1770  Not(p) == q
1771  """
1772  ctx = _get_ctx(_ctx_from_ast_arg_list([a, b], ctx))
1773  s = BoolSort(ctx)
1774  a = s.cast(a)
1775  b = s.cast(b)
1776  return BoolRef(Z3_mk_xor(ctx.ref(), a.as_ast(), b.as_ast()), ctx)
1777 
1778 
def Xor(a, b, ctx=None)
Definition: z3py.py:1763
Z3_ast Z3_API Z3_mk_xor(Z3_context c, Z3_ast t1, Z3_ast t2)
Create an AST node representing t1 xor t2.

◆ z3_debug()

def z3py.z3_debug ( )

Definition at line 64 of file z3py.py.

64 def z3_debug():
65  global Z3_DEBUG
66  return Z3_DEBUG
67 
68 

Referenced by FuncDeclRef.__call__(), Probe.__call__(), QuantifierRef.__getitem__(), ModelRef.__getitem__(), Context.__init__(), Goal.__init__(), ArithRef.__mod__(), ArithRef.__rmod__(), DatatypeSortRef.accessor(), And(), AndThen(), Tactic.apply(), ExprRef.arg(), args2params(), ArraySort(), IntNumRef.as_long(), AtLeast(), AtMost(), BV2Int(), BVRedAnd(), BVRedOr(), BVSNegNoOverflow(), SortRef.cast(), BoolSortRef.cast(), ArithSortRef.cast(), BitVecSortRef.cast(), FPSortRef.cast(), ExprRef.children(), Concat(), Const(), DatatypeSortRef.constructor(), Goal.convert_model(), CreateDatatypes(), ExprRef.decl(), Datatype.declare(), Datatype.declare_core(), Default(), describe_probes(), Distinct(), FuncDeclRef.domain(), EnumSort(), eq(), AstRef.eq(), Ext(), Extract(), FiniteDomainVal(), fpIsPositive(), fpNeg(), FPSort(), fpToFPUnsigned(), fpToIEEEBV(), fpToReal(), fpToSBV(), fpToUBV(), FreshFunction(), Function(), get_as_array_func(), ModelRef.get_interp(), get_map_func(), ModelRef.get_universe(), get_var_index(), If(), AlgebraicNumRef.index(), Intersect(), is_quantifier(), is_sort(), IsInt(), K(), Map(), MultiPattern(), QuantifierRef.no_pattern(), ExprRef.num_args(), Or(), OrElse(), Tactic.param_descrs(), ParOr(), ParThen(), QuantifierRef.pattern(), prove(), RatVal(), RealSort(), RecFunction(), DatatypeSortRef.recognizer(), RepeatBitVec(), Select(), ParamsRef.set(), set_param(), SignExt(), simplify(), solve_using(), substitute(), substitute_vars(), ToInt(), ToReal(), AstRef.translate(), Goal.translate(), ModelRef.translate(), Solver.translate(), Union(), Update(), Var(), QuantifierRef.var_name(), QuantifierRef.var_sort(), and ZeroExt().

◆ z3_error_handler()

def z3py.z3_error_handler (   c,
  e 
)

Definition at line 179 of file z3py.py.

179 def z3_error_handler(c, e):
180  # Do nothing error handler, just avoid exit(0)
181  # The wrappers in z3core.py will raise a Z3Exception if an error is detected
182  return
183 
184 
def z3_error_handler(c, e)
Definition: z3py.py:179

◆ ZeroExt()

def z3py.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 4355 of file z3py.py.

4355 def ZeroExt(n, a):
4356  """Return a bit-vector expression with `n` extra zero-bits.
4357 
4358  >>> x = BitVec('x', 16)
4359  >>> n = ZeroExt(8, x)
4360  >>> n.size()
4361  24
4362  >>> n
4363  ZeroExt(8, x)
4364  >>> n.sort()
4365  BitVec(24)
4366  >>> v0 = BitVecVal(2, 2)
4367  >>> v0
4368  2
4369  >>> v0.size()
4370  2
4371  >>> v = simplify(ZeroExt(6, v0))
4372  >>> v
4373  2
4374  >>> v.size()
4375  8
4376  """
4377  if z3_debug():
4378  _z3_assert(_is_int(n), "First argument must be an integer")
4379  _z3_assert(is_bv(a), "Second argument must be a Z3 bit-vector expression")
4380  return BitVecRef(Z3_mk_zero_ext(a.ctx_ref(), n, a.as_ast()), a.ctx)
4381 
4382 
def ZeroExt(n, a)
Definition: z3py.py:4355
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

◆ sat

Definition at line 6782 of file z3py.py.

◆ unknown

Definition at line 6784 of file z3py.py.

◆ unsat

Definition at line 6783 of file z3py.py.

◆ Z3_DEBUG

Z3_DEBUG = __debug__

Definition at line 61 of file z3py.py.