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 z3_debug ()
 
def enable_trace (msg)
 
def disable_trace (msg)
 
def get_version_string ()
 
def get_version ()
 
def get_full_version ()
 
def open_log (fname)
 
def append_log (s)
 
def to_symbol (s, ctx=None)
 
def z3_error_handler (c, e)
 
def main_ctx ()
 
def 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 SetHasSize (a, k)
 
def is_select (a)
 
def is_store (a)
 
def SetSort (s)
 Sets. More...
 
def EmptySet (s)
 
def FullSet (s)
 
def SetUnion (args)
 
def SetIntersect (args)
 
def SetAdd (s, e)
 
def SetDel (s, e)
 
def SetComplement (s)
 
def SetDifference (a, b)
 
def IsMember (e, s)
 
def IsSubset (a, b)
 
def CreateDatatypes (ds)
 
def TupleSort (name, sorts, ctx=None)
 
def DisjointSum (name, sorts, ctx=None)
 
def EnumSort (name, values, ctx=None)
 
def args2params (arguments, keywords, ctx=None)
 
def Model (ctx=None)
 
def is_as_array (n)
 
def get_as_array_func (n)
 
def SolverFor (logic, ctx=None)
 
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 LastIndexOf (s, substr)
 
def Length (s)
 
def StrToInt (s)
 
def IntToStr (s)
 
def Re (s, ctx=None)
 
def ReSort (s)
 
def is_re (s)
 
def InRe (s, re)
 
def Union (args)
 
def Intersect (args)
 
def Plus (re)
 
def Option (re)
 
def Complement (re)
 
def Star (re)
 
def Loop (re, lo, hi=0)
 
def Range (lo, hi, ctx=None)
 
def PartialOrder (a, index)
 
def LinearOrder (a, index)
 
def TreeOrder (a, index)
 
def PiecewiseLinearOrder (a, index)
 
def TransitiveClosure (f)
 

Variables

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

Function Documentation

◆ And()

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

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

Definition at line 1672 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().

1672 def And(*args):
1673  """Create a Z3 and-expression or and-probe.
1674 
1675  >>> p, q, r = Bools('p q r')
1676  >>> And(p, q, r)
1677  And(p, q, r)
1678  >>> P = BoolVector('p', 5)
1679  >>> And(P)
1680  And(p__0, p__1, p__2, p__3, p__4)
1681  """
1682  last_arg = None
1683  if len(args) > 0:
1684  last_arg = args[len(args)-1]
1685  if isinstance(last_arg, Context):
1686  ctx = args[len(args)-1]
1687  args = args[:len(args)-1]
1688  elif len(args) == 1 and isinstance(args[0], AstVector):
1689  ctx = args[0].ctx
1690  args = [a for a in args[0]]
1691  else:
1692  ctx = main_ctx()
1693  args = _get_args(args)
1694  ctx_args = _ctx_from_ast_arg_list(args, ctx)
1695  if z3_debug():
1696  _z3_assert(ctx_args is None or ctx_args == ctx, "context mismatch")
1697  _z3_assert(ctx is not None, "At least one of the arguments must be a Z3 expression or probe")
1698  if _has_probe(args):
1699  return _probe_and(args, ctx)
1700  else:
1701  args = _coerce_expr_list(args, ctx)
1702  _args, sz = _to_ast_array(args)
1703  return BoolRef(Z3_mk_and(ctx.ref(), sz, _args), ctx)
1704 
def And(args)
Definition: z3py.py:1672
def main_ctx()
Definition: z3py.py:213
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].
def z3_debug()
Definition: z3py.py:58

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

Referenced by Then().

7714 def AndThen(*ts, **ks):
7715  """Return a tactic that applies the tactics in `*ts` in sequence.
7716 
7717  >>> x, y = Ints('x y')
7718  >>> t = AndThen(Tactic('simplify'), Tactic('solve-eqs'))
7719  >>> t(And(x == 0, y > x + 1))
7720  [[Not(y <= 1)]]
7721  >>> t(And(x == 0, y > x + 1)).as_expr()
7722  Not(y <= 1)
7723  """
7724  if z3_debug():
7725  _z3_assert(len(ts) >= 2, "At least two arguments expected")
7726  ctx = ks.get('ctx', None)
7727  num = len(ts)
7728  r = ts[0]
7729  for i in range(num - 1):
7730  r = _and_then(r, ts[i+1], ctx)
7731  return r
7732 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3358
def AndThen(ts, ks)
Definition: z3py.py:7714
def z3_debug()
Definition: z3py.py:58

◆ append_log()

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

Definition at line 107 of file z3py.py.

107 def append_log(s):
108  """Append user-defined string to interaction log. """
109  Z3_append_log(s)
110 
void Z3_API Z3_append_log(Z3_string string)
Append user-defined string to interaction log.
def append_log(s)
Definition: z3py.py:107

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

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

5050 def args2params(arguments, keywords, ctx=None):
5051  """Convert python arguments into a Z3_params object.
5052  A ':' is added to the keywords, and '_' is replaced with '-'
5053 
5054  >>> args2params(['model', True, 'relevancy', 2], {'elim_and' : True})
5055  (params model true relevancy 2 elim_and true)
5056  """
5057  if z3_debug():
5058  _z3_assert(len(arguments) % 2 == 0, "Argument list must have an even number of elements.")
5059  prev = None
5060  r = ParamsRef(ctx)
5061  for a in arguments:
5062  if prev is None:
5063  prev = a
5064  else:
5065  r.set(prev, a)
5066  prev = None
5067  for k in keywords:
5068  v = keywords[k]
5069  r.set(k, v)
5070  return r
5071 
def args2params(arguments, keywords, ctx=None)
Definition: z3py.py:5050
def z3_debug()
Definition: z3py.py:58

◆ 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 4383 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().

4383 def Array(name, dom, rng):
4384  """Return an array constant named `name` with the given domain and range sorts.
4385 
4386  >>> a = Array('a', IntSort(), IntSort())
4387  >>> a.sort()
4388  Array(Int, Int)
4389  >>> a[0]
4390  a[0]
4391  """
4392  s = ArraySort(dom, rng)
4393  ctx = s.ctx
4394  return ArrayRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), s.ast), ctx)
4395 
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:4351
def to_symbol(s, ctx=None)
Definition: z3py.py:111
def Array(name, dom, rng)
Definition: z3py.py:4383

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

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

4351 def ArraySort(*sig):
4352  """Return the Z3 array sort with the given domain and range sorts.
4353 
4354  >>> A = ArraySort(IntSort(), BoolSort())
4355  >>> A
4356  Array(Int, Bool)
4357  >>> A.domain()
4358  Int
4359  >>> A.range()
4360  Bool
4361  >>> AA = ArraySort(IntSort(), A)
4362  >>> AA
4363  Array(Int, Array(Int, Bool))
4364  """
4365  sig = _get_args(sig)
4366  if z3_debug():
4367  _z3_assert(len(sig) > 1, "At least two arguments expected")
4368  arity = len(sig) - 1
4369  r = sig[arity]
4370  d = sig[0]
4371  if z3_debug():
4372  for s in sig:
4373  _z3_assert(is_sort(s), "Z3 sort expected")
4374  _z3_assert(s.ctx == r.ctx, "Context mismatch")
4375  ctx = d.ctx
4376  if len(sig) == 2:
4377  return ArraySortRef(Z3_mk_array_sort(ctx.ref(), d.ast, r.ast), ctx)
4378  dom = (Sort * arity)()
4379  for i in range(arity):
4380  dom[i] = sig[i].ast
4381  return ArraySortRef(Z3_mk_array_sort_n(ctx.ref(), arity, dom, r.ast), ctx)
4382 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3358
def ArraySort(sig)
Definition: z3py.py:4351
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:586
def z3_debug()
Definition: z3py.py:58

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

8295 def AtLeast(*args):
8296  """Create an at-most Pseudo-Boolean k constraint.
8297 
8298  >>> a, b, c = Bools('a b c')
8299  >>> f = AtLeast(a, b, c, 2)
8300  """
8301  args = _get_args(args)
8302  if z3_debug():
8303  _z3_assert(len(args) > 1, "Non empty list of arguments expected")
8304  ctx = _ctx_from_ast_arg_list(args)
8305  if z3_debug():
8306  _z3_assert(ctx is not None, "At least one of the arguments must be a Z3 expression")
8307  args1 = _coerce_expr_list(args[:-1], ctx)
8308  k = args[-1]
8309  _args, sz = _to_ast_array(args1)
8310  return BoolRef(Z3_mk_atleast(ctx.ref(), sz, _args, k), ctx)
8311 
8312 
def AtLeast(args)
Definition: z3py.py:8295
def z3_debug()
Definition: z3py.py:58
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 8278 of file z3py.py.

8278 def AtMost(*args):
8279  """Create an at-most Pseudo-Boolean k constraint.
8280 
8281  >>> a, b, c = Bools('a b c')
8282  >>> f = AtMost(a, b, c, 2)
8283  """
8284  args = _get_args(args)
8285  if z3_debug():
8286  _z3_assert(len(args) > 1, "Non empty list of arguments expected")
8287  ctx = _ctx_from_ast_arg_list(args)
8288  if z3_debug():
8289  _z3_assert(ctx is not None, "At least one of the arguments must be a Z3 expression")
8290  args1 = _coerce_expr_list(args[:-1], ctx)
8291  k = args[-1]
8292  _args, sz = _to_ast_array(args1)
8293  return BoolRef(Z3_mk_atmost(ctx.ref(), sz, _args, k), ctx)
8294 
def AtMost(args)
Definition: z3py.py:8278
def z3_debug()
Definition: z3py.py:58
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 3753 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().

3753 def BitVec(name, bv, ctx=None):
3754  """Return a bit-vector constant named `name`. `bv` may be the number of bits of a bit-vector sort.
3755  If `ctx=None`, then the global context is used.
3756 
3757  >>> x = BitVec('x', 16)
3758  >>> is_bv(x)
3759  True
3760  >>> x.size()
3761  16
3762  >>> x.sort()
3763  BitVec(16)
3764  >>> word = BitVecSort(16)
3765  >>> x2 = BitVec('x', word)
3766  >>> eq(x, x2)
3767  True
3768  """
3769  if isinstance(bv, BitVecSortRef):
3770  ctx = bv.ctx
3771  else:
3772  ctx = _get_ctx(ctx)
3773  bv = BitVecSort(bv, ctx)
3774  return BitVecRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), bv.ast), ctx)
3775 
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:111
def BitVec(name, bv, ctx=None)
Definition: z3py.py:3753
def BitVecSort(sz, ctx=None)
Definition: z3py.py:3723

◆ 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 3776 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().

3776 def BitVecs(names, bv, ctx=None):
3777  """Return a tuple of bit-vector constants of size bv.
3778 
3779  >>> x, y, z = BitVecs('x y z', 16)
3780  >>> x.size()
3781  16
3782  >>> x.sort()
3783  BitVec(16)
3784  >>> Sum(x, y, z)
3785  0 + x + y + z
3786  >>> Product(x, y, z)
3787  1*x*y*z
3788  >>> simplify(Product(x, y, z))
3789  x*y*z
3790  """
3791  ctx = _get_ctx(ctx)
3792  if isinstance(names, str):
3793  names = names.split(" ")
3794  return [BitVec(name, bv, ctx) for name in names]
3795 
def BitVec(name, bv, ctx=None)
Definition: z3py.py:3753
def BitVecs(names, bv, ctx=None)
Definition: z3py.py:3776

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

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

3723 def BitVecSort(sz, ctx=None):
3724  """Return a Z3 bit-vector sort of the given size. If `ctx=None`, then the global context is used.
3725 
3726  >>> Byte = BitVecSort(8)
3727  >>> Word = BitVecSort(16)
3728  >>> Byte
3729  BitVec(8)
3730  >>> x = Const('x', Byte)
3731  >>> eq(x, BitVec('x', 8))
3732  True
3733  """
3734  ctx = _get_ctx(ctx)
3735  return BitVecSortRef(Z3_mk_bv_sort(ctx.ref(), sz), ctx)
3736 
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:3723

◆ 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 3737 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().

3737 def BitVecVal(val, bv, ctx=None):
3738  """Return a bit-vector value with the given number of bits. If `ctx=None`, then the global context is used.
3739 
3740  >>> v = BitVecVal(10, 32)
3741  >>> v
3742  10
3743  >>> print("0x%.8x" % v.as_long())
3744  0x0000000a
3745  """
3746  if is_bv_sort(bv):
3747  ctx = bv.ctx
3748  return BitVecNumRef(Z3_mk_numeral(ctx.ref(), _to_int_str(val), bv.ast), ctx)
3749  else:
3750  ctx = _get_ctx(ctx)
3751  return BitVecNumRef(Z3_mk_numeral(ctx.ref(), _to_int_str(val), BitVecSort(bv, ctx).ast), ctx)
3752 
def BitVecVal(val, bv, ctx=None)
Definition: z3py.py:3737
def is_bv_sort(s)
Definition: z3py.py:3205
def BitVecSort(sz, ctx=None)
Definition: z3py.py:3723
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 1558 of file z3py.py.

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

1558 def Bool(name, ctx=None):
1559  """Return a Boolean constant named `name`. If `ctx=None`, then the global context is used.
1560 
1561  >>> p = Bool('p')
1562  >>> q = Bool('q')
1563  >>> And(p, q)
1564  And(p, q)
1565  """
1566  ctx = _get_ctx(ctx)
1567  return BoolRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), BoolSort(ctx).ast), ctx)
1568 
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:111
def Bool(name, ctx=None)
Definition: z3py.py:1558
def BoolSort(ctx=None)
Definition: z3py.py:1523

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

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

1569 def Bools(names, ctx=None):
1570  """Return a tuple of Boolean constants.
1571 
1572  `names` is a single string containing all names separated by blank spaces.
1573  If `ctx=None`, then the global context is used.
1574 
1575  >>> p, q, r = Bools('p q r')
1576  >>> And(p, Or(q, r))
1577  And(p, Or(q, r))
1578  """
1579  ctx = _get_ctx(ctx)
1580  if isinstance(names, str):
1581  names = names.split(" ")
1582  return [Bool(name, ctx) for name in names]
1583 
def Bools(names, ctx=None)
Definition: z3py.py:1569
def Bool(name, ctx=None)
Definition: z3py.py:1558

◆ 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 1523 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().

1523 def BoolSort(ctx=None):
1524  """Return the Boolean Z3 sort. If `ctx=None`, then the global context is used.
1525 
1526  >>> BoolSort()
1527  Bool
1528  >>> p = Const('p', BoolSort())
1529  >>> is_bool(p)
1530  True
1531  >>> r = Function('r', IntSort(), IntSort(), BoolSort())
1532  >>> r(0, 1)
1533  r(0, 1)
1534  >>> is_bool(r(0, 1))
1535  True
1536  """
1537  ctx = _get_ctx(ctx)
1538  return BoolSortRef(Z3_mk_bool_sort(ctx.ref()), ctx)
1539 
def is_bool(a)
Definition: z3py.py:1412
def BoolSort(ctx=None)
Definition: z3py.py:1523

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

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

1540 def BoolVal(val, ctx=None):
1541  """Return the Boolean value `True` or `False`. If `ctx=None`, then the global context is used.
1542 
1543  >>> BoolVal(True)
1544  True
1545  >>> is_true(BoolVal(True))
1546  True
1547  >>> is_true(True)
1548  False
1549  >>> is_false(BoolVal(False))
1550  True
1551  """
1552  ctx = _get_ctx(ctx)
1553  if val == False:
1554  return BoolRef(Z3_mk_false(ctx.ref()), ctx)
1555  else:
1556  return BoolRef(Z3_mk_true(ctx.ref()), ctx)
1557 
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:1540

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

Referenced by And(), and Or().

1584 def BoolVector(prefix, sz, ctx=None):
1585  """Return a list of Boolean constants of size `sz`.
1586 
1587  The constants are named using the given prefix.
1588  If `ctx=None`, then the global context is used.
1589 
1590  >>> P = BoolVector('p', 3)
1591  >>> P
1592  [p__0, p__1, p__2]
1593  >>> And(P)
1594  And(p__0, p__1, p__2)
1595  """
1596  return [ Bool('%s__%s' % (prefix, i)) for i in range(sz) ]
1597 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3358
def BoolVector(prefix, sz, ctx=None)
Definition: z3py.py:1584
def Bool(name, ctx=None)
Definition: z3py.py:1558

◆ BV2Int()

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

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

Definition at line 3693 of file z3py.py.

3693 def BV2Int(a, is_signed=False):
3694  """Return the Z3 expression BV2Int(a).
3695 
3696  >>> b = BitVec('b', 3)
3697  >>> BV2Int(b).sort()
3698  Int
3699  >>> x = Int('x')
3700  >>> x > BV2Int(b)
3701  x > BV2Int(b)
3702  >>> x > BV2Int(b, is_signed=False)
3703  x > BV2Int(b)
3704  >>> x > BV2Int(b, is_signed=True)
3705  x > If(b < 0, BV2Int(b) - 8, BV2Int(b))
3706  >>> solve(x > BV2Int(b), b == 1, x < 3)
3707  [x = 2, b = 1]
3708  """
3709  if z3_debug():
3710  _z3_assert(is_bv(a), "Z3 bit-vector expression expected")
3711  ctx = a.ctx
3712 
3713  return ArithRef(Z3_mk_bv2int(ctx.ref(), a.as_ast(), is_signed), ctx)
3714 
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 z3_debug()
Definition: z3py.py:58
def BV2Int(a, is_signed=False)
Definition: z3py.py:3693
def is_bv(a)
Definition: z3py.py:3666

◆ BVAddNoOverflow()

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

Definition at line 4148 of file z3py.py.

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

4154 def BVAddNoUnderflow(a, b):
4155  """A predicate the determines that signed bit-vector addition does not underflow"""
4156  _check_bv_args(a, b)
4157  a, b = _coerce_exprs(a, b)
4158  return BoolRef(Z3_mk_bvadd_no_underflow(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4159 
def BVAddNoUnderflow(a, b)
Definition: z3py.py:4154
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 4185 of file z3py.py.

4185 def BVMulNoOverflow(a, b, signed):
4186  """A predicate the determines that bit-vector multiplication does not overflow"""
4187  _check_bv_args(a, b)
4188  a, b = _coerce_exprs(a, b)
4189  return BoolRef(Z3_mk_bvmul_no_overflow(a.ctx_ref(), a.as_ast(), b.as_ast(), signed), a.ctx)
4190 
4191 
def BVMulNoOverflow(a, b, signed)
Definition: z3py.py:4185
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 4192 of file z3py.py.

4192 def BVMulNoUnderflow(a, b):
4193  """A predicate the determines that bit-vector signed multiplication does not underflow"""
4194  _check_bv_args(a, b)
4195  a, b = _coerce_exprs(a, b)
4196  return BoolRef(Z3_mk_bvmul_no_underflow(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4197 
4198 
4199 
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:4192

◆ BVRedAnd()

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

Definition at line 4136 of file z3py.py.

4136 def BVRedAnd(a):
4137  """Return the reduction-and expression of `a`."""
4138  if z3_debug():
4139  _z3_assert(is_bv(a), "First argument must be a Z3 Bitvector expression")
4140  return BitVecRef(Z3_mk_bvredand(a.ctx_ref(), a.as_ast()), a.ctx)
4141 
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:4136
def z3_debug()
Definition: z3py.py:58
def is_bv(a)
Definition: z3py.py:3666

◆ BVRedOr()

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

Definition at line 4142 of file z3py.py.

4142 def BVRedOr(a):
4143  """Return the reduction-or expression of `a`."""
4144  if z3_debug():
4145  _z3_assert(is_bv(a), "First argument must be a Z3 Bitvector expression")
4146  return BitVecRef(Z3_mk_bvredor(a.ctx_ref(), a.as_ast()), a.ctx)
4147 
def BVRedOr(a)
Definition: z3py.py:4142
def z3_debug()
Definition: z3py.py:58
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:3666

◆ BVSDivNoOverflow()

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

Definition at line 4173 of file z3py.py.

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

4179 def BVSNegNoOverflow(a):
4180  """A predicate the determines that bit-vector unary negation does not overflow"""
4181  if z3_debug():
4182  _z3_assert(is_bv(a), "Argument should be a bit-vector")
4183  return BoolRef(Z3_mk_bvneg_no_overflow(a.ctx_ref(), a.as_ast()), a.ctx)
4184 
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 z3_debug()
Definition: z3py.py:58
def BVSNegNoOverflow(a)
Definition: z3py.py:4179
def is_bv(a)
Definition: z3py.py:3666

◆ BVSubNoOverflow()

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

Definition at line 4160 of file z3py.py.

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

4167 def BVSubNoUnderflow(a, b, signed):
4168  """A predicate the determines that bit-vector subtraction does not underflow"""
4169  _check_bv_args(a, b)
4170  a, b = _coerce_exprs(a, b)
4171  return BoolRef(Z3_mk_bvsub_no_underflow(a.ctx_ref(), a.as_ast(), b.as_ast(), signed), a.ctx)
4172 
def BVSubNoUnderflow(a, b, signed)
Definition: z3py.py:4167
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 3155 of file z3py.py.

3155 def Cbrt(a, ctx=None):
3156  """ Return a Z3 expression which represents the cubic root of a.
3157 
3158  >>> x = Real('x')
3159  >>> Cbrt(x)
3160  x**(1/3)
3161  """
3162  if not is_expr(a):
3163  ctx = _get_ctx(ctx)
3164  a = RealVal(a, ctx)
3165  return a ** "1/3"
3166 
def Cbrt(a, ctx=None)
Definition: z3py.py:3155
def RealVal(val, ctx=None)
Definition: z3py.py:2948
def is_expr(a)
Definition: z3py.py:1105

◆ Complement()

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

Definition at line 10337 of file z3py.py.

10337 def Complement(re):
10338  """Create the complement regular expression."""
10339  return ReRef(Z3_mk_re_complement(re.ctx_ref(), re.as_ast()), re.ctx)
10340 
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:10337

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

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

3796 def Concat(*args):
3797  """Create a Z3 bit-vector concatenation expression.
3798 
3799  >>> v = BitVecVal(1, 4)
3800  >>> Concat(v, v+1, v)
3801  Concat(Concat(1, 1 + 1), 1)
3802  >>> simplify(Concat(v, v+1, v))
3803  289
3804  >>> print("%.3x" % simplify(Concat(v, v+1, v)).as_long())
3805  121
3806  """
3807  args = _get_args(args)
3808  sz = len(args)
3809  if z3_debug():
3810  _z3_assert(sz >= 2, "At least two arguments expected.")
3811 
3812  ctx = None
3813  for a in args:
3814  if is_expr(a):
3815  ctx = a.ctx
3816  break
3817  if is_seq(args[0]) or isinstance(args[0], str):
3818  args = [_coerce_seq(s, ctx) for s in args]
3819  if z3_debug():
3820  _z3_assert(all([is_seq(a) for a in args]), "All arguments must be sequence expressions.")
3821  v = (Ast * sz)()
3822  for i in range(sz):
3823  v[i] = args[i].as_ast()
3824  return SeqRef(Z3_mk_seq_concat(ctx.ref(), sz, v), ctx)
3825 
3826  if is_re(args[0]):
3827  if z3_debug():
3828  _z3_assert(all([is_re(a) for a in args]), "All arguments must be regular expressions.")
3829  v = (Ast * sz)()
3830  for i in range(sz):
3831  v[i] = args[i].as_ast()
3832  return ReRef(Z3_mk_re_concat(ctx.ref(), sz, v), ctx)
3833 
3834  if z3_debug():
3835  _z3_assert(all([is_bv(a) for a in args]), "All arguments must be Z3 bit-vector expressions.")
3836  r = args[0]
3837  for i in range(sz - 1):
3838  r = BitVecRef(Z3_mk_concat(ctx.ref(), r.as_ast(), args[i+1].as_ast()), ctx)
3839  return r
3840 
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:3358
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:10260
def z3_debug()
Definition: z3py.py:58
def is_expr(a)
Definition: z3py.py:1105
def is_bv(a)
Definition: z3py.py:3666
def Concat(args)
Definition: z3py.py:3796
def is_seq(a)
Definition: z3py.py:10012

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

Referenced by If().

8133 def Cond(p, t1, t2, ctx=None):
8134  """Return a tactic that applies tactic `t1` to a goal if probe `p` evaluates to true, and `t2` otherwise.
8135 
8136  >>> t = Cond(Probe('is-qfnra'), Tactic('qfnra'), Tactic('smt'))
8137  """
8138  p = _to_probe(p, ctx)
8139  t1 = _to_tactic(t1, ctx)
8140  t2 = _to_tactic(t2, ctx)
8141  return Tactic(Z3_tactic_cond(t1.ctx.ref(), p.probe, t1.tactic, t2.tactic), t1.ctx)
8142 
def Cond(p, t1, t2, ctx=None)
Definition: z3py.py:8133
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 1291 of file z3py.py.

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

1291 def Const(name, sort):
1292  """Create a constant of the given sort.
1293 
1294  >>> Const('x', IntSort())
1295  x
1296  """
1297  if z3_debug():
1298  _z3_assert(isinstance(sort, SortRef), "Z3 sort expected")
1299  ctx = sort.ctx
1300  return _to_expr_ref(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), sort.ast), ctx)
1301 
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:111
def Const(name, sort)
Definition: z3py.py:1291
def z3_debug()
Definition: z3py.py:58

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

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

1302 def Consts(names, sort):
1303  """Create a several constants of the given sort.
1304 
1305  `names` is a string containing the names of all constants to be created.
1306  Blank spaces separate the names of different constants.
1307 
1308  >>> x, y, z = Consts('x y z', IntSort())
1309  >>> x + y + z
1310  x + y + z
1311  """
1312  if isinstance(names, str):
1313  names = names.split(" ")
1314  return [Const(name, sort) for name in names]
1315 
def Consts(names, sort)
Definition: z3py.py:1302
def Const(name, sort)
Definition: z3py.py:1291

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

10131 def Contains(a, b):
10132  """Check if 'a' contains 'b'
10133  >>> s1 = Contains("abc", "ab")
10134  >>> simplify(s1)
10135  True
10136  >>> s2 = Contains("abc", "bc")
10137  >>> simplify(s2)
10138  True
10139  >>> x, y, z = Strings('x y z')
10140  >>> s3 = Contains(Concat(x,y,z), y)
10141  >>> simplify(s3)
10142  True
10143  """
10144  ctx = _get_ctx2(a, b)
10145  a = _coerce_seq(a, ctx)
10146  b = _coerce_seq(b, ctx)
10147  return BoolRef(Z3_mk_seq_contains(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
10148 
10149 
def Contains(a, b)
Definition: z3py.py:10131
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 4762 of file z3py.py.

Referenced by Datatype.create().

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

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

627 def DeclareSort(name, ctx=None):
628  """Create a new uninterpreted sort named `name`.
629 
630  If `ctx=None`, then the new sort is declared in the global Z3Py context.
631 
632  >>> A = DeclareSort('A')
633  >>> a = Const('a', A)
634  >>> b = Const('b', A)
635  >>> a.sort() == A
636  True
637  >>> b.sort() == A
638  True
639  >>> a == b
640  a == b
641  """
642  ctx = _get_ctx(ctx)
643  return SortRef(Z3_mk_uninterpreted_sort(ctx.ref(), to_symbol(name, ctx)), ctx)
644 
def to_symbol(s, ctx=None)
Definition: z3py.py:111
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:627

◆ Default()

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

Definition at line 4417 of file z3py.py.

Referenced by is_default().

4417 def Default(a):
4418  """ Return a default value for array expression.
4419  >>> b = K(IntSort(), 1)
4420  >>> prove(Default(b) == 1)
4421  proved
4422  """
4423  if z3_debug():
4424  _z3_assert(is_array(a), "First argument must be a Z3 array expression")
4425  return a.default()
4426 
4427 
def is_array(a)
Definition: z3py.py:4274
def Default(a)
Definition: z3py.py:4417
def z3_debug()
Definition: z3py.py:58

◆ describe_probes()

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

Definition at line 8063 of file z3py.py.

8063 def describe_probes():
8064  """Display a (tabular) description of all available probes in Z3."""
8065  if in_html_mode():
8066  even = True
8067  print('<table border="1" cellpadding="2" cellspacing="0">')
8068  for p in probes():
8069  if even:
8070  print('<tr style="background-color:#CFCFCF">')
8071  even = False
8072  else:
8073  print('<tr>')
8074  even = True
8075  print('<td>%s</td><td>%s</td></tr>' % (p, insert_line_breaks(probe_description(p), 40)))
8076  print('</table>')
8077  else:
8078  for p in probes():
8079  print('%s : %s' % (p, probe_description(p)))
8080 
def probes(ctx=None)
Definition: z3py.py:8045
def probe_description(name, ctx=None)
Definition: z3py.py:8055
def describe_probes()
Definition: z3py.py:8063

◆ describe_tactics()

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

Definition at line 7872 of file z3py.py.

7872 def describe_tactics():
7873  """Display a (tabular) description of all available tactics in Z3."""
7874  if in_html_mode():
7875  even = True
7876  print('<table border="1" cellpadding="2" cellspacing="0">')
7877  for t in tactics():
7878  if even:
7879  print('<tr style="background-color:#CFCFCF">')
7880  even = False
7881  else:
7882  print('<tr>')
7883  even = True
7884  print('<td>%s</td><td>%s</td></tr>' % (t, insert_line_breaks(tactic_description(t), 40)))
7885  print('</table>')
7886  else:
7887  for t in tactics():
7888  print('%s : %s' % (t, tactic_description(t)))
7889 
def tactics(ctx=None)
Definition: z3py.py:7854
def tactic_description(name, ctx=None)
Definition: z3py.py:7864
def describe_tactics()
Definition: z3py.py:7872

◆ disable_trace()

def z3py.disable_trace (   msg)

Definition at line 72 of file z3py.py.

72 def disable_trace(msg):
73  Z3_disable_trace(msg)
74 
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:72

◆ DisjointSum()

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

Definition at line 4962 of file z3py.py.

4962 def DisjointSum(name, sorts, ctx=None):
4963  """Create a named tagged union sort base on a set of underlying sorts
4964  Example:
4965  >>> sum, ((inject0, extract0), (inject1, extract1)) = DisjointSum("+", [IntSort(), StringSort()])
4966  """
4967  sum = Datatype(name, ctx)
4968  for i in range(len(sorts)):
4969  sum.declare("inject%d" % i, ("project%d" % i, sorts[i]))
4970  sum = sum.create()
4971  return sum, [(sum.constructor(i), sum.accessor(i, 0)) for i in range(len(sorts))]
4972 
4973 
def DisjointSum(name, sorts, ctx=None)
Definition: z3py.py:4962
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3358

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

1260 def Distinct(*args):
1261  """Create a Z3 distinct expression.
1262 
1263  >>> x = Int('x')
1264  >>> y = Int('y')
1265  >>> Distinct(x, y)
1266  x != y
1267  >>> z = Int('z')
1268  >>> Distinct(x, y, z)
1269  Distinct(x, y, z)
1270  >>> simplify(Distinct(x, y, z))
1271  Distinct(x, y, z)
1272  >>> simplify(Distinct(x, y, z), blast_distinct=True)
1273  And(Not(x == y), Not(x == z), Not(y == z))
1274  """
1275  args = _get_args(args)
1276  ctx = _ctx_from_ast_arg_list(args)
1277  if z3_debug():
1278  _z3_assert(ctx is not None, "At least one of the arguments must be a Z3 expression")
1279  args = _coerce_expr_list(args, ctx)
1280  _args, sz = _to_ast_array(args)
1281  return BoolRef(Z3_mk_distinct(ctx.ref(), sz, _args), ctx)
1282 
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 z3_debug()
Definition: z3py.py:58
def Distinct(args)
Definition: z3py.py:1260

◆ Empty()

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

Definition at line 10066 of file z3py.py.

10066 def Empty(s):
10067  """Create the empty sequence of the given sort
10068  >>> e = Empty(StringSort())
10069  >>> e2 = StringVal("")
10070  >>> print(e.eq(e2))
10071  True
10072  >>> e3 = Empty(SeqSort(IntSort()))
10073  >>> print(e3)
10074  Empty(Seq(Int))
10075  >>> e4 = Empty(ReSort(SeqSort(IntSort())))
10076  >>> print(e4)
10077  Empty(ReSort(Seq(Int)))
10078  """
10079  if isinstance(s, SeqSortRef):
10080  return SeqRef(Z3_mk_seq_empty(s.ctx_ref(), s.ast), s.ctx)
10081  if isinstance(s, ReSortRef):
10082  return ReRef(Z3_mk_re_empty(s.ctx_ref(), s.ast), s.ctx)
10083  raise Z3Exception("Non-sequence, non-regular expression sort passed to Empty")
10084 
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:10066

◆ EmptySet()

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

Definition at line 4552 of file z3py.py.

4552 def EmptySet(s):
4553  """Create the empty set
4554  >>> EmptySet(IntSort())
4555  K(Int, False)
4556  """
4557  ctx = s.ctx
4558  return ArrayRef(Z3_mk_empty_set(ctx.ref(), s.ast), ctx)
4559 
Z3_ast Z3_API Z3_mk_empty_set(Z3_context c, Z3_sort domain)
Create the empty set.
def EmptySet(s)
Definition: z3py.py:4552

◆ enable_trace()

def z3py.enable_trace (   msg)

Definition at line 69 of file z3py.py.

69 def enable_trace(msg):
70  Z3_enable_trace(msg)
71 
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:69

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

Referenced by Context.mkEnumSort().

4974 def EnumSort(name, values, ctx=None):
4975  """Return a new enumeration sort named `name` containing the given values.
4976 
4977  The result is a pair (sort, list of constants).
4978  Example:
4979  >>> Color, (red, green, blue) = EnumSort('Color', ['red', 'green', 'blue'])
4980  """
4981  if z3_debug():
4982  _z3_assert(isinstance(name, str), "Name must be a string")
4983  _z3_assert(all([isinstance(v, str) for v in values]), "Eumeration sort values must be strings")
4984  _z3_assert(len(values) > 0, "At least one value expected")
4985  ctx = _get_ctx(ctx)
4986  num = len(values)
4987  _val_names = (Symbol * num)()
4988  for i in range(num):
4989  _val_names[i] = to_symbol(values[i])
4990  _values = (FuncDecl * num)()
4991  _testers = (FuncDecl * num)()
4992  name = to_symbol(name)
4993  S = DatatypeSortRef(Z3_mk_enumeration_sort(ctx.ref(), name, num, _val_names, _values, _testers), ctx)
4994  V = []
4995  for i in range(num):
4996  V.append(FuncDeclRef(_values[i], ctx))
4997  V = [a() for a in V]
4998  return S, V
4999 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3358
def to_symbol(s, ctx=None)
Definition: z3py.py:111
def z3_debug()
Definition: z3py.py:58
def EnumSort(name, values, ctx=None)
Definition: z3py.py:4974
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 422 of file z3py.py.

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

422 def eq(a, b):
423  """Return `True` if `a` and `b` are structurally identical AST nodes.
424 
425  >>> x = Int('x')
426  >>> y = Int('y')
427  >>> eq(x, y)
428  False
429  >>> eq(x + 1, x + 1)
430  True
431  >>> eq(x + 1, 1 + x)
432  False
433  >>> eq(simplify(x + 1), simplify(1 + x))
434  True
435  """
436  if z3_debug():
437  _z3_assert(is_ast(a) and is_ast(b), "Z3 ASTs expected")
438  return a.eq(b)
439 
def eq(a, b)
Definition: z3py.py:422
def z3_debug()
Definition: z3py.py:58
def is_ast(a)
Definition: z3py.py:402

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

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

2044 def Exists(vs, body, weight=1, qid="", skid="", patterns=[], no_patterns=[]):
2045  """Create a Z3 exists formula.
2046 
2047  The parameters `weight`, `qif`, `skid`, `patterns` and `no_patterns` are optional annotations.
2048 
2049 
2050  >>> f = Function('f', IntSort(), IntSort(), IntSort())
2051  >>> x = Int('x')
2052  >>> y = Int('y')
2053  >>> q = Exists([x, y], f(x, y) >= x, skid="foo")
2054  >>> q
2055  Exists([x, y], f(x, y) >= x)
2056  >>> is_quantifier(q)
2057  True
2058  >>> r = Tactic('nnf')(q).as_expr()
2059  >>> is_quantifier(r)
2060  False
2061  """
2062  return _mk_quantifier(False, vs, body, weight, qid, skid, patterns, no_patterns)
2063 
def Exists(vs, body, weight=1, qid="", skid="", patterns=[], no_patterns=[])
Definition: z3py.py:2044

◆ Ext()

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

Definition at line 4502 of file z3py.py.

4502 def Ext(a, b):
4503  """Return extensionality index for one-dimensional arrays.
4504  >> a, b = Consts('a b', SetSort(IntSort()))
4505  >> Ext(a, b)
4506  Ext(a, b)
4507  """
4508  ctx = a.ctx
4509  if z3_debug():
4510  _z3_assert(is_array(a) and is_array(b), "arguments must be arrays")
4511  return _to_expr_ref(Z3_mk_array_ext(ctx.ref(), a.as_ast(), b.as_ast()), ctx)
4512 
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:4274
def z3_debug()
Definition: z3py.py:58
def Ext(a, b)
Definition: z3py.py:4502

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

3841 def Extract(high, low, a):
3842  """Create a Z3 bit-vector extraction expression, or create a string extraction expression.
3843 
3844  >>> x = BitVec('x', 8)
3845  >>> Extract(6, 2, x)
3846  Extract(6, 2, x)
3847  >>> Extract(6, 2, x).sort()
3848  BitVec(5)
3849  >>> simplify(Extract(StringVal("abcd"),2,1))
3850  "c"
3851  """
3852  if isinstance(high, str):
3853  high = StringVal(high)
3854  if is_seq(high):
3855  s = high
3856  offset, length = _coerce_exprs(low, a, s.ctx)
3857  return SeqRef(Z3_mk_seq_extract(s.ctx_ref(), s.as_ast(), offset.as_ast(), length.as_ast()), s.ctx)
3858  if z3_debug():
3859  _z3_assert(low <= high, "First argument must be greater than or equal to second argument")
3860  _z3_assert(_is_int(high) and high >= 0 and _is_int(low) and low >= 0, "First and second arguments must be non negative integers")
3861  _z3_assert(is_bv(a), "Third argument must be a Z3 Bitvector expression")
3862  return BitVecRef(Z3_mk_extract(a.ctx_ref(), high, low, a.as_ast()), a.ctx)
3863 
def Extract(high, low, a)
Definition: z3py.py:3841
def StringVal(s, ctx=None)
Definition: z3py.py:10038
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.
def z3_debug()
Definition: z3py.py:58
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:3666
def is_seq(a)
Definition: z3py.py:10012

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

8096 def FailIf(p, ctx=None):
8097  """Return a tactic that fails if the probe `p` evaluates to true. Otherwise, it returns the input goal unmodified.
8098 
8099  In the following example, the tactic applies 'simplify' if and only if there are more than 2 constraints in the goal.
8100 
8101  >>> t = OrElse(FailIf(Probe('size') > 2), Tactic('simplify'))
8102  >>> x, y = Ints('x y')
8103  >>> g = Goal()
8104  >>> g.add(x > 0)
8105  >>> g.add(y > 0)
8106  >>> t(g)
8107  [[x > 0, y > 0]]
8108  >>> g.add(x == y + 1)
8109  >>> t(g)
8110  [[Not(x <= 0), Not(y <= 0), x == 1 + y]]
8111  """
8112  p = _to_probe(p, ctx)
8113  return Tactic(Z3_tactic_fail_if(p.ctx.ref(), p.probe), p.ctx)
8114 
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:8096

◆ FiniteDomainSort()

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

Definition at line 7188 of file z3py.py.

Referenced by Context.mkFiniteDomainSort().

7188 def FiniteDomainSort(name, sz, ctx=None):
7189  """Create a named finite domain sort of a given size sz"""
7190  if not isinstance(name, Symbol):
7191  name = to_symbol(name)
7192  ctx = _get_ctx(ctx)
7193  return FiniteDomainSortRef(Z3_mk_finite_domain_sort(ctx.ref(), name, sz), ctx)
7194 
def to_symbol(s, ctx=None)
Definition: z3py.py:111
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:7188

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

7256 def FiniteDomainVal(val, sort, ctx=None):
7257  """Return a Z3 finite-domain value. If `ctx=None`, then the global context is used.
7258 
7259  >>> s = FiniteDomainSort('S', 256)
7260  >>> FiniteDomainVal(255, s)
7261  255
7262  >>> FiniteDomainVal('100', s)
7263  100
7264  """
7265  if z3_debug():
7266  _z3_assert(is_finite_domain_sort(sort), "Expected finite-domain sort" )
7267  ctx = sort.ctx
7268  return FiniteDomainNumRef(Z3_mk_numeral(ctx.ref(), _to_int_str(val), sort.ast), ctx)
7269 
def is_finite_domain_sort(s)
Definition: z3py.py:7195
def FiniteDomainVal(val, sort, ctx=None)
Definition: z3py.py:7256
def z3_debug()
Definition: z3py.py:58
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 8720 of file z3py.py.

8720 def Float128(ctx=None):
8721  """Floating-point 128-bit (quadruple) sort."""
8722  ctx = _get_ctx(ctx)
8723  return FPSortRef(Z3_mk_fpa_sort_128(ctx.ref()), ctx)
8724 
def Float128(ctx=None)
Definition: z3py.py:8720
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 8690 of file z3py.py.

8690 def Float16(ctx=None):
8691  """Floating-point 16-bit (half) sort."""
8692  ctx = _get_ctx(ctx)
8693  return FPSortRef(Z3_mk_fpa_sort_16(ctx.ref()), ctx)
8694 
def Float16(ctx=None)
Definition: z3py.py:8690
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 8700 of file z3py.py.

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

8700 def Float32(ctx=None):
8701  """Floating-point 32-bit (single) sort."""
8702  ctx = _get_ctx(ctx)
8703  return FPSortRef(Z3_mk_fpa_sort_32(ctx.ref()), ctx)
8704 
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:8700

◆ Float64()

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

Definition at line 8710 of file z3py.py.

Referenced by fpFPToFP(), and fpToFP().

8710 def Float64(ctx=None):
8711  """Floating-point 64-bit (double) sort."""
8712  ctx = _get_ctx(ctx)
8713  return FPSortRef(Z3_mk_fpa_sort_64(ctx.ref()), ctx)
8714 
def Float64(ctx=None)
Definition: z3py.py:8710
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 8715 of file z3py.py.

8715 def FloatDouble(ctx=None):
8716  """Floating-point 64-bit (double) sort."""
8717  ctx = _get_ctx(ctx)
8718  return FPSortRef(Z3_mk_fpa_sort_double(ctx.ref()), ctx)
8719 
def FloatDouble(ctx=None)
Definition: z3py.py:8715
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 8695 of file z3py.py.

8695 def FloatHalf(ctx=None):
8696  """Floating-point 16-bit (half) sort."""
8697  ctx = _get_ctx(ctx)
8698  return FPSortRef(Z3_mk_fpa_sort_half(ctx.ref()), ctx)
8699 
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:8695

◆ FloatQuadruple()

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

Definition at line 8725 of file z3py.py.

8725 def FloatQuadruple(ctx=None):
8726  """Floating-point 128-bit (quadruple) sort."""
8727  ctx = _get_ctx(ctx)
8728  return FPSortRef(Z3_mk_fpa_sort_quadruple(ctx.ref()), ctx)
8729 
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:8725

◆ FloatSingle()

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

Definition at line 8705 of file z3py.py.

8705 def FloatSingle(ctx=None):
8706  """Floating-point 32-bit (single) sort."""
8707  ctx = _get_ctx(ctx)
8708  return FPSortRef(Z3_mk_fpa_sort_single(ctx.ref()), ctx)
8709 
def FloatSingle(ctx=None)
Definition: z3py.py:8705
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 2027 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().

2027 def ForAll(vs, body, weight=1, qid="", skid="", patterns=[], no_patterns=[]):
2028  """Create a Z3 forall formula.
2029 
2030  The parameters `weight`, `qif`, `skid`, `patterns` and `no_patterns` are optional annotations.
2031 
2032  >>> f = Function('f', IntSort(), IntSort(), IntSort())
2033  >>> x = Int('x')
2034  >>> y = Int('y')
2035  >>> ForAll([x, y], f(x, y) >= x)
2036  ForAll([x, y], f(x, y) >= x)
2037  >>> ForAll([x, y], f(x, y) >= x, patterns=[ f(x, y) ])
2038  ForAll([x, y], f(x, y) >= x)
2039  >>> ForAll([x, y], f(x, y) >= x, weight=10)
2040  ForAll([x, y], f(x, y) >= x)
2041  """
2042  return _mk_quantifier(True, vs, body, weight, qid, skid, patterns, no_patterns)
2043 
def ForAll(vs, body, weight=1, qid="", skid="", patterns=[], no_patterns=[])
Definition: z3py.py:2027

◆ 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 9306 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().

9306 def FP(name, fpsort, ctx=None):
9307  """Return a floating-point constant named `name`.
9308  `fpsort` is the floating-point sort.
9309  If `ctx=None`, then the global context is used.
9310 
9311  >>> x = FP('x', FPSort(8, 24))
9312  >>> is_fp(x)
9313  True
9314  >>> x.ebits()
9315  8
9316  >>> x.sort()
9317  FPSort(8, 24)
9318  >>> word = FPSort(8, 24)
9319  >>> x2 = FP('x', word)
9320  >>> eq(x, x2)
9321  True
9322  """
9323  if isinstance(fpsort, FPSortRef) and ctx is None:
9324  ctx = fpsort.ctx
9325  else:
9326  ctx = _get_ctx(ctx)
9327  return FPRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), fpsort.ast), ctx)
9328 
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:111
def FP(name, fpsort, ctx=None)
Definition: z3py.py:9306

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

9347 def fpAbs(a, ctx=None):
9348  """Create a Z3 floating-point absolute value expression.
9349 
9350  >>> s = FPSort(8, 24)
9351  >>> rm = RNE()
9352  >>> x = FPVal(1.0, s)
9353  >>> fpAbs(x)
9354  fpAbs(1)
9355  >>> y = FPVal(-20.0, s)
9356  >>> y
9357  -1.25*(2**4)
9358  >>> fpAbs(y)
9359  fpAbs(-1.25*(2**4))
9360  >>> fpAbs(-1.25*(2**4))
9361  fpAbs(-1.25*(2**4))
9362  >>> fpAbs(x).sort()
9363  FPSort(8, 24)
9364  """
9365  ctx = _get_ctx(ctx)
9366  [a] = _coerce_fp_expr_list([a], ctx)
9367  return FPRef(Z3_mk_fpa_abs(ctx.ref(), a.as_ast()), ctx)
9368 
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:9347

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

Referenced by FPs().

9436 def fpAdd(rm, a, b, ctx=None):
9437  """Create a Z3 floating-point addition expression.
9438 
9439  >>> s = FPSort(8, 24)
9440  >>> rm = RNE()
9441  >>> x = FP('x', s)
9442  >>> y = FP('y', s)
9443  >>> fpAdd(rm, x, y)
9444  fpAdd(RNE(), x, y)
9445  >>> fpAdd(RTZ(), x, y) # default rounding mode is RTZ
9446  x + y
9447  >>> fpAdd(rm, x, y).sort()
9448  FPSort(8, 24)
9449  """
9450  return _mk_fp_bin(Z3_mk_fpa_add, rm, a, b, ctx)
9451 
def fpAdd(rm, a, b, ctx=None)
Definition: z3py.py:9436

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

9733 def fpBVToFP(v, sort, ctx=None):
9734  """Create a Z3 floating-point conversion expression that represents the
9735  conversion from a bit-vector term to a floating-point term.
9736 
9737  >>> x_bv = BitVecVal(0x3F800000, 32)
9738  >>> x_fp = fpBVToFP(x_bv, Float32())
9739  >>> x_fp
9740  fpToFP(1065353216)
9741  >>> simplify(x_fp)
9742  1
9743  """
9744  _z3_assert(is_bv(v), "First argument must be a Z3 floating-point rounding mode expression.")
9745  _z3_assert(is_fp_sort(sort), "Second argument must be a Z3 floating-point sort.")
9746  ctx = _get_ctx(ctx)
9747  return FPRef(Z3_mk_fpa_to_fp_bv(ctx.ref(), v.ast, sort.ast), ctx)
9748 
def fpBVToFP(v, sort, ctx=None)
Definition: z3py.py:9733
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:8734
def is_bv(a)
Definition: z3py.py:3666

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

9480 def fpDiv(rm, a, b, ctx=None):
9481  """Create a Z3 floating-point division expression.
9482 
9483  >>> s = FPSort(8, 24)
9484  >>> rm = RNE()
9485  >>> x = FP('x', s)
9486  >>> y = FP('y', s)
9487  >>> fpDiv(rm, x, y)
9488  fpDiv(RNE(), x, y)
9489  >>> fpDiv(rm, x, y).sort()
9490  FPSort(8, 24)
9491  """
9492  return _mk_fp_bin(Z3_mk_fpa_div, rm, a, b, ctx)
9493 
def fpDiv(rm, a, b, ctx=None)
Definition: z3py.py:9480

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

Referenced by fpFP(), and fpNEQ().

9645 def fpEQ(a, b, ctx=None):
9646  """Create the Z3 floating-point expression `fpEQ(other, self)`.
9647 
9648  >>> x, y = FPs('x y', FPSort(8, 24))
9649  >>> fpEQ(x, y)
9650  fpEQ(x, y)
9651  >>> fpEQ(x, y).sexpr()
9652  '(fp.eq x y)'
9653  """
9654  return _mk_fp_bin_pred(Z3_mk_fpa_eq, a, b, ctx)
9655 
def fpEQ(a, b, ctx=None)
Definition: z3py.py:9645

◆ fpFMA()

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

Definition at line 9535 of file z3py.py.

9535 def fpFMA(rm, a, b, c, ctx=None):
9536  """Create a Z3 floating-point fused multiply-add expression.
9537  """
9538  return _mk_fp_tern(Z3_mk_fpa_fma, rm, a, b, c, ctx)
9539 
def fpFMA(rm, a, b, c, ctx=None)
Definition: z3py.py:9535

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

9667 def fpFP(sgn, exp, sig, ctx=None):
9668  """Create the Z3 floating-point value `fpFP(sgn, sig, exp)` from the three bit-vectors sgn, sig, and exp.
9669 
9670  >>> s = FPSort(8, 24)
9671  >>> x = fpFP(BitVecVal(1, 1), BitVecVal(2**7-1, 8), BitVecVal(2**22, 23))
9672  >>> print(x)
9673  fpFP(1, 127, 4194304)
9674  >>> xv = FPVal(-1.5, s)
9675  >>> print(xv)
9676  -1.5
9677  >>> slvr = Solver()
9678  >>> slvr.add(fpEQ(x, xv))
9679  >>> slvr.check()
9680  sat
9681  >>> xv = FPVal(+1.5, s)
9682  >>> print(xv)
9683  1.5
9684  >>> slvr = Solver()
9685  >>> slvr.add(fpEQ(x, xv))
9686  >>> slvr.check()
9687  unsat
9688  """
9689  _z3_assert(is_bv(sgn) and is_bv(exp) and is_bv(sig), "sort mismatch")
9690  _z3_assert(sgn.sort().size() == 1, "sort mismatch")
9691  ctx = _get_ctx(ctx)
9692  _z3_assert(ctx == sgn.ctx == exp.ctx == sig.ctx, "context mismatch")
9693  return FPRef(Z3_mk_fpa_fp(ctx.ref(), sgn.ast, exp.ast, sig.ast), ctx)
9694 
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:9667
def is_bv(a)
Definition: z3py.py:3666

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

9749 def fpFPToFP(rm, v, sort, ctx=None):
9750  """Create a Z3 floating-point conversion expression that represents the
9751  conversion from a floating-point term to a floating-point term of different precision.
9752 
9753  >>> x_sgl = FPVal(1.0, Float32())
9754  >>> x_dbl = fpFPToFP(RNE(), x_sgl, Float64())
9755  >>> x_dbl
9756  fpToFP(RNE(), 1)
9757  >>> simplify(x_dbl)
9758  1
9759  >>> x_dbl.sort()
9760  FPSort(11, 53)
9761  """
9762  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression.")
9763  _z3_assert(is_fp(v), "Second argument must be a Z3 floating-point expression.")
9764  _z3_assert(is_fp_sort(sort), "Third argument must be a Z3 floating-point sort.")
9765  ctx = _get_ctx(ctx)
9766  return FPRef(Z3_mk_fpa_to_fp_float(ctx.ref(), rm.ast, v.ast, sort.ast), ctx)
9767 
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:8734
def fpFPToFP(rm, v, sort, ctx=None)
Definition: z3py.py:9749
def is_fprm(a)
Definition: z3py.py:8982
def is_fp(a)
Definition: z3py.py:9118

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

9634 def fpGEQ(a, b, ctx=None):
9635  """Create the Z3 floating-point expression `other >= self`.
9636 
9637  >>> x, y = FPs('x y', FPSort(8, 24))
9638  >>> fpGEQ(x, y)
9639  x >= y
9640  >>> (x >= y).sexpr()
9641  '(fp.geq x y)'
9642  """
9643  return _mk_fp_bin_pred(Z3_mk_fpa_geq, a, b, ctx)
9644 
def fpGEQ(a, b, ctx=None)
Definition: z3py.py:9634

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

9623 def fpGT(a, b, ctx=None):
9624  """Create the Z3 floating-point expression `other > self`.
9625 
9626  >>> x, y = FPs('x y', FPSort(8, 24))
9627  >>> fpGT(x, y)
9628  x > y
9629  >>> (x > y).sexpr()
9630  '(fp.gt x y)'
9631  """
9632  return _mk_fp_bin_pred(Z3_mk_fpa_gt, a, b, ctx)
9633 
def fpGT(a, b, ctx=None)
Definition: z3py.py:9623

◆ fpInfinity()

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

Definition at line 9240 of file z3py.py.

9240 def fpInfinity(s, negative):
9241  """Create a Z3 floating-point +oo or -oo term."""
9242  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
9243  _z3_assert(isinstance(negative, bool), "expected Boolean flag")
9244  return FPNumRef(Z3_mk_fpa_inf(s.ctx_ref(), s.ast, negative), s.ctx)
9245 
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:9240

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

9561 def fpIsInf(a, ctx=None):
9562  """Create a Z3 floating-point isInfinite expression.
9563 
9564  >>> s = FPSort(8, 24)
9565  >>> x = FP('x', s)
9566  >>> fpIsInf(x)
9567  fpIsInf(x)
9568  """
9569  return _mk_fp_unary_norm(Z3_mk_fpa_is_infinite, a, ctx)
9570 
def fpIsInf(a, ctx=None)
Definition: z3py.py:9561

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

9550 def fpIsNaN(a, ctx=None):
9551  """Create a Z3 floating-point isNaN expression.
9552 
9553  >>> s = FPSort(8, 24)
9554  >>> x = FP('x', s)
9555  >>> y = FP('y', s)
9556  >>> fpIsNaN(x)
9557  fpIsNaN(x)
9558  """
9559  return _mk_fp_unary_norm(Z3_mk_fpa_is_nan, a, ctx)
9560 
def fpIsNaN(a, ctx=None)
Definition: z3py.py:9550

◆ fpIsNegative()

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

Definition at line 9586 of file z3py.py.

9586 def fpIsNegative(a, ctx=None):
9587  """Create a Z3 floating-point isNegative expression.
9588  """
9589  return _mk_fp_unary_norm(Z3_mk_fpa_is_negative, a, ctx)
9590 
def fpIsNegative(a, ctx=None)
Definition: z3py.py:9586

◆ fpIsNormal()

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

Definition at line 9576 of file z3py.py.

9576 def fpIsNormal(a, ctx=None):
9577  """Create a Z3 floating-point isNormal expression.
9578  """
9579  return _mk_fp_unary_norm(Z3_mk_fpa_is_normal, a, ctx)
9580 
def fpIsNormal(a, ctx=None)
Definition: z3py.py:9576

◆ fpIsPositive()

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

Definition at line 9591 of file z3py.py.

9591 def fpIsPositive(a, ctx=None):
9592  """Create a Z3 floating-point isPositive expression.
9593  """
9594  return _mk_fp_unary_norm(Z3_mk_fpa_is_positive, a, ctx)
9595  return FPRef(Z3_mk_fpa_is_positive(a.ctx_ref(), a.as_ast()), a.ctx)
9596 
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:9591

◆ fpIsSubnormal()

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

Definition at line 9581 of file z3py.py.

9581 def fpIsSubnormal(a, ctx=None):
9582  """Create a Z3 floating-point isSubnormal expression.
9583  """
9584  return _mk_fp_unary_norm(Z3_mk_fpa_is_subnormal, a, ctx)
9585 
def fpIsSubnormal(a, ctx=None)
Definition: z3py.py:9581

◆ fpIsZero()

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

Definition at line 9571 of file z3py.py.

9571 def fpIsZero(a, ctx=None):
9572  """Create a Z3 floating-point isZero expression.
9573  """
9574  return _mk_fp_unary_norm(Z3_mk_fpa_is_zero, a, ctx)
9575 
def fpIsZero(a, ctx=None)
Definition: z3py.py:9571

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

9612 def fpLEQ(a, b, ctx=None):
9613  """Create the Z3 floating-point expression `other <= self`.
9614 
9615  >>> x, y = FPs('x y', FPSort(8, 24))
9616  >>> fpLEQ(x, y)
9617  x <= y
9618  >>> (x <= y).sexpr()
9619  '(fp.leq x y)'
9620  """
9621  return _mk_fp_bin_pred(Z3_mk_fpa_leq, a, b, ctx)
9622 
def fpLEQ(a, b, ctx=None)
Definition: z3py.py:9612

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

9601 def fpLT(a, b, ctx=None):
9602  """Create the Z3 floating-point expression `other < self`.
9603 
9604  >>> x, y = FPs('x y', FPSort(8, 24))
9605  >>> fpLT(x, y)
9606  x < y
9607  >>> (x < y).sexpr()
9608  '(fp.lt x y)'
9609  """
9610  return _mk_fp_bin_pred(Z3_mk_fpa_lt, a, b, ctx)
9611 
def fpLT(a, b, ctx=None)
Definition: z3py.py:9601

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

9521 def fpMax(a, b, ctx=None):
9522  """Create a Z3 floating-point maximum expression.
9523 
9524  >>> s = FPSort(8, 24)
9525  >>> rm = RNE()
9526  >>> x = FP('x', s)
9527  >>> y = FP('y', s)
9528  >>> fpMax(x, y)
9529  fpMax(x, y)
9530  >>> fpMax(x, y).sort()
9531  FPSort(8, 24)
9532  """
9533  return _mk_fp_bin_norm(Z3_mk_fpa_max, a, b, ctx)
9534 
def fpMax(a, b, ctx=None)
Definition: z3py.py:9521

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

9507 def fpMin(a, b, ctx=None):
9508  """Create a Z3 floating-point minimum expression.
9509 
9510  >>> s = FPSort(8, 24)
9511  >>> rm = RNE()
9512  >>> x = FP('x', s)
9513  >>> y = FP('y', s)
9514  >>> fpMin(x, y)
9515  fpMin(x, y)
9516  >>> fpMin(x, y).sort()
9517  FPSort(8, 24)
9518  """
9519  return _mk_fp_bin_norm(Z3_mk_fpa_min, a, b, ctx)
9520 
def fpMin(a, b, ctx=None)
Definition: z3py.py:9507

◆ fpMinusInfinity()

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

Definition at line 9235 of file z3py.py.

9235 def fpMinusInfinity(s):
9236  """Create a Z3 floating-point -oo term."""
9237  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
9238  return FPNumRef(Z3_mk_fpa_inf(s.ctx_ref(), s.ast, True), s.ctx)
9239 
def fpMinusInfinity(s)
Definition: z3py.py:9235
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 9251 of file z3py.py.

9251 def fpMinusZero(s):
9252  """Create a Z3 floating-point -0.0 term."""
9253  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
9254  return FPNumRef(Z3_mk_fpa_zero(s.ctx_ref(), s.ast, True), s.ctx)
9255 
def fpMinusZero(s)
Definition: z3py.py:9251
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 9466 of file z3py.py.

Referenced by FPs().

9466 def fpMul(rm, a, b, ctx=None):
9467  """Create a Z3 floating-point multiplication expression.
9468 
9469  >>> s = FPSort(8, 24)
9470  >>> rm = RNE()
9471  >>> x = FP('x', s)
9472  >>> y = FP('y', s)
9473  >>> fpMul(rm, x, y)
9474  fpMul(RNE(), x, y)
9475  >>> fpMul(rm, x, y).sort()
9476  FPSort(8, 24)
9477  """
9478  return _mk_fp_bin(Z3_mk_fpa_mul, rm, a, b, ctx)
9479 
def fpMul(rm, a, b, ctx=None)
Definition: z3py.py:9466

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

9203 def fpNaN(s):
9204  """Create a Z3 floating-point NaN term.
9205 
9206  >>> s = FPSort(8, 24)
9207  >>> set_fpa_pretty(True)
9208  >>> fpNaN(s)
9209  NaN
9210  >>> pb = get_fpa_pretty()
9211  >>> set_fpa_pretty(False)
9212  >>> fpNaN(s)
9213  fpNaN(FPSort(8, 24))
9214  >>> set_fpa_pretty(pb)
9215  """
9216  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
9217  return FPNumRef(Z3_mk_fpa_nan(s.ctx_ref(), s.ast), s.ctx)
9218 
def fpNaN(s)
Definition: z3py.py:9203
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 9369 of file z3py.py.

9369 def fpNeg(a, ctx=None):
9370  """Create a Z3 floating-point addition expression.
9371 
9372  >>> s = FPSort(8, 24)
9373  >>> rm = RNE()
9374  >>> x = FP('x', s)
9375  >>> fpNeg(x)
9376  -x
9377  >>> fpNeg(x).sort()
9378  FPSort(8, 24)
9379  """
9380  ctx = _get_ctx(ctx)
9381  [a] = _coerce_fp_expr_list([a], ctx)
9382  return FPRef(Z3_mk_fpa_neg(ctx.ref(), a.as_ast()), ctx)
9383 
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:9369

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

9656 def fpNEQ(a, b, ctx=None):
9657  """Create the Z3 floating-point expression `Not(fpEQ(other, self))`.
9658 
9659  >>> x, y = FPs('x y', FPSort(8, 24))
9660  >>> fpNEQ(x, y)
9661  Not(fpEQ(x, y))
9662  >>> (x != y).sexpr()
9663  '(distinct x y)'
9664  """
9665  return Not(fpEQ(a, b, ctx))
9666 
def fpEQ(a, b, ctx=None)
Definition: z3py.py:9645
def Not(a, ctx=None)
Definition: z3py.py:1641
def fpNEQ(a, b, ctx=None)
Definition: z3py.py:9656

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

9219 def fpPlusInfinity(s):
9220  """Create a Z3 floating-point +oo term.
9221 
9222  >>> s = FPSort(8, 24)
9223  >>> pb = get_fpa_pretty()
9224  >>> set_fpa_pretty(True)
9225  >>> fpPlusInfinity(s)
9226  +oo
9227  >>> set_fpa_pretty(False)
9228  >>> fpPlusInfinity(s)
9229  fpPlusInfinity(FPSort(8, 24))
9230  >>> set_fpa_pretty(pb)
9231  """
9232  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
9233  return FPNumRef(Z3_mk_fpa_inf(s.ctx_ref(), s.ast, False), s.ctx)
9234 
def fpPlusInfinity(s)
Definition: z3py.py:9219
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 9246 of file z3py.py.

9246 def fpPlusZero(s):
9247  """Create a Z3 floating-point +0.0 term."""
9248  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
9249  return FPNumRef(Z3_mk_fpa_zero(s.ctx_ref(), s.ast, False), s.ctx)
9250 
def fpPlusZero(s)
Definition: z3py.py:9246
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 9768 of file z3py.py.

9768 def fpRealToFP(rm, v, sort, ctx=None):
9769  """Create a Z3 floating-point conversion expression that represents the
9770  conversion from a real term to a floating-point term.
9771 
9772  >>> x_r = RealVal(1.5)
9773  >>> x_fp = fpRealToFP(RNE(), x_r, Float32())
9774  >>> x_fp
9775  fpToFP(RNE(), 3/2)
9776  >>> simplify(x_fp)
9777  1.5
9778  """
9779  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression.")
9780  _z3_assert(is_real(v), "Second argument must be a Z3 expression or real sort.")
9781  _z3_assert(is_fp_sort(sort), "Third argument must be a Z3 floating-point sort.")
9782  ctx = _get_ctx(ctx)
9783  return FPRef(Z3_mk_fpa_to_fp_real(ctx.ref(), rm.ast, v.ast, sort.ast), ctx)
9784 
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:2498
def is_fp_sort(s)
Definition: z3py.py:8734
def fpRealToFP(rm, v, sort, ctx=None)
Definition: z3py.py:9768
def is_fprm(a)
Definition: z3py.py:8982

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

9494 def fpRem(a, b, ctx=None):
9495  """Create a Z3 floating-point remainder expression.
9496 
9497  >>> s = FPSort(8, 24)
9498  >>> x = FP('x', s)
9499  >>> y = FP('y', s)
9500  >>> fpRem(x, y)
9501  fpRem(x, y)
9502  >>> fpRem(x, y).sort()
9503  FPSort(8, 24)
9504  """
9505  return _mk_fp_bin_norm(Z3_mk_fpa_rem, a, b, ctx)
9506 
def fpRem(a, b, ctx=None)
Definition: z3py.py:9494

◆ fpRoundToIntegral()

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

Definition at line 9545 of file z3py.py.

9545 def fpRoundToIntegral(rm, a, ctx=None):
9546  """Create a Z3 floating-point roundToIntegral expression.
9547  """
9548  return _mk_fp_unary(Z3_mk_fpa_round_to_integral, rm, a, ctx)
9549 
def fpRoundToIntegral(rm, a, ctx=None)
Definition: z3py.py:9545

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

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

9329 def FPs(names, fpsort, ctx=None):
9330  """Return an array of floating-point constants.
9331 
9332  >>> x, y, z = FPs('x y z', FPSort(8, 24))
9333  >>> x.sort()
9334  FPSort(8, 24)
9335  >>> x.sbits()
9336  24
9337  >>> x.ebits()
9338  8
9339  >>> fpMul(RNE(), fpAdd(RNE(), x, y), z)
9340  fpMul(RNE(), fpAdd(RNE(), x, y), z)
9341  """
9342  ctx = _get_ctx(ctx)
9343  if isinstance(names, str):
9344  names = names.split(" ")
9345  return [FP(name, fpsort, ctx) for name in names]
9346 
def FPs(names, fpsort, ctx=None)
Definition: z3py.py:9329
def FP(name, fpsort, ctx=None)
Definition: z3py.py:9306

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

9785 def fpSignedToFP(rm, v, sort, ctx=None):
9786  """Create a Z3 floating-point conversion expression that represents the
9787  conversion from a signed bit-vector term (encoding an integer) to a floating-point term.
9788 
9789  >>> x_signed = BitVecVal(-5, BitVecSort(32))
9790  >>> x_fp = fpSignedToFP(RNE(), x_signed, Float32())
9791  >>> x_fp
9792  fpToFP(RNE(), 4294967291)
9793  >>> simplify(x_fp)
9794  -1.25*(2**2)
9795  """
9796  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression.")
9797  _z3_assert(is_bv(v), "Second argument must be a Z3 expression or real sort.")
9798  _z3_assert(is_fp_sort(sort), "Third argument must be a Z3 floating-point sort.")
9799  ctx = _get_ctx(ctx)
9800  return FPRef(Z3_mk_fpa_to_fp_signed(ctx.ref(), rm.ast, v.ast, sort.ast), ctx)
9801 
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:9785
def is_fp_sort(s)
Definition: z3py.py:8734
def is_bv(a)
Definition: z3py.py:3666
def is_fprm(a)
Definition: z3py.py:8982

◆ 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 9145 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().

9145 def FPSort(ebits, sbits, ctx=None):
9146  """Return a Z3 floating-point sort of the given sizes. If `ctx=None`, then the global context is used.
9147 
9148  >>> Single = FPSort(8, 24)
9149  >>> Double = FPSort(11, 53)
9150  >>> Single
9151  FPSort(8, 24)
9152  >>> x = Const('x', Single)
9153  >>> eq(x, FP('x', FPSort(8, 24)))
9154  True
9155  """
9156  ctx = _get_ctx(ctx)
9157  return FPSortRef(Z3_mk_fpa_sort(ctx.ref(), ebits, sbits), ctx)
9158 
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:9145

◆ fpSqrt()

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

Definition at line 9540 of file z3py.py.

9540 def fpSqrt(rm, a, ctx=None):
9541  """Create a Z3 floating-point square root expression.
9542  """
9543  return _mk_fp_unary(Z3_mk_fpa_sqrt, rm, a, ctx)
9544 
def fpSqrt(rm, a, ctx=None)
Definition: z3py.py:9540

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

9452 def fpSub(rm, a, b, ctx=None):
9453  """Create a Z3 floating-point subtraction expression.
9454 
9455  >>> s = FPSort(8, 24)
9456  >>> rm = RNE()
9457  >>> x = FP('x', s)
9458  >>> y = FP('y', s)
9459  >>> fpSub(rm, x, y)
9460  fpSub(RNE(), x, y)
9461  >>> fpSub(rm, x, y).sort()
9462  FPSort(8, 24)
9463  """
9464  return _mk_fp_bin(Z3_mk_fpa_sub, rm, a, b, ctx)
9465 
def fpSub(rm, a, b, ctx=None)
Definition: z3py.py:9452

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

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

9695 def fpToFP(a1, a2=None, a3=None, ctx=None):
9696  """Create a Z3 floating-point conversion expression from other term sorts
9697  to floating-point.
9698 
9699  From a bit-vector term in IEEE 754-2008 format:
9700  >>> x = FPVal(1.0, Float32())
9701  >>> x_bv = fpToIEEEBV(x)
9702  >>> simplify(fpToFP(x_bv, Float32()))
9703  1
9704 
9705  From a floating-point term with different precision:
9706  >>> x = FPVal(1.0, Float32())
9707  >>> x_db = fpToFP(RNE(), x, Float64())
9708  >>> x_db.sort()
9709  FPSort(11, 53)
9710 
9711  From a real term:
9712  >>> x_r = RealVal(1.5)
9713  >>> simplify(fpToFP(RNE(), x_r, Float32()))
9714  1.5
9715 
9716  From a signed bit-vector term:
9717  >>> x_signed = BitVecVal(-5, BitVecSort(32))
9718  >>> simplify(fpToFP(RNE(), x_signed, Float32()))
9719  -1.25*(2**2)
9720  """
9721  ctx = _get_ctx(ctx)
9722  if is_bv(a1) and is_fp_sort(a2):
9723  return FPRef(Z3_mk_fpa_to_fp_bv(ctx.ref(), a1.ast, a2.ast), ctx)
9724  elif is_fprm(a1) and is_fp(a2) and is_fp_sort(a3):
9725  return FPRef(Z3_mk_fpa_to_fp_float(ctx.ref(), a1.ast, a2.ast, a3.ast), ctx)
9726  elif is_fprm(a1) and is_real(a2) and is_fp_sort(a3):
9727  return FPRef(Z3_mk_fpa_to_fp_real(ctx.ref(), a1.ast, a2.ast, a3.ast), ctx)
9728  elif is_fprm(a1) and is_bv(a2) and is_fp_sort(a3):
9729  return FPRef(Z3_mk_fpa_to_fp_signed(ctx.ref(), a1.ast, a2.ast, a3.ast), ctx)
9730  else:
9731  raise Z3Exception("Unsupported combination of arguments for conversion to floating-point term.")
9732 
def fpToFP(a1, a2=None, a3=None, ctx=None)
Definition: z3py.py:9695
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:2498
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:8734
def is_bv(a)
Definition: z3py.py:3666
def is_fprm(a)
Definition: z3py.py:8982
def is_fp(a)
Definition: z3py.py:9118

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

Referenced by fpUnsignedToFP().

9819 def fpToFPUnsigned(rm, x, s, ctx=None):
9820  """Create a Z3 floating-point conversion expression, from unsigned bit-vector to floating-point expression."""
9821  if z3_debug():
9822  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
9823  _z3_assert(is_bv(x), "Second argument must be a Z3 bit-vector expression")
9824  _z3_assert(is_fp_sort(s), "Third argument must be Z3 floating-point sort")
9825  ctx = _get_ctx(ctx)
9826  return FPRef(Z3_mk_fpa_to_fp_unsigned(ctx.ref(), rm.ast, x.ast, s.ast), ctx)
9827 
def fpToFPUnsigned(rm, x, s, ctx=None)
Definition: z3py.py:9819
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 z3_debug()
Definition: z3py.py:58
def is_fp_sort(s)
Definition: z3py.py:8734
def is_bv(a)
Definition: z3py.py:3666
def is_fprm(a)
Definition: z3py.py:8982

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

Referenced by fpToFP().

9889 def fpToIEEEBV(x, ctx=None):
9890  """\brief Conversion of a floating-point term into a bit-vector term in IEEE 754-2008 format.
9891 
9892  The size of the resulting bit-vector is automatically determined.
9893 
9894  Note that IEEE 754-2008 allows multiple different representations of NaN. This conversion
9895  knows only one NaN and it will always produce the same bit-vector representation of
9896  that NaN.
9897 
9898  >>> x = FP('x', FPSort(8, 24))
9899  >>> y = fpToIEEEBV(x)
9900  >>> print(is_fp(x))
9901  True
9902  >>> print(is_bv(y))
9903  True
9904  >>> print(is_fp(y))
9905  False
9906  >>> print(is_bv(x))
9907  False
9908  """
9909  if z3_debug():
9910  _z3_assert(is_fp(x), "First argument must be a Z3 floating-point expression")
9911  ctx = _get_ctx(ctx)
9912  return BitVecRef(Z3_mk_fpa_to_ieee_bv(ctx.ref(), x.ast), ctx)
9913 
9914 
9915 
def fpToIEEEBV(x, ctx=None)
Definition: z3py.py:9889
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 z3_debug()
Definition: z3py.py:58
def is_fp(a)
Definition: z3py.py:9118

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

9870 def fpToReal(x, ctx=None):
9871  """Create a Z3 floating-point conversion expression, from floating-point expression to real.
9872 
9873  >>> x = FP('x', FPSort(8, 24))
9874  >>> y = fpToReal(x)
9875  >>> print(is_fp(x))
9876  True
9877  >>> print(is_real(y))
9878  True
9879  >>> print(is_fp(y))
9880  False
9881  >>> print(is_real(x))
9882  False
9883  """
9884  if z3_debug():
9885  _z3_assert(is_fp(x), "First argument must be a Z3 floating-point expression")
9886  ctx = _get_ctx(ctx)
9887  return ArithRef(Z3_mk_fpa_to_real(ctx.ref(), x.ast), ctx)
9888 
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 z3_debug()
Definition: z3py.py:58
def fpToReal(x, ctx=None)
Definition: z3py.py:9870
def is_fp(a)
Definition: z3py.py:9118

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

9828 def fpToSBV(rm, x, s, ctx=None):
9829  """Create a Z3 floating-point conversion expression, from floating-point expression to signed bit-vector.
9830 
9831  >>> x = FP('x', FPSort(8, 24))
9832  >>> y = fpToSBV(RTZ(), x, BitVecSort(32))
9833  >>> print(is_fp(x))
9834  True
9835  >>> print(is_bv(y))
9836  True
9837  >>> print(is_fp(y))
9838  False
9839  >>> print(is_bv(x))
9840  False
9841  """
9842  if z3_debug():
9843  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
9844  _z3_assert(is_fp(x), "Second argument must be a Z3 floating-point expression")
9845  _z3_assert(is_bv_sort(s), "Third argument must be Z3 bit-vector sort")
9846  ctx = _get_ctx(ctx)
9847  return BitVecRef(Z3_mk_fpa_to_sbv(ctx.ref(), rm.ast, x.ast, s.size()), ctx)
9848 
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:9828
def z3_debug()
Definition: z3py.py:58
def is_bv_sort(s)
Definition: z3py.py:3205
def is_fprm(a)
Definition: z3py.py:8982
def is_fp(a)
Definition: z3py.py:9118

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

9849 def fpToUBV(rm, x, s, ctx=None):
9850  """Create a Z3 floating-point conversion expression, from floating-point expression to unsigned bit-vector.
9851 
9852  >>> x = FP('x', FPSort(8, 24))
9853  >>> y = fpToUBV(RTZ(), x, BitVecSort(32))
9854  >>> print(is_fp(x))
9855  True
9856  >>> print(is_bv(y))
9857  True
9858  >>> print(is_fp(y))
9859  False
9860  >>> print(is_bv(x))
9861  False
9862  """
9863  if z3_debug():
9864  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
9865  _z3_assert(is_fp(x), "Second argument must be a Z3 floating-point expression")
9866  _z3_assert(is_bv_sort(s), "Third argument must be Z3 bit-vector sort")
9867  ctx = _get_ctx(ctx)
9868  return BitVecRef(Z3_mk_fpa_to_ubv(ctx.ref(), rm.ast, x.ast, s.size()), ctx)
9869 
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:9849
def z3_debug()
Definition: z3py.py:58
def is_bv_sort(s)
Definition: z3py.py:3205
def is_fprm(a)
Definition: z3py.py:8982
def is_fp(a)
Definition: z3py.py:9118

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

9802 def fpUnsignedToFP(rm, v, sort, ctx=None):
9803  """Create a Z3 floating-point conversion expression that represents the
9804  conversion from an unsigned bit-vector term (encoding an integer) to a floating-point term.
9805 
9806  >>> x_signed = BitVecVal(-5, BitVecSort(32))
9807  >>> x_fp = fpUnsignedToFP(RNE(), x_signed, Float32())
9808  >>> x_fp
9809  fpToFPUnsigned(RNE(), 4294967291)
9810  >>> simplify(x_fp)
9811  1*(2**32)
9812  """
9813  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression.")
9814  _z3_assert(is_bv(v), "Second argument must be a Z3 expression or real sort.")
9815  _z3_assert(is_fp_sort(sort), "Third argument must be a Z3 floating-point sort.")
9816  ctx = _get_ctx(ctx)
9817  return FPRef(Z3_mk_fpa_to_fp_unsigned(ctx.ref(), rm.ast, v.ast, sort.ast), ctx)
9818 
def fpUnsignedToFP(rm, v, sort, ctx=None)
Definition: z3py.py:9802
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:8734
def is_bv(a)
Definition: z3py.py:3666
def is_fprm(a)
Definition: z3py.py:8982

◆ 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 9262 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().

9262 def FPVal(sig, exp=None, fps=None, ctx=None):
9263  """Return a floating-point value of value `val` and sort `fps`. If `ctx=None`, then the global context is used.
9264 
9265  >>> v = FPVal(20.0, FPSort(8, 24))
9266  >>> v
9267  1.25*(2**4)
9268  >>> print("0x%.8x" % v.exponent_as_long(False))
9269  0x00000004
9270  >>> v = FPVal(2.25, FPSort(8, 24))
9271  >>> v
9272  1.125*(2**1)
9273  >>> v = FPVal(-2.25, FPSort(8, 24))
9274  >>> v
9275  -1.125*(2**1)
9276  >>> FPVal(-0.0, FPSort(8, 24))
9277  -0.0
9278  >>> FPVal(0.0, FPSort(8, 24))
9279  +0.0
9280  >>> FPVal(+0.0, FPSort(8, 24))
9281  +0.0
9282  """
9283  ctx = _get_ctx(ctx)
9284  if is_fp_sort(exp):
9285  fps = exp
9286  exp = None
9287  elif fps is None:
9288  fps = _dflt_fps(ctx)
9289  _z3_assert(is_fp_sort(fps), "sort mismatch")
9290  if exp is None:
9291  exp = 0
9292  val = _to_float_str(sig)
9293  if val == "NaN" or val == "nan":
9294  return fpNaN(fps)
9295  elif val == "-0.0":
9296  return fpMinusZero(fps)
9297  elif val == "0.0" or val == "+0.0":
9298  return fpPlusZero(fps)
9299  elif val == "+oo" or val == "+inf" or val == "+Inf":
9300  return fpPlusInfinity(fps)
9301  elif val == "-oo" or val == "-inf" or val == "-Inf":
9302  return fpMinusInfinity(fps)
9303  else:
9304  return FPNumRef(Z3_mk_numeral(ctx.ref(), val, fps.ast), ctx)
9305 
def FPVal(sig, exp=None, fps=None, ctx=None)
Definition: z3py.py:9262
def fpMinusInfinity(s)
Definition: z3py.py:9235
def fpMinusZero(s)
Definition: z3py.py:9251
def fpPlusZero(s)
Definition: z3py.py:9246
def fpPlusInfinity(s)
Definition: z3py.py:9219
def fpNaN(s)
Definition: z3py.py:9203
def is_fp_sort(s)
Definition: z3py.py:8734
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 9256 of file z3py.py.

9256 def fpZero(s, negative):
9257  """Create a Z3 floating-point +0.0 or -0.0 term."""
9258  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
9259  _z3_assert(isinstance(negative, bool), "expected Boolean flag")
9260  return FPNumRef(Z3_mk_fpa_zero(s.ctx_ref(), s.ast, negative), s.ctx)
9261 
def fpZero(s, negative)
Definition: z3py.py:9256
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 1598 of file z3py.py.

1598 def FreshBool(prefix='b', ctx=None):
1599  """Return a fresh Boolean constant in the given context using the given prefix.
1600 
1601  If `ctx=None`, then the global context is used.
1602 
1603  >>> b1 = FreshBool()
1604  >>> b2 = FreshBool()
1605  >>> eq(b1, b2)
1606  False
1607  """
1608  ctx = _get_ctx(ctx)
1609  return BoolRef(Z3_mk_fresh_const(ctx.ref(), prefix, BoolSort(ctx).ast), ctx)
1610 
def FreshBool(prefix='b', ctx=None)
Definition: z3py.py:1598
def BoolSort(ctx=None)
Definition: z3py.py:1523
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 1316 of file z3py.py.

1316 def FreshConst(sort, prefix='c'):
1317  """Create a fresh constant of a specified sort"""
1318  ctx = _get_ctx(sort.ctx)
1319  return _to_expr_ref(Z3_mk_fresh_const(ctx.ref(), prefix, sort.ast), ctx)
1320 
def FreshConst(sort, prefix='c')
Definition: z3py.py:1316
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 3028 of file z3py.py.

3028 def FreshInt(prefix='x', ctx=None):
3029  """Return a fresh integer constant in the given context using the given prefix.
3030 
3031  >>> x = FreshInt()
3032  >>> y = FreshInt()
3033  >>> eq(x, y)
3034  False
3035  >>> x.sort()
3036  Int
3037  """
3038  ctx = _get_ctx(ctx)
3039  return ArithRef(Z3_mk_fresh_const(ctx.ref(), prefix, IntSort(ctx).ast), ctx)
3040 
def IntSort(ctx=None)
Definition: z3py.py:2890
def FreshInt(prefix='x', ctx=None)
Definition: z3py.py:3028
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 3080 of file z3py.py.

3080 def FreshReal(prefix='b', ctx=None):
3081  """Return a fresh real constant in the given context using the given prefix.
3082 
3083  >>> x = FreshReal()
3084  >>> y = FreshReal()
3085  >>> eq(x, y)
3086  False
3087  >>> x.sort()
3088  Real
3089  """
3090  ctx = _get_ctx(ctx)
3091  return ArithRef(Z3_mk_fresh_const(ctx.ref(), prefix, RealSort(ctx).ast), ctx)
3092 
def FreshReal(prefix='b', ctx=None)
Definition: z3py.py:3080
def RealSort(ctx=None)
Definition: z3py.py:2906
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)
Full(ReSort(Seq(Int)))
>>> e1 = Full(ReSort(StringSort()))
>>> print(e1)
Full(ReSort(String))

Definition at line 10085 of file z3py.py.

10085 def Full(s):
10086  """Create the regular expression that accepts the universal language
10087  >>> e = Full(ReSort(SeqSort(IntSort())))
10088  >>> print(e)
10089  Full(ReSort(Seq(Int)))
10090  >>> e1 = Full(ReSort(StringSort()))
10091  >>> print(e1)
10092  Full(ReSort(String))
10093  """
10094  if isinstance(s, ReSortRef):
10095  return ReRef(Z3_mk_re_full(s.ctx_ref(), s.ast), s.ctx)
10096  raise Z3Exception("Non-sequence, non-regular expression sort passed to Full")
10097 
10098 
def Full(s)
Definition: z3py.py:10085
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 4560 of file z3py.py.

4560 def FullSet(s):
4561  """Create the full set
4562  >>> FullSet(IntSort())
4563  K(Int, True)
4564  """
4565  ctx = s.ctx
4566  return ArrayRef(Z3_mk_full_set(ctx.ref(), s.ast), ctx)
4567 
Z3_ast Z3_API Z3_mk_full_set(Z3_context c, Z3_sort domain)
Create the full set.
def FullSet(s)
Definition: z3py.py:4560

◆ 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 789 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().

789 def Function(name, *sig):
790  """Create a new Z3 uninterpreted function with the given sorts.
791 
792  >>> f = Function('f', IntSort(), IntSort())
793  >>> f(f(0))
794  f(f(0))
795  """
796  sig = _get_args(sig)
797  if z3_debug():
798  _z3_assert(len(sig) > 0, "At least two arguments expected")
799  arity = len(sig) - 1
800  rng = sig[arity]
801  if z3_debug():
802  _z3_assert(is_sort(rng), "Z3 sort expected")
803  dom = (Sort * arity)()
804  for i in range(arity):
805  if z3_debug():
806  _z3_assert(is_sort(sig[i]), "Z3 sort expected")
807  dom[i] = sig[i].ast
808  ctx = rng.ctx
809  return FuncDeclRef(Z3_mk_func_decl(ctx.ref(), to_symbol(name, ctx), arity, dom, rng.ast), ctx)
810 
def Function(name, sig)
Definition: z3py.py:789
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3358
def to_symbol(s, ctx=None)
Definition: z3py.py:111
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:586
def z3_debug()
Definition: z3py.py:58

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

6224 def get_as_array_func(n):
6225  """Return the function declaration f associated with a Z3 expression of the form (_ as-array f)."""
6226  if z3_debug():
6227  _z3_assert(is_as_array(n), "as-array Z3 expression expected.")
6228  return FuncDeclRef(Z3_get_as_array_func_decl(n.ctx.ref(), n.as_ast()), n.ctx)
6229 
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:6224
def z3_debug()
Definition: z3py.py:58
def is_as_array(n)
Definition: z3py.py:6220

◆ get_default_fp_sort()

def z3py.get_default_fp_sort (   ctx = None)

Definition at line 8614 of file z3py.py.

8614 def get_default_fp_sort(ctx=None):
8615  return FPSort(_dflt_fpsort_ebits, _dflt_fpsort_sbits, ctx)
8616 
def FPSort(ebits, sbits, ctx=None)
Definition: z3py.py:9145
def get_default_fp_sort(ctx=None)
Definition: z3py.py:8614

◆ get_default_rounding_mode()

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

Definition at line 8587 of file z3py.py.

8587 def get_default_rounding_mode(ctx=None):
8588  """Retrieves the global default rounding mode."""
8589  global _dflt_rounding_mode
8590  if _dflt_rounding_mode == Z3_OP_FPA_RM_TOWARD_ZERO:
8591  return RTZ(ctx)
8592  elif _dflt_rounding_mode == Z3_OP_FPA_RM_TOWARD_NEGATIVE:
8593  return RTN(ctx)
8594  elif _dflt_rounding_mode == Z3_OP_FPA_RM_TOWARD_POSITIVE:
8595  return RTP(ctx)
8596  elif _dflt_rounding_mode == Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN:
8597  return RNE(ctx)
8598  elif _dflt_rounding_mode == Z3_OP_FPA_RM_NEAREST_TIES_TO_AWAY:
8599  return RNA(ctx)
8600 
def RTN(ctx=None)
Definition: z3py.py:8970
def RTZ(ctx=None)
Definition: z3py.py:8978
def RTP(ctx=None)
Definition: z3py.py:8962
def RNA(ctx=None)
Definition: z3py.py:8954
def get_default_rounding_mode(ctx=None)
Definition: z3py.py:8587
def RNE(ctx=None)
Definition: z3py.py:8946

◆ get_full_version()

def z3py.get_full_version ( )

Definition at line 91 of file z3py.py.

91 def get_full_version():
92  return Z3_get_full_version()
93 
94 # We use _z3_assert instead of the assert command because we want to
95 # 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:91

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

4334 def get_map_func(a):
4335  """Return the function declaration associated with a Z3 map array expression.
4336 
4337  >>> f = Function('f', IntSort(), IntSort())
4338  >>> b = Array('b', IntSort(), IntSort())
4339  >>> a = Map(f, b)
4340  >>> eq(f, get_map_func(a))
4341  True
4342  >>> get_map_func(a)
4343  f
4344  >>> get_map_func(a)(0)
4345  f(0)
4346  """
4347  if z3_debug():
4348  _z3_assert(is_map(a), "Z3 array map expression expected.")
4349  return FuncDeclRef(Z3_to_func_decl(a.ctx_ref(), Z3_get_decl_ast_parameter(a.ctx_ref(), a.decl().ast, 0)), a.ctx)
4350 
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:4311
def get_map_func(a)
Definition: z3py.py:4334
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.
def z3_debug()
Definition: z3py.py:58

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

272 def get_param(name):
273  """Return the value of a Z3 global (or module) parameter
274 
275  >>> get_param('nlsat.reorder')
276  'true'
277  """
278  ptr = (ctypes.c_char_p * 1)()
279  if Z3_global_param_get(str(name), ptr):
280  r = z3core._to_pystr(ptr[0])
281  return r
282  raise Z3Exception("failed to retrieve value for '%s'" % name)
283 
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:272

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

1194 def get_var_index(a):
1195  """Return the de-Bruijn index of the Z3 bounded variable `a`.
1196 
1197  >>> x = Int('x')
1198  >>> y = Int('y')
1199  >>> is_var(x)
1200  False
1201  >>> is_const(x)
1202  True
1203  >>> f = Function('f', IntSort(), IntSort(), IntSort())
1204  >>> # Z3 replaces x and y with bound variables when ForAll is executed.
1205  >>> q = ForAll([x, y], f(x, y) == x + y)
1206  >>> q.body()
1207  f(Var(1), Var(0)) == Var(1) + Var(0)
1208  >>> b = q.body()
1209  >>> b.arg(0)
1210  f(Var(1), Var(0))
1211  >>> v1 = b.arg(0).arg(0)
1212  >>> v2 = b.arg(0).arg(1)
1213  >>> v1
1214  Var(1)
1215  >>> v2
1216  Var(0)
1217  >>> get_var_index(v1)
1218  1
1219  >>> get_var_index(v2)
1220  0
1221  """
1222  if z3_debug():
1223  _z3_assert(is_var(a), "Z3 bound variable expected")
1224  return int(Z3_get_index_value(a.ctx.ref(), a.as_ast()))
1225 
unsigned Z3_API Z3_get_index_value(Z3_context c, Z3_ast a)
Return index of de-Bruijn bound variable.
def z3_debug()
Definition: z3py.py:58
def get_var_index(a)
Definition: z3py.py:1194
def is_var(a)
Definition: z3py.py:1170

◆ get_version()

def z3py.get_version ( )

Definition at line 83 of file z3py.py.

83 def get_version():
84  major = ctypes.c_uint(0)
85  minor = ctypes.c_uint(0)
86  build = ctypes.c_uint(0)
87  rev = ctypes.c_uint(0)
88  Z3_get_version(major, minor, build, rev)
89  return (major.value, minor.value, build.value, rev.value)
90 
def get_version()
Definition: z3py.py:83
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 75 of file z3py.py.

75 def get_version_string():
76  major = ctypes.c_uint(0)
77  minor = ctypes.c_uint(0)
78  build = ctypes.c_uint(0)
79  rev = ctypes.c_uint(0)
80  Z3_get_version(major, minor, build, rev)
81  return "%s.%s.%s" % (major.value, minor.value, build.value)
82 
def get_version_string()
Definition: z3py.py:75
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 8173 of file z3py.py.

8173 def help_simplify():
8174  """Return a string describing all options available for Z3 `simplify` procedure."""
8175  print(Z3_simplify_get_help(main_ctx().ref()))
8176 
def main_ctx()
Definition: z3py.py:213
def help_simplify()
Definition: z3py.py:8173
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 1238 of file z3py.py.

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

1238 def If(a, b, c, ctx=None):
1239  """Create a Z3 if-then-else expression.
1240 
1241  >>> x = Int('x')
1242  >>> y = Int('y')
1243  >>> max = If(x > y, x, y)
1244  >>> max
1245  If(x > y, x, y)
1246  >>> simplify(max)
1247  If(x <= y, y, x)
1248  """
1249  if isinstance(a, Probe) or isinstance(b, Tactic) or isinstance(c, Tactic):
1250  return Cond(a, b, c, ctx)
1251  else:
1252  ctx = _get_ctx(_ctx_from_ast_arg_list([a, b, c], ctx))
1253  s = BoolSort(ctx)
1254  a = s.cast(a)
1255  b, c = _coerce_exprs(b, c, ctx)
1256  if z3_debug():
1257  _z3_assert(a.ctx == b.ctx, "Context mismatch")
1258  return _to_expr_ref(Z3_mk_ite(ctx.ref(), a.as_ast(), b.as_ast(), c.as_ast()), ctx)
1259 
def If(a, b, c, ctx=None)
Definition: z3py.py:1238
def Cond(p, t1, t2, ctx=None)
Definition: z3py.py:8133
def z3_debug()
Definition: z3py.py:58
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:1523

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

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

1611 def Implies(a, b, ctx=None):
1612  """Create a Z3 implies expression.
1613 
1614  >>> p, q = Bools('p q')
1615  >>> Implies(p, q)
1616  Implies(p, q)
1617  >>> simplify(Implies(p, q))
1618  Or(Not(p), q)
1619  """
1620  ctx = _get_ctx(_ctx_from_ast_arg_list([a, b], ctx))
1621  s = BoolSort(ctx)
1622  a = s.cast(a)
1623  b = s.cast(b)
1624  return BoolRef(Z3_mk_implies(ctx.ref(), a.as_ast(), b.as_ast()), ctx)
1625 
def Implies(a, b, ctx=None)
Definition: z3py.py:1611
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:1523

◆ IndexOf() [1/2]

def z3py.IndexOf (   s,
  substr 
)

Definition at line 10164 of file z3py.py.

Referenced by IndexOf().

10164 def IndexOf(s, substr):
10165  return IndexOf(s, substr, IntVal(0))
10166 
def IntVal(val, ctx=None)
Definition: z3py.py:2937
def IndexOf(s, substr)
Definition: z3py.py:10164

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

10167 def IndexOf(s, substr, offset):
10168  """Retrieve the index of substring within a string starting at a specified offset.
10169  >>> simplify(IndexOf("abcabc", "bc", 0))
10170  1
10171  >>> simplify(IndexOf("abcabc", "bc", 2))
10172  4
10173  """
10174  ctx = None
10175  if is_expr(offset):
10176  ctx = offset.ctx
10177  ctx = _get_ctx2(s, substr, ctx)
10178  s = _coerce_seq(s, ctx)
10179  substr = _coerce_seq(substr, ctx)
10180  if _is_int(offset):
10181  offset = IntVal(offset, ctx)
10182  return ArithRef(Z3_mk_seq_index(s.ctx_ref(), s.as_ast(), substr.as_ast(), offset.as_ast()), s.ctx)
10183 
def IntVal(val, ctx=None)
Definition: z3py.py:2937
def IndexOf(s, substr)
Definition: z3py.py:10164
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:1105

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

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

10264 def InRe(s, re):
10265  """Create regular expression membership test
10266  >>> re = Union(Re("a"),Re("b"))
10267  >>> print (simplify(InRe("a", re)))
10268  True
10269  >>> print (simplify(InRe("b", re)))
10270  True
10271  >>> print (simplify(InRe("c", re)))
10272  False
10273  """
10274  s = _coerce_seq(s, re.ctx)
10275  return BoolRef(Z3_mk_seq_in_re(s.ctx_ref(), s.as_ast(), re.as_ast()), s.ctx)
10276 
def InRe(s, re)
Definition: z3py.py:10264
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 2993 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().

2993 def Int(name, ctx=None):
2994  """Return an integer constant named `name`. If `ctx=None`, then the global context is used.
2995 
2996  >>> x = Int('x')
2997  >>> is_int(x)
2998  True
2999  >>> is_int(x + 1)
3000  True
3001  """
3002  ctx = _get_ctx(ctx)
3003  return ArithRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), IntSort(ctx).ast), ctx)
3004 
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:111
def Int(name, ctx=None)
Definition: z3py.py:2993
def IntSort(ctx=None)
Definition: z3py.py:2890

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

3715 def Int2BV(a, num_bits):
3716  """Return the z3 expression Int2BV(a, num_bits).
3717  It is a bit-vector of width num_bits and represents the
3718  modulo of a by 2^num_bits
3719  """
3720  ctx = a.ctx
3721  return BitVecRef(Z3_mk_int2bv(ctx.ref(), num_bits, a.as_ast()), ctx)
3722 
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:3715

◆ Intersect()

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

Definition at line 10296 of file z3py.py.

10296 def Intersect(*args):
10297  """Create intersection of regular expressions.
10298  >>> re = Intersect(Re("a"), Re("b"), Re("c"))
10299  """
10300  args = _get_args(args)
10301  sz = len(args)
10302  if z3_debug():
10303  _z3_assert(sz > 0, "At least one argument expected.")
10304  _z3_assert(all([is_re(a) for a in args]), "All arguments must be regular expressions.")
10305  if sz == 1:
10306  return args[0]
10307  ctx = args[0].ctx
10308  v = (Ast * sz)()
10309  for i in range(sz):
10310  v[i] = args[i].as_ast()
10311  return ReRef(Z3_mk_re_intersect(ctx.ref(), sz, v), ctx)
10312 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3358
def Intersect(args)
Definition: z3py.py:10296
Z3_ast Z3_API Z3_mk_re_intersect(Z3_context c, unsigned n, Z3_ast const args[])
Create the intersection of the regular languages.
def is_re(s)
Definition: z3py.py:10260
def z3_debug()
Definition: z3py.py:58

◆ 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 3005 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().

3005 def Ints(names, ctx=None):
3006  """Return a tuple of Integer constants.
3007 
3008  >>> x, y, z = Ints('x y z')
3009  >>> Sum(x, y, z)
3010  x + y + z
3011  """
3012  ctx = _get_ctx(ctx)
3013  if isinstance(names, str):
3014  names = names.split(" ")
3015  return [Int(name, ctx) for name in names]
3016 
def Int(name, ctx=None)
Definition: z3py.py:2993
def Ints(names, ctx=None)
Definition: z3py.py:3005

◆ 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 2890 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(), DisjointSum(), ArraySortRef.domain(), ArrayRef.domain(), FuncInterp.else_value(), Empty(), EmptySet(), FuncInterp.entry(), Exists(), Ext(), 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(), TupleSort(), Update(), FuncEntry.value(), QuantifierRef.var_name(), QuantifierRef.var_sort(), and QuantifierRef.weight().

2890 def IntSort(ctx=None):
2891  """Return the integer sort in the given context. If `ctx=None`, then the global context is used.
2892 
2893  >>> IntSort()
2894  Int
2895  >>> x = Const('x', IntSort())
2896  >>> is_int(x)
2897  True
2898  >>> x.sort() == IntSort()
2899  True
2900  >>> x.sort() == BoolSort()
2901  False
2902  """
2903  ctx = _get_ctx(ctx)
2904  return ArithSortRef(Z3_mk_int_sort(ctx.ref()), ctx)
2905 
Z3_sort Z3_API Z3_mk_int_sort(Z3_context c)
Create the integer type.
def IntSort(ctx=None)
Definition: z3py.py:2890

◆ IntToStr()

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

Definition at line 10218 of file z3py.py.

Referenced by StrToInt().

10218 def IntToStr(s):
10219  """Convert integer expression to string"""
10220  if not is_expr(s):
10221  s = _py2expr(s)
10222  return SeqRef(Z3_mk_int_to_str(s.ctx_ref(), s.as_ast()), s.ctx)
10223 
10224 
def IntToStr(s)
Definition: z3py.py:10218
def is_expr(a)
Definition: z3py.py:1105
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 2937 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().

2937 def IntVal(val, ctx=None):
2938  """Return a Z3 integer value. If `ctx=None`, then the global context is used.
2939 
2940  >>> IntVal(1)
2941  1
2942  >>> IntVal("100")
2943  100
2944  """
2945  ctx = _get_ctx(ctx)
2946  return IntNumRef(Z3_mk_numeral(ctx.ref(), _to_int_str(val), IntSort(ctx).ast), ctx)
2947 
def IntVal(val, ctx=None)
Definition: z3py.py:2937
def IntSort(ctx=None)
Definition: z3py.py:2890
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 3017 of file z3py.py.

3017 def IntVector(prefix, sz, ctx=None):
3018  """Return a list of integer constants of size `sz`.
3019 
3020  >>> X = IntVector('x', 3)
3021  >>> X
3022  [x__0, x__1, x__2]
3023  >>> Sum(X)
3024  x__0 + x__1 + x__2
3025  """
3026  return [ Int('%s__%s' % (prefix, i)) for i in range(sz) ]
3027 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3358
def Int(name, ctx=None)
Definition: z3py.py:2993
def IntVector(prefix, sz, ctx=None)
Definition: z3py.py:3017

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

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

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

2566 def is_algebraic_value(a):
2567  """Return `True` if `a` is an algebraic value of sort Real.
2568 
2569  >>> is_algebraic_value(RealVal("3/5"))
2570  False
2571  >>> n = simplify(Sqrt(2))
2572  >>> n
2573  1.4142135623?
2574  >>> is_algebraic_value(n)
2575  True
2576  """
2577  return is_arith(a) and a.is_real() and _is_algebraic(a.ctx, a.as_ast())
2578 
def is_arith(a)
Definition: z3py.py:2460
def is_algebraic_value(a)
Definition: z3py.py:2566

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

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

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

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

1127 def is_app(a):
1128  """Return `True` if `a` is a Z3 function application.
1129 
1130  Note that, constants are function applications with 0 arguments.
1131 
1132  >>> a = Int('a')
1133  >>> is_app(a)
1134  True
1135  >>> is_app(a + 1)
1136  True
1137  >>> is_app(IntSort())
1138  False
1139  >>> is_app(1)
1140  False
1141  >>> is_app(IntVal(1))
1142  True
1143  >>> x = Int('x')
1144  >>> is_app(ForAll(x, x >= 0))
1145  False
1146  """
1147  if not isinstance(a, ExprRef):
1148  return False
1149  k = _ast_kind(a.ctx, a)
1150  return k == Z3_NUMERAL_AST or k == Z3_APP_AST
1151 
def is_app(a)
Definition: z3py.py:1127

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

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

1226 def is_app_of(a, k):
1227  """Return `True` if `a` is an application of the given kind `k`.
1228 
1229  >>> x = Int('x')
1230  >>> n = x + 1
1231  >>> is_app_of(n, Z3_OP_ADD)
1232  True
1233  >>> is_app_of(n, Z3_OP_MUL)
1234  False
1235  """
1236  return is_app(a) and a.decl().kind() == k
1237 
def is_app(a)
Definition: z3py.py:1127
def is_app_of(a, k)
Definition: z3py.py:1226

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

2460 def is_arith(a):
2461  """Return `True` if `a` is an arithmetical expression.
2462 
2463  >>> x = Int('x')
2464  >>> is_arith(x)
2465  True
2466  >>> is_arith(x + 1)
2467  True
2468  >>> is_arith(1)
2469  False
2470  >>> is_arith(IntVal(1))
2471  True
2472  >>> y = Real('y')
2473  >>> is_arith(y)
2474  True
2475  >>> is_arith(y + 1)
2476  True
2477  """
2478  return isinstance(a, ArithRef)
2479 
def is_arith(a)
Definition: z3py.py:2460

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

2161 def is_arith_sort(s):
2162  """Return `True` if s is an arithmetical sort (type).
2163 
2164  >>> is_arith_sort(IntSort())
2165  True
2166  >>> is_arith_sort(RealSort())
2167  True
2168  >>> is_arith_sort(BoolSort())
2169  False
2170  >>> n = Int('x') + 1
2171  >>> is_arith_sort(n.sort())
2172  True
2173  """
2174  return isinstance(s, ArithSortRef)
2175 
def is_arith_sort(s)
Definition: z3py.py:2161

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

4274 def is_array(a):
4275  """Return `True` if `a` is a Z3 array expression.
4276 
4277  >>> a = Array('a', IntSort(), IntSort())
4278  >>> is_array(a)
4279  True
4280  >>> is_array(Store(a, 0, 1))
4281  True
4282  >>> is_array(a[0])
4283  False
4284  """
4285  return isinstance(a, ArrayRef)
4286 
def is_array(a)
Definition: z3py.py:4274

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

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

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

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

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

Referenced by BoolSort(), and prove().

1412 def is_bool(a):
1413  """Return `True` if `a` is a Z3 Boolean expression.
1414 
1415  >>> p = Bool('p')
1416  >>> is_bool(p)
1417  True
1418  >>> q = Bool('q')
1419  >>> is_bool(And(p, q))
1420  True
1421  >>> x = Real('x')
1422  >>> is_bool(x)
1423  False
1424  >>> is_bool(x == 0)
1425  True
1426  """
1427  return isinstance(a, BoolRef)
1428 
def is_bool(a)
Definition: z3py.py:1412

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

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

3666 def is_bv(a):
3667  """Return `True` if `a` is a Z3 bit-vector expression.
3668 
3669  >>> b = BitVec('b', 32)
3670  >>> is_bv(b)
3671  True
3672  >>> is_bv(b + 10)
3673  True
3674  >>> is_bv(Int('x'))
3675  False
3676  """
3677  return isinstance(a, BitVecRef)
3678 
def is_bv(a)
Definition: z3py.py:3666

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

3205 def is_bv_sort(s):
3206  """Return True if `s` is a Z3 bit-vector sort.
3207 
3208  >>> is_bv_sort(BitVecSort(32))
3209  True
3210  >>> is_bv_sort(IntSort())
3211  False
3212  """
3213  return isinstance(s, BitVecSortRef)
3214 
def is_bv_sort(s)
Definition: z3py.py:3205

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

3679 def is_bv_value(a):
3680  """Return `True` if `a` is a Z3 bit-vector numeral value.
3681 
3682  >>> b = BitVec('b', 32)
3683  >>> is_bv_value(b)
3684  False
3685  >>> b = BitVecVal(10, 32)
3686  >>> b
3687  10
3688  >>> is_bv_value(b)
3689  True
3690  """
3691  return is_bv(a) and _is_numeral(a.ctx, a.as_ast())
3692 
def is_bv_value(a)
Definition: z3py.py:3679
def is_bv(a)
Definition: z3py.py:3666

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

Referenced by Optimize.assert_and_track(), and prove().

1152 def is_const(a):
1153  """Return `True` if `a` is Z3 constant/variable expression.
1154 
1155  >>> a = Int('a')
1156  >>> is_const(a)
1157  True
1158  >>> is_const(a + 1)
1159  False
1160  >>> is_const(1)
1161  False
1162  >>> is_const(IntVal(1))
1163  True
1164  >>> x = Int('x')
1165  >>> is_const(ForAll(x, x >= 0))
1166  False
1167  """
1168  return is_app(a) and a.num_args() == 0
1169 
def is_app(a)
Definition: z3py.py:1127
def is_const(a)
Definition: z3py.py:1152

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

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

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

4326 def is_default(a):
4327  """Return `True` if `a` is a Z3 default array expression.
4328  >>> d = Default(K(IntSort(), 10))
4329  >>> is_default(d)
4330  True
4331  """
4332  return is_app_of(a, Z3_OP_ARRAY_DEFAULT)
4333 
def is_default(a)
Definition: z3py.py:4326
def is_app_of(a, k)
Definition: z3py.py:1226

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

1512 def is_distinct(a):
1513  """Return `True` if `a` is a Z3 distinct expression.
1514 
1515  >>> x, y, z = Ints('x y z')
1516  >>> is_distinct(x == y)
1517  False
1518  >>> is_distinct(Distinct(x, y, z))
1519  True
1520  """
1521  return is_app_of(a, Z3_OP_DISTINCT)
1522 
def is_distinct(a)
Definition: z3py.py:1512
def is_app_of(a, k)
Definition: z3py.py:1226

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

2612 def is_div(a):
2613  """Return `True` if `a` is an expression of the form b / c.
2614 
2615  >>> x, y = Reals('x y')
2616  >>> is_div(x / y)
2617  True
2618  >>> is_div(x + y)
2619  False
2620  >>> x, y = Ints('x y')
2621  >>> is_div(x / y)
2622  False
2623  >>> is_idiv(x / y)
2624  True
2625  """
2626  return is_app_of(a, Z3_OP_DIV)
2627 
def is_div(a)
Definition: z3py.py:2612
def is_app_of(a, k)
Definition: z3py.py:1226

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

Referenced by AstRef.__bool__().

1503 def is_eq(a):
1504  """Return `True` if `a` is a Z3 equality expression.
1505 
1506  >>> x, y = Ints('x y')
1507  >>> is_eq(x == y)
1508  True
1509  """
1510  return is_app_of(a, Z3_OP_EQ)
1511 
def is_eq(a)
Definition: z3py.py:1503
def is_app_of(a, k)
Definition: z3py.py:1226

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

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

1105 def is_expr(a):
1106  """Return `True` if `a` is a Z3 expression.
1107 
1108  >>> a = Int('a')
1109  >>> is_expr(a)
1110  True
1111  >>> is_expr(a + 1)
1112  True
1113  >>> is_expr(IntSort())
1114  False
1115  >>> is_expr(1)
1116  False
1117  >>> is_expr(IntVal(1))
1118  True
1119  >>> x = Int('x')
1120  >>> is_expr(ForAll(x, x >= 0))
1121  True
1122  >>> is_expr(FPVal(1.0))
1123  True
1124  """
1125  return isinstance(a, ExprRef)
1126 
def is_expr(a)
Definition: z3py.py:1105

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

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

1446 def is_false(a):
1447  """Return `True` if `a` is the Z3 false expression.
1448 
1449  >>> p = Bool('p')
1450  >>> is_false(p)
1451  False
1452  >>> is_false(False)
1453  False
1454  >>> is_false(BoolVal(False))
1455  True
1456  """
1457  return is_app_of(a, Z3_OP_FALSE)
1458 
def is_app_of(a, k)
Definition: z3py.py:1226
def is_false(a)
Definition: z3py.py:1446

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

Referenced by is_finite_domain_value().

7217 def is_finite_domain(a):
7218  """Return `True` if `a` is a Z3 finite-domain expression.
7219 
7220  >>> s = FiniteDomainSort('S', 100)
7221  >>> b = Const('b', s)
7222  >>> is_finite_domain(b)
7223  True
7224  >>> is_finite_domain(Int('x'))
7225  False
7226  """
7227  return isinstance(a, FiniteDomainRef)
7228 
7229 
def is_finite_domain(a)
Definition: z3py.py:7217

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

Referenced by FiniteDomainVal().

7195 def is_finite_domain_sort(s):
7196  """Return True if `s` is a Z3 finite-domain sort.
7197 
7198  >>> is_finite_domain_sort(FiniteDomainSort('S', 100))
7199  True
7200  >>> is_finite_domain_sort(IntSort())
7201  False
7202  """
7203  return isinstance(s, FiniteDomainSortRef)
7204 
7205 
def is_finite_domain_sort(s)
Definition: z3py.py:7195

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

7270 def is_finite_domain_value(a):
7271  """Return `True` if `a` is a Z3 finite-domain value.
7272 
7273  >>> s = FiniteDomainSort('S', 100)
7274  >>> b = Const('b', s)
7275  >>> is_finite_domain_value(b)
7276  False
7277  >>> b = FiniteDomainVal(10, s)
7278  >>> b
7279  10
7280  >>> is_finite_domain_value(b)
7281  True
7282  """
7283  return is_finite_domain(a) and _is_numeral(a.ctx, a.as_ast())
7284 
7285 
def is_finite_domain_value(a)
Definition: z3py.py:7270
def is_finite_domain(a)
Definition: z3py.py:7217

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

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

9118 def is_fp(a):
9119  """Return `True` if `a` is a Z3 floating-point expression.
9120 
9121  >>> b = FP('b', FPSort(8, 24))
9122  >>> is_fp(b)
9123  True
9124  >>> is_fp(b + 1.0)
9125  True
9126  >>> is_fp(Int('x'))
9127  False
9128  """
9129  return isinstance(a, FPRef)
9130 
def is_fp(a)
Definition: z3py.py:9118

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

8734 def is_fp_sort(s):
8735  """Return True if `s` is a Z3 floating-point sort.
8736 
8737  >>> is_fp_sort(FPSort(8, 24))
8738  True
8739  >>> is_fp_sort(IntSort())
8740  False
8741  """
8742  return isinstance(s, FPSortRef)
8743 
def is_fp_sort(s)
Definition: z3py.py:8734

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

9131 def is_fp_value(a):
9132  """Return `True` if `a` is a Z3 floating-point numeral value.
9133 
9134  >>> b = FP('b', FPSort(8, 24))
9135  >>> is_fp_value(b)
9136  False
9137  >>> b = FPVal(1.0, FPSort(8, 24))
9138  >>> b
9139  1
9140  >>> is_fp_value(b)
9141  True
9142  """
9143  return is_fp(a) and _is_numeral(a.ctx, a.ast)
9144 
def is_fp_value(a)
Definition: z3py.py:9131
def is_fp(a)
Definition: z3py.py:9118

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

8982 def is_fprm(a):
8983  """Return `True` if `a` is a Z3 floating-point rounding mode expression.
8984 
8985  >>> rm = RNE()
8986  >>> is_fprm(rm)
8987  True
8988  >>> rm = 1.0
8989  >>> is_fprm(rm)
8990  False
8991  """
8992  return isinstance(a, FPRMRef)
8993 
def is_fprm(a)
Definition: z3py.py:8982

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

8744 def is_fprm_sort(s):
8745  """Return True if `s` is a Z3 floating-point rounding mode sort.
8746 
8747  >>> is_fprm_sort(FPSort(8, 24))
8748  False
8749  >>> is_fprm_sort(RNE().sort())
8750  True
8751  """
8752  return isinstance(s, FPRMSortRef)
8753 
def is_fprm_sort(s)
Definition: z3py.py:8744

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

8994 def is_fprm_value(a):
8995  """Return `True` if `a` is a Z3 floating-point rounding mode numeral value."""
8996  return is_fprm(a) and _is_numeral(a.ctx, a.ast)
8997 
def is_fprm_value(a)
Definition: z3py.py:8994
def is_fprm(a)
Definition: z3py.py:8982

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

Referenced by prove().

777 def is_func_decl(a):
778  """Return `True` if `a` is a Z3 function declaration.
779 
780  >>> f = Function('f', IntSort(), IntSort())
781  >>> is_func_decl(f)
782  True
783  >>> x = Real('x')
784  >>> is_func_decl(x)
785  False
786  """
787  return isinstance(a, FuncDeclRef)
788 
def is_func_decl(a)
Definition: z3py.py:777

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

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

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

2683 def is_gt(a):
2684  """Return `True` if `a` is an expression of the form b > c.
2685 
2686  >>> x, y = Ints('x y')
2687  >>> is_gt(x > y)
2688  True
2689  >>> is_gt(x == y)
2690  False
2691  """
2692  return is_app_of(a, Z3_OP_GT)
2693 
def is_gt(a)
Definition: z3py.py:2683
def is_app_of(a, k)
Definition: z3py.py:1226

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

Referenced by is_div().

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

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

1481 def is_implies(a):
1482  """Return `True` if `a` is a Z3 implication expression.
1483 
1484  >>> p, q = Bools('p q')
1485  >>> is_implies(Implies(p, q))
1486  True
1487  >>> is_implies(And(p, q))
1488  False
1489  """
1490  return is_app_of(a, Z3_OP_IMPLIES)
1491 
def is_implies(a)
Definition: z3py.py:1481
def is_app_of(a, k)
Definition: z3py.py:1226

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

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

2480 def is_int(a):
2481  """Return `True` if `a` is an integer expression.
2482 
2483  >>> x = Int('x')
2484  >>> is_int(x + 1)
2485  True
2486  >>> is_int(1)
2487  False
2488  >>> is_int(IntVal(1))
2489  True
2490  >>> y = Real('y')
2491  >>> is_int(y)
2492  False
2493  >>> is_int(y + 1)
2494  False
2495  """
2496  return is_arith(a) and a.is_int()
2497 
def is_arith(a)
Definition: z3py.py:2460
def is_int(a)
Definition: z3py.py:2480

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

2522 def is_int_value(a):
2523  """Return `True` if `a` is an integer value of sort Int.
2524 
2525  >>> is_int_value(IntVal(1))
2526  True
2527  >>> is_int_value(1)
2528  False
2529  >>> is_int_value(Int('x'))
2530  False
2531  >>> n = Int('x') + 1
2532  >>> n
2533  x + 1
2534  >>> n.arg(1)
2535  1
2536  >>> is_int_value(n.arg(1))
2537  True
2538  >>> is_int_value(RealVal("1/3"))
2539  False
2540  >>> is_int_value(RealVal(1))
2541  False
2542  """
2543  return is_arith(a) and a.is_int() and _is_numeral(a.ctx, a.as_ast())
2544 
def is_int_value(a)
Definition: z3py.py:2522
def is_arith(a)
Definition: z3py.py:2460

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

2694 def is_is_int(a):
2695  """Return `True` if `a` is an expression of the form IsInt(b).
2696 
2697  >>> x = Real('x')
2698  >>> is_is_int(IsInt(x))
2699  True
2700  >>> is_is_int(x)
2701  False
2702  """
2703  return is_app_of(a, Z3_OP_IS_INT)
2704 
def is_app_of(a, k)
Definition: z3py.py:1226
def is_is_int(a)
Definition: z3py.py:2694

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

4299 def is_K(a):
4300  """Return `True` if `a` is a Z3 constant array.
4301 
4302  >>> a = K(IntSort(), 10)
4303  >>> is_K(a)
4304  True
4305  >>> a = Array('a', IntSort(), IntSort())
4306  >>> is_K(a)
4307  False
4308  """
4309  return is_app_of(a, Z3_OP_CONST_ARRAY)
4310 
def is_K(a)
Definition: z3py.py:4299
def is_app_of(a, k)
Definition: z3py.py:1226

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

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

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

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

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

4311 def is_map(a):
4312  """Return `True` if `a` is a Z3 map array expression.
4313 
4314  >>> f = Function('f', IntSort(), IntSort())
4315  >>> b = Array('b', IntSort(), IntSort())
4316  >>> a = Map(f, b)
4317  >>> a
4318  Map(f, b)
4319  >>> is_map(a)
4320  True
4321  >>> is_map(b)
4322  False
4323  """
4324  return is_app_of(a, Z3_OP_ARRAY_MAP)
4325 
def is_map(a)
Definition: z3py.py:4311
def is_app_of(a, k)
Definition: z3py.py:1226

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

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

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

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

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

1492 def is_not(a):
1493  """Return `True` if `a` is a Z3 not expression.
1494 
1495  >>> p = Bool('p')
1496  >>> is_not(p)
1497  False
1498  >>> is_not(Not(p))
1499  True
1500  """
1501  return is_app_of(a, Z3_OP_NOT)
1502 
def is_not(a)
Definition: z3py.py:1492
def is_app_of(a, k)
Definition: z3py.py:1226

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

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

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

Referenced by MultiPattern().

1751 def is_pattern(a):
1752  """Return `True` if `a` is a Z3 pattern (hint for quantifier instantiation.
1753 
1754  >>> f = Function('f', IntSort(), IntSort())
1755  >>> x = Int('x')
1756  >>> q = ForAll(x, f(x) == 0, patterns = [ f(x) ])
1757  >>> q
1758  ForAll(x, f(x) == 0)
1759  >>> q.num_patterns()
1760  1
1761  >>> is_pattern(q.pattern(0))
1762  True
1763  >>> q.pattern(0)
1764  f(Var(0))
1765  """
1766  return isinstance(a, PatternRef)
1767 
def is_pattern(a)
Definition: z3py.py:1751

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

Referenced by eq().

8029 def is_probe(p):
8030  """Return `True` if `p` is a Z3 probe.
8031 
8032  >>> is_probe(Int('x'))
8033  False
8034  >>> is_probe(Probe('memory'))
8035  True
8036  """
8037  return isinstance(p, Probe)
8038 
def is_probe(p)
Definition: z3py.py:8029

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

Referenced by Exists().

1980 def is_quantifier(a):
1981  """Return `True` if `a` is a Z3 quantifier.
1982 
1983  >>> f = Function('f', IntSort(), IntSort())
1984  >>> x = Int('x')
1985  >>> q = ForAll(x, f(x) == 0)
1986  >>> is_quantifier(q)
1987  True
1988  >>> is_quantifier(f(x))
1989  False
1990  """
1991  return isinstance(a, QuantifierRef)
1992 
def is_quantifier(a)
Definition: z3py.py:1980

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

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

2545 def is_rational_value(a):
2546  """Return `True` if `a` is rational value of sort Real.
2547 
2548  >>> is_rational_value(RealVal(1))
2549  True
2550  >>> is_rational_value(RealVal("3/5"))
2551  True
2552  >>> is_rational_value(IntVal(1))
2553  False
2554  >>> is_rational_value(1)
2555  False
2556  >>> n = Real('x') + 1
2557  >>> n.arg(1)
2558  1
2559  >>> is_rational_value(n.arg(1))
2560  True
2561  >>> is_rational_value(Real('x'))
2562  False
2563  """
2564  return is_arith(a) and a.is_real() and _is_numeral(a.ctx, a.as_ast())
2565 
def is_arith(a)
Definition: z3py.py:2460
def is_rational_value(a)
Definition: z3py.py:2545

◆ is_re()

def z3py.is_re (   s)

Definition at line 10260 of file z3py.py.

10260 def is_re(s):
10261  return isinstance(s, ReRef)
10262 
10263 
def is_re(s)
Definition: z3py.py:10260

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

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

2498 def is_real(a):
2499  """Return `True` if `a` is a real expression.
2500 
2501  >>> x = Int('x')
2502  >>> is_real(x + 1)
2503  False
2504  >>> y = Real('y')
2505  >>> is_real(y)
2506  True
2507  >>> is_real(y + 1)
2508  True
2509  >>> is_real(1)
2510  False
2511  >>> is_real(RealVal(1))
2512  True
2513  """
2514  return is_arith(a) and a.is_real()
2515 
def is_real(a)
Definition: z3py.py:2498
def is_arith(a)
Definition: z3py.py:2460

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

4518 def is_select(a):
4519  """Return `True` if `a` is a Z3 array select application.
4520 
4521  >>> a = Array('a', IntSort(), IntSort())
4522  >>> is_select(a)
4523  False
4524  >>> i = Int('i')
4525  >>> is_select(a[i])
4526  True
4527  """
4528  return is_app_of(a, Z3_OP_SELECT)
4529 
def is_select(a)
Definition: z3py.py:4518
def is_app_of(a, k)
Definition: z3py.py:1226

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

10012 def is_seq(a):
10013  """Return `True` if `a` is a Z3 sequence expression.
10014  >>> print (is_seq(Unit(IntVal(0))))
10015  True
10016  >>> print (is_seq(StringVal("abc")))
10017  True
10018  """
10019  return isinstance(a, SeqRef)
10020 
def is_seq(a)
Definition: z3py.py:10012

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

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

586 def is_sort(s):
587  """Return `True` if `s` is a Z3 sort.
588 
589  >>> is_sort(IntSort())
590  True
591  >>> is_sort(Int('x'))
592  False
593  >>> is_expr(Int('x'))
594  True
595  """
596  return isinstance(s, SortRef)
597 
def is_sort(s)
Definition: z3py.py:586

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

4530 def is_store(a):
4531  """Return `True` if `a` is a Z3 array store application.
4532 
4533  >>> a = Array('a', IntSort(), IntSort())
4534  >>> is_store(a)
4535  False
4536  >>> is_store(Store(a, 0, 1))
4537  True
4538  """
4539  return is_app_of(a, Z3_OP_STORE)
4540 
def is_store(a)
Definition: z3py.py:4530
def is_app_of(a, k)
Definition: z3py.py:1226

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

10021 def is_string(a):
10022  """Return `True` if `a` is a Z3 string expression.
10023  >>> print (is_string(StringVal("ab")))
10024  True
10025  """
10026  return isinstance(a, SeqRef) and a.is_string()
10027 
def is_string(a)
Definition: z3py.py:10021

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

10028 def is_string_value(a):
10029  """return 'True' if 'a' is a Z3 string constant expression.
10030  >>> print (is_string_value(StringVal("a")))
10031  True
10032  >>> print (is_string_value(StringVal("a") + StringVal("b")))
10033  False
10034  """
10035  return isinstance(a, SeqRef) and a.is_string_value()
10036 
10037 
def is_string_value(a)
Definition: z3py.py:10028

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

2601 def is_sub(a):
2602  """Return `True` if `a` is an expression of the form b - c.
2603 
2604  >>> x, y = Ints('x y')
2605  >>> is_sub(x - y)
2606  True
2607  >>> is_sub(x + y)
2608  False
2609  """
2610  return is_app_of(a, Z3_OP_SUB)
2611 
def is_app_of(a, k)
Definition: z3py.py:1226
def is_sub(a)
Definition: z3py.py:2601

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

2719 def is_to_int(a):
2720  """Return `True` if `a` is an expression of the form ToInt(b).
2721 
2722  >>> x = Real('x')
2723  >>> n = ToInt(x)
2724  >>> n
2725  ToInt(x)
2726  >>> is_to_int(n)
2727  True
2728  >>> is_to_int(x)
2729  False
2730  """
2731  return is_app_of(a, Z3_OP_TO_INT)
2732 
def is_app_of(a, k)
Definition: z3py.py:1226
def is_to_int(a)
Definition: z3py.py:2719

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

2705 def is_to_real(a):
2706  """Return `True` if `a` is an expression of the form ToReal(b).
2707 
2708  >>> x = Int('x')
2709  >>> n = ToReal(x)
2710  >>> n
2711  ToReal(x)
2712  >>> is_to_real(n)
2713  True
2714  >>> is_to_real(x)
2715  False
2716  """
2717  return is_app_of(a, Z3_OP_TO_REAL)
2718 
def is_to_real(a)
Definition: z3py.py:2705
def is_app_of(a, k)
Definition: z3py.py:1226

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

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

1429 def is_true(a):
1430  """Return `True` if `a` is the Z3 true expression.
1431 
1432  >>> p = Bool('p')
1433  >>> is_true(p)
1434  False
1435  >>> is_true(simplify(p == p))
1436  True
1437  >>> x = Real('x')
1438  >>> is_true(x == 0)
1439  False
1440  >>> # True is a Python Boolean expression
1441  >>> is_true(True)
1442  False
1443  """
1444  return is_app_of(a, Z3_OP_TRUE)
1445 
def is_true(a)
Definition: z3py.py:1429
def is_app_of(a, k)
Definition: z3py.py:1226

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

Referenced by get_var_index().

1170 def is_var(a):
1171  """Return `True` if `a` is variable.
1172 
1173  Z3 uses de-Bruijn indices for representing bound variables in
1174  quantifiers.
1175 
1176  >>> x = Int('x')
1177  >>> is_var(x)
1178  False
1179  >>> is_const(x)
1180  True
1181  >>> f = Function('f', IntSort(), IntSort())
1182  >>> # Z3 replaces x with bound variables when ForAll is executed.
1183  >>> q = ForAll(x, f(x) == x)
1184  >>> b = q.body()
1185  >>> b
1186  f(Var(0)) == Var(0)
1187  >>> b.arg(1)
1188  Var(0)
1189  >>> is_var(b.arg(1))
1190  True
1191  """
1192  return is_expr(a) and _ast_kind(a.ctx, a) == Z3_VAR_AST
1193 
def is_expr(a)
Definition: z3py.py:1105
def is_var(a)
Definition: z3py.py:1170

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

Referenced by is_is_int().

3127 def IsInt(a):
3128  """ Return the Z3 predicate IsInt(a).
3129 
3130  >>> x = Real('x')
3131  >>> IsInt(x + "1/2")
3132  IsInt(x + 1/2)
3133  >>> solve(IsInt(x + "1/2"), x > 0, x < 1)
3134  [x = 1/2]
3135  >>> solve(IsInt(x + "1/2"), x > 0, x < 1, x != "1/2")
3136  no solution
3137  """
3138  if z3_debug():
3139  _z3_assert(a.is_real(), "Z3 real expression expected.")
3140  ctx = a.ctx
3141  return BoolRef(Z3_mk_is_int(ctx.ref(), a.as_ast()), ctx)
3142 
def IsInt(a)
Definition: z3py.py:3127
Z3_ast Z3_API Z3_mk_is_int(Z3_context c, Z3_ast t1)
Check if a real number is an integer.
def z3_debug()
Definition: z3py.py:58

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

4631 def IsMember(e, s):
4632  """ Check if e is a member of set s
4633  >>> a = Const('a', SetSort(IntSort()))
4634  >>> IsMember(1, a)
4635  a[1]
4636  """
4637  ctx = _ctx_from_ast_arg_list([s,e])
4638  e = _py2expr(e, ctx)
4639  return BoolRef(Z3_mk_set_member(ctx.ref(), e.as_ast(), s.as_ast()), ctx)
4640 
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:4631

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

4641 def IsSubset(a, b):
4642  """ Check if a is a subset of b
4643  >>> a = Const('a', SetSort(IntSort()))
4644  >>> b = Const('b', SetSort(IntSort()))
4645  >>> IsSubset(a, b)
4646  subset(a, b)
4647  """
4648  ctx = _ctx_from_ast_arg_list([a, b])
4649  return BoolRef(Z3_mk_set_subset(ctx.ref(), a.as_ast(), b.as_ast()), ctx)
4650 
4651 
def IsSubset(a, b)
Definition: z3py.py:4641
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 4481 of file z3py.py.

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

4481 def K(dom, v):
4482  """Return a Z3 constant array expression.
4483 
4484  >>> a = K(IntSort(), 10)
4485  >>> a
4486  K(Int, 10)
4487  >>> a.sort()
4488  Array(Int, Int)
4489  >>> i = Int('i')
4490  >>> a[i]
4491  K(Int, 10)[i]
4492  >>> simplify(a[i])
4493  10
4494  """
4495  if z3_debug():
4496  _z3_assert(is_sort(dom), "Z3 sort expected")
4497  ctx = dom.ctx
4498  if not is_expr(v):
4499  v = _py2expr(v, ctx)
4500  return ArrayRef(Z3_mk_const_array(ctx.ref(), dom.ast, v.as_ast()), ctx)
4501 
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:586
def z3_debug()
Definition: z3py.py:58
def K(dom, v)
Definition: z3py.py:4481
def is_expr(a)
Definition: z3py.py:1105

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

Referenced by QuantifierRef.is_lambda().

2064 def Lambda(vs, body):
2065  """Create a Z3 lambda expression.
2066 
2067  >>> f = Function('f', IntSort(), IntSort(), IntSort())
2068  >>> mem0 = Array('mem0', IntSort(), IntSort())
2069  >>> lo, hi, e, i = Ints('lo hi e i')
2070  >>> mem1 = Lambda([i], If(And(lo <= i, i <= hi), e, mem0[i]))
2071  >>> mem1
2072  Lambda(i, If(And(lo <= i, i <= hi), e, mem0[i]))
2073  """
2074  ctx = body.ctx
2075  if is_app(vs):
2076  vs = [vs]
2077  num_vars = len(vs)
2078  _vs = (Ast * num_vars)()
2079  for i in range(num_vars):
2080 
2081  _vs[i] = vs[i].as_ast()
2082  return QuantifierRef(Z3_mk_lambda_const(ctx.ref(), num_vars, _vs, body.as_ast()), ctx)
2083 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3358
def is_app(a)
Definition: z3py.py:1127
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:2064

◆ LastIndexOf()

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

Definition at line 10184 of file z3py.py.

10184 def LastIndexOf(s, substr):
10185  """Retrieve the last index of substring within a string"""
10186  ctx = None
10187  ctx = _get_ctx2(s, substr, ctx)
10188  s = _coerce_seq(s, ctx)
10189  substr = _coerce_seq(substr, ctx)
10190  return ArithRef(Z3_mk_seq_last_index(s.ctx_ref(), s.as_ast(), substr.as_ast()), s.ctx)
10191 
10192 
def LastIndexOf(s, substr)
Definition: z3py.py:10184
Z3_ast Z3_API Z3_mk_seq_last_index(Z3_context c, Z3_ast, Z3_ast substr)
Return the last occurrence of substr in s. If s does not contain substr, then the value is -1...

◆ Length()

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

Definition at line 10193 of file z3py.py.

10193 def Length(s):
10194  """Obtain the length of a sequence 's'
10195  >>> l = Length(StringVal("abc"))
10196  >>> simplify(l)
10197  3
10198  """
10199  s = _coerce_seq(s)
10200  return ArithRef(Z3_mk_seq_length(s.ctx_ref(), s.as_ast()), s.ctx)
10201 
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:10193

◆ LinearOrder()

def z3py.LinearOrder (   a,
  index 
)

Definition at line 10382 of file z3py.py.

10382 def LinearOrder(a, index):
10383  return FuncDeclRef(Z3_mk_linear_order(a.ctx_ref(), a.ast, index), a.ctx);
10384 
def LinearOrder(a, index)
Definition: z3py.py:10382
Z3_func_decl Z3_API Z3_mk_linear_order(Z3_context c, Z3_sort a, unsigned id)
declare a and b are in linear order over a relation indexed by id.

◆ Loop()

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

Definition at line 10353 of file z3py.py.

10353 def Loop(re, lo, hi=0):
10354  """Create the regular expression accepting between a lower and upper bound repetitions
10355  >>> re = Loop(Re("a"), 1, 3)
10356  >>> print(simplify(InRe("aa", re)))
10357  True
10358  >>> print(simplify(InRe("aaaa", re)))
10359  False
10360  >>> print(simplify(InRe("", re)))
10361  False
10362  """
10363  return ReRef(Z3_mk_re_loop(re.ctx_ref(), re.as_ast(), lo, hi), re.ctx)
10364 
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:10353

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

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

3996 def LShR(a, b):
3997  """Create the Z3 expression logical right shift.
3998 
3999  Use the operator >> for the arithmetical right shift.
4000 
4001  >>> x, y = BitVecs('x y', 32)
4002  >>> LShR(x, y)
4003  LShR(x, y)
4004  >>> (x >> y).sexpr()
4005  '(bvashr x y)'
4006  >>> LShR(x, y).sexpr()
4007  '(bvlshr x y)'
4008  >>> BitVecVal(4, 3)
4009  4
4010  >>> BitVecVal(4, 3).as_signed_long()
4011  -4
4012  >>> simplify(BitVecVal(4, 3) >> 1).as_signed_long()
4013  -2
4014  >>> simplify(BitVecVal(4, 3) >> 1)
4015  6
4016  >>> simplify(LShR(BitVecVal(4, 3), 1))
4017  2
4018  >>> simplify(BitVecVal(2, 3) >> 1)
4019  1
4020  >>> simplify(LShR(BitVecVal(2, 3), 1))
4021  1
4022  """
4023  _check_bv_args(a, b)
4024  a, b = _coerce_exprs(a, b)
4025  return BitVecRef(Z3_mk_bvlshr(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4026 
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:3996

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

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

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

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

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

4459 def Map(f, *args):
4460  """Return a Z3 map array expression.
4461 
4462  >>> f = Function('f', IntSort(), IntSort(), IntSort())
4463  >>> a1 = Array('a1', IntSort(), IntSort())
4464  >>> a2 = Array('a2', IntSort(), IntSort())
4465  >>> b = Map(f, a1, a2)
4466  >>> b
4467  Map(f, a1, a2)
4468  >>> prove(b[0] == f(a1[0], a2[0]))
4469  proved
4470  """
4471  args = _get_args(args)
4472  if z3_debug():
4473  _z3_assert(len(args) > 0, "At least one Z3 array expression expected")
4474  _z3_assert(is_func_decl(f), "First argument must be a Z3 function declaration")
4475  _z3_assert(all([is_array(a) for a in args]), "Z3 array expected expected")
4476  _z3_assert(len(args) == f.arity(), "Number of arguments mismatch")
4477  _args, sz = _to_ast_array(args)
4478  ctx = f.ctx
4479  return ArrayRef(Z3_mk_map(ctx.ref(), f.ast, sz, _args), ctx)
4480 
def is_array(a)
Definition: z3py.py:4274
def z3_debug()
Definition: z3py.py:58
def Map(f, args)
Definition: z3py.py:4459
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:777

◆ mk_not()

def z3py.mk_not (   a)

Definition at line 1659 of file z3py.py.

1659 def mk_not(a):
1660  if is_not(a):
1661  return a.arg(0)
1662  else:
1663  return Not(a)
1664 
def mk_not(a)
Definition: z3py.py:1659
def is_not(a)
Definition: z3py.py:1492
def Not(a, ctx=None)
Definition: z3py.py:1641

◆ Model()

def z3py.Model (   ctx = None)

Definition at line 6216 of file z3py.py.

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

6216 def Model(ctx = None):
6217  ctx = _get_ctx(ctx)
6218  return ModelRef(Z3_mk_model(ctx.ref()), ctx)
6219 
def Model(ctx=None)
Definition: z3py.py:6216
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 1768 of file z3py.py.

1768 def MultiPattern(*args):
1769  """Create a Z3 multi-pattern using the given expressions `*args`
1770 
1771  >>> f = Function('f', IntSort(), IntSort())
1772  >>> g = Function('g', IntSort(), IntSort())
1773  >>> x = Int('x')
1774  >>> q = ForAll(x, f(x) != g(x), patterns = [ MultiPattern(f(x), g(x)) ])
1775  >>> q
1776  ForAll(x, f(x) != g(x))
1777  >>> q.num_patterns()
1778  1
1779  >>> is_pattern(q.pattern(0))
1780  True
1781  >>> q.pattern(0)
1782  MultiPattern(f(Var(0)), g(Var(0)))
1783  """
1784  if z3_debug():
1785  _z3_assert(len(args) > 0, "At least one argument expected")
1786  _z3_assert(all([ is_expr(a) for a in args ]), "Z3 expressions expected")
1787  ctx = args[0].ctx
1788  args, sz = _to_ast_array(args)
1789  return PatternRef(Z3_mk_pattern(ctx.ref(), sz, args), ctx)
1790 
def z3_debug()
Definition: z3py.py:58
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:1768
def is_expr(a)
Definition: z3py.py:1105

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

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

1641 def Not(a, ctx=None):
1642  """Create a Z3 not expression or probe.
1643 
1644  >>> p = Bool('p')
1645  >>> Not(Not(p))
1646  Not(Not(p))
1647  >>> simplify(Not(Not(p)))
1648  p
1649  """
1650  ctx = _get_ctx(_ctx_from_ast_arg_list([a], ctx))
1651  if is_probe(a):
1652  # Not is also used to build probes
1653  return Probe(Z3_probe_not(ctx.ref(), a.probe), ctx)
1654  else:
1655  s = BoolSort(ctx)
1656  a = s.cast(a)
1657  return BoolRef(Z3_mk_not(ctx.ref(), a.as_ast()), ctx)
1658 
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:1641
def is_probe(p)
Definition: z3py.py:8029
def BoolSort(ctx=None)
Definition: z3py.py:1523

◆ open_log()

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

Definition at line 103 of file z3py.py.

103 def open_log(fname):
104  """Log interaction to a file. This function must be invoked immediately after init(). """
105  Z3_open_log(fname)
106 
def open_log(fname)
Definition: z3py.py:103
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 10325 of file z3py.py.

10325 def Option(re):
10326  """Create the regular expression that optionally accepts the argument.
10327  >>> re = Option(Re("a"))
10328  >>> print(simplify(InRe("a", re)))
10329  True
10330  >>> print(simplify(InRe("", re)))
10331  True
10332  >>> print(simplify(InRe("aa", re)))
10333  False
10334  """
10335  return ReRef(Z3_mk_re_option(re.ctx_ref(), re.as_ast()), re.ctx)
10336 
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:10325

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

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

1705 def Or(*args):
1706  """Create a Z3 or-expression or or-probe.
1707 
1708  >>> p, q, r = Bools('p q r')
1709  >>> Or(p, q, r)
1710  Or(p, q, r)
1711  >>> P = BoolVector('p', 5)
1712  >>> Or(P)
1713  Or(p__0, p__1, p__2, p__3, p__4)
1714  """
1715  last_arg = None
1716  if len(args) > 0:
1717  last_arg = args[len(args)-1]
1718  if isinstance(last_arg, Context):
1719  ctx = args[len(args)-1]
1720  args = args[:len(args)-1]
1721  else:
1722  ctx = main_ctx()
1723  args = _get_args(args)
1724  ctx_args = _ctx_from_ast_arg_list(args, ctx)
1725  if z3_debug():
1726  _z3_assert(ctx_args is None or ctx_args == ctx, "context mismatch")
1727  _z3_assert(ctx is not None, "At least one of the arguments must be a Z3 expression or probe")
1728  if _has_probe(args):
1729  return _probe_or(args, ctx)
1730  else:
1731  args = _coerce_expr_list(args, ctx)
1732  _args, sz = _to_ast_array(args)
1733  return BoolRef(Z3_mk_or(ctx.ref(), sz, _args), ctx)
1734 
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:213
def Or(args)
Definition: z3py.py:1705
def z3_debug()
Definition: z3py.py:58

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

7745 def OrElse(*ts, **ks):
7746  """Return a tactic that applies the tactics in `*ts` until one of them succeeds (it doesn't fail).
7747 
7748  >>> x = Int('x')
7749  >>> t = OrElse(Tactic('split-clause'), Tactic('skip'))
7750  >>> # Tactic split-clause fails if there is no clause in the given goal.
7751  >>> t(x == 0)
7752  [[x == 0]]
7753  >>> t(Or(x == 0, x == 1))
7754  [[x == 0], [x == 1]]
7755  """
7756  if z3_debug():
7757  _z3_assert(len(ts) >= 2, "At least two arguments expected")
7758  ctx = ks.get('ctx', None)
7759  num = len(ts)
7760  r = ts[0]
7761  for i in range(num - 1):
7762  r = _or_else(r, ts[i+1], ctx)
7763  return r
7764 
def OrElse(ts, ks)
Definition: z3py.py:7745
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3358
def z3_debug()
Definition: z3py.py:58

◆ ParAndThen()

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

Definition at line 7797 of file z3py.py.

7797 def ParAndThen(t1, t2, ctx=None):
7798  """Alias for ParThen(t1, t2, ctx)."""
7799  return ParThen(t1, t2, ctx)
7800 
def ParAndThen(t1, t2, ctx=None)
Definition: z3py.py:7797
def ParThen(t1, t2, ctx=None)
Definition: z3py.py:7783

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

7765 def ParOr(*ts, **ks):
7766  """Return a tactic that applies the tactics in `*ts` in parallel until one of them succeeds (it doesn't fail).
7767 
7768  >>> x = Int('x')
7769  >>> t = ParOr(Tactic('simplify'), Tactic('fail'))
7770  >>> t(x + 1 == 2)
7771  [[x == 1]]
7772  """
7773  if z3_debug():
7774  _z3_assert(len(ts) >= 2, "At least two arguments expected")
7775  ctx = _get_ctx(ks.get('ctx', None))
7776  ts = [ _to_tactic(t, ctx) for t in ts ]
7777  sz = len(ts)
7778  _args = (TacticObj * sz)()
7779  for i in range(sz):
7780  _args[i] = ts[i].tactic
7781  return Tactic(Z3_tactic_par_or(ctx.ref(), sz, _args), ctx)
7782 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3358
def z3_debug()
Definition: z3py.py:58
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:7765

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

8564 def parse_smt2_file(f, sorts={}, decls={}, ctx=None):
8565  """Parse a file in SMT 2.0 format using the given sorts and decls.
8566 
8567  This function is similar to parse_smt2_string().
8568  """
8569  ctx = _get_ctx(ctx)
8570  ssz, snames, ssorts = _dict2sarray(sorts, ctx)
8571  dsz, dnames, ddecls = _dict2darray(decls, ctx)
8572  return AstVector(Z3_parse_smtlib2_file(ctx.ref(), f, ssz, snames, ssorts, dsz, dnames, ddecls), ctx)
8573 
8574 
def parse_smt2_file(f, sorts={}, decls={}, ctx=None)
Definition: z3py.py:8564
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 8544 of file z3py.py.

Referenced by parse_smt2_file().

8544 def parse_smt2_string(s, sorts={}, decls={}, ctx=None):
8545  """Parse a string in SMT 2.0 format using the given sorts and decls.
8546 
8547  The arguments sorts and decls are Python dictionaries used to initialize
8548  the symbol table used for the SMT 2.0 parser.
8549 
8550  >>> parse_smt2_string('(declare-const x Int) (assert (> x 0)) (assert (< x 10))')
8551  [x > 0, x < 10]
8552  >>> x, y = Ints('x y')
8553  >>> f = Function('f', IntSort(), IntSort())
8554  >>> parse_smt2_string('(assert (> (+ foo (g bar)) 0))', decls={ 'foo' : x, 'bar' : y, 'g' : f})
8555  [x + f(y) > 0]
8556  >>> parse_smt2_string('(declare-const a U) (assert (> a 0))', sorts={ 'U' : IntSort() }) [a > 0]
8557  """
8558  ctx = _get_ctx(ctx)
8559  ssz, snames, ssorts = _dict2sarray(sorts, ctx)
8560  dsz, dnames, ddecls = _dict2darray(decls, ctx)
8561  return AstVector(Z3_parse_smtlib2_string(ctx.ref(), s, ssz, snames, ssorts, dsz, dnames, ddecls), ctx)
8562 
8563 
def parse_smt2_string(s, sorts={}, decls={}, ctx=None)
Definition: z3py.py:8544

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

Referenced by ParAndThen().

7783 def ParThen(t1, t2, ctx=None):
7784  """Return a tactic that applies t1 and then t2 to every subgoal produced by t1. The subgoals are processed in parallel.
7785 
7786  >>> x, y = Ints('x y')
7787  >>> t = ParThen(Tactic('split-clause'), Tactic('propagate-values'))
7788  >>> t(And(Or(x == 1, x == 2), y == x + 1))
7789  [[x == 1, y == 2], [x == 2, y == 3]]
7790  """
7791  t1 = _to_tactic(t1, ctx)
7792  t2 = _to_tactic(t2, ctx)
7793  if z3_debug():
7794  _z3_assert(t1.ctx == t2.ctx, "Context mismatch")
7795  return Tactic(Z3_tactic_par_and_then(t1.ctx.ref(), t1.tactic, t2.tactic), t1.ctx)
7796 
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 z3_debug()
Definition: z3py.py:58
def ParThen(t1, t2, ctx=None)
Definition: z3py.py:7783

◆ PartialOrder()

def z3py.PartialOrder (   a,
  index 
)

Definition at line 10379 of file z3py.py.

10379 def PartialOrder(a, index):
10380  return FuncDeclRef(Z3_mk_partial_order(a.ctx_ref(), a.ast, index), a.ctx);
10381 
Z3_func_decl Z3_API Z3_mk_partial_order(Z3_context c, Z3_sort a, unsigned id)
create a partial ordering relation over signature a and index id.
def PartialOrder(a, index)
Definition: z3py.py:10379

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

8351 def PbEq(args, k, ctx = None):
8352  """Create a Pseudo-Boolean inequality k constraint.
8353 
8354  >>> a, b, c = Bools('a b c')
8355  >>> f = PbEq(((a,1),(b,3),(c,2)), 3)
8356  """
8357  _z3_check_cint_overflow(k, "k")
8358  ctx, sz, _args, _coeffs = _pb_args_coeffs(args)
8359  return BoolRef(Z3_mk_pbeq(ctx.ref(), sz, _args, _coeffs, k), ctx)
8360 
8361 
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:8351

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

8341 def PbGe(args, k):
8342  """Create a Pseudo-Boolean inequality k constraint.
8343 
8344  >>> a, b, c = Bools('a b c')
8345  >>> f = PbGe(((a,1),(b,3),(c,2)), 3)
8346  """
8347  _z3_check_cint_overflow(k, "k")
8348  ctx, sz, _args, _coeffs = _pb_args_coeffs(args)
8349  return BoolRef(Z3_mk_pbge(ctx.ref(), sz, _args, _coeffs, k), ctx)
8350 
def PbGe(args, k)
Definition: z3py.py:8341
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 8331 of file z3py.py.

8331 def PbLe(args, k):
8332  """Create a Pseudo-Boolean inequality k constraint.
8333 
8334  >>> a, b, c = Bools('a b c')
8335  >>> f = PbLe(((a,1),(b,3),(c,2)), 3)
8336  """
8337  _z3_check_cint_overflow(k, "k")
8338  ctx, sz, _args, _coeffs = _pb_args_coeffs(args)
8339  return BoolRef(Z3_mk_pble(ctx.ref(), sz, _args, _coeffs, k), ctx)
8340 
def PbLe(args, k)
Definition: z3py.py:8331
Z3_ast Z3_API Z3_mk_pble(Z3_context c, unsigned num_args, Z3_ast const args[], int const coeffs[], int k)
Pseudo-Boolean relations.

◆ PiecewiseLinearOrder()

def z3py.PiecewiseLinearOrder (   a,
  index 
)

Definition at line 10388 of file z3py.py.

10388 def PiecewiseLinearOrder(a, index):
10389  return FuncDeclRef(Z3_mk_piecewise_linear_order(a.ctx_ref(), a.ast, index), a.ctx);
10390 
Z3_func_decl Z3_API Z3_mk_piecewise_linear_order(Z3_context c, Z3_sort a, unsigned id)
create a piecewise linear ordering relation over signature a and index id.
def PiecewiseLinearOrder(a, index)
Definition: z3py.py:10388

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

10313 def Plus(re):
10314  """Create the regular expression accepting one or more repetitions of argument.
10315  >>> re = Plus(Re("a"))
10316  >>> print(simplify(InRe("aa", re)))
10317  True
10318  >>> print(simplify(InRe("ab", re)))
10319  False
10320  >>> print(simplify(InRe("", re)))
10321  False
10322  """
10323  return ReRef(Z3_mk_re_plus(re.ctx_ref(), re.as_ast()), re.ctx)
10324 
def Plus(re)
Definition: z3py.py:10313
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 10103 of file z3py.py.

10103 def PrefixOf(a, b):
10104  """Check if 'a' is a prefix of 'b'
10105  >>> s1 = PrefixOf("ab", "abc")
10106  >>> simplify(s1)
10107  True
10108  >>> s2 = PrefixOf("bc", "abc")
10109  >>> simplify(s2)
10110  False
10111  """
10112  ctx = _get_ctx2(a, b)
10113  a = _coerce_seq(a, ctx)
10114  b = _coerce_seq(b, ctx)
10115  return BoolRef(Z3_mk_seq_prefix(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
10116 
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:10103

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

Referenced by describe_probes().

8055 def probe_description(name, ctx=None):
8056  """Return a short description for the probe named `name`.
8057 
8058  >>> d = probe_description('memory')
8059  """
8060  ctx = _get_ctx(ctx)
8061  return Z3_probe_get_descr(ctx.ref(), name)
8062 
def probe_description(name, ctx=None)
Definition: z3py.py:8055
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 8045 of file z3py.py.

Referenced by describe_probes().

8045 def probes(ctx=None):
8046  """Return a list of all available probes in Z3.
8047 
8048  >>> l = probes()
8049  >>> l.count('memory') == 1
8050  True
8051  """
8052  ctx = _get_ctx(ctx)
8053  return [ Z3_get_probe_name(ctx.ref(), i) for i in range(Z3_get_num_probes(ctx.ref())) ]
8054 
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:3358
def probes(ctx=None)
Definition: z3py.py:8045
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 8253 of file z3py.py.

Referenced by BitVecs().

8253 def Product(*args):
8254  """Create the product of the Z3 expressions.
8255 
8256  >>> a, b, c = Ints('a b c')
8257  >>> Product(a, b, c)
8258  a*b*c
8259  >>> Product([a, b, c])
8260  a*b*c
8261  >>> A = IntVector('a', 5)
8262  >>> Product(A)
8263  a__0*a__1*a__2*a__3*a__4
8264  """
8265  args = _get_args(args)
8266  if len(args) == 0:
8267  return 1
8268  ctx = _ctx_from_ast_arg_list(args)
8269  if ctx is None:
8270  return _reduce(lambda a, b: a * b, args, 1)
8271  args = _coerce_expr_list(args, ctx)
8272  if is_bv(args[0]):
8273  return _reduce(lambda a, b: a * b, args, 1)
8274  else:
8275  _args, sz = _to_ast_array(args)
8276  return ArithRef(Z3_mk_mul(ctx.ref(), sz, _args), ctx)
8277 
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:8253
def is_bv(a)
Definition: z3py.py:3666

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

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

8419 def prove(claim, **keywords):
8420  """Try to prove the given claim.
8421 
8422  This is a simple function for creating demonstrations. It tries to prove
8423  `claim` by showing the negation is unsatisfiable.
8424 
8425  >>> p, q = Bools('p q')
8426  >>> prove(Not(And(p, q)) == Or(Not(p), Not(q)))
8427  proved
8428  """
8429  if z3_debug():
8430  _z3_assert(is_bool(claim), "Z3 Boolean expression expected")
8431  s = Solver()
8432  s.set(**keywords)
8433  s.add(Not(claim))
8434  if keywords.get('show', False):
8435  print(s)
8436  r = s.check()
8437  if r == unsat:
8438  print("proved")
8439  elif r == unknown:
8440  print("failed to prove")
8441  print(s.model())
8442  else:
8443  print("counterexample")
8444  print(s.model())
8445 
def prove(claim, keywords)
Definition: z3py.py:8419
def z3_debug()
Definition: z3py.py:58
def Not(a, ctx=None)
Definition: z3py.py:1641
def is_bool(a)
Definition: z3py.py:1412

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

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

2981 def Q(a, b, ctx=None):
2982  """Return a Z3 rational a/b.
2983 
2984  If `ctx=None`, then the global context is used.
2985 
2986  >>> Q(3,5)
2987  3/5
2988  >>> Q(3,5).sort()
2989  Real
2990  """
2991  return simplify(RatVal(a, b))
2992 
def simplify(a, arguments, keywords)
Utils.
Definition: z3py.py:8149
def RatVal(a, b, ctx=None)
Definition: z3py.py:2966
def Q(a, b, ctx=None)
Definition: z3py.py:2981

◆ Range()

def z3py.Range (   lo,
  hi,
  ctx = None 
)
Create the range regular expression over two sequences of length 1
>>> range = Range("a","z")
>>> print(simplify(InRe("b", range)))
True
>>> print(simplify(InRe("bb", range)))
False

Definition at line 10365 of file z3py.py.

10365 def Range(lo, hi, ctx = None):
10366  """Create the range regular expression over two sequences of length 1
10367  >>> range = Range("a","z")
10368  >>> print(simplify(InRe("b", range)))
10369  True
10370  >>> print(simplify(InRe("bb", range)))
10371  False
10372  """
10373  lo = _coerce_seq(lo, ctx)
10374  hi = _coerce_seq(hi, ctx)
10375  return ReRef(Z3_mk_re_range(lo.ctx_ref(), lo.ast, hi.ast), lo.ctx)
10376 
10377 # Special Relations
10378 
def Range(lo, hi, ctx=None)
Definition: z3py.py:10365
Z3_ast Z3_API Z3_mk_re_range(Z3_context c, Z3_ast lo, Z3_ast hi)
Create the range regular expression over two sequences of length 1.

◆ RatVal()

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

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

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

Definition at line 2966 of file z3py.py.

2966 def RatVal(a, b, ctx=None):
2967  """Return a Z3 rational a/b.
2968 
2969  If `ctx=None`, then the global context is used.
2970 
2971  >>> RatVal(3,5)
2972  3/5
2973  >>> RatVal(3,5).sort()
2974  Real
2975  """
2976  if z3_debug():
2977  _z3_assert(_is_int(a) or isinstance(a, str), "First argument cannot be converted into an integer")
2978  _z3_assert(_is_int(b) or isinstance(b, str), "Second argument cannot be converted into an integer")
2979  return simplify(RealVal(a, ctx)/RealVal(b, ctx))
2980 
def simplify(a, arguments, keywords)
Utils.
Definition: z3py.py:8149
def RatVal(a, b, ctx=None)
Definition: z3py.py:2966
def RealVal(val, ctx=None)
Definition: z3py.py:2948
def z3_debug()
Definition: z3py.py:58

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

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

10225 def Re(s, ctx=None):
10226  """The regular expression that accepts sequence 's'
10227  >>> s1 = Re("ab")
10228  >>> s2 = Re(StringVal("ab"))
10229  >>> s3 = Re(Unit(BoolVal(True)))
10230  """
10231  s = _coerce_seq(s, ctx)
10232  return ReRef(Z3_mk_seq_to_re(s.ctx_ref(), s.as_ast()), s.ctx)
10233 
10234 
10235 
10236 
def Re(s, ctx=None)
Definition: z3py.py:10225
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 3041 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().

3041 def Real(name, ctx=None):
3042  """Return a real constant named `name`. If `ctx=None`, then the global context is used.
3043 
3044  >>> x = Real('x')
3045  >>> is_real(x)
3046  True
3047  >>> is_real(x + 1)
3048  True
3049  """
3050  ctx = _get_ctx(ctx)
3051  return ArithRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), RealSort(ctx).ast), ctx)
3052 
def RealSort(ctx=None)
Definition: z3py.py:2906
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:111
def Real(name, ctx=None)
Definition: z3py.py:3041

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

Referenced by is_div().

3053 def Reals(names, ctx=None):
3054  """Return a tuple of real constants.
3055 
3056  >>> x, y, z = Reals('x y z')
3057  >>> Sum(x, y, z)
3058  x + y + z
3059  >>> Sum(x, y, z).sort()
3060  Real
3061  """
3062  ctx = _get_ctx(ctx)
3063  if isinstance(names, str):
3064  names = names.split(" ")
3065  return [Real(name, ctx) for name in names]
3066 
def Real(name, ctx=None)
Definition: z3py.py:3041
def Reals(names, ctx=None)
Definition: z3py.py:3053

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

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

2906 def RealSort(ctx=None):
2907  """Return the real sort in the given context. If `ctx=None`, then the global context is used.
2908 
2909  >>> RealSort()
2910  Real
2911  >>> x = Const('x', RealSort())
2912  >>> is_real(x)
2913  True
2914  >>> is_int(x)
2915  False
2916  >>> x.sort() == RealSort()
2917  True
2918  """
2919  ctx = _get_ctx(ctx)
2920  return ArithSortRef(Z3_mk_real_sort(ctx.ref()), ctx)
2921 
def RealSort(ctx=None)
Definition: z3py.py:2906
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 2948 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().

2948 def RealVal(val, ctx=None):
2949  """Return a Z3 real value.
2950 
2951  `val` may be a Python int, long, float or string representing a number in decimal or rational notation.
2952  If `ctx=None`, then the global context is used.
2953 
2954  >>> RealVal(1)
2955  1
2956  >>> RealVal(1).sort()
2957  Real
2958  >>> RealVal("3/5")
2959  3/5
2960  >>> RealVal("1.5")
2961  3/2
2962  """
2963  ctx = _get_ctx(ctx)
2964  return RatNumRef(Z3_mk_numeral(ctx.ref(), str(val), RealSort(ctx).ast), ctx)
2965 
def RealSort(ctx=None)
Definition: z3py.py:2906
def RealVal(val, ctx=None)
Definition: z3py.py:2948
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 1333 of file z3py.py.

Referenced by RealVarVector().

1333 def RealVar(idx, ctx=None):
1334  """
1335  Create a real free variable. Free variables are used to create quantified formulas.
1336  They are also used to create polynomials.
1337 
1338  >>> RealVar(0)
1339  Var(0)
1340  """
1341  return Var(idx, RealSort(ctx))
1342 
def RealSort(ctx=None)
Definition: z3py.py:2906
def Var(idx, s)
Definition: z3py.py:1321
def RealVar(idx, ctx=None)
Definition: z3py.py:1333

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

1343 def RealVarVector(n, ctx=None):
1344  """
1345  Create a list of Real free variables.
1346  The variables have ids: 0, 1, ..., n-1
1347 
1348  >>> x0, x1, x2, x3 = RealVarVector(4)
1349  >>> x2
1350  Var(2)
1351  """
1352  return [ RealVar(i, ctx) for i in range(n) ]
1353 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3358
def RealVarVector(n, ctx=None)
Definition: z3py.py:1343
def RealVar(idx, ctx=None)
Definition: z3py.py:1333

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

3067 def RealVector(prefix, sz, ctx=None):
3068  """Return a list of real constants of size `sz`.
3069 
3070  >>> X = RealVector('x', 3)
3071  >>> X
3072  [x__0, x__1, x__2]
3073  >>> Sum(X)
3074  x__0 + x__1 + x__2
3075  >>> Sum(X).sort()
3076  Real
3077  """
3078  return [ Real('%s__%s' % (prefix, i)) for i in range(sz) ]
3079 
def RealVector(prefix, sz, ctx=None)
Definition: z3py.py:3067
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3358
def Real(name, ctx=None)
Definition: z3py.py:3041

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

831 def RecAddDefinition(f, args, body):
832  """Set the body of a recursive function.
833  Recursive definitions are only unfolded during search.
834  >>> ctx = Context()
835  >>> fac = RecFunction('fac', IntSort(ctx), IntSort(ctx))
836  >>> n = Int('n', ctx)
837  >>> RecAddDefinition(fac, n, If(n == 0, 1, n*fac(n-1)))
838  >>> simplify(fac(5))
839  fac(5)
840  >>> s = Solver(ctx=ctx)
841  >>> s.add(fac(n) < 3)
842  >>> s.check()
843  sat
844  >>> s.model().eval(fac(5))
845  120
846  """
847  if is_app(args):
848  args = [args]
849  ctx = body.ctx
850  args = _get_args(args)
851  n = len(args)
852  _args = (Ast * n)()
853  for i in range(n):
854  _args[i] = args[i].ast
855  Z3_add_rec_def(ctx.ref(), f.ast, n, _args, body.ast)
856 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3358
def is_app(a)
Definition: z3py.py:1127
def RecAddDefinition(f, args, body)
Definition: z3py.py:831
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 814 of file z3py.py.

814 def RecFunction(name, *sig):
815  """Create a new Z3 recursive with the given sorts."""
816  sig = _get_args(sig)
817  if z3_debug():
818  _z3_assert(len(sig) > 0, "At least two arguments expected")
819  arity = len(sig) - 1
820  rng = sig[arity]
821  if z3_debug():
822  _z3_assert(is_sort(rng), "Z3 sort expected")
823  dom = (Sort * arity)()
824  for i in range(arity):
825  if z3_debug():
826  _z3_assert(is_sort(sig[i]), "Z3 sort expected")
827  dom[i] = sig[i].ast
828  ctx = rng.ctx
829  return FuncDeclRef(Z3_mk_rec_func_decl(ctx.ref(), to_symbol(name, ctx), arity, dom, rng.ast), ctx)
830 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3358
def to_symbol(s, ctx=None)
Definition: z3py.py:111
def RecFunction(name, sig)
Definition: z3py.py:814
def is_sort(s)
Definition: z3py.py:586
def z3_debug()
Definition: z3py.py:58
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 7827 of file z3py.py.

7827 def Repeat(t, max=4294967295, ctx=None):
7828  """Return a tactic that keeps applying `t` until the goal is not modified anymore or the maximum number of iterations `max` is reached.
7829 
7830  >>> x, y = Ints('x y')
7831  >>> c = And(Or(x == 0, x == 1), Or(y == 0, y == 1), x > y)
7832  >>> t = Repeat(OrElse(Tactic('split-clause'), Tactic('skip')))
7833  >>> r = t(c)
7834  >>> for subgoal in r: print(subgoal)
7835  [x == 0, y == 0, x > y]
7836  [x == 0, y == 1, x > y]
7837  [x == 1, y == 0, x > y]
7838  [x == 1, y == 1, x > y]
7839  >>> t = Then(t, Tactic('propagate-values'))
7840  >>> t(c)
7841  [[x == 1, y == 0]]
7842  """
7843  t = _to_tactic(t, ctx)
7844  return Tactic(Z3_tactic_repeat(t.ctx.ref(), t.tactic, max), t.ctx)
7845 
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:7827

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

4113 def RepeatBitVec(n, a):
4114  """Return an expression representing `n` copies of `a`.
4115 
4116  >>> x = BitVec('x', 8)
4117  >>> n = RepeatBitVec(4, x)
4118  >>> n
4119  RepeatBitVec(4, x)
4120  >>> n.size()
4121  32
4122  >>> v0 = BitVecVal(10, 4)
4123  >>> print("%.x" % v0.as_long())
4124  a
4125  >>> v = simplify(RepeatBitVec(4, v0))
4126  >>> v.size()
4127  16
4128  >>> print("%.x" % v.as_long())
4129  aaaa
4130  """
4131  if z3_debug():
4132  _z3_assert(_is_int(n), "First argument must be an integer")
4133  _z3_assert(is_bv(a), "Second argument must be a Z3 Bitvector expression")
4134  return BitVecRef(Z3_mk_repeat(a.ctx_ref(), n, a.as_ast()), a.ctx)
4135 
Z3_ast Z3_API Z3_mk_repeat(Z3_context c, unsigned i, Z3_ast t1)
Repeat the given bit-vector up length i.
def z3_debug()
Definition: z3py.py:58
def is_bv(a)
Definition: z3py.py:3666
def RepeatBitVec(n, a)
Definition: z3py.py:4113

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

10150 def Replace(s, src, dst):
10151  """Replace the first occurrence of 'src' by 'dst' in 's'
10152  >>> r = Replace("aaa", "a", "b")
10153  >>> simplify(r)
10154  "baa"
10155  """
10156  ctx = _get_ctx2(dst, s)
10157  if ctx is None and is_expr(src):
10158  ctx = src.ctx
10159  src = _coerce_seq(src, ctx)
10160  dst = _coerce_seq(dst, ctx)
10161  s = _coerce_seq(s, ctx)
10162  return SeqRef(Z3_mk_seq_replace(src.ctx_ref(), s.as_ast(), src.as_ast(), dst.as_ast()), s.ctx)
10163 
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:10150
def is_expr(a)
Definition: z3py.py:1105

◆ reset_params()

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

Definition at line 262 of file z3py.py.

262 def reset_params():
263  """Reset all global (or module) parameters.
264  """
266 
def reset_params()
Definition: z3py.py:262
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 10245 of file z3py.py.

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

10245 def ReSort(s):
10246  if is_ast(s):
10247  return ReSortRef(Z3_mk_re_sort(s.ctx.ref(), s.ast), s.ctx)
10248  if s is None or isinstance(s, Context):
10249  ctx = _get_ctx(s)
10250  return ReSortRef(Z3_mk_re_sort(ctx.ref(), Z3_mk_string_sort(ctx.ref())), s.ctx)
10251  raise Z3Exception("Regular expression sort constructor expects either a string or a context or no argument")
10252 
10253 
def ReSort(s)
Definition: z3py.py:10245
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:402
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 8954 of file z3py.py.

8954 def RNA (ctx=None):
8955  ctx = _get_ctx(ctx)
8956  return FPRMRef(Z3_mk_fpa_round_nearest_ties_to_away(ctx.ref()), ctx)
8957 
def RNA(ctx=None)
Definition: z3py.py:8954
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 8946 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().

8946 def RNE (ctx=None):
8947  ctx = _get_ctx(ctx)
8948  return FPRMRef(Z3_mk_fpa_round_nearest_ties_to_even(ctx.ref()), ctx)
8949 
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:8946

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

4027 def RotateLeft(a, b):
4028  """Return an expression representing `a` rotated to the left `b` times.
4029 
4030  >>> a, b = BitVecs('a b', 16)
4031  >>> RotateLeft(a, b)
4032  RotateLeft(a, b)
4033  >>> simplify(RotateLeft(a, 0))
4034  a
4035  >>> simplify(RotateLeft(a, 16))
4036  a
4037  """
4038  _check_bv_args(a, b)
4039  a, b = _coerce_exprs(a, b)
4040  return BitVecRef(Z3_mk_ext_rotate_left(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4041 
def RotateLeft(a, b)
Definition: z3py.py:4027
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 4042 of file z3py.py.

4042 def RotateRight(a, b):
4043  """Return an expression representing `a` rotated to the right `b` times.
4044 
4045  >>> a, b = BitVecs('a b', 16)
4046  >>> RotateRight(a, b)
4047  RotateRight(a, b)
4048  >>> simplify(RotateRight(a, 0))
4049  a
4050  >>> simplify(RotateRight(a, 16))
4051  a
4052  """
4053  _check_bv_args(a, b)
4054  a, b = _coerce_exprs(a, b)
4055  return BitVecRef(Z3_mk_ext_rotate_right(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4056 
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:4042

◆ RoundNearestTiesToAway()

def z3py.RoundNearestTiesToAway (   ctx = None)

Definition at line 8950 of file z3py.py.

8950 def RoundNearestTiesToAway(ctx=None):
8951  ctx = _get_ctx(ctx)
8952  return FPRMRef(Z3_mk_fpa_round_nearest_ties_to_away(ctx.ref()), ctx)
8953 
def RoundNearestTiesToAway(ctx=None)
Definition: z3py.py:8950
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 8942 of file z3py.py.

8942 def RoundNearestTiesToEven(ctx=None):
8943  ctx = _get_ctx(ctx)
8944  return FPRMRef(Z3_mk_fpa_round_nearest_ties_to_even(ctx.ref()), ctx)
8945 
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:8942

◆ RoundTowardNegative()

def z3py.RoundTowardNegative (   ctx = None)

Definition at line 8966 of file z3py.py.

8966 def RoundTowardNegative(ctx=None):
8967  ctx = _get_ctx(ctx)
8968  return FPRMRef(Z3_mk_fpa_round_toward_negative(ctx.ref()), ctx)
8969 
def RoundTowardNegative(ctx=None)
Definition: z3py.py:8966
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 8958 of file z3py.py.

8958 def RoundTowardPositive(ctx=None):
8959  ctx = _get_ctx(ctx)
8960  return FPRMRef(Z3_mk_fpa_round_toward_positive(ctx.ref()), ctx)
8961 
def RoundTowardPositive(ctx=None)
Definition: z3py.py:8958
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 8974 of file z3py.py.

8974 def RoundTowardZero(ctx=None):
8975  ctx = _get_ctx(ctx)
8976  return FPRMRef(Z3_mk_fpa_round_toward_zero(ctx.ref()), ctx)
8977 
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:8974

◆ RTN()

def z3py.RTN (   ctx = None)

Definition at line 8970 of file z3py.py.

8970 def RTN(ctx=None):
8971  ctx = _get_ctx(ctx)
8972  return FPRMRef(Z3_mk_fpa_round_toward_negative(ctx.ref()), ctx)
8973 
def RTN(ctx=None)
Definition: z3py.py:8970
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 8962 of file z3py.py.

8962 def RTP(ctx=None):
8963  ctx = _get_ctx(ctx)
8964  return FPRMRef(Z3_mk_fpa_round_toward_positive(ctx.ref()), ctx)
8965 
def RTP(ctx=None)
Definition: z3py.py:8962
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 8978 of file z3py.py.

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

8978 def RTZ(ctx=None):
8979  ctx = _get_ctx(ctx)
8980  return FPRMRef(Z3_mk_fpa_round_toward_zero(ctx.ref()), ctx)
8981 
def RTZ(ctx=None)
Definition: z3py.py:8978
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 4444 of file z3py.py.

4444 def Select(a, i):
4445  """Return a Z3 select array expression.
4446 
4447  >>> a = Array('a', IntSort(), IntSort())
4448  >>> i = Int('i')
4449  >>> Select(a, i)
4450  a[i]
4451  >>> eq(Select(a, i), a[i])
4452  True
4453  """
4454  if z3_debug():
4455  _z3_assert(is_array(a), "First argument must be a Z3 array expression")
4456  return a[i]
4457 
4458 
def is_array(a)
Definition: z3py.py:4274
def z3_debug()
Definition: z3py.py:58
def Select(a, i)
Definition: z3py.py:4444

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

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

9950 def SeqSort(s):
9951  """Create a sequence sort over elements provided in the argument
9952  >>> s = SeqSort(IntSort())
9953  >>> s == Unit(IntVal(1)).sort()
9954  True
9955  """
9956  return SeqSortRef(Z3_mk_seq_sort(s.ctx_ref(), s.ast), s.ctx)
9957 
def SeqSort(s)
Definition: z3py.py:9950
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 8617 of file z3py.py.

8617 def set_default_fp_sort(ebits, sbits, ctx=None):
8618  global _dflt_fpsort_ebits
8619  global _dflt_fpsort_sbits
8620  _dflt_fpsort_ebits = ebits
8621  _dflt_fpsort_sbits = sbits
8622 
def set_default_fp_sort(ebits, sbits, ctx=None)
Definition: z3py.py:8617

◆ set_default_rounding_mode()

def z3py.set_default_rounding_mode (   rm,
  ctx = None 
)

Definition at line 8601 of file z3py.py.

8601 def set_default_rounding_mode(rm, ctx=None):
8602  global _dflt_rounding_mode
8603  if is_fprm_value(rm):
8604  _dflt_rounding_mode = rm.decl().kind()
8605  else:
8606  _z3_assert(_dflt_rounding_mode == Z3_OP_FPA_RM_TOWARD_ZERO or
8607  _dflt_rounding_mode == Z3_OP_FPA_RM_TOWARD_NEGATIVE or
8608  _dflt_rounding_mode == Z3_OP_FPA_RM_TOWARD_POSITIVE or
8609  _dflt_rounding_mode == Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN or
8610  _dflt_rounding_mode == Z3_OP_FPA_RM_NEAREST_TIES_TO_AWAY,
8611  "illegal rounding mode")
8612  _dflt_rounding_mode = rm
8613 
def set_default_rounding_mode(rm, ctx=None)
Definition: z3py.py:8601
def is_fprm_value(a)
Definition: z3py.py:8994

◆ set_option()

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

Definition at line 267 of file z3py.py.

267 def set_option(*args, **kws):
268  """Alias for 'set_param' for backward compatibility.
269  """
270  return set_param(*args, **kws)
271 
def set_option(args, kws)
Definition: z3py.py:267
def set_param(args, kws)
Definition: z3py.py:239

◆ set_param()

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

>>> set_param(precision=10)

Definition at line 239 of file z3py.py.

Referenced by set_option().

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

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

4592 def SetAdd(s, e):
4593  """ Add element e to set s
4594  >>> a = Const('a', SetSort(IntSort()))
4595  >>> SetAdd(a, 1)
4596  Store(a, 1, True)
4597  """
4598  ctx = _ctx_from_ast_arg_list([s,e])
4599  e = _py2expr(e, ctx)
4600  return ArrayRef(Z3_mk_set_add(ctx.ref(), s.as_ast(), e.as_ast()), ctx)
4601 
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:4592

◆ SetComplement()

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

Definition at line 4612 of file z3py.py.

4612 def SetComplement(s):
4613  """ The complement of set s
4614  >>> a = Const('a', SetSort(IntSort()))
4615  >>> SetComplement(a)
4616  complement(a)
4617  """
4618  ctx = s.ctx
4619  return ArrayRef(Z3_mk_set_complement(ctx.ref(), s.as_ast()), ctx)
4620 
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:4612

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

4602 def SetDel(s, e):
4603  """ Remove element e to set s
4604  >>> a = Const('a', SetSort(IntSort()))
4605  >>> SetDel(a, 1)
4606  Store(a, 1, False)
4607  """
4608  ctx = _ctx_from_ast_arg_list([s,e])
4609  e = _py2expr(e, ctx)
4610  return ArrayRef(Z3_mk_set_del(ctx.ref(), s.as_ast(), e.as_ast()), ctx)
4611 
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:4602

◆ SetDifference()

def z3py.SetDifference (   a,
  b 
)
The set difference of a and b
>>> a = Const('a', SetSort(IntSort()))
>>> b = Const('b', SetSort(IntSort()))
>>> SetDifference(a, b)
setminus(a, b)

Definition at line 4621 of file z3py.py.

4621 def SetDifference(a, b):
4622  """ The set difference of a and b
4623  >>> a = Const('a', SetSort(IntSort()))
4624  >>> b = Const('b', SetSort(IntSort()))
4625  >>> SetDifference(a, b)
4626  setminus(a, b)
4627  """
4628  ctx = _ctx_from_ast_arg_list([a, b])
4629  return ArrayRef(Z3_mk_set_difference(ctx.ref(), a.as_ast(), b.as_ast()), ctx)
4630 
def SetDifference(a, b)
Definition: z3py.py:4621
Z3_ast Z3_API Z3_mk_set_difference(Z3_context c, Z3_ast arg1, Z3_ast arg2)
Take the set difference between two sets.

◆ SetHasSize()

def z3py.SetHasSize (   a,
  k 
)

Definition at line 4513 of file z3py.py.

4513 def SetHasSize(a, k):
4514  ctx = a.ctx
4515  k = _py2expr(k, ctx)
4516  return _to_expr_ref(Z3_mk_set_has_size(ctx.ref(), a.as_ast(), k.as_ast()), ctx)
4517 
def SetHasSize(a, k)
Definition: z3py.py:4513
Z3_ast Z3_API Z3_mk_set_has_size(Z3_context c, Z3_ast set, Z3_ast k)
Create predicate that holds if Boolean array set has k elements set to true.

◆ SetIntersect()

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

Definition at line 4580 of file z3py.py.

4580 def SetIntersect(*args):
4581  """ Take the union of sets
4582  >>> a = Const('a', SetSort(IntSort()))
4583  >>> b = Const('b', SetSort(IntSort()))
4584  >>> SetIntersect(a, b)
4585  intersection(a, b)
4586  """
4587  args = _get_args(args)
4588  ctx = _ctx_from_ast_arg_list(args)
4589  _args, sz = _to_ast_array(args)
4590  return ArrayRef(Z3_mk_set_intersect(ctx.ref(), sz, _args), ctx)
4591 
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:4580

◆ SetSort()

def z3py.SetSort (   s)

Sets.

Create a set sort over element sort s

Definition at line 4548 of file z3py.py.

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

4548 def SetSort(s):
4549  """ Create a set sort over element sort s"""
4550  return ArraySort(s, BoolSort())
4551 
def ArraySort(sig)
Definition: z3py.py:4351
def SetSort(s)
Sets.
Definition: z3py.py:4548
def BoolSort(ctx=None)
Definition: z3py.py:1523

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

4568 def SetUnion(*args):
4569  """ Take the union of sets
4570  >>> a = Const('a', SetSort(IntSort()))
4571  >>> b = Const('b', SetSort(IntSort()))
4572  >>> SetUnion(a, b)
4573  union(a, b)
4574  """
4575  args = _get_args(args)
4576  ctx = _ctx_from_ast_arg_list(args)
4577  _args, sz = _to_ast_array(args)
4578  return ArrayRef(Z3_mk_set_union(ctx.ref(), sz, _args), ctx)
4579 
def SetUnion(args)
Definition: z3py.py:4568
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 4057 of file z3py.py.

4057 def SignExt(n, a):
4058  """Return a bit-vector expression with `n` extra sign-bits.
4059 
4060  >>> x = BitVec('x', 16)
4061  >>> n = SignExt(8, x)
4062  >>> n.size()
4063  24
4064  >>> n
4065  SignExt(8, x)
4066  >>> n.sort()
4067  BitVec(24)
4068  >>> v0 = BitVecVal(2, 2)
4069  >>> v0
4070  2
4071  >>> v0.size()
4072  2
4073  >>> v = simplify(SignExt(6, v0))
4074  >>> v
4075  254
4076  >>> v.size()
4077  8
4078  >>> print("%.x" % v.as_long())
4079  fe
4080  """
4081  if z3_debug():
4082  _z3_assert(_is_int(n), "First argument must be an integer")
4083  _z3_assert(is_bv(a), "Second argument must be a Z3 Bitvector expression")
4084  return BitVecRef(Z3_mk_sign_ext(a.ctx_ref(), n, a.as_ast()), a.ctx)
4085 
def SignExt(n, a)
Definition: z3py.py:4057
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 z3_debug()
Definition: z3py.py:58
def is_bv(a)
Definition: z3py.py:3666

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

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

6898 def SimpleSolver(ctx=None):
6899  """Return a simple general purpose solver with limited amount of preprocessing.
6900 
6901  >>> s = SimpleSolver()
6902  >>> x = Int('x')
6903  >>> s.add(x > 0)
6904  >>> s.check()
6905  sat
6906  """
6907  ctx = _get_ctx(ctx)
6908  return Solver(Z3_mk_simple_solver(ctx.ref()), ctx)
6909 
Z3_solver Z3_API Z3_mk_simple_solver(Z3_context c)
Create a new incremental solver.
def SimpleSolver(ctx=None)
Definition: z3py.py:6898

◆ 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 8149 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(), Range(), DatatypeSortRef.recognizer(), RepeatBitVec(), Replace(), RotateLeft(), RotateRight(), SignExt(), Star(), StrToInt(), SuffixOf(), Union(), Xor(), and ZeroExt().

8149 def simplify(a, *arguments, **keywords):
8150  """Simplify the expression `a` using the given options.
8151 
8152  This function has many options. Use `help_simplify` to obtain the complete list.
8153 
8154  >>> x = Int('x')
8155  >>> y = Int('y')
8156  >>> simplify(x + 1 + y + x + 1)
8157  2 + 2*x + y
8158  >>> simplify((x + 1)*(y + 1), som=True)
8159  1 + x + y + x*y
8160  >>> simplify(Distinct(x, y, 1), blast_distinct=True)
8161  And(Not(x == y), Not(x == 1), Not(y == 1))
8162  >>> simplify(And(x == 0, y == 1), elim_and=True)
8163  Not(Or(Not(x == 0), Not(y == 1)))
8164  """
8165  if z3_debug():
8166  _z3_assert(is_expr(a), "Z3 expression expected")
8167  if len(arguments) > 0 or len(keywords) > 0:
8168  p = args2params(arguments, keywords, a.ctx)
8169  return _to_expr_ref(Z3_simplify_ex(a.ctx_ref(), a.as_ast(), p.params), a.ctx)
8170  else:
8171  return _to_expr_ref(Z3_simplify(a.ctx_ref(), a.as_ast()), a.ctx)
8172 
def simplify(a, arguments, keywords)
Utils.
Definition: z3py.py:8149
def args2params(arguments, keywords, ctx=None)
Definition: z3py.py:5050
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 z3_debug()
Definition: z3py.py:58
def is_expr(a)
Definition: z3py.py:1105

◆ simplify_param_descrs()

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

Definition at line 8177 of file z3py.py.

8177 def simplify_param_descrs():
8178  """Return the set of parameter descriptions for Z3 `simplify` procedure."""
8179  return ParamDescrsRef(Z3_simplify_get_param_descrs(main_ctx().ref()), main_ctx())
8180 
def main_ctx()
Definition: z3py.py:213
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:8177

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

Referenced by BV2Int(), and IsInt().

8362 def solve(*args, **keywords):
8363  """Solve the constraints `*args`.
8364 
8365  This is a simple function for creating demonstrations. It creates a solver,
8366  configure it using the options in `keywords`, adds the constraints
8367  in `args`, and invokes check.
8368 
8369  >>> a = Int('a')
8370  >>> solve(a > 0, a < 2)
8371  [a = 1]
8372  """
8373  s = Solver()
8374  s.set(**keywords)
8375  s.add(*args)
8376  if keywords.get('show', False):
8377  print(s)
8378  r = s.check()
8379  if r == unsat:
8380  print("no solution")
8381  elif r == unknown:
8382  print("failed to solve")
8383  try:
8384  print(s.model())
8385  except Z3Exception:
8386  return
8387  else:
8388  print(s.model())
8389 
def solve(args, keywords)
Definition: z3py.py:8362

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

8390 def solve_using(s, *args, **keywords):
8391  """Solve the constraints `*args` using solver `s`.
8392 
8393  This is a simple function for creating demonstrations. It is similar to `solve`,
8394  but it uses the given solver `s`.
8395  It configures solver `s` using the options in `keywords`, adds the constraints
8396  in `args`, and invokes check.
8397  """
8398  if z3_debug():
8399  _z3_assert(isinstance(s, Solver), "Solver object expected")
8400  s.set(**keywords)
8401  s.add(*args)
8402  if keywords.get('show', False):
8403  print("Problem:")
8404  print(s)
8405  r = s.check()
8406  if r == unsat:
8407  print("no solution")
8408  elif r == unknown:
8409  print("failed to solve")
8410  try:
8411  print(s.model())
8412  except Z3Exception:
8413  return
8414  else:
8415  if keywords.get('show', False):
8416  print("Solution:")
8417  print(s.model())
8418 
def solve_using(s, args, keywords)
Definition: z3py.py:8390
def z3_debug()
Definition: z3py.py:58

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

6878 def SolverFor(logic, ctx=None):
6879  """Create a solver customized for the given logic.
6880 
6881  The parameter `logic` is a string. It should be contains
6882  the name of a SMT-LIB logic.
6883  See http://www.smtlib.org/ for the name of all available logics.
6884 
6885  >>> s = SolverFor("QF_LIA")
6886  >>> x = Int('x')
6887  >>> s.add(x > 0)
6888  >>> s.add(x < 2)
6889  >>> s.check()
6890  sat
6891  >>> s.model()
6892  [x = 1]
6893  """
6894  ctx = _get_ctx(ctx)
6895  logic = to_symbol(logic)
6896  return Solver(Z3_mk_solver_for_logic(ctx.ref(), logic), ctx)
6897 
def to_symbol(s, ctx=None)
Definition: z3py.py:111
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:6878

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

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

3143 def Sqrt(a, ctx=None):
3144  """ Return a Z3 expression which represents the square root of a.
3145 
3146  >>> x = Real('x')
3147  >>> Sqrt(x)
3148  x**(1/2)
3149  """
3150  if not is_expr(a):
3151  ctx = _get_ctx(ctx)
3152  a = RealVal(a, ctx)
3153  return a ** "1/2"
3154 
def RealVal(val, ctx=None)
Definition: z3py.py:2948
def is_expr(a)
Definition: z3py.py:1105
def Sqrt(a, ctx=None)
Definition: z3py.py:3143

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

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

3976 def SRem(a, b):
3977  """Create the Z3 expression signed remainder.
3978 
3979  Use the operator % for signed modulus, and URem() for unsigned remainder.
3980 
3981  >>> x = BitVec('x', 32)
3982  >>> y = BitVec('y', 32)
3983  >>> SRem(x, y)
3984  SRem(x, y)
3985  >>> SRem(x, y).sort()
3986  BitVec(32)
3987  >>> (x % y).sexpr()
3988  '(bvsmod x y)'
3989  >>> SRem(x, y).sexpr()
3990  '(bvsrem x y)'
3991  """
3992  _check_bv_args(a, b)
3993  a, b = _coerce_exprs(a, b)
3994  return BitVecRef(Z3_mk_bvsrem(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3995 
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:3976

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

10341 def Star(re):
10342  """Create the regular expression accepting zero or more repetitions of argument.
10343  >>> re = Star(Re("a"))
10344  >>> print(simplify(InRe("aa", re)))
10345  True
10346  >>> print(simplify(InRe("ab", re)))
10347  False
10348  >>> print(simplify(InRe("", re)))
10349  True
10350  """
10351  return ReRef(Z3_mk_re_star(re.ctx_ref(), re.as_ast()), re.ctx)
10352 
def Star(re)
Definition: z3py.py:10341
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 4428 of file z3py.py.

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

4428 def Store(a, i, v):
4429  """Return a Z3 store array expression.
4430 
4431  >>> a = Array('a', IntSort(), IntSort())
4432  >>> i, v = Ints('i v')
4433  >>> s = Store(a, i, v)
4434  >>> s.sort()
4435  Array(Int, Int)
4436  >>> prove(s[i] == v)
4437  proved
4438  >>> j = Int('j')
4439  >>> prove(Implies(i != j, s[j] == a[j]))
4440  proved
4441  """
4442  return Update(a, i, v)
4443 
def Update(a, i, v)
Definition: z3py.py:4396
def Store(a, i, v)
Definition: z3py.py:4428

◆ 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 10043 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.getLstring(), 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.solverToDimacsString(), Native.solverToString(), Native.sortToString(), Native.statsGetKey(), Native.statsToString(), Native.tacticGetDescr(), Native.tacticGetHelp(), and FuncInterp.toString().

10043 def String(name, ctx=None):
10044  """Return a string constant named `name`. If `ctx=None`, then the global context is used.
10045 
10046  >>> x = String('x')
10047  """
10048  ctx = _get_ctx(ctx)
10049  return SeqRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), StringSort(ctx).ast), ctx)
10050 
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:111
def StringSort(ctx=None)
Definition: z3py.py:9940
def String(name, ctx=None)
Definition: z3py.py:10043

◆ Strings()

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

Definition at line 10059 of file z3py.py.

Referenced by Contains().

10059 def Strings(names, ctx=None):
10060  """Return a tuple of String constants. """
10061  ctx = _get_ctx(ctx)
10062  if isinstance(names, str):
10063  names = names.split(" ")
10064  return [String(name, ctx) for name in names]
10065 
def Strings(names, ctx=None)
Definition: z3py.py:10059
def String(name, ctx=None)
Definition: z3py.py:10043

◆ StringSort()

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

Definition at line 9940 of file z3py.py.

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

9940 def StringSort(ctx=None):
9941  """Create a string sort
9942  >>> s = StringSort()
9943  >>> print(s)
9944  String
9945  """
9946  ctx = _get_ctx(ctx)
9947  return SeqSortRef(Z3_mk_string_sort(ctx.ref()), ctx)
9948 
9949 
def StringSort(ctx=None)
Definition: z3py.py:9940
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 10038 of file z3py.py.

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

10038 def StringVal(s, ctx=None):
10039  """create a string expression"""
10040  ctx = _get_ctx(ctx)
10041  return SeqRef(Z3_mk_lstring(ctx.ref(), len(s), s), ctx)
10042 
def StringVal(s, ctx=None)
Definition: z3py.py:10038
Z3_ast Z3_API Z3_mk_lstring(Z3_context c, unsigned len, Z3_string s)
Create a string constant out of the string that is passed in It takes the length of the string as wel...

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

10202 def StrToInt(s):
10203  """Convert string expression to integer
10204  >>> a = StrToInt("1")
10205  >>> simplify(1 == a)
10206  True
10207  >>> b = StrToInt("2")
10208  >>> simplify(1 == b)
10209  False
10210  >>> c = StrToInt(IntToStr(2))
10211  >>> simplify(1 == c)
10212  False
10213  """
10214  s = _coerce_seq(s)
10215  return ArithRef(Z3_mk_str_to_int(s.ctx_ref(), s.as_ast()), s.ctx)
10216 
10217 
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:10202

◆ SubSeq()

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

Definition at line 10055 of file z3py.py.

10055 def SubSeq(s, offset, length):
10056  """Extract substring or subsequence starting at offset"""
10057  return Extract(s, offset, length)
10058 
def SubSeq(s, offset, length)
Definition: z3py.py:10055
def Extract(high, low, a)
Definition: z3py.py:3841

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

8181 def substitute(t, *m):
8182  """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.
8183 
8184  >>> x = Int('x')
8185  >>> y = Int('y')
8186  >>> substitute(x + 1, (x, y + 1))
8187  y + 1 + 1
8188  >>> f = Function('f', IntSort(), IntSort())
8189  >>> substitute(f(x) + f(y), (f(x), IntVal(1)), (f(y), IntVal(1)))
8190  1 + 1
8191  """
8192  if isinstance(m, tuple):
8193  m1 = _get_args(m)
8194  if isinstance(m1, list) and all(isinstance(p, tuple) for p in m1):
8195  m = m1
8196  if z3_debug():
8197  _z3_assert(is_expr(t), "Z3 expression expected")
8198  _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.")
8199  num = len(m)
8200  _from = (Ast * num)()
8201  _to = (Ast * num)()
8202  for i in range(num):
8203  _from[i] = m[i][0].as_ast()
8204  _to[i] = m[i][1].as_ast()
8205  return _to_expr_ref(Z3_substitute(t.ctx.ref(), t.as_ast(), num, _from, _to), t.ctx)
8206 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3358
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:8181
def eq(a, b)
Definition: z3py.py:422
def z3_debug()
Definition: z3py.py:58
def is_expr(a)
Definition: z3py.py:1105

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

8207 def substitute_vars(t, *m):
8208  """Substitute the free variables in t with the expression in m.
8209 
8210  >>> v0 = Var(0, IntSort())
8211  >>> v1 = Var(1, IntSort())
8212  >>> x = Int('x')
8213  >>> f = Function('f', IntSort(), IntSort(), IntSort())
8214  >>> # replace v0 with x+1 and v1 with x
8215  >>> substitute_vars(f(v0, v1), x + 1, x)
8216  f(x + 1, x)
8217  """
8218  if z3_debug():
8219  _z3_assert(is_expr(t), "Z3 expression expected")
8220  _z3_assert(all([is_expr(n) for n in m]), "Z3 invalid substitution, list of expressions expected.")
8221  num = len(m)
8222  _to = (Ast * num)()
8223  for i in range(num):
8224  _to[i] = m[i].as_ast()
8225  return _to_expr_ref(Z3_substitute_vars(t.ctx.ref(), t.as_ast(), num, _to), t.ctx)
8226 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3358
def substitute_vars(t, m)
Definition: z3py.py:8207
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 z3_debug()
Definition: z3py.py:58
def is_expr(a)
Definition: z3py.py:1105

◆ SubString()

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

Definition at line 10051 of file z3py.py.

10051 def SubString(s, offset, length):
10052  """Extract substring or subsequence starting at offset"""
10053  return Extract(s, offset, length)
10054 
def SubString(s, offset, length)
Definition: z3py.py:10051
def Extract(high, low, a)
Definition: z3py.py:3841

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

10117 def SuffixOf(a, b):
10118  """Check if 'a' is a suffix of 'b'
10119  >>> s1 = SuffixOf("ab", "abc")
10120  >>> simplify(s1)
10121  False
10122  >>> s2 = SuffixOf("bc", "abc")
10123  >>> simplify(s2)
10124  True
10125  """
10126  ctx = _get_ctx2(a, b)
10127  a = _coerce_seq(a, ctx)
10128  b = _coerce_seq(b, ctx)
10129  return BoolRef(Z3_mk_seq_suffix(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
10130 
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:10117

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

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

8227 def Sum(*args):
8228  """Create the sum of the Z3 expressions.
8229 
8230  >>> a, b, c = Ints('a b c')
8231  >>> Sum(a, b, c)
8232  a + b + c
8233  >>> Sum([a, b, c])
8234  a + b + c
8235  >>> A = IntVector('a', 5)
8236  >>> Sum(A)
8237  a__0 + a__1 + a__2 + a__3 + a__4
8238  """
8239  args = _get_args(args)
8240  if len(args) == 0:
8241  return 0
8242  ctx = _ctx_from_ast_arg_list(args)
8243  if ctx is None:
8244  return _reduce(lambda a, b: a + b, args, 0)
8245  args = _coerce_expr_list(args, ctx)
8246  if is_bv(args[0]):
8247  return _reduce(lambda a, b: a + b, args, 0)
8248  else:
8249  _args, sz = _to_ast_array(args)
8250  return ArithRef(Z3_mk_add(ctx.ref(), sz, _args), ctx)
8251 
8252 
def Sum(args)
Definition: z3py.py:8227
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:3666

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

Referenced by describe_tactics().

7864 def tactic_description(name, ctx=None):
7865  """Return a short description for the tactic named `name`.
7866 
7867  >>> d = tactic_description('simplify')
7868  """
7869  ctx = _get_ctx(ctx)
7870  return Z3_tactic_get_descr(ctx.ref(), name)
7871 
def tactic_description(name, ctx=None)
Definition: z3py.py:7864
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 7854 of file z3py.py.

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

7854 def tactics(ctx=None):
7855  """Return a list of all available tactics in Z3.
7856 
7857  >>> l = tactics()
7858  >>> l.count('simplify') == 1
7859  True
7860  """
7861  ctx = _get_ctx(ctx)
7862  return [ Z3_get_tactic_name(ctx.ref(), i) for i in range(Z3_get_num_tactics(ctx.ref())) ]
7863 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3358
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:7854
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 7733 of file z3py.py.

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

7733 def Then(*ts, **ks):
7734  """Return a tactic that applies the tactics in `*ts` in sequence. Shorthand for AndThen(*ts, **ks).
7735 
7736  >>> x, y = Ints('x y')
7737  >>> t = Then(Tactic('simplify'), Tactic('solve-eqs'))
7738  >>> t(And(x == 0, y > x + 1))
7739  [[Not(y <= 1)]]
7740  >>> t(And(x == 0, y > x + 1)).as_expr()
7741  Not(y <= 1)
7742  """
7743  return AndThen(*ts, **ks)
7744 
def Then(ts, ks)
Definition: z3py.py:7733
def AndThen(ts, ks)
Definition: z3py.py:7714

◆ to_symbol()

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

Definition at line 111 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().

111 def to_symbol(s, ctx=None):
112  """Convert an integer or string into a Z3 symbol."""
113  if _is_int(s):
114  return Z3_mk_int_symbol(_get_ctx(ctx).ref(), s)
115  else:
116  return Z3_mk_string_symbol(_get_ctx(ctx).ref(), s)
117 
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:111
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 3110 of file z3py.py.

Referenced by is_to_int().

3110 def ToInt(a):
3111  """ Return the Z3 expression ToInt(a).
3112 
3113  >>> x = Real('x')
3114  >>> x.sort()
3115  Real
3116  >>> n = ToInt(x)
3117  >>> n
3118  ToInt(x)
3119  >>> n.sort()
3120  Int
3121  """
3122  if z3_debug():
3123  _z3_assert(a.is_real(), "Z3 real expression expected.")
3124  ctx = a.ctx
3125  return ArithRef(Z3_mk_real2int(ctx.ref(), a.as_ast()), ctx)
3126 
Z3_ast Z3_API Z3_mk_real2int(Z3_context c, Z3_ast t1)
Coerce a real to an integer.
def z3_debug()
Definition: z3py.py:58
def ToInt(a)
Definition: z3py.py:3110

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

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

3093 def ToReal(a):
3094  """ Return the Z3 expression ToReal(a).
3095 
3096  >>> x = Int('x')
3097  >>> x.sort()
3098  Int
3099  >>> n = ToReal(x)
3100  >>> n
3101  ToReal(x)
3102  >>> n.sort()
3103  Real
3104  """
3105  if z3_debug():
3106  _z3_assert(a.is_int(), "Z3 integer expression expected.")
3107  ctx = a.ctx
3108  return ArithRef(Z3_mk_int2real(ctx.ref(), a.as_ast()), ctx)
3109 
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:3093
def z3_debug()
Definition: z3py.py:58

◆ TransitiveClosure()

def z3py.TransitiveClosure (   f)
Given a binary relation R, such that the two arguments have the same sort
create the transitive closure relation R+.
The transitive closure R+ is a new relation.

Definition at line 10391 of file z3py.py.

10391 def TransitiveClosure(f):
10392  """Given a binary relation R, such that the two arguments have the same sort
10393  create the transitive closure relation R+.
10394  The transitive closure R+ is a new relation.
10395  """
10396  return FuncDeclRef(Z3_mk_transitive_closure(f.ctx_ref(), f.ast), f.ctx)
10397 
10398 
def TransitiveClosure(f)
Definition: z3py.py:10391
Z3_func_decl Z3_API Z3_mk_transitive_closure(Z3_context c, Z3_func_decl f)
create transitive closure of binary relation.

◆ TreeOrder()

def z3py.TreeOrder (   a,
  index 
)

Definition at line 10385 of file z3py.py.

10385 def TreeOrder(a, index):
10386  return FuncDeclRef(Z3_mk_tree_order(a.ctx_ref(), a.ast, index), a.ctx);
10387 
def TreeOrder(a, index)
Definition: z3py.py:10385
Z3_func_decl Z3_API Z3_mk_tree_order(Z3_context c, Z3_sort a, unsigned id)
create a tree ordering lreation over signature a identified using index id.

◆ TryFor()

def z3py.TryFor (   t,
  ms,
  ctx = None 
)
Return a tactic that applies `t` to a given goal for `ms` milliseconds.

If `t` does not terminate in `ms` milliseconds, then it fails.

Definition at line 7846 of file z3py.py.

7846 def TryFor(t, ms, ctx=None):
7847  """Return a tactic that applies `t` to a given goal for `ms` milliseconds.
7848 
7849  If `t` does not terminate in `ms` milliseconds, then it fails.
7850  """
7851  t = _to_tactic(t, ctx)
7852  return Tactic(Z3_tactic_try_for(t.ctx.ref(), t.tactic, ms), t.ctx)
7853 
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:7846

◆ TupleSort()

def z3py.TupleSort (   name,
  sorts,
  ctx = None 
)
Create a named tuple sort base on a set of underlying sorts
Example:
    >>> pair, mk_pair, (first, second) = TupleSort("pair", [IntSort(), StringSort()])

Definition at line 4951 of file z3py.py.

Referenced by Context.mkTupleSort().

4951 def TupleSort(name, sorts, ctx = None):
4952  """Create a named tuple sort base on a set of underlying sorts
4953  Example:
4954  >>> pair, mk_pair, (first, second) = TupleSort("pair", [IntSort(), StringSort()])
4955  """
4956  tuple = Datatype(name, ctx)
4957  projects = [ ('project%d' % i, sorts[i]) for i in range(len(sorts)) ]
4958  tuple.declare(name, *projects)
4959  tuple = tuple.create()
4960  return tuple, tuple.constructor(0), [tuple.accessor(0, i) for i in range(len(sorts))]
4961 
def TupleSort(name, sorts, ctx=None)
Definition: z3py.py:4951
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3358

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

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

3936 def UDiv(a, b):
3937  """Create the Z3 expression (unsigned) division `self / other`.
3938 
3939  Use the operator / for signed division.
3940 
3941  >>> x = BitVec('x', 32)
3942  >>> y = BitVec('y', 32)
3943  >>> UDiv(x, y)
3944  UDiv(x, y)
3945  >>> UDiv(x, y).sort()
3946  BitVec(32)
3947  >>> (x / y).sexpr()
3948  '(bvsdiv x y)'
3949  >>> UDiv(x, y).sexpr()
3950  '(bvudiv x y)'
3951  """
3952  _check_bv_args(a, b)
3953  a, b = _coerce_exprs(a, b)
3954  return BitVecRef(Z3_mk_bvudiv(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3955 
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:3936

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

Referenced by BitVecRef.__ge__().

3902 def UGE(a, b):
3903  """Create the Z3 expression (unsigned) `other >= self`.
3904 
3905  Use the operator >= for signed greater than or equal to.
3906 
3907  >>> x, y = BitVecs('x y', 32)
3908  >>> UGE(x, y)
3909  UGE(x, y)
3910  >>> (x >= y).sexpr()
3911  '(bvsge x y)'
3912  >>> UGE(x, y).sexpr()
3913  '(bvuge x y)'
3914  """
3915  _check_bv_args(a, b)
3916  a, b = _coerce_exprs(a, b)
3917  return BoolRef(Z3_mk_bvuge(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3918 
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:3902

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

Referenced by BitVecRef.__gt__().

3919 def UGT(a, b):
3920  """Create the Z3 expression (unsigned) `other > self`.
3921 
3922  Use the operator > for signed greater than.
3923 
3924  >>> x, y = BitVecs('x y', 32)
3925  >>> UGT(x, y)
3926  UGT(x, y)
3927  >>> (x > y).sexpr()
3928  '(bvsgt x y)'
3929  >>> UGT(x, y).sexpr()
3930  '(bvugt x y)'
3931  """
3932  _check_bv_args(a, b)
3933  a, b = _coerce_exprs(a, b)
3934  return BoolRef(Z3_mk_bvugt(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3935 
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:3919

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

Referenced by BitVecRef.__le__().

3868 def ULE(a, b):
3869  """Create the Z3 expression (unsigned) `other <= self`.
3870 
3871  Use the operator <= for signed less than or equal to.
3872 
3873  >>> x, y = BitVecs('x y', 32)
3874  >>> ULE(x, y)
3875  ULE(x, y)
3876  >>> (x <= y).sexpr()
3877  '(bvsle x y)'
3878  >>> ULE(x, y).sexpr()
3879  '(bvule x y)'
3880  """
3881  _check_bv_args(a, b)
3882  a, b = _coerce_exprs(a, b)
3883  return BoolRef(Z3_mk_bvule(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3884 
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:3868

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

Referenced by BitVecRef.__lt__().

3885 def ULT(a, b):
3886  """Create the Z3 expression (unsigned) `other < self`.
3887 
3888  Use the operator < for signed less than.
3889 
3890  >>> x, y = BitVecs('x y', 32)
3891  >>> ULT(x, y)
3892  ULT(x, y)
3893  >>> (x < y).sexpr()
3894  '(bvslt x y)'
3895  >>> ULT(x, y).sexpr()
3896  '(bvult x y)'
3897  """
3898  _check_bv_args(a, b)
3899  a, b = _coerce_exprs(a, b)
3900  return BoolRef(Z3_mk_bvult(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3901 
def ULT(a, b)
Definition: z3py.py:3885
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 10277 of file z3py.py.

Referenced by InRe().

10277 def Union(*args):
10278  """Create union of regular expressions.
10279  >>> re = Union(Re("a"), Re("b"), Re("c"))
10280  >>> print (simplify(InRe("d", re)))
10281  False
10282  """
10283  args = _get_args(args)
10284  sz = len(args)
10285  if z3_debug():
10286  _z3_assert(sz > 0, "At least one argument expected.")
10287  _z3_assert(all([is_re(a) for a in args]), "All arguments must be regular expressions.")
10288  if sz == 1:
10289  return args[0]
10290  ctx = args[0].ctx
10291  v = (Ast * sz)()
10292  for i in range(sz):
10293  v[i] = args[i].as_ast()
10294  return ReRef(Z3_mk_re_union(ctx.ref(), sz, v), ctx)
10295 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3358
def Union(args)
Definition: z3py.py:10277
def is_re(s)
Definition: z3py.py:10260
def z3_debug()
Definition: z3py.py:58
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 10099 of file z3py.py.

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

10099 def Unit(a):
10100  """Create a singleton sequence"""
10101  return SeqRef(Z3_mk_seq_unit(a.ctx_ref(), a.as_ast()), a.ctx)
10102 
def Unit(a)
Definition: z3py.py:10099
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 4396 of file z3py.py.

4396 def Update(a, i, v):
4397  """Return a Z3 store array expression.
4398 
4399  >>> a = Array('a', IntSort(), IntSort())
4400  >>> i, v = Ints('i v')
4401  >>> s = Update(a, i, v)
4402  >>> s.sort()
4403  Array(Int, Int)
4404  >>> prove(s[i] == v)
4405  proved
4406  >>> j = Int('j')
4407  >>> prove(Implies(i != j, s[j] == a[j]))
4408  proved
4409  """
4410  if z3_debug():
4411  _z3_assert(is_array(a), "First argument must be a Z3 array expression")
4412  i = a.domain().cast(i)
4413  v = a.range().cast(v)
4414  ctx = a.ctx
4415  return _to_expr_ref(Z3_mk_store(ctx.ref(), a.as_ast(), i.as_ast(), v.as_ast()), ctx)
4416 
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:4274
def z3_debug()
Definition: z3py.py:58
def Update(a, i, v)
Definition: z3py.py:4396

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

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

3956 def URem(a, b):
3957  """Create the Z3 expression (unsigned) remainder `self % other`.
3958 
3959  Use the operator % for signed modulus, and SRem() for signed remainder.
3960 
3961  >>> x = BitVec('x', 32)
3962  >>> y = BitVec('y', 32)
3963  >>> URem(x, y)
3964  URem(x, y)
3965  >>> URem(x, y).sort()
3966  BitVec(32)
3967  >>> (x % y).sexpr()
3968  '(bvsmod x y)'
3969  >>> URem(x, y).sexpr()
3970  '(bvurem x y)'
3971  """
3972  _check_bv_args(a, b)
3973  a, b = _coerce_exprs(a, b)
3974  return BitVecRef(Z3_mk_bvurem(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3975 
def URem(a, b)
Definition: z3py.py:3956
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 1321 of file z3py.py.

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

1321 def Var(idx, s):
1322  """Create a Z3 free variable. Free variables are used to create quantified formulas.
1323 
1324  >>> Var(0, IntSort())
1325  Var(0)
1326  >>> eq(Var(0, IntSort()), Var(0, BoolSort()))
1327  False
1328  """
1329  if z3_debug():
1330  _z3_assert(is_sort(s), "Z3 sort expected")
1331  return _to_expr_ref(Z3_mk_bound(s.ctx_ref(), idx, s.ast), s.ctx)
1332 
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:1321
def is_sort(s)
Definition: z3py.py:586
def z3_debug()
Definition: z3py.py:58

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

8115 def When(p, t, ctx=None):
8116  """Return a tactic that applies tactic `t` only if probe `p` evaluates to true. Otherwise, it returns the input goal unmodified.
8117 
8118  >>> t = When(Probe('size') > 2, Tactic('simplify'))
8119  >>> x, y = Ints('x y')
8120  >>> g = Goal()
8121  >>> g.add(x > 0)
8122  >>> g.add(y > 0)
8123  >>> t(g)
8124  [[x > 0, y > 0]]
8125  >>> g.add(x == y + 1)
8126  >>> t(g)
8127  [[Not(x <= 0), Not(y <= 0), x == 1 + y]]
8128  """
8129  p = _to_probe(p, ctx)
8130  t = _to_tactic(t, ctx)
8131  return Tactic(Z3_tactic_when(t.ctx.ref(), p.probe, t.tactic), t.ctx)
8132 
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:8115

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

Referenced by Goal.prec().

7801 def With(t, *args, **keys):
7802  """Return a tactic that applies tactic `t` using the given configuration options.
7803 
7804  >>> x, y = Ints('x y')
7805  >>> t = With(Tactic('simplify'), som=True)
7806  >>> t((x + 1)*(y + 2) == 0)
7807  [[2*x + y + x*y == -2]]
7808  """
7809  ctx = keys.pop('ctx', None)
7810  t = _to_tactic(t, ctx)
7811  p = args2params(args, keys, t.ctx)
7812  return Tactic(Z3_tactic_using_params(t.ctx.ref(), t.tactic, p.params), t.ctx)
7813 
def args2params(arguments, keywords, ctx=None)
Definition: z3py.py:5050
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:7801

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

7814 def WithParams(t, p):
7815  """Return a tactic that applies tactic `t` using the given configuration options.
7816 
7817  >>> x, y = Ints('x y')
7818  >>> p = ParamsRef()
7819  >>> p.set("som", True)
7820  >>> t = WithParams(Tactic('simplify'), p)
7821  >>> t((x + 1)*(y + 2) == 0)
7822  [[2*x + y + x*y == -2]]
7823  """
7824  t = _to_tactic(t, None)
7825  return Tactic(Z3_tactic_using_params(t.ctx.ref(), t.tactic, p.params), t.ctx)
7826 
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:7814

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

1626 def Xor(a, b, ctx=None):
1627  """Create a Z3 Xor expression.
1628 
1629  >>> p, q = Bools('p q')
1630  >>> Xor(p, q)
1631  Xor(p, q)
1632  >>> simplify(Xor(p, q))
1633  Not(p) == q
1634  """
1635  ctx = _get_ctx(_ctx_from_ast_arg_list([a, b], ctx))
1636  s = BoolSort(ctx)
1637  a = s.cast(a)
1638  b = s.cast(b)
1639  return BoolRef(Z3_mk_xor(ctx.ref(), a.as_ast(), b.as_ast()), ctx)
1640 
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:1626
def BoolSort(ctx=None)
Definition: z3py.py:1523

◆ z3_debug()

◆ z3_error_handler()

def z3py.z3_error_handler (   c,
  e 
)

Definition at line 158 of file z3py.py.

158 def z3_error_handler(c, e):
159  # Do nothing error handler, just avoid exit(0)
160  # The wrappers in z3core.py will raise a Z3Exception if an error is detected
161  return
162 
def z3_error_handler(c, e)
Definition: z3py.py:158

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

4086 def ZeroExt(n, a):
4087  """Return a bit-vector expression with `n` extra zero-bits.
4088 
4089  >>> x = BitVec('x', 16)
4090  >>> n = ZeroExt(8, x)
4091  >>> n.size()
4092  24
4093  >>> n
4094  ZeroExt(8, x)
4095  >>> n.sort()
4096  BitVec(24)
4097  >>> v0 = BitVecVal(2, 2)
4098  >>> v0
4099  2
4100  >>> v0.size()
4101  2
4102  >>> v = simplify(ZeroExt(6, v0))
4103  >>> v
4104  2
4105  >>> v.size()
4106  8
4107  """
4108  if z3_debug():
4109  _z3_assert(_is_int(n), "First argument must be an integer")
4110  _z3_assert(is_bv(a), "Second argument must be a Z3 Bitvector expression")
4111  return BitVecRef(Z3_mk_zero_ext(a.ctx_ref(), n, a.as_ast()), a.ctx)
4112 
def ZeroExt(n, a)
Definition: z3py.py:4086
def z3_debug()
Definition: z3py.py:58
def is_bv(a)
Definition: z3py.py:3666
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 6405 of file z3py.py.

◆ unknown

Definition at line 6407 of file z3py.py.

◆ unsat

Definition at line 6406 of file z3py.py.

◆ Z3_DEBUG

Z3_DEBUG = __debug__

Definition at line 56 of file z3py.py.