Z3
Data Structures | Functions | Variables
z3py Namespace Reference

Data Structures

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

Functions

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 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 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 (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 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 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)
 
def SimpleSolver (ctx=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, 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 SubString (s, offset, length)
 
def SubSeq (s, offset, length)
 
def Strings (names, ctx=None)
 
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)
 
def IndexOf (s, substr, offset)
 
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 Plus (re)
 
def Option (re)
 
def Complement (re)
 
def Star (re)
 
def Loop (re, lo, hi=0)
 

Variables

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

Referenced by Fixedpoint.add_rule(), Goal.as_expr(), Bool(), Bools(), BoolVector(), Lambda(), Fixedpoint.query(), Fixedpoint.query_from_lvl(), and Fixedpoint.update_rule().

1661 def And(*args):
1662  """Create a Z3 and-expression or and-probe.
1663 
1664  >>> p, q, r = Bools('p q r')
1665  >>> And(p, q, r)
1666  And(p, q, r)
1667  >>> P = BoolVector('p', 5)
1668  >>> And(P)
1669  And(p__0, p__1, p__2, p__3, p__4)
1670  """
1671  last_arg = None
1672  if len(args) > 0:
1673  last_arg = args[len(args)-1]
1674  if isinstance(last_arg, Context):
1675  ctx = args[len(args)-1]
1676  args = args[:len(args)-1]
1677  elif len(args) == 1 and isinstance(args[0], AstVector):
1678  ctx = args[0].ctx
1679  args = [a for a in args[0]]
1680  else:
1681  ctx = main_ctx()
1682  args = _get_args(args)
1683  ctx_args = _ctx_from_ast_arg_list(args, ctx)
1684  if __debug__:
1685  _z3_assert(ctx_args is None or ctx_args == ctx, "context mismatch")
1686  _z3_assert(ctx is not None, "At least one of the arguments must be a Z3 expression or probe")
1687  if _has_probe(args):
1688  return _probe_and(args, ctx)
1689  else:
1690  args = _coerce_expr_list(args, ctx)
1691  _args, sz = _to_ast_array(args)
1692  return BoolRef(Z3_mk_and(ctx.ref(), sz, _args), ctx)
1693 
def And(args)
Definition: z3py.py:1661
def main_ctx()
Definition: z3py.py:207
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].

◆ 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 7651 of file z3py.py.

Referenced by Then().

7651 def AndThen(*ts, **ks):
7652  """Return a tactic that applies the tactics in `*ts` in sequence.
7653 
7654  >>> x, y = Ints('x y')
7655  >>> t = AndThen(Tactic('simplify'), Tactic('solve-eqs'))
7656  >>> t(And(x == 0, y > x + 1))
7657  [[Not(y <= 1)]]
7658  >>> t(And(x == 0, y > x + 1)).as_expr()
7659  Not(y <= 1)
7660  """
7661  if __debug__:
7662  _z3_assert(len(ts) >= 2, "At least two arguments expected")
7663  ctx = ks.get('ctx', None)
7664  num = len(ts)
7665  r = ts[0]
7666  for i in range(num - 1):
7667  r = _and_then(r, ts[i+1], ctx)
7668  return r
7669 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3244
def AndThen(ts, ks)
Definition: z3py.py:7651

◆ append_log()

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

Definition at line 101 of file z3py.py.

101 def append_log(s):
102  """Append user-defined string to interaction log. """
103  Z3_append_log(s)
104 
void Z3_API Z3_append_log(Z3_string string)
Append user-defined string to interaction log.
def append_log(s)
Definition: z3py.py:101

◆ 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 5007 of file z3py.py.

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

5007 def args2params(arguments, keywords, ctx=None):
5008  """Convert python arguments into a Z3_params object.
5009  A ':' is added to the keywords, and '_' is replaced with '-'
5010 
5011  >>> args2params(['model', True, 'relevancy', 2], {'elim_and' : True})
5012  (params model true relevancy 2 elim_and true)
5013  """
5014  if __debug__:
5015  _z3_assert(len(arguments) % 2 == 0, "Argument list must have an even number of elements.")
5016  prev = None
5017  r = ParamsRef(ctx)
5018  for a in arguments:
5019  if prev is None:
5020  prev = a
5021  else:
5022  r.set(prev, a)
5023  prev = None
5024  for k in keywords:
5025  v = keywords[k]
5026  r.set(k, v)
5027  return r
5028 
def args2params(arguments, keywords, ctx=None)
Definition: z3py.py:5007

◆ 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 4372 of file z3py.py.

Referenced by ArrayRef.__getitem__(), ArraySort(), ArrayRef.domain(), get_map_func(), is_array(), is_const_array(), is_K(), is_map(), is_select(), is_store(), K(), Lambda(), Map(), ArrayRef.range(), Select(), ArrayRef.sort(), Store(), and Update().

4372 def Array(name, dom, rng):
4373  """Return an array constant named `name` with the given domain and range sorts.
4374 
4375  >>> a = Array('a', IntSort(), IntSort())
4376  >>> a.sort()
4377  Array(Int, Int)
4378  >>> a[0]
4379  a[0]
4380  """
4381  s = ArraySort(dom, rng)
4382  ctx = s.ctx
4383  return ArrayRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), s.ast), ctx)
4384 
Z3_ast Z3_API Z3_mk_const(Z3_context c, Z3_symbol s, Z3_sort ty)
Declare and create a constant.
def ArraySort(sig)
Definition: z3py.py:4340
def to_symbol(s, ctx=None)
Definition: z3py.py:105
def Array(name, dom, rng)
Definition: z3py.py:4372

◆ 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 4340 of file z3py.py.

Referenced by ArraySortRef.domain(), Context.mkArraySort(), and ArraySortRef.range().

4340 def ArraySort(*sig):
4341  """Return the Z3 array sort with the given domain and range sorts.
4342 
4343  >>> A = ArraySort(IntSort(), BoolSort())
4344  >>> A
4345  Array(Int, Bool)
4346  >>> A.domain()
4347  Int
4348  >>> A.range()
4349  Bool
4350  >>> AA = ArraySort(IntSort(), A)
4351  >>> AA
4352  Array(Int, Array(Int, Bool))
4353  """
4354  sig = _get_args(sig)
4355  if __debug__:
4356  _z3_assert(len(sig) > 1, "At least two arguments expected")
4357  arity = len(sig) - 1
4358  r = sig[arity]
4359  d = sig[0]
4360  if __debug__:
4361  for s in sig:
4362  _z3_assert(is_sort(s), "Z3 sort expected")
4363  _z3_assert(s.ctx == r.ctx, "Context mismatch")
4364  ctx = d.ctx
4365  if len(sig) == 2:
4366  return ArraySortRef(Z3_mk_array_sort(ctx.ref(), d.ast, r.ast), ctx)
4367  dom = (Sort * arity)()
4368  for i in range(arity):
4369  dom[i] = sig[i].ast
4370  return ArraySortRef(Z3_mk_array_sort_n(ctx.ref(), arity, dom, r.ast), ctx)
4371 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3244
def ArraySort(sig)
Definition: z3py.py:4340
Z3_sort Z3_API Z3_mk_array_sort(Z3_context c, Z3_sort domain, Z3_sort range)
Create an array type.
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.
def is_sort(s)
Definition: z3py.py:579

◆ 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 8232 of file z3py.py.

8232 def AtLeast(*args):
8233  """Create an at-most Pseudo-Boolean k constraint.
8234 
8235  >>> a, b, c = Bools('a b c')
8236  >>> f = AtLeast(a, b, c, 2)
8237  """
8238  args = _get_args(args)
8239  if __debug__:
8240  _z3_assert(len(args) > 1, "Non empty list of arguments expected")
8241  ctx = _ctx_from_ast_arg_list(args)
8242  if __debug__:
8243  _z3_assert(ctx is not None, "At least one of the arguments must be a Z3 expression")
8244  args1 = _coerce_expr_list(args[:-1], ctx)
8245  k = args[-1]
8246  _args, sz = _to_ast_array(args1)
8247  return BoolRef(Z3_mk_atleast(ctx.ref(), sz, _args, k), ctx)
8248 
8249 
def AtLeast(args)
Definition: z3py.py:8232
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 8215 of file z3py.py.

8215 def AtMost(*args):
8216  """Create an at-most Pseudo-Boolean k constraint.
8217 
8218  >>> a, b, c = Bools('a b c')
8219  >>> f = AtMost(a, b, c, 2)
8220  """
8221  args = _get_args(args)
8222  if __debug__:
8223  _z3_assert(len(args) > 1, "Non empty list of arguments expected")
8224  ctx = _ctx_from_ast_arg_list(args)
8225  if __debug__:
8226  _z3_assert(ctx is not None, "At least one of the arguments must be a Z3 expression")
8227  args1 = _coerce_expr_list(args[:-1], ctx)
8228  k = args[-1]
8229  _args, sz = _to_ast_array(args1)
8230  return BoolRef(Z3_mk_atmost(ctx.ref(), sz, _args, k), ctx)
8231 
def AtMost(args)
Definition: z3py.py:8215
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 3742 of file z3py.py.

Referenced by BitVecRef.__add__(), BitVecRef.__and__(), BitVecRef.__div__(), BitVecRef.__invert__(), BitVecRef.__mod__(), BitVecRef.__mul__(), BitVecRef.__neg__(), BitVecRef.__or__(), BitVecRef.__pos__(), BitVecRef.__radd__(), BitVecRef.__rand__(), BitVecRef.__rdiv__(), BitVecRef.__rlshift__(), BitVecRef.__rmod__(), BitVecRef.__rmul__(), BitVecRef.__ror__(), BitVecRef.__rrshift__(), BitVecRef.__rsub__(), BitVecRef.__rxor__(), BitVecRef.__sub__(), BitVecRef.__xor__(), BitVecs(), BitVecSort(), BV2Int(), Extract(), is_bv(), is_bv_value(), RepeatBitVec(), SignExt(), BitVecRef.size(), BitVecRef.sort(), SRem(), UDiv(), URem(), and ZeroExt().

3742 def BitVec(name, bv, ctx=None):
3743  """Return a bit-vector constant named `name`. `bv` may be the number of bits of a bit-vector sort.
3744  If `ctx=None`, then the global context is used.
3745 
3746  >>> x = BitVec('x', 16)
3747  >>> is_bv(x)
3748  True
3749  >>> x.size()
3750  16
3751  >>> x.sort()
3752  BitVec(16)
3753  >>> word = BitVecSort(16)
3754  >>> x2 = BitVec('x', word)
3755  >>> eq(x, x2)
3756  True
3757  """
3758  if isinstance(bv, BitVecSortRef):
3759  ctx = bv.ctx
3760  else:
3761  ctx = _get_ctx(ctx)
3762  bv = BitVecSort(bv, ctx)
3763  return BitVecRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), bv.ast), ctx)
3764 
Z3_ast Z3_API Z3_mk_const(Z3_context c, Z3_symbol s, Z3_sort ty)
Declare and create a constant.
def to_symbol(s, ctx=None)
Definition: z3py.py:105
def BitVec(name, bv, ctx=None)
Definition: z3py.py:3742
def BitVecSort(sz, ctx=None)
Definition: z3py.py:3712

◆ 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 3765 of file z3py.py.

Referenced by BitVecRef.__ge__(), BitVecRef.__gt__(), BitVecRef.__le__(), BitVecRef.__lshift__(), BitVecRef.__lt__(), BitVecRef.__rshift__(), LShR(), RotateLeft(), RotateRight(), UGE(), UGT(), ULE(), and ULT().

3765 def BitVecs(names, bv, ctx=None):
3766  """Return a tuple of bit-vector constants of size bv.
3767 
3768  >>> x, y, z = BitVecs('x y z', 16)
3769  >>> x.size()
3770  16
3771  >>> x.sort()
3772  BitVec(16)
3773  >>> Sum(x, y, z)
3774  0 + x + y + z
3775  >>> Product(x, y, z)
3776  1*x*y*z
3777  >>> simplify(Product(x, y, z))
3778  x*y*z
3779  """
3780  ctx = _get_ctx(ctx)
3781  if isinstance(names, str):
3782  names = names.split(" ")
3783  return [BitVec(name, bv, ctx) for name in names]
3784 
def BitVec(name, bv, ctx=None)
Definition: z3py.py:3742
def BitVecs(names, bv, ctx=None)
Definition: z3py.py:3765

◆ 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 3712 of file z3py.py.

Referenced by BitVec(), BitVecSortRef.cast(), fpSignedToFP(), fpToFP(), fpToSBV(), fpToUBV(), fpUnsignedToFP(), is_bv_sort(), Context.mkBitVecSort(), BitVecSortRef.size(), and BitVecRef.sort().

3712 def BitVecSort(sz, ctx=None):
3713  """Return a Z3 bit-vector sort of the given size. If `ctx=None`, then the global context is used.
3714 
3715  >>> Byte = BitVecSort(8)
3716  >>> Word = BitVecSort(16)
3717  >>> Byte
3718  BitVec(8)
3719  >>> x = Const('x', Byte)
3720  >>> eq(x, BitVec('x', 8))
3721  True
3722  """
3723  ctx = _get_ctx(ctx)
3724  return BitVecSortRef(Z3_mk_bv_sort(ctx.ref(), sz), ctx)
3725 
Z3_sort Z3_API Z3_mk_bv_sort(Z3_context c, unsigned sz)
Create a bit-vector type of the given size.
def BitVecSort(sz, ctx=None)
Definition: z3py.py:3712

◆ 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 3726 of file z3py.py.

Referenced by BitVecRef.__lshift__(), BitVecRef.__rshift__(), BitVecNumRef.as_long(), BitVecNumRef.as_signed_long(), Concat(), fpBVToFP(), fpFP(), fpSignedToFP(), fpToFP(), fpUnsignedToFP(), is_bv_value(), LShR(), RepeatBitVec(), SignExt(), and ZeroExt().

3726 def BitVecVal(val, bv, ctx=None):
3727  """Return a bit-vector value with the given number of bits. If `ctx=None`, then the global context is used.
3728 
3729  >>> v = BitVecVal(10, 32)
3730  >>> v
3731  10
3732  >>> print("0x%.8x" % v.as_long())
3733  0x0000000a
3734  """
3735  if is_bv_sort(bv):
3736  ctx = bv.ctx
3737  return BitVecNumRef(Z3_mk_numeral(ctx.ref(), _to_int_str(val), bv.ast), ctx)
3738  else:
3739  ctx = _get_ctx(ctx)
3740  return BitVecNumRef(Z3_mk_numeral(ctx.ref(), _to_int_str(val), BitVecSort(bv, ctx).ast), ctx)
3741 
def BitVecVal(val, bv, ctx=None)
Definition: z3py.py:3726
def is_bv_sort(s)
Definition: z3py.py:3194
def BitVecSort(sz, ctx=None)
Definition: z3py.py:3712
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 1547 of file z3py.py.

Referenced by Solver.assert_and_track(), and Not().

1547 def Bool(name, ctx=None):
1548  """Return a Boolean constant named `name`. If `ctx=None`, then the global context is used.
1549 
1550  >>> p = Bool('p')
1551  >>> q = Bool('q')
1552  >>> And(p, q)
1553  And(p, q)
1554  """
1555  ctx = _get_ctx(ctx)
1556  return BoolRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), BoolSort(ctx).ast), ctx)
1557 
Z3_ast Z3_API Z3_mk_const(Z3_context c, Z3_symbol s, Z3_sort ty)
Declare and create a constant.
def to_symbol(s, ctx=None)
Definition: z3py.py:105
def Bool(name, ctx=None)
Definition: z3py.py:1547
def BoolSort(ctx=None)
Definition: z3py.py:1512

◆ 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 1558 of file z3py.py.

Referenced by And(), Solver.consequences(), Implies(), Or(), Solver.unsat_core(), and Xor().

1558 def Bools(names, ctx=None):
1559  """Return a tuple of Boolean constants.
1560 
1561  `names` is a single string containing all names separated by blank spaces.
1562  If `ctx=None`, then the global context is used.
1563 
1564  >>> p, q, r = Bools('p q r')
1565  >>> And(p, Or(q, r))
1566  And(p, Or(q, r))
1567  """
1568  ctx = _get_ctx(ctx)
1569  if isinstance(names, str):
1570  names = names.split(" ")
1571  return [Bool(name, ctx) for name in names]
1572 
def Bools(names, ctx=None)
Definition: z3py.py:1558
def Bool(name, ctx=None)
Definition: z3py.py:1547

◆ 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 1512 of file z3py.py.

Referenced by ArrayRef.__getitem__(), ArraySort(), Fixedpoint.assert_exprs(), Optimize.assert_exprs(), ArraySortRef.domain(), ArrayRef.domain(), Context.getBoolSort(), If(), IntSort(), is_arith_sort(), Context.mkBoolSort(), ArraySortRef.range(), ArrayRef.range(), and ArrayRef.sort().

1512 def BoolSort(ctx=None):
1513  """Return the Boolean Z3 sort. If `ctx=None`, then the global context is used.
1514 
1515  >>> BoolSort()
1516  Bool
1517  >>> p = Const('p', BoolSort())
1518  >>> is_bool(p)
1519  True
1520  >>> r = Function('r', IntSort(), IntSort(), BoolSort())
1521  >>> r(0, 1)
1522  r(0, 1)
1523  >>> is_bool(r(0, 1))
1524  True
1525  """
1526  ctx = _get_ctx(ctx)
1527  return BoolSortRef(Z3_mk_bool_sort(ctx.ref()), ctx)
1528 
def is_bool(a)
Definition: z3py.py:1401
def BoolSort(ctx=None)
Definition: z3py.py:1512

◆ 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 1529 of file z3py.py.

Referenced by ApplyResult.as_expr(), BoolSortRef.cast(), Re(), and Solver.to_smt2().

1529 def BoolVal(val, ctx=None):
1530  """Return the Boolean value `True` or `False`. If `ctx=None`, then the global context is used.
1531 
1532  >>> BoolVal(True)
1533  True
1534  >>> is_true(BoolVal(True))
1535  True
1536  >>> is_true(True)
1537  False
1538  >>> is_false(BoolVal(False))
1539  True
1540  """
1541  ctx = _get_ctx(ctx)
1542  if val == False:
1543  return BoolRef(Z3_mk_false(ctx.ref()), ctx)
1544  else:
1545  return BoolRef(Z3_mk_true(ctx.ref()), ctx)
1546 
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.
def BoolVal(val, ctx=None)
Definition: z3py.py:1529

◆ 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 1573 of file z3py.py.

Referenced by And(), and Or().

1573 def BoolVector(prefix, sz, ctx=None):
1574  """Return a list of Boolean constants of size `sz`.
1575 
1576  The constants are named using the given prefix.
1577  If `ctx=None`, then the global context is used.
1578 
1579  >>> P = BoolVector('p', 3)
1580  >>> P
1581  [p__0, p__1, p__2]
1582  >>> And(P)
1583  And(p__0, p__1, p__2)
1584  """
1585  return [ Bool('%s__%s' % (prefix, i)) for i in range(sz) ]
1586 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3244
def BoolVector(prefix, sz, ctx=None)
Definition: z3py.py:1573
def Bool(name, ctx=None)
Definition: z3py.py:1547

◆ 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)
[b = 1, x = 2]

Definition at line 3682 of file z3py.py.

3682 def BV2Int(a, is_signed=False):
3683  """Return the Z3 expression BV2Int(a).
3684 
3685  >>> b = BitVec('b', 3)
3686  >>> BV2Int(b).sort()
3687  Int
3688  >>> x = Int('x')
3689  >>> x > BV2Int(b)
3690  x > BV2Int(b)
3691  >>> x > BV2Int(b, is_signed=False)
3692  x > BV2Int(b)
3693  >>> x > BV2Int(b, is_signed=True)
3694  x > If(b < 0, BV2Int(b) - 8, BV2Int(b))
3695  >>> solve(x > BV2Int(b), b == 1, x < 3)
3696  [b = 1, x = 2]
3697  """
3698  if __debug__:
3699  _z3_assert(is_bv(a), "Z3 bit-vector expression expected")
3700  ctx = a.ctx
3701 
3702  return ArithRef(Z3_mk_bv2int(ctx.ref(), a.as_ast(), is_signed), ctx)
3703 
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...
def BV2Int(a, is_signed=False)
Definition: z3py.py:3682
def is_bv(a)
Definition: z3py.py:3655

◆ BVAddNoOverflow()

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

Definition at line 4137 of file z3py.py.

4137 def BVAddNoOverflow(a, b, signed):
4138  """A predicate the determines that bit-vector addition does not overflow"""
4139  _check_bv_args(a, b)
4140  a, b = _coerce_exprs(a, b)
4141  return BoolRef(Z3_mk_bvadd_no_overflow(a.ctx_ref(), a.as_ast(), b.as_ast(), signed), a.ctx)
4142 
def BVAddNoOverflow(a, b, signed)
Definition: z3py.py:4137
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 4143 of file z3py.py.

4143 def BVAddNoUnderflow(a, b):
4144  """A predicate the determines that signed bit-vector addition does not underflow"""
4145  _check_bv_args(a, b)
4146  a, b = _coerce_exprs(a, b)
4147  return BoolRef(Z3_mk_bvadd_no_underflow(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4148 
def BVAddNoUnderflow(a, b)
Definition: z3py.py:4143
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 4174 of file z3py.py.

4174 def BVMulNoOverflow(a, b, signed):
4175  """A predicate the determines that bit-vector multiplication does not overflow"""
4176  _check_bv_args(a, b)
4177  a, b = _coerce_exprs(a, b)
4178  return BoolRef(Z3_mk_bvmul_no_overflow(a.ctx_ref(), a.as_ast(), b.as_ast(), signed), a.ctx)
4179 
4180 
def BVMulNoOverflow(a, b, signed)
Definition: z3py.py:4174
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 4181 of file z3py.py.

4181 def BVMulNoUnderflow(a, b):
4182  """A predicate the determines that bit-vector signed multiplication does not underflow"""
4183  _check_bv_args(a, b)
4184  a, b = _coerce_exprs(a, b)
4185  return BoolRef(Z3_mk_bvmul_no_underflow(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4186 
4187 
4188 
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...
def BVMulNoUnderflow(a, b)
Definition: z3py.py:4181

◆ BVRedAnd()

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

Definition at line 4125 of file z3py.py.

4125 def BVRedAnd(a):
4126  """Return the reduction-and expression of `a`."""
4127  if __debug__:
4128  _z3_assert(is_bv(a), "First argument must be a Z3 Bitvector expression")
4129  return BitVecRef(Z3_mk_bvredand(a.ctx_ref(), a.as_ast()), a.ctx)
4130 
Z3_ast Z3_API Z3_mk_bvredand(Z3_context c, Z3_ast t1)
Take conjunction of bits in vector, return vector of length 1.
def BVRedAnd(a)
Definition: z3py.py:4125
def is_bv(a)
Definition: z3py.py:3655

◆ BVRedOr()

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

Definition at line 4131 of file z3py.py.

4131 def BVRedOr(a):
4132  """Return the reduction-or expression of `a`."""
4133  if __debug__:
4134  _z3_assert(is_bv(a), "First argument must be a Z3 Bitvector expression")
4135  return BitVecRef(Z3_mk_bvredor(a.ctx_ref(), a.as_ast()), a.ctx)
4136 
def BVRedOr(a)
Definition: z3py.py:4131
Z3_ast Z3_API Z3_mk_bvredor(Z3_context c, Z3_ast t1)
Take disjunction of bits in vector, return vector of length 1.
def is_bv(a)
Definition: z3py.py:3655

◆ BVSDivNoOverflow()

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

Definition at line 4162 of file z3py.py.

4162 def BVSDivNoOverflow(a, b):
4163  """A predicate the determines that bit-vector signed division does not overflow"""
4164  _check_bv_args(a, b)
4165  a, b = _coerce_exprs(a, b)
4166  return BoolRef(Z3_mk_bvsdiv_no_overflow(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4167 
def BVSDivNoOverflow(a, b)
Definition: z3py.py:4162
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 4168 of file z3py.py.

4168 def BVSNegNoOverflow(a):
4169  """A predicate the determines that bit-vector unary negation does not overflow"""
4170  if __debug__:
4171  _z3_assert(is_bv(a), "Argument should be a bit-vector")
4172  return BoolRef(Z3_mk_bvneg_no_overflow(a.ctx_ref(), a.as_ast()), a.ctx)
4173 
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...
def BVSNegNoOverflow(a)
Definition: z3py.py:4168
def is_bv(a)
Definition: z3py.py:3655

◆ BVSubNoOverflow()

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

Definition at line 4149 of file z3py.py.

4149 def BVSubNoOverflow(a, b):
4150  """A predicate the determines that bit-vector subtraction does not overflow"""
4151  _check_bv_args(a, b)
4152  a, b = _coerce_exprs(a, b)
4153  return BoolRef(Z3_mk_bvsub_no_overflow(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4154 
4155 
def BVSubNoOverflow(a, b)
Definition: z3py.py:4149
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 4156 of file z3py.py.

4156 def BVSubNoUnderflow(a, b, signed):
4157  """A predicate the determines that bit-vector subtraction does not underflow"""
4158  _check_bv_args(a, b)
4159  a, b = _coerce_exprs(a, b)
4160  return BoolRef(Z3_mk_bvsub_no_underflow(a.ctx_ref(), a.as_ast(), b.as_ast(), signed), a.ctx)
4161 
def BVSubNoUnderflow(a, b, signed)
Definition: z3py.py:4156
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 3144 of file z3py.py.

3144 def Cbrt(a, ctx=None):
3145  """ Return a Z3 expression which represents the cubic root of a.
3146 
3147  >>> x = Real('x')
3148  >>> Cbrt(x)
3149  x**(1/3)
3150  """
3151  if not is_expr(a):
3152  ctx = _get_ctx(ctx)
3153  a = RealVal(a, ctx)
3154  return a ** "1/3"
3155 
def Cbrt(a, ctx=None)
Definition: z3py.py:3144
def RealVal(val, ctx=None)
Definition: z3py.py:2937
def is_expr(a)
Definition: z3py.py:1094

◆ Complement()

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

Definition at line 10239 of file z3py.py.

10239 def Complement(re):
10240  """Create the complement regular expression."""
10241  return ReRef(Z3_mk_re_complement(re.ctx_ref(), re.as_ast()), re.ctx)
10242 
Z3_ast Z3_API Z3_mk_re_complement(Z3_context c, Z3_ast re)
Create the complement of the regular language re.
def Complement(re)
Definition: z3py.py:10239

◆ 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 3785 of file z3py.py.

Referenced by Contains(), and BitVecRef.size().

3785 def Concat(*args):
3786  """Create a Z3 bit-vector concatenation expression.
3787 
3788  >>> v = BitVecVal(1, 4)
3789  >>> Concat(v, v+1, v)
3790  Concat(Concat(1, 1 + 1), 1)
3791  >>> simplify(Concat(v, v+1, v))
3792  289
3793  >>> print("%.3x" % simplify(Concat(v, v+1, v)).as_long())
3794  121
3795  """
3796  args = _get_args(args)
3797  sz = len(args)
3798  if __debug__:
3799  _z3_assert(sz >= 2, "At least two arguments expected.")
3800 
3801  ctx = None
3802  for a in args:
3803  if is_expr(a):
3804  ctx = a.ctx
3805  break
3806  if is_seq(args[0]) or isinstance(args[0], str):
3807  args = [_coerce_seq(s, ctx) for s in args]
3808  if __debug__:
3809  _z3_assert(all([is_seq(a) for a in args]), "All arguments must be sequence expressions.")
3810  v = (Ast * sz)()
3811  for i in range(sz):
3812  v[i] = args[i].as_ast()
3813  return SeqRef(Z3_mk_seq_concat(ctx.ref(), sz, v), ctx)
3814 
3815  if is_re(args[0]):
3816  if __debug__:
3817  _z3_assert(all([is_re(a) for a in args]), "All arguments must be regular expressions.")
3818  v = (Ast * sz)()
3819  for i in range(sz):
3820  v[i] = args[i].as_ast()
3821  return ReRef(Z3_mk_re_concat(ctx.ref(), sz, v), ctx)
3822 
3823  if __debug__:
3824  _z3_assert(all([is_bv(a) for a in args]), "All arguments must be Z3 bit-vector expressions.")
3825  r = args[0]
3826  for i in range(sz - 1):
3827  r = BitVecRef(Z3_mk_concat(ctx.ref(), r.as_ast(), args[i+1].as_ast()), ctx)
3828  return r
3829 
Z3_ast Z3_API Z3_mk_seq_concat(Z3_context c, unsigned n, Z3_ast const args[])
Concatenate sequences.
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3244
Z3_ast Z3_API Z3_mk_concat(Z3_context c, Z3_ast t1, Z3_ast t2)
Concatenate the given bit-vectors.
Z3_ast Z3_API Z3_mk_re_concat(Z3_context c, unsigned n, Z3_ast const args[])
Create the concatenation of the regular languages.
def is_re(s)
Definition: z3py.py:10179
def is_expr(a)
Definition: z3py.py:1094
def is_bv(a)
Definition: z3py.py:3655
def Concat(args)
Definition: z3py.py:3785
def is_seq(a)
Definition: z3py.py:9941

◆ 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 8070 of file z3py.py.

Referenced by If().

8070 def Cond(p, t1, t2, ctx=None):
8071  """Return a tactic that applies tactic `t1` to a goal if probe `p` evaluates to true, and `t2` otherwise.
8072 
8073  >>> t = Cond(Probe('is-qfnra'), Tactic('qfnra'), Tactic('smt'))
8074  """
8075  p = _to_probe(p, ctx)
8076  t1 = _to_tactic(t1, ctx)
8077  t2 = _to_tactic(t2, ctx)
8078  return Tactic(Z3_tactic_cond(t1.ctx.ref(), p.probe, t1.tactic, t2.tactic), t1.ctx)
8079 
def Cond(p, t1, t2, ctx=None)
Definition: z3py.py:8070
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...

◆ Const()

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

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

Definition at line 1280 of file z3py.py.

Referenced by BitVecSort(), Consts(), FPSort(), IntSort(), IsMember(), IsSubset(), RealSort(), DatatypeSortRef.recognizer(), SetAdd(), SetComplement(), SetDel(), SetDifference(), SetIntersect(), and SetUnion().

1280 def Const(name, sort):
1281  """Create a constant of the given sort.
1282 
1283  >>> Const('x', IntSort())
1284  x
1285  """
1286  if __debug__:
1287  _z3_assert(isinstance(sort, SortRef), "Z3 sort expected")
1288  ctx = sort.ctx
1289  return _to_expr_ref(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), sort.ast), ctx)
1290 
Z3_ast Z3_API Z3_mk_const(Z3_context c, Z3_symbol s, Z3_sort ty)
Declare and create a constant.
def to_symbol(s, ctx=None)
Definition: z3py.py:105
def Const(name, sort)
Definition: z3py.py:1280

◆ Consts()

def z3py.Consts (   names,
  sort 
)
Create a 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 1291 of file z3py.py.

Referenced by ModelRef.get_sort(), ModelRef.get_universe(), ModelRef.num_sorts(), and ModelRef.sorts().

1291 def Consts(names, sort):
1292  """Create a several constants of the given sort.
1293 
1294  `names` is a string containing the names of all constants to be created.
1295  Blank spaces separate the names of different constants.
1296 
1297  >>> x, y, z = Consts('x y z', IntSort())
1298  >>> x + y + z
1299  x + y + z
1300  """
1301  if isinstance(names, str):
1302  names = names.split(" ")
1303  return [Const(name, sort) for name in names]
1304 
def Consts(names, sort)
Definition: z3py.py:1291
def Const(name, sort)
Definition: z3py.py:1280

◆ 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 10060 of file z3py.py.

10060 def Contains(a, b):
10061  """Check if 'a' contains 'b'
10062  >>> s1 = Contains("abc", "ab")
10063  >>> simplify(s1)
10064  True
10065  >>> s2 = Contains("abc", "bc")
10066  >>> simplify(s2)
10067  True
10068  >>> x, y, z = Strings('x y z')
10069  >>> s3 = Contains(Concat(x,y,z), y)
10070  >>> simplify(s3)
10071  True
10072  """
10073  ctx = _get_ctx2(a, b)
10074  a = _coerce_seq(a, ctx)
10075  b = _coerce_seq(b, ctx)
10076  return BoolRef(Z3_mk_seq_contains(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
10077 
10078 
def Contains(a, b)
Definition: z3py.py:10060
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 4742 of file z3py.py.

Referenced by Datatype.create().

4742 def CreateDatatypes(*ds):
4743  """Create mutually recursive Z3 datatypes using 1 or more Datatype helper objects.
4744 
4745  In the following example we define a Tree-List using two mutually recursive datatypes.
4746 
4747  >>> TreeList = Datatype('TreeList')
4748  >>> Tree = Datatype('Tree')
4749  >>> # Tree has two constructors: leaf and node
4750  >>> Tree.declare('leaf', ('val', IntSort()))
4751  >>> # a node contains a list of trees
4752  >>> Tree.declare('node', ('children', TreeList))
4753  >>> TreeList.declare('nil')
4754  >>> TreeList.declare('cons', ('car', Tree), ('cdr', TreeList))
4755  >>> Tree, TreeList = CreateDatatypes(Tree, TreeList)
4756  >>> Tree.val(Tree.leaf(10))
4757  val(leaf(10))
4758  >>> simplify(Tree.val(Tree.leaf(10)))
4759  10
4760  >>> n1 = Tree.node(TreeList.cons(Tree.leaf(10), TreeList.cons(Tree.leaf(20), TreeList.nil)))
4761  >>> n1
4762  node(cons(leaf(10), cons(leaf(20), nil)))
4763  >>> n2 = Tree.node(TreeList.cons(n1, TreeList.nil))
4764  >>> simplify(n2 == n1)
4765  False
4766  >>> simplify(TreeList.car(Tree.children(n2)) == n1)
4767  True
4768  """
4769  ds = _get_args(ds)
4770  if __debug__:
4771  _z3_assert(len(ds) > 0, "At least one Datatype must be specified")
4772  _z3_assert(all([isinstance(d, Datatype) for d in ds]), "Arguments must be Datatypes")
4773  _z3_assert(all([d.ctx == ds[0].ctx for d in ds]), "Context mismatch")
4774  _z3_assert(all([d.constructors != [] for d in ds]), "Non-empty Datatypes expected")
4775  ctx = ds[0].ctx
4776  num = len(ds)
4777  names = (Symbol * num)()
4778  out = (Sort * num)()
4779  clists = (ConstructorList * num)()
4780  to_delete = []
4781  for i in range(num):
4782  d = ds[i]
4783  names[i] = to_symbol(d.name, ctx)
4784  num_cs = len(d.constructors)
4785  cs = (Constructor * num_cs)()
4786  for j in range(num_cs):
4787  c = d.constructors[j]
4788  cname = to_symbol(c[0], ctx)
4789  rname = to_symbol(c[1], ctx)
4790  fs = c[2]
4791  num_fs = len(fs)
4792  fnames = (Symbol * num_fs)()
4793  sorts = (Sort * num_fs)()
4794  refs = (ctypes.c_uint * num_fs)()
4795  for k in range(num_fs):
4796  fname = fs[k][0]
4797  ftype = fs[k][1]
4798  fnames[k] = to_symbol(fname, ctx)
4799  if isinstance(ftype, Datatype):
4800  if __debug__:
4801  _z3_assert(ds.count(ftype) == 1, "One and only one occurrence of each datatype is expected")
4802  sorts[k] = None
4803  refs[k] = ds.index(ftype)
4804  else:
4805  if __debug__:
4806  _z3_assert(is_sort(ftype), "Z3 sort expected")
4807  sorts[k] = ftype.ast
4808  refs[k] = 0
4809  cs[j] = Z3_mk_constructor(ctx.ref(), cname, rname, num_fs, fnames, sorts, refs)
4810  to_delete.append(ScopedConstructor(cs[j], ctx))
4811  clists[i] = Z3_mk_constructor_list(ctx.ref(), num_cs, cs)
4812  to_delete.append(ScopedConstructorList(clists[i], ctx))
4813  Z3_mk_datatypes(ctx.ref(), num, names, out, clists)
4814  result = []
4815 
4816  for i in range(num):
4817  dref = DatatypeSortRef(out[i], ctx)
4818  num_cs = dref.num_constructors()
4819  for j in range(num_cs):
4820  cref = dref.constructor(j)
4821  cref_name = cref.name()
4822  cref_arity = cref.arity()
4823  if cref.arity() == 0:
4824  cref = cref()
4825  setattr(dref, cref_name, cref)
4826  rref = dref.recognizer(j)
4827  setattr(dref, "is_" + cref_name, rref)
4828  for k in range(cref_arity):
4829  aref = dref.accessor(j, k)
4830  setattr(dref, aref.name(), aref)
4831  result.append(dref)
4832  return tuple(result)
4833 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3244
def to_symbol(s, ctx=None)
Definition: z3py.py:105
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.
def CreateDatatypes(ds)
Definition: z3py.py:4742
def is_sort(s)
Definition: z3py.py:579
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.

◆ 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 616 of file z3py.py.

Referenced by ModelRef.get_sort(), ModelRef.get_universe(), ModelRef.num_sorts(), and ModelRef.sorts().

616 def DeclareSort(name, ctx=None):
617  """Create a new uninterpreted sort named `name`.
618 
619  If `ctx=None`, then the new sort is declared in the global Z3Py context.
620 
621  >>> A = DeclareSort('A')
622  >>> a = Const('a', A)
623  >>> b = Const('b', A)
624  >>> a.sort() == A
625  True
626  >>> b.sort() == A
627  True
628  >>> a == b
629  a == b
630  """
631  ctx = _get_ctx(ctx)
632  return SortRef(Z3_mk_uninterpreted_sort(ctx.ref(), to_symbol(name, ctx)), ctx)
633 
def to_symbol(s, ctx=None)
Definition: z3py.py:105
Z3_sort Z3_API Z3_mk_uninterpreted_sort(Z3_context c, Z3_symbol s)
Create a free (uninterpreted) type using the given name (symbol).
def DeclareSort(name, ctx=None)
Definition: z3py.py:616

◆ Default()

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

Definition at line 4406 of file z3py.py.

Referenced by is_default().

4406 def Default(a):
4407  """ Return a default value for array expression.
4408  >>> b = K(IntSort(), 1)
4409  >>> prove(Default(b) == 1)
4410  proved
4411  """
4412  if __debug__:
4413  _z3_assert(is_array(a), "First argument must be a Z3 array expression")
4414  return a.default()
4415 
4416 
def is_array(a)
Definition: z3py.py:4263
def Default(a)
Definition: z3py.py:4406

◆ describe_probes()

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

Definition at line 8000 of file z3py.py.

8000 def describe_probes():
8001  """Display a (tabular) description of all available probes in Z3."""
8002  if in_html_mode():
8003  even = True
8004  print('<table border="1" cellpadding="2" cellspacing="0">')
8005  for p in probes():
8006  if even:
8007  print('<tr style="background-color:#CFCFCF">')
8008  even = False
8009  else:
8010  print('<tr>')
8011  even = True
8012  print('<td>%s</td><td>%s</td></tr>' % (p, insert_line_breaks(probe_description(p), 40)))
8013  print('</table>')
8014  else:
8015  for p in probes():
8016  print('%s : %s' % (p, probe_description(p)))
8017 
def probes(ctx=None)
Definition: z3py.py:7982
def probe_description(name, ctx=None)
Definition: z3py.py:7992
def describe_probes()
Definition: z3py.py:8000

◆ describe_tactics()

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

Definition at line 7809 of file z3py.py.

7809 def describe_tactics():
7810  """Display a (tabular) description of all available tactics in Z3."""
7811  if in_html_mode():
7812  even = True
7813  print('<table border="1" cellpadding="2" cellspacing="0">')
7814  for t in tactics():
7815  if even:
7816  print('<tr style="background-color:#CFCFCF">')
7817  even = False
7818  else:
7819  print('<tr>')
7820  even = True
7821  print('<td>%s</td><td>%s</td></tr>' % (t, insert_line_breaks(tactic_description(t), 40)))
7822  print('</table>')
7823  else:
7824  for t in tactics():
7825  print('%s : %s' % (t, tactic_description(t)))
7826 
def tactics(ctx=None)
Definition: z3py.py:7791
def tactic_description(name, ctx=None)
Definition: z3py.py:7801
def describe_tactics()
Definition: z3py.py:7809

◆ disable_trace()

def z3py.disable_trace (   msg)

Definition at line 66 of file z3py.py.

66 def disable_trace(msg):
67  Z3_disable_trace(msg)
68 
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...
def disable_trace(msg)
Definition: z3py.py:66

◆ 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 1249 of file z3py.py.

1249 def Distinct(*args):
1250  """Create a Z3 distinct expression.
1251 
1252  >>> x = Int('x')
1253  >>> y = Int('y')
1254  >>> Distinct(x, y)
1255  x != y
1256  >>> z = Int('z')
1257  >>> Distinct(x, y, z)
1258  Distinct(x, y, z)
1259  >>> simplify(Distinct(x, y, z))
1260  Distinct(x, y, z)
1261  >>> simplify(Distinct(x, y, z), blast_distinct=True)
1262  And(Not(x == y), Not(x == z), Not(y == z))
1263  """
1264  args = _get_args(args)
1265  ctx = _ctx_from_ast_arg_list(args)
1266  if __debug__:
1267  _z3_assert(ctx is not None, "At least one of the arguments must be a Z3 expression")
1268  args = _coerce_expr_list(args, ctx)
1269  _args, sz = _to_ast_array(args)
1270  return BoolRef(Z3_mk_distinct(ctx.ref(), sz, _args), ctx)
1271 
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]).
def Distinct(args)
Definition: z3py.py:1249

◆ 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)
seq.empty
>>> e4 = Empty(ReSort(SeqSort(IntSort())))
>>> print(e4)
re.empty

Definition at line 9995 of file z3py.py.

9995 def Empty(s):
9996  """Create the empty sequence of the given sort
9997  >>> e = Empty(StringSort())
9998  >>> e2 = StringVal("")
9999  >>> print(e.eq(e2))
10000  True
10001  >>> e3 = Empty(SeqSort(IntSort()))
10002  >>> print(e3)
10003  seq.empty
10004  >>> e4 = Empty(ReSort(SeqSort(IntSort())))
10005  >>> print(e4)
10006  re.empty
10007  """
10008  if isinstance(s, SeqSortRef):
10009  return SeqRef(Z3_mk_seq_empty(s.ctx_ref(), s.ast), s.ctx)
10010  if isinstance(s, ReSortRef):
10011  return ReRef(Z3_mk_re_empty(s.ctx_ref(), s.ast), s.ctx)
10012  raise Z3Exception("Non-sequence, non-regular expression sort passed to Empty")
10013 
Z3_ast Z3_API Z3_mk_re_empty(Z3_context c, Z3_sort re)
Create an empty regular expression of sort re.
Z3_ast Z3_API Z3_mk_seq_empty(Z3_context c, Z3_sort seq)
Create an empty sequence of the sequence sort seq.
def Empty(s)
Definition: z3py.py:9995

◆ EmptySet()

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

Definition at line 4532 of file z3py.py.

4532 def EmptySet(s):
4533  """Create the empty set
4534  >>> EmptySet(IntSort())
4535  K(Int, False)
4536  """
4537  ctx = s.ctx
4538  return ArrayRef(Z3_mk_empty_set(ctx.ref(), s.ast), ctx)
4539 
Z3_ast Z3_API Z3_mk_empty_set(Z3_context c, Z3_sort domain)
Create the empty set.
def EmptySet(s)
Definition: z3py.py:4532

◆ enable_trace()

def z3py.enable_trace (   msg)

Definition at line 63 of file z3py.py.

63 def enable_trace(msg):
64  Z3_enable_trace(msg)
65 
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...
def enable_trace(msg)
Definition: z3py.py:63

◆ 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 4931 of file z3py.py.

Referenced by Context.mkEnumSort().

4931 def EnumSort(name, values, ctx=None):
4932  """Return a new enumeration sort named `name` containing the given values.
4933 
4934  The result is a pair (sort, list of constants).
4935  Example:
4936  >>> Color, (red, green, blue) = EnumSort('Color', ['red', 'green', 'blue'])
4937  """
4938  if __debug__:
4939  _z3_assert(isinstance(name, str), "Name must be a string")
4940  _z3_assert(all([isinstance(v, str) for v in values]), "Eumeration sort values must be strings")
4941  _z3_assert(len(values) > 0, "At least one value expected")
4942  ctx = _get_ctx(ctx)
4943  num = len(values)
4944  _val_names = (Symbol * num)()
4945  for i in range(num):
4946  _val_names[i] = to_symbol(values[i])
4947  _values = (FuncDecl * num)()
4948  _testers = (FuncDecl * num)()
4949  name = to_symbol(name)
4950  S = DatatypeSortRef(Z3_mk_enumeration_sort(ctx.ref(), name, num, _val_names, _values, _testers), ctx)
4951  V = []
4952  for i in range(num):
4953  V.append(FuncDeclRef(_values[i], ctx))
4954  V = [a() for a in V]
4955  return S, V
4956 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3244
def to_symbol(s, ctx=None)
Definition: z3py.py:105
def EnumSort(name, values, ctx=None)
Definition: z3py.py:4931
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 416 of file z3py.py.

Referenced by BitVec(), BitVecSort(), FP(), FPSort(), FreshBool(), FreshInt(), FreshReal(), get_map_func(), Select(), and substitute().

416 def eq(a, b):
417  """Return `True` if `a` and `b` are structurally identical AST nodes.
418 
419  >>> x = Int('x')
420  >>> y = Int('y')
421  >>> eq(x, y)
422  False
423  >>> eq(x + 1, x + 1)
424  True
425  >>> eq(x + 1, 1 + x)
426  False
427  >>> eq(simplify(x + 1), simplify(1 + x))
428  True
429  """
430  if __debug__:
431  _z3_assert(is_ast(a) and is_ast(b), "Z3 ASTs expected")
432  return a.eq(b)
433 
def eq(a, b)
Definition: z3py.py:416
def is_ast(a)
Definition: z3py.py:396

◆ 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 2033 of file z3py.py.

Referenced by Fixedpoint.abstract(), QuantifierRef.is_exists(), QuantifierRef.is_forall(), and QuantifierRef.is_lambda().

2033 def Exists(vs, body, weight=1, qid="", skid="", patterns=[], no_patterns=[]):
2034  """Create a Z3 exists formula.
2035 
2036  The parameters `weight`, `qif`, `skid`, `patterns` and `no_patterns` are optional annotations.
2037 
2038 
2039  >>> f = Function('f', IntSort(), IntSort(), IntSort())
2040  >>> x = Int('x')
2041  >>> y = Int('y')
2042  >>> q = Exists([x, y], f(x, y) >= x, skid="foo")
2043  >>> q
2044  Exists([x, y], f(x, y) >= x)
2045  >>> is_quantifier(q)
2046  True
2047  >>> r = Tactic('nnf')(q).as_expr()
2048  >>> is_quantifier(r)
2049  False
2050  """
2051  return _mk_quantifier(False, vs, body, weight, qid, skid, patterns, no_patterns)
2052 
def Exists(vs, body, weight=1, qid="", skid="", patterns=[], no_patterns=[])
Definition: z3py.py:2033

◆ Ext()

def z3py.Ext (   a,
  b 
)
Return extensionality index for arrays.

Definition at line 4491 of file z3py.py.

4491 def Ext(a, b):
4492  """Return extensionality index for arrays.
4493  """
4494  if __debug__:
4495  _z3_assert(is_array(a) and is_array(b))
4496  return _to_expr_ref(Z3_mk_array_ext(ctx.ref(), a.as_ast(), b.as_ast()));
4497 
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...
def is_array(a)
Definition: z3py.py:4263
def Ext(a, b)
Definition: z3py.py:4491

◆ Extract()

def z3py.Extract (   high,
  low,
  a 
)
Create a Z3 bit-vector extraction expression, or create a string extraction expression.

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

3830 def Extract(high, low, a):
3831  """Create a Z3 bit-vector extraction expression, or create a string extraction expression.
3832 
3833  >>> x = BitVec('x', 8)
3834  >>> Extract(6, 2, x)
3835  Extract(6, 2, x)
3836  >>> Extract(6, 2, x).sort()
3837  BitVec(5)
3838  >>> simplify(Extract(StringVal("abcd"),2,1))
3839  c
3840  """
3841  if isinstance(high, str):
3842  high = StringVal(high)
3843  if is_seq(high):
3844  s = high
3845  offset, length = _coerce_exprs(low, a, s.ctx)
3846  return SeqRef(Z3_mk_seq_extract(s.ctx_ref(), s.as_ast(), offset.as_ast(), length.as_ast()), s.ctx)
3847  if __debug__:
3848  _z3_assert(low <= high, "First argument must be greater than or equal to second argument")
3849  _z3_assert(_is_int(high) and high >= 0 and _is_int(low) and low >= 0, "First and second arguments must be non negative integers")
3850  _z3_assert(is_bv(a), "Third argument must be a Z3 Bitvector expression")
3851  return BitVecRef(Z3_mk_extract(a.ctx_ref(), high, low, a.as_ast()), a.ctx)
3852 
def Extract(high, low, a)
Definition: z3py.py:3830
def StringVal(s, ctx=None)
Definition: z3py.py:9967
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.
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...
def is_bv(a)
Definition: z3py.py:3655
def is_seq(a)
Definition: z3py.py:9941

◆ 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 8033 of file z3py.py.

8033 def FailIf(p, ctx=None):
8034  """Return a tactic that fails if the probe `p` evaluates to true. Otherwise, it returns the input goal unmodified.
8035 
8036  In the following example, the tactic applies 'simplify' if and only if there are more than 2 constraints in the goal.
8037 
8038  >>> t = OrElse(FailIf(Probe('size') > 2), Tactic('simplify'))
8039  >>> x, y = Ints('x y')
8040  >>> g = Goal()
8041  >>> g.add(x > 0)
8042  >>> g.add(y > 0)
8043  >>> t(g)
8044  [[x > 0, y > 0]]
8045  >>> g.add(x == y + 1)
8046  >>> t(g)
8047  [[Not(x <= 0), Not(y <= 0), x == 1 + y]]
8048  """
8049  p = _to_probe(p, ctx)
8050  return Tactic(Z3_tactic_fail_if(p.ctx.ref(), p.probe), p.ctx)
8051 
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.
def FailIf(p, ctx=None)
Definition: z3py.py:8033

◆ FiniteDomainSort()

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

Definition at line 7148 of file z3py.py.

Referenced by Context.mkFiniteDomainSort().

7148 def FiniteDomainSort(name, sz, ctx=None):
7149  """Create a named finite domain sort of a given size sz"""
7150  if not isinstance(name, Symbol):
7151  name = to_symbol(name)
7152  ctx = _get_ctx(ctx)
7153  return FiniteDomainSortRef(Z3_mk_finite_domain_sort(ctx.ref(), name, sz), ctx)
7154 
def to_symbol(s, ctx=None)
Definition: z3py.py:105
Z3_sort Z3_API Z3_mk_finite_domain_sort(Z3_context c, Z3_symbol name, uint64_t size)
Create a named finite domain sort.
def FiniteDomainSort(name, sz, ctx=None)
Definition: z3py.py:7148

◆ 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 7216 of file z3py.py.

7216 def FiniteDomainVal(val, sort, ctx=None):
7217  """Return a Z3 finite-domain value. If `ctx=None`, then the global context is used.
7218 
7219  >>> s = FiniteDomainSort('S', 256)
7220  >>> FiniteDomainVal(255, s)
7221  255
7222  >>> FiniteDomainVal('100', s)
7223  100
7224  """
7225  if __debug__:
7226  _z3_assert(is_finite_domain_sort(sort), "Expected finite-domain sort" )
7227  ctx = sort.ctx
7228  return FiniteDomainNumRef(Z3_mk_numeral(ctx.ref(), _to_int_str(val), sort.ast), ctx)
7229 
def is_finite_domain_sort(s)
Definition: z3py.py:7155
def FiniteDomainVal(val, sort, ctx=None)
Definition: z3py.py:7216
Z3_ast Z3_API Z3_mk_numeral(Z3_context c, Z3_string numeral, Z3_sort ty)
Create a numeral of a given sort.

◆ Float128()

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

Definition at line 8657 of file z3py.py.

8657 def Float128(ctx=None):
8658  """Floating-point 128-bit (quadruple) sort."""
8659  ctx = _get_ctx(ctx)
8660  return FPSortRef(Z3_mk_fpa_sort_128(ctx.ref()), ctx)
8661 
def Float128(ctx=None)
Definition: z3py.py:8657
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 8627 of file z3py.py.

8627 def Float16(ctx=None):
8628  """Floating-point 16-bit (half) sort."""
8629  ctx = _get_ctx(ctx)
8630  return FPSortRef(Z3_mk_fpa_sort_16(ctx.ref()), ctx)
8631 
def Float16(ctx=None)
Definition: z3py.py:8627
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 8637 of file z3py.py.

Referenced by FPRef.__neg__(), fpBVToFP(), fpFPToFP(), fpRealToFP(), fpSignedToFP(), fpToFP(), and fpUnsignedToFP().

8637 def Float32(ctx=None):
8638  """Floating-point 32-bit (single) sort."""
8639  ctx = _get_ctx(ctx)
8640  return FPSortRef(Z3_mk_fpa_sort_32(ctx.ref()), ctx)
8641 
Z3_sort Z3_API Z3_mk_fpa_sort_32(Z3_context c)
Create the single-precision (32-bit) FloatingPoint sort.
def Float32(ctx=None)
Definition: z3py.py:8637

◆ Float64()

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

Definition at line 8647 of file z3py.py.

Referenced by fpFPToFP(), and fpToFP().

8647 def Float64(ctx=None):
8648  """Floating-point 64-bit (double) sort."""
8649  ctx = _get_ctx(ctx)
8650  return FPSortRef(Z3_mk_fpa_sort_64(ctx.ref()), ctx)
8651 
def Float64(ctx=None)
Definition: z3py.py:8647
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 8652 of file z3py.py.

8652 def FloatDouble(ctx=None):
8653  """Floating-point 64-bit (double) sort."""
8654  ctx = _get_ctx(ctx)
8655  return FPSortRef(Z3_mk_fpa_sort_double(ctx.ref()), ctx)
8656 
def FloatDouble(ctx=None)
Definition: z3py.py:8652
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 8632 of file z3py.py.

8632 def FloatHalf(ctx=None):
8633  """Floating-point 16-bit (half) sort."""
8634  ctx = _get_ctx(ctx)
8635  return FPSortRef(Z3_mk_fpa_sort_half(ctx.ref()), ctx)
8636 
Z3_sort Z3_API Z3_mk_fpa_sort_half(Z3_context c)
Create the half-precision (16-bit) FloatingPoint sort.
def FloatHalf(ctx=None)
Definition: z3py.py:8632

◆ FloatQuadruple()

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

Definition at line 8662 of file z3py.py.

8662 def FloatQuadruple(ctx=None):
8663  """Floating-point 128-bit (quadruple) sort."""
8664  ctx = _get_ctx(ctx)
8665  return FPSortRef(Z3_mk_fpa_sort_quadruple(ctx.ref()), ctx)
8666 
Z3_sort Z3_API Z3_mk_fpa_sort_quadruple(Z3_context c)
Create the quadruple-precision (128-bit) FloatingPoint sort.
def FloatQuadruple(ctx=None)
Definition: z3py.py:8662

◆ FloatSingle()

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

Definition at line 8642 of file z3py.py.

8642 def FloatSingle(ctx=None):
8643  """Floating-point 32-bit (single) sort."""
8644  ctx = _get_ctx(ctx)
8645  return FPSortRef(Z3_mk_fpa_sort_single(ctx.ref()), ctx)
8646 
def FloatSingle(ctx=None)
Definition: z3py.py:8642
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`, `qif`, `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 2016 of file z3py.py.

Referenced by Fixedpoint.abstract(), QuantifierRef.body(), QuantifierRef.children(), QuantifierRef.is_exists(), QuantifierRef.is_forall(), is_pattern(), is_quantifier(), MultiPattern(), QuantifierRef.num_patterns(), QuantifierRef.num_vars(), QuantifierRef.pattern(), QuantifierRef.var_name(), QuantifierRef.var_sort(), and QuantifierRef.weight().

2016 def ForAll(vs, body, weight=1, qid="", skid="", patterns=[], no_patterns=[]):
2017  """Create a Z3 forall formula.
2018 
2019  The parameters `weight`, `qif`, `skid`, `patterns` and `no_patterns` are optional annotations.
2020 
2021  >>> f = Function('f', IntSort(), IntSort(), IntSort())
2022  >>> x = Int('x')
2023  >>> y = Int('y')
2024  >>> ForAll([x, y], f(x, y) >= x)
2025  ForAll([x, y], f(x, y) >= x)
2026  >>> ForAll([x, y], f(x, y) >= x, patterns=[ f(x, y) ])
2027  ForAll([x, y], f(x, y) >= x)
2028  >>> ForAll([x, y], f(x, y) >= x, weight=10)
2029  ForAll([x, y], f(x, y) >= x)
2030  """
2031  return _mk_quantifier(True, vs, body, weight, qid, skid, patterns, no_patterns)
2032 
def ForAll(vs, body, weight=1, qid="", skid="", patterns=[], no_patterns=[])
Definition: z3py.py:2016

◆ 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 9243 of file z3py.py.

Referenced by FPRef.__add__(), FPRef.__div__(), FPRef.__mul__(), FPRef.__neg__(), FPRef.__radd__(), FPRef.__rdiv__(), FPRef.__rmul__(), FPRef.__rsub__(), FPRef.__sub__(), fpAdd(), fpDiv(), fpIsInf(), fpIsNaN(), fpMax(), fpMin(), fpMul(), fpNeg(), fpRem(), FPSort(), fpSub(), fpToIEEEBV(), fpToReal(), fpToSBV(), fpToUBV(), is_fp(), is_fp_value(), and FPRef.sort().

9243 def FP(name, fpsort, ctx=None):
9244  """Return a floating-point constant named `name`.
9245  `fpsort` is the floating-point sort.
9246  If `ctx=None`, then the global context is used.
9247 
9248  >>> x = FP('x', FPSort(8, 24))
9249  >>> is_fp(x)
9250  True
9251  >>> x.ebits()
9252  8
9253  >>> x.sort()
9254  FPSort(8, 24)
9255  >>> word = FPSort(8, 24)
9256  >>> x2 = FP('x', word)
9257  >>> eq(x, x2)
9258  True
9259  """
9260  if isinstance(fpsort, FPSortRef) and ctx is None:
9261  ctx = fpsort.ctx
9262  else:
9263  ctx = _get_ctx(ctx)
9264  return FPRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), fpsort.ast), ctx)
9265 
Z3_ast Z3_API Z3_mk_const(Z3_context c, Z3_symbol s, Z3_sort ty)
Declare and create a constant.
def to_symbol(s, ctx=None)
Definition: z3py.py:105
def FP(name, fpsort, ctx=None)
Definition: z3py.py:9243

◆ 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 9284 of file z3py.py.

9284 def fpAbs(a, ctx=None):
9285  """Create a Z3 floating-point absolute value expression.
9286 
9287  >>> s = FPSort(8, 24)
9288  >>> rm = RNE()
9289  >>> x = FPVal(1.0, s)
9290  >>> fpAbs(x)
9291  fpAbs(1)
9292  >>> y = FPVal(-20.0, s)
9293  >>> y
9294  -1.25*(2**4)
9295  >>> fpAbs(y)
9296  fpAbs(-1.25*(2**4))
9297  >>> fpAbs(-1.25*(2**4))
9298  fpAbs(-1.25*(2**4))
9299  >>> fpAbs(x).sort()
9300  FPSort(8, 24)
9301  """
9302  ctx = _get_ctx(ctx)
9303  [a] = _coerce_fp_expr_list([a], ctx)
9304  return FPRef(Z3_mk_fpa_abs(ctx.ref(), a.as_ast()), ctx)
9305 
Z3_ast Z3_API Z3_mk_fpa_abs(Z3_context c, Z3_ast t)
Floating-point absolute value.
def fpAbs(a, ctx=None)
Definition: z3py.py:9284

◆ 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 9373 of file z3py.py.

Referenced by FPs().

9373 def fpAdd(rm, a, b, ctx=None):
9374  """Create a Z3 floating-point addition expression.
9375 
9376  >>> s = FPSort(8, 24)
9377  >>> rm = RNE()
9378  >>> x = FP('x', s)
9379  >>> y = FP('y', s)
9380  >>> fpAdd(rm, x, y)
9381  fpAdd(RNE(), x, y)
9382  >>> fpAdd(RTZ(), x, y) # default rounding mode is RTZ
9383  x + y
9384  >>> fpAdd(rm, x, y).sort()
9385  FPSort(8, 24)
9386  """
9387  return _mk_fp_bin(Z3_mk_fpa_add, rm, a, b, ctx)
9388 
def fpAdd(rm, a, b, ctx=None)
Definition: z3py.py:9373

◆ 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 9670 of file z3py.py.

9670 def fpBVToFP(v, sort, ctx=None):
9671  """Create a Z3 floating-point conversion expression that represents the
9672  conversion from a bit-vector term to a floating-point term.
9673 
9674  >>> x_bv = BitVecVal(0x3F800000, 32)
9675  >>> x_fp = fpBVToFP(x_bv, Float32())
9676  >>> x_fp
9677  fpToFP(1065353216)
9678  >>> simplify(x_fp)
9679  1
9680  """
9681  _z3_assert(is_bv(v), "First argument must be a Z3 floating-point rounding mode expression.")
9682  _z3_assert(is_fp_sort(sort), "Second argument must be a Z3 floating-point sort.")
9683  ctx = _get_ctx(ctx)
9684  return FPRef(Z3_mk_fpa_to_fp_bv(ctx.ref(), v.ast, sort.ast), ctx)
9685 
def fpBVToFP(v, sort, ctx=None)
Definition: z3py.py:9670
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.
def is_fp_sort(s)
Definition: z3py.py:8671
def is_bv(a)
Definition: z3py.py:3655

◆ 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 9417 of file z3py.py.

9417 def fpDiv(rm, a, b, ctx=None):
9418  """Create a Z3 floating-point division expression.
9419 
9420  >>> s = FPSort(8, 24)
9421  >>> rm = RNE()
9422  >>> x = FP('x', s)
9423  >>> y = FP('y', s)
9424  >>> fpDiv(rm, x, y)
9425  fpDiv(RNE(), x, y)
9426  >>> fpDiv(rm, x, y).sort()
9427  FPSort(8, 24)
9428  """
9429  return _mk_fp_bin(Z3_mk_fpa_div, rm, a, b, ctx)
9430 
def fpDiv(rm, a, b, ctx=None)
Definition: z3py.py:9417

◆ 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 9582 of file z3py.py.

Referenced by fpFP(), and fpNEQ().

9582 def fpEQ(a, b, ctx=None):
9583  """Create the Z3 floating-point expression `fpEQ(other, self)`.
9584 
9585  >>> x, y = FPs('x y', FPSort(8, 24))
9586  >>> fpEQ(x, y)
9587  fpEQ(x, y)
9588  >>> fpEQ(x, y).sexpr()
9589  '(fp.eq x y)'
9590  """
9591  return _mk_fp_bin_pred(Z3_mk_fpa_eq, a, b, ctx)
9592 
def fpEQ(a, b, ctx=None)
Definition: z3py.py:9582

◆ fpFMA()

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

Definition at line 9472 of file z3py.py.

9472 def fpFMA(rm, a, b, c, ctx=None):
9473  """Create a Z3 floating-point fused multiply-add expression.
9474  """
9475  return _mk_fp_tern(Z3_mk_fpa_fma, rm, a, b, c, ctx)
9476 
def fpFMA(rm, a, b, c, ctx=None)
Definition: z3py.py:9472

◆ 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 9604 of file z3py.py.

9604 def fpFP(sgn, exp, sig, ctx=None):
9605  """Create the Z3 floating-point value `fpFP(sgn, sig, exp)` from the three bit-vectors sgn, sig, and exp.
9606 
9607  >>> s = FPSort(8, 24)
9608  >>> x = fpFP(BitVecVal(1, 1), BitVecVal(2**7-1, 8), BitVecVal(2**22, 23))
9609  >>> print(x)
9610  fpFP(1, 127, 4194304)
9611  >>> xv = FPVal(-1.5, s)
9612  >>> print(xv)
9613  -1.5
9614  >>> slvr = Solver()
9615  >>> slvr.add(fpEQ(x, xv))
9616  >>> slvr.check()
9617  sat
9618  >>> xv = FPVal(+1.5, s)
9619  >>> print(xv)
9620  1.5
9621  >>> slvr = Solver()
9622  >>> slvr.add(fpEQ(x, xv))
9623  >>> slvr.check()
9624  unsat
9625  """
9626  _z3_assert(is_bv(sgn) and is_bv(exp) and is_bv(sig), "sort mismatch")
9627  _z3_assert(sgn.sort().size() == 1, "sort mismatch")
9628  ctx = _get_ctx(ctx)
9629  _z3_assert(ctx == sgn.ctx == exp.ctx == sig.ctx, "context mismatch")
9630  return FPRef(Z3_mk_fpa_fp(ctx.ref(), sgn.ast, exp.ast, sig.ast), ctx)
9631 
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.
def fpFP(sgn, exp, sig, ctx=None)
Definition: z3py.py:9604
def is_bv(a)
Definition: z3py.py:3655

◆ 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 9686 of file z3py.py.

9686 def fpFPToFP(rm, v, sort, ctx=None):
9687  """Create a Z3 floating-point conversion expression that represents the
9688  conversion from a floating-point term to a floating-point term of different precision.
9689 
9690  >>> x_sgl = FPVal(1.0, Float32())
9691  >>> x_dbl = fpFPToFP(RNE(), x_sgl, Float64())
9692  >>> x_dbl
9693  fpToFP(RNE(), 1)
9694  >>> simplify(x_dbl)
9695  1
9696  >>> x_dbl.sort()
9697  FPSort(11, 53)
9698  """
9699  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression.")
9700  _z3_assert(is_fp(v), "Second argument must be a Z3 floating-point expression.")
9701  _z3_assert(is_fp_sort(sort), "Third argument must be a Z3 floating-point sort.")
9702  ctx = _get_ctx(ctx)
9703  return FPRef(Z3_mk_fpa_to_fp_float(ctx.ref(), rm.ast, v.ast, sort.ast), ctx)
9704 
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.
def is_fp_sort(s)
Definition: z3py.py:8671
def fpFPToFP(rm, v, sort, ctx=None)
Definition: z3py.py:9686
def is_fprm(a)
Definition: z3py.py:8919
def is_fp(a)
Definition: z3py.py:9055

◆ 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 9571 of file z3py.py.

9571 def fpGEQ(a, b, ctx=None):
9572  """Create the Z3 floating-point expression `other >= self`.
9573 
9574  >>> x, y = FPs('x y', FPSort(8, 24))
9575  >>> fpGEQ(x, y)
9576  x >= y
9577  >>> (x >= y).sexpr()
9578  '(fp.geq x y)'
9579  """
9580  return _mk_fp_bin_pred(Z3_mk_fpa_geq, a, b, ctx)
9581 
def fpGEQ(a, b, ctx=None)
Definition: z3py.py:9571

◆ 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 9560 of file z3py.py.

9560 def fpGT(a, b, ctx=None):
9561  """Create the Z3 floating-point expression `other > self`.
9562 
9563  >>> x, y = FPs('x y', FPSort(8, 24))
9564  >>> fpGT(x, y)
9565  x > y
9566  >>> (x > y).sexpr()
9567  '(fp.gt x y)'
9568  """
9569  return _mk_fp_bin_pred(Z3_mk_fpa_gt, a, b, ctx)
9570 
def fpGT(a, b, ctx=None)
Definition: z3py.py:9560

◆ fpInfinity()

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

Definition at line 9177 of file z3py.py.

9177 def fpInfinity(s, negative):
9178  """Create a Z3 floating-point +oo or -oo term."""
9179  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
9180  _z3_assert(isinstance(negative, bool), "expected Boolean flag")
9181  return FPNumRef(Z3_mk_fpa_inf(s.ctx_ref(), s.ast, negative), s.ctx)
9182 
Z3_ast Z3_API Z3_mk_fpa_inf(Z3_context c, Z3_sort s, bool negative)
Create a floating-point infinity of sort s.
def fpInfinity(s, negative)
Definition: z3py.py:9177

◆ 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 9498 of file z3py.py.

9498 def fpIsInf(a, ctx=None):
9499  """Create a Z3 floating-point isInfinite expression.
9500 
9501  >>> s = FPSort(8, 24)
9502  >>> x = FP('x', s)
9503  >>> fpIsInf(x)
9504  fpIsInf(x)
9505  """
9506  return _mk_fp_unary_norm(Z3_mk_fpa_is_infinite, a, ctx)
9507 
def fpIsInf(a, ctx=None)
Definition: z3py.py:9498

◆ 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 9487 of file z3py.py.

9487 def fpIsNaN(a, ctx=None):
9488  """Create a Z3 floating-point isNaN expression.
9489 
9490  >>> s = FPSort(8, 24)
9491  >>> x = FP('x', s)
9492  >>> y = FP('y', s)
9493  >>> fpIsNaN(x)
9494  fpIsNaN(x)
9495  """
9496  return _mk_fp_unary_norm(Z3_mk_fpa_is_nan, a, ctx)
9497 
def fpIsNaN(a, ctx=None)
Definition: z3py.py:9487

◆ fpIsNegative()

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

Definition at line 9523 of file z3py.py.

9523 def fpIsNegative(a, ctx=None):
9524  """Create a Z3 floating-point isNegative expression.
9525  """
9526  return _mk_fp_unary_norm(Z3_mk_fpa_is_negative, a, ctx)
9527 
def fpIsNegative(a, ctx=None)
Definition: z3py.py:9523

◆ fpIsNormal()

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

Definition at line 9513 of file z3py.py.

9513 def fpIsNormal(a, ctx=None):
9514  """Create a Z3 floating-point isNormal expression.
9515  """
9516  return _mk_fp_unary_norm(Z3_mk_fpa_is_normal, a, ctx)
9517 
def fpIsNormal(a, ctx=None)
Definition: z3py.py:9513

◆ fpIsPositive()

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

Definition at line 9528 of file z3py.py.

9528 def fpIsPositive(a, ctx=None):
9529  """Create a Z3 floating-point isPositive expression.
9530  """
9531  return _mk_fp_unary_norm(Z3_mk_fpa_is_positive, a, ctx)
9532  return FPRef(Z3_mk_fpa_is_positive(a.ctx_ref(), a.as_ast()), a.ctx)
9533 
Z3_ast Z3_API Z3_mk_fpa_is_positive(Z3_context c, Z3_ast t)
Predicate indicating whether t is a positive floating-point number.
def fpIsPositive(a, ctx=None)
Definition: z3py.py:9528

◆ fpIsSubnormal()

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

Definition at line 9518 of file z3py.py.

9518 def fpIsSubnormal(a, ctx=None):
9519  """Create a Z3 floating-point isSubnormal expression.
9520  """
9521  return _mk_fp_unary_norm(Z3_mk_fpa_is_subnormal, a, ctx)
9522 
def fpIsSubnormal(a, ctx=None)
Definition: z3py.py:9518

◆ fpIsZero()

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

Definition at line 9508 of file z3py.py.

9508 def fpIsZero(a, ctx=None):
9509  """Create a Z3 floating-point isZero expression.
9510  """
9511  return _mk_fp_unary_norm(Z3_mk_fpa_is_zero, a, ctx)
9512 
def fpIsZero(a, ctx=None)
Definition: z3py.py:9508

◆ 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 9549 of file z3py.py.

9549 def fpLEQ(a, b, ctx=None):
9550  """Create the Z3 floating-point expression `other <= self`.
9551 
9552  >>> x, y = FPs('x y', FPSort(8, 24))
9553  >>> fpLEQ(x, y)
9554  x <= y
9555  >>> (x <= y).sexpr()
9556  '(fp.leq x y)'
9557  """
9558  return _mk_fp_bin_pred(Z3_mk_fpa_leq, a, b, ctx)
9559 
def fpLEQ(a, b, ctx=None)
Definition: z3py.py:9549

◆ 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 9538 of file z3py.py.

9538 def fpLT(a, b, ctx=None):
9539  """Create the Z3 floating-point expression `other < self`.
9540 
9541  >>> x, y = FPs('x y', FPSort(8, 24))
9542  >>> fpLT(x, y)
9543  x < y
9544  >>> (x < y).sexpr()
9545  '(fp.lt x y)'
9546  """
9547  return _mk_fp_bin_pred(Z3_mk_fpa_lt, a, b, ctx)
9548 
def fpLT(a, b, ctx=None)
Definition: z3py.py:9538

◆ 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 9458 of file z3py.py.

9458 def fpMax(a, b, ctx=None):
9459  """Create a Z3 floating-point maximum expression.
9460 
9461  >>> s = FPSort(8, 24)
9462  >>> rm = RNE()
9463  >>> x = FP('x', s)
9464  >>> y = FP('y', s)
9465  >>> fpMax(x, y)
9466  fpMax(x, y)
9467  >>> fpMax(x, y).sort()
9468  FPSort(8, 24)
9469  """
9470  return _mk_fp_bin_norm(Z3_mk_fpa_max, a, b, ctx)
9471 
def fpMax(a, b, ctx=None)
Definition: z3py.py:9458

◆ 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 9444 of file z3py.py.

9444 def fpMin(a, b, ctx=None):
9445  """Create a Z3 floating-point minimum expression.
9446 
9447  >>> s = FPSort(8, 24)
9448  >>> rm = RNE()
9449  >>> x = FP('x', s)
9450  >>> y = FP('y', s)
9451  >>> fpMin(x, y)
9452  fpMin(x, y)
9453  >>> fpMin(x, y).sort()
9454  FPSort(8, 24)
9455  """
9456  return _mk_fp_bin_norm(Z3_mk_fpa_min, a, b, ctx)
9457 
def fpMin(a, b, ctx=None)
Definition: z3py.py:9444

◆ fpMinusInfinity()

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

Definition at line 9172 of file z3py.py.

9172 def fpMinusInfinity(s):
9173  """Create a Z3 floating-point -oo term."""
9174  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
9175  return FPNumRef(Z3_mk_fpa_inf(s.ctx_ref(), s.ast, True), s.ctx)
9176 
def fpMinusInfinity(s)
Definition: z3py.py:9172
Z3_ast Z3_API Z3_mk_fpa_inf(Z3_context c, Z3_sort s, bool negative)
Create a floating-point infinity of sort s.

◆ fpMinusZero()

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

Definition at line 9188 of file z3py.py.

9188 def fpMinusZero(s):
9189  """Create a Z3 floating-point -0.0 term."""
9190  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
9191  return FPNumRef(Z3_mk_fpa_zero(s.ctx_ref(), s.ast, True), s.ctx)
9192 
def fpMinusZero(s)
Definition: z3py.py:9188
Z3_ast Z3_API Z3_mk_fpa_zero(Z3_context c, Z3_sort s, bool negative)
Create a floating-point zero of sort s.

◆ fpMul()

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

Referenced by FPs().

9403 def fpMul(rm, a, b, ctx=None):
9404  """Create a Z3 floating-point multiplication expression.
9405 
9406  >>> s = FPSort(8, 24)
9407  >>> rm = RNE()
9408  >>> x = FP('x', s)
9409  >>> y = FP('y', s)
9410  >>> fpMul(rm, x, y)
9411  fpMul(RNE(), x, y)
9412  >>> fpMul(rm, x, y).sort()
9413  FPSort(8, 24)
9414  """
9415  return _mk_fp_bin(Z3_mk_fpa_mul, rm, a, b, ctx)
9416 
def fpMul(rm, a, b, ctx=None)
Definition: z3py.py:9403

◆ 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 9140 of file z3py.py.

9140 def fpNaN(s):
9141  """Create a Z3 floating-point NaN term.
9142 
9143  >>> s = FPSort(8, 24)
9144  >>> set_fpa_pretty(True)
9145  >>> fpNaN(s)
9146  NaN
9147  >>> pb = get_fpa_pretty()
9148  >>> set_fpa_pretty(False)
9149  >>> fpNaN(s)
9150  fpNaN(FPSort(8, 24))
9151  >>> set_fpa_pretty(pb)
9152  """
9153  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
9154  return FPNumRef(Z3_mk_fpa_nan(s.ctx_ref(), s.ast), s.ctx)
9155 
def fpNaN(s)
Definition: z3py.py:9140
Z3_ast Z3_API Z3_mk_fpa_nan(Z3_context c, Z3_sort s)
Create a floating-point NaN of sort s.

◆ 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 9306 of file z3py.py.

9306 def fpNeg(a, ctx=None):
9307  """Create a Z3 floating-point addition expression.
9308 
9309  >>> s = FPSort(8, 24)
9310  >>> rm = RNE()
9311  >>> x = FP('x', s)
9312  >>> fpNeg(x)
9313  -x
9314  >>> fpNeg(x).sort()
9315  FPSort(8, 24)
9316  """
9317  ctx = _get_ctx(ctx)
9318  [a] = _coerce_fp_expr_list([a], ctx)
9319  return FPRef(Z3_mk_fpa_neg(ctx.ref(), a.as_ast()), ctx)
9320 
Z3_ast Z3_API Z3_mk_fpa_neg(Z3_context c, Z3_ast t)
Floating-point negation.
def fpNeg(a, ctx=None)
Definition: z3py.py:9306

◆ 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 9593 of file z3py.py.

9593 def fpNEQ(a, b, ctx=None):
9594  """Create the Z3 floating-point expression `Not(fpEQ(other, self))`.
9595 
9596  >>> x, y = FPs('x y', FPSort(8, 24))
9597  >>> fpNEQ(x, y)
9598  Not(fpEQ(x, y))
9599  >>> (x != y).sexpr()
9600  '(distinct x y)'
9601  """
9602  return Not(fpEQ(a, b, ctx))
9603 
def fpEQ(a, b, ctx=None)
Definition: z3py.py:9582
def Not(a, ctx=None)
Definition: z3py.py:1630
def fpNEQ(a, b, ctx=None)
Definition: z3py.py:9593

◆ 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 9156 of file z3py.py.

9156 def fpPlusInfinity(s):
9157  """Create a Z3 floating-point +oo term.
9158 
9159  >>> s = FPSort(8, 24)
9160  >>> pb = get_fpa_pretty()
9161  >>> set_fpa_pretty(True)
9162  >>> fpPlusInfinity(s)
9163  +oo
9164  >>> set_fpa_pretty(False)
9165  >>> fpPlusInfinity(s)
9166  fpPlusInfinity(FPSort(8, 24))
9167  >>> set_fpa_pretty(pb)
9168  """
9169  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
9170  return FPNumRef(Z3_mk_fpa_inf(s.ctx_ref(), s.ast, False), s.ctx)
9171 
def fpPlusInfinity(s)
Definition: z3py.py:9156
Z3_ast Z3_API Z3_mk_fpa_inf(Z3_context c, Z3_sort s, bool negative)
Create a floating-point infinity of sort s.

◆ fpPlusZero()

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

Definition at line 9183 of file z3py.py.

9183 def fpPlusZero(s):
9184  """Create a Z3 floating-point +0.0 term."""
9185  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
9186  return FPNumRef(Z3_mk_fpa_zero(s.ctx_ref(), s.ast, False), s.ctx)
9187 
def fpPlusZero(s)
Definition: z3py.py:9183
Z3_ast Z3_API Z3_mk_fpa_zero(Z3_context c, Z3_sort s, bool negative)
Create a floating-point zero of sort s.

◆ 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 9705 of file z3py.py.

9705 def fpRealToFP(rm, v, sort, ctx=None):
9706  """Create a Z3 floating-point conversion expression that represents the
9707  conversion from a real term to a floating-point term.
9708 
9709  >>> x_r = RealVal(1.5)
9710  >>> x_fp = fpRealToFP(RNE(), x_r, Float32())
9711  >>> x_fp
9712  fpToFP(RNE(), 3/2)
9713  >>> simplify(x_fp)
9714  1.5
9715  """
9716  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression.")
9717  _z3_assert(is_real(v), "Second argument must be a Z3 expression or real sort.")
9718  _z3_assert(is_fp_sort(sort), "Third argument must be a Z3 floating-point sort.")
9719  ctx = _get_ctx(ctx)
9720  return FPRef(Z3_mk_fpa_to_fp_real(ctx.ref(), rm.ast, v.ast, sort.ast), ctx)
9721 
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.
def is_real(a)
Definition: z3py.py:2487
def is_fp_sort(s)
Definition: z3py.py:8671
def fpRealToFP(rm, v, sort, ctx=None)
Definition: z3py.py:9705
def is_fprm(a)
Definition: z3py.py:8919

◆ 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 9431 of file z3py.py.

9431 def fpRem(a, b, ctx=None):
9432  """Create a Z3 floating-point remainder expression.
9433 
9434  >>> s = FPSort(8, 24)
9435  >>> x = FP('x', s)
9436  >>> y = FP('y', s)
9437  >>> fpRem(x, y)
9438  fpRem(x, y)
9439  >>> fpRem(x, y).sort()
9440  FPSort(8, 24)
9441  """
9442  return _mk_fp_bin_norm(Z3_mk_fpa_rem, a, b, ctx)
9443 
def fpRem(a, b, ctx=None)
Definition: z3py.py:9431

◆ fpRoundToIntegral()

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

Definition at line 9482 of file z3py.py.

9482 def fpRoundToIntegral(rm, a, ctx=None):
9483  """Create a Z3 floating-point roundToIntegral expression.
9484  """
9485  return _mk_fp_unary(Z3_mk_fpa_round_to_integral, rm, a, ctx)
9486 
def fpRoundToIntegral(rm, a, ctx=None)
Definition: z3py.py:9482

◆ 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 9266 of file z3py.py.

Referenced by fpEQ(), fpGEQ(), fpGT(), fpLEQ(), fpLT(), and fpNEQ().

9266 def FPs(names, fpsort, ctx=None):
9267  """Return an array of floating-point constants.
9268 
9269  >>> x, y, z = FPs('x y z', FPSort(8, 24))
9270  >>> x.sort()
9271  FPSort(8, 24)
9272  >>> x.sbits()
9273  24
9274  >>> x.ebits()
9275  8
9276  >>> fpMul(RNE(), fpAdd(RNE(), x, y), z)
9277  fpMul(RNE(), fpAdd(RNE(), x, y), z)
9278  """
9279  ctx = _get_ctx(ctx)
9280  if isinstance(names, str):
9281  names = names.split(" ")
9282  return [FP(name, fpsort, ctx) for name in names]
9283 
def FPs(names, fpsort, ctx=None)
Definition: z3py.py:9266
def FP(name, fpsort, ctx=None)
Definition: z3py.py:9243

◆ 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 9722 of file z3py.py.

9722 def fpSignedToFP(rm, v, sort, ctx=None):
9723  """Create a Z3 floating-point conversion expression that represents the
9724  conversion from a signed bit-vector term (encoding an integer) to a floating-point term.
9725 
9726  >>> x_signed = BitVecVal(-5, BitVecSort(32))
9727  >>> x_fp = fpSignedToFP(RNE(), x_signed, Float32())
9728  >>> x_fp
9729  fpToFP(RNE(), 4294967291)
9730  >>> simplify(x_fp)
9731  -1.25*(2**2)
9732  """
9733  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression.")
9734  _z3_assert(is_bv(v), "Second argument must be a Z3 expression or real sort.")
9735  _z3_assert(is_fp_sort(sort), "Third argument must be a Z3 floating-point sort.")
9736  ctx = _get_ctx(ctx)
9737  return FPRef(Z3_mk_fpa_to_fp_signed(ctx.ref(), rm.ast, v.ast, sort.ast), ctx)
9738 
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&#39;s complement signed bit-vector term into a term of FloatingPoint sort...
def fpSignedToFP(rm, v, sort, ctx=None)
Definition: z3py.py:9722
def is_fp_sort(s)
Definition: z3py.py:8671
def is_bv(a)
Definition: z3py.py:3655
def is_fprm(a)
Definition: z3py.py:8919

◆ 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 9082 of file z3py.py.

Referenced by FPRef.__add__(), FPRef.__div__(), FPRef.__mul__(), FPRef.__radd__(), FPRef.__rdiv__(), FPRef.__rmul__(), FPRef.__rsub__(), FPRef.__sub__(), FPSortRef.cast(), FPSortRef.ebits(), FPRef.ebits(), FPNumRef.exponent(), FP(), fpAbs(), fpAdd(), fpDiv(), fpEQ(), fpFP(), fpFPToFP(), fpGEQ(), fpGT(), fpIsInf(), fpIsNaN(), fpLEQ(), fpLT(), fpMax(), fpMin(), fpMul(), fpNaN(), fpNeg(), fpNEQ(), fpPlusInfinity(), fpRem(), FPs(), fpSub(), fpToFP(), fpToIEEEBV(), fpToReal(), fpToSBV(), fpToUBV(), FPVal(), is_fp(), is_fp_sort(), is_fp_value(), is_fprm_sort(), FPNumRef.isNegative(), Context.mkFPSort(), Context.mkFPSort128(), Context.mkFPSort16(), Context.mkFPSort32(), Context.mkFPSort64(), Context.mkFPSortDouble(), Context.mkFPSortHalf(), Context.mkFPSortQuadruple(), Context.mkFPSortSingle(), FPSortRef.sbits(), FPRef.sbits(), FPNumRef.sign_as_bv(), FPNumRef.significand(), FPNumRef.significand_as_bv(), and FPRef.sort().

9082 def FPSort(ebits, sbits, ctx=None):
9083  """Return a Z3 floating-point sort of the given sizes. If `ctx=None`, then the global context is used.
9084 
9085  >>> Single = FPSort(8, 24)
9086  >>> Double = FPSort(11, 53)
9087  >>> Single
9088  FPSort(8, 24)
9089  >>> x = Const('x', Single)
9090  >>> eq(x, FP('x', FPSort(8, 24)))
9091  True
9092  """
9093  ctx = _get_ctx(ctx)
9094  return FPSortRef(Z3_mk_fpa_sort(ctx.ref(), ebits, sbits), ctx)
9095 
Z3_sort Z3_API Z3_mk_fpa_sort(Z3_context c, unsigned ebits, unsigned sbits)
Create a FloatingPoint sort.
def FPSort(ebits, sbits, ctx=None)
Definition: z3py.py:9082

◆ fpSqrt()

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

Definition at line 9477 of file z3py.py.

9477 def fpSqrt(rm, a, ctx=None):
9478  """Create a Z3 floating-point square root expression.
9479  """
9480  return _mk_fp_unary(Z3_mk_fpa_sqrt, rm, a, ctx)
9481 
def fpSqrt(rm, a, ctx=None)
Definition: z3py.py:9477

◆ 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 9389 of file z3py.py.

9389 def fpSub(rm, a, b, ctx=None):
9390  """Create a Z3 floating-point subtraction expression.
9391 
9392  >>> s = FPSort(8, 24)
9393  >>> rm = RNE()
9394  >>> x = FP('x', s)
9395  >>> y = FP('y', s)
9396  >>> fpSub(rm, x, y)
9397  fpSub(RNE(), x, y)
9398  >>> fpSub(rm, x, y).sort()
9399  FPSort(8, 24)
9400  """
9401  return _mk_fp_bin(Z3_mk_fpa_sub, rm, a, b, ctx)
9402 
def fpSub(rm, a, b, ctx=None)
Definition: z3py.py:9389

◆ 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 9632 of file z3py.py.

Referenced by fpBVToFP(), fpFPToFP(), fpRealToFP(), and fpSignedToFP().

9632 def fpToFP(a1, a2=None, a3=None, ctx=None):
9633  """Create a Z3 floating-point conversion expression from other term sorts
9634  to floating-point.
9635 
9636  From a bit-vector term in IEEE 754-2008 format:
9637  >>> x = FPVal(1.0, Float32())
9638  >>> x_bv = fpToIEEEBV(x)
9639  >>> simplify(fpToFP(x_bv, Float32()))
9640  1
9641 
9642  From a floating-point term with different precision:
9643  >>> x = FPVal(1.0, Float32())
9644  >>> x_db = fpToFP(RNE(), x, Float64())
9645  >>> x_db.sort()
9646  FPSort(11, 53)
9647 
9648  From a real term:
9649  >>> x_r = RealVal(1.5)
9650  >>> simplify(fpToFP(RNE(), x_r, Float32()))
9651  1.5
9652 
9653  From a signed bit-vector term:
9654  >>> x_signed = BitVecVal(-5, BitVecSort(32))
9655  >>> simplify(fpToFP(RNE(), x_signed, Float32()))
9656  -1.25*(2**2)
9657  """
9658  ctx = _get_ctx(ctx)
9659  if is_bv(a1) and is_fp_sort(a2):
9660  return FPRef(Z3_mk_fpa_to_fp_bv(ctx.ref(), a1.ast, a2.ast), ctx)
9661  elif is_fprm(a1) and is_fp(a2) and is_fp_sort(a3):
9662  return FPRef(Z3_mk_fpa_to_fp_float(ctx.ref(), a1.ast, a2.ast, a3.ast), ctx)
9663  elif is_fprm(a1) and is_real(a2) and is_fp_sort(a3):
9664  return FPRef(Z3_mk_fpa_to_fp_real(ctx.ref(), a1.ast, a2.ast, a3.ast), ctx)
9665  elif is_fprm(a1) and is_bv(a2) and is_fp_sort(a3):
9666  return FPRef(Z3_mk_fpa_to_fp_signed(ctx.ref(), a1.ast, a2.ast, a3.ast), ctx)
9667  else:
9668  raise Z3Exception("Unsupported combination of arguments for conversion to floating-point term.")
9669 
def fpToFP(a1, a2=None, a3=None, ctx=None)
Definition: z3py.py:9632
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.
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.
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&#39;s complement signed bit-vector term into a term of FloatingPoint sort...
def is_real(a)
Definition: z3py.py:2487
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.
def is_fp_sort(s)
Definition: z3py.py:8671
def is_bv(a)
Definition: z3py.py:3655
def is_fprm(a)
Definition: z3py.py:8919
def is_fp(a)
Definition: z3py.py:9055

◆ 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 9756 of file z3py.py.

Referenced by fpUnsignedToFP().

9756 def fpToFPUnsigned(rm, x, s, ctx=None):
9757  """Create a Z3 floating-point conversion expression, from unsigned bit-vector to floating-point expression."""
9758  if __debug__:
9759  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
9760  _z3_assert(is_bv(x), "Second argument must be a Z3 bit-vector expression")
9761  _z3_assert(is_fp_sort(s), "Third argument must be Z3 floating-point sort")
9762  ctx = _get_ctx(ctx)
9763  return FPRef(Z3_mk_fpa_to_fp_unsigned(ctx.ref(), rm.ast, x.ast, s.ast), ctx)
9764 
def fpToFPUnsigned(rm, x, s, ctx=None)
Definition: z3py.py:9756
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&#39;s complement unsigned bit-vector term into a term of FloatingPoint sort...
def is_fp_sort(s)
Definition: z3py.py:8671
def is_bv(a)
Definition: z3py.py:3655
def is_fprm(a)
Definition: z3py.py:8919

◆ 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 9826 of file z3py.py.

Referenced by fpToFP().

9826 def fpToIEEEBV(x, ctx=None):
9827  """\brief Conversion of a floating-point term into a bit-vector term in IEEE 754-2008 format.
9828 
9829  The size of the resulting bit-vector is automatically determined.
9830 
9831  Note that IEEE 754-2008 allows multiple different representations of NaN. This conversion
9832  knows only one NaN and it will always produce the same bit-vector representation of
9833  that NaN.
9834 
9835  >>> x = FP('x', FPSort(8, 24))
9836  >>> y = fpToIEEEBV(x)
9837  >>> print(is_fp(x))
9838  True
9839  >>> print(is_bv(y))
9840  True
9841  >>> print(is_fp(y))
9842  False
9843  >>> print(is_bv(x))
9844  False
9845  """
9846  if __debug__:
9847  _z3_assert(is_fp(x), "First argument must be a Z3 floating-point expression")
9848  ctx = _get_ctx(ctx)
9849  return BitVecRef(Z3_mk_fpa_to_ieee_bv(ctx.ref(), x.ast), ctx)
9850 
9851 
9852 
def fpToIEEEBV(x, ctx=None)
Definition: z3py.py:9826
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.
def is_fp(a)
Definition: z3py.py:9055

◆ 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 9807 of file z3py.py.

9807 def fpToReal(x, ctx=None):
9808  """Create a Z3 floating-point conversion expression, from floating-point expression to real.
9809 
9810  >>> x = FP('x', FPSort(8, 24))
9811  >>> y = fpToReal(x)
9812  >>> print(is_fp(x))
9813  True
9814  >>> print(is_real(y))
9815  True
9816  >>> print(is_fp(y))
9817  False
9818  >>> print(is_real(x))
9819  False
9820  """
9821  if __debug__:
9822  _z3_assert(is_fp(x), "First argument must be a Z3 floating-point expression")
9823  ctx = _get_ctx(ctx)
9824  return ArithRef(Z3_mk_fpa_to_real(ctx.ref(), x.ast), ctx)
9825 
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.
def fpToReal(x, ctx=None)
Definition: z3py.py:9807
def is_fp(a)
Definition: z3py.py:9055

◆ 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 9765 of file z3py.py.

9765 def fpToSBV(rm, x, s, ctx=None):
9766  """Create a Z3 floating-point conversion expression, from floating-point expression to signed bit-vector.
9767 
9768  >>> x = FP('x', FPSort(8, 24))
9769  >>> y = fpToSBV(RTZ(), x, BitVecSort(32))
9770  >>> print(is_fp(x))
9771  True
9772  >>> print(is_bv(y))
9773  True
9774  >>> print(is_fp(y))
9775  False
9776  >>> print(is_bv(x))
9777  False
9778  """
9779  if __debug__:
9780  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
9781  _z3_assert(is_fp(x), "Second argument must be a Z3 floating-point expression")
9782  _z3_assert(is_bv_sort(s), "Third argument must be Z3 bit-vector sort")
9783  ctx = _get_ctx(ctx)
9784  return BitVecRef(Z3_mk_fpa_to_sbv(ctx.ref(), rm.ast, x.ast, s.size()), ctx)
9785 
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.
def fpToSBV(rm, x, s, ctx=None)
Definition: z3py.py:9765
def is_bv_sort(s)
Definition: z3py.py:3194
def is_fprm(a)
Definition: z3py.py:8919
def is_fp(a)
Definition: z3py.py:9055

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

9786 def fpToUBV(rm, x, s, ctx=None):
9787  """Create a Z3 floating-point conversion expression, from floating-point expression to unsigned bit-vector.
9788 
9789  >>> x = FP('x', FPSort(8, 24))
9790  >>> y = fpToUBV(RTZ(), x, BitVecSort(32))
9791  >>> print(is_fp(x))
9792  True
9793  >>> print(is_bv(y))
9794  True
9795  >>> print(is_fp(y))
9796  False
9797  >>> print(is_bv(x))
9798  False
9799  """
9800  if __debug__:
9801  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
9802  _z3_assert(is_fp(x), "Second argument must be a Z3 floating-point expression")
9803  _z3_assert(is_bv_sort(s), "Third argument must be Z3 bit-vector sort")
9804  ctx = _get_ctx(ctx)
9805  return BitVecRef(Z3_mk_fpa_to_ubv(ctx.ref(), rm.ast, x.ast, s.size()), ctx)
9806 
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.
def fpToUBV(rm, x, s, ctx=None)
Definition: z3py.py:9786
def is_bv_sort(s)
Definition: z3py.py:3194
def is_fprm(a)
Definition: z3py.py:8919
def is_fp(a)
Definition: z3py.py:9055

◆ 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 9739 of file z3py.py.

9739 def fpUnsignedToFP(rm, v, sort, ctx=None):
9740  """Create a Z3 floating-point conversion expression that represents the
9741  conversion from an unsigned bit-vector term (encoding an integer) to a floating-point term.
9742 
9743  >>> x_signed = BitVecVal(-5, BitVecSort(32))
9744  >>> x_fp = fpUnsignedToFP(RNE(), x_signed, Float32())
9745  >>> x_fp
9746  fpToFPUnsigned(RNE(), 4294967291)
9747  >>> simplify(x_fp)
9748  1*(2**32)
9749  """
9750  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression.")
9751  _z3_assert(is_bv(v), "Second argument must be a Z3 expression or real sort.")
9752  _z3_assert(is_fp_sort(sort), "Third argument must be a Z3 floating-point sort.")
9753  ctx = _get_ctx(ctx)
9754  return FPRef(Z3_mk_fpa_to_fp_unsigned(ctx.ref(), rm.ast, v.ast, sort.ast), ctx)
9755 
def fpUnsignedToFP(rm, v, sort, ctx=None)
Definition: z3py.py:9739
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&#39;s complement unsigned bit-vector term into a term of FloatingPoint sort...
def is_fp_sort(s)
Definition: z3py.py:8671
def is_bv(a)
Definition: z3py.py:3655
def is_fprm(a)
Definition: z3py.py:8919

◆ 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 9199 of file z3py.py.

Referenced by FPNumRef.exponent(), fpAbs(), fpFP(), fpFPToFP(), fpToFP(), is_fp_value(), FPNumRef.isNegative(), FPNumRef.sign_as_bv(), FPNumRef.significand(), and FPNumRef.significand_as_bv().

9199 def FPVal(sig, exp=None, fps=None, ctx=None):
9200  """Return a floating-point value of value `val` and sort `fps`. If `ctx=None`, then the global context is used.
9201 
9202  >>> v = FPVal(20.0, FPSort(8, 24))
9203  >>> v
9204  1.25*(2**4)
9205  >>> print("0x%.8x" % v.exponent_as_long(False))
9206  0x00000004
9207  >>> v = FPVal(2.25, FPSort(8, 24))
9208  >>> v
9209  1.125*(2**1)
9210  >>> v = FPVal(-2.25, FPSort(8, 24))
9211  >>> v
9212  -1.125*(2**1)
9213  >>> FPVal(-0.0, FPSort(8, 24))
9214  -0.0
9215  >>> FPVal(0.0, FPSort(8, 24))
9216  +0.0
9217  >>> FPVal(+0.0, FPSort(8, 24))
9218  +0.0
9219  """
9220  ctx = _get_ctx(ctx)
9221  if is_fp_sort(exp):
9222  fps = exp
9223  exp = None
9224  elif fps is None:
9225  fps = _dflt_fps(ctx)
9226  _z3_assert(is_fp_sort(fps), "sort mismatch")
9227  if exp is None:
9228  exp = 0
9229  val = _to_float_str(sig)
9230  if val == "NaN" or val == "nan":
9231  return fpNaN(fps)
9232  elif val == "-0.0":
9233  return fpMinusZero(fps)
9234  elif val == "0.0" or val == "+0.0":
9235  return fpPlusZero(fps)
9236  elif val == "+oo" or val == "+inf" or val == "+Inf":
9237  return fpPlusInfinity(fps)
9238  elif val == "-oo" or val == "-inf" or val == "-Inf":
9239  return fpMinusInfinity(fps)
9240  else:
9241  return FPNumRef(Z3_mk_numeral(ctx.ref(), val, fps.ast), ctx)
9242 
def FPVal(sig, exp=None, fps=None, ctx=None)
Definition: z3py.py:9199
def fpMinusInfinity(s)
Definition: z3py.py:9172
def fpMinusZero(s)
Definition: z3py.py:9188
def fpPlusZero(s)
Definition: z3py.py:9183
def fpPlusInfinity(s)
Definition: z3py.py:9156
def fpNaN(s)
Definition: z3py.py:9140
def is_fp_sort(s)
Definition: z3py.py:8671
Z3_ast Z3_API Z3_mk_numeral(Z3_context c, Z3_string numeral, Z3_sort ty)
Create a numeral of a given sort.

◆ fpZero()

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

Definition at line 9193 of file z3py.py.

9193 def fpZero(s, negative):
9194  """Create a Z3 floating-point +0.0 or -0.0 term."""
9195  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
9196  _z3_assert(isinstance(negative, bool), "expected Boolean flag")
9197  return FPNumRef(Z3_mk_fpa_zero(s.ctx_ref(), s.ast, negative), s.ctx)
9198 
def fpZero(s, negative)
Definition: z3py.py:9193
Z3_ast Z3_API Z3_mk_fpa_zero(Z3_context c, Z3_sort s, bool negative)
Create a floating-point zero of sort s.

◆ 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 1587 of file z3py.py.

1587 def FreshBool(prefix='b', ctx=None):
1588  """Return a fresh Boolean constant in the given context using the given prefix.
1589 
1590  If `ctx=None`, then the global context is used.
1591 
1592  >>> b1 = FreshBool()
1593  >>> b2 = FreshBool()
1594  >>> eq(b1, b2)
1595  False
1596  """
1597  ctx = _get_ctx(ctx)
1598  return BoolRef(Z3_mk_fresh_const(ctx.ref(), prefix, BoolSort(ctx).ast), ctx)
1599 
def FreshBool(prefix='b', ctx=None)
Definition: z3py.py:1587
def BoolSort(ctx=None)
Definition: z3py.py:1512
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 1305 of file z3py.py.

1305 def FreshConst(sort, prefix='c'):
1306  """Create a fresh constant of a specified sort"""
1307  ctx = _get_ctx(sort.ctx)
1308  return _to_expr_ref(Z3_mk_fresh_const(ctx.ref(), prefix, sort.ast), ctx)
1309 
def FreshConst(sort, prefix='c')
Definition: z3py.py:1305
Z3_ast Z3_API Z3_mk_fresh_const(Z3_context c, Z3_string prefix, Z3_sort ty)
Declare and create a fresh constant.

◆ 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 3017 of file z3py.py.

3017 def FreshInt(prefix='x', ctx=None):
3018  """Return a fresh integer constant in the given context using the given prefix.
3019 
3020  >>> x = FreshInt()
3021  >>> y = FreshInt()
3022  >>> eq(x, y)
3023  False
3024  >>> x.sort()
3025  Int
3026  """
3027  ctx = _get_ctx(ctx)
3028  return ArithRef(Z3_mk_fresh_const(ctx.ref(), prefix, IntSort(ctx).ast), ctx)
3029 
def IntSort(ctx=None)
Definition: z3py.py:2879
def FreshInt(prefix='x', ctx=None)
Definition: z3py.py:3017
Z3_ast Z3_API Z3_mk_fresh_const(Z3_context c, Z3_string prefix, Z3_sort ty)
Declare and create a fresh constant.

◆ 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 3069 of file z3py.py.

3069 def FreshReal(prefix='b', ctx=None):
3070  """Return a fresh real constant in the given context using the given prefix.
3071 
3072  >>> x = FreshReal()
3073  >>> y = FreshReal()
3074  >>> eq(x, y)
3075  False
3076  >>> x.sort()
3077  Real
3078  """
3079  ctx = _get_ctx(ctx)
3080  return ArithRef(Z3_mk_fresh_const(ctx.ref(), prefix, RealSort(ctx).ast), ctx)
3081 
def FreshReal(prefix='b', ctx=None)
Definition: z3py.py:3069
def RealSort(ctx=None)
Definition: z3py.py:2895
Z3_ast Z3_API Z3_mk_fresh_const(Z3_context c, Z3_string prefix, Z3_sort ty)
Declare and create a fresh constant.

◆ Full()

def z3py.Full (   s)
Create the regular expression that accepts the universal language
>>> e = Full(ReSort(SeqSort(IntSort())))
>>> print(e)
re.all
>>> e1 = Full(ReSort(StringSort()))
>>> print(e1)
re.all

Definition at line 10014 of file z3py.py.

10014 def Full(s):
10015  """Create the regular expression that accepts the universal language
10016  >>> e = Full(ReSort(SeqSort(IntSort())))
10017  >>> print(e)
10018  re.all
10019  >>> e1 = Full(ReSort(StringSort()))
10020  >>> print(e1)
10021  re.all
10022  """
10023  if isinstance(s, ReSortRef):
10024  return ReRef(Z3_mk_re_full(s.ctx_ref(), s.ast), s.ctx)
10025  raise Z3Exception("Non-sequence, non-regular expression sort passed to Full")
10026 
10027 
def Full(s)
Definition: z3py.py:10014
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 4540 of file z3py.py.

4540 def FullSet(s):
4541  """Create the full set
4542  >>> FullSet(IntSort())
4543  K(Int, True)
4544  """
4545  ctx = s.ctx
4546  return ArrayRef(Z3_mk_full_set(ctx.ref(), s.ast), ctx)
4547 
Z3_ast Z3_API Z3_mk_full_set(Z3_context c, Z3_sort domain)
Create the full set.
def FullSet(s)
Definition: z3py.py:4540

◆ 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 778 of file z3py.py.

Referenced by ModelRef.__getitem__(), ModelRef.__len__(), FuncEntry.arg_value(), FuncInterp.arity(), FuncEntry.as_list(), FuncInterp.as_list(), QuantifierRef.body(), QuantifierRef.children(), ModelRef.decls(), FuncInterp.else_value(), FuncInterp.entry(), Exists(), ForAll(), ModelRef.get_interp(), get_map_func(), QuantifierRef.is_exists(), QuantifierRef.is_forall(), QuantifierRef.is_lambda(), is_map(), is_pattern(), is_quantifier(), Lambda(), Map(), MultiPattern(), FuncEntry.num_args(), FuncInterp.num_entries(), QuantifierRef.num_patterns(), QuantifierRef.num_vars(), QuantifierRef.pattern(), FuncEntry.value(), QuantifierRef.var_name(), QuantifierRef.var_sort(), and QuantifierRef.weight().

778 def Function(name, *sig):
779  """Create a new Z3 uninterpreted function with the given sorts.
780 
781  >>> f = Function('f', IntSort(), IntSort())
782  >>> f(f(0))
783  f(f(0))
784  """
785  sig = _get_args(sig)
786  if __debug__:
787  _z3_assert(len(sig) > 0, "At least two arguments expected")
788  arity = len(sig) - 1
789  rng = sig[arity]
790  if __debug__:
791  _z3_assert(is_sort(rng), "Z3 sort expected")
792  dom = (Sort * arity)()
793  for i in range(arity):
794  if __debug__:
795  _z3_assert(is_sort(sig[i]), "Z3 sort expected")
796  dom[i] = sig[i].ast
797  ctx = rng.ctx
798  return FuncDeclRef(Z3_mk_func_decl(ctx.ref(), to_symbol(name, ctx), arity, dom, rng.ast), ctx)
799 
def Function(name, sig)
Definition: z3py.py:778
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3244
def to_symbol(s, ctx=None)
Definition: z3py.py:105
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.
def is_sort(s)
Definition: z3py.py:579

◆ 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 6181 of file z3py.py.

6181 def get_as_array_func(n):
6182  """Return the function declaration f associated with a Z3 expression of the form (_ as-array f)."""
6183  if __debug__:
6184  _z3_assert(is_as_array(n), "as-array Z3 expression expected.")
6185  return FuncDeclRef(Z3_get_as_array_func_decl(n.ctx.ref(), n.as_ast()), n.ctx)
6186 
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.
def get_as_array_func(n)
Definition: z3py.py:6181
def is_as_array(n)
Definition: z3py.py:6177

◆ get_default_fp_sort()

def z3py.get_default_fp_sort (   ctx = None)

Definition at line 8551 of file z3py.py.

8551 def get_default_fp_sort(ctx=None):
8552  return FPSort(_dflt_fpsort_ebits, _dflt_fpsort_sbits, ctx)
8553 
def FPSort(ebits, sbits, ctx=None)
Definition: z3py.py:9082
def get_default_fp_sort(ctx=None)
Definition: z3py.py:8551

◆ get_default_rounding_mode()

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

Definition at line 8524 of file z3py.py.

8524 def get_default_rounding_mode(ctx=None):
8525  """Retrieves the global default rounding mode."""
8526  global _dflt_rounding_mode
8527  if _dflt_rounding_mode == Z3_OP_FPA_RM_TOWARD_ZERO:
8528  return RTZ(ctx)
8529  elif _dflt_rounding_mode == Z3_OP_FPA_RM_TOWARD_NEGATIVE:
8530  return RTN(ctx)
8531  elif _dflt_rounding_mode == Z3_OP_FPA_RM_TOWARD_POSITIVE:
8532  return RTP(ctx)
8533  elif _dflt_rounding_mode == Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN:
8534  return RNE(ctx)
8535  elif _dflt_rounding_mode == Z3_OP_FPA_RM_NEAREST_TIES_TO_AWAY:
8536  return RNA(ctx)
8537 
def RTN(ctx=None)
Definition: z3py.py:8907
def RTZ(ctx=None)
Definition: z3py.py:8915
def RTP(ctx=None)
Definition: z3py.py:8899
def RNA(ctx=None)
Definition: z3py.py:8891
def get_default_rounding_mode(ctx=None)
Definition: z3py.py:8524
def RNE(ctx=None)
Definition: z3py.py:8883

◆ get_full_version()

def z3py.get_full_version ( )

Definition at line 85 of file z3py.py.

85 def get_full_version():
86  return Z3_get_full_version()
87 
88 # We use _z3_assert instead of the assert command because we want to
89 # produce nice error messages in Z3Py at rise4fun.com
Z3_string Z3_API Z3_get_full_version(void)
Return a string that fully describes the version of Z3 in use.
def get_full_version()
Definition: z3py.py:85

◆ 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 4323 of file z3py.py.

4323 def get_map_func(a):
4324  """Return the function declaration associated with a Z3 map array expression.
4325 
4326  >>> f = Function('f', IntSort(), IntSort())
4327  >>> b = Array('b', IntSort(), IntSort())
4328  >>> a = Map(f, b)
4329  >>> eq(f, get_map_func(a))
4330  True
4331  >>> get_map_func(a)
4332  f
4333  >>> get_map_func(a)(0)
4334  f(0)
4335  """
4336  if __debug__:
4337  _z3_assert(is_map(a), "Z3 array map expression expected.")
4338  return FuncDeclRef(Z3_to_func_decl(a.ctx_ref(), Z3_get_decl_ast_parameter(a.ctx_ref(), a.decl().ast, 0)), a.ctx)
4339 
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.
def is_map(a)
Definition: z3py.py:4300
def get_map_func(a)
Definition: z3py.py:4323
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 266 of file z3py.py.

266 def get_param(name):
267  """Return the value of a Z3 global (or module) parameter
268 
269  >>> get_param('nlsat.reorder')
270  'true'
271  """
272  ptr = (ctypes.c_char_p * 1)()
273  if Z3_global_param_get(str(name), ptr):
274  r = z3core._to_pystr(ptr[0])
275  return r
276  raise Z3Exception("failed to retrieve value for '%s'" % name)
277 
Z3_bool Z3_API Z3_global_param_get(Z3_string param_id, Z3_string_ptr param_value)
Get a global (or module) parameter.
def get_param(name)
Definition: z3py.py:266

◆ 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 1183 of file z3py.py.

1183 def get_var_index(a):
1184  """Return the de-Bruijn index of the Z3 bounded variable `a`.
1185 
1186  >>> x = Int('x')
1187  >>> y = Int('y')
1188  >>> is_var(x)
1189  False
1190  >>> is_const(x)
1191  True
1192  >>> f = Function('f', IntSort(), IntSort(), IntSort())
1193  >>> # Z3 replaces x and y with bound variables when ForAll is executed.
1194  >>> q = ForAll([x, y], f(x, y) == x + y)
1195  >>> q.body()
1196  f(Var(1), Var(0)) == Var(1) + Var(0)
1197  >>> b = q.body()
1198  >>> b.arg(0)
1199  f(Var(1), Var(0))
1200  >>> v1 = b.arg(0).arg(0)
1201  >>> v2 = b.arg(0).arg(1)
1202  >>> v1
1203  Var(1)
1204  >>> v2
1205  Var(0)
1206  >>> get_var_index(v1)
1207  1
1208  >>> get_var_index(v2)
1209  0
1210  """
1211  if __debug__:
1212  _z3_assert(is_var(a), "Z3 bound variable expected")
1213  return int(Z3_get_index_value(a.ctx.ref(), a.as_ast()))
1214 
unsigned Z3_API Z3_get_index_value(Z3_context c, Z3_ast a)
Return index of de-Bruijn bound variable.
def get_var_index(a)
Definition: z3py.py:1183
def is_var(a)
Definition: z3py.py:1159

◆ get_version()

def z3py.get_version ( )

Definition at line 77 of file z3py.py.

77 def get_version():
78  major = ctypes.c_uint(0)
79  minor = ctypes.c_uint(0)
80  build = ctypes.c_uint(0)
81  rev = ctypes.c_uint(0)
82  Z3_get_version(major, minor, build, rev)
83  return (major.value, minor.value, build.value, rev.value)
84 
def get_version()
Definition: z3py.py:77
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 69 of file z3py.py.

69 def get_version_string():
70  major = ctypes.c_uint(0)
71  minor = ctypes.c_uint(0)
72  build = ctypes.c_uint(0)
73  rev = ctypes.c_uint(0)
74  Z3_get_version(major, minor, build, rev)
75  return "%s.%s.%s" % (major.value, minor.value, build.value)
76 
def get_version_string()
Definition: z3py.py:69
void Z3_API Z3_get_version(unsigned *major, unsigned *minor, unsigned *build_number, unsigned *revision_number)
Return Z3 version number information.

◆ help_simplify()

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

Definition at line 8110 of file z3py.py.

8110 def help_simplify():
8111  """Return a string describing all options available for Z3 `simplify` procedure."""
8112  print(Z3_simplify_get_help(main_ctx().ref()))
8113 
def main_ctx()
Definition: z3py.py:207
def help_simplify()
Definition: z3py.py:8110
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 1227 of file z3py.py.

Referenced by BoolRef.__mul__(), BV2Int(), and Lambda().

1227 def If(a, b, c, ctx=None):
1228  """Create a Z3 if-then-else expression.
1229 
1230  >>> x = Int('x')
1231  >>> y = Int('y')
1232  >>> max = If(x > y, x, y)
1233  >>> max
1234  If(x > y, x, y)
1235  >>> simplify(max)
1236  If(x <= y, y, x)
1237  """
1238  if isinstance(a, Probe) or isinstance(b, Tactic) or isinstance(c, Tactic):
1239  return Cond(a, b, c, ctx)
1240  else:
1241  ctx = _get_ctx(_ctx_from_ast_arg_list([a, b, c], ctx))
1242  s = BoolSort(ctx)
1243  a = s.cast(a)
1244  b, c = _coerce_exprs(b, c, ctx)
1245  if __debug__:
1246  _z3_assert(a.ctx == b.ctx, "Context mismatch")
1247  return _to_expr_ref(Z3_mk_ite(ctx.ref(), a.as_ast(), b.as_ast(), c.as_ast()), ctx)
1248 
def If(a, b, c, ctx=None)
Definition: z3py.py:1227
def Cond(p, t1, t2, ctx=None)
Definition: z3py.py:8070
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).
def BoolSort(ctx=None)
Definition: z3py.py:1512

◆ Implies()

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

>>> p, q = Bools('p q')
>>> Implies(p, q)
Implies(p, q)
>>> simplify(Implies(p, q))
Or(Not(p), q)

Definition at line 1600 of file z3py.py.

Referenced by Fixedpoint.add_rule(), Solver.consequences(), Store(), Solver.unsat_core(), Update(), and Fixedpoint.update_rule().

1600 def Implies(a, b, ctx=None):
1601  """Create a Z3 implies expression.
1602 
1603  >>> p, q = Bools('p q')
1604  >>> Implies(p, q)
1605  Implies(p, q)
1606  >>> simplify(Implies(p, q))
1607  Or(Not(p), q)
1608  """
1609  ctx = _get_ctx(_ctx_from_ast_arg_list([a, b], ctx))
1610  s = BoolSort(ctx)
1611  a = s.cast(a)
1612  b = s.cast(b)
1613  return BoolRef(Z3_mk_implies(ctx.ref(), a.as_ast(), b.as_ast()), ctx)
1614 
def Implies(a, b, ctx=None)
Definition: z3py.py:1600
Z3_ast Z3_API Z3_mk_implies(Z3_context c, Z3_ast t1, Z3_ast t2)
Create an AST node representing t1 implies t2.
def BoolSort(ctx=None)
Definition: z3py.py:1512

◆ IndexOf() [1/2]

def z3py.IndexOf (   s,
  substr 
)

Definition at line 10093 of file z3py.py.

Referenced by IndexOf().

10093 def IndexOf(s, substr):
10094  return IndexOf(s, substr, IntVal(0))
10095 
def IntVal(val, ctx=None)
Definition: z3py.py:2926
def IndexOf(s, substr)
Definition: z3py.py:10093

◆ IndexOf() [2/2]

def z3py.IndexOf (   s,
  substr,
  offset 
)
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 10096 of file z3py.py.

10096 def IndexOf(s, substr, offset):
10097  """Retrieve the index of substring within a string starting at a specified offset.
10098  >>> simplify(IndexOf("abcabc", "bc", 0))
10099  1
10100  >>> simplify(IndexOf("abcabc", "bc", 2))
10101  4
10102  """
10103  ctx = None
10104  if is_expr(offset):
10105  ctx = offset.ctx
10106  ctx = _get_ctx2(s, substr, ctx)
10107  s = _coerce_seq(s, ctx)
10108  substr = _coerce_seq(substr, ctx)
10109  if _is_int(offset):
10110  offset = IntVal(offset, ctx)
10111  return SeqRef(Z3_mk_seq_index(s.ctx_ref(), s.as_ast(), substr.as_ast(), offset.as_ast()), s.ctx)
10112 
def IntVal(val, ctx=None)
Definition: z3py.py:2926
def IndexOf(s, substr)
Definition: z3py.py:10093
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...
def is_expr(a)
Definition: z3py.py:1094

◆ 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 10183 of file z3py.py.

Referenced by Loop(), Option(), Plus(), Star(), and Union().

10183 def InRe(s, re):
10184  """Create regular expression membership test
10185  >>> re = Union(Re("a"),Re("b"))
10186  >>> print (simplify(InRe("a", re)))
10187  True
10188  >>> print (simplify(InRe("b", re)))
10189  True
10190  >>> print (simplify(InRe("c", re)))
10191  False
10192  """
10193  s = _coerce_seq(s, re.ctx)
10194  return BoolRef(Z3_mk_seq_in_re(s.ctx_ref(), s.as_ast(), re.as_ast()), s.ctx)
10195 
def InRe(s, re)
Definition: z3py.py:10183
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 2982 of file z3py.py.

Referenced by ArithRef.__add__(), AstVector.__contains__(), AstMap.__contains__(), ArithRef.__div__(), Statistics.__getattr__(), ArrayRef.__getitem__(), AstVector.__getitem__(), AstMap.__getitem__(), ModelRef.__getitem__(), Statistics.__getitem__(), AstVector.__len__(), AstMap.__len__(), ModelRef.__len__(), Statistics.__len__(), ArithRef.__mod__(), ArithRef.__neg__(), ArithRef.__pos__(), ArithRef.__radd__(), ArithRef.__rdiv__(), ArithRef.__rmod__(), ArithRef.__rsub__(), AstVector.__setitem__(), AstMap.__setitem__(), ArithRef.__sub__(), Goal.add(), Solver.add(), Goal.append(), Solver.append(), Goal.as_expr(), Solver.assert_and_track(), Goal.assert_exprs(), Solver.assert_exprs(), Solver.assertions(), QuantifierRef.body(), BV2Int(), Solver.check(), QuantifierRef.children(), ModelRef.decls(), AstMap.erase(), ModelRef.eval(), ModelRef.evaluate(), Exists(), ForAll(), ModelRef.get_interp(), Statistics.get_key_value(), Goal.insert(), Solver.insert(), is_arith(), is_arith_sort(), is_bv(), QuantifierRef.is_exists(), QuantifierRef.is_forall(), is_fp(), ArithSortRef.is_int(), ArithRef.is_int(), is_int(), is_int_value(), QuantifierRef.is_lambda(), is_pattern(), is_quantifier(), ArithSortRef.is_real(), is_real(), is_select(), is_to_real(), K(), AstMap.keys(), Statistics.keys(), Solver.model(), MultiPattern(), QuantifierRef.num_patterns(), QuantifierRef.num_vars(), QuantifierRef.pattern(), Solver.pop(), AstVector.push(), Solver.push(), Solver.reason_unknown(), AstMap.reset(), Solver.reset(), AstVector.resize(), Select(), Solver.sexpr(), Goal.simplify(), ArithRef.sort(), Solver.statistics(), Store(), ToReal(), Goal.translate(), AstVector.translate(), Update(), QuantifierRef.var_name(), QuantifierRef.var_sort(), and QuantifierRef.weight().

2982 def Int(name, ctx=None):
2983  """Return an integer constant named `name`. If `ctx=None`, then the global context is used.
2984 
2985  >>> x = Int('x')
2986  >>> is_int(x)
2987  True
2988  >>> is_int(x + 1)
2989  True
2990  """
2991  ctx = _get_ctx(ctx)
2992  return ArithRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), IntSort(ctx).ast), ctx)
2993 
Z3_ast Z3_API Z3_mk_const(Z3_context c, Z3_symbol s, Z3_sort ty)
Declare and create a constant.
def to_symbol(s, ctx=None)
Definition: z3py.py:105
def Int(name, ctx=None)
Definition: z3py.py:2982
def IntSort(ctx=None)
Definition: z3py.py:2879

◆ 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 3704 of file z3py.py.

3704 def Int2BV(a, num_bits):
3705  """Return the z3 expression Int2BV(a, num_bits).
3706  It is a bit-vector of width num_bits and represents the
3707  modulo of a by 2^num_bits
3708  """
3709  ctx = a.ctx
3710  return BitVecRef(Z3_mk_int2bv(ctx.ref(), num_bits, a.as_ast()), ctx)
3711 
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.
def Int2BV(a, num_bits)
Definition: z3py.py:3704

◆ 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 2994 of file z3py.py.

Referenced by ArithRef.__ge__(), Goal.__getitem__(), ArithRef.__gt__(), ArithRef.__le__(), Goal.__len__(), ArithRef.__lt__(), Goal.convert_model(), Goal.depth(), Goal.get(), Goal.inconsistent(), is_add(), is_div(), is_ge(), is_gt(), is_idiv(), is_le(), is_lt(), is_mod(), is_mul(), is_sub(), Lambda(), Goal.prec(), Goal.size(), Store(), Solver.unsat_core(), and Update().

2994 def Ints(names, ctx=None):
2995  """Return a tuple of Integer constants.
2996 
2997  >>> x, y, z = Ints('x y z')
2998  >>> Sum(x, y, z)
2999  x + y + z
3000  """
3001  ctx = _get_ctx(ctx)
3002  if isinstance(names, str):
3003  names = names.split(" ")
3004  return [Int(name, ctx) for name in names]
3005 
def Int(name, ctx=None)
Definition: z3py.py:2982
def Ints(names, ctx=None)
Definition: z3py.py:2994

◆ 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 2879 of file z3py.py.

Referenced by ArrayRef.__getitem__(), ModelRef.__getitem__(), ModelRef.__len__(), DatatypeSortRef.accessor(), FuncEntry.arg_value(), FuncInterp.arity(), Array(), ArraySort(), FuncEntry.as_list(), FuncInterp.as_list(), QuantifierRef.body(), ArithSortRef.cast(), QuantifierRef.children(), DatatypeSortRef.constructor(), Datatype.create(), CreateDatatypes(), Datatype.declare(), ModelRef.decls(), Default(), ArraySortRef.domain(), ArrayRef.domain(), FuncInterp.else_value(), Empty(), EmptySet(), FuncInterp.entry(), Exists(), ForAll(), Full(), FullSet(), ModelRef.get_interp(), get_map_func(), Context.getIntSort(), is_arith_sort(), is_array(), is_bv_sort(), is_const_array(), is_default(), QuantifierRef.is_exists(), QuantifierRef.is_forall(), is_fp_sort(), is_K(), QuantifierRef.is_lambda(), is_map(), is_pattern(), is_quantifier(), is_select(), is_store(), SeqSortRef.is_string(), IsMember(), IsSubset(), K(), Lambda(), Map(), Context.mkIntSort(), MultiPattern(), FuncEntry.num_args(), DatatypeSortRef.num_constructors(), FuncInterp.num_entries(), QuantifierRef.num_patterns(), QuantifierRef.num_vars(), QuantifierRef.pattern(), ArraySortRef.range(), ArrayRef.range(), DatatypeSortRef.recognizer(), Select(), SeqSort(), SetAdd(), SetComplement(), SetDel(), SetDifference(), SetIntersect(), SetUnion(), ArrayRef.sort(), Store(), Update(), FuncEntry.value(), QuantifierRef.var_name(), QuantifierRef.var_sort(), and QuantifierRef.weight().

2879 def IntSort(ctx=None):
2880  """Return the integer sort in the given context. If `ctx=None`, then the global context is used.
2881 
2882  >>> IntSort()
2883  Int
2884  >>> x = Const('x', IntSort())
2885  >>> is_int(x)
2886  True
2887  >>> x.sort() == IntSort()
2888  True
2889  >>> x.sort() == BoolSort()
2890  False
2891  """
2892  ctx = _get_ctx(ctx)
2893  return ArithSortRef(Z3_mk_int_sort(ctx.ref()), ctx)
2894 
Z3_sort Z3_API Z3_mk_int_sort(Z3_context c)
Create the integer type.
def IntSort(ctx=None)
Definition: z3py.py:2879

◆ IntToStr()

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

Definition at line 10138 of file z3py.py.

Referenced by StrToInt().

10138 def IntToStr(s):
10139  """Convert integer expression to string"""
10140  if not is_expr(s):
10141  s = _py2expr(s)
10142  return SeqRef(Z3_mk_int_to_str(s.ctx_ref(), s.as_ast()), s.ctx)
10143 
10144 
def IntToStr(s)
Definition: z3py.py:10138
def is_expr(a)
Definition: z3py.py:1094
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 2926 of file z3py.py.

Referenced by AstMap.__len__(), ArithRef.__mod__(), ArithRef.__pow__(), ArithRef.__rpow__(), AstMap.__setitem__(), IntNumRef.as_long(), IntNumRef.as_string(), is_arith(), is_int(), is_int_value(), is_rational_value(), is_seq(), AstMap.keys(), AstMap.reset(), and SeqSort().

2926 def IntVal(val, ctx=None):
2927  """Return a Z3 integer value. If `ctx=None`, then the global context is used.
2928 
2929  >>> IntVal(1)
2930  1
2931  >>> IntVal("100")
2932  100
2933  """
2934  ctx = _get_ctx(ctx)
2935  return IntNumRef(Z3_mk_numeral(ctx.ref(), _to_int_str(val), IntSort(ctx).ast), ctx)
2936 
def IntVal(val, ctx=None)
Definition: z3py.py:2926
def IntSort(ctx=None)
Definition: z3py.py:2879
Z3_ast Z3_API Z3_mk_numeral(Z3_context c, Z3_string numeral, Z3_sort ty)
Create a numeral of a given sort.

◆ 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 3006 of file z3py.py.

3006 def IntVector(prefix, sz, ctx=None):
3007  """Return a list of integer constants of size `sz`.
3008 
3009  >>> X = IntVector('x', 3)
3010  >>> X
3011  [x__0, x__1, x__2]
3012  >>> Sum(X)
3013  x__0 + x__1 + x__2
3014  """
3015  return [ Int('%s__%s' % (prefix, i)) for i in range(sz) ]
3016 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3244
def Int(name, ctx=None)
Definition: z3py.py:2982
def IntVector(prefix, sz, ctx=None)
Definition: z3py.py:3006

◆ 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 2568 of file z3py.py.

2568 def is_add(a):
2569  """Return `True` if `a` is an expression of the form b + c.
2570 
2571  >>> x, y = Ints('x y')
2572  >>> is_add(x + y)
2573  True
2574  >>> is_add(x - y)
2575  False
2576  """
2577  return is_app_of(a, Z3_OP_ADD)
2578 
def is_app_of(a, k)
Definition: z3py.py:1215
def is_add(a)
Definition: z3py.py:2568

◆ 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 2555 of file z3py.py.

2555 def is_algebraic_value(a):
2556  """Return `True` if `a` is an algebraic value of sort Real.
2557 
2558  >>> is_algebraic_value(RealVal("3/5"))
2559  False
2560  >>> n = simplify(Sqrt(2))
2561  >>> n
2562  1.4142135623?
2563  >>> is_algebraic_value(n)
2564  True
2565  """
2566  return is_arith(a) and a.is_real() and _is_algebraic(a.ctx, a.as_ast())
2567 
def is_arith(a)
Definition: z3py.py:2449
def is_algebraic_value(a)
Definition: z3py.py:2555

◆ 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 1448 of file z3py.py.

1448 def is_and(a):
1449  """Return `True` if `a` is a Z3 and expression.
1450 
1451  >>> p, q = Bools('p q')
1452  >>> is_and(And(p, q))
1453  True
1454  >>> is_and(Or(p, q))
1455  False
1456  """
1457  return is_app_of(a, Z3_OP_AND)
1458 
def is_and(a)
Definition: z3py.py:1448
def is_app_of(a, k)
Definition: z3py.py:1215

◆ 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 1116 of file z3py.py.

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

1116 def is_app(a):
1117  """Return `True` if `a` is a Z3 function application.
1118 
1119  Note that, constants are function applications with 0 arguments.
1120 
1121  >>> a = Int('a')
1122  >>> is_app(a)
1123  True
1124  >>> is_app(a + 1)
1125  True
1126  >>> is_app(IntSort())
1127  False
1128  >>> is_app(1)
1129  False
1130  >>> is_app(IntVal(1))
1131  True
1132  >>> x = Int('x')
1133  >>> is_app(ForAll(x, x >= 0))
1134  False
1135  """
1136  if not isinstance(a, ExprRef):
1137  return False
1138  k = _ast_kind(a.ctx, a)
1139  return k == Z3_NUMERAL_AST or k == Z3_APP_AST
1140 
def is_app(a)
Definition: z3py.py:1116

◆ 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 1215 of file z3py.py.

Referenced by is_and(), is_distinct(), is_eq(), is_false(), is_implies(), is_not(), is_or(), and is_true().

1215 def is_app_of(a, k):
1216  """Return `True` if `a` is an application of the given kind `k`.
1217 
1218  >>> x = Int('x')
1219  >>> n = x + 1
1220  >>> is_app_of(n, Z3_OP_ADD)
1221  True
1222  >>> is_app_of(n, Z3_OP_MUL)
1223  False
1224  """
1225  return is_app(a) and a.decl().kind() == k
1226 
def is_app(a)
Definition: z3py.py:1116
def is_app_of(a, k)
Definition: z3py.py:1215

◆ 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 2449 of file z3py.py.

2449 def is_arith(a):
2450  """Return `True` if `a` is an arithmetical expression.
2451 
2452  >>> x = Int('x')
2453  >>> is_arith(x)
2454  True
2455  >>> is_arith(x + 1)
2456  True
2457  >>> is_arith(1)
2458  False
2459  >>> is_arith(IntVal(1))
2460  True
2461  >>> y = Real('y')
2462  >>> is_arith(y)
2463  True
2464  >>> is_arith(y + 1)
2465  True
2466  """
2467  return isinstance(a, ArithRef)
2468 
def is_arith(a)
Definition: z3py.py:2449

◆ 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 2150 of file z3py.py.

2150 def is_arith_sort(s):
2151  """Return `True` if s is an arithmetical sort (type).
2152 
2153  >>> is_arith_sort(IntSort())
2154  True
2155  >>> is_arith_sort(RealSort())
2156  True
2157  >>> is_arith_sort(BoolSort())
2158  False
2159  >>> n = Int('x') + 1
2160  >>> is_arith_sort(n.sort())
2161  True
2162  """
2163  return isinstance(s, ArithSortRef)
2164 
def is_arith_sort(s)
Definition: z3py.py:2150

◆ 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 4263 of file z3py.py.

4263 def is_array(a):
4264  """Return `True` if `a` is a Z3 array expression.
4265 
4266  >>> a = Array('a', IntSort(), IntSort())
4267  >>> is_array(a)
4268  True
4269  >>> is_array(Store(a, 0, 1))
4270  True
4271  >>> is_array(a[0])
4272  False
4273  """
4274  return isinstance(a, ArrayRef)
4275 
def is_array(a)
Definition: z3py.py:4263

◆ 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 6177 of file z3py.py.

6177 def is_as_array(n):
6178  """Return true if n is a Z3 expression of the form (_ as-array f)."""
6179  return isinstance(n, ExprRef) and Z3_is_as_array(n.ctx.ref(), n.as_ast())
6180 
def is_as_array(n)
Definition: z3py.py:6177
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...

◆ 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 396 of file z3py.py.

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

396 def is_ast(a):
397  """Return `True` if `a` is an AST node.
398 
399  >>> is_ast(10)
400  False
401  >>> is_ast(IntVal(10))
402  True
403  >>> is_ast(Int('x'))
404  True
405  >>> is_ast(BoolSort())
406  True
407  >>> is_ast(Function('f', IntSort(), IntSort()))
408  True
409  >>> is_ast("x")
410  False
411  >>> is_ast(Solver())
412  False
413  """
414  return isinstance(a, AstRef)
415 
def is_ast(a)
Definition: z3py.py:396

◆ 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 1401 of file z3py.py.

Referenced by BoolSort(), and prove().

1401 def is_bool(a):
1402  """Return `True` if `a` is a Z3 Boolean expression.
1403 
1404  >>> p = Bool('p')
1405  >>> is_bool(p)
1406  True
1407  >>> q = Bool('q')
1408  >>> is_bool(And(p, q))
1409  True
1410  >>> x = Real('x')
1411  >>> is_bool(x)
1412  False
1413  >>> is_bool(x == 0)
1414  True
1415  """
1416  return isinstance(a, BoolRef)
1417 
def is_bool(a)
Definition: z3py.py:1401

◆ 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 3655 of file z3py.py.

Referenced by BitVec(), fpToIEEEBV(), fpToSBV(), fpToUBV(), Product(), and Sum().

3655 def is_bv(a):
3656  """Return `True` if `a` is a Z3 bit-vector expression.
3657 
3658  >>> b = BitVec('b', 32)
3659  >>> is_bv(b)
3660  True
3661  >>> is_bv(b + 10)
3662  True
3663  >>> is_bv(Int('x'))
3664  False
3665  """
3666  return isinstance(a, BitVecRef)
3667 
def is_bv(a)
Definition: z3py.py:3655

◆ 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 3194 of file z3py.py.

3194 def is_bv_sort(s):
3195  """Return True if `s` is a Z3 bit-vector sort.
3196 
3197  >>> is_bv_sort(BitVecSort(32))
3198  True
3199  >>> is_bv_sort(IntSort())
3200  False
3201  """
3202  return isinstance(s, BitVecSortRef)
3203 
def is_bv_sort(s)
Definition: z3py.py:3194

◆ 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 3668 of file z3py.py.

3668 def is_bv_value(a):
3669  """Return `True` if `a` is a Z3 bit-vector numeral value.
3670 
3671  >>> b = BitVec('b', 32)
3672  >>> is_bv_value(b)
3673  False
3674  >>> b = BitVecVal(10, 32)
3675  >>> b
3676  10
3677  >>> is_bv_value(b)
3678  True
3679  """
3680  return is_bv(a) and _is_numeral(a.ctx, a.as_ast())
3681 
def is_bv_value(a)
Definition: z3py.py:3668
def is_bv(a)
Definition: z3py.py:3655

◆ 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 1141 of file z3py.py.

Referenced by prove().

1141 def is_const(a):
1142  """Return `True` if `a` is Z3 constant/variable expression.
1143 
1144  >>> a = Int('a')
1145  >>> is_const(a)
1146  True
1147  >>> is_const(a + 1)
1148  False
1149  >>> is_const(1)
1150  False
1151  >>> is_const(IntVal(1))
1152  True
1153  >>> x = Int('x')
1154  >>> is_const(ForAll(x, x >= 0))
1155  False
1156  """
1157  return is_app(a) and a.num_args() == 0
1158 
def is_app(a)
Definition: z3py.py:1116
def is_const(a)
Definition: z3py.py:1141

◆ 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 4276 of file z3py.py.

4276 def is_const_array(a):
4277  """Return `True` if `a` is a Z3 constant array.
4278 
4279  >>> a = K(IntSort(), 10)
4280  >>> is_const_array(a)
4281  True
4282  >>> a = Array('a', IntSort(), IntSort())
4283  >>> is_const_array(a)
4284  False
4285  """
4286  return is_app_of(a, Z3_OP_CONST_ARRAY)
4287 
def is_const_array(a)
Definition: z3py.py:4276
def is_app_of(a, k)
Definition: z3py.py:1215

◆ 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 4315 of file z3py.py.

4315 def is_default(a):
4316  """Return `True` if `a` is a Z3 default array expression.
4317  >>> d = Default(K(IntSort(), 10))
4318  >>> is_default(d)
4319  True
4320  """
4321  return is_app_of(a, Z3_OP_ARRAY_DEFAULT)
4322 
def is_default(a)
Definition: z3py.py:4315
def is_app_of(a, k)
Definition: z3py.py:1215

◆ 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 1501 of file z3py.py.

1501 def is_distinct(a):
1502  """Return `True` if `a` is a Z3 distinct expression.
1503 
1504  >>> x, y, z = Ints('x y z')
1505  >>> is_distinct(x == y)
1506  False
1507  >>> is_distinct(Distinct(x, y, z))
1508  True
1509  """
1510  return is_app_of(a, Z3_OP_DISTINCT)
1511 
def is_distinct(a)
Definition: z3py.py:1501
def is_app_of(a, k)
Definition: z3py.py:1215

◆ 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 2601 of file z3py.py.

2601 def is_div(a):
2602  """Return `True` if `a` is an expression of the form b / c.
2603 
2604  >>> x, y = Reals('x y')
2605  >>> is_div(x / y)
2606  True
2607  >>> is_div(x + y)
2608  False
2609  >>> x, y = Ints('x y')
2610  >>> is_div(x / y)
2611  False
2612  >>> is_idiv(x / y)
2613  True
2614  """
2615  return is_app_of(a, Z3_OP_DIV)
2616 
def is_div(a)
Definition: z3py.py:2601
def is_app_of(a, k)
Definition: z3py.py:1215

◆ 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 1492 of file z3py.py.

Referenced by AstRef.__bool__().

1492 def is_eq(a):
1493  """Return `True` if `a` is a Z3 equality expression.
1494 
1495  >>> x, y = Ints('x y')
1496  >>> is_eq(x == y)
1497  True
1498  """
1499  return is_app_of(a, Z3_OP_EQ)
1500 
def is_eq(a)
Definition: z3py.py:1492
def is_app_of(a, k)
Definition: z3py.py:1215

◆ 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 1094 of file z3py.py.

Referenced by SortRef.cast(), BoolSortRef.cast(), ExprRef.children(), is_var(), simplify(), substitute(), and substitute_vars().

1094 def is_expr(a):
1095  """Return `True` if `a` is a Z3 expression.
1096 
1097  >>> a = Int('a')
1098  >>> is_expr(a)
1099  True
1100  >>> is_expr(a + 1)
1101  True
1102  >>> is_expr(IntSort())
1103  False
1104  >>> is_expr(1)
1105  False
1106  >>> is_expr(IntVal(1))
1107  True
1108  >>> x = Int('x')
1109  >>> is_expr(ForAll(x, x >= 0))
1110  True
1111  >>> is_expr(FPVal(1.0))
1112  True
1113  """
1114  return isinstance(a, ExprRef)
1115 
def is_expr(a)
Definition: z3py.py:1094

◆ 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 1435 of file z3py.py.

Referenced by AstRef.__bool__(), and BoolVal().

1435 def is_false(a):
1436  """Return `True` if `a` is the Z3 false expression.
1437 
1438  >>> p = Bool('p')
1439  >>> is_false(p)
1440  False
1441  >>> is_false(False)
1442  False
1443  >>> is_false(BoolVal(False))
1444  True
1445  """
1446  return is_app_of(a, Z3_OP_FALSE)
1447 
def is_app_of(a, k)
Definition: z3py.py:1215
def is_false(a)
Definition: z3py.py:1435

◆ 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 7177 of file z3py.py.

Referenced by is_finite_domain_value().

7177 def is_finite_domain(a):
7178  """Return `True` if `a` is a Z3 finite-domain expression.
7179 
7180  >>> s = FiniteDomainSort('S', 100)
7181  >>> b = Const('b', s)
7182  >>> is_finite_domain(b)
7183  True
7184  >>> is_finite_domain(Int('x'))
7185  False
7186  """
7187  return isinstance(a, FiniteDomainRef)
7188 
7189 
def is_finite_domain(a)
Definition: z3py.py:7177

◆ 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 7155 of file z3py.py.

Referenced by FiniteDomainVal().

7155 def is_finite_domain_sort(s):
7156  """Return True if `s` is a Z3 finite-domain sort.
7157 
7158  >>> is_finite_domain_sort(FiniteDomainSort('S', 100))
7159  True
7160  >>> is_finite_domain_sort(IntSort())
7161  False
7162  """
7163  return isinstance(s, FiniteDomainSortRef)
7164 
7165 
def is_finite_domain_sort(s)
Definition: z3py.py:7155

◆ 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 7230 of file z3py.py.

7230 def is_finite_domain_value(a):
7231  """Return `True` if `a` is a Z3 finite-domain value.
7232 
7233  >>> s = FiniteDomainSort('S', 100)
7234  >>> b = Const('b', s)
7235  >>> is_finite_domain_value(b)
7236  False
7237  >>> b = FiniteDomainVal(10, s)
7238  >>> b
7239  10
7240  >>> is_finite_domain_value(b)
7241  True
7242  """
7243  return is_finite_domain(a) and _is_numeral(a.ctx, a.as_ast())
7244 
7245 
def is_finite_domain_value(a)
Definition: z3py.py:7230
def is_finite_domain(a)
Definition: z3py.py:7177

◆ 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 9055 of file z3py.py.

Referenced by FP(), fpToIEEEBV(), fpToReal(), fpToSBV(), and fpToUBV().

9055 def is_fp(a):
9056  """Return `True` if `a` is a Z3 floating-point expression.
9057 
9058  >>> b = FP('b', FPSort(8, 24))
9059  >>> is_fp(b)
9060  True
9061  >>> is_fp(b + 1.0)
9062  True
9063  >>> is_fp(Int('x'))
9064  False
9065  """
9066  return isinstance(a, FPRef)
9067 
def is_fp(a)
Definition: z3py.py:9055

◆ 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 8671 of file z3py.py.

8671 def is_fp_sort(s):
8672  """Return True if `s` is a Z3 floating-point sort.
8673 
8674  >>> is_fp_sort(FPSort(8, 24))
8675  True
8676  >>> is_fp_sort(IntSort())
8677  False
8678  """
8679  return isinstance(s, FPSortRef)
8680 
def is_fp_sort(s)
Definition: z3py.py:8671

◆ 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 9068 of file z3py.py.

9068 def is_fp_value(a):
9069  """Return `True` if `a` is a Z3 floating-point numeral value.
9070 
9071  >>> b = FP('b', FPSort(8, 24))
9072  >>> is_fp_value(b)
9073  False
9074  >>> b = FPVal(1.0, FPSort(8, 24))
9075  >>> b
9076  1
9077  >>> is_fp_value(b)
9078  True
9079  """
9080  return is_fp(a) and _is_numeral(a.ctx, a.ast)
9081 
def is_fp_value(a)
Definition: z3py.py:9068
def is_fp(a)
Definition: z3py.py:9055

◆ 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 8919 of file z3py.py.

8919 def is_fprm(a):
8920  """Return `True` if `a` is a Z3 floating-point rounding mode expression.
8921 
8922  >>> rm = RNE()
8923  >>> is_fprm(rm)
8924  True
8925  >>> rm = 1.0
8926  >>> is_fprm(rm)
8927  False
8928  """
8929  return isinstance(a, FPRMRef)
8930 
def is_fprm(a)
Definition: z3py.py:8919

◆ 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 8681 of file z3py.py.

8681 def is_fprm_sort(s):
8682  """Return True if `s` is a Z3 floating-point rounding mode sort.
8683 
8684  >>> is_fprm_sort(FPSort(8, 24))
8685  False
8686  >>> is_fprm_sort(RNE().sort())
8687  True
8688  """
8689  return isinstance(s, FPRMSortRef)
8690 
def is_fprm_sort(s)
Definition: z3py.py:8681

◆ 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 8931 of file z3py.py.

8931 def is_fprm_value(a):
8932  """Return `True` if `a` is a Z3 floating-point rounding mode numeral value."""
8933  return is_fprm(a) and _is_numeral(a.ctx, a.ast)
8934 
def is_fprm_value(a)
Definition: z3py.py:8931
def is_fprm(a)
Definition: z3py.py:8919

◆ 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 766 of file z3py.py.

Referenced by prove().

766 def is_func_decl(a):
767  """Return `True` if `a` is a Z3 function declaration.
768 
769  >>> f = Function('f', IntSort(), IntSort())
770  >>> is_func_decl(f)
771  True
772  >>> x = Real('x')
773  >>> is_func_decl(x)
774  False
775  """
776  return isinstance(a, FuncDeclRef)
777 
def is_func_decl(a)
Definition: z3py.py:766

◆ 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 2661 of file z3py.py.

2661 def is_ge(a):
2662  """Return `True` if `a` is an expression of the form b >= c.
2663 
2664  >>> x, y = Ints('x y')
2665  >>> is_ge(x >= y)
2666  True
2667  >>> is_ge(x == y)
2668  False
2669  """
2670  return is_app_of(a, Z3_OP_GE)
2671 
def is_ge(a)
Definition: z3py.py:2661
def is_app_of(a, k)
Definition: z3py.py:1215

◆ 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 2672 of file z3py.py.

2672 def is_gt(a):
2673  """Return `True` if `a` is an expression of the form b > c.
2674 
2675  >>> x, y = Ints('x y')
2676  >>> is_gt(x > y)
2677  True
2678  >>> is_gt(x == y)
2679  False
2680  """
2681  return is_app_of(a, Z3_OP_GT)
2682 
def is_gt(a)
Definition: z3py.py:2672
def is_app_of(a, k)
Definition: z3py.py:1215

◆ 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 2617 of file z3py.py.

Referenced by is_div().

2617 def is_idiv(a):
2618  """Return `True` if `a` is an expression of the form b div c.
2619 
2620  >>> x, y = Ints('x y')
2621  >>> is_idiv(x / y)
2622  True
2623  >>> is_idiv(x + y)
2624  False
2625  """
2626  return is_app_of(a, Z3_OP_IDIV)
2627 
def is_idiv(a)
Definition: z3py.py:2617
def is_app_of(a, k)
Definition: z3py.py:1215

◆ 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 1470 of file z3py.py.

1470 def is_implies(a):
1471  """Return `True` if `a` is a Z3 implication expression.
1472 
1473  >>> p, q = Bools('p q')
1474  >>> is_implies(Implies(p, q))
1475  True
1476  >>> is_implies(And(p, q))
1477  False
1478  """
1479  return is_app_of(a, Z3_OP_IMPLIES)
1480 
def is_implies(a)
Definition: z3py.py:1470
def is_app_of(a, k)
Definition: z3py.py:1215

◆ 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 2469 of file z3py.py.

Referenced by Int(), IntSort(), and RealSort().

2469 def is_int(a):
2470  """Return `True` if `a` is an integer expression.
2471 
2472  >>> x = Int('x')
2473  >>> is_int(x + 1)
2474  True
2475  >>> is_int(1)
2476  False
2477  >>> is_int(IntVal(1))
2478  True
2479  >>> y = Real('y')
2480  >>> is_int(y)
2481  False
2482  >>> is_int(y + 1)
2483  False
2484  """
2485  return is_arith(a) and a.is_int()
2486 
def is_arith(a)
Definition: z3py.py:2449
def is_int(a)
Definition: z3py.py:2469

◆ 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 2511 of file z3py.py.

2511 def is_int_value(a):
2512  """Return `True` if `a` is an integer value of sort Int.
2513 
2514  >>> is_int_value(IntVal(1))
2515  True
2516  >>> is_int_value(1)
2517  False
2518  >>> is_int_value(Int('x'))
2519  False
2520  >>> n = Int('x') + 1
2521  >>> n
2522  x + 1
2523  >>> n.arg(1)
2524  1
2525  >>> is_int_value(n.arg(1))
2526  True
2527  >>> is_int_value(RealVal("1/3"))
2528  False
2529  >>> is_int_value(RealVal(1))
2530  False
2531  """
2532  return is_arith(a) and a.is_int() and _is_numeral(a.ctx, a.as_ast())
2533 
def is_int_value(a)
Definition: z3py.py:2511
def is_arith(a)
Definition: z3py.py:2449

◆ 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 2683 of file z3py.py.

2683 def is_is_int(a):
2684  """Return `True` if `a` is an expression of the form IsInt(b).
2685 
2686  >>> x = Real('x')
2687  >>> is_is_int(IsInt(x))
2688  True
2689  >>> is_is_int(x)
2690  False
2691  """
2692  return is_app_of(a, Z3_OP_IS_INT)
2693 
def is_app_of(a, k)
Definition: z3py.py:1215
def is_is_int(a)
Definition: z3py.py:2683

◆ 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 4288 of file z3py.py.

4288 def is_K(a):
4289  """Return `True` if `a` is a Z3 constant array.
4290 
4291  >>> a = K(IntSort(), 10)
4292  >>> is_K(a)
4293  True
4294  >>> a = Array('a', IntSort(), IntSort())
4295  >>> is_K(a)
4296  False
4297  """
4298  return is_app_of(a, Z3_OP_CONST_ARRAY)
4299 
def is_K(a)
Definition: z3py.py:4288
def is_app_of(a, k)
Definition: z3py.py:1215

◆ 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 2639 of file z3py.py.

2639 def is_le(a):
2640  """Return `True` if `a` is an expression of the form b <= c.
2641 
2642  >>> x, y = Ints('x y')
2643  >>> is_le(x <= y)
2644  True
2645  >>> is_le(x < y)
2646  False
2647  """
2648  return is_app_of(a, Z3_OP_LE)
2649 
def is_le(a)
Definition: z3py.py:2639
def is_app_of(a, k)
Definition: z3py.py:1215

◆ 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 2650 of file z3py.py.

2650 def is_lt(a):
2651  """Return `True` if `a` is an expression of the form b < c.
2652 
2653  >>> x, y = Ints('x y')
2654  >>> is_lt(x < y)
2655  True
2656  >>> is_lt(x == y)
2657  False
2658  """
2659  return is_app_of(a, Z3_OP_LT)
2660 
def is_lt(a)
Definition: z3py.py:2650
def is_app_of(a, k)
Definition: z3py.py:1215

◆ 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 4300 of file z3py.py.

4300 def is_map(a):
4301  """Return `True` if `a` is a Z3 map array expression.
4302 
4303  >>> f = Function('f', IntSort(), IntSort())
4304  >>> b = Array('b', IntSort(), IntSort())
4305  >>> a = Map(f, b)
4306  >>> a
4307  Map(f, b)
4308  >>> is_map(a)
4309  True
4310  >>> is_map(b)
4311  False
4312  """
4313  return is_app_of(a, Z3_OP_ARRAY_MAP)
4314 
def is_map(a)
Definition: z3py.py:4300
def is_app_of(a, k)
Definition: z3py.py:1215

◆ 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 2628 of file z3py.py.

2628 def is_mod(a):
2629  """Return `True` if `a` is an expression of the form b % c.
2630 
2631  >>> x, y = Ints('x y')
2632  >>> is_mod(x % y)
2633  True
2634  >>> is_mod(x + y)
2635  False
2636  """
2637  return is_app_of(a, Z3_OP_MOD)
2638 
def is_mod(a)
Definition: z3py.py:2628
def is_app_of(a, k)
Definition: z3py.py:1215

◆ 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 2579 of file z3py.py.

2579 def is_mul(a):
2580  """Return `True` if `a` is an expression of the form b * c.
2581 
2582  >>> x, y = Ints('x y')
2583  >>> is_mul(x * y)
2584  True
2585  >>> is_mul(x - y)
2586  False
2587  """
2588  return is_app_of(a, Z3_OP_MUL)
2589 
def is_app_of(a, k)
Definition: z3py.py:1215
def is_mul(a)
Definition: z3py.py:2579

◆ 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 1481 of file z3py.py.

1481 def is_not(a):
1482  """Return `True` if `a` is a Z3 not expression.
1483 
1484  >>> p = Bool('p')
1485  >>> is_not(p)
1486  False
1487  >>> is_not(Not(p))
1488  True
1489  """
1490  return is_app_of(a, Z3_OP_NOT)
1491 
def is_not(a)
Definition: z3py.py:1481
def is_app_of(a, k)
Definition: z3py.py:1215

◆ 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 1459 of file z3py.py.

1459 def is_or(a):
1460  """Return `True` if `a` is a Z3 or expression.
1461 
1462  >>> p, q = Bools('p q')
1463  >>> is_or(Or(p, q))
1464  True
1465  >>> is_or(And(p, q))
1466  False
1467  """
1468  return is_app_of(a, Z3_OP_OR)
1469 
def is_or(a)
Definition: z3py.py:1459
def is_app_of(a, k)
Definition: z3py.py:1215

◆ 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 1740 of file z3py.py.

Referenced by MultiPattern().

1740 def is_pattern(a):
1741  """Return `True` if `a` is a Z3 pattern (hint for quantifier instantiation.
1742 
1743  >>> f = Function('f', IntSort(), IntSort())
1744  >>> x = Int('x')
1745  >>> q = ForAll(x, f(x) == 0, patterns = [ f(x) ])
1746  >>> q
1747  ForAll(x, f(x) == 0)
1748  >>> q.num_patterns()
1749  1
1750  >>> is_pattern(q.pattern(0))
1751  True
1752  >>> q.pattern(0)
1753  f(Var(0))
1754  """
1755  return isinstance(a, PatternRef)
1756 
def is_pattern(a)
Definition: z3py.py:1740

◆ 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 7966 of file z3py.py.

Referenced by eq().

7966 def is_probe(p):
7967  """Return `True` if `p` is a Z3 probe.
7968 
7969  >>> is_probe(Int('x'))
7970  False
7971  >>> is_probe(Probe('memory'))
7972  True
7973  """
7974  return isinstance(p, Probe)
7975 
def is_probe(p)
Definition: z3py.py:7966

◆ 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 1969 of file z3py.py.

Referenced by Exists().

1969 def is_quantifier(a):
1970  """Return `True` if `a` is a Z3 quantifier.
1971 
1972  >>> f = Function('f', IntSort(), IntSort())
1973  >>> x = Int('x')
1974  >>> q = ForAll(x, f(x) == 0)
1975  >>> is_quantifier(q)
1976  True
1977  >>> is_quantifier(f(x))
1978  False
1979  """
1980  return isinstance(a, QuantifierRef)
1981 
def is_quantifier(a)
Definition: z3py.py:1969

◆ 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 2534 of file z3py.py.

Referenced by RatNumRef.denominator(), and RatNumRef.numerator().

2534 def is_rational_value(a):
2535  """Return `True` if `a` is rational value of sort Real.
2536 
2537  >>> is_rational_value(RealVal(1))
2538  True
2539  >>> is_rational_value(RealVal("3/5"))
2540  True
2541  >>> is_rational_value(IntVal(1))
2542  False
2543  >>> is_rational_value(1)
2544  False
2545  >>> n = Real('x') + 1
2546  >>> n.arg(1)
2547  1
2548  >>> is_rational_value(n.arg(1))
2549  True
2550  >>> is_rational_value(Real('x'))
2551  False
2552  """
2553  return is_arith(a) and a.is_real() and _is_numeral(a.ctx, a.as_ast())
2554 
def is_arith(a)
Definition: z3py.py:2449
def is_rational_value(a)
Definition: z3py.py:2534

◆ is_re()

def z3py.is_re (   s)

Definition at line 10179 of file z3py.py.

10179 def is_re(s):
10180  return isinstance(s, ReRef)
10181 
10182 
def is_re(s)
Definition: z3py.py:10179

◆ 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 2487 of file z3py.py.

Referenced by fpToReal(), Real(), and RealSort().

2487 def is_real(a):
2488  """Return `True` if `a` is a real expression.
2489 
2490  >>> x = Int('x')
2491  >>> is_real(x + 1)
2492  False
2493  >>> y = Real('y')
2494  >>> is_real(y)
2495  True
2496  >>> is_real(y + 1)
2497  True
2498  >>> is_real(1)
2499  False
2500  >>> is_real(RealVal(1))
2501  True
2502  """
2503  return is_arith(a) and a.is_real()
2504 
def is_real(a)
Definition: z3py.py:2487
def is_arith(a)
Definition: z3py.py:2449

◆ 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 4498 of file z3py.py.

4498 def is_select(a):
4499  """Return `True` if `a` is a Z3 array select application.
4500 
4501  >>> a = Array('a', IntSort(), IntSort())
4502  >>> is_select(a)
4503  False
4504  >>> i = Int('i')
4505  >>> is_select(a[i])
4506  True
4507  """
4508  return is_app_of(a, Z3_OP_SELECT)
4509 
def is_select(a)
Definition: z3py.py:4498
def is_app_of(a, k)
Definition: z3py.py:1215

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

9941 def is_seq(a):
9942  """Return `True` if `a` is a Z3 sequence expression.
9943  >>> print (is_seq(Unit(IntVal(0))))
9944  True
9945  >>> print (is_seq(StringVal("abc")))
9946  True
9947  """
9948  return isinstance(a, SeqRef)
9949 
def is_seq(a)
Definition: z3py.py:9941

◆ 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 579 of file z3py.py.

Referenced by Function(), prove(), RecFunction(), and Var().

579 def is_sort(s):
580  """Return `True` if `s` is a Z3 sort.
581 
582  >>> is_sort(IntSort())
583  True
584  >>> is_sort(Int('x'))
585  False
586  >>> is_expr(Int('x'))
587  True
588  """
589  return isinstance(s, SortRef)
590 
def is_sort(s)
Definition: z3py.py:579

◆ 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 4510 of file z3py.py.

4510 def is_store(a):
4511  """Return `True` if `a` is a Z3 array store application.
4512 
4513  >>> a = Array('a', IntSort(), IntSort())
4514  >>> is_store(a)
4515  False
4516  >>> is_store(Store(a, 0, 1))
4517  True
4518  """
4519  return is_app_of(a, Z3_OP_STORE)
4520 
def is_store(a)
Definition: z3py.py:4510
def is_app_of(a, k)
Definition: z3py.py:1215

◆ 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 9950 of file z3py.py.

9950 def is_string(a):
9951  """Return `True` if `a` is a Z3 string expression.
9952  >>> print (is_string(StringVal("ab")))
9953  True
9954  """
9955  return isinstance(a, SeqRef) and a.is_string()
9956 
def is_string(a)
Definition: z3py.py:9950

◆ 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 9957 of file z3py.py.

9957 def is_string_value(a):
9958  """return 'True' if 'a' is a Z3 string constant expression.
9959  >>> print (is_string_value(StringVal("a")))
9960  True
9961  >>> print (is_string_value(StringVal("a") + StringVal("b")))
9962  False
9963  """
9964  return isinstance(a, SeqRef) and a.is_string_value()
9965 
9966 
def is_string_value(a)
Definition: z3py.py:9957

◆ 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 2590 of file z3py.py.

2590 def is_sub(a):
2591  """Return `True` if `a` is an expression of the form b - c.
2592 
2593  >>> x, y = Ints('x y')
2594  >>> is_sub(x - y)
2595  True
2596  >>> is_sub(x + y)
2597  False
2598  """
2599  return is_app_of(a, Z3_OP_SUB)
2600 
def is_app_of(a, k)
Definition: z3py.py:1215
def is_sub(a)
Definition: z3py.py:2590

◆ 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 2708 of file z3py.py.

2708 def is_to_int(a):
2709  """Return `True` if `a` is an expression of the form ToInt(b).
2710 
2711  >>> x = Real('x')
2712  >>> n = ToInt(x)
2713  >>> n
2714  ToInt(x)
2715  >>> is_to_int(n)
2716  True
2717  >>> is_to_int(x)
2718  False
2719  """
2720  return is_app_of(a, Z3_OP_TO_INT)
2721 
def is_app_of(a, k)
Definition: z3py.py:1215
def is_to_int(a)
Definition: z3py.py:2708

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

2694 def is_to_real(a):
2695  """Return `True` if `a` is an expression of the form ToReal(b).
2696 
2697  >>> x = Int('x')
2698  >>> n = ToReal(x)
2699  >>> n
2700  ToReal(x)
2701  >>> is_to_real(n)
2702  True
2703  >>> is_to_real(x)
2704  False
2705  """
2706  return is_app_of(a, Z3_OP_TO_REAL)
2707 
def is_to_real(a)
Definition: z3py.py:2694
def is_app_of(a, k)
Definition: z3py.py:1215

◆ 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 1418 of file z3py.py.

Referenced by AstRef.__bool__(), and BoolVal().

1418 def is_true(a):
1419  """Return `True` if `a` is the Z3 true expression.
1420 
1421  >>> p = Bool('p')
1422  >>> is_true(p)
1423  False
1424  >>> is_true(simplify(p == p))
1425  True
1426  >>> x = Real('x')
1427  >>> is_true(x == 0)
1428  False
1429  >>> # True is a Python Boolean expression
1430  >>> is_true(True)
1431  False
1432  """
1433  return is_app_of(a, Z3_OP_TRUE)
1434 
def is_true(a)
Definition: z3py.py:1418
def is_app_of(a, k)
Definition: z3py.py:1215

◆ 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 1159 of file z3py.py.

Referenced by get_var_index().

1159 def is_var(a):
1160  """Return `True` if `a` is variable.
1161 
1162  Z3 uses de-Bruijn indices for representing bound variables in
1163  quantifiers.
1164 
1165  >>> x = Int('x')
1166  >>> is_var(x)
1167  False
1168  >>> is_const(x)
1169  True
1170  >>> f = Function('f', IntSort(), IntSort())
1171  >>> # Z3 replaces x with bound variables when ForAll is executed.
1172  >>> q = ForAll(x, f(x) == x)
1173  >>> b = q.body()
1174  >>> b
1175  f(Var(0)) == Var(0)
1176  >>> b.arg(1)
1177  Var(0)
1178  >>> is_var(b.arg(1))
1179  True
1180  """
1181  return is_expr(a) and _ast_kind(a.ctx, a) == Z3_VAR_AST
1182 
def is_expr(a)
Definition: z3py.py:1094
def is_var(a)
Definition: z3py.py:1159

◆ 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 3116 of file z3py.py.

Referenced by is_is_int().

3116 def IsInt(a):
3117  """ Return the Z3 predicate IsInt(a).
3118 
3119  >>> x = Real('x')
3120  >>> IsInt(x + "1/2")
3121  IsInt(x + 1/2)
3122  >>> solve(IsInt(x + "1/2"), x > 0, x < 1)
3123  [x = 1/2]
3124  >>> solve(IsInt(x + "1/2"), x > 0, x < 1, x != "1/2")
3125  no solution
3126  """
3127  if __debug__:
3128  _z3_assert(a.is_real(), "Z3 real expression expected.")
3129  ctx = a.ctx
3130  return BoolRef(Z3_mk_is_int(ctx.ref(), a.as_ast()), ctx)
3131 
def IsInt(a)
Definition: z3py.py:3116
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 4611 of file z3py.py.

4611 def IsMember(e, s):
4612  """ Check if e is a member of set s
4613  >>> a = Const('a', SetSort(IntSort()))
4614  >>> IsMember(1, a)
4615  a[1]
4616  """
4617  ctx = _ctx_from_ast_arg_list([s,e])
4618  e = _py2expr(e, ctx)
4619  return BoolRef(Z3_mk_set_member(ctx.ref(), e.as_ast(), s.as_ast()), ctx)
4620 
Z3_ast Z3_API Z3_mk_set_member(Z3_context c, Z3_ast elem, Z3_ast set)
Check for set membership.
def IsMember(e, s)
Definition: z3py.py:4611

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

4621 def IsSubset(a, b):
4622  """ Check if a is a subset of b
4623  >>> a = Const('a', SetSort(IntSort()))
4624  >>> b = Const('b', SetSort(IntSort()))
4625  >>> IsSubset(a, b)
4626  subset(a, b)
4627  """
4628  ctx = _ctx_from_ast_arg_list([a, b])
4629  return BoolRef(Z3_mk_set_subset(ctx.ref(), a.as_ast(), b.as_ast()), ctx)
4630 
4631 
def IsSubset(a, b)
Definition: z3py.py:4621
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 4470 of file z3py.py.

Referenced by Default(), EmptySet(), FullSet(), is_const_array(), is_default(), and is_K().

4470 def K(dom, v):
4471  """Return a Z3 constant array expression.
4472 
4473  >>> a = K(IntSort(), 10)
4474  >>> a
4475  K(Int, 10)
4476  >>> a.sort()
4477  Array(Int, Int)
4478  >>> i = Int('i')
4479  >>> a[i]
4480  K(Int, 10)[i]
4481  >>> simplify(a[i])
4482  10
4483  """
4484  if __debug__:
4485  _z3_assert(is_sort(dom), "Z3 sort expected")
4486  ctx = dom.ctx
4487  if not is_expr(v):
4488  v = _py2expr(v, ctx)
4489  return ArrayRef(Z3_mk_const_array(ctx.ref(), dom.ast, v.as_ast()), ctx)
4490 
Z3_ast Z3_API Z3_mk_const_array(Z3_context c, Z3_sort domain, Z3_ast v)
Create the constant array.
def is_sort(s)
Definition: z3py.py:579
def K(dom, v)
Definition: z3py.py:4470
def is_expr(a)
Definition: z3py.py:1094

◆ 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 2053 of file z3py.py.

Referenced by QuantifierRef.is_lambda().

2053 def Lambda(vs, body):
2054  """Create a Z3 lambda expression.
2055 
2056  >>> f = Function('f', IntSort(), IntSort(), IntSort())
2057  >>> mem0 = Array('mem0', IntSort(), IntSort())
2058  >>> lo, hi, e, i = Ints('lo hi e i')
2059  >>> mem1 = Lambda([i], If(And(lo <= i, i <= hi), e, mem0[i]))
2060  >>> mem1
2061  Lambda(i, If(And(lo <= i, i <= hi), e, mem0[i]))
2062  """
2063  ctx = body.ctx
2064  if is_app(vs):
2065  vs = [vs]
2066  num_vars = len(vs)
2067  _vs = (Ast * num_vars)()
2068  for i in range(num_vars):
2069 
2070  _vs[i] = vs[i].as_ast()
2071  return QuantifierRef(Z3_mk_lambda_const(ctx.ref(), num_vars, _vs, body.as_ast()), ctx)
2072 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3244
def is_app(a)
Definition: z3py.py:1116
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.
def Lambda(vs, body)
Definition: z3py.py:2053

◆ Length()

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

Definition at line 10113 of file z3py.py.

10113 def Length(s):
10114  """Obtain the length of a sequence 's'
10115  >>> l = Length(StringVal("abc"))
10116  >>> simplify(l)
10117  3
10118  """
10119  s = _coerce_seq(s)
10120  return ArithRef(Z3_mk_seq_length(s.ctx_ref(), s.as_ast()), s.ctx)
10121 
Z3_ast Z3_API Z3_mk_seq_length(Z3_context c, Z3_ast s)
Return the length of the sequence s.
def Length(s)
Definition: z3py.py:10113

◆ 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 10255 of file z3py.py.

10255 def Loop(re, lo, hi=0):
10256  """Create the regular expression accepting between a lower and upper bound repetitions
10257  >>> re = Loop(Re("a"), 1, 3)
10258  >>> print(simplify(InRe("aa", re)))
10259  True
10260  >>> print(simplify(InRe("aaaa", re)))
10261  False
10262  >>> print(simplify(InRe("", re)))
10263  False
10264  """
10265  return ReRef(Z3_mk_re_loop(re.ctx_ref(), re.as_ast(), lo, hi), re.ctx)
10266 
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...
def Loop(re, lo, hi=0)
Definition: z3py.py:10255

◆ 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 3985 of file z3py.py.

Referenced by BitVecRef.__rlshift__(), BitVecRef.__rrshift__(), and BitVecRef.__rshift__().

3985 def LShR(a, b):
3986  """Create the Z3 expression logical right shift.
3987 
3988  Use the operator >> for the arithmetical right shift.
3989 
3990  >>> x, y = BitVecs('x y', 32)
3991  >>> LShR(x, y)
3992  LShR(x, y)
3993  >>> (x >> y).sexpr()
3994  '(bvashr x y)'
3995  >>> LShR(x, y).sexpr()
3996  '(bvlshr x y)'
3997  >>> BitVecVal(4, 3)
3998  4
3999  >>> BitVecVal(4, 3).as_signed_long()
4000  -4
4001  >>> simplify(BitVecVal(4, 3) >> 1).as_signed_long()
4002  -2
4003  >>> simplify(BitVecVal(4, 3) >> 1)
4004  6
4005  >>> simplify(LShR(BitVecVal(4, 3), 1))
4006  2
4007  >>> simplify(BitVecVal(2, 3) >> 1)
4008  1
4009  >>> simplify(LShR(BitVecVal(2, 3), 1))
4010  1
4011  """
4012  _check_bv_args(a, b)
4013  a, b = _coerce_exprs(a, b)
4014  return BitVecRef(Z3_mk_bvlshr(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4015 
Z3_ast Z3_API Z3_mk_bvlshr(Z3_context c, Z3_ast t1, Z3_ast t2)
Logical shift right.
def LShR(a, b)
Definition: z3py.py:3985

◆ 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 207 of file z3py.py.

Referenced by help_simplify(), simplify_param_descrs(), and Goal.translate().

207 def main_ctx():
208  """Return a reference to the global Z3 context.
209 
210  >>> x = Real('x')
211  >>> x.ctx == main_ctx()
212  True
213  >>> c = Context()
214  >>> c == main_ctx()
215  False
216  >>> x2 = Real('x', c)
217  >>> x2.ctx == c
218  True
219  >>> eq(x, x2)
220  False
221  """
222  global _main_ctx
223  if _main_ctx is None:
224  _main_ctx = Context()
225  return _main_ctx
226 
def main_ctx()
Definition: z3py.py:207

◆ 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 4448 of file z3py.py.

Referenced by Context.Context(), get_map_func(), and is_map().

4448 def Map(f, *args):
4449  """Return a Z3 map array expression.
4450 
4451  >>> f = Function('f', IntSort(), IntSort(), IntSort())
4452  >>> a1 = Array('a1', IntSort(), IntSort())
4453  >>> a2 = Array('a2', IntSort(), IntSort())
4454  >>> b = Map(f, a1, a2)
4455  >>> b
4456  Map(f, a1, a2)
4457  >>> prove(b[0] == f(a1[0], a2[0]))
4458  proved
4459  """
4460  args = _get_args(args)
4461  if __debug__:
4462  _z3_assert(len(args) > 0, "At least one Z3 array expression expected")
4463  _z3_assert(is_func_decl(f), "First argument must be a Z3 function declaration")
4464  _z3_assert(all([is_array(a) for a in args]), "Z3 array expected expected")
4465  _z3_assert(len(args) == f.arity(), "Number of arguments mismatch")
4466  _args, sz = _to_ast_array(args)
4467  ctx = f.ctx
4468  return ArrayRef(Z3_mk_map(ctx.ref(), f.ast, sz, _args), ctx)
4469 
def is_array(a)
Definition: z3py.py:4263
def Map(f, args)
Definition: z3py.py:4448
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.
def is_func_decl(a)
Definition: z3py.py:766

◆ mk_not()

def z3py.mk_not (   a)

Definition at line 1648 of file z3py.py.

1648 def mk_not(a):
1649  if is_not(a):
1650  return a.arg(0)
1651  else:
1652  return Not(a)
1653 
def mk_not(a)
Definition: z3py.py:1648
def is_not(a)
Definition: z3py.py:1481
def Not(a, ctx=None)
Definition: z3py.py:1630

◆ Model()

def z3py.Model (   ctx = None)

Definition at line 6173 of file z3py.py.

Referenced by Goal.convertModel(), Optimize.getModel(), and Solver.getModel().

6173 def Model(ctx = None):
6174  ctx = _get_ctx(ctx)
6175  return ModelRef(Z3_mk_model(ctx.ref()), ctx)
6176 
def Model(ctx=None)
Definition: z3py.py:6173
Z3_model Z3_API Z3_mk_model(Z3_context c)
Create a fresh model object. It has reference count 0.

◆ 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 1757 of file z3py.py.

1757 def MultiPattern(*args):
1758  """Create a Z3 multi-pattern using the given expressions `*args`
1759 
1760  >>> f = Function('f', IntSort(), IntSort())
1761  >>> g = Function('g', IntSort(), IntSort())
1762  >>> x = Int('x')
1763  >>> q = ForAll(x, f(x) != g(x), patterns = [ MultiPattern(f(x), g(x)) ])
1764  >>> q
1765  ForAll(x, f(x) != g(x))
1766  >>> q.num_patterns()
1767  1
1768  >>> is_pattern(q.pattern(0))
1769  True
1770  >>> q.pattern(0)
1771  MultiPattern(f(Var(0)), g(Var(0)))
1772  """
1773  if __debug__:
1774  _z3_assert(len(args) > 0, "At least one argument expected")
1775  _z3_assert(all([ is_expr(a) for a in args ]), "Z3 expressions expected")
1776  ctx = args[0].ctx
1777  args, sz = _to_ast_array(args)
1778  return PatternRef(Z3_mk_pattern(ctx.ref(), sz, args), ctx)
1779 
Z3_pattern Z3_API Z3_mk_pattern(Z3_context c, unsigned num_patterns, Z3_ast const terms[])
Create a pattern for quantifier instantiation.
def MultiPattern(args)
Definition: z3py.py:1757
def is_expr(a)
Definition: z3py.py:1094

◆ 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 1630 of file z3py.py.

Referenced by Solver.consequences(), Goal.convert_model(), fpNEQ(), Implies(), prove(), and Xor().

1630 def Not(a, ctx=None):
1631  """Create a Z3 not expression or probe.
1632 
1633  >>> p = Bool('p')
1634  >>> Not(Not(p))
1635  Not(Not(p))
1636  >>> simplify(Not(Not(p)))
1637  p
1638  """
1639  ctx = _get_ctx(_ctx_from_ast_arg_list([a], ctx))
1640  if is_probe(a):
1641  # Not is also used to build probes
1642  return Probe(Z3_probe_not(ctx.ref(), a.probe), ctx)
1643  else:
1644  s = BoolSort(ctx)
1645  a = s.cast(a)
1646  return BoolRef(Z3_mk_not(ctx.ref(), a.as_ast()), ctx)
1647 
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).
def Not(a, ctx=None)
Definition: z3py.py:1630
def is_probe(p)
Definition: z3py.py:7966
def BoolSort(ctx=None)
Definition: z3py.py:1512

◆ open_log()

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

Definition at line 97 of file z3py.py.

97 def open_log(fname):
98  """Log interaction to a file. This function must be invoked immediately after init(). """
99  Z3_open_log(fname)
100 
def open_log(fname)
Definition: z3py.py:97
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 10227 of file z3py.py.

10227 def Option(re):
10228  """Create the regular expression that optionally accepts the argument.
10229  >>> re = Option(Re("a"))
10230  >>> print(simplify(InRe("a", re)))
10231  True
10232  >>> print(simplify(InRe("", re)))
10233  True
10234  >>> print(simplify(InRe("aa", re)))
10235  False
10236  """
10237  return ReRef(Z3_mk_re_option(re.ctx_ref(), re.as_ast()), re.ctx)
10238 
Z3_ast Z3_API Z3_mk_re_option(Z3_context c, Z3_ast re)
Create the regular language [re].
def Option(re)
Definition: z3py.py:10227

◆ 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 1694 of file z3py.py.

Referenced by ApplyResult.as_expr(), Bools(), Goal.convert_model(), and Implies().

1694 def Or(*args):
1695  """Create a Z3 or-expression or or-probe.
1696 
1697  >>> p, q, r = Bools('p q r')
1698  >>> Or(p, q, r)
1699  Or(p, q, r)
1700  >>> P = BoolVector('p', 5)
1701  >>> Or(P)
1702  Or(p__0, p__1, p__2, p__3, p__4)
1703  """
1704  last_arg = None
1705  if len(args) > 0:
1706  last_arg = args[len(args)-1]
1707  if isinstance(last_arg, Context):
1708  ctx = args[len(args)-1]
1709  args = args[:len(args)-1]
1710  else:
1711  ctx = main_ctx()
1712  args = _get_args(args)
1713  ctx_args = _ctx_from_ast_arg_list(args, ctx)
1714  if __debug__:
1715  _z3_assert(ctx_args is None or ctx_args == ctx, "context mismatch")
1716  _z3_assert(ctx is not None, "At least one of the arguments must be a Z3 expression or probe")
1717  if _has_probe(args):
1718  return _probe_or(args, ctx)
1719  else:
1720  args = _coerce_expr_list(args, ctx)
1721  _args, sz = _to_ast_array(args)
1722  return BoolRef(Z3_mk_or(ctx.ref(), sz, _args), ctx)
1723 
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].
def main_ctx()
Definition: z3py.py:207
def Or(args)
Definition: z3py.py:1694

◆ 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 7682 of file z3py.py.

7682 def OrElse(*ts, **ks):
7683  """Return a tactic that applies the tactics in `*ts` until one of them succeeds (it doesn't fail).
7684 
7685  >>> x = Int('x')
7686  >>> t = OrElse(Tactic('split-clause'), Tactic('skip'))
7687  >>> # Tactic split-clause fails if there is no clause in the given goal.
7688  >>> t(x == 0)
7689  [[x == 0]]
7690  >>> t(Or(x == 0, x == 1))
7691  [[x == 0], [x == 1]]
7692  """
7693  if __debug__:
7694  _z3_assert(len(ts) >= 2, "At least two arguments expected")
7695  ctx = ks.get('ctx', None)
7696  num = len(ts)
7697  r = ts[0]
7698  for i in range(num - 1):
7699  r = _or_else(r, ts[i+1], ctx)
7700  return r
7701 
def OrElse(ts, ks)
Definition: z3py.py:7682
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3244

◆ ParAndThen()

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

Definition at line 7734 of file z3py.py.

7734 def ParAndThen(t1, t2, ctx=None):
7735  """Alias for ParThen(t1, t2, ctx)."""
7736  return ParThen(t1, t2, ctx)
7737 
def ParAndThen(t1, t2, ctx=None)
Definition: z3py.py:7734
def ParThen(t1, t2, ctx=None)
Definition: z3py.py:7720

◆ 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 7702 of file z3py.py.

7702 def ParOr(*ts, **ks):
7703  """Return a tactic that applies the tactics in `*ts` in parallel until one of them succeeds (it doesn't fail).
7704 
7705  >>> x = Int('x')
7706  >>> t = ParOr(Tactic('simplify'), Tactic('fail'))
7707  >>> t(x + 1 == 2)
7708  [[x == 1]]
7709  """
7710  if __debug__:
7711  _z3_assert(len(ts) >= 2, "At least two arguments expected")
7712  ctx = _get_ctx(ks.get('ctx', None))
7713  ts = [ _to_tactic(t, ctx) for t in ts ]
7714  sz = len(ts)
7715  _args = (TacticObj * sz)()
7716  for i in range(sz):
7717  _args[i] = ts[i].tactic
7718  return Tactic(Z3_tactic_par_or(ctx.ref(), sz, _args), ctx)
7719 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3244
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.
def ParOr(ts, ks)
Definition: z3py.py:7702

◆ 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 8501 of file z3py.py.

8501 def parse_smt2_file(f, sorts={}, decls={}, ctx=None):
8502  """Parse a file in SMT 2.0 format using the given sorts and decls.
8503 
8504  This function is similar to parse_smt2_string().
8505  """
8506  ctx = _get_ctx(ctx)
8507  ssz, snames, ssorts = _dict2sarray(sorts, ctx)
8508  dsz, dnames, ddecls = _dict2darray(decls, ctx)
8509  return AstVector(Z3_parse_smtlib2_file(ctx.ref(), f, ssz, snames, ssorts, dsz, dnames, ddecls), ctx)
8510 
8511 
def parse_smt2_file(f, sorts={}, decls={}, ctx=None)
Definition: z3py.py:8501
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 8481 of file z3py.py.

Referenced by parse_smt2_file().

8481 def parse_smt2_string(s, sorts={}, decls={}, ctx=None):
8482  """Parse a string in SMT 2.0 format using the given sorts and decls.
8483 
8484  The arguments sorts and decls are Python dictionaries used to initialize
8485  the symbol table used for the SMT 2.0 parser.
8486 
8487  >>> parse_smt2_string('(declare-const x Int) (assert (> x 0)) (assert (< x 10))')
8488  [x > 0, x < 10]
8489  >>> x, y = Ints('x y')
8490  >>> f = Function('f', IntSort(), IntSort())
8491  >>> parse_smt2_string('(assert (> (+ foo (g bar)) 0))', decls={ 'foo' : x, 'bar' : y, 'g' : f})
8492  [x + f(y) > 0]
8493  >>> parse_smt2_string('(declare-const a U) (assert (> a 0))', sorts={ 'U' : IntSort() }) [a > 0]
8494  """
8495  ctx = _get_ctx(ctx)
8496  ssz, snames, ssorts = _dict2sarray(sorts, ctx)
8497  dsz, dnames, ddecls = _dict2darray(decls, ctx)
8498  return AstVector(Z3_parse_smtlib2_string(ctx.ref(), s, ssz, snames, ssorts, dsz, dnames, ddecls), ctx)
8499 
8500 
def parse_smt2_string(s, sorts={}, decls={}, ctx=None)
Definition: z3py.py:8481

◆ 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 7720 of file z3py.py.

Referenced by ParAndThen().

7720 def ParThen(t1, t2, ctx=None):
7721  """Return a tactic that applies t1 and then t2 to every subgoal produced by t1. The subgoals are processed in parallel.
7722 
7723  >>> x, y = Ints('x y')
7724  >>> t = ParThen(Tactic('split-clause'), Tactic('propagate-values'))
7725  >>> t(And(Or(x == 1, x == 2), y == x + 1))
7726  [[x == 1, y == 2], [x == 2, y == 3]]
7727  """
7728  t1 = _to_tactic(t1, ctx)
7729  t2 = _to_tactic(t2, ctx)
7730  if __debug__:
7731  _z3_assert(t1.ctx == t2.ctx, "Context mismatch")
7732  return Tactic(Z3_tactic_par_and_then(t1.ctx.ref(), t1.tactic, t2.tactic), t1.ctx)
7733 
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...
def ParThen(t1, t2, ctx=None)
Definition: z3py.py:7720

◆ 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 8288 of file z3py.py.

8288 def PbEq(args, k, ctx = None):
8289  """Create a Pseudo-Boolean inequality k constraint.
8290 
8291  >>> a, b, c = Bools('a b c')
8292  >>> f = PbEq(((a,1),(b,3),(c,2)), 3)
8293  """
8294  _z3_check_cint_overflow(k, "k")
8295  ctx, sz, _args, _coeffs = _pb_args_coeffs(args)
8296  return BoolRef(Z3_mk_pbeq(ctx.ref(), sz, _args, _coeffs, k), ctx)
8297 
8298 
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.
def PbEq(args, k, ctx=None)
Definition: z3py.py:8288

◆ 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 8278 of file z3py.py.

8278 def PbGe(args, k):
8279  """Create a Pseudo-Boolean inequality k constraint.
8280 
8281  >>> a, b, c = Bools('a b c')
8282  >>> f = PbGe(((a,1),(b,3),(c,2)), 3)
8283  """
8284  _z3_check_cint_overflow(k, "k")
8285  ctx, sz, _args, _coeffs = _pb_args_coeffs(args)
8286  return BoolRef(Z3_mk_pbge(ctx.ref(), sz, _args, _coeffs, k), ctx)
8287 
def PbGe(args, k)
Definition: z3py.py:8278
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 8268 of file z3py.py.

8268 def PbLe(args, k):
8269  """Create a Pseudo-Boolean inequality k constraint.
8270 
8271  >>> a, b, c = Bools('a b c')
8272  >>> f = PbLe(((a,1),(b,3),(c,2)), 3)
8273  """
8274  _z3_check_cint_overflow(k, "k")
8275  ctx, sz, _args, _coeffs = _pb_args_coeffs(args)
8276  return BoolRef(Z3_mk_pble(ctx.ref(), sz, _args, _coeffs, k), ctx)
8277 
def PbLe(args, k)
Definition: z3py.py:8268
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.

◆ 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 10215 of file z3py.py.

10215 def Plus(re):
10216  """Create the regular expression accepting one or more repetitions of argument.
10217  >>> re = Plus(Re("a"))
10218  >>> print(simplify(InRe("aa", re)))
10219  True
10220  >>> print(simplify(InRe("ab", re)))
10221  False
10222  >>> print(simplify(InRe("", re)))
10223  False
10224  """
10225  return ReRef(Z3_mk_re_plus(re.ctx_ref(), re.as_ast()), re.ctx)
10226 
def Plus(re)
Definition: z3py.py:10215
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 10032 of file z3py.py.

10032 def PrefixOf(a, b):
10033  """Check if 'a' is a prefix of 'b'
10034  >>> s1 = PrefixOf("ab", "abc")
10035  >>> simplify(s1)
10036  True
10037  >>> s2 = PrefixOf("bc", "abc")
10038  >>> simplify(s2)
10039  False
10040  """
10041  ctx = _get_ctx2(a, b)
10042  a = _coerce_seq(a, ctx)
10043  b = _coerce_seq(b, ctx)
10044  return BoolRef(Z3_mk_seq_prefix(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
10045 
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.
def PrefixOf(a, b)
Definition: z3py.py:10032

◆ 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 7992 of file z3py.py.

Referenced by describe_probes().

7992 def probe_description(name, ctx=None):
7993  """Return a short description for the probe named `name`.
7994 
7995  >>> d = probe_description('memory')
7996  """
7997  ctx = _get_ctx(ctx)
7998  return Z3_probe_get_descr(ctx.ref(), name)
7999 
def probe_description(name, ctx=None)
Definition: z3py.py:7992
Z3_string Z3_API Z3_probe_get_descr(Z3_context c, Z3_string name)
Return a string containing a description of the probe with the given name.

◆ probes()

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

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

Definition at line 7982 of file z3py.py.

Referenced by describe_probes().

7982 def probes(ctx=None):
7983  """Return a list of all available probes in Z3.
7984 
7985  >>> l = probes()
7986  >>> l.count('memory') == 1
7987  True
7988  """
7989  ctx = _get_ctx(ctx)
7990  return [ Z3_get_probe_name(ctx.ref(), i) for i in range(Z3_get_num_probes(ctx.ref())) ]
7991 
Z3_string Z3_API Z3_get_probe_name(Z3_context c, unsigned i)
Return the name of the i probe.
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3244
def probes(ctx=None)
Definition: z3py.py:7982
unsigned Z3_API Z3_get_num_probes(Z3_context c)
Return the number of builtin probes available in Z3.

◆ 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 8190 of file z3py.py.

Referenced by BitVecs().

8190 def Product(*args):
8191  """Create the product of the Z3 expressions.
8192 
8193  >>> a, b, c = Ints('a b c')
8194  >>> Product(a, b, c)
8195  a*b*c
8196  >>> Product([a, b, c])
8197  a*b*c
8198  >>> A = IntVector('a', 5)
8199  >>> Product(A)
8200  a__0*a__1*a__2*a__3*a__4
8201  """
8202  args = _get_args(args)
8203  if len(args) == 0:
8204  return 1
8205  ctx = _ctx_from_ast_arg_list(args)
8206  if ctx is None:
8207  return _reduce(lambda a, b: a * b, args, 1)
8208  args = _coerce_expr_list(args, ctx)
8209  if is_bv(args[0]):
8210  return _reduce(lambda a, b: a * b, args, 1)
8211  else:
8212  _args, sz = _to_ast_array(args)
8213  return ArithRef(Z3_mk_mul(ctx.ref(), sz, _args), ctx)
8214 
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].
def Product(args)
Definition: z3py.py:8190
def is_bv(a)
Definition: z3py.py:3655

◆ prove()

def z3py.prove (   claim,
  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 8356 of file z3py.py.

Referenced by Default(), Map(), Store(), and Update().

8356 def prove(claim, **keywords):
8357  """Try to prove the given claim.
8358 
8359  This is a simple function for creating demonstrations. It tries to prove
8360  `claim` by showing the negation is unsatisfiable.
8361 
8362  >>> p, q = Bools('p q')
8363  >>> prove(Not(And(p, q)) == Or(Not(p), Not(q)))
8364  proved
8365  """
8366  if __debug__:
8367  _z3_assert(is_bool(claim), "Z3 Boolean expression expected")
8368  s = Solver()
8369  s.set(**keywords)
8370  s.add(Not(claim))
8371  if keywords.get('show', False):
8372  print(s)
8373  r = s.check()
8374  if r == unsat:
8375  print("proved")
8376  elif r == unknown:
8377  print("failed to prove")
8378  print(s.model())
8379  else:
8380  print("counterexample")
8381  print(s.model())
8382 
def prove(claim, keywords)
Definition: z3py.py:8356
def Not(a, ctx=None)
Definition: z3py.py:1630
def is_bool(a)
Definition: z3py.py:1401

◆ 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 2970 of file z3py.py.

Referenced by RatNumRef.as_string(), RatNumRef.denominator(), and RatNumRef.numerator().

2970 def Q(a, b, ctx=None):
2971  """Return a Z3 rational a/b.
2972 
2973  If `ctx=None`, then the global context is used.
2974 
2975  >>> Q(3,5)
2976  3/5
2977  >>> Q(3,5).sort()
2978  Real
2979  """
2980  return simplify(RatVal(a, b))
2981 
def simplify(a, arguments, keywords)
Utils.
Definition: z3py.py:8086
def RatVal(a, b, ctx=None)
Definition: z3py.py:2955
def Q(a, b, ctx=None)
Definition: z3py.py:2970

◆ 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 2955 of file z3py.py.

2955 def RatVal(a, b, ctx=None):
2956  """Return a Z3 rational a/b.
2957 
2958  If `ctx=None`, then the global context is used.
2959 
2960  >>> RatVal(3,5)
2961  3/5
2962  >>> RatVal(3,5).sort()
2963  Real
2964  """
2965  if __debug__:
2966  _z3_assert(_is_int(a) or isinstance(a, str), "First argument cannot be converted into an integer")
2967  _z3_assert(_is_int(b) or isinstance(b, str), "Second argument cannot be converted into an integer")
2968  return simplify(RealVal(a, ctx)/RealVal(b, ctx))
2969 
def simplify(a, arguments, keywords)
Utils.
Definition: z3py.py:8086
def RatVal(a, b, ctx=None)
Definition: z3py.py:2955
def RealVal(val, ctx=None)
Definition: z3py.py:2937

◆ 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 10145 of file z3py.py.

Referenced by InRe(), Loop(), Option(), Plus(), Star(), and Union().

10145 def Re(s, ctx=None):
10146  """The regular expression that accepts sequence 's'
10147  >>> s1 = Re("ab")
10148  >>> s2 = Re(StringVal("ab"))
10149  >>> s3 = Re(Unit(BoolVal(True)))
10150  """
10151  s = _coerce_seq(s, ctx)
10152  return ReRef(Z3_mk_seq_to_re(s.ctx_ref(), s.as_ast()), s.ctx)
10153 
10154 
10155 
10156 
def Re(s, ctx=None)
Definition: z3py.py:10145
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 3030 of file z3py.py.

Referenced by ArithRef.__div__(), ArithRef.__ge__(), ArithRef.__gt__(), ArithRef.__le__(), ArithRef.__lt__(), ArithRef.__mul__(), ArithRef.__pow__(), ArithRef.__rdiv__(), ArithRef.__rmul__(), ArithRef.__rpow__(), Cbrt(), is_arith(), ArithSortRef.is_int(), ArithRef.is_int(), is_int(), is_is_int(), is_rational_value(), ArithSortRef.is_real(), ArithRef.is_real(), is_real(), is_to_int(), IsInt(), ArithRef.sort(), Sqrt(), ToInt(), and QuantifierRef.var_sort().

3030 def Real(name, ctx=None):
3031  """Return a real constant named `name`. If `ctx=None`, then the global context is used.
3032 
3033  >>> x = Real('x')
3034  >>> is_real(x)
3035  True
3036  >>> is_real(x + 1)
3037  True
3038  """
3039  ctx = _get_ctx(ctx)
3040  return ArithRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), RealSort(ctx).ast), ctx)
3041 
def RealSort(ctx=None)
Definition: z3py.py:2895
Z3_ast Z3_API Z3_mk_const(Z3_context c, Z3_symbol s, Z3_sort ty)
Declare and create a constant.
def to_symbol(s, ctx=None)
Definition: z3py.py:105
def Real(name, ctx=None)
Definition: z3py.py:3030

◆ 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 3042 of file z3py.py.

Referenced by is_div().

3042 def Reals(names, ctx=None):
3043  """Return a tuple of real constants.
3044 
3045  >>> x, y, z = Reals('x y z')
3046  >>> Sum(x, y, z)
3047  x + y + z
3048  >>> Sum(x, y, z).sort()
3049  Real
3050  """
3051  ctx = _get_ctx(ctx)
3052  if isinstance(names, str):
3053  names = names.split(" ")
3054  return [Real(name, ctx) for name in names]
3055 
def Real(name, ctx=None)
Definition: z3py.py:3030
def Reals(names, ctx=None)
Definition: z3py.py:3042

◆ 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 2895 of file z3py.py.

Referenced by ArithSortRef.cast(), Context.getRealSort(), is_arith_sort(), Context.mkRealSort(), RealVar(), and QuantifierRef.var_sort().

2895 def RealSort(ctx=None):
2896  """Return the real sort in the given context. If `ctx=None`, then the global context is used.
2897 
2898  >>> RealSort()
2899  Real
2900  >>> x = Const('x', RealSort())
2901  >>> is_real(x)
2902  True
2903  >>> is_int(x)
2904  False
2905  >>> x.sort() == RealSort()
2906  True
2907  """
2908  ctx = _get_ctx(ctx)
2909  return ArithSortRef(Z3_mk_real_sort(ctx.ref()), ctx)
2910 
def RealSort(ctx=None)
Definition: z3py.py:2895
Z3_sort Z3_API Z3_mk_real_sort(Z3_context c)
Create the real type.

◆ 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 2937 of file z3py.py.

Referenced by RatNumRef.as_decimal(), RatNumRef.as_fraction(), RatNumRef.denominator_as_long(), fpRealToFP(), fpToFP(), is_algebraic_value(), is_int_value(), is_rational_value(), is_real(), RatNumRef.numerator(), and RatNumRef.numerator_as_long().

2937 def RealVal(val, ctx=None):
2938  """Return a Z3 real value.
2939 
2940  `val` may be a Python int, long, float or string representing a number in decimal or rational notation.
2941  If `ctx=None`, then the global context is used.
2942 
2943  >>> RealVal(1)
2944  1
2945  >>> RealVal(1).sort()
2946  Real
2947  >>> RealVal("3/5")
2948  3/5
2949  >>> RealVal("1.5")
2950  3/2
2951  """
2952  ctx = _get_ctx(ctx)
2953  return RatNumRef(Z3_mk_numeral(ctx.ref(), str(val), RealSort(ctx).ast), ctx)
2954 
def RealSort(ctx=None)
Definition: z3py.py:2895
def RealVal(val, ctx=None)
Definition: z3py.py:2937
Z3_ast Z3_API Z3_mk_numeral(Z3_context c, Z3_string numeral, Z3_sort ty)
Create a numeral of a given sort.

◆ 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 1322 of file z3py.py.

Referenced by RealVarVector().

1322 def RealVar(idx, ctx=None):
1323  """
1324  Create a real free variable. Free variables are used to create quantified formulas.
1325  They are also used to create polynomials.
1326 
1327  >>> RealVar(0)
1328  Var(0)
1329  """
1330  return Var(idx, RealSort(ctx))
1331 
def RealSort(ctx=None)
Definition: z3py.py:2895
def Var(idx, s)
Definition: z3py.py:1310
def RealVar(idx, ctx=None)
Definition: z3py.py:1322

◆ 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 1332 of file z3py.py.

1332 def RealVarVector(n, ctx=None):
1333  """
1334  Create a list of Real free variables.
1335  The variables have ids: 0, 1, ..., n-1
1336 
1337  >>> x0, x1, x2, x3 = RealVarVector(4)
1338  >>> x2
1339  Var(2)
1340  """
1341  return [ RealVar(i, ctx) for i in range(n) ]
1342 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3244
def RealVarVector(n, ctx=None)
Definition: z3py.py:1332
def RealVar(idx, ctx=None)
Definition: z3py.py:1322

◆ 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 3056 of file z3py.py.

3056 def RealVector(prefix, sz, ctx=None):
3057  """Return a list of real constants of size `sz`.
3058 
3059  >>> X = RealVector('x', 3)
3060  >>> X
3061  [x__0, x__1, x__2]
3062  >>> Sum(X)
3063  x__0 + x__1 + x__2
3064  >>> Sum(X).sort()
3065  Real
3066  """
3067  return [ Real('%s__%s' % (prefix, i)) for i in range(sz) ]
3068 
def RealVector(prefix, sz, ctx=None)
Definition: z3py.py:3056
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3244
def Real(name, ctx=None)
Definition: z3py.py:3030

◆ RecAddDefinition()

def z3py.RecAddDefinition (   f,
  args,
  body 
)
Set the body of a recursive function.
   Recursive definitions are only unfolded during search.
>>> 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))
fac(5)
>>> s = Solver(ctx=ctx)
>>> s.add(fac(n) < 3)
>>> s.check()
sat
>>> s.model().eval(fac(5))
120

Definition at line 820 of file z3py.py.

820 def RecAddDefinition(f, args, body):
821  """Set the body of a recursive function.
822  Recursive definitions are only unfolded during search.
823  >>> ctx = Context()
824  >>> fac = RecFunction('fac', IntSort(ctx), IntSort(ctx))
825  >>> n = Int('n', ctx)
826  >>> RecAddDefinition(fac, n, If(n == 0, 1, n*fac(n-1)))
827  >>> simplify(fac(5))
828  fac(5)
829  >>> s = Solver(ctx=ctx)
830  >>> s.add(fac(n) < 3)
831  >>> s.check()
832  sat
833  >>> s.model().eval(fac(5))
834  120
835  """
836  if is_app(args):
837  args = [args]
838  ctx = body.ctx
839  args = _get_args(args)
840  n = len(args)
841  _args = (Ast * n)()
842  for i in range(n):
843  _args[i] = args[i].ast
844  Z3_add_rec_def(ctx.ref(), f.ast, n, _args, body.ast)
845 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3244
def is_app(a)
Definition: z3py.py:1116
def RecAddDefinition(f, args, body)
Definition: z3py.py:820
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 803 of file z3py.py.

803 def RecFunction(name, *sig):
804  """Create a new Z3 recursive with the given sorts."""
805  sig = _get_args(sig)
806  if __debug__:
807  _z3_assert(len(sig) > 0, "At least two arguments expected")
808  arity = len(sig) - 1
809  rng = sig[arity]
810  if __debug__:
811  _z3_assert(is_sort(rng), "Z3 sort expected")
812  dom = (Sort * arity)()
813  for i in range(arity):
814  if __debug__:
815  _z3_assert(is_sort(sig[i]), "Z3 sort expected")
816  dom[i] = sig[i].ast
817  ctx = rng.ctx
818  return FuncDeclRef(Z3_mk_rec_func_decl(ctx.ref(), to_symbol(name, ctx), arity, dom, rng.ast), ctx)
819 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3244
def to_symbol(s, ctx=None)
Definition: z3py.py:105
def RecFunction(name, sig)
Definition: z3py.py:803
def is_sort(s)
Definition: z3py.py:579
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 7764 of file z3py.py.

7764 def Repeat(t, max=4294967295, ctx=None):
7765  """Return a tactic that keeps applying `t` until the goal is not modified anymore or the maximum number of iterations `max` is reached.
7766 
7767  >>> x, y = Ints('x y')
7768  >>> c = And(Or(x == 0, x == 1), Or(y == 0, y == 1), x > y)
7769  >>> t = Repeat(OrElse(Tactic('split-clause'), Tactic('skip')))
7770  >>> r = t(c)
7771  >>> for subgoal in r: print(subgoal)
7772  [x == 0, y == 0, x > y]
7773  [x == 0, y == 1, x > y]
7774  [x == 1, y == 0, x > y]
7775  [x == 1, y == 1, x > y]
7776  >>> t = Then(t, Tactic('propagate-values'))
7777  >>> t(c)
7778  [[x == 1, y == 0]]
7779  """
7780  t = _to_tactic(t, ctx)
7781  return Tactic(Z3_tactic_repeat(t.ctx.ref(), t.tactic, max), t.ctx)
7782 
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...
def Repeat(t, max=4294967295, ctx=None)
Definition: z3py.py:7764

◆ 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 4102 of file z3py.py.

4102 def RepeatBitVec(n, a):
4103  """Return an expression representing `n` copies of `a`.
4104 
4105  >>> x = BitVec('x', 8)
4106  >>> n = RepeatBitVec(4, x)
4107  >>> n
4108  RepeatBitVec(4, x)
4109  >>> n.size()
4110  32
4111  >>> v0 = BitVecVal(10, 4)
4112  >>> print("%.x" % v0.as_long())
4113  a
4114  >>> v = simplify(RepeatBitVec(4, v0))
4115  >>> v.size()
4116  16
4117  >>> print("%.x" % v.as_long())
4118  aaaa
4119  """
4120  if __debug__:
4121  _z3_assert(_is_int(n), "First argument must be an integer")
4122  _z3_assert(is_bv(a), "Second argument must be a Z3 Bitvector expression")
4123  return BitVecRef(Z3_mk_repeat(a.ctx_ref(), n, a.as_ast()), a.ctx)
4124 
Z3_ast Z3_API Z3_mk_repeat(Z3_context c, unsigned i, Z3_ast t1)
Repeat the given bit-vector up length i.
def is_bv(a)
Definition: z3py.py:3655
def RepeatBitVec(n, a)
Definition: z3py.py:4102

◆ 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 10079 of file z3py.py.

10079 def Replace(s, src, dst):
10080  """Replace the first occurrence of 'src' by 'dst' in 's'
10081  >>> r = Replace("aaa", "a", "b")
10082  >>> simplify(r)
10083  baa
10084  """
10085  ctx = _get_ctx2(dst, s)
10086  if ctx is None and is_expr(src):
10087  ctx = src.ctx
10088  src = _coerce_seq(src, ctx)
10089  dst = _coerce_seq(dst, ctx)
10090  s = _coerce_seq(s, ctx)
10091  return SeqRef(Z3_mk_seq_replace(src.ctx_ref(), s.as_ast(), src.as_ast(), dst.as_ast()), s.ctx)
10092 
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.
def Replace(s, src, dst)
Definition: z3py.py:10079
def is_expr(a)
Definition: z3py.py:1094

◆ reset_params()

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

Definition at line 256 of file z3py.py.

256 def reset_params():
257  """Reset all global (or module) parameters.
258  """
260 
def reset_params()
Definition: z3py.py:256
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 10163 of file z3py.py.

Referenced by Empty(), Full(), and Context.mkReSort().

10163 def ReSort(s):
10164  if is_ast(s):
10165  return ReSortRef(Z3_mk_re_sort(s.ctx.ref(), s.ast), s.ctx)
10166  if s is None or isinstance(s, Context):
10167  ctx = _get_ctx(s)
10168  return ReSortRef(Z3_mk_re_sort(ctx.ref(), Z3_mk_string_sort(ctx.ref())), s.ctx)
10169  raise Z3Exception("Regular expression sort constructor expects either a string or a context or no argument")
10170 
10171 
def ReSort(s)
Definition: z3py.py:10163
Z3_sort Z3_API Z3_mk_string_sort(Z3_context c)
Create a sort for 8 bit strings.
def is_ast(a)
Definition: z3py.py:396
Z3_sort Z3_API Z3_mk_re_sort(Z3_context c, Z3_sort seq)
Create a regular expression sort out of a sequence sort.

◆ RNA()

def z3py.RNA (   ctx = None)

Definition at line 8891 of file z3py.py.

8891 def RNA (ctx=None):
8892  ctx = _get_ctx(ctx)
8893  return FPRMRef(Z3_mk_fpa_round_nearest_ties_to_away(ctx.ref()), ctx)
8894 
def RNA(ctx=None)
Definition: z3py.py:8891
Z3_ast Z3_API Z3_mk_fpa_round_nearest_ties_to_away(Z3_context c)
Create a numeral of RoundingMode sort which represents the NearestTiesToAway rounding mode...

◆ RNE()

def z3py.RNE (   ctx = None)

Definition at line 8883 of file z3py.py.

Referenced by fpAbs(), fpAdd(), fpDiv(), fpFPToFP(), fpMax(), fpMin(), fpMul(), fpNeg(), fpRealToFP(), FPs(), fpSignedToFP(), fpSub(), fpToFP(), fpUnsignedToFP(), is_fprm(), and is_fprm_sort().

8883 def RNE (ctx=None):
8884  ctx = _get_ctx(ctx)
8885  return FPRMRef(Z3_mk_fpa_round_nearest_ties_to_even(ctx.ref()), ctx)
8886 
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...
def RNE(ctx=None)
Definition: z3py.py:8883

◆ 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 4016 of file z3py.py.

4016 def RotateLeft(a, b):
4017  """Return an expression representing `a` rotated to the left `b` times.
4018 
4019  >>> a, b = BitVecs('a b', 16)
4020  >>> RotateLeft(a, b)
4021  RotateLeft(a, b)
4022  >>> simplify(RotateLeft(a, 0))
4023  a
4024  >>> simplify(RotateLeft(a, 16))
4025  a
4026  """
4027  _check_bv_args(a, b)
4028  a, b = _coerce_exprs(a, b)
4029  return BitVecRef(Z3_mk_ext_rotate_left(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4030 
def RotateLeft(a, b)
Definition: z3py.py:4016
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 4031 of file z3py.py.

4031 def RotateRight(a, b):
4032  """Return an expression representing `a` rotated to the right `b` times.
4033 
4034  >>> a, b = BitVecs('a b', 16)
4035  >>> RotateRight(a, b)
4036  RotateRight(a, b)
4037  >>> simplify(RotateRight(a, 0))
4038  a
4039  >>> simplify(RotateRight(a, 16))
4040  a
4041  """
4042  _check_bv_args(a, b)
4043  a, b = _coerce_exprs(a, b)
4044  return BitVecRef(Z3_mk_ext_rotate_right(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4045 
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.
def RotateRight(a, b)
Definition: z3py.py:4031

◆ RoundNearestTiesToAway()

def z3py.RoundNearestTiesToAway (   ctx = None)

Definition at line 8887 of file z3py.py.

8887 def RoundNearestTiesToAway(ctx=None):
8888  ctx = _get_ctx(ctx)
8889  return FPRMRef(Z3_mk_fpa_round_nearest_ties_to_away(ctx.ref()), ctx)
8890 
def RoundNearestTiesToAway(ctx=None)
Definition: z3py.py:8887
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...

◆ RoundNearestTiesToEven()

def z3py.RoundNearestTiesToEven (   ctx = None)

Definition at line 8879 of file z3py.py.

8879 def RoundNearestTiesToEven(ctx=None):
8880  ctx = _get_ctx(ctx)
8881  return FPRMRef(Z3_mk_fpa_round_nearest_ties_to_even(ctx.ref()), ctx)
8882 
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...
def RoundNearestTiesToEven(ctx=None)
Definition: z3py.py:8879

◆ RoundTowardNegative()

def z3py.RoundTowardNegative (   ctx = None)

Definition at line 8903 of file z3py.py.

8903 def RoundTowardNegative(ctx=None):
8904  ctx = _get_ctx(ctx)
8905  return FPRMRef(Z3_mk_fpa_round_toward_negative(ctx.ref()), ctx)
8906 
def RoundTowardNegative(ctx=None)
Definition: z3py.py:8903
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 8895 of file z3py.py.

8895 def RoundTowardPositive(ctx=None):
8896  ctx = _get_ctx(ctx)
8897  return FPRMRef(Z3_mk_fpa_round_toward_positive(ctx.ref()), ctx)
8898 
def RoundTowardPositive(ctx=None)
Definition: z3py.py:8895
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 8911 of file z3py.py.

8911 def RoundTowardZero(ctx=None):
8912  ctx = _get_ctx(ctx)
8913  return FPRMRef(Z3_mk_fpa_round_toward_zero(ctx.ref()), ctx)
8914 
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.
def RoundTowardZero(ctx=None)
Definition: z3py.py:8911

◆ RTN()

def z3py.RTN (   ctx = None)

Definition at line 8907 of file z3py.py.

8907 def RTN(ctx=None):
8908  ctx = _get_ctx(ctx)
8909  return FPRMRef(Z3_mk_fpa_round_toward_negative(ctx.ref()), ctx)
8910 
def RTN(ctx=None)
Definition: z3py.py:8907
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...

◆ RTP()

def z3py.RTP (   ctx = None)

Definition at line 8899 of file z3py.py.

8899 def RTP(ctx=None):
8900  ctx = _get_ctx(ctx)
8901  return FPRMRef(Z3_mk_fpa_round_toward_positive(ctx.ref()), ctx)
8902 
def RTP(ctx=None)
Definition: z3py.py:8899
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...

◆ RTZ()

def z3py.RTZ (   ctx = None)

Definition at line 8915 of file z3py.py.

Referenced by fpAdd(), fpToSBV(), and fpToUBV().

8915 def RTZ(ctx=None):
8916  ctx = _get_ctx(ctx)
8917  return FPRMRef(Z3_mk_fpa_round_toward_zero(ctx.ref()), ctx)
8918 
def RTZ(ctx=None)
Definition: z3py.py:8915
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.

◆ 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 4433 of file z3py.py.

4433 def Select(a, i):
4434  """Return a Z3 select array expression.
4435 
4436  >>> a = Array('a', IntSort(), IntSort())
4437  >>> i = Int('i')
4438  >>> Select(a, i)
4439  a[i]
4440  >>> eq(Select(a, i), a[i])
4441  True
4442  """
4443  if __debug__:
4444  _z3_assert(is_array(a), "First argument must be a Z3 array expression")
4445  return a[i]
4446 
4447 
def is_array(a)
Definition: z3py.py:4263
def Select(a, i)
Definition: z3py.py:4433

◆ 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 9884 of file z3py.py.

Referenced by Empty(), Full(), SeqSortRef.is_string(), Context.mkSeqSort(), and Context.mkStringSort().

9884 def SeqSort(s):
9885  """Create a sequence sort over elements provided in the argument
9886  >>> s = SeqSort(IntSort())
9887  >>> s == Unit(IntVal(1)).sort()
9888  True
9889  """
9890  return SeqSortRef(Z3_mk_seq_sort(s.ctx_ref(), s.ast), s.ctx)
9891 
def SeqSort(s)
Definition: z3py.py:9884
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 8554 of file z3py.py.

8554 def set_default_fp_sort(ebits, sbits, ctx=None):
8555  global _dflt_fpsort_ebits
8556  global _dflt_fpsort_sbits
8557  _dflt_fpsort_ebits = ebits
8558  _dflt_fpsort_sbits = sbits
8559 
def set_default_fp_sort(ebits, sbits, ctx=None)
Definition: z3py.py:8554

◆ set_default_rounding_mode()

def z3py.set_default_rounding_mode (   rm,
  ctx = None 
)

Definition at line 8538 of file z3py.py.

8538 def set_default_rounding_mode(rm, ctx=None):
8539  global _dflt_rounding_mode
8540  if is_fprm_value(rm):
8541  _dflt_rounding_mode = rm.decl().kind()
8542  else:
8543  _z3_assert(_dflt_rounding_mode == Z3_OP_FPA_RM_TOWARD_ZERO or
8544  _dflt_rounding_mode == Z3_OP_FPA_RM_TOWARD_NEGATIVE or
8545  _dflt_rounding_mode == Z3_OP_FPA_RM_TOWARD_POSITIVE or
8546  _dflt_rounding_mode == Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN or
8547  _dflt_rounding_mode == Z3_OP_FPA_RM_NEAREST_TIES_TO_AWAY,
8548  "illegal rounding mode")
8549  _dflt_rounding_mode = rm
8550 
def set_default_rounding_mode(rm, ctx=None)
Definition: z3py.py:8538
def is_fprm_value(a)
Definition: z3py.py:8931

◆ set_option()

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

Definition at line 261 of file z3py.py.

261 def set_option(*args, **kws):
262  """Alias for 'set_param' for backward compatibility.
263  """
264  return set_param(*args, **kws)
265 
def set_option(args, kws)
Definition: z3py.py:261
def set_param(args, kws)
Definition: z3py.py:233

◆ set_param()

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

>>> set_param(precision=10)

Definition at line 233 of file z3py.py.

Referenced by set_option().

233 def set_param(*args, **kws):
234  """Set Z3 global (or module) parameters.
235 
236  >>> set_param(precision=10)
237  """
238  if __debug__:
239  _z3_assert(len(args) % 2 == 0, "Argument list must have an even number of elements.")
240  new_kws = {}
241  for k in kws:
242  v = kws[k]
243  if not set_pp_option(k, v):
244  new_kws[k] = v
245  for key in new_kws:
246  value = new_kws[key]
247  Z3_global_param_set(str(key).upper(), _to_param_value(value))
248  prev = None
249  for a in args:
250  if prev is None:
251  prev = a
252  else:
253  Z3_global_param_set(str(prev), _to_param_value(a))
254  prev = None
255 
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.
def set_param(args, kws)
Definition: z3py.py:233

◆ 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 4572 of file z3py.py.

4572 def SetAdd(s, e):
4573  """ Add element e to set s
4574  >>> a = Const('a', SetSort(IntSort()))
4575  >>> SetAdd(a, 1)
4576  Store(a, 1, True)
4577  """
4578  ctx = _ctx_from_ast_arg_list([s,e])
4579  e = _py2expr(e, ctx)
4580  return ArrayRef(Z3_mk_set_add(ctx.ref(), s.as_ast(), e.as_ast()), ctx)
4581 
Z3_ast Z3_API Z3_mk_set_add(Z3_context c, Z3_ast set, Z3_ast elem)
Add an element to a set.
def SetAdd(s, e)
Definition: z3py.py:4572

◆ SetComplement()

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

Definition at line 4592 of file z3py.py.

4592 def SetComplement(s):
4593  """ The complement of set s
4594  >>> a = Const('a', SetSort(IntSort()))
4595  >>> SetComplement(a)
4596  complement(a)
4597  """
4598  ctx = s.ctx
4599  return ArrayRef(Z3_mk_set_complement(ctx.ref(), s.as_ast()), ctx)
4600 
Z3_ast Z3_API Z3_mk_set_complement(Z3_context c, Z3_ast arg)
Take the complement of a set.
def SetComplement(s)
Definition: z3py.py:4592

◆ 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 4582 of file z3py.py.

4582 def SetDel(s, e):
4583  """ Remove element e to set s
4584  >>> a = Const('a', SetSort(IntSort()))
4585  >>> SetDel(a, 1)
4586  Store(a, 1, False)
4587  """
4588  ctx = _ctx_from_ast_arg_list([s,e])
4589  e = _py2expr(e, ctx)
4590  return ArrayRef(Z3_mk_set_del(ctx.ref(), s.as_ast(), e.as_ast()), ctx)
4591 
Z3_ast Z3_API Z3_mk_set_del(Z3_context c, Z3_ast set, Z3_ast elem)
Remove an element to a set.
def SetDel(s, e)
Definition: z3py.py:4582

◆ 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)
difference(a, b)

Definition at line 4601 of file z3py.py.

4601 def SetDifference(a, b):
4602  """ The set difference of a and b
4603  >>> a = Const('a', SetSort(IntSort()))
4604  >>> b = Const('b', SetSort(IntSort()))
4605  >>> SetDifference(a, b)
4606  difference(a, b)
4607  """
4608  ctx = _ctx_from_ast_arg_list([a, b])
4609  return ArrayRef(Z3_mk_set_difference(ctx.ref(), a.as_ast(), b.as_ast()), ctx)
4610 
def SetDifference(a, b)
Definition: z3py.py:4601
Z3_ast Z3_API Z3_mk_set_difference(Z3_context c, Z3_ast arg1, Z3_ast arg2)
Take the set difference between two sets.

◆ SetIntersect()

def z3py.SetIntersect (   args)
Take the union of sets
>>> a = Const('a', SetSort(IntSort()))
>>> b = Const('b', SetSort(IntSort()))
>>> SetIntersect(a, b)
intersect(a, b)

Definition at line 4560 of file z3py.py.

4560 def SetIntersect(*args):
4561  """ Take the union of sets
4562  >>> a = Const('a', SetSort(IntSort()))
4563  >>> b = Const('b', SetSort(IntSort()))
4564  >>> SetIntersect(a, b)
4565  intersect(a, b)
4566  """
4567  args = _get_args(args)
4568  ctx = _ctx_from_ast_arg_list(args)
4569  _args, sz = _to_ast_array(args)
4570  return ArrayRef(Z3_mk_set_intersect(ctx.ref(), sz, _args), ctx)
4571 
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.
def SetIntersect(args)
Definition: z3py.py:4560

◆ SetSort()

def z3py.SetSort (   s)

Sets.

Create a set sort over element sort s

Definition at line 4528 of file z3py.py.

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

4528 def SetSort(s):
4529  """ Create a set sort over element sort s"""
4530  return ArraySort(s, BoolSort())
4531 
def ArraySort(sig)
Definition: z3py.py:4340
def SetSort(s)
Sets.
Definition: z3py.py:4528
def BoolSort(ctx=None)
Definition: z3py.py:1512

◆ 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 4548 of file z3py.py.

4548 def SetUnion(*args):
4549  """ Take the union of sets
4550  >>> a = Const('a', SetSort(IntSort()))
4551  >>> b = Const('b', SetSort(IntSort()))
4552  >>> SetUnion(a, b)
4553  union(a, b)
4554  """
4555  args = _get_args(args)
4556  ctx = _ctx_from_ast_arg_list(args)
4557  _args, sz = _to_ast_array(args)
4558  return ArrayRef(Z3_mk_set_union(ctx.ref(), sz, _args), ctx)
4559 
def SetUnion(args)
Definition: z3py.py:4548
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 4046 of file z3py.py.

4046 def SignExt(n, a):
4047  """Return a bit-vector expression with `n` extra sign-bits.
4048 
4049  >>> x = BitVec('x', 16)
4050  >>> n = SignExt(8, x)
4051  >>> n.size()
4052  24
4053  >>> n
4054  SignExt(8, x)
4055  >>> n.sort()
4056  BitVec(24)
4057  >>> v0 = BitVecVal(2, 2)
4058  >>> v0
4059  2
4060  >>> v0.size()
4061  2
4062  >>> v = simplify(SignExt(6, v0))
4063  >>> v
4064  254
4065  >>> v.size()
4066  8
4067  >>> print("%.x" % v.as_long())
4068  fe
4069  """
4070  if __debug__:
4071  _z3_assert(_is_int(n), "First argument must be an integer")
4072  _z3_assert(is_bv(a), "Second argument must be a Z3 Bitvector expression")
4073  return BitVecRef(Z3_mk_sign_ext(a.ctx_ref(), n, a.as_ast()), a.ctx)
4074 
def SignExt(n, a)
Definition: z3py.py:4046
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...
def is_bv(a)
Definition: z3py.py:3655

◆ SimpleSolver()

def z3py.SimpleSolver (   ctx = 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 6844 of file z3py.py.

Referenced by Solver.reason_unknown(), and Solver.statistics().

6844 def SimpleSolver(ctx=None):
6845  """Return a simple general purpose solver with limited amount of preprocessing.
6846 
6847  >>> s = SimpleSolver()
6848  >>> x = Int('x')
6849  >>> s.add(x > 0)
6850  >>> s.check()
6851  sat
6852  """
6853  ctx = _get_ctx(ctx)
6854  return Solver(Z3_mk_simple_solver(ctx.ref()), ctx)
6855 
Z3_solver Z3_API Z3_mk_simple_solver(Z3_context c)
Create a new incremental solver.
def SimpleSolver(ctx=None)
Definition: z3py.py:6844

◆ 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 8086 of file z3py.py.

Referenced by BitVecRef.__invert__(), BitVecRef.__lshift__(), ArithRef.__mod__(), ArithRef.__neg__(), BitVecRef.__neg__(), ArithRef.__pow__(), ArithRef.__rpow__(), BitVecRef.__rshift__(), AlgebraicNumRef.approx(), AlgebraicNumRef.as_decimal(), BitVecs(), Concat(), Contains(), CreateDatatypes(), Extract(), fpBVToFP(), fpFPToFP(), fpRealToFP(), fpSignedToFP(), fpToFP(), fpUnsignedToFP(), Implies(), IndexOf(), InRe(), is_algebraic_value(), K(), Length(), Loop(), LShR(), Not(), Option(), Plus(), PrefixOf(), DatatypeSortRef.recognizer(), RepeatBitVec(), Replace(), RotateLeft(), RotateRight(), SignExt(), Star(), StrToInt(), SuffixOf(), Union(), Xor(), and ZeroExt().

8086 def simplify(a, *arguments, **keywords):
8087  """Simplify the expression `a` using the given options.
8088 
8089  This function has many options. Use `help_simplify` to obtain the complete list.
8090 
8091  >>> x = Int('x')
8092  >>> y = Int('y')
8093  >>> simplify(x + 1 + y + x + 1)
8094  2 + 2*x + y
8095  >>> simplify((x + 1)*(y + 1), som=True)
8096  1 + x + y + x*y
8097  >>> simplify(Distinct(x, y, 1), blast_distinct=True)
8098  And(Not(x == y), Not(x == 1), Not(y == 1))
8099  >>> simplify(And(x == 0, y == 1), elim_and=True)
8100  Not(Or(Not(x == 0), Not(y == 1)))
8101  """
8102  if __debug__:
8103  _z3_assert(is_expr(a), "Z3 expression expected")
8104  if len(arguments) > 0 or len(keywords) > 0:
8105  p = args2params(arguments, keywords, a.ctx)
8106  return _to_expr_ref(Z3_simplify_ex(a.ctx_ref(), a.as_ast(), p.params), a.ctx)
8107  else:
8108  return _to_expr_ref(Z3_simplify(a.ctx_ref(), a.as_ast()), a.ctx)
8109 
def simplify(a, arguments, keywords)
Utils.
Definition: z3py.py:8086
def args2params(arguments, keywords, ctx=None)
Definition: z3py.py:5007
Z3_ast Z3_API Z3_simplify_ex(Z3_context c, Z3_ast a, Z3_params p)
Interface to simplifier.
Z3_ast Z3_API Z3_simplify(Z3_context c, Z3_ast a)
Interface to simplifier.
def is_expr(a)
Definition: z3py.py:1094

◆ simplify_param_descrs()

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

Definition at line 8114 of file z3py.py.

8114 def simplify_param_descrs():
8115  """Return the set of parameter descriptions for Z3 `simplify` procedure."""
8116  return ParamDescrsRef(Z3_simplify_get_param_descrs(main_ctx().ref()), main_ctx())
8117 
def main_ctx()
Definition: z3py.py:207
Z3_param_descrs Z3_API Z3_simplify_get_param_descrs(Z3_context c)
Return the parameter description set for the simplify procedure.
def simplify_param_descrs()
Definition: z3py.py:8114

◆ 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 8299 of file z3py.py.

Referenced by BV2Int(), and IsInt().

8299 def solve(*args, **keywords):
8300  """Solve the constraints `*args`.
8301 
8302  This is a simple function for creating demonstrations. It creates a solver,
8303  configure it using the options in `keywords`, adds the constraints
8304  in `args`, and invokes check.
8305 
8306  >>> a = Int('a')
8307  >>> solve(a > 0, a < 2)
8308  [a = 1]
8309  """
8310  s = Solver()
8311  s.set(**keywords)
8312  s.add(*args)
8313  if keywords.get('show', False):
8314  print(s)
8315  r = s.check()
8316  if r == unsat:
8317  print("no solution")
8318  elif r == unknown:
8319  print("failed to solve")
8320  try:
8321  print(s.model())
8322  except Z3Exception:
8323  return
8324  else:
8325  print(s.model())
8326 
def solve(args, keywords)
Definition: z3py.py:8299

◆ 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 8327 of file z3py.py.

8327 def solve_using(s, *args, **keywords):
8328  """Solve the constraints `*args` using solver `s`.
8329 
8330  This is a simple function for creating demonstrations. It is similar to `solve`,
8331  but it uses the given solver `s`.
8332  It configures solver `s` using the options in `keywords`, adds the constraints
8333  in `args`, and invokes check.
8334  """
8335  if __debug__:
8336  _z3_assert(isinstance(s, Solver), "Solver object expected")
8337  s.set(**keywords)
8338  s.add(*args)
8339  if keywords.get('show', False):
8340  print("Problem:")
8341  print(s)
8342  r = s.check()
8343  if r == unsat:
8344  print("no solution")
8345  elif r == unknown:
8346  print("failed to solve")
8347  try:
8348  print(s.model())
8349  except Z3Exception:
8350  return
8351  else:
8352  if keywords.get('show', False):
8353  print("Solution:")
8354  print(s.model())
8355 
def solve_using(s, args, keywords)
Definition: z3py.py:8327

◆ SolverFor()

def z3py.SolverFor (   logic,
  ctx = 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 6824 of file z3py.py.

6824 def SolverFor(logic, ctx=None):
6825  """Create a solver customized for the given logic.
6826 
6827  The parameter `logic` is a string. It should be contains
6828  the name of a SMT-LIB logic.
6829  See http://www.smtlib.org/ for the name of all available logics.
6830 
6831  >>> s = SolverFor("QF_LIA")
6832  >>> x = Int('x')
6833  >>> s.add(x > 0)
6834  >>> s.add(x < 2)
6835  >>> s.check()
6836  sat
6837  >>> s.model()
6838  [x = 1]
6839  """
6840  ctx = _get_ctx(ctx)
6841  logic = to_symbol(logic)
6842  return Solver(Z3_mk_solver_for_logic(ctx.ref(), logic), ctx)
6843 
def to_symbol(s, ctx=None)
Definition: z3py.py:105
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...
def SolverFor(logic, ctx=None)
Definition: z3py.py:6824

◆ 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 3132 of file z3py.py.

Referenced by AlgebraicNumRef.approx(), AlgebraicNumRef.as_decimal(), and is_algebraic_value().

3132 def Sqrt(a, ctx=None):
3133  """ Return a Z3 expression which represents the square root of a.
3134 
3135  >>> x = Real('x')
3136  >>> Sqrt(x)
3137  x**(1/2)
3138  """
3139  if not is_expr(a):
3140  ctx = _get_ctx(ctx)
3141  a = RealVal(a, ctx)
3142  return a ** "1/2"
3143 
def RealVal(val, ctx=None)
Definition: z3py.py:2937
def is_expr(a)
Definition: z3py.py:1094
def Sqrt(a, ctx=None)
Definition: z3py.py:3132

◆ 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 3965 of file z3py.py.

Referenced by BitVecRef.__mod__(), BitVecRef.__rmod__(), and URem().

3965 def SRem(a, b):
3966  """Create the Z3 expression signed remainder.
3967 
3968  Use the operator % for signed modulus, and URem() for unsigned remainder.
3969 
3970  >>> x = BitVec('x', 32)
3971  >>> y = BitVec('y', 32)
3972  >>> SRem(x, y)
3973  SRem(x, y)
3974  >>> SRem(x, y).sort()
3975  BitVec(32)
3976  >>> (x % y).sexpr()
3977  '(bvsmod x y)'
3978  >>> SRem(x, y).sexpr()
3979  '(bvsrem x y)'
3980  """
3981  _check_bv_args(a, b)
3982  a, b = _coerce_exprs(a, b)
3983  return BitVecRef(Z3_mk_bvsrem(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3984 
Z3_ast Z3_API Z3_mk_bvsrem(Z3_context c, Z3_ast t1, Z3_ast t2)
Two&#39;s complement signed remainder (sign follows dividend).
def SRem(a, b)
Definition: z3py.py:3965

◆ 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 10243 of file z3py.py.

10243 def Star(re):
10244  """Create the regular expression accepting zero or more repetitions of argument.
10245  >>> re = Star(Re("a"))
10246  >>> print(simplify(InRe("aa", re)))
10247  True
10248  >>> print(simplify(InRe("ab", re)))
10249  False
10250  >>> print(simplify(InRe("", re)))
10251  True
10252  """
10253  return ReRef(Z3_mk_re_star(re.ctx_ref(), re.as_ast()), re.ctx)
10254 
def Star(re)
Definition: z3py.py:10243
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 4417 of file z3py.py.

Referenced by is_array(), is_store(), SetAdd(), and SetDel().

4417 def Store(a, i, v):
4418  """Return a Z3 store array expression.
4419 
4420  >>> a = Array('a', IntSort(), IntSort())
4421  >>> i, v = Ints('i v')
4422  >>> s = Store(a, i, v)
4423  >>> s.sort()
4424  Array(Int, Int)
4425  >>> prove(s[i] == v)
4426  proved
4427  >>> j = Int('j')
4428  >>> prove(Implies(i != j, s[j] == a[j]))
4429  proved
4430  """
4431  return Update(a, i, v)
4432 
def Update(a, i, v)
Definition: z3py.py:4385
def Store(a, i, v)
Definition: z3py.py:4417

◆ 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 9972 of file z3py.py.

Referenced by Native.applyResultToString(), Native.astMapToString(), Native.astToString(), Native.astVectorToString(), Native.benchmarkToSmtlibString(), Context.Context(), Native.evalSmtlib2String(), Native.fixedpointGetHelp(), Native.fixedpointGetReasonUnknown(), Native.fixedpointToString(), Native.fpaGetNumeralExponentString(), Native.fpaGetNumeralSignificandString(), Native.funcDeclToString(), Native.getDeclRationalParameter(), Statistics.getEntries(), Native.getErrorMsg(), Native.getFullVersion(), Statistics.getKeys(), Native.getNumeralDecimalString(), Native.getNumeralString(), Native.getProbeName(), Context.getProbeNames(), Native.getString(), Native.getSymbolString(), Native.getTacticName(), Context.getTacticNames(), Native.goalToDimacsString(), Native.goalToString(), Native.modelToString(), Native.optimizeGetHelp(), Native.optimizeGetReasonUnknown(), Native.optimizeToString(), Native.paramDescrsGetDocumentation(), Native.paramDescrsToString(), Native.paramsToString(), Native.patternToString(), Native.probeGetDescr(), Native.rcfNumToDecimalString(), Native.rcfNumToString(), Native.simplifyGetHelp(), Native.solverGetHelp(), Native.solverGetReasonUnknown(), Native.solverToString(), Native.sortToString(), Native.statsGetKey(), Native.statsToString(), Native.tacticGetDescr(), Native.tacticGetHelp(), and FuncInterp.toString().

9972 def String(name, ctx=None):
9973  """Return a string constant named `name`. If `ctx=None`, then the global context is used.
9974 
9975  >>> x = String('x')
9976  """
9977  ctx = _get_ctx(ctx)
9978  return SeqRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), StringSort(ctx).ast), ctx)
9979 
Z3_ast Z3_API Z3_mk_const(Z3_context c, Z3_symbol s, Z3_sort ty)
Declare and create a constant.
def to_symbol(s, ctx=None)
Definition: z3py.py:105
def StringSort(ctx=None)
Definition: z3py.py:9874
def String(name, ctx=None)
Definition: z3py.py:9972

◆ Strings()

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

Definition at line 9988 of file z3py.py.

Referenced by Contains().

9988 def Strings(names, ctx=None):
9989  """Return a tuple of String constants. """
9990  ctx = _get_ctx(ctx)
9991  if isinstance(names, str):
9992  names = names.split(" ")
9993  return [String(name, ctx) for name in names]
9994 
def Strings(names, ctx=None)
Definition: z3py.py:9988
def String(name, ctx=None)
Definition: z3py.py:9972

◆ StringSort()

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

Definition at line 9874 of file z3py.py.

Referenced by Empty(), Full(), and SeqSortRef.is_string().

9874 def StringSort(ctx=None):
9875  """Create a string sort
9876  >>> s = StringSort()
9877  >>> print(s)
9878  String
9879  """
9880  ctx = _get_ctx(ctx)
9881  return SeqSortRef(Z3_mk_string_sort(ctx.ref()), ctx)
9882 
9883 
def StringSort(ctx=None)
Definition: z3py.py:9874
Z3_sort Z3_API Z3_mk_string_sort(Z3_context c)
Create a sort for 8 bit strings.

◆ StringVal()

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

Definition at line 9967 of file z3py.py.

Referenced by Empty(), Extract(), is_seq(), is_string(), is_string_value(), Length(), and Re().

9967 def StringVal(s, ctx=None):
9968  """create a string expression"""
9969  ctx = _get_ctx(ctx)
9970  return SeqRef(Z3_mk_string(ctx.ref(), s), ctx)
9971 
Z3_ast Z3_API Z3_mk_string(Z3_context c, Z3_string s)
Create a string constant out of the string that is passed in.
def StringVal(s, ctx=None)
Definition: z3py.py:9967

◆ 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 10122 of file z3py.py.

10122 def StrToInt(s):
10123  """Convert string expression to integer
10124  >>> a = StrToInt("1")
10125  >>> simplify(1 == a)
10126  True
10127  >>> b = StrToInt("2")
10128  >>> simplify(1 == b)
10129  False
10130  >>> c = StrToInt(IntToStr(2))
10131  >>> simplify(1 == c)
10132  False
10133  """
10134  s = _coerce_seq(s)
10135  return ArithRef(Z3_mk_str_to_int(s.ctx_ref(), s.as_ast()), s.ctx)
10136 
10137 
Z3_ast Z3_API Z3_mk_str_to_int(Z3_context c, Z3_ast s)
Convert string to integer.
def StrToInt(s)
Definition: z3py.py:10122

◆ SubSeq()

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

Definition at line 9984 of file z3py.py.

9984 def SubSeq(s, offset, length):
9985  """Extract substring or subsequence starting at offset"""
9986  return Extract(s, offset, length)
9987 
def SubSeq(s, offset, length)
Definition: z3py.py:9984
def Extract(high, low, a)
Definition: z3py.py:3830

◆ 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 8118 of file z3py.py.

8118 def substitute(t, *m):
8119  """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.
8120 
8121  >>> x = Int('x')
8122  >>> y = Int('y')
8123  >>> substitute(x + 1, (x, y + 1))
8124  y + 1 + 1
8125  >>> f = Function('f', IntSort(), IntSort())
8126  >>> substitute(f(x) + f(y), (f(x), IntVal(1)), (f(y), IntVal(1)))
8127  1 + 1
8128  """
8129  if isinstance(m, tuple):
8130  m1 = _get_args(m)
8131  if isinstance(m1, list) and all(isinstance(p, tuple) for p in m1):
8132  m = m1
8133  if __debug__:
8134  _z3_assert(is_expr(t), "Z3 expression expected")
8135  _z3_assert(all([isinstance(p, tuple) and is_expr(p[0]) and is_expr(p[1]) and p[0].sort().eq(p[1].sort()) for p in m]), "Z3 invalid substitution, expression pairs expected.")
8136  num = len(m)
8137  _from = (Ast * num)()
8138  _to = (Ast * num)()
8139  for i in range(num):
8140  _from[i] = m[i][0].as_ast()
8141  _to[i] = m[i][1].as_ast()
8142  return _to_expr_ref(Z3_substitute(t.ctx.ref(), t.as_ast(), num, _from, _to), t.ctx)
8143 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3244
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. The result is the new AST. The arrays from and to must have size num_exprs. For every i smaller than num_exprs, we must have that sort of from[i] must be equal to sort of to[i].
def substitute(t, m)
Definition: z3py.py:8118
def eq(a, b)
Definition: z3py.py:416
def is_expr(a)
Definition: z3py.py:1094

◆ 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 8144 of file z3py.py.

8144 def substitute_vars(t, *m):
8145  """Substitute the free variables in t with the expression in m.
8146 
8147  >>> v0 = Var(0, IntSort())
8148  >>> v1 = Var(1, IntSort())
8149  >>> x = Int('x')
8150  >>> f = Function('f', IntSort(), IntSort(), IntSort())
8151  >>> # replace v0 with x+1 and v1 with x
8152  >>> substitute_vars(f(v0, v1), x + 1, x)
8153  f(x + 1, x)
8154  """
8155  if __debug__:
8156  _z3_assert(is_expr(t), "Z3 expression expected")
8157  _z3_assert(all([is_expr(n) for n in m]), "Z3 invalid substitution, list of expressions expected.")
8158  num = len(m)
8159  _to = (Ast * num)()
8160  for i in range(num):
8161  _to[i] = m[i].as_ast()
8162  return _to_expr_ref(Z3_substitute_vars(t.ctx.ref(), t.as_ast(), num, _to), t.ctx)
8163 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3244
def substitute_vars(t, m)
Definition: z3py.py:8144
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...
def is_expr(a)
Definition: z3py.py:1094

◆ SubString()

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

Definition at line 9980 of file z3py.py.

9980 def SubString(s, offset, length):
9981  """Extract substring or subsequence starting at offset"""
9982  return Extract(s, offset, length)
9983 
def SubString(s, offset, length)
Definition: z3py.py:9980
def Extract(high, low, a)
Definition: z3py.py:3830

◆ 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 10046 of file z3py.py.

10046 def SuffixOf(a, b):
10047  """Check if 'a' is a suffix of 'b'
10048  >>> s1 = SuffixOf("ab", "abc")
10049  >>> simplify(s1)
10050  False
10051  >>> s2 = SuffixOf("bc", "abc")
10052  >>> simplify(s2)
10053  True
10054  """
10055  ctx = _get_ctx2(a, b)
10056  a = _coerce_seq(a, ctx)
10057  b = _coerce_seq(b, ctx)
10058  return BoolRef(Z3_mk_seq_suffix(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
10059 
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.
def SuffixOf(a, b)
Definition: z3py.py:10046

◆ 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 8164 of file z3py.py.

Referenced by BitVecs(), Ints(), IntVector(), Reals(), and RealVector().

8164 def Sum(*args):
8165  """Create the sum of the Z3 expressions.
8166 
8167  >>> a, b, c = Ints('a b c')
8168  >>> Sum(a, b, c)
8169  a + b + c
8170  >>> Sum([a, b, c])
8171  a + b + c
8172  >>> A = IntVector('a', 5)
8173  >>> Sum(A)
8174  a__0 + a__1 + a__2 + a__3 + a__4
8175  """
8176  args = _get_args(args)
8177  if len(args) == 0:
8178  return 0
8179  ctx = _ctx_from_ast_arg_list(args)
8180  if ctx is None:
8181  return _reduce(lambda a, b: a + b, args, 0)
8182  args = _coerce_expr_list(args, ctx)
8183  if is_bv(args[0]):
8184  return _reduce(lambda a, b: a + b, args, 0)
8185  else:
8186  _args, sz = _to_ast_array(args)
8187  return ArithRef(Z3_mk_add(ctx.ref(), sz, _args), ctx)
8188 
8189 
def Sum(args)
Definition: z3py.py:8164
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].
def is_bv(a)
Definition: z3py.py:3655

◆ 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 7801 of file z3py.py.

Referenced by describe_tactics().

7801 def tactic_description(name, ctx=None):
7802  """Return a short description for the tactic named `name`.
7803 
7804  >>> d = tactic_description('simplify')
7805  """
7806  ctx = _get_ctx(ctx)
7807  return Z3_tactic_get_descr(ctx.ref(), name)
7808 
def tactic_description(name, ctx=None)
Definition: z3py.py:7801
Z3_string Z3_API Z3_tactic_get_descr(Z3_context c, Z3_string name)
Return a string containing a description of the tactic with the given name.

◆ tactics()

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

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

Definition at line 7791 of file z3py.py.

Referenced by describe_tactics(), and z3.par_or().

7791 def tactics(ctx=None):
7792  """Return a list of all available tactics in Z3.
7793 
7794  >>> l = tactics()
7795  >>> l.count('simplify') == 1
7796  True
7797  """
7798  ctx = _get_ctx(ctx)
7799  return [ Z3_get_tactic_name(ctx.ref(), i) for i in range(Z3_get_num_tactics(ctx.ref())) ]
7800 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3244
Z3_string Z3_API Z3_get_tactic_name(Z3_context c, unsigned i)
Return the name of the idx tactic.
def tactics(ctx=None)
Definition: z3py.py:7791
unsigned Z3_API Z3_get_num_tactics(Z3_context c)
Return the number of builtin tactics available in Z3.

◆ 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 7670 of file z3py.py.

Referenced by Statistics.__getattr__(), Statistics.__getitem__(), Statistics.__len__(), Goal.convert_model(), Goal.depth(), Statistics.get_key_value(), and Statistics.keys().

7670 def Then(*ts, **ks):
7671  """Return a tactic that applies the tactics in `*ts` in sequence. Shorthand for AndThen(*ts, **ks).
7672 
7673  >>> x, y = Ints('x y')
7674  >>> t = Then(Tactic('simplify'), Tactic('solve-eqs'))
7675  >>> t(And(x == 0, y > x + 1))
7676  [[Not(y <= 1)]]
7677  >>> t(And(x == 0, y > x + 1)).as_expr()
7678  Not(y <= 1)
7679  """
7680  return AndThen(*ts, **ks)
7681 
def Then(ts, ks)
Definition: z3py.py:7670
def AndThen(ts, ks)
Definition: z3py.py:7651

◆ to_symbol()

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

Definition at line 105 of file z3py.py.

Referenced by Fixedpoint.add_rule(), Optimize.add_soft(), Const(), DeclareSort(), FiniteDomainSort(), Function(), prove(), RecFunction(), Fixedpoint.set_predicate_representation(), SolverFor(), and Fixedpoint.update_rule().

105 def to_symbol(s, ctx=None):
106  """Convert an integer or string into a Z3 symbol."""
107  if _is_int(s):
108  return Z3_mk_int_symbol(_get_ctx(ctx).ref(), s)
109  else:
110  return Z3_mk_string_symbol(_get_ctx(ctx).ref(), s)
111 
Z3_symbol Z3_API Z3_mk_string_symbol(Z3_context c, Z3_string s)
Create a Z3 symbol using a C string.
def to_symbol(s, ctx=None)
Definition: z3py.py:105
Z3_symbol Z3_API Z3_mk_int_symbol(Z3_context c, int i)
Create a Z3 symbol using an integer.

◆ 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 3099 of file z3py.py.

Referenced by is_to_int().

3099 def ToInt(a):
3100  """ Return the Z3 expression ToInt(a).
3101 
3102  >>> x = Real('x')
3103  >>> x.sort()
3104  Real
3105  >>> n = ToInt(x)
3106  >>> n
3107  ToInt(x)
3108  >>> n.sort()
3109  Int
3110  """
3111  if __debug__:
3112  _z3_assert(a.is_real(), "Z3 real expression expected.")
3113  ctx = a.ctx
3114  return ArithRef(Z3_mk_real2int(ctx.ref(), a.as_ast()), ctx)
3115 
Z3_ast Z3_API Z3_mk_real2int(Z3_context c, Z3_ast t1)
Coerce a real to an integer.
def ToInt(a)
Definition: z3py.py:3099

◆ 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 3082 of file z3py.py.

Referenced by ArithRef.__ge__(), ArithRef.__gt__(), ArithRef.__le__(), ArithRef.__lt__(), and is_to_real().

3082 def ToReal(a):
3083  """ Return the Z3 expression ToReal(a).
3084 
3085  >>> x = Int('x')
3086  >>> x.sort()
3087  Int
3088  >>> n = ToReal(x)
3089  >>> n
3090  ToReal(x)
3091  >>> n.sort()
3092  Real
3093  """
3094  if __debug__:
3095  _z3_assert(a.is_int(), "Z3 integer expression expected.")
3096  ctx = a.ctx
3097  return ArithRef(Z3_mk_int2real(ctx.ref(), a.as_ast()), ctx)
3098 
Z3_ast Z3_API Z3_mk_int2real(Z3_context c, Z3_ast t1)
Coerce an integer to a real.
def ToReal(a)
Definition: z3py.py:3082

◆ 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 7783 of file z3py.py.

7783 def TryFor(t, ms, ctx=None):
7784  """Return a tactic that applies `t` to a given goal for `ms` milliseconds.
7785 
7786  If `t` does not terminate in `ms` milliseconds, then it fails.
7787  """
7788  t = _to_tactic(t, ctx)
7789  return Tactic(Z3_tactic_try_for(t.ctx.ref(), t.tactic, ms), t.ctx)
7790 
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...
def TryFor(t, ms, ctx=None)
Definition: z3py.py:7783

◆ 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 3925 of file z3py.py.

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

3925 def UDiv(a, b):
3926  """Create the Z3 expression (unsigned) division `self / other`.
3927 
3928  Use the operator / for signed division.
3929 
3930  >>> x = BitVec('x', 32)
3931  >>> y = BitVec('y', 32)
3932  >>> UDiv(x, y)
3933  UDiv(x, y)
3934  >>> UDiv(x, y).sort()
3935  BitVec(32)
3936  >>> (x / y).sexpr()
3937  '(bvsdiv x y)'
3938  >>> UDiv(x, y).sexpr()
3939  '(bvudiv x y)'
3940  """
3941  _check_bv_args(a, b)
3942  a, b = _coerce_exprs(a, b)
3943  return BitVecRef(Z3_mk_bvudiv(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3944 
Z3_ast Z3_API Z3_mk_bvudiv(Z3_context c, Z3_ast t1, Z3_ast t2)
Unsigned division.
def UDiv(a, b)
Definition: z3py.py:3925

◆ 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 3891 of file z3py.py.

Referenced by BitVecRef.__ge__().

3891 def UGE(a, b):
3892  """Create the Z3 expression (unsigned) `other >= self`.
3893 
3894  Use the operator >= for signed greater than or equal to.
3895 
3896  >>> x, y = BitVecs('x y', 32)
3897  >>> UGE(x, y)
3898  UGE(x, y)
3899  >>> (x >= y).sexpr()
3900  '(bvsge x y)'
3901  >>> UGE(x, y).sexpr()
3902  '(bvuge x y)'
3903  """
3904  _check_bv_args(a, b)
3905  a, b = _coerce_exprs(a, b)
3906  return BoolRef(Z3_mk_bvuge(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3907 
Z3_ast Z3_API Z3_mk_bvuge(Z3_context c, Z3_ast t1, Z3_ast t2)
Unsigned greater than or equal to.
def UGE(a, b)
Definition: z3py.py:3891

◆ 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 3908 of file z3py.py.

Referenced by BitVecRef.__gt__().

3908 def UGT(a, b):
3909  """Create the Z3 expression (unsigned) `other > self`.
3910 
3911  Use the operator > for signed greater than.
3912 
3913  >>> x, y = BitVecs('x y', 32)
3914  >>> UGT(x, y)
3915  UGT(x, y)
3916  >>> (x > y).sexpr()
3917  '(bvsgt x y)'
3918  >>> UGT(x, y).sexpr()
3919  '(bvugt x y)'
3920  """
3921  _check_bv_args(a, b)
3922  a, b = _coerce_exprs(a, b)
3923  return BoolRef(Z3_mk_bvugt(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3924 
Z3_ast Z3_API Z3_mk_bvugt(Z3_context c, Z3_ast t1, Z3_ast t2)
Unsigned greater than.
def UGT(a, b)
Definition: z3py.py:3908

◆ 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 3857 of file z3py.py.

Referenced by BitVecRef.__le__().

3857 def ULE(a, b):
3858  """Create the Z3 expression (unsigned) `other <= self`.
3859 
3860  Use the operator <= for signed less than or equal to.
3861 
3862  >>> x, y = BitVecs('x y', 32)
3863  >>> ULE(x, y)
3864  ULE(x, y)
3865  >>> (x <= y).sexpr()
3866  '(bvsle x y)'
3867  >>> ULE(x, y).sexpr()
3868  '(bvule x y)'
3869  """
3870  _check_bv_args(a, b)
3871  a, b = _coerce_exprs(a, b)
3872  return BoolRef(Z3_mk_bvule(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3873 
Z3_ast Z3_API Z3_mk_bvule(Z3_context c, Z3_ast t1, Z3_ast t2)
Unsigned less than or equal to.
def ULE(a, b)
Definition: z3py.py:3857

◆ 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 3874 of file z3py.py.

Referenced by BitVecRef.__lt__().

3874 def ULT(a, b):
3875  """Create the Z3 expression (unsigned) `other < self`.
3876 
3877  Use the operator < for signed less than.
3878 
3879  >>> x, y = BitVecs('x y', 32)
3880  >>> ULT(x, y)
3881  ULT(x, y)
3882  >>> (x < y).sexpr()
3883  '(bvslt x y)'
3884  >>> ULT(x, y).sexpr()
3885  '(bvult x y)'
3886  """
3887  _check_bv_args(a, b)
3888  a, b = _coerce_exprs(a, b)
3889  return BoolRef(Z3_mk_bvult(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3890 
def ULT(a, b)
Definition: z3py.py:3874
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 10196 of file z3py.py.

Referenced by InRe().

10196 def Union(*args):
10197  """Create union of regular expressions.
10198  >>> re = Union(Re("a"), Re("b"), Re("c"))
10199  >>> print (simplify(InRe("d", re)))
10200  False
10201  """
10202  args = _get_args(args)
10203  sz = len(args)
10204  if __debug__:
10205  _z3_assert(sz > 0, "At least one argument expected.")
10206  _z3_assert(all([is_re(a) for a in args]), "All arguments must be regular expressions.")
10207  if sz == 1:
10208  return args[0]
10209  ctx = args[0].ctx
10210  v = (Ast * sz)()
10211  for i in range(sz):
10212  v[i] = args[i].as_ast()
10213  return ReRef(Z3_mk_re_union(ctx.ref(), sz, v), ctx)
10214 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3244
def Union(args)
Definition: z3py.py:10196
def is_re(s)
Definition: z3py.py:10179
Z3_ast Z3_API Z3_mk_re_union(Z3_context c, unsigned n, Z3_ast const args[])
Create the union of the regular languages.

◆ Unit()

def z3py.Unit (   a)
Create a singleton sequence

Definition at line 10028 of file z3py.py.

Referenced by is_seq(), Re(), and SeqSort().

10028 def Unit(a):
10029  """Create a singleton sequence"""
10030  return SeqRef(Z3_mk_seq_unit(a.ctx_ref(), a.as_ast()), a.ctx)
10031 
def Unit(a)
Definition: z3py.py:10028
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 4385 of file z3py.py.

4385 def Update(a, i, v):
4386  """Return a Z3 store array expression.
4387 
4388  >>> a = Array('a', IntSort(), IntSort())
4389  >>> i, v = Ints('i v')
4390  >>> s = Update(a, i, v)
4391  >>> s.sort()
4392  Array(Int, Int)
4393  >>> prove(s[i] == v)
4394  proved
4395  >>> j = Int('j')
4396  >>> prove(Implies(i != j, s[j] == a[j]))
4397  proved
4398  """
4399  if __debug__:
4400  _z3_assert(is_array(a), "First argument must be a Z3 array expression")
4401  i = a.domain().cast(i)
4402  v = a.range().cast(v)
4403  ctx = a.ctx
4404  return _to_expr_ref(Z3_mk_store(ctx.ref(), a.as_ast(), i.as_ast(), v.as_ast()), ctx)
4405 
Z3_ast Z3_API Z3_mk_store(Z3_context c, Z3_ast a, Z3_ast i, Z3_ast v)
Array update.
def is_array(a)
Definition: z3py.py:4263
def Update(a, i, v)
Definition: z3py.py:4385

◆ 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 3945 of file z3py.py.

Referenced by BitVecRef.__mod__(), BitVecRef.__rmod__(), and SRem().

3945 def URem(a, b):
3946  """Create the Z3 expression (unsigned) remainder `self % other`.
3947 
3948  Use the operator % for signed modulus, and SRem() for signed remainder.
3949 
3950  >>> x = BitVec('x', 32)
3951  >>> y = BitVec('y', 32)
3952  >>> URem(x, y)
3953  URem(x, y)
3954  >>> URem(x, y).sort()
3955  BitVec(32)
3956  >>> (x % y).sexpr()
3957  '(bvsmod x y)'
3958  >>> URem(x, y).sexpr()
3959  '(bvurem x y)'
3960  """
3961  _check_bv_args(a, b)
3962  a, b = _coerce_exprs(a, b)
3963  return BitVecRef(Z3_mk_bvurem(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3964 
def URem(a, b)
Definition: z3py.py:3945
Z3_ast Z3_API Z3_mk_bvurem(Z3_context c, Z3_ast t1, Z3_ast t2)
Unsigned remainder.

◆ 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 1310 of file z3py.py.

Referenced by QuantifierRef.body(), QuantifierRef.children(), is_pattern(), MultiPattern(), QuantifierRef.pattern(), and RealVar().

1310 def Var(idx, s):
1311  """Create a Z3 free variable. Free variables are used to create quantified formulas.
1312 
1313  >>> Var(0, IntSort())
1314  Var(0)
1315  >>> eq(Var(0, IntSort()), Var(0, BoolSort()))
1316  False
1317  """
1318  if __debug__:
1319  _z3_assert(is_sort(s), "Z3 sort expected")
1320  return _to_expr_ref(Z3_mk_bound(s.ctx_ref(), idx, s.ast), s.ctx)
1321 
Z3_ast Z3_API Z3_mk_bound(Z3_context c, unsigned index, Z3_sort ty)
Create a bound variable.
def Var(idx, s)
Definition: z3py.py:1310
def is_sort(s)
Definition: z3py.py:579

◆ 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 8052 of file z3py.py.

8052 def When(p, t, ctx=None):
8053  """Return a tactic that applies tactic `t` only if probe `p` evaluates to true. Otherwise, it returns the input goal unmodified.
8054 
8055  >>> t = When(Probe('size') > 2, Tactic('simplify'))
8056  >>> x, y = Ints('x y')
8057  >>> g = Goal()
8058  >>> g.add(x > 0)
8059  >>> g.add(y > 0)
8060  >>> t(g)
8061  [[x > 0, y > 0]]
8062  >>> g.add(x == y + 1)
8063  >>> t(g)
8064  [[Not(x <= 0), Not(y <= 0), x == 1 + y]]
8065  """
8066  p = _to_probe(p, ctx)
8067  t = _to_tactic(t, ctx)
8068  return Tactic(Z3_tactic_when(t.ctx.ref(), p.probe, t.tactic), t.ctx)
8069 
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...
def When(p, t, ctx=None)
Definition: z3py.py:8052

◆ 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 7738 of file z3py.py.

Referenced by Goal.prec().

7738 def With(t, *args, **keys):
7739  """Return a tactic that applies tactic `t` using the given configuration options.
7740 
7741  >>> x, y = Ints('x y')
7742  >>> t = With(Tactic('simplify'), som=True)
7743  >>> t((x + 1)*(y + 2) == 0)
7744  [[2*x + y + x*y == -2]]
7745  """
7746  ctx = keys.pop('ctx', None)
7747  t = _to_tactic(t, ctx)
7748  p = args2params(args, keys, t.ctx)
7749  return Tactic(Z3_tactic_using_params(t.ctx.ref(), t.tactic, p.params), t.ctx)
7750 
def args2params(arguments, keywords, ctx=None)
Definition: z3py.py:5007
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.
def With(t, args, keys)
Definition: z3py.py:7738

◆ 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 7751 of file z3py.py.

7751 def WithParams(t, p):
7752  """Return a tactic that applies tactic `t` using the given configuration options.
7753 
7754  >>> x, y = Ints('x y')
7755  >>> p = ParamsRef()
7756  >>> p.set("som", True)
7757  >>> t = WithParams(Tactic('simplify'), p)
7758  >>> t((x + 1)*(y + 2) == 0)
7759  [[2*x + y + x*y == -2]]
7760  """
7761  t = _to_tactic(t, None)
7762  return Tactic(Z3_tactic_using_params(t.ctx.ref(), t.tactic, p.params), t.ctx)
7763 
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.
def WithParams(t, p)
Definition: z3py.py:7751

◆ 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 1615 of file z3py.py.

1615 def Xor(a, b, ctx=None):
1616  """Create a Z3 Xor expression.
1617 
1618  >>> p, q = Bools('p q')
1619  >>> Xor(p, q)
1620  Xor(p, q)
1621  >>> simplify(Xor(p, q))
1622  Not(p) == q
1623  """
1624  ctx = _get_ctx(_ctx_from_ast_arg_list([a, b], ctx))
1625  s = BoolSort(ctx)
1626  a = s.cast(a)
1627  b = s.cast(b)
1628  return BoolRef(Z3_mk_xor(ctx.ref(), a.as_ast(), b.as_ast()), ctx)
1629 
Z3_ast Z3_API Z3_mk_xor(Z3_context c, Z3_ast t1, Z3_ast t2)
Create an AST node representing t1 xor t2.
def Xor(a, b, ctx=None)
Definition: z3py.py:1615
def BoolSort(ctx=None)
Definition: z3py.py:1512

◆ z3_error_handler()

def z3py.z3_error_handler (   c,
  e 
)

Definition at line 152 of file z3py.py.

152 def z3_error_handler(c, e):
153  # Do nothing error handler, just avoid exit(0)
154  # The wrappers in z3core.py will raise a Z3Exception if an error is detected
155  return
156 
def z3_error_handler(c, e)
Definition: z3py.py:152

◆ 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 4075 of file z3py.py.

4075 def ZeroExt(n, a):
4076  """Return a bit-vector expression with `n` extra zero-bits.
4077 
4078  >>> x = BitVec('x', 16)
4079  >>> n = ZeroExt(8, x)
4080  >>> n.size()
4081  24
4082  >>> n
4083  ZeroExt(8, x)
4084  >>> n.sort()
4085  BitVec(24)
4086  >>> v0 = BitVecVal(2, 2)
4087  >>> v0
4088  2
4089  >>> v0.size()
4090  2
4091  >>> v = simplify(ZeroExt(6, v0))
4092  >>> v
4093  2
4094  >>> v.size()
4095  8
4096  """
4097  if __debug__:
4098  _z3_assert(_is_int(n), "First argument must be an integer")
4099  _z3_assert(is_bv(a), "Second argument must be a Z3 Bitvector expression")
4100  return BitVecRef(Z3_mk_zero_ext(a.ctx_ref(), n, a.as_ast()), a.ctx)
4101 
def ZeroExt(n, a)
Definition: z3py.py:4075
def is_bv(a)
Definition: z3py.py:3655
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 6362 of file z3py.py.

◆ unknown

Definition at line 6364 of file z3py.py.

◆ unsat

Definition at line 6363 of file z3py.py.