Z3
Data Structures | Functions | Variables
z3py Namespace Reference

Data Structures

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

Functions

def enable_trace (msg)
 
def disable_trace (msg)
 
def get_version_string ()
 
def get_version ()
 
def get_full_version ()
 
def open_log (fname)
 
def append_log (s)
 
def to_symbol (s, ctx=None)
 
def z3_error_handler (c, e)
 
def main_ctx ()
 
def set_param (args, kws)
 
def reset_params ()
 
def set_option (args, kws)
 
def get_param (name)
 
def is_ast (a)
 
def eq (a, b)
 
def is_sort (s)
 
def DeclareSort (name, ctx=None)
 
def is_func_decl (a)
 
def Function (name, sig)
 
def 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 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_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 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 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 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 (d, r)
 
def Array (name, dom, rng)
 
def Update (a, i, v)
 
def Default (a)
 
def Store (a, i, v)
 
def Select (a, i)
 
def Map (f, args)
 
def K (dom, v)
 
def Ext (a, b)
 
def is_select (a)
 
def is_store (a)
 
def CreateDatatypes (ds)
 
def EnumSort (name, values, ctx=None)
 
def args2params (arguments, keywords, 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 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)
 
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 Interpolant (a, ctx=None)
 
def tree_interpolant (pat, p=None, ctx=None)
 
def binary_interpolant (a, b, p=None, ctx=None)
 
def sequence_interpolant (v, p=None, ctx=None)
 
def get_default_rounding_mode (ctx=None)
 
def set_default_rounding_mode (rm, ctx=None)
 
def get_default_fp_sort (ctx=None)
 
def set_default_fp_sort (ebits, sbits, ctx=None)
 
def Float16 (ctx=None)
 
def FloatHalf (ctx=None)
 
def Float32 (ctx=None)
 
def FloatSingle (ctx=None)
 
def Float64 (ctx=None)
 
def FloatDouble (ctx=None)
 
def Float128 (ctx=None)
 
def FloatQuadruple (ctx=None)
 
def is_fp_sort (s)
 
def is_fprm_sort (s)
 
def RoundNearestTiesToEven (ctx=None)
 
def RNE (ctx=None)
 
def RoundNearestTiesToAway (ctx=None)
 
def RNA (ctx=None)
 
def RoundTowardPositive (ctx=None)
 
def RTP (ctx=None)
 
def RoundTowardNegative (ctx=None)
 
def RTN (ctx=None)
 
def RoundTowardZero (ctx=None)
 
def RTZ (ctx=None)
 
def is_fprm (a)
 
def is_fprm_value (a)
 
def is_fp (a)
 
def is_fp_value (a)
 
def FPSort (ebits, sbits, ctx=None)
 
def fpNaN (s)
 
def fpPlusInfinity (s)
 
def fpMinusInfinity (s)
 
def fpInfinity (s, negative)
 
def fpPlusZero (s)
 
def fpMinusZero (s)
 
def fpZero (s, negative)
 
def FPVal (sig, exp=None, fps=None, ctx=None)
 
def FP (name, fpsort, ctx=None)
 
def FPs (names, fpsort, ctx=None)
 
def fpAbs (a, ctx=None)
 
def fpNeg (a, ctx=None)
 
def fpAdd (rm, a, b, ctx=None)
 
def fpSub (rm, a, b, ctx=None)
 
def fpMul (rm, a, b, ctx=None)
 
def fpDiv (rm, a, b, ctx=None)
 
def fpRem (a, b, ctx=None)
 
def fpMin (a, b, ctx=None)
 
def fpMax (a, b, ctx=None)
 
def fpFMA (rm, a, b, c, ctx=None)
 
def fpSqrt (rm, a, ctx=None)
 
def fpRoundToIntegral (rm, a, ctx=None)
 
def fpIsNaN (a, ctx=None)
 
def fpIsInf (a, ctx=None)
 
def fpIsZero (a, ctx=None)
 
def fpIsNormal (a, ctx=None)
 
def fpIsSubnormal (a, ctx=None)
 
def fpIsNegative (a, ctx=None)
 
def fpIsPositive (a, ctx=None)
 
def fpLT (a, b, ctx=None)
 
def fpLEQ (a, b, ctx=None)
 
def fpGT (a, b, ctx=None)
 
def fpGEQ (a, b, ctx=None)
 
def fpEQ (a, b, ctx=None)
 
def fpNEQ (a, b, ctx=None)
 
def fpFP (sgn, exp, sig, ctx=None)
 
def fpToFP (a1, a2=None, a3=None, ctx=None)
 
def fpBVToFP (v, sort, ctx=None)
 
def fpFPToFP (rm, v, sort, ctx=None)
 
def fpRealToFP (rm, v, sort, ctx=None)
 
def fpSignedToFP (rm, v, sort, ctx=None)
 
def fpUnsignedToFP (rm, v, sort, ctx=None)
 
def fpToFPUnsigned (rm, x, s, ctx=None)
 
def fpToSBV (rm, x, s, ctx=None)
 
def fpToUBV (rm, x, s, ctx=None)
 
def fpToReal (x, ctx=None)
 
def fpToIEEEBV (x, ctx=None)
 
def StringSort (ctx=None)
 
def SeqSort (s)
 
def is_seq (a)
 
def is_string (a)
 
def is_string_value (a)
 
def StringVal (s, ctx=None)
 
def String (name, ctx=None)
 
def Strings (names, ctx=None)
 
def Empty (s)
 
def Full (s)
 
def Unit (a)
 
def PrefixOf (a, b)
 
def SuffixOf (a, b)
 
def Contains (a, b)
 
def Replace (s, src, dst)
 
def IndexOf (s, substr)
 
def IndexOf (s, substr, offset)
 
def Length (s)
 
def StrToInt (s)
 
def IntToStr (s)
 
def Re (s, ctx=None)
 
def ReSort (s)
 
def is_re (s)
 
def InRe (s, re)
 
def Union (args)
 
def Plus (re)
 
def Option (re)
 
def Complement (re)
 
def Star (re)
 
def Loop (re, lo, hi=0)
 

Variables

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

Function Documentation

◆ And()

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

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

Definition at line 1578 of file z3py.py.

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

1578 def And(*args):
1579  """Create a Z3 and-expression or and-probe.
1580 
1581  >>> p, q, r = Bools('p q r')
1582  >>> And(p, q, r)
1583  And(p, q, r)
1584  >>> P = BoolVector('p', 5)
1585  >>> And(P)
1586  And(p__0, p__1, p__2, p__3, p__4)
1587  """
1588  last_arg = None
1589  if len(args) > 0:
1590  last_arg = args[len(args)-1]
1591  if isinstance(last_arg, Context):
1592  ctx = args[len(args)-1]
1593  args = args[:len(args)-1]
1594  elif len(args) == 1 and isinstance(args[0], AstVector):
1595  ctx = args[0].ctx
1596  args = [a for a in args[0]]
1597  else:
1598  ctx = main_ctx()
1599  args = _get_args(args)
1600  ctx_args = _ctx_from_ast_arg_list(args, ctx)
1601  if __debug__:
1602  _z3_assert(ctx_args is None or ctx_args == ctx, "context mismatch")
1603  _z3_assert(ctx is not None, "At least one of the arguments must be a Z3 expression or probe")
1604  if _has_probe(args):
1605  return _probe_and(args, ctx)
1606  else:
1607  args = _coerce_expr_list(args, ctx)
1608  _args, sz = _to_ast_array(args)
1609  return BoolRef(Z3_mk_and(ctx.ref(), sz, _args), ctx)
1610 
def And(args)
Definition: z3py.py:1578
def main_ctx()
Definition: z3py.py:192
Z3_ast Z3_API Z3_mk_and(Z3_context c, unsigned num_args, Z3_ast const args[])
Create an AST node representing args[0] and ... and args[num_args-1].

◆ AndThen()

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

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

Definition at line 7290 of file z3py.py.

Referenced by Then().

7290 def AndThen(*ts, **ks):
7291  """Return a tactic that applies the tactics in `*ts` in sequence.
7292 
7293  >>> x, y = Ints('x y')
7294  >>> t = AndThen(Tactic('simplify'), Tactic('solve-eqs'))
7295  >>> t(And(x == 0, y > x + 1))
7296  [[Not(y <= 1)]]
7297  >>> t(And(x == 0, y > x + 1)).as_expr()
7298  Not(y <= 1)
7299  """
7300  if __debug__:
7301  _z3_assert(len(ts) >= 2, "At least two arguments expected")
7302  ctx = ks.get('ctx', None)
7303  num = len(ts)
7304  r = ts[0]
7305  for i in range(num - 1):
7306  r = _and_then(r, ts[i+1], ctx)
7307  return r
7308 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:2813
def AndThen(ts, ks)
Definition: z3py.py:7290

◆ append_log()

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

Definition at line 97 of file z3py.py.

97 def append_log(s):
98  """Append user-defined string to interaction log. """
99  Z3_append_log(s)
100 
void Z3_API Z3_append_log(Z3_string string)
Append user-defined string to interaction log.
def append_log(s)
Definition: z3py.py:97

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

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

4744 def args2params(arguments, keywords, ctx=None):
4745  """Convert python arguments into a Z3_params object.
4746  A ':' is added to the keywords, and '_' is replaced with '-'
4747 
4748  >>> args2params(['model', True, 'relevancy', 2], {'elim_and' : True})
4749  (params model true relevancy 2 elim_and true)
4750  """
4751  if __debug__:
4752  _z3_assert(len(arguments) % 2 == 0, "Argument list must have an even number of elements.")
4753  prev = None
4754  r = ParamsRef(ctx)
4755  for a in arguments:
4756  if prev is None:
4757  prev = a
4758  else:
4759  r.set(prev, a)
4760  prev = None
4761  for k in keywords:
4762  v = keywords[k]
4763  r.set(k, v)
4764  return r
4765 
def args2params(arguments, keywords, ctx=None)
Definition: z3py.py:4744

◆ 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 4220 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(), Map(), ArrayRef.range(), Select(), ArrayRef.sort(), Store(), and Update().

4220 def Array(name, dom, rng):
4221  """Return an array constant named `name` with the given domain and range sorts.
4222 
4223  >>> a = Array('a', IntSort(), IntSort())
4224  >>> a.sort()
4225  Array(Int, Int)
4226  >>> a[0]
4227  a[0]
4228  """
4229  s = ArraySort(dom, rng)
4230  ctx = s.ctx
4231  return ArrayRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), s.ast), ctx)
4232 
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:101
def Array(name, dom, rng)
Definition: z3py.py:4220
def ArraySort(d, r)
Definition: z3py.py:4199

◆ ArraySort()

def z3py.ArraySort (   d,
  r 
)
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 4199 of file z3py.py.

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

4199 def ArraySort(d, r):
4200  """Return the Z3 array sort with the given domain and range sorts.
4201 
4202  >>> A = ArraySort(IntSort(), BoolSort())
4203  >>> A
4204  Array(Int, Bool)
4205  >>> A.domain()
4206  Int
4207  >>> A.range()
4208  Bool
4209  >>> AA = ArraySort(IntSort(), A)
4210  >>> AA
4211  Array(Int, Array(Int, Bool))
4212  """
4213  if __debug__:
4214  _z3_assert(is_sort(d), "Z3 sort expected")
4215  _z3_assert(is_sort(r), "Z3 sort expected")
4216  _z3_assert(d.ctx == r.ctx, "Context mismatch")
4217  ctx = d.ctx
4218  return ArraySortRef(Z3_mk_array_sort(ctx.ref(), d.ast, r.ast), ctx)
4219 
Z3_sort Z3_API Z3_mk_array_sort(Z3_context c, Z3_sort domain, Z3_sort range)
Create an array type.
def is_sort(s)
Definition: z3py.py:561
def ArraySort(d, r)
Definition: z3py.py:4199

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

7858 def AtLeast(*args):
7859  """Create an at-most Pseudo-Boolean k constraint.
7860 
7861  >>> a, b, c = Bools('a b c')
7862  >>> f = AtLeast(a, b, c, 2)
7863  """
7864  args = _get_args(args)
7865  if __debug__:
7866  _z3_assert(len(args) > 1, "Non empty list of arguments expected")
7867  ctx = _ctx_from_ast_arg_list(args)
7868  if __debug__:
7869  _z3_assert(ctx is not None, "At least one of the arguments must be a Z3 expression")
7870  args1 = _coerce_expr_list(args[:-1], ctx)
7871  k = args[-1]
7872  _args, sz = _to_ast_array(args1)
7873  return BoolRef(Z3_mk_atleast(ctx.ref(), sz, _args, k), ctx)
7874 
7875 
def AtLeast(args)
Definition: z3py.py:7858
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 7841 of file z3py.py.

7841 def AtMost(*args):
7842  """Create an at-most Pseudo-Boolean k constraint.
7843 
7844  >>> a, b, c = Bools('a b c')
7845  >>> f = AtMost(a, b, c, 2)
7846  """
7847  args = _get_args(args)
7848  if __debug__:
7849  _z3_assert(len(args) > 1, "Non empty list of arguments expected")
7850  ctx = _ctx_from_ast_arg_list(args)
7851  if __debug__:
7852  _z3_assert(ctx is not None, "At least one of the arguments must be a Z3 expression")
7853  args1 = _coerce_expr_list(args[:-1], ctx)
7854  k = args[-1]
7855  _args, sz = _to_ast_array(args1)
7856  return BoolRef(Z3_mk_atmost(ctx.ref(), sz, _args, k), ctx)
7857 
def AtMost(args)
Definition: z3py.py:7841
Z3_ast Z3_API Z3_mk_atmost(Z3_context c, unsigned num_args, Z3_ast const args[], unsigned k)
Pseudo-Boolean relations.

◆ binary_interpolant()

def z3py.binary_interpolant (   a,
  b,
  p = None,
  ctx = None 
)
Compute an interpolant for a binary conjunction.

If a & b is unsatisfiable, returns an interpolant for a & b.
This is a formula phi such that

1) a implies phi
2) b implies not phi
3) All the uninterpreted symbols of phi occur in both a and b.

If a & b is satisfiable, raises an object of class ModelRef
that represents a model of a &b.

If neither a proof of unsatisfiability nor a model is obtained
(for example, because of a timeout, or because models are disabled)
then None is returned.

If parameters p are supplied, these are used in creating the
solver that determines satisfiability.

x = Int('x')
print(binary_interpolant(x<0,x>2))
Not(x >= 0)

Definition at line 8221 of file z3py.py.

8221 def binary_interpolant(a,b,p=None,ctx=None):
8222  """Compute an interpolant for a binary conjunction.
8223 
8224  If a & b is unsatisfiable, returns an interpolant for a & b.
8225  This is a formula phi such that
8226 
8227  1) a implies phi
8228  2) b implies not phi
8229  3) All the uninterpreted symbols of phi occur in both a and b.
8230 
8231  If a & b is satisfiable, raises an object of class ModelRef
8232  that represents a model of a &b.
8233 
8234  If neither a proof of unsatisfiability nor a model is obtained
8235  (for example, because of a timeout, or because models are disabled)
8236  then None is returned.
8237 
8238  If parameters p are supplied, these are used in creating the
8239  solver that determines satisfiability.
8240 
8241  x = Int('x')
8242  print(binary_interpolant(x<0,x>2))
8243  Not(x >= 0)
8244  """
8245  f = And(Interpolant(a),b)
8246  ti = tree_interpolant(f,p,ctx)
8247  return ti[0] if ti is not None else None
8248 
def And(args)
Definition: z3py.py:1578
def binary_interpolant(a, b, p=None, ctx=None)
Definition: z3py.py:8221
def Interpolant(a, ctx=None)
Definition: z3py.py:8142
def tree_interpolant(pat, p=None, ctx=None)
Definition: z3py.py:8156

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

3601 def BitVec(name, bv, ctx=None):
3602  """Return a bit-vector constant named `name`. `bv` may be the number of bits of a bit-vector sort.
3603  If `ctx=None`, then the global context is used.
3604 
3605  >>> x = BitVec('x', 16)
3606  >>> is_bv(x)
3607  True
3608  >>> x.size()
3609  16
3610  >>> x.sort()
3611  BitVec(16)
3612  >>> word = BitVecSort(16)
3613  >>> x2 = BitVec('x', word)
3614  >>> eq(x, x2)
3615  True
3616  """
3617  if isinstance(bv, BitVecSortRef):
3618  ctx = bv.ctx
3619  else:
3620  ctx = _get_ctx(ctx)
3621  bv = BitVecSort(bv, ctx)
3622  return BitVecRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), bv.ast), ctx)
3623 
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:101
def BitVec(name, bv, ctx=None)
Definition: z3py.py:3601
def BitVecSort(sz, ctx=None)
Definition: z3py.py:3571

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

3624 def BitVecs(names, bv, ctx=None):
3625  """Return a tuple of bit-vector constants of size bv.
3626 
3627  >>> x, y, z = BitVecs('x y z', 16)
3628  >>> x.size()
3629  16
3630  >>> x.sort()
3631  BitVec(16)
3632  >>> Sum(x, y, z)
3633  0 + x + y + z
3634  >>> Product(x, y, z)
3635  1*x*y*z
3636  >>> simplify(Product(x, y, z))
3637  x*y*z
3638  """
3639  ctx = _get_ctx(ctx)
3640  if isinstance(names, str):
3641  names = names.split(" ")
3642  return [BitVec(name, bv, ctx) for name in names]
3643 
def BitVec(name, bv, ctx=None)
Definition: z3py.py:3601
def BitVecs(names, bv, ctx=None)
Definition: z3py.py:3624

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

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

3571 def BitVecSort(sz, ctx=None):
3572  """Return a Z3 bit-vector sort of the given size. If `ctx=None`, then the global context is used.
3573 
3574  >>> Byte = BitVecSort(8)
3575  >>> Word = BitVecSort(16)
3576  >>> Byte
3577  BitVec(8)
3578  >>> x = Const('x', Byte)
3579  >>> eq(x, BitVec('x', 8))
3580  True
3581  """
3582  ctx = _get_ctx(ctx)
3583  return BitVecSortRef(Z3_mk_bv_sort(ctx.ref(), sz), ctx)
3584 
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:3571

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

3585 def BitVecVal(val, bv, ctx=None):
3586  """Return a bit-vector value with the given number of bits. If `ctx=None`, then the global context is used.
3587 
3588  >>> v = BitVecVal(10, 32)
3589  >>> v
3590  10
3591  >>> print("0x%.8x" % v.as_long())
3592  0x0000000a
3593  """
3594  if is_bv_sort(bv):
3595  ctx = bv.ctx
3596  return BitVecNumRef(Z3_mk_numeral(ctx.ref(), _to_int_str(val), bv.ast), ctx)
3597  else:
3598  ctx = _get_ctx(ctx)
3599  return BitVecNumRef(Z3_mk_numeral(ctx.ref(), _to_int_str(val), BitVecSort(bv, ctx).ast), ctx)
3600 
def BitVecVal(val, bv, ctx=None)
Definition: z3py.py:3585
def is_bv_sort(s)
Definition: z3py.py:3061
def BitVecSort(sz, ctx=None)
Definition: z3py.py:3571
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 1470 of file z3py.py.

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

1470 def Bool(name, ctx=None):
1471  """Return a Boolean constant named `name`. If `ctx=None`, then the global context is used.
1472 
1473  >>> p = Bool('p')
1474  >>> q = Bool('q')
1475  >>> And(p, q)
1476  And(p, q)
1477  """
1478  ctx = _get_ctx(ctx)
1479  return BoolRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), BoolSort(ctx).ast), ctx)
1480 
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:101
def Bool(name, ctx=None)
Definition: z3py.py:1470
def BoolSort(ctx=None)
Definition: z3py.py:1435

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

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

1481 def Bools(names, ctx=None):
1482  """Return a tuple of Boolean constants.
1483 
1484  `names` is a single string containing all names separated by blank spaces.
1485  If `ctx=None`, then the global context is used.
1486 
1487  >>> p, q, r = Bools('p q r')
1488  >>> And(p, Or(q, r))
1489  And(p, Or(q, r))
1490  """
1491  ctx = _get_ctx(ctx)
1492  if isinstance(names, str):
1493  names = names.split(" ")
1494  return [Bool(name, ctx) for name in names]
1495 
def Bools(names, ctx=None)
Definition: z3py.py:1481
def Bool(name, ctx=None)
Definition: z3py.py:1470

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

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

1435 def BoolSort(ctx=None):
1436  """Return the Boolean Z3 sort. If `ctx=None`, then the global context is used.
1437 
1438  >>> BoolSort()
1439  Bool
1440  >>> p = Const('p', BoolSort())
1441  >>> is_bool(p)
1442  True
1443  >>> r = Function('r', IntSort(), IntSort(), BoolSort())
1444  >>> r(0, 1)
1445  r(0, 1)
1446  >>> is_bool(r(0, 1))
1447  True
1448  """
1449  ctx = _get_ctx(ctx)
1450  return BoolSortRef(Z3_mk_bool_sort(ctx.ref()), ctx)
1451 
def is_bool(a)
Definition: z3py.py:1335
def BoolSort(ctx=None)
Definition: z3py.py:1435

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

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

1452 def BoolVal(val, ctx=None):
1453  """Return the Boolean value `True` or `False`. If `ctx=None`, then the global context is used.
1454 
1455  >>> BoolVal(True)
1456  True
1457  >>> is_true(BoolVal(True))
1458  True
1459  >>> is_true(True)
1460  False
1461  >>> is_false(BoolVal(False))
1462  True
1463  """
1464  ctx = _get_ctx(ctx)
1465  if val == False:
1466  return BoolRef(Z3_mk_false(ctx.ref()), ctx)
1467  else:
1468  return BoolRef(Z3_mk_true(ctx.ref()), ctx)
1469 
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:1452

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

Referenced by And(), and Or().

1496 def BoolVector(prefix, sz, ctx=None):
1497  """Return a list of Boolean constants of size `sz`.
1498 
1499  The constants are named using the given prefix.
1500  If `ctx=None`, then the global context is used.
1501 
1502  >>> P = BoolVector('p', 3)
1503  >>> P
1504  [p__0, p__1, p__2]
1505  >>> And(P)
1506  And(p__0, p__1, p__2)
1507  """
1508  return [ Bool('%s__%s' % (prefix, i)) for i in range(sz) ]
1509 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:2813
def BoolVector(prefix, sz, ctx=None)
Definition: z3py.py:1496
def Bool(name, ctx=None)
Definition: z3py.py:1470

◆ BV2Int()

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

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

Definition at line 3549 of file z3py.py.

3549 def BV2Int(a, is_signed=False):
3550  """Return the Z3 expression BV2Int(a).
3551 
3552  >>> b = BitVec('b', 3)
3553  >>> BV2Int(b).sort()
3554  Int
3555  >>> x = Int('x')
3556  >>> x > BV2Int(b)
3557  x > BV2Int(b)
3558  >>> x > BV2Int(b, is_signed=False)
3559  x > BV2Int(b)
3560  >>> x > BV2Int(b, is_signed=True)
3561  x > If(b < 0, BV2Int(b) - 8, BV2Int(b))
3562  >>> solve(x > BV2Int(b), b == 1, x < 3)
3563  [b = 1, x = 2]
3564  """
3565  if __debug__:
3566  _z3_assert(is_bv(a), "Z3 bit-vector expression expected")
3567  ctx = a.ctx
3568 
3569  return ArithRef(Z3_mk_bv2int(ctx.ref(), a.as_ast(), is_signed), ctx)
3570 
Z3_ast Z3_API Z3_mk_bv2int(Z3_context c, Z3_ast t1, Z3_bool is_signed)
Create an integer from the bit-vector argument t1. If is_signed is false, then the bit-vector t1 is t...
def BV2Int(a, is_signed=False)
Definition: z3py.py:3549
def is_bv(a)
Definition: z3py.py:3522

◆ BVAddNoOverflow()

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

Definition at line 3996 of file z3py.py.

3996 def BVAddNoOverflow(a, b, signed):
3997  """A predicate the determines that bit-vector addition does not overflow"""
3998  _check_bv_args(a, b)
3999  a, b = _coerce_exprs(a, b)
4000  return BoolRef(Z3_mk_bvadd_no_overflow(a.ctx_ref(), a.as_ast(), b.as_ast(), signed), a.ctx)
4001 
def BVAddNoOverflow(a, b, signed)
Definition: z3py.py:3996
Z3_ast Z3_API Z3_mk_bvadd_no_overflow(Z3_context c, Z3_ast t1, Z3_ast t2, Z3_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 4002 of file z3py.py.

4002 def BVAddNoUnderflow(a, b):
4003  """A predicate the determines that signed bit-vector addition does not underflow"""
4004  _check_bv_args(a, b)
4005  a, b = _coerce_exprs(a, b)
4006  return BoolRef(Z3_mk_bvadd_no_underflow(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4007 
def BVAddNoUnderflow(a, b)
Definition: z3py.py:4002
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 4033 of file z3py.py.

4033 def BVMulNoOverflow(a, b, signed):
4034  """A predicate the determines that bit-vector multiplication does not overflow"""
4035  _check_bv_args(a, b)
4036  a, b = _coerce_exprs(a, b)
4037  return BoolRef(Z3_mk_bvmul_no_overflow(a.ctx_ref(), a.as_ast(), b.as_ast(), signed), a.ctx)
4038 
4039 
Z3_ast Z3_API Z3_mk_bvmul_no_overflow(Z3_context c, Z3_ast t1, Z3_ast t2, Z3_bool is_signed)
Create a predicate that checks that the bit-wise multiplication of t1 and t2 does not overflow...
def BVMulNoOverflow(a, b, signed)
Definition: z3py.py:4033

◆ BVMulNoUnderflow()

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

Definition at line 4040 of file z3py.py.

4040 def BVMulNoUnderflow(a, b):
4041  """A predicate the determines that bit-vector signed multiplication does not underflow"""
4042  _check_bv_args(a, b)
4043  a, b = _coerce_exprs(a, b)
4044  return BoolRef(Z3_mk_bvmul_no_underflow(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4045 
4046 
4047 
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:4040

◆ BVRedAnd()

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

Definition at line 3984 of file z3py.py.

3984 def BVRedAnd(a):
3985  """Return the reduction-and expression of `a`."""
3986  if __debug__:
3987  _z3_assert(is_bv(a), "First argument must be a Z3 Bitvector expression")
3988  return BitVecRef(Z3_mk_bvredand(a.ctx_ref(), a.as_ast()), a.ctx)
3989 
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:3984
def is_bv(a)
Definition: z3py.py:3522

◆ BVRedOr()

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

Definition at line 3990 of file z3py.py.

3990 def BVRedOr(a):
3991  """Return the reduction-or expression of `a`."""
3992  if __debug__:
3993  _z3_assert(is_bv(a), "First argument must be a Z3 Bitvector expression")
3994  return BitVecRef(Z3_mk_bvredor(a.ctx_ref(), a.as_ast()), a.ctx)
3995 
def BVRedOr(a)
Definition: z3py.py:3990
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:3522

◆ BVSDivNoOverflow()

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

Definition at line 4021 of file z3py.py.

4021 def BVSDivNoOverflow(a, b):
4022  """A predicate the determines that bit-vector signed division does not overflow"""
4023  _check_bv_args(a, b)
4024  a, b = _coerce_exprs(a, b)
4025  return BoolRef(Z3_mk_bvsdiv_no_overflow(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4026 
def BVSDivNoOverflow(a, b)
Definition: z3py.py:4021
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 4027 of file z3py.py.

4027 def BVSNegNoOverflow(a):
4028  """A predicate the determines that bit-vector unary negation does not overflow"""
4029  if __debug__:
4030  _z3_assert(is_bv(a), "Argument should be a bit-vector")
4031  return BoolRef(Z3_mk_bvneg_no_overflow(a.ctx_ref(), a.as_ast()), a.ctx)
4032 
Z3_ast Z3_API Z3_mk_bvneg_no_overflow(Z3_context c, Z3_ast t1)
Check that bit-wise negation does not overflow when t1 is interpreted as a signed bit-vector...
def BVSNegNoOverflow(a)
Definition: z3py.py:4027
def is_bv(a)
Definition: z3py.py:3522

◆ BVSubNoOverflow()

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

Definition at line 4008 of file z3py.py.

4008 def BVSubNoOverflow(a, b):
4009  """A predicate the determines that bit-vector subtraction does not overflow"""
4010  _check_bv_args(a, b)
4011  a, b = _coerce_exprs(a, b)
4012  return BoolRef(Z3_mk_bvsub_no_overflow(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4013 
4014 
def BVSubNoOverflow(a, b)
Definition: z3py.py:4008
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 4015 of file z3py.py.

4015 def BVSubNoUnderflow(a, b, signed):
4016  """A predicate the determines that bit-vector subtraction does not underflow"""
4017  _check_bv_args(a, b)
4018  a, b = _coerce_exprs(a, b)
4019  return BoolRef(Z3_mk_bvsub_no_underflow(a.ctx_ref(), a.as_ast(), b.as_ast(), signed), a.ctx)
4020 
def BVSubNoUnderflow(a, b, signed)
Definition: z3py.py:4015
Z3_ast Z3_API Z3_mk_bvsub_no_underflow(Z3_context c, Z3_ast t1, Z3_ast t2, Z3_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 3011 of file z3py.py.

3011 def Cbrt(a, ctx=None):
3012  """ Return a Z3 expression which represents the cubic root of a.
3013 
3014  >>> x = Real('x')
3015  >>> Cbrt(x)
3016  x**(1/3)
3017  """
3018  if not is_expr(a):
3019  ctx = _get_ctx(ctx)
3020  a = RealVal(a, ctx)
3021  return a ** "1/3"
3022 
def Cbrt(a, ctx=None)
Definition: z3py.py:3011
def RealVal(val, ctx=None)
Definition: z3py.py:2804
def is_expr(a)
Definition: z3py.py:1033

◆ Complement()

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

Definition at line 9999 of file z3py.py.

9999 def Complement(re):
10000  """Create the complement regular expression."""
10001  return ReRef(Z3_mk_re_complement(re.ctx_ref(), re.as_ast()), re.ctx)
10002 
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:9999

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

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

3644 def Concat(*args):
3645  """Create a Z3 bit-vector concatenation expression.
3646 
3647  >>> v = BitVecVal(1, 4)
3648  >>> Concat(v, v+1, v)
3649  Concat(Concat(1, 1 + 1), 1)
3650  >>> simplify(Concat(v, v+1, v))
3651  289
3652  >>> print("%.3x" % simplify(Concat(v, v+1, v)).as_long())
3653  121
3654  """
3655  args = _get_args(args)
3656  sz = len(args)
3657  if __debug__:
3658  _z3_assert(sz >= 2, "At least two arguments expected.")
3659 
3660  ctx = None
3661  for a in args:
3662  if is_expr(a):
3663  ctx = a.ctx
3664  break
3665  if is_seq(args[0]) or isinstance(args[0], str):
3666  args = [_coerce_seq(s, ctx) for s in args]
3667  if __debug__:
3668  _z3_assert(all([is_seq(a) for a in args]), "All arguments must be sequence expressions.")
3669  v = (Ast * sz)()
3670  for i in range(sz):
3671  v[i] = args[i].as_ast()
3672  return SeqRef(Z3_mk_seq_concat(ctx.ref(), sz, v), ctx)
3673 
3674  if is_re(args[0]):
3675  if __debug__:
3676  _z3_assert(all([is_re(a) for a in args]), "All arguments must be regular expressions.")
3677  v = (Ast * sz)()
3678  for i in range(sz):
3679  v[i] = args[i].as_ast()
3680  return ReRef(Z3_mk_re_concat(ctx.ref(), sz, v), ctx)
3681 
3682  if __debug__:
3683  _z3_assert(all([is_bv(a) for a in args]), "All arguments must be Z3 bit-vector expressions.")
3684  r = args[0]
3685  for i in range(sz - 1):
3686  r = BitVecRef(Z3_mk_concat(ctx.ref(), r.as_ast(), args[i+1].as_ast()), ctx)
3687  return r
3688 
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:2813
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:9939
def is_expr(a)
Definition: z3py.py:1033
def is_bv(a)
Definition: z3py.py:3522
def Concat(args)
Definition: z3py.py:3644
def is_seq(a)
Definition: z3py.py:9707

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

Referenced by If().

7696 def Cond(p, t1, t2, ctx=None):
7697  """Return a tactic that applies tactic `t1` to a goal if probe `p` evaluates to true, and `t2` otherwise.
7698 
7699  >>> t = Cond(Probe('is-qfnra'), Tactic('qfnra'), Tactic('smt'))
7700  """
7701  p = _to_probe(p, ctx)
7702  t1 = _to_tactic(t1, ctx)
7703  t2 = _to_tactic(t2, ctx)
7704  return Tactic(Z3_tactic_cond(t1.ctx.ref(), p.probe, t1.tactic, t2.tactic), t1.ctx)
7705 
def Cond(p, t1, t2, ctx=None)
Definition: z3py.py:7696
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 1219 of file z3py.py.

Referenced by BitVecSort(), Consts(), FPSort(), IntSort(), RealSort(), and DatatypeSortRef.recognizer().

1219 def Const(name, sort):
1220  """Create a constant of the given sort.
1221 
1222  >>> Const('x', IntSort())
1223  x
1224  """
1225  if __debug__:
1226  _z3_assert(isinstance(sort, SortRef), "Z3 sort expected")
1227  ctx = sort.ctx
1228  return _to_expr_ref(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), sort.ast), ctx)
1229 
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:101
def Const(name, sort)
Definition: z3py.py:1219

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

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

1230 def Consts(names, sort):
1231  """Create a several constants of the given sort.
1232 
1233  `names` is a string containing the names of all constants to be created.
1234  Blank spaces separate the names of different constants.
1235 
1236  >>> x, y, z = Consts('x y z', IntSort())
1237  >>> x + y + z
1238  x + y + z
1239  """
1240  if isinstance(names, str):
1241  names = names.split(" ")
1242  return [Const(name, sort) for name in names]
1243 
def Consts(names, sort)
Definition: z3py.py:1230
def Const(name, sort)
Definition: z3py.py:1219

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

9820 def Contains(a, b):
9821  """Check if 'a' contains 'b'
9822  >>> s1 = Contains("abc", "ab")
9823  >>> simplify(s1)
9824  True
9825  >>> s2 = Contains("abc", "bc")
9826  >>> simplify(s2)
9827  True
9828  >>> x, y, z = Strings('x y z')
9829  >>> s3 = Contains(Concat(x,y,z), y)
9830  >>> simplify(s3)
9831  True
9832  """
9833  ctx = _get_ctx2(a, b)
9834  a = _coerce_seq(a, ctx)
9835  b = _coerce_seq(b, ctx)
9836  return BoolRef(Z3_mk_seq_contains(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
9837 
9838 
def Contains(a, b)
Definition: z3py.py:9820
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 4479 of file z3py.py.

Referenced by Datatype.create().

4479 def CreateDatatypes(*ds):
4480  """Create mutually recursive Z3 datatypes using 1 or more Datatype helper objects.
4481 
4482  In the following example we define a Tree-List using two mutually recursive datatypes.
4483 
4484  >>> TreeList = Datatype('TreeList')
4485  >>> Tree = Datatype('Tree')
4486  >>> # Tree has two constructors: leaf and node
4487  >>> Tree.declare('leaf', ('val', IntSort()))
4488  >>> # a node contains a list of trees
4489  >>> Tree.declare('node', ('children', TreeList))
4490  >>> TreeList.declare('nil')
4491  >>> TreeList.declare('cons', ('car', Tree), ('cdr', TreeList))
4492  >>> Tree, TreeList = CreateDatatypes(Tree, TreeList)
4493  >>> Tree.val(Tree.leaf(10))
4494  val(leaf(10))
4495  >>> simplify(Tree.val(Tree.leaf(10)))
4496  10
4497  >>> n1 = Tree.node(TreeList.cons(Tree.leaf(10), TreeList.cons(Tree.leaf(20), TreeList.nil)))
4498  >>> n1
4499  node(cons(leaf(10), cons(leaf(20), nil)))
4500  >>> n2 = Tree.node(TreeList.cons(n1, TreeList.nil))
4501  >>> simplify(n2 == n1)
4502  False
4503  >>> simplify(TreeList.car(Tree.children(n2)) == n1)
4504  True
4505  """
4506  ds = _get_args(ds)
4507  if __debug__:
4508  _z3_assert(len(ds) > 0, "At least one Datatype must be specified")
4509  _z3_assert(all([isinstance(d, Datatype) for d in ds]), "Arguments must be Datatypes")
4510  _z3_assert(all([d.ctx == ds[0].ctx for d in ds]), "Context mismatch")
4511  _z3_assert(all([d.constructors != [] for d in ds]), "Non-empty Datatypes expected")
4512  ctx = ds[0].ctx
4513  num = len(ds)
4514  names = (Symbol * num)()
4515  out = (Sort * num)()
4516  clists = (ConstructorList * num)()
4517  to_delete = []
4518  for i in range(num):
4519  d = ds[i]
4520  names[i] = to_symbol(d.name, ctx)
4521  num_cs = len(d.constructors)
4522  cs = (Constructor * num_cs)()
4523  for j in range(num_cs):
4524  c = d.constructors[j]
4525  cname = to_symbol(c[0], ctx)
4526  rname = to_symbol(c[1], ctx)
4527  fs = c[2]
4528  num_fs = len(fs)
4529  fnames = (Symbol * num_fs)()
4530  sorts = (Sort * num_fs)()
4531  refs = (ctypes.c_uint * num_fs)()
4532  for k in range(num_fs):
4533  fname = fs[k][0]
4534  ftype = fs[k][1]
4535  fnames[k] = to_symbol(fname, ctx)
4536  if isinstance(ftype, Datatype):
4537  if __debug__:
4538  _z3_assert(ds.count(ftype) == 1, "One and only one occurrence of each datatype is expected")
4539  sorts[k] = None
4540  refs[k] = ds.index(ftype)
4541  else:
4542  if __debug__:
4543  _z3_assert(is_sort(ftype), "Z3 sort expected")
4544  sorts[k] = ftype.ast
4545  refs[k] = 0
4546  cs[j] = Z3_mk_constructor(ctx.ref(), cname, rname, num_fs, fnames, sorts, refs)
4547  to_delete.append(ScopedConstructor(cs[j], ctx))
4548  clists[i] = Z3_mk_constructor_list(ctx.ref(), num_cs, cs)
4549  to_delete.append(ScopedConstructorList(clists[i], ctx))
4550  Z3_mk_datatypes(ctx.ref(), num, names, out, clists)
4551  result = []
4552 
4553  for i in range(num):
4554  dref = DatatypeSortRef(out[i], ctx)
4555  num_cs = dref.num_constructors()
4556  for j in range(num_cs):
4557  cref = dref.constructor(j)
4558  cref_name = cref.name()
4559  cref_arity = cref.arity()
4560  if cref.arity() == 0:
4561  cref = cref()
4562  setattr(dref, cref_name, cref)
4563  rref = dref.recognizer(j)
4564  setattr(dref, rref.name(), rref)
4565  for k in range(cref_arity):
4566  aref = dref.accessor(j, k)
4567  setattr(dref, aref.name(), aref)
4568  result.append(dref)
4569  return tuple(result)
4570 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:2813
def to_symbol(s, ctx=None)
Definition: z3py.py:101
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:4479
def is_sort(s)
Definition: z3py.py:561
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 uninterpred 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 598 of file z3py.py.

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

598 def DeclareSort(name, ctx=None):
599  """Create a new uninterpred sort named `name`.
600 
601  If `ctx=None`, then the new sort is declared in the global Z3Py context.
602 
603  >>> A = DeclareSort('A')
604  >>> a = Const('a', A)
605  >>> b = Const('b', A)
606  >>> a.sort() == A
607  True
608  >>> b.sort() == A
609  True
610  >>> a == b
611  a == b
612  """
613  ctx = _get_ctx(ctx)
614  return SortRef(Z3_mk_uninterpreted_sort(ctx.ref(), to_symbol(name, ctx)), ctx)
615 
def to_symbol(s, ctx=None)
Definition: z3py.py:101
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:598

◆ Default()

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

Definition at line 4254 of file z3py.py.

Referenced by is_default().

4254 def Default(a):
4255  """ Return a default value for array expression.
4256  >>> b = K(IntSort(), 1)
4257  >>> prove(Default(b) == 1)
4258  proved
4259  """
4260  if __debug__:
4261  _z3_assert(is_array(a), "First argument must be a Z3 array expression")
4262  return a.default()
4263 
4264 
def is_array(a)
Definition: z3py.py:4122
def Default(a)
Definition: z3py.py:4254

◆ describe_probes()

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

Definition at line 7626 of file z3py.py.

7626 def describe_probes():
7627  """Display a (tabular) description of all available probes in Z3."""
7628  if in_html_mode():
7629  even = True
7630  print('<table border="1" cellpadding="2" cellspacing="0">')
7631  for p in probes():
7632  if even:
7633  print('<tr style="background-color:#CFCFCF">')
7634  even = False
7635  else:
7636  print('<tr>')
7637  even = True
7638  print('<td>%s</td><td>%s</td></tr>' % (p, insert_line_breaks(probe_description(p), 40)))
7639  print('</table>')
7640  else:
7641  for p in probes():
7642  print('%s : %s' % (p, probe_description(p)))
7643 
def probes(ctx=None)
Definition: z3py.py:7608
def probe_description(name, ctx=None)
Definition: z3py.py:7618
def describe_probes()
Definition: z3py.py:7626

◆ describe_tactics()

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

Definition at line 7435 of file z3py.py.

7435 def describe_tactics():
7436  """Display a (tabular) description of all available tactics in Z3."""
7437  if in_html_mode():
7438  even = True
7439  print('<table border="1" cellpadding="2" cellspacing="0">')
7440  for t in tactics():
7441  if even:
7442  print('<tr style="background-color:#CFCFCF">')
7443  even = False
7444  else:
7445  print('<tr>')
7446  even = True
7447  print('<td>%s</td><td>%s</td></tr>' % (t, insert_line_breaks(tactic_description(t), 40)))
7448  print('</table>')
7449  else:
7450  for t in tactics():
7451  print('%s : %s' % (t, tactic_description(t)))
7452 
def tactics(ctx=None)
Definition: z3py.py:7417
def tactic_description(name, ctx=None)
Definition: z3py.py:7427
def describe_tactics()
Definition: z3py.py:7435

◆ disable_trace()

def z3py.disable_trace (   msg)

Definition at line 65 of file z3py.py.

65 def disable_trace(msg):
66  Z3_disable_trace(msg)
67 
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:65

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

1188 def Distinct(*args):
1189  """Create a Z3 distinct expression.
1190 
1191  >>> x = Int('x')
1192  >>> y = Int('y')
1193  >>> Distinct(x, y)
1194  x != y
1195  >>> z = Int('z')
1196  >>> Distinct(x, y, z)
1197  Distinct(x, y, z)
1198  >>> simplify(Distinct(x, y, z))
1199  Distinct(x, y, z)
1200  >>> simplify(Distinct(x, y, z), blast_distinct=True)
1201  And(Not(x == y), Not(x == z), Not(y == z))
1202  """
1203  args = _get_args(args)
1204  ctx = _ctx_from_ast_arg_list(args)
1205  if __debug__:
1206  _z3_assert(ctx is not None, "At least one of the arguments must be a Z3 expression")
1207  args = _coerce_expr_list(args, ctx)
1208  _args, sz = _to_ast_array(args)
1209  return BoolRef(Z3_mk_distinct(ctx.ref(), sz, _args), ctx)
1210 
Z3_ast Z3_API Z3_mk_distinct(Z3_context c, unsigned num_args, Z3_ast const args[])
Create an AST node representing distinct(args[0], ..., args[num_args-1]).
def Distinct(args)
Definition: z3py.py:1188

◆ Empty()

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

Definition at line 9753 of file z3py.py.

9753 def Empty(s):
9754  """Create the empty sequence of the given sort
9755  >>> e = Empty(StringSort())
9756  >>> print(e)
9757  ""
9758  >>> e2 = StringVal("")
9759  >>> print(e.eq(e2))
9760  True
9761  >>> e3 = Empty(SeqSort(IntSort()))
9762  >>> print(e3)
9763  seq.empty
9764  >>> e4 = Empty(ReSort(SeqSort(IntSort())))
9765  >>> print(e4)
9766  re.empty
9767  """
9768  if isinstance(s, SeqSortRef):
9769  return SeqRef(Z3_mk_seq_empty(s.ctx_ref(), s.ast), s.ctx)
9770  if isinstance(s, ReSortRef):
9771  return ReRef(Z3_mk_re_empty(s.ctx_ref(), s.ast), s.ctx)
9772  raise Z3Exception("Non-sequence, non-regular expression sort passed to Empty")
9773 
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:9753

◆ enable_trace()

def z3py.enable_trace (   msg)

Definition at line 62 of file z3py.py.

62 def enable_trace(msg):
63  Z3_enable_trace(msg)
64 
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:62

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

Referenced by Context.mkEnumSort().

4668 def EnumSort(name, values, ctx=None):
4669  """Return a new enumeration sort named `name` containing the given values.
4670 
4671  The result is a pair (sort, list of constants).
4672  Example:
4673  >>> Color, (red, green, blue) = EnumSort('Color', ['red', 'green', 'blue'])
4674  """
4675  if __debug__:
4676  _z3_assert(isinstance(name, str), "Name must be a string")
4677  _z3_assert(all([isinstance(v, str) for v in values]), "Eumeration sort values must be strings")
4678  _z3_assert(len(values) > 0, "At least one value expected")
4679  ctx = _get_ctx(ctx)
4680  num = len(values)
4681  _val_names = (Symbol * num)()
4682  for i in range(num):
4683  _val_names[i] = to_symbol(values[i])
4684  _values = (FuncDecl * num)()
4685  _testers = (FuncDecl * num)()
4686  name = to_symbol(name)
4687  S = DatatypeSortRef(Z3_mk_enumeration_sort(ctx.ref(), name, num, _val_names, _values, _testers), ctx)
4688  V = []
4689  for i in range(num):
4690  V.append(FuncDeclRef(_values[i], ctx))
4691  V = [a() for a in V]
4692  return S, V
4693 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:2813
def to_symbol(s, ctx=None)
Definition: z3py.py:101
def EnumSort(name, values, ctx=None)
Definition: z3py.py:4668
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 398 of file z3py.py.

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

398 def eq(a, b):
399  """Return `True` if `a` and `b` are structurally identical AST nodes.
400 
401  >>> x = Int('x')
402  >>> y = Int('y')
403  >>> eq(x, y)
404  False
405  >>> eq(x + 1, x + 1)
406  True
407  >>> eq(x + 1, 1 + x)
408  False
409  >>> eq(simplify(x + 1), simplify(1 + x))
410  True
411  """
412  if __debug__:
413  _z3_assert(is_ast(a) and is_ast(b), "Z3 ASTs expected")
414  return a.eq(b)
415 
def eq(a, b)
Definition: z3py.py:398
def is_ast(a)
Definition: z3py.py:378

◆ 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.

See http://rise4fun.com/Z3Py/tutorial/advanced for more details.

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

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

1923 def Exists(vs, body, weight=1, qid="", skid="", patterns=[], no_patterns=[]):
1924  """Create a Z3 exists formula.
1925 
1926  The parameters `weight`, `qif`, `skid`, `patterns` and `no_patterns` are optional annotations.
1927 
1928  See http://rise4fun.com/Z3Py/tutorial/advanced for more details.
1929 
1930  >>> f = Function('f', IntSort(), IntSort(), IntSort())
1931  >>> x = Int('x')
1932  >>> y = Int('y')
1933  >>> q = Exists([x, y], f(x, y) >= x, skid="foo")
1934  >>> q
1935  Exists([x, y], f(x, y) >= x)
1936  >>> is_quantifier(q)
1937  True
1938  >>> r = Tactic('nnf')(q).as_expr()
1939  >>> is_quantifier(r)
1940  False
1941  """
1942  return _mk_quantifier(False, vs, body, weight, qid, skid, patterns, no_patterns)
1943 
def Exists(vs, body, weight=1, qid="", skid="", patterns=[], no_patterns=[])
Definition: z3py.py:1923

◆ Ext()

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

Definition at line 4339 of file z3py.py.

4339 def Ext(a, b):
4340  """Return extensionality index for arrays.
4341  """
4342  if __debug__:
4343  _z3_assert(is_array(a) and is_array(b))
4344  return _to_expr_ref(Z3_mk_array_ext(ctx.ref(), a.as_ast(), b.as_ast()));
4345 
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:4122
def Ext(a, b)
Definition: z3py.py:4339

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

3689 def Extract(high, low, a):
3690  """Create a Z3 bit-vector extraction expression, or create a string extraction expression.
3691 
3692  >>> x = BitVec('x', 8)
3693  >>> Extract(6, 2, x)
3694  Extract(6, 2, x)
3695  >>> Extract(6, 2, x).sort()
3696  BitVec(5)
3697  >>> simplify(Extract(StringVal("abcd"),2,1))
3698  "c"
3699  """
3700  if isinstance(high, str):
3701  high = StringVal(high)
3702  if is_seq(high):
3703  s = high
3704  offset, length = _coerce_exprs(low, a, s.ctx)
3705  return SeqRef(Z3_mk_seq_extract(s.ctx_ref(), s.as_ast(), offset.as_ast(), length.as_ast()), s.ctx)
3706  if __debug__:
3707  _z3_assert(low <= high, "First argument must be greater than or equal to second argument")
3708  _z3_assert(_is_int(high) and high >= 0 and _is_int(low) and low >= 0, "First and second arguments must be non negative integers")
3709  _z3_assert(is_bv(a), "Third argument must be a Z3 Bitvector expression")
3710  return BitVecRef(Z3_mk_extract(a.ctx_ref(), high, low, a.as_ast()), a.ctx)
3711 
def Extract(high, low, a)
Definition: z3py.py:3689
def StringVal(s, ctx=None)
Definition: z3py.py:9733
Z3_ast Z3_API Z3_mk_seq_extract(Z3_context c, Z3_ast s, Z3_ast offset, Z3_ast length)
Extract subsequence starting at offset of length.
Z3_ast Z3_API Z3_mk_extract(Z3_context c, unsigned high, unsigned low, Z3_ast t1)
Extract the bits high down to low from a bit-vector of size m to yield a new bit-vector of size n...
def is_bv(a)
Definition: z3py.py:3522
def is_seq(a)
Definition: z3py.py:9707

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

7659 def FailIf(p, ctx=None):
7660  """Return a tactic that fails if the probe `p` evaluates to true. Otherwise, it returns the input goal unmodified.
7661 
7662  In the following example, the tactic applies 'simplify' if and only if there are more than 2 constraints in the goal.
7663 
7664  >>> t = OrElse(FailIf(Probe('size') > 2), Tactic('simplify'))
7665  >>> x, y = Ints('x y')
7666  >>> g = Goal()
7667  >>> g.add(x > 0)
7668  >>> g.add(y > 0)
7669  >>> t(g)
7670  [[x > 0, y > 0]]
7671  >>> g.add(x == y + 1)
7672  >>> t(g)
7673  [[Not(x <= 0), Not(y <= 0), x == 1 + y]]
7674  """
7675  p = _to_probe(p, ctx)
7676  return Tactic(Z3_tactic_fail_if(p.ctx.ref(), p.probe), p.ctx)
7677 
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:7659

◆ FiniteDomainSort()

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

Definition at line 6767 of file z3py.py.

Referenced by Context.mkFiniteDomainSort().

6767 def FiniteDomainSort(name, sz, ctx=None):
6768  """Create a named finite domain sort of a given size sz"""
6769  if not isinstance(name, Symbol):
6770  name = to_symbol(name)
6771  ctx = _get_ctx(ctx)
6772  return FiniteDomainSortRef(Z3_mk_finite_domain_sort(ctx.ref(), name, sz), ctx)
6773 
def to_symbol(s, ctx=None)
Definition: z3py.py:101
def FiniteDomainSort(name, sz, ctx=None)
Definition: z3py.py:6767
Z3_sort Z3_API Z3_mk_finite_domain_sort(Z3_context c, Z3_symbol name, __uint64 size)
Create a named finite domain sort.

◆ FiniteDomainVal()

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

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

Definition at line 6835 of file z3py.py.

6835 def FiniteDomainVal(val, sort, ctx=None):
6836  """Return a Z3 finite-domain value. If `ctx=None`, then the global context is used.
6837 
6838  >>> s = FiniteDomainSort('S', 256)
6839  >>> FiniteDomainVal(255, s)
6840  255
6841  >>> FiniteDomainVal('100', s)
6842  100
6843  """
6844  if __debug__:
6845  _z3_assert(is_finite_domain_sort(sort), "Expected finite-domain sort" )
6846  ctx = sort.ctx
6847  return FiniteDomainNumRef(Z3_mk_numeral(ctx.ref(), _to_int_str(val), sort.ast), ctx)
6848 
def is_finite_domain_sort(s)
Definition: z3py.py:6774
def FiniteDomainVal(val, sort, ctx=None)
Definition: z3py.py:6835
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 8428 of file z3py.py.

8428 def Float128(ctx=None):
8429  """Floating-point 128-bit (quadruple) sort."""
8430  ctx = _get_ctx(ctx)
8431  return FPSortRef(Z3_mk_fpa_sort_128(ctx.ref()), ctx)
8432 
def Float128(ctx=None)
Definition: z3py.py:8428
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 8398 of file z3py.py.

8398 def Float16(ctx=None):
8399  """Floating-point 16-bit (half) sort."""
8400  ctx = _get_ctx(ctx)
8401  return FPSortRef(Z3_mk_fpa_sort_16(ctx.ref()), ctx)
8402 
def Float16(ctx=None)
Definition: z3py.py:8398
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 8408 of file z3py.py.

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

8408 def Float32(ctx=None):
8409  """Floating-point 32-bit (single) sort."""
8410  ctx = _get_ctx(ctx)
8411  return FPSortRef(Z3_mk_fpa_sort_32(ctx.ref()), ctx)
8412 
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:8408

◆ Float64()

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

Definition at line 8418 of file z3py.py.

Referenced by fpFPToFP(), and fpToFP().

8418 def Float64(ctx=None):
8419  """Floating-point 64-bit (double) sort."""
8420  ctx = _get_ctx(ctx)
8421  return FPSortRef(Z3_mk_fpa_sort_64(ctx.ref()), ctx)
8422 
def Float64(ctx=None)
Definition: z3py.py:8418
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 8423 of file z3py.py.

8423 def FloatDouble(ctx=None):
8424  """Floating-point 64-bit (double) sort."""
8425  ctx = _get_ctx(ctx)
8426  return FPSortRef(Z3_mk_fpa_sort_double(ctx.ref()), ctx)
8427 
def FloatDouble(ctx=None)
Definition: z3py.py:8423
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 8403 of file z3py.py.

8403 def FloatHalf(ctx=None):
8404  """Floating-point 16-bit (half) sort."""
8405  ctx = _get_ctx(ctx)
8406  return FPSortRef(Z3_mk_fpa_sort_half(ctx.ref()), ctx)
8407 
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:8403

◆ FloatQuadruple()

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

Definition at line 8433 of file z3py.py.

8433 def FloatQuadruple(ctx=None):
8434  """Floating-point 128-bit (quadruple) sort."""
8435  ctx = _get_ctx(ctx)
8436  return FPSortRef(Z3_mk_fpa_sort_quadruple(ctx.ref()), ctx)
8437 
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:8433

◆ FloatSingle()

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

Definition at line 8413 of file z3py.py.

8413 def FloatSingle(ctx=None):
8414  """Floating-point 32-bit (single) sort."""
8415  ctx = _get_ctx(ctx)
8416  return FPSortRef(Z3_mk_fpa_sort_single(ctx.ref()), ctx)
8417 
def FloatSingle(ctx=None)
Definition: z3py.py:8413
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.

See http://rise4fun.com/Z3Py/tutorial/advanced for more details.

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

Referenced by Fixedpoint.abstract(), QuantifierRef.body(), QuantifierRef.children(), 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().

1904 def ForAll(vs, body, weight=1, qid="", skid="", patterns=[], no_patterns=[]):
1905  """Create a Z3 forall formula.
1906 
1907  The parameters `weight`, `qif`, `skid`, `patterns` and `no_patterns` are optional annotations.
1908 
1909  See http://rise4fun.com/Z3Py/tutorial/advanced for more details.
1910 
1911  >>> f = Function('f', IntSort(), IntSort(), IntSort())
1912  >>> x = Int('x')
1913  >>> y = Int('y')
1914  >>> ForAll([x, y], f(x, y) >= x)
1915  ForAll([x, y], f(x, y) >= x)
1916  >>> ForAll([x, y], f(x, y) >= x, patterns=[ f(x, y) ])
1917  ForAll([x, y], f(x, y) >= x)
1918  >>> ForAll([x, y], f(x, y) >= x, weight=10)
1919  ForAll([x, y], f(x, y) >= x)
1920  """
1921  return _mk_quantifier(True, vs, body, weight, qid, skid, patterns, no_patterns)
1922 
def ForAll(vs, body, weight=1, qid="", skid="", patterns=[], no_patterns=[])
Definition: z3py.py:1904

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

9011 def FP(name, fpsort, ctx=None):
9012  """Return a floating-point constant named `name`.
9013  `fpsort` is the floating-point sort.
9014  If `ctx=None`, then the global context is used.
9015 
9016  >>> x = FP('x', FPSort(8, 24))
9017  >>> is_fp(x)
9018  True
9019  >>> x.ebits()
9020  8
9021  >>> x.sort()
9022  FPSort(8, 24)
9023  >>> word = FPSort(8, 24)
9024  >>> x2 = FP('x', word)
9025  >>> eq(x, x2)
9026  True
9027  """
9028  if isinstance(fpsort, FPSortRef) and ctx is None:
9029  ctx = fpsort.ctx
9030  else:
9031  ctx = _get_ctx(ctx)
9032  return FPRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), fpsort.ast), ctx)
9033 
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:101
def FP(name, fpsort, ctx=None)
Definition: z3py.py:9011

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

9052 def fpAbs(a, ctx=None):
9053  """Create a Z3 floating-point absolute value expression.
9054 
9055  >>> s = FPSort(8, 24)
9056  >>> rm = RNE()
9057  >>> x = FPVal(1.0, s)
9058  >>> fpAbs(x)
9059  fpAbs(1)
9060  >>> y = FPVal(-20.0, s)
9061  >>> y
9062  -1.25*(2**4)
9063  >>> fpAbs(y)
9064  fpAbs(-1.25*(2**4))
9065  >>> fpAbs(-1.25*(2**4))
9066  fpAbs(-1.25*(2**4))
9067  >>> fpAbs(x).sort()
9068  FPSort(8, 24)
9069  """
9070  ctx = _get_ctx(ctx)
9071  [a] = _coerce_fp_expr_list([a], ctx)
9072  return FPRef(Z3_mk_fpa_abs(ctx.ref(), a.as_ast()), ctx)
9073 
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:9052

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

Referenced by FPs().

9141 def fpAdd(rm, a, b, ctx=None):
9142  """Create a Z3 floating-point addition expression.
9143 
9144  >>> s = FPSort(8, 24)
9145  >>> rm = RNE()
9146  >>> x = FP('x', s)
9147  >>> y = FP('y', s)
9148  >>> fpAdd(rm, x, y)
9149  fpAdd(RNE(), x, y)
9150  >>> fpAdd(RTZ(), x, y) # default rounding mode is RTZ
9151  x + y
9152  >>> fpAdd(rm, x, y).sort()
9153  FPSort(8, 24)
9154  """
9155  return _mk_fp_bin(Z3_mk_fpa_add, rm, a, b, ctx)
9156 
def fpAdd(rm, a, b, ctx=None)
Definition: z3py.py:9141

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

9438 def fpBVToFP(v, sort, ctx=None):
9439  """Create a Z3 floating-point conversion expression that represents the
9440  conversion from a bit-vector term to a floating-point term.
9441 
9442  >>> x_bv = BitVecVal(0x3F800000, 32)
9443  >>> x_fp = fpBVToFP(x_bv, Float32())
9444  >>> x_fp
9445  fpToFP(1065353216)
9446  >>> simplify(x_fp)
9447  1
9448  """
9449  _z3_assert(is_bv(v), "First argument must be a Z3 floating-point rounding mode expression.")
9450  _z3_assert(is_fp_sort(sort), "Second argument must be a Z3 floating-point sort.")
9451  ctx = _get_ctx(ctx)
9452  return FPRef(Z3_mk_fpa_to_fp_bv(ctx.ref(), v.ast, sort.ast), ctx)
9453 
def fpBVToFP(v, sort, ctx=None)
Definition: z3py.py:9438
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:8442
def is_bv(a)
Definition: z3py.py:3522

◆ fpDiv()

def z3py.fpDiv (   rm,
  a,
  b,
  ctx = None 
)
Create a Z3 floating-point divison 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 9185 of file z3py.py.

9185 def fpDiv(rm, a, b, ctx=None):
9186  """Create a Z3 floating-point divison expression.
9187 
9188  >>> s = FPSort(8, 24)
9189  >>> rm = RNE()
9190  >>> x = FP('x', s)
9191  >>> y = FP('y', s)
9192  >>> fpDiv(rm, x, y)
9193  fpDiv(RNE(), x, y)
9194  >>> fpDiv(rm, x, y).sort()
9195  FPSort(8, 24)
9196  """
9197  return _mk_fp_bin(Z3_mk_fpa_div, rm, a, b, ctx)
9198 
def fpDiv(rm, a, b, ctx=None)
Definition: z3py.py:9185

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

Referenced by fpFP(), and fpNEQ().

9350 def fpEQ(a, b, ctx=None):
9351  """Create the Z3 floating-point expression `fpEQ(other, self)`.
9352 
9353  >>> x, y = FPs('x y', FPSort(8, 24))
9354  >>> fpEQ(x, y)
9355  fpEQ(x, y)
9356  >>> fpEQ(x, y).sexpr()
9357  '(fp.eq x y)'
9358  """
9359  return _mk_fp_bin_pred(Z3_mk_fpa_eq, a, b, ctx)
9360 
def fpEQ(a, b, ctx=None)
Definition: z3py.py:9350

◆ fpFMA()

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

Definition at line 9240 of file z3py.py.

9240 def fpFMA(rm, a, b, c, ctx=None):
9241  """Create a Z3 floating-point fused multiply-add expression.
9242  """
9243  return _mk_fp_tern(Z3_mk_fpa_fma, rm, a, b, c, ctx)
9244 
def fpFMA(rm, a, b, c, ctx=None)
Definition: z3py.py:9240

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

9372 def fpFP(sgn, exp, sig, ctx=None):
9373  """Create the Z3 floating-point value `fpFP(sgn, sig, exp)` from the three bit-vectors sgn, sig, and exp.
9374 
9375  >>> s = FPSort(8, 24)
9376  >>> x = fpFP(BitVecVal(1, 1), BitVecVal(2**7-1, 8), BitVecVal(2**22, 23))
9377  >>> print(x)
9378  fpFP(1, 127, 4194304)
9379  >>> xv = FPVal(-1.5, s)
9380  >>> print(xv)
9381  -1.5
9382  >>> slvr = Solver()
9383  >>> slvr.add(fpEQ(x, xv))
9384  >>> slvr.check()
9385  sat
9386  >>> xv = FPVal(+1.5, s)
9387  >>> print(xv)
9388  1.5
9389  >>> slvr = Solver()
9390  >>> slvr.add(fpEQ(x, xv))
9391  >>> slvr.check()
9392  unsat
9393  """
9394  _z3_assert(is_bv(sgn) and is_bv(exp) and is_bv(sig), "sort mismatch")
9395  _z3_assert(sgn.sort().size() == 1, "sort mismatch")
9396  ctx = _get_ctx(ctx)
9397  _z3_assert(ctx == sgn.ctx == exp.ctx == sig.ctx, "context mismatch")
9398  return FPRef(Z3_mk_fpa_fp(ctx.ref(), sgn.ast, exp.ast, sig.ast), ctx)
9399 
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:9372
def is_bv(a)
Definition: z3py.py:3522

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

9454 def fpFPToFP(rm, v, sort, ctx=None):
9455  """Create a Z3 floating-point conversion expression that represents the
9456  conversion from a floating-point term to a floating-point term of different precision.
9457 
9458  >>> x_sgl = FPVal(1.0, Float32())
9459  >>> x_dbl = fpFPToFP(RNE(), x_sgl, Float64())
9460  >>> x_dbl
9461  fpToFP(RNE(), 1)
9462  >>> simplify(x_dbl)
9463  1
9464  >>> x_dbl.sort()
9465  FPSort(11, 53)
9466  """
9467  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression.")
9468  _z3_assert(is_fp(v), "Second argument must be a Z3 floating-point expression.")
9469  _z3_assert(is_fp_sort(sort), "Third argument must be a Z3 floating-point sort.")
9470  ctx = _get_ctx(ctx)
9471  return FPRef(Z3_mk_fpa_to_fp_float(ctx.ref(), rm.ast, v.ast, sort.ast), ctx)
9472 
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:8442
def fpFPToFP(rm, v, sort, ctx=None)
Definition: z3py.py:9454
def is_fprm(a)
Definition: z3py.py:8690
def is_fp(a)
Definition: z3py.py:8823

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

9339 def fpGEQ(a, b, ctx=None):
9340  """Create the Z3 floating-point expression `other >= self`.
9341 
9342  >>> x, y = FPs('x y', FPSort(8, 24))
9343  >>> fpGEQ(x, y)
9344  x >= y
9345  >>> (x >= y).sexpr()
9346  '(fp.geq x y)'
9347  """
9348  return _mk_fp_bin_pred(Z3_mk_fpa_geq, a, b, ctx)
9349 
def fpGEQ(a, b, ctx=None)
Definition: z3py.py:9339

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

9328 def fpGT(a, b, ctx=None):
9329  """Create the Z3 floating-point expression `other > self`.
9330 
9331  >>> x, y = FPs('x y', FPSort(8, 24))
9332  >>> fpGT(x, y)
9333  x > y
9334  >>> (x > y).sexpr()
9335  '(fp.gt x y)'
9336  """
9337  return _mk_fp_bin_pred(Z3_mk_fpa_gt, a, b, ctx)
9338 
def fpGT(a, b, ctx=None)
Definition: z3py.py:9328

◆ fpInfinity()

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

Definition at line 8945 of file z3py.py.

8945 def fpInfinity(s, negative):
8946  """Create a Z3 floating-point +oo or -oo term."""
8947  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
8948  _z3_assert(isinstance(negative, bool), "expected Boolean flag")
8949  return FPNumRef(Z3_mk_fpa_inf(s.ctx_ref(), s.ast, negative), s.ctx)
8950 
Z3_ast Z3_API Z3_mk_fpa_inf(Z3_context c, Z3_sort s, Z3_bool negative)
Create a floating-point infinity of sort s.
def fpInfinity(s, negative)
Definition: z3py.py:8945

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

9266 def fpIsInf(a, ctx=None):
9267  """Create a Z3 floating-point isInfinite expression.
9268 
9269  >>> s = FPSort(8, 24)
9270  >>> x = FP('x', s)
9271  >>> fpIsInf(x)
9272  fpIsInf(x)
9273  """
9274  return _mk_fp_unary_norm(Z3_mk_fpa_is_infinite, a, ctx)
9275 
def fpIsInf(a, ctx=None)
Definition: z3py.py:9266

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

9255 def fpIsNaN(a, ctx=None):
9256  """Create a Z3 floating-point isNaN expression.
9257 
9258  >>> s = FPSort(8, 24)
9259  >>> x = FP('x', s)
9260  >>> y = FP('y', s)
9261  >>> fpIsNaN(x)
9262  fpIsNaN(x)
9263  """
9264  return _mk_fp_unary_norm(Z3_mk_fpa_is_nan, a, ctx)
9265 
def fpIsNaN(a, ctx=None)
Definition: z3py.py:9255

◆ fpIsNegative()

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

Definition at line 9291 of file z3py.py.

9291 def fpIsNegative(a, ctx=None):
9292  """Create a Z3 floating-point isNegative expression.
9293  """
9294  return _mk_fp_unary_norm(Z3_mk_fpa_is_negative, a, ctx)
9295 
def fpIsNegative(a, ctx=None)
Definition: z3py.py:9291

◆ fpIsNormal()

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

Definition at line 9281 of file z3py.py.

9281 def fpIsNormal(a, ctx=None):
9282  """Create a Z3 floating-point isNormal expression.
9283  """
9284  return _mk_fp_unary_norm(Z3_mk_fpa_is_normal, a, ctx)
9285 
def fpIsNormal(a, ctx=None)
Definition: z3py.py:9281

◆ fpIsPositive()

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

Definition at line 9296 of file z3py.py.

9296 def fpIsPositive(a, ctx=None):
9297  """Create a Z3 floating-point isPositive expression.
9298  """
9299  return _mk_fp_unary_norm(Z3_mk_fpa_is_positive, a, ctx)
9300  return FPRef(Z3_mk_fpa_is_positive(a.ctx_ref(), a.as_ast()), a.ctx)
9301 
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:9296

◆ fpIsSubnormal()

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

Definition at line 9286 of file z3py.py.

9286 def fpIsSubnormal(a, ctx=None):
9287  """Create a Z3 floating-point isSubnormal expression.
9288  """
9289  return _mk_fp_unary_norm(Z3_mk_fpa_is_subnormal, a, ctx)
9290 
def fpIsSubnormal(a, ctx=None)
Definition: z3py.py:9286

◆ fpIsZero()

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

Definition at line 9276 of file z3py.py.

9276 def fpIsZero(a, ctx=None):
9277  """Create a Z3 floating-point isZero expression.
9278  """
9279  return _mk_fp_unary_norm(Z3_mk_fpa_is_zero, a, ctx)
9280 
def fpIsZero(a, ctx=None)
Definition: z3py.py:9276

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

9317 def fpLEQ(a, b, ctx=None):
9318  """Create the Z3 floating-point expression `other <= self`.
9319 
9320  >>> x, y = FPs('x y', FPSort(8, 24))
9321  >>> fpLEQ(x, y)
9322  x <= y
9323  >>> (x <= y).sexpr()
9324  '(fp.leq x y)'
9325  """
9326  return _mk_fp_bin_pred(Z3_mk_fpa_leq, a, b, ctx)
9327 
def fpLEQ(a, b, ctx=None)
Definition: z3py.py:9317

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

9306 def fpLT(a, b, ctx=None):
9307  """Create the Z3 floating-point expression `other < self`.
9308 
9309  >>> x, y = FPs('x y', FPSort(8, 24))
9310  >>> fpLT(x, y)
9311  x < y
9312  >>> (x < y).sexpr()
9313  '(fp.lt x y)'
9314  """
9315  return _mk_fp_bin_pred(Z3_mk_fpa_lt, a, b, ctx)
9316 
def fpLT(a, b, ctx=None)
Definition: z3py.py:9306

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

9226 def fpMax(a, b, ctx=None):
9227  """Create a Z3 floating-point maximum expression.
9228 
9229  >>> s = FPSort(8, 24)
9230  >>> rm = RNE()
9231  >>> x = FP('x', s)
9232  >>> y = FP('y', s)
9233  >>> fpMax(x, y)
9234  fpMax(x, y)
9235  >>> fpMax(x, y).sort()
9236  FPSort(8, 24)
9237  """
9238  return _mk_fp_bin_norm(Z3_mk_fpa_max, a, b, ctx)
9239 
def fpMax(a, b, ctx=None)
Definition: z3py.py:9226

◆ fpMin()

def z3py.fpMin (   a,
  b,
  ctx = None 
)
Create a Z3 floating-point minimium 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 9212 of file z3py.py.

9212 def fpMin(a, b, ctx=None):
9213  """Create a Z3 floating-point minimium expression.
9214 
9215  >>> s = FPSort(8, 24)
9216  >>> rm = RNE()
9217  >>> x = FP('x', s)
9218  >>> y = FP('y', s)
9219  >>> fpMin(x, y)
9220  fpMin(x, y)
9221  >>> fpMin(x, y).sort()
9222  FPSort(8, 24)
9223  """
9224  return _mk_fp_bin_norm(Z3_mk_fpa_min, a, b, ctx)
9225 
def fpMin(a, b, ctx=None)
Definition: z3py.py:9212

◆ fpMinusInfinity()

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

Definition at line 8940 of file z3py.py.

8940 def fpMinusInfinity(s):
8941  """Create a Z3 floating-point -oo term."""
8942  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
8943  return FPNumRef(Z3_mk_fpa_inf(s.ctx_ref(), s.ast, True), s.ctx)
8944 
def fpMinusInfinity(s)
Definition: z3py.py:8940
Z3_ast Z3_API Z3_mk_fpa_inf(Z3_context c, Z3_sort s, Z3_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 8956 of file z3py.py.

8956 def fpMinusZero(s):
8957  """Create a Z3 floating-point -0.0 term."""
8958  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
8959  return FPNumRef(Z3_mk_fpa_zero(s.ctx_ref(), s.ast, True), s.ctx)
8960 
def fpMinusZero(s)
Definition: z3py.py:8956
Z3_ast Z3_API Z3_mk_fpa_zero(Z3_context c, Z3_sort s, Z3_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 9171 of file z3py.py.

Referenced by FPs().

9171 def fpMul(rm, a, b, ctx=None):
9172  """Create a Z3 floating-point multiplication expression.
9173 
9174  >>> s = FPSort(8, 24)
9175  >>> rm = RNE()
9176  >>> x = FP('x', s)
9177  >>> y = FP('y', s)
9178  >>> fpMul(rm, x, y)
9179  fpMul(RNE(), x, y)
9180  >>> fpMul(rm, x, y).sort()
9181  FPSort(8, 24)
9182  """
9183  return _mk_fp_bin(Z3_mk_fpa_mul, rm, a, b, ctx)
9184 
def fpMul(rm, a, b, ctx=None)
Definition: z3py.py:9171

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

8908 def fpNaN(s):
8909  """Create a Z3 floating-point NaN term.
8910 
8911  >>> s = FPSort(8, 24)
8912  >>> set_fpa_pretty(True)
8913  >>> fpNaN(s)
8914  NaN
8915  >>> pb = get_fpa_pretty()
8916  >>> set_fpa_pretty(False)
8917  >>> fpNaN(s)
8918  fpNaN(FPSort(8, 24))
8919  >>> set_fpa_pretty(pb)
8920  """
8921  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
8922  return FPNumRef(Z3_mk_fpa_nan(s.ctx_ref(), s.ast), s.ctx)
8923 
def fpNaN(s)
Definition: z3py.py:8908
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 9074 of file z3py.py.

9074 def fpNeg(a, ctx=None):
9075  """Create a Z3 floating-point addition expression.
9076 
9077  >>> s = FPSort(8, 24)
9078  >>> rm = RNE()
9079  >>> x = FP('x', s)
9080  >>> fpNeg(x)
9081  -x
9082  >>> fpNeg(x).sort()
9083  FPSort(8, 24)
9084  """
9085  ctx = _get_ctx(ctx)
9086  [a] = _coerce_fp_expr_list([a], ctx)
9087  return FPRef(Z3_mk_fpa_neg(ctx.ref(), a.as_ast()), ctx)
9088 
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:9074

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

9361 def fpNEQ(a, b, ctx=None):
9362  """Create the Z3 floating-point expression `Not(fpEQ(other, self))`.
9363 
9364  >>> x, y = FPs('x y', FPSort(8, 24))
9365  >>> fpNEQ(x, y)
9366  Not(fpEQ(x, y))
9367  >>> (x != y).sexpr()
9368  '(distinct x y)'
9369  """
9370  return Not(fpEQ(a, b, ctx))
9371 
def fpEQ(a, b, ctx=None)
Definition: z3py.py:9350
def Not(a, ctx=None)
Definition: z3py.py:1553
def fpNEQ(a, b, ctx=None)
Definition: z3py.py:9361

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

8924 def fpPlusInfinity(s):
8925  """Create a Z3 floating-point +oo term.
8926 
8927  >>> s = FPSort(8, 24)
8928  >>> pb = get_fpa_pretty()
8929  >>> set_fpa_pretty(True)
8930  >>> fpPlusInfinity(s)
8931  +oo
8932  >>> set_fpa_pretty(False)
8933  >>> fpPlusInfinity(s)
8934  fpPlusInfinity(FPSort(8, 24))
8935  >>> set_fpa_pretty(pb)
8936  """
8937  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
8938  return FPNumRef(Z3_mk_fpa_inf(s.ctx_ref(), s.ast, False), s.ctx)
8939 
def fpPlusInfinity(s)
Definition: z3py.py:8924
Z3_ast Z3_API Z3_mk_fpa_inf(Z3_context c, Z3_sort s, Z3_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 8951 of file z3py.py.

8951 def fpPlusZero(s):
8952  """Create a Z3 floating-point +0.0 term."""
8953  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
8954  return FPNumRef(Z3_mk_fpa_zero(s.ctx_ref(), s.ast, False), s.ctx)
8955 
def fpPlusZero(s)
Definition: z3py.py:8951
Z3_ast Z3_API Z3_mk_fpa_zero(Z3_context c, Z3_sort s, Z3_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 9473 of file z3py.py.

9473 def fpRealToFP(rm, v, sort, ctx=None):
9474  """Create a Z3 floating-point conversion expression that represents the
9475  conversion from a real term to a floating-point term.
9476 
9477  >>> x_r = RealVal(1.5)
9478  >>> x_fp = fpRealToFP(RNE(), x_r, Float32())
9479  >>> x_fp
9480  fpToFP(RNE(), 3/2)
9481  >>> simplify(x_fp)
9482  1.5
9483  """
9484  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression.")
9485  _z3_assert(is_real(v), "Second argument must be a Z3 expression or real sort.")
9486  _z3_assert(is_fp_sort(sort), "Third argument must be a Z3 floating-point sort.")
9487  ctx = _get_ctx(ctx)
9488  return FPRef(Z3_mk_fpa_to_fp_real(ctx.ref(), rm.ast, v.ast, sort.ast), ctx)
9489 
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:2356
def is_fp_sort(s)
Definition: z3py.py:8442
def fpRealToFP(rm, v, sort, ctx=None)
Definition: z3py.py:9473
def is_fprm(a)
Definition: z3py.py:8690

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

9199 def fpRem(a, b, ctx=None):
9200  """Create a Z3 floating-point remainder expression.
9201 
9202  >>> s = FPSort(8, 24)
9203  >>> x = FP('x', s)
9204  >>> y = FP('y', s)
9205  >>> fpRem(x, y)
9206  fpRem(x, y)
9207  >>> fpRem(x, y).sort()
9208  FPSort(8, 24)
9209  """
9210  return _mk_fp_bin_norm(Z3_mk_fpa_rem, a, b, ctx)
9211 
def fpRem(a, b, ctx=None)
Definition: z3py.py:9199

◆ fpRoundToIntegral()

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

Definition at line 9250 of file z3py.py.

9250 def fpRoundToIntegral(rm, a, ctx=None):
9251  """Create a Z3 floating-point roundToIntegral expression.
9252  """
9253  return _mk_fp_unary(Z3_mk_fpa_round_to_integral, rm, a, ctx)
9254 
def fpRoundToIntegral(rm, a, ctx=None)
Definition: z3py.py:9250

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

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

9034 def FPs(names, fpsort, ctx=None):
9035  """Return an array of floating-point constants.
9036 
9037  >>> x, y, z = FPs('x y z', FPSort(8, 24))
9038  >>> x.sort()
9039  FPSort(8, 24)
9040  >>> x.sbits()
9041  24
9042  >>> x.ebits()
9043  8
9044  >>> fpMul(RNE(), fpAdd(RNE(), x, y), z)
9045  fpMul(RNE(), fpAdd(RNE(), x, y), z)
9046  """
9047  ctx = _get_ctx(ctx)
9048  if isinstance(names, str):
9049  names = names.split(" ")
9050  return [FP(name, fpsort, ctx) for name in names]
9051 
def FPs(names, fpsort, ctx=None)
Definition: z3py.py:9034
def FP(name, fpsort, ctx=None)
Definition: z3py.py:9011

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

9490 def fpSignedToFP(rm, v, sort, ctx=None):
9491  """Create a Z3 floating-point conversion expression that represents the
9492  conversion from a signed bit-vector term (encoding an integer) to a floating-point term.
9493 
9494  >>> x_signed = BitVecVal(-5, BitVecSort(32))
9495  >>> x_fp = fpSignedToFP(RNE(), x_signed, Float32())
9496  >>> x_fp
9497  fpToFP(RNE(), 4294967291)
9498  >>> simplify(x_fp)
9499  -1.25*(2**2)
9500  """
9501  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression.")
9502  _z3_assert(is_bv(v), "Second argument must be a Z3 expression or real sort.")
9503  _z3_assert(is_fp_sort(sort), "Third argument must be a Z3 floating-point sort.")
9504  ctx = _get_ctx(ctx)
9505  return FPRef(Z3_mk_fpa_to_fp_signed(ctx.ref(), rm.ast, v.ast, sort.ast), ctx)
9506 
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:9490
def is_fp_sort(s)
Definition: z3py.py:8442
def is_bv(a)
Definition: z3py.py:3522
def is_fprm(a)
Definition: z3py.py:8690

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

8850 def FPSort(ebits, sbits, ctx=None):
8851  """Return a Z3 floating-point sort of the given sizes. If `ctx=None`, then the global context is used.
8852 
8853  >>> Single = FPSort(8, 24)
8854  >>> Double = FPSort(11, 53)
8855  >>> Single
8856  FPSort(8, 24)
8857  >>> x = Const('x', Single)
8858  >>> eq(x, FP('x', FPSort(8, 24)))
8859  True
8860  """
8861  ctx = _get_ctx(ctx)
8862  return FPSortRef(Z3_mk_fpa_sort(ctx.ref(), ebits, sbits), ctx)
8863 
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:8850

◆ fpSqrt()

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

Definition at line 9245 of file z3py.py.

9245 def fpSqrt(rm, a, ctx=None):
9246  """Create a Z3 floating-point square root expression.
9247  """
9248  return _mk_fp_unary(Z3_mk_fpa_sqrt, rm, a, ctx)
9249 
def fpSqrt(rm, a, ctx=None)
Definition: z3py.py:9245

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

9157 def fpSub(rm, a, b, ctx=None):
9158  """Create a Z3 floating-point subtraction expression.
9159 
9160  >>> s = FPSort(8, 24)
9161  >>> rm = RNE()
9162  >>> x = FP('x', s)
9163  >>> y = FP('y', s)
9164  >>> fpSub(rm, x, y)
9165  fpSub(RNE(), x, y)
9166  >>> fpSub(rm, x, y).sort()
9167  FPSort(8, 24)
9168  """
9169  return _mk_fp_bin(Z3_mk_fpa_sub, rm, a, b, ctx)
9170 
def fpSub(rm, a, b, ctx=None)
Definition: z3py.py:9157

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

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

9400 def fpToFP(a1, a2=None, a3=None, ctx=None):
9401  """Create a Z3 floating-point conversion expression from other term sorts
9402  to floating-point.
9403 
9404  From a bit-vector term in IEEE 754-2008 format:
9405  >>> x = FPVal(1.0, Float32())
9406  >>> x_bv = fpToIEEEBV(x)
9407  >>> simplify(fpToFP(x_bv, Float32()))
9408  1
9409 
9410  From a floating-point term with different precision:
9411  >>> x = FPVal(1.0, Float32())
9412  >>> x_db = fpToFP(RNE(), x, Float64())
9413  >>> x_db.sort()
9414  FPSort(11, 53)
9415 
9416  From a real term:
9417  >>> x_r = RealVal(1.5)
9418  >>> simplify(fpToFP(RNE(), x_r, Float32()))
9419  1.5
9420 
9421  From a signed bit-vector term:
9422  >>> x_signed = BitVecVal(-5, BitVecSort(32))
9423  >>> simplify(fpToFP(RNE(), x_signed, Float32()))
9424  -1.25*(2**2)
9425  """
9426  ctx = _get_ctx(ctx)
9427  if is_bv(a1) and is_fp_sort(a2):
9428  return FPRef(Z3_mk_fpa_to_fp_bv(ctx.ref(), a1.ast, a2.ast), ctx)
9429  elif is_fprm(a1) and is_fp(a2) and is_fp_sort(a3):
9430  return FPRef(Z3_mk_fpa_to_fp_float(ctx.ref(), a1.ast, a2.ast, a3.ast), ctx)
9431  elif is_fprm(a1) and is_real(a2) and is_fp_sort(a3):
9432  return FPRef(Z3_mk_fpa_to_fp_real(ctx.ref(), a1.ast, a2.ast, a3.ast), ctx)
9433  elif is_fprm(a1) and is_bv(a2) and is_fp_sort(a3):
9434  return FPRef(Z3_mk_fpa_to_fp_signed(ctx.ref(), a1.ast, a2.ast, a3.ast), ctx)
9435  else:
9436  raise Z3Exception("Unsupported combination of arguments for conversion to floating-point term.")
9437 
def fpToFP(a1, a2=None, a3=None, ctx=None)
Definition: z3py.py:9400
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:2356
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:8442
def is_bv(a)
Definition: z3py.py:3522
def is_fprm(a)
Definition: z3py.py:8690
def is_fp(a)
Definition: z3py.py:8823

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

Referenced by fpUnsignedToFP().

9524 def fpToFPUnsigned(rm, x, s, ctx=None):
9525  """Create a Z3 floating-point conversion expression, from unsigned bit-vector to floating-point expression."""
9526  if __debug__:
9527  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
9528  _z3_assert(is_bv(x), "Second argument must be a Z3 bit-vector expression")
9529  _z3_assert(is_fp_sort(s), "Third argument must be Z3 floating-point sort")
9530  ctx = _get_ctx(ctx)
9531  return FPRef(Z3_mk_fpa_to_fp_unsigned(ctx.ref(), rm.ast, x.ast, s.ast), ctx)
9532 
def fpToFPUnsigned(rm, x, s, ctx=None)
Definition: z3py.py:9524
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:8442
def is_bv(a)
Definition: z3py.py:3522
def is_fprm(a)
Definition: z3py.py:8690

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

Referenced by fpToFP().

9594 def fpToIEEEBV(x, ctx=None):
9595  """\brief Conversion of a floating-point term into a bit-vector term in IEEE 754-2008 format.
9596 
9597  The size of the resulting bit-vector is automatically determined.
9598 
9599  Note that IEEE 754-2008 allows multiple different representations of NaN. This conversion
9600  knows only one NaN and it will always produce the same bit-vector represenatation of
9601  that NaN.
9602 
9603  >>> x = FP('x', FPSort(8, 24))
9604  >>> y = fpToIEEEBV(x)
9605  >>> print(is_fp(x))
9606  True
9607  >>> print(is_bv(y))
9608  True
9609  >>> print(is_fp(y))
9610  False
9611  >>> print(is_bv(x))
9612  False
9613  """
9614  if __debug__:
9615  _z3_assert(is_fp(x), "First argument must be a Z3 floating-point expression")
9616  ctx = _get_ctx(ctx)
9617  return BitVecRef(Z3_mk_fpa_to_ieee_bv(ctx.ref(), x.ast), ctx)
9618 
9619 
9620 
def fpToIEEEBV(x, ctx=None)
Definition: z3py.py:9594
Z3_ast Z3_API Z3_mk_fpa_to_ieee_bv(Z3_context c, Z3_ast t)
Conversion of a floating-point term into a bit-vector term in IEEE 754-2008 format.
def is_fp(a)
Definition: z3py.py:8823

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

9575 def fpToReal(x, ctx=None):
9576  """Create a Z3 floating-point conversion expression, from floating-point expression to real.
9577 
9578  >>> x = FP('x', FPSort(8, 24))
9579  >>> y = fpToReal(x)
9580  >>> print(is_fp(x))
9581  True
9582  >>> print(is_real(y))
9583  True
9584  >>> print(is_fp(y))
9585  False
9586  >>> print(is_real(x))
9587  False
9588  """
9589  if __debug__:
9590  _z3_assert(is_fp(x), "First argument must be a Z3 floating-point expression")
9591  ctx = _get_ctx(ctx)
9592  return ArithRef(Z3_mk_fpa_to_real(ctx.ref(), x.ast), ctx)
9593 
Z3_ast Z3_API Z3_mk_fpa_to_real(Z3_context c, Z3_ast t)
Conversion of a floating-point term into a real-numbered term.
def fpToReal(x, ctx=None)
Definition: z3py.py:9575
def is_fp(a)
Definition: z3py.py:8823

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

9533 def fpToSBV(rm, x, s, ctx=None):
9534  """Create a Z3 floating-point conversion expression, from floating-point expression to signed bit-vector.
9535 
9536  >>> x = FP('x', FPSort(8, 24))
9537  >>> y = fpToSBV(RTZ(), x, BitVecSort(32))
9538  >>> print(is_fp(x))
9539  True
9540  >>> print(is_bv(y))
9541  True
9542  >>> print(is_fp(y))
9543  False
9544  >>> print(is_bv(x))
9545  False
9546  """
9547  if __debug__:
9548  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
9549  _z3_assert(is_fp(x), "Second argument must be a Z3 floating-point expression")
9550  _z3_assert(is_bv_sort(s), "Third argument must be Z3 bit-vector sort")
9551  ctx = _get_ctx(ctx)
9552  return BitVecRef(Z3_mk_fpa_to_sbv(ctx.ref(), rm.ast, x.ast, s.size()), ctx)
9553 
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:9533
def is_bv_sort(s)
Definition: z3py.py:3061
def is_fprm(a)
Definition: z3py.py:8690
def is_fp(a)
Definition: z3py.py:8823

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

9554 def fpToUBV(rm, x, s, ctx=None):
9555  """Create a Z3 floating-point conversion expression, from floating-point expression to unsigned bit-vector.
9556 
9557  >>> x = FP('x', FPSort(8, 24))
9558  >>> y = fpToUBV(RTZ(), x, BitVecSort(32))
9559  >>> print(is_fp(x))
9560  True
9561  >>> print(is_bv(y))
9562  True
9563  >>> print(is_fp(y))
9564  False
9565  >>> print(is_bv(x))
9566  False
9567  """
9568  if __debug__:
9569  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
9570  _z3_assert(is_fp(x), "Second argument must be a Z3 floating-point expression")
9571  _z3_assert(is_bv_sort(s), "Third argument must be Z3 bit-vector sort")
9572  ctx = _get_ctx(ctx)
9573  return BitVecRef(Z3_mk_fpa_to_ubv(ctx.ref(), rm.ast, x.ast, s.size()), ctx)
9574 
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:9554
def is_bv_sort(s)
Definition: z3py.py:3061
def is_fprm(a)
Definition: z3py.py:8690
def is_fp(a)
Definition: z3py.py:8823

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

9507 def fpUnsignedToFP(rm, v, sort, ctx=None):
9508  """Create a Z3 floating-point conversion expression that represents the
9509  conversion from an unsigned bit-vector term (encoding an integer) to a floating-point term.
9510 
9511  >>> x_signed = BitVecVal(-5, BitVecSort(32))
9512  >>> x_fp = fpUnsignedToFP(RNE(), x_signed, Float32())
9513  >>> x_fp
9514  fpToFPUnsigned(RNE(), 4294967291)
9515  >>> simplify(x_fp)
9516  1*(2**32)
9517  """
9518  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression.")
9519  _z3_assert(is_bv(v), "Second argument must be a Z3 expression or real sort.")
9520  _z3_assert(is_fp_sort(sort), "Third argument must be a Z3 floating-point sort.")
9521  ctx = _get_ctx(ctx)
9522  return FPRef(Z3_mk_fpa_to_fp_unsigned(ctx.ref(), rm.ast, v.ast, sort.ast), ctx)
9523 
def fpUnsignedToFP(rm, v, sort, ctx=None)
Definition: z3py.py:9507
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:8442
def is_bv(a)
Definition: z3py.py:3522
def is_fprm(a)
Definition: z3py.py:8690

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

8967 def FPVal(sig, exp=None, fps=None, ctx=None):
8968  """Return a floating-point value of value `val` and sort `fps`. If `ctx=None`, then the global context is used.
8969 
8970  >>> v = FPVal(20.0, FPSort(8, 24))
8971  >>> v
8972  1.25*(2**4)
8973  >>> print("0x%.8x" % v.exponent_as_long(False))
8974  0x00000004
8975  >>> v = FPVal(2.25, FPSort(8, 24))
8976  >>> v
8977  1.125*(2**1)
8978  >>> v = FPVal(-2.25, FPSort(8, 24))
8979  >>> v
8980  -1.125*(2**1)
8981  >>> FPVal(-0.0, FPSort(8, 24))
8982  -0.0
8983  >>> FPVal(0.0, FPSort(8, 24))
8984  +0.0
8985  >>> FPVal(+0.0, FPSort(8, 24))
8986  +0.0
8987  """
8988  ctx = _get_ctx(ctx)
8989  if is_fp_sort(exp):
8990  fps = exp
8991  exp = None
8992  elif fps is None:
8993  fps = _dflt_fps(ctx)
8994  _z3_assert(is_fp_sort(fps), "sort mismatch")
8995  if exp is None:
8996  exp = 0
8997  val = _to_float_str(sig)
8998  if val == "NaN" or val == "nan":
8999  return fpNaN(fps)
9000  elif val == "-0.0":
9001  return fpMinusZero(fps)
9002  elif val == "0.0" or val == "+0.0":
9003  return fpPlusZero(fps)
9004  elif val == "+oo" or val == "+inf" or val == "+Inf":
9005  return fpPlusInfinity(fps)
9006  elif val == "-oo" or val == "-inf" or val == "-Inf":
9007  return fpMinusInfinity(fps)
9008  else:
9009  return FPNumRef(Z3_mk_numeral(ctx.ref(), val, fps.ast), ctx)
9010 
def FPVal(sig, exp=None, fps=None, ctx=None)
Definition: z3py.py:8967
def fpMinusInfinity(s)
Definition: z3py.py:8940
def fpMinusZero(s)
Definition: z3py.py:8956
def fpPlusZero(s)
Definition: z3py.py:8951
def fpPlusInfinity(s)
Definition: z3py.py:8924
def fpNaN(s)
Definition: z3py.py:8908
def is_fp_sort(s)
Definition: z3py.py:8442
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 8961 of file z3py.py.

8961 def fpZero(s, negative):
8962  """Create a Z3 floating-point +0.0 or -0.0 term."""
8963  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
8964  _z3_assert(isinstance(negative, bool), "expected Boolean flag")
8965  return FPNumRef(Z3_mk_fpa_zero(s.ctx_ref(), s.ast, negative), s.ctx)
8966 
def fpZero(s, negative)
Definition: z3py.py:8961
Z3_ast Z3_API Z3_mk_fpa_zero(Z3_context c, Z3_sort s, Z3_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 1510 of file z3py.py.

1510 def FreshBool(prefix='b', ctx=None):
1511  """Return a fresh Boolean constant in the given context using the given prefix.
1512 
1513  If `ctx=None`, then the global context is used.
1514 
1515  >>> b1 = FreshBool()
1516  >>> b2 = FreshBool()
1517  >>> eq(b1, b2)
1518  False
1519  """
1520  ctx = _get_ctx(ctx)
1521  return BoolRef(Z3_mk_fresh_const(ctx.ref(), prefix, BoolSort(ctx).ast), ctx)
1522 
def FreshBool(prefix='b', ctx=None)
Definition: z3py.py:1510
def BoolSort(ctx=None)
Definition: z3py.py:1435
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 2884 of file z3py.py.

2884 def FreshInt(prefix='x', ctx=None):
2885  """Return a fresh integer constant in the given context using the given prefix.
2886 
2887  >>> x = FreshInt()
2888  >>> y = FreshInt()
2889  >>> eq(x, y)
2890  False
2891  >>> x.sort()
2892  Int
2893  """
2894  ctx = _get_ctx(ctx)
2895  return ArithRef(Z3_mk_fresh_const(ctx.ref(), prefix, IntSort(ctx).ast), ctx)
2896 
def IntSort(ctx=None)
Definition: z3py.py:2746
def FreshInt(prefix='x', ctx=None)
Definition: z3py.py:2884
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 2936 of file z3py.py.

2936 def FreshReal(prefix='b', ctx=None):
2937  """Return a fresh real constant in the given context using the given prefix.
2938 
2939  >>> x = FreshReal()
2940  >>> y = FreshReal()
2941  >>> eq(x, y)
2942  False
2943  >>> x.sort()
2944  Real
2945  """
2946  ctx = _get_ctx(ctx)
2947  return ArithRef(Z3_mk_fresh_const(ctx.ref(), prefix, RealSort(ctx).ast), ctx)
2948 
def FreshReal(prefix='b', ctx=None)
Definition: z3py.py:2936
def RealSort(ctx=None)
Definition: z3py.py:2762
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 langauge
>>> e = Full(ReSort(SeqSort(IntSort())))
>>> print(e)
re.all
>>> e1 = Full(ReSort(StringSort()))
>>> print(e1)
re.allchar

Definition at line 9774 of file z3py.py.

9774 def Full(s):
9775  """Create the regular expression that accepts the universal langauge
9776  >>> e = Full(ReSort(SeqSort(IntSort())))
9777  >>> print(e)
9778  re.all
9779  >>> e1 = Full(ReSort(StringSort()))
9780  >>> print(e1)
9781  re.allchar
9782  """
9783  if isinstance(s, ReSortRef):
9784  return ReRef(Z3_mk_re_full(s.ctx_ref(), s.ast), s.ctx)
9785  raise Z3Exception("Non-sequence, non-regular expression sort passed to Full")
9786 
9787 
def Full(s)
Definition: z3py.py:9774
Z3_ast Z3_API Z3_mk_re_full(Z3_context c, Z3_sort re)
Create an universal regular expression of sort re.

◆ 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 760 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_forall(), is_map(), is_pattern(), is_quantifier(), 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().

760 def Function(name, *sig):
761  """Create a new Z3 uninterpreted function with the given sorts.
762 
763  >>> f = Function('f', IntSort(), IntSort())
764  >>> f(f(0))
765  f(f(0))
766  """
767  sig = _get_args(sig)
768  if __debug__:
769  _z3_assert(len(sig) > 0, "At least two arguments expected")
770  arity = len(sig) - 1
771  rng = sig[arity]
772  if __debug__:
773  _z3_assert(is_sort(rng), "Z3 sort expected")
774  dom = (Sort * arity)()
775  for i in range(arity):
776  if __debug__:
777  _z3_assert(is_sort(sig[i]), "Z3 sort expected")
778  dom[i] = sig[i].ast
779  ctx = rng.ctx
780  return FuncDeclRef(Z3_mk_func_decl(ctx.ref(), to_symbol(name, ctx), arity, dom, rng.ast), ctx)
781 
def Function(name, sig)
Definition: z3py.py:760
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:2813
def to_symbol(s, ctx=None)
Definition: z3py.py:101
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:561

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

5842 def get_as_array_func(n):
5843  """Return the function declaration f associated with a Z3 expression of the form (_ as-array f)."""
5844  if __debug__:
5845  _z3_assert(is_as_array(n), "as-array Z3 expression expected.")
5846  return FuncDeclRef(Z3_get_as_array_func_decl(n.ctx.ref(), n.as_ast()), n.ctx)
5847 
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:5842
def is_as_array(n)
Definition: z3py.py:5838

◆ get_default_fp_sort()

def z3py.get_default_fp_sort (   ctx = None)

Definition at line 8322 of file z3py.py.

8322 def get_default_fp_sort(ctx=None):
8323  return FPSort(_dflt_fpsort_ebits, _dflt_fpsort_sbits, ctx)
8324 
def FPSort(ebits, sbits, ctx=None)
Definition: z3py.py:8850
def get_default_fp_sort(ctx=None)
Definition: z3py.py:8322

◆ get_default_rounding_mode()

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

Definition at line 8295 of file z3py.py.

8295 def get_default_rounding_mode(ctx=None):
8296  """Retrieves the global default rounding mode."""
8297  global _dflt_rounding_mode
8298  if _dflt_rounding_mode == Z3_OP_FPA_RM_TOWARD_ZERO:
8299  return RTZ(ctx)
8300  elif _dflt_rounding_mode == Z3_OP_FPA_RM_TOWARD_NEGATIVE:
8301  return RTN(ctx)
8302  elif _dflt_rounding_mode == Z3_OP_FPA_RM_TOWARD_POSITIVE:
8303  return RTP(ctx)
8304  elif _dflt_rounding_mode == Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN:
8305  return RNE(ctx)
8306  elif _dflt_rounding_mode == Z3_OP_FPA_RM_NEAREST_TIES_TO_AWAY:
8307  return RNA(ctx)
8308 
def RTN(ctx=None)
Definition: z3py.py:8678
def RTZ(ctx=None)
Definition: z3py.py:8686
def RTP(ctx=None)
Definition: z3py.py:8670
def RNA(ctx=None)
Definition: z3py.py:8662
def get_default_rounding_mode(ctx=None)
Definition: z3py.py:8295
def RNE(ctx=None)
Definition: z3py.py:8654

◆ get_full_version()

def z3py.get_full_version ( )

Definition at line 84 of file z3py.py.

84 def get_full_version():
85  return Z3_get_full_version()
86 
87 # We use _z3_assert instead of the assert command because we want to
88 # 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:84

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

4182 def get_map_func(a):
4183  """Return the function declaration associated with a Z3 map array expression.
4184 
4185  >>> f = Function('f', IntSort(), IntSort())
4186  >>> b = Array('b', IntSort(), IntSort())
4187  >>> a = Map(f, b)
4188  >>> eq(f, get_map_func(a))
4189  True
4190  >>> get_map_func(a)
4191  f
4192  >>> get_map_func(a)(0)
4193  f(0)
4194  """
4195  if __debug__:
4196  _z3_assert(is_map(a), "Z3 array map expression expected.")
4197  return FuncDeclRef(Z3_to_func_decl(a.ctx_ref(), Z3_get_decl_ast_parameter(a.ctx_ref(), a.decl().ast, 0)), a.ctx)
4198 
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:4159
def get_map_func(a)
Definition: z3py.py:4182
Z3_ast Z3_API Z3_get_decl_ast_parameter(Z3_context c, Z3_func_decl d, unsigned idx)
Return the expresson value associated with an expression parameter.

◆ get_param()

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

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

Definition at line 251 of file z3py.py.

251 def get_param(name):
252  """Return the value of a Z3 global (or module) parameter
253 
254  >>> get_param('nlsat.reorder')
255  'true'
256  """
257  ptr = (ctypes.c_char_p * 1)()
258  if Z3_global_param_get(str(name), ptr):
259  r = z3core._to_pystr(ptr[0])
260  return r
261  raise Z3Exception("failed to retrieve value for '%s'" % name)
262 
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:251

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

1122 def get_var_index(a):
1123  """Return the de-Bruijn index of the Z3 bounded variable `a`.
1124 
1125  >>> x = Int('x')
1126  >>> y = Int('y')
1127  >>> is_var(x)
1128  False
1129  >>> is_const(x)
1130  True
1131  >>> f = Function('f', IntSort(), IntSort(), IntSort())
1132  >>> # Z3 replaces x and y with bound variables when ForAll is executed.
1133  >>> q = ForAll([x, y], f(x, y) == x + y)
1134  >>> q.body()
1135  f(Var(1), Var(0)) == Var(1) + Var(0)
1136  >>> b = q.body()
1137  >>> b.arg(0)
1138  f(Var(1), Var(0))
1139  >>> v1 = b.arg(0).arg(0)
1140  >>> v2 = b.arg(0).arg(1)
1141  >>> v1
1142  Var(1)
1143  >>> v2
1144  Var(0)
1145  >>> get_var_index(v1)
1146  1
1147  >>> get_var_index(v2)
1148  0
1149  """
1150  if __debug__:
1151  _z3_assert(is_var(a), "Z3 bound variable expected")
1152  return int(Z3_get_index_value(a.ctx.ref(), a.as_ast()))
1153 
unsigned Z3_API Z3_get_index_value(Z3_context c, Z3_ast a)
Return index of de-Brujin bound variable.
def get_var_index(a)
Definition: z3py.py:1122
def is_var(a)
Definition: z3py.py:1098

◆ get_version()

def z3py.get_version ( )

Definition at line 76 of file z3py.py.

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

68 def get_version_string():
69  major = ctypes.c_uint(0)
70  minor = ctypes.c_uint(0)
71  build = ctypes.c_uint(0)
72  rev = ctypes.c_uint(0)
73  Z3_get_version(major, minor, build, rev)
74  return "%s.%s.%s" % (major.value, minor.value, build.value)
75 
def get_version_string()
Definition: z3py.py:68
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 7736 of file z3py.py.

7736 def help_simplify():
7737  """Return a string describing all options available for Z3 `simplify` procedure."""
7738  print(Z3_simplify_get_help(main_ctx().ref()))
7739 
def main_ctx()
Definition: z3py.py:192
def help_simplify()
Definition: z3py.py:7736
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 1166 of file z3py.py.

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

1166 def If(a, b, c, ctx=None):
1167  """Create a Z3 if-then-else expression.
1168 
1169  >>> x = Int('x')
1170  >>> y = Int('y')
1171  >>> max = If(x > y, x, y)
1172  >>> max
1173  If(x > y, x, y)
1174  >>> simplify(max)
1175  If(x <= y, y, x)
1176  """
1177  if isinstance(a, Probe) or isinstance(b, Tactic) or isinstance(c, Tactic):
1178  return Cond(a, b, c, ctx)
1179  else:
1180  ctx = _get_ctx(_ctx_from_ast_arg_list([a, b, c], ctx))
1181  s = BoolSort(ctx)
1182  a = s.cast(a)
1183  b, c = _coerce_exprs(b, c, ctx)
1184  if __debug__:
1185  _z3_assert(a.ctx == b.ctx, "Context mismatch")
1186  return _to_expr_ref(Z3_mk_ite(ctx.ref(), a.as_ast(), b.as_ast(), c.as_ast()), ctx)
1187 
def If(a, b, c, ctx=None)
Definition: z3py.py:1166
def Cond(p, t1, t2, ctx=None)
Definition: z3py.py:7696
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:1435

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

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

1523 def Implies(a, b, ctx=None):
1524  """Create a Z3 implies expression.
1525 
1526  >>> p, q = Bools('p q')
1527  >>> Implies(p, q)
1528  Implies(p, q)
1529  >>> simplify(Implies(p, q))
1530  Or(Not(p), q)
1531  """
1532  ctx = _get_ctx(_ctx_from_ast_arg_list([a, b], ctx))
1533  s = BoolSort(ctx)
1534  a = s.cast(a)
1535  b = s.cast(b)
1536  return BoolRef(Z3_mk_implies(ctx.ref(), a.as_ast(), b.as_ast()), ctx)
1537 
def Implies(a, b, ctx=None)
Definition: z3py.py:1523
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:1435

◆ IndexOf() [1/2]

def z3py.IndexOf (   s,
  substr 
)

Definition at line 9853 of file z3py.py.

Referenced by IndexOf().

9853 def IndexOf(s, substr):
9854  return IndexOf(s, substr, IntVal(0))
9855 
def IntVal(val, ctx=None)
Definition: z3py.py:2793
def IndexOf(s, substr)
Definition: z3py.py:9853

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

9856 def IndexOf(s, substr, offset):
9857  """Retrieve the index of substring within a string starting at a specified offset.
9858  >>> simplify(IndexOf("abcabc", "bc", 0))
9859  1
9860  >>> simplify(IndexOf("abcabc", "bc", 2))
9861  4
9862  """
9863  ctx = None
9864  if is_expr(offset):
9865  ctx = offset.ctx
9866  ctx = _get_ctx2(s, substr, ctx)
9867  s = _coerce_seq(s, ctx)
9868  substr = _coerce_seq(substr, ctx)
9869  if _is_int(offset):
9870  offset = IntVal(offset, ctx)
9871  return SeqRef(Z3_mk_seq_index(s.ctx_ref(), s.as_ast(), substr.as_ast(), offset.as_ast()), s.ctx)
9872 
def IntVal(val, ctx=None)
Definition: z3py.py:2793
def IndexOf(s, substr)
Definition: z3py.py:9853
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:1033

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

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

9943 def InRe(s, re):
9944  """Create regular expression membership test
9945  >>> re = Union(Re("a"),Re("b"))
9946  >>> print (simplify(InRe("a", re)))
9947  True
9948  >>> print (simplify(InRe("b", re)))
9949  True
9950  >>> print (simplify(InRe("c", re)))
9951  False
9952  """
9953  s = _coerce_seq(s, re.ctx)
9954  return BoolRef(Z3_mk_seq_in_re(s.ctx_ref(), s.as_ast(), re.as_ast()), s.ctx)
9955 
def InRe(s, re)
Definition: z3py.py:9943
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 2849 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(), binary_interpolant(), 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(), Interpolant(), is_arith(), is_arith_sort(), is_bv(), QuantifierRef.is_forall(), is_fp(), ArithSortRef.is_int(), ArithRef.is_int(), is_int(), is_int_value(), 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(), sequence_interpolant(), Solver.sexpr(), Goal.simplify(), ArithRef.sort(), Solver.statistics(), Store(), ToReal(), Goal.translate(), AstVector.translate(), tree_interpolant(), Update(), QuantifierRef.var_name(), QuantifierRef.var_sort(), and QuantifierRef.weight().

2849 def Int(name, ctx=None):
2850  """Return an integer constant named `name`. If `ctx=None`, then the global context is used.
2851 
2852  >>> x = Int('x')
2853  >>> is_int(x)
2854  True
2855  >>> is_int(x + 1)
2856  True
2857  """
2858  ctx = _get_ctx(ctx)
2859  return ArithRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), IntSort(ctx).ast), ctx)
2860 
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:101
def Int(name, ctx=None)
Definition: z3py.py:2849
def IntSort(ctx=None)
Definition: z3py.py:2746

◆ Interpolant()

def z3py.Interpolant (   a,
  ctx = None 
)
Create an interpolation operator.

The argument is an interpolation pattern (see tree_interpolant).

>>> x = Int('x')
>>> print(Interpolant(x>0))
interp(x > 0)

Definition at line 8142 of file z3py.py.

Referenced by tree_interpolant().

8142 def Interpolant(a,ctx=None):
8143  """Create an interpolation operator.
8144 
8145  The argument is an interpolation pattern (see tree_interpolant).
8146 
8147  >>> x = Int('x')
8148  >>> print(Interpolant(x>0))
8149  interp(x > 0)
8150  """
8151  ctx = _get_ctx(_ctx_from_ast_arg_list([a], ctx))
8152  s = BoolSort(ctx)
8153  a = s.cast(a)
8154  return BoolRef(Z3_mk_interpolant(ctx.ref(), a.as_ast()), ctx)
8155 
Z3_ast Z3_API Z3_mk_interpolant(Z3_context c, Z3_ast a)
Create an AST node marking a formula position for interpolation.
def Interpolant(a, ctx=None)
Definition: z3py.py:8142
def BoolSort(ctx=None)
Definition: z3py.py:1435

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

Referenced by ArithRef.__ge__(), Goal.__getitem__(), ArithRef.__gt__(), ArithRef.__le__(), Goal.__len__(), ArithRef.__lt__(), 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(), Goal.prec(), Goal.size(), Store(), Solver.unsat_core(), and Update().

2861 def Ints(names, ctx=None):
2862  """Return a tuple of Integer constants.
2863 
2864  >>> x, y, z = Ints('x y z')
2865  >>> Sum(x, y, z)
2866  x + y + z
2867  """
2868  ctx = _get_ctx(ctx)
2869  if isinstance(names, str):
2870  names = names.split(" ")
2871  return [Int(name, ctx) for name in names]
2872 
def Int(name, ctx=None)
Definition: z3py.py:2849
def Ints(names, ctx=None)
Definition: z3py.py:2861

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

Referenced by ArrayRef.__getitem__(), ModelRef.__getitem__(), ModelRef.__len__(), DatatypeSortRef.accessor(), FuncEntry.arg_value(), FuncInterp.arity(), Array(), ArraySort(), FuncEntry.as_list(), FuncInterp.as_list(), QuantifierRef.body(), ArithSortRef.cast(), QuantifierRef.children(), DatatypeSortRef.constructor(), Datatype.create(), CreateDatatypes(), Datatype.declare(), ModelRef.decls(), Default(), ArraySortRef.domain(), ArrayRef.domain(), FuncInterp.else_value(), Empty(), FuncInterp.entry(), Exists(), ForAll(), Full(), ModelRef.get_interp(), get_map_func(), Context.getIntSort(), is_arith_sort(), is_array(), is_bv_sort(), is_const_array(), is_default(), QuantifierRef.is_forall(), is_fp_sort(), is_K(), is_map(), is_pattern(), is_quantifier(), is_select(), is_store(), SeqSortRef.is_string(), K(), 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(), ArrayRef.sort(), Store(), Update(), FuncEntry.value(), QuantifierRef.var_name(), QuantifierRef.var_sort(), and QuantifierRef.weight().

2746 def IntSort(ctx=None):
2747  """Return the integer sort in the given context. If `ctx=None`, then the global context is used.
2748 
2749  >>> IntSort()
2750  Int
2751  >>> x = Const('x', IntSort())
2752  >>> is_int(x)
2753  True
2754  >>> x.sort() == IntSort()
2755  True
2756  >>> x.sort() == BoolSort()
2757  False
2758  """
2759  ctx = _get_ctx(ctx)
2760  return ArithSortRef(Z3_mk_int_sort(ctx.ref()), ctx)
2761 
Z3_sort Z3_API Z3_mk_int_sort(Z3_context c)
Create the integer type.
def IntSort(ctx=None)
Definition: z3py.py:2746

◆ IntToStr()

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

Definition at line 9898 of file z3py.py.

Referenced by StrToInt().

9898 def IntToStr(s):
9899  """Convert integer expression to string"""
9900  if not is_expr(s):
9901  s = _py2expr(s)
9902  return SeqRef(Z3_mk_int_to_str(s.ctx_ref(), s.as_ast()), s.ctx)
9903 
9904 
def IntToStr(s)
Definition: z3py.py:9898
def is_expr(a)
Definition: z3py.py:1033
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 2793 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().

2793 def IntVal(val, ctx=None):
2794  """Return a Z3 integer value. If `ctx=None`, then the global context is used.
2795 
2796  >>> IntVal(1)
2797  1
2798  >>> IntVal("100")
2799  100
2800  """
2801  ctx = _get_ctx(ctx)
2802  return IntNumRef(Z3_mk_numeral(ctx.ref(), _to_int_str(val), IntSort(ctx).ast), ctx)
2803 
def IntVal(val, ctx=None)
Definition: z3py.py:2793
def IntSort(ctx=None)
Definition: z3py.py:2746
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 2873 of file z3py.py.

2873 def IntVector(prefix, sz, ctx=None):
2874  """Return a list of integer constants of size `sz`.
2875 
2876  >>> X = IntVector('x', 3)
2877  >>> X
2878  [x__0, x__1, x__2]
2879  >>> Sum(X)
2880  x__0 + x__1 + x__2
2881  """
2882  return [ Int('%s__%s' % (prefix, i)) for i in range(sz) ]
2883 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:2813
def Int(name, ctx=None)
Definition: z3py.py:2849
def IntVector(prefix, sz, ctx=None)
Definition: z3py.py:2873

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

2437 def is_add(a):
2438  """Return `True` if `a` is an expression of the form b + c.
2439 
2440  >>> x, y = Ints('x y')
2441  >>> is_add(x + y)
2442  True
2443  >>> is_add(x - y)
2444  False
2445  """
2446  return is_app_of(a, Z3_OP_ADD)
2447 
def is_app_of(a, k)
Definition: z3py.py:1154
def is_add(a)
Definition: z3py.py:2437

◆ is_algebraic_value()

def z3py.is_algebraic_value (   a)
Return `True` if `a` is an algerbraic 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 2424 of file z3py.py.

2424 def is_algebraic_value(a):
2425  """Return `True` if `a` is an algerbraic value of sort Real.
2426 
2427  >>> is_algebraic_value(RealVal("3/5"))
2428  False
2429  >>> n = simplify(Sqrt(2))
2430  >>> n
2431  1.4142135623?
2432  >>> is_algebraic_value(n)
2433  True
2434  """
2435  return is_arith(a) and a.is_real() and _is_algebraic(a.ctx, a.as_ast())
2436 
def is_arith(a)
Definition: z3py.py:2318
def is_algebraic_value(a)
Definition: z3py.py:2424

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

1382 def is_and(a):
1383  """Return `True` if `a` is a Z3 and expression.
1384 
1385  >>> p, q = Bools('p q')
1386  >>> is_and(And(p, q))
1387  True
1388  >>> is_and(Or(p, q))
1389  False
1390  """
1391  return is_app_of(a, Z3_OP_AND)
1392 
def is_and(a)
Definition: z3py.py:1382
def is_app_of(a, k)
Definition: z3py.py:1154

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

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

1055 def is_app(a):
1056  """Return `True` if `a` is a Z3 function application.
1057 
1058  Note that, constants are function applications with 0 arguments.
1059 
1060  >>> a = Int('a')
1061  >>> is_app(a)
1062  True
1063  >>> is_app(a + 1)
1064  True
1065  >>> is_app(IntSort())
1066  False
1067  >>> is_app(1)
1068  False
1069  >>> is_app(IntVal(1))
1070  True
1071  >>> x = Int('x')
1072  >>> is_app(ForAll(x, x >= 0))
1073  False
1074  """
1075  if not isinstance(a, ExprRef):
1076  return False
1077  k = _ast_kind(a.ctx, a)
1078  return k == Z3_NUMERAL_AST or k == Z3_APP_AST
1079 
def is_app(a)
Definition: z3py.py:1055

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

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

1154 def is_app_of(a, k):
1155  """Return `True` if `a` is an application of the given kind `k`.
1156 
1157  >>> x = Int('x')
1158  >>> n = x + 1
1159  >>> is_app_of(n, Z3_OP_ADD)
1160  True
1161  >>> is_app_of(n, Z3_OP_MUL)
1162  False
1163  """
1164  return is_app(a) and a.decl().kind() == k
1165 
def is_app(a)
Definition: z3py.py:1055
def is_app_of(a, k)
Definition: z3py.py:1154

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

2318 def is_arith(a):
2319  """Return `True` if `a` is an arithmetical expression.
2320 
2321  >>> x = Int('x')
2322  >>> is_arith(x)
2323  True
2324  >>> is_arith(x + 1)
2325  True
2326  >>> is_arith(1)
2327  False
2328  >>> is_arith(IntVal(1))
2329  True
2330  >>> y = Real('y')
2331  >>> is_arith(y)
2332  True
2333  >>> is_arith(y + 1)
2334  True
2335  """
2336  return isinstance(a, ArithRef)
2337 
def is_arith(a)
Definition: z3py.py:2318

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

2021 def is_arith_sort(s):
2022  """Return `True` if s is an arithmetical sort (type).
2023 
2024  >>> is_arith_sort(IntSort())
2025  True
2026  >>> is_arith_sort(RealSort())
2027  True
2028  >>> is_arith_sort(BoolSort())
2029  False
2030  >>> n = Int('x') + 1
2031  >>> is_arith_sort(n.sort())
2032  True
2033  """
2034  return isinstance(s, ArithSortRef)
2035 
def is_arith_sort(s)
Definition: z3py.py:2021

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

4122 def is_array(a):
4123  """Return `True` if `a` is a Z3 array expression.
4124 
4125  >>> a = Array('a', IntSort(), IntSort())
4126  >>> is_array(a)
4127  True
4128  >>> is_array(Store(a, 0, 1))
4129  True
4130  >>> is_array(a[0])
4131  False
4132  """
4133  return isinstance(a, ArrayRef)
4134 
def is_array(a)
Definition: z3py.py:4122

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

5838 def is_as_array(n):
5839  """Return true if n is a Z3 expression of the form (_ as-array f)."""
5840  return isinstance(n, ExprRef) and Z3_is_as_array(n.ctx.ref(), n.as_ast())
5841 
def is_as_array(n)
Definition: z3py.py:5838
Z3_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 378 of file z3py.py.

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

378 def is_ast(a):
379  """Return `True` if `a` is an AST node.
380 
381  >>> is_ast(10)
382  False
383  >>> is_ast(IntVal(10))
384  True
385  >>> is_ast(Int('x'))
386  True
387  >>> is_ast(BoolSort())
388  True
389  >>> is_ast(Function('f', IntSort(), IntSort()))
390  True
391  >>> is_ast("x")
392  False
393  >>> is_ast(Solver())
394  False
395  """
396  return isinstance(a, AstRef)
397 
def is_ast(a)
Definition: z3py.py:378

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

Referenced by BoolSort(), and prove().

1335 def is_bool(a):
1336  """Return `True` if `a` is a Z3 Boolean expression.
1337 
1338  >>> p = Bool('p')
1339  >>> is_bool(p)
1340  True
1341  >>> q = Bool('q')
1342  >>> is_bool(And(p, q))
1343  True
1344  >>> x = Real('x')
1345  >>> is_bool(x)
1346  False
1347  >>> is_bool(x == 0)
1348  True
1349  """
1350  return isinstance(a, BoolRef)
1351 
def is_bool(a)
Definition: z3py.py:1335

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

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

3522 def is_bv(a):
3523  """Return `True` if `a` is a Z3 bit-vector expression.
3524 
3525  >>> b = BitVec('b', 32)
3526  >>> is_bv(b)
3527  True
3528  >>> is_bv(b + 10)
3529  True
3530  >>> is_bv(Int('x'))
3531  False
3532  """
3533  return isinstance(a, BitVecRef)
3534 
def is_bv(a)
Definition: z3py.py:3522

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

3061 def is_bv_sort(s):
3062  """Return True if `s` is a Z3 bit-vector sort.
3063 
3064  >>> is_bv_sort(BitVecSort(32))
3065  True
3066  >>> is_bv_sort(IntSort())
3067  False
3068  """
3069  return isinstance(s, BitVecSortRef)
3070 
def is_bv_sort(s)
Definition: z3py.py:3061

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

3535 def is_bv_value(a):
3536  """Return `True` if `a` is a Z3 bit-vector numeral value.
3537 
3538  >>> b = BitVec('b', 32)
3539  >>> is_bv_value(b)
3540  False
3541  >>> b = BitVecVal(10, 32)
3542  >>> b
3543  10
3544  >>> is_bv_value(b)
3545  True
3546  """
3547  return is_bv(a) and _is_numeral(a.ctx, a.as_ast())
3548 
def is_bv_value(a)
Definition: z3py.py:3535
def is_bv(a)
Definition: z3py.py:3522

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

Referenced by prove().

1080 def is_const(a):
1081  """Return `True` if `a` is Z3 constant/variable expression.
1082 
1083  >>> a = Int('a')
1084  >>> is_const(a)
1085  True
1086  >>> is_const(a + 1)
1087  False
1088  >>> is_const(1)
1089  False
1090  >>> is_const(IntVal(1))
1091  True
1092  >>> x = Int('x')
1093  >>> is_const(ForAll(x, x >= 0))
1094  False
1095  """
1096  return is_app(a) and a.num_args() == 0
1097 
def is_app(a)
Definition: z3py.py:1055
def is_const(a)
Definition: z3py.py:1080

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

4135 def is_const_array(a):
4136  """Return `True` if `a` is a Z3 constant array.
4137 
4138  >>> a = K(IntSort(), 10)
4139  >>> is_const_array(a)
4140  True
4141  >>> a = Array('a', IntSort(), IntSort())
4142  >>> is_const_array(a)
4143  False
4144  """
4145  return is_app_of(a, Z3_OP_CONST_ARRAY)
4146 
def is_const_array(a)
Definition: z3py.py:4135
def is_app_of(a, k)
Definition: z3py.py:1154

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

4174 def is_default(a):
4175  """Return `True` if `a` is a Z3 default array expression.
4176  >>> d = Default(K(IntSort(), 10))
4177  >>> is_default(d)
4178  True
4179  """
4180  return is_app_of(a, Z3_OP_ARRAY_DEFAULT)
4181 
def is_default(a)
Definition: z3py.py:4174
def is_app_of(a, k)
Definition: z3py.py:1154

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

1424 def is_distinct(a):
1425  """Return `True` if `a` is a Z3 distinct expression.
1426 
1427  >>> x, y, z = Ints('x y z')
1428  >>> is_distinct(x == y)
1429  False
1430  >>> is_distinct(Distinct(x, y, z))
1431  True
1432  """
1433  return is_app_of(a, Z3_OP_DISTINCT)
1434 
def is_distinct(a)
Definition: z3py.py:1424
def is_app_of(a, k)
Definition: z3py.py:1154

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

2470 def is_div(a):
2471  """Return `True` if `a` is an expression of the form b / c.
2472 
2473  >>> x, y = Reals('x y')
2474  >>> is_div(x / y)
2475  True
2476  >>> is_div(x + y)
2477  False
2478  >>> x, y = Ints('x y')
2479  >>> is_div(x / y)
2480  False
2481  >>> is_idiv(x / y)
2482  True
2483  """
2484  return is_app_of(a, Z3_OP_DIV)
2485 
def is_div(a)
Definition: z3py.py:2470
def is_app_of(a, k)
Definition: z3py.py:1154

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

Referenced by AstRef.__bool__().

1415 def is_eq(a):
1416  """Return `True` if `a` is a Z3 equality expression.
1417 
1418  >>> x, y = Ints('x y')
1419  >>> is_eq(x == y)
1420  True
1421  """
1422  return is_app_of(a, Z3_OP_EQ)
1423 
def is_eq(a)
Definition: z3py.py:1415
def is_app_of(a, k)
Definition: z3py.py:1154

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

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

1033 def is_expr(a):
1034  """Return `True` if `a` is a Z3 expression.
1035 
1036  >>> a = Int('a')
1037  >>> is_expr(a)
1038  True
1039  >>> is_expr(a + 1)
1040  True
1041  >>> is_expr(IntSort())
1042  False
1043  >>> is_expr(1)
1044  False
1045  >>> is_expr(IntVal(1))
1046  True
1047  >>> x = Int('x')
1048  >>> is_expr(ForAll(x, x >= 0))
1049  True
1050  >>> is_expr(FPVal(1.0))
1051  True
1052  """
1053  return isinstance(a, ExprRef)
1054 
def is_expr(a)
Definition: z3py.py:1033

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

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

1369 def is_false(a):
1370  """Return `True` if `a` is the Z3 false expression.
1371 
1372  >>> p = Bool('p')
1373  >>> is_false(p)
1374  False
1375  >>> is_false(False)
1376  False
1377  >>> is_false(BoolVal(False))
1378  True
1379  """
1380  return is_app_of(a, Z3_OP_FALSE)
1381 
def is_app_of(a, k)
Definition: z3py.py:1154
def is_false(a)
Definition: z3py.py:1369

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

Referenced by is_finite_domain_value().

6796 def is_finite_domain(a):
6797  """Return `True` if `a` is a Z3 finite-domain expression.
6798 
6799  >>> s = FiniteDomainSort('S', 100)
6800  >>> b = Const('b', s)
6801  >>> is_finite_domain(b)
6802  True
6803  >>> is_finite_domain(Int('x'))
6804  False
6805  """
6806  return isinstance(a, FiniteDomainRef)
6807 
6808 
def is_finite_domain(a)
Definition: z3py.py:6796

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

Referenced by FiniteDomainVal().

6774 def is_finite_domain_sort(s):
6775  """Return True if `s` is a Z3 finite-domain sort.
6776 
6777  >>> is_finite_domain_sort(FiniteDomainSort('S', 100))
6778  True
6779  >>> is_finite_domain_sort(IntSort())
6780  False
6781  """
6782  return isinstance(s, FiniteDomainSortRef)
6783 
6784 
def is_finite_domain_sort(s)
Definition: z3py.py:6774

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

6849 def is_finite_domain_value(a):
6850  """Return `True` if `a` is a Z3 finite-domain value.
6851 
6852  >>> s = FiniteDomainSort('S', 100)
6853  >>> b = Const('b', s)
6854  >>> is_finite_domain_value(b)
6855  False
6856  >>> b = FiniteDomainVal(10, s)
6857  >>> b
6858  10
6859  >>> is_finite_domain_value(b)
6860  True
6861  """
6862  return is_finite_domain(a) and _is_numeral(a.ctx, a.as_ast())
6863 
6864 
def is_finite_domain_value(a)
Definition: z3py.py:6849
def is_finite_domain(a)
Definition: z3py.py:6796

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

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

8823 def is_fp(a):
8824  """Return `True` if `a` is a Z3 floating-point expression.
8825 
8826  >>> b = FP('b', FPSort(8, 24))
8827  >>> is_fp(b)
8828  True
8829  >>> is_fp(b + 1.0)
8830  True
8831  >>> is_fp(Int('x'))
8832  False
8833  """
8834  return isinstance(a, FPRef)
8835 
def is_fp(a)
Definition: z3py.py:8823

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

8442 def is_fp_sort(s):
8443  """Return True if `s` is a Z3 floating-point sort.
8444 
8445  >>> is_fp_sort(FPSort(8, 24))
8446  True
8447  >>> is_fp_sort(IntSort())
8448  False
8449  """
8450  return isinstance(s, FPSortRef)
8451 
def is_fp_sort(s)
Definition: z3py.py:8442

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

8836 def is_fp_value(a):
8837  """Return `True` if `a` is a Z3 floating-point numeral value.
8838 
8839  >>> b = FP('b', FPSort(8, 24))
8840  >>> is_fp_value(b)
8841  False
8842  >>> b = FPVal(1.0, FPSort(8, 24))
8843  >>> b
8844  1
8845  >>> is_fp_value(b)
8846  True
8847  """
8848  return is_fp(a) and _is_numeral(a.ctx, a.ast)
8849 
def is_fp_value(a)
Definition: z3py.py:8836
def is_fp(a)
Definition: z3py.py:8823

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

8690 def is_fprm(a):
8691  """Return `True` if `a` is a Z3 floating-point rounding mode expression.
8692 
8693  >>> rm = RNE()
8694  >>> is_fprm(rm)
8695  True
8696  >>> rm = 1.0
8697  >>> is_fprm(rm)
8698  False
8699  """
8700  return isinstance(a, FPRMRef)
8701 
def is_fprm(a)
Definition: z3py.py:8690

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

8452 def is_fprm_sort(s):
8453  """Return True if `s` is a Z3 floating-point rounding mode sort.
8454 
8455  >>> is_fprm_sort(FPSort(8, 24))
8456  False
8457  >>> is_fprm_sort(RNE().sort())
8458  True
8459  """
8460  return isinstance(s, FPRMSortRef)
8461 
def is_fprm_sort(s)
Definition: z3py.py:8452

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

8702 def is_fprm_value(a):
8703  """Return `True` if `a` is a Z3 floating-point rounding mode numeral value."""
8704  return is_fprm(a) and _is_numeral(a.ctx, a.ast)
8705 
def is_fprm_value(a)
Definition: z3py.py:8702
def is_fprm(a)
Definition: z3py.py:8690

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

Referenced by prove().

748 def is_func_decl(a):
749  """Return `True` if `a` is a Z3 function declaration.
750 
751  >>> f = Function('f', IntSort(), IntSort())
752  >>> is_func_decl(f)
753  True
754  >>> x = Real('x')
755  >>> is_func_decl(x)
756  False
757  """
758  return isinstance(a, FuncDeclRef)
759 
def is_func_decl(a)
Definition: z3py.py:748

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

2530 def is_ge(a):
2531  """Return `True` if `a` is an expression of the form b >= c.
2532 
2533  >>> x, y = Ints('x y')
2534  >>> is_ge(x >= y)
2535  True
2536  >>> is_ge(x == y)
2537  False
2538  """
2539  return is_app_of(a, Z3_OP_GE)
2540 
def is_ge(a)
Definition: z3py.py:2530
def is_app_of(a, k)
Definition: z3py.py:1154

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

2541 def is_gt(a):
2542  """Return `True` if `a` is an expression of the form b > c.
2543 
2544  >>> x, y = Ints('x y')
2545  >>> is_gt(x > y)
2546  True
2547  >>> is_gt(x == y)
2548  False
2549  """
2550  return is_app_of(a, Z3_OP_GT)
2551 
def is_gt(a)
Definition: z3py.py:2541
def is_app_of(a, k)
Definition: z3py.py:1154

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

Referenced by is_div().

2486 def is_idiv(a):
2487  """Return `True` if `a` is an expression of the form b div c.
2488 
2489  >>> x, y = Ints('x y')
2490  >>> is_idiv(x / y)
2491  True
2492  >>> is_idiv(x + y)
2493  False
2494  """
2495  return is_app_of(a, Z3_OP_IDIV)
2496 
def is_idiv(a)
Definition: z3py.py:2486
def is_app_of(a, k)
Definition: z3py.py:1154

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

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

2338 def is_int(a):
2339  """Return `True` if `a` is an integer expression.
2340 
2341  >>> x = Int('x')
2342  >>> is_int(x + 1)
2343  True
2344  >>> is_int(1)
2345  False
2346  >>> is_int(IntVal(1))
2347  True
2348  >>> y = Real('y')
2349  >>> is_int(y)
2350  False
2351  >>> is_int(y + 1)
2352  False
2353  """
2354  return is_arith(a) and a.is_int()
2355 
def is_arith(a)
Definition: z3py.py:2318
def is_int(a)
Definition: z3py.py:2338

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

2380 def is_int_value(a):
2381  """Return `True` if `a` is an integer value of sort Int.
2382 
2383  >>> is_int_value(IntVal(1))
2384  True
2385  >>> is_int_value(1)
2386  False
2387  >>> is_int_value(Int('x'))
2388  False
2389  >>> n = Int('x') + 1
2390  >>> n
2391  x + 1
2392  >>> n.arg(1)
2393  1
2394  >>> is_int_value(n.arg(1))
2395  True
2396  >>> is_int_value(RealVal("1/3"))
2397  False
2398  >>> is_int_value(RealVal(1))
2399  False
2400  """
2401  return is_arith(a) and a.is_int() and _is_numeral(a.ctx, a.as_ast())
2402 
def is_int_value(a)
Definition: z3py.py:2380
def is_arith(a)
Definition: z3py.py:2318

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

2552 def is_is_int(a):
2553  """Return `True` if `a` is an expression of the form IsInt(b).
2554 
2555  >>> x = Real('x')
2556  >>> is_is_int(IsInt(x))
2557  True
2558  >>> is_is_int(x)
2559  False
2560  """
2561  return is_app_of(a, Z3_OP_IS_INT)
2562 
def is_app_of(a, k)
Definition: z3py.py:1154
def is_is_int(a)
Definition: z3py.py:2552

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

4147 def is_K(a):
4148  """Return `True` if `a` is a Z3 constant array.
4149 
4150  >>> a = K(IntSort(), 10)
4151  >>> is_K(a)
4152  True
4153  >>> a = Array('a', IntSort(), IntSort())
4154  >>> is_K(a)
4155  False
4156  """
4157  return is_app_of(a, Z3_OP_CONST_ARRAY)
4158 
def is_K(a)
Definition: z3py.py:4147
def is_app_of(a, k)
Definition: z3py.py:1154

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

2508 def is_le(a):
2509  """Return `True` if `a` is an expression of the form b <= c.
2510 
2511  >>> x, y = Ints('x y')
2512  >>> is_le(x <= y)
2513  True
2514  >>> is_le(x < y)
2515  False
2516  """
2517  return is_app_of(a, Z3_OP_LE)
2518 
def is_le(a)
Definition: z3py.py:2508
def is_app_of(a, k)
Definition: z3py.py:1154

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

2519 def is_lt(a):
2520  """Return `True` if `a` is an expression of the form b < c.
2521 
2522  >>> x, y = Ints('x y')
2523  >>> is_lt(x < y)
2524  True
2525  >>> is_lt(x == y)
2526  False
2527  """
2528  return is_app_of(a, Z3_OP_LT)
2529 
def is_lt(a)
Definition: z3py.py:2519
def is_app_of(a, k)
Definition: z3py.py:1154

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

4159 def is_map(a):
4160  """Return `True` if `a` is a Z3 map array expression.
4161 
4162  >>> f = Function('f', IntSort(), IntSort())
4163  >>> b = Array('b', IntSort(), IntSort())
4164  >>> a = Map(f, b)
4165  >>> a
4166  Map(f, b)
4167  >>> is_map(a)
4168  True
4169  >>> is_map(b)
4170  False
4171  """
4172  return is_app_of(a, Z3_OP_ARRAY_MAP)
4173 
def is_map(a)
Definition: z3py.py:4159
def is_app_of(a, k)
Definition: z3py.py:1154

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

2497 def is_mod(a):
2498  """Return `True` if `a` is an expression of the form b % c.
2499 
2500  >>> x, y = Ints('x y')
2501  >>> is_mod(x % y)
2502  True
2503  >>> is_mod(x + y)
2504  False
2505  """
2506  return is_app_of(a, Z3_OP_MOD)
2507 
def is_mod(a)
Definition: z3py.py:2497
def is_app_of(a, k)
Definition: z3py.py:1154

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

2448 def is_mul(a):
2449  """Return `True` if `a` is an expression of the form b * c.
2450 
2451  >>> x, y = Ints('x y')
2452  >>> is_mul(x * y)
2453  True
2454  >>> is_mul(x - y)
2455  False
2456  """
2457  return is_app_of(a, Z3_OP_MUL)
2458 
def is_app_of(a, k)
Definition: z3py.py:1154
def is_mul(a)
Definition: z3py.py:2448

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

1404 def is_not(a):
1405  """Return `True` if `a` is a Z3 not expression.
1406 
1407  >>> p = Bool('p')
1408  >>> is_not(p)
1409  False
1410  >>> is_not(Not(p))
1411  True
1412  """
1413  return is_app_of(a, Z3_OP_NOT)
1414 
def is_not(a)
Definition: z3py.py:1404
def is_app_of(a, k)
Definition: z3py.py:1154

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

1393 def is_or(a):
1394  """Return `True` if `a` is a Z3 or expression.
1395 
1396  >>> p, q = Bools('p q')
1397  >>> is_or(Or(p, q))
1398  True
1399  >>> is_or(And(p, q))
1400  False
1401  """
1402  return is_app_of(a, Z3_OP_OR)
1403 
def is_or(a)
Definition: z3py.py:1393
def is_app_of(a, k)
Definition: z3py.py:1154

◆ is_pattern()

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

See http://rise4fun.com/Z3Py/tutorial/advanced for more details.

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

Referenced by MultiPattern().

1658 def is_pattern(a):
1659  """Return `True` if `a` is a Z3 pattern (hint for quantifier instantiation.
1660 
1661  See http://rise4fun.com/Z3Py/tutorial/advanced for more details.
1662 
1663  >>> f = Function('f', IntSort(), IntSort())
1664  >>> x = Int('x')
1665  >>> q = ForAll(x, f(x) == 0, patterns = [ f(x) ])
1666  >>> q
1667  ForAll(x, f(x) == 0)
1668  >>> q.num_patterns()
1669  1
1670  >>> is_pattern(q.pattern(0))
1671  True
1672  >>> q.pattern(0)
1673  f(Var(0))
1674  """
1675  return isinstance(a, PatternRef)
1676 
def is_pattern(a)
Definition: z3py.py:1658

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

Referenced by eq().

7592 def is_probe(p):
7593  """Return `True` if `p` is a Z3 probe.
7594 
7595  >>> is_probe(Int('x'))
7596  False
7597  >>> is_probe(Probe('memory'))
7598  True
7599  """
7600  return isinstance(p, Probe)
7601 
def is_probe(p)
Definition: z3py.py:7592

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

Referenced by Exists().

1861 def is_quantifier(a):
1862  """Return `True` if `a` is a Z3 quantifier.
1863 
1864  >>> f = Function('f', IntSort(), IntSort())
1865  >>> x = Int('x')
1866  >>> q = ForAll(x, f(x) == 0)
1867  >>> is_quantifier(q)
1868  True
1869  >>> is_quantifier(f(x))
1870  False
1871  """
1872  return isinstance(a, QuantifierRef)
1873 
def is_quantifier(a)
Definition: z3py.py:1861

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

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

2403 def is_rational_value(a):
2404  """Return `True` if `a` is rational value of sort Real.
2405 
2406  >>> is_rational_value(RealVal(1))
2407  True
2408  >>> is_rational_value(RealVal("3/5"))
2409  True
2410  >>> is_rational_value(IntVal(1))
2411  False
2412  >>> is_rational_value(1)
2413  False
2414  >>> n = Real('x') + 1
2415  >>> n.arg(1)
2416  1
2417  >>> is_rational_value(n.arg(1))
2418  True
2419  >>> is_rational_value(Real('x'))
2420  False
2421  """
2422  return is_arith(a) and a.is_real() and _is_numeral(a.ctx, a.as_ast())
2423 
def is_arith(a)
Definition: z3py.py:2318
def is_rational_value(a)
Definition: z3py.py:2403

◆ is_re()

def z3py.is_re (   s)

Definition at line 9939 of file z3py.py.

9939 def is_re(s):
9940  return isinstance(s, ReRef)
9941 
9942 
def is_re(s)
Definition: z3py.py:9939

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

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

2356 def is_real(a):
2357  """Return `True` if `a` is a real expression.
2358 
2359  >>> x = Int('x')
2360  >>> is_real(x + 1)
2361  False
2362  >>> y = Real('y')
2363  >>> is_real(y)
2364  True
2365  >>> is_real(y + 1)
2366  True
2367  >>> is_real(1)
2368  False
2369  >>> is_real(RealVal(1))
2370  True
2371  """
2372  return is_arith(a) and a.is_real()
2373 
def is_real(a)
Definition: z3py.py:2356
def is_arith(a)
Definition: z3py.py:2318

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

4346 def is_select(a):
4347  """Return `True` if `a` is a Z3 array select application.
4348 
4349  >>> a = Array('a', IntSort(), IntSort())
4350  >>> is_select(a)
4351  False
4352  >>> i = Int('i')
4353  >>> is_select(a[i])
4354  True
4355  """
4356  return is_app_of(a, Z3_OP_SELECT)
4357 
def is_select(a)
Definition: z3py.py:4346
def is_app_of(a, k)
Definition: z3py.py:1154

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

9707 def is_seq(a):
9708  """Return `True` if `a` is a Z3 sequence expression.
9709  >>> print (is_seq(Unit(IntVal(0))))
9710  True
9711  >>> print (is_seq(StringVal("abc")))
9712  True
9713  """
9714  return isinstance(a, SeqRef)
9715 
def is_seq(a)
Definition: z3py.py:9707

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

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

561 def is_sort(s):
562  """Return `True` if `s` is a Z3 sort.
563 
564  >>> is_sort(IntSort())
565  True
566  >>> is_sort(Int('x'))
567  False
568  >>> is_expr(Int('x'))
569  True
570  """
571  return isinstance(s, SortRef)
572 
def is_sort(s)
Definition: z3py.py:561

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

4358 def is_store(a):
4359  """Return `True` if `a` is a Z3 array store application.
4360 
4361  >>> a = Array('a', IntSort(), IntSort())
4362  >>> is_store(a)
4363  False
4364  >>> is_store(Store(a, 0, 1))
4365  True
4366  """
4367  return is_app_of(a, Z3_OP_STORE)
4368 
def is_store(a)
Definition: z3py.py:4358
def is_app_of(a, k)
Definition: z3py.py:1154

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

9716 def is_string(a):
9717  """Return `True` if `a` is a Z3 string expression.
9718  >>> print (is_string(StringVal("ab")))
9719  True
9720  """
9721  return isinstance(a, SeqRef) and a.is_string()
9722 
def is_string(a)
Definition: z3py.py:9716

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

9723 def is_string_value(a):
9724  """return 'True' if 'a' is a Z3 string constant expression.
9725  >>> print (is_string_value(StringVal("a")))
9726  True
9727  >>> print (is_string_value(StringVal("a") + StringVal("b")))
9728  False
9729  """
9730  return isinstance(a, SeqRef) and a.is_string_value()
9731 
9732 
def is_string_value(a)
Definition: z3py.py:9723

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

2459 def is_sub(a):
2460  """Return `True` if `a` is an expression of the form b - c.
2461 
2462  >>> x, y = Ints('x y')
2463  >>> is_sub(x - y)
2464  True
2465  >>> is_sub(x + y)
2466  False
2467  """
2468  return is_app_of(a, Z3_OP_SUB)
2469 
def is_app_of(a, k)
Definition: z3py.py:1154
def is_sub(a)
Definition: z3py.py:2459

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

2577 def is_to_int(a):
2578  """Return `True` if `a` is an expression of the form ToInt(b).
2579 
2580  >>> x = Real('x')
2581  >>> n = ToInt(x)
2582  >>> n
2583  ToInt(x)
2584  >>> is_to_int(n)
2585  True
2586  >>> is_to_int(x)
2587  False
2588  """
2589  return is_app_of(a, Z3_OP_TO_INT)
2590 
def is_app_of(a, k)
Definition: z3py.py:1154
def is_to_int(a)
Definition: z3py.py:2577

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

2563 def is_to_real(a):
2564  """Return `True` if `a` is an expression of the form ToReal(b).
2565 
2566  >>> x = Int('x')
2567  >>> n = ToReal(x)
2568  >>> n
2569  ToReal(x)
2570  >>> is_to_real(n)
2571  True
2572  >>> is_to_real(x)
2573  False
2574  """
2575  return is_app_of(a, Z3_OP_TO_REAL)
2576 
def is_to_real(a)
Definition: z3py.py:2563
def is_app_of(a, k)
Definition: z3py.py:1154

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

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

1352 def is_true(a):
1353  """Return `True` if `a` is the Z3 true expression.
1354 
1355  >>> p = Bool('p')
1356  >>> is_true(p)
1357  False
1358  >>> is_true(simplify(p == p))
1359  True
1360  >>> x = Real('x')
1361  >>> is_true(x == 0)
1362  False
1363  >>> # True is a Python Boolean expression
1364  >>> is_true(True)
1365  False
1366  """
1367  return is_app_of(a, Z3_OP_TRUE)
1368 
def is_true(a)
Definition: z3py.py:1352
def is_app_of(a, k)
Definition: z3py.py:1154

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

Referenced by get_var_index().

1098 def is_var(a):
1099  """Return `True` if `a` is variable.
1100 
1101  Z3 uses de-Bruijn indices for representing bound variables in
1102  quantifiers.
1103 
1104  >>> x = Int('x')
1105  >>> is_var(x)
1106  False
1107  >>> is_const(x)
1108  True
1109  >>> f = Function('f', IntSort(), IntSort())
1110  >>> # Z3 replaces x with bound variables when ForAll is executed.
1111  >>> q = ForAll(x, f(x) == x)
1112  >>> b = q.body()
1113  >>> b
1114  f(Var(0)) == Var(0)
1115  >>> b.arg(1)
1116  Var(0)
1117  >>> is_var(b.arg(1))
1118  True
1119  """
1120  return is_expr(a) and _ast_kind(a.ctx, a) == Z3_VAR_AST
1121 
def is_expr(a)
Definition: z3py.py:1033
def is_var(a)
Definition: z3py.py:1098

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

Referenced by is_is_int().

2983 def IsInt(a):
2984  """ Return the Z3 predicate IsInt(a).
2985 
2986  >>> x = Real('x')
2987  >>> IsInt(x + "1/2")
2988  IsInt(x + 1/2)
2989  >>> solve(IsInt(x + "1/2"), x > 0, x < 1)
2990  [x = 1/2]
2991  >>> solve(IsInt(x + "1/2"), x > 0, x < 1, x != "1/2")
2992  no solution
2993  """
2994  if __debug__:
2995  _z3_assert(a.is_real(), "Z3 real expression expected.")
2996  ctx = a.ctx
2997  return BoolRef(Z3_mk_is_int(ctx.ref(), a.as_ast()), ctx)
2998 
def IsInt(a)
Definition: z3py.py:2983
Z3_ast Z3_API Z3_mk_is_int(Z3_context c, Z3_ast t1)
Check if a real number is an integer.

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

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

4318 def K(dom, v):
4319  """Return a Z3 constant array expression.
4320 
4321  >>> a = K(IntSort(), 10)
4322  >>> a
4323  K(Int, 10)
4324  >>> a.sort()
4325  Array(Int, Int)
4326  >>> i = Int('i')
4327  >>> a[i]
4328  K(Int, 10)[i]
4329  >>> simplify(a[i])
4330  10
4331  """
4332  if __debug__:
4333  _z3_assert(is_sort(dom), "Z3 sort expected")
4334  ctx = dom.ctx
4335  if not is_expr(v):
4336  v = _py2expr(v, ctx)
4337  return ArrayRef(Z3_mk_const_array(ctx.ref(), dom.ast, v.as_ast()), ctx)
4338 
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:561
def K(dom, v)
Definition: z3py.py:4318
def is_expr(a)
Definition: z3py.py:1033

◆ Length()

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

Definition at line 9873 of file z3py.py.

9873 def Length(s):
9874  """Obtain the length of a sequence 's'
9875  >>> l = Length(StringVal("abc"))
9876  >>> simplify(l)
9877  3
9878  """
9879  s = _coerce_seq(s)
9880  return ArithRef(Z3_mk_seq_length(s.ctx_ref(), s.as_ast()), s.ctx)
9881 
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:9873

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

10015 def Loop(re, lo, hi=0):
10016  """Create the regular expression accepting between a lower and upper bound repetitions
10017  >>> re = Loop(Re("a"), 1, 3)
10018  >>> print(simplify(InRe("aa", re)))
10019  True
10020  >>> print(simplify(InRe("aaaa", re)))
10021  False
10022  >>> print(simplify(InRe("", re)))
10023  False
10024  """
10025  return ReRef(Z3_mk_re_loop(re.ctx_ref(), re.as_ast(), lo, hi), re.ctx)
10026 
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 repated between lo and hi time...
def Loop(re, lo, hi=0)
Definition: z3py.py:10015

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

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

3844 def LShR(a, b):
3845  """Create the Z3 expression logical right shift.
3846 
3847  Use the operator >> for the arithmetical right shift.
3848 
3849  >>> x, y = BitVecs('x y', 32)
3850  >>> LShR(x, y)
3851  LShR(x, y)
3852  >>> (x >> y).sexpr()
3853  '(bvashr x y)'
3854  >>> LShR(x, y).sexpr()
3855  '(bvlshr x y)'
3856  >>> BitVecVal(4, 3)
3857  4
3858  >>> BitVecVal(4, 3).as_signed_long()
3859  -4
3860  >>> simplify(BitVecVal(4, 3) >> 1).as_signed_long()
3861  -2
3862  >>> simplify(BitVecVal(4, 3) >> 1)
3863  6
3864  >>> simplify(LShR(BitVecVal(4, 3), 1))
3865  2
3866  >>> simplify(BitVecVal(2, 3) >> 1)
3867  1
3868  >>> simplify(LShR(BitVecVal(2, 3), 1))
3869  1
3870  """
3871  _check_bv_args(a, b)
3872  a, b = _coerce_exprs(a, b)
3873  return BitVecRef(Z3_mk_bvlshr(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3874 
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:3844

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

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

192 def main_ctx():
193  """Return a reference to the global Z3 context.
194 
195  >>> x = Real('x')
196  >>> x.ctx == main_ctx()
197  True
198  >>> c = Context()
199  >>> c == main_ctx()
200  False
201  >>> x2 = Real('x', c)
202  >>> x2.ctx == c
203  True
204  >>> eq(x, x2)
205  False
206  """
207  global _main_ctx
208  if _main_ctx is None:
209  _main_ctx = Context()
210  return _main_ctx
211 
def main_ctx()
Definition: z3py.py:192

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

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

4296 def Map(f, *args):
4297  """Return a Z3 map array expression.
4298 
4299  >>> f = Function('f', IntSort(), IntSort(), IntSort())
4300  >>> a1 = Array('a1', IntSort(), IntSort())
4301  >>> a2 = Array('a2', IntSort(), IntSort())
4302  >>> b = Map(f, a1, a2)
4303  >>> b
4304  Map(f, a1, a2)
4305  >>> prove(b[0] == f(a1[0], a2[0]))
4306  proved
4307  """
4308  args = _get_args(args)
4309  if __debug__:
4310  _z3_assert(len(args) > 0, "At least one Z3 array expression expected")
4311  _z3_assert(is_func_decl(f), "First argument must be a Z3 function declaration")
4312  _z3_assert(all([is_array(a) for a in args]), "Z3 array expected expected")
4313  _z3_assert(len(args) == f.arity(), "Number of arguments mismatch")
4314  _args, sz = _to_ast_array(args)
4315  ctx = f.ctx
4316  return ArrayRef(Z3_mk_map(ctx.ref(), f.ast, sz, _args), ctx)
4317 
def is_array(a)
Definition: z3py.py:4122
def Map(f, args)
Definition: z3py.py:4296
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:748

◆ MultiPattern()

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

See http://rise4fun.com/Z3Py/tutorial/advanced for more details.

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

1677 def MultiPattern(*args):
1678  """Create a Z3 multi-pattern using the given expressions `*args`
1679 
1680  See http://rise4fun.com/Z3Py/tutorial/advanced for more details.
1681 
1682  >>> f = Function('f', IntSort(), IntSort())
1683  >>> g = Function('g', IntSort(), IntSort())
1684  >>> x = Int('x')
1685  >>> q = ForAll(x, f(x) != g(x), patterns = [ MultiPattern(f(x), g(x)) ])
1686  >>> q
1687  ForAll(x, f(x) != g(x))
1688  >>> q.num_patterns()
1689  1
1690  >>> is_pattern(q.pattern(0))
1691  True
1692  >>> q.pattern(0)
1693  MultiPattern(f(Var(0)), g(Var(0)))
1694  """
1695  if __debug__:
1696  _z3_assert(len(args) > 0, "At least one argument expected")
1697  _z3_assert(all([ is_expr(a) for a in args ]), "Z3 expressions expected")
1698  ctx = args[0].ctx
1699  args, sz = _to_ast_array(args)
1700  return PatternRef(Z3_mk_pattern(ctx.ref(), sz, args), ctx)
1701 
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:1677
def is_expr(a)
Definition: z3py.py:1033

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

Referenced by binary_interpolant(), Solver.consequences(), fpNEQ(), Implies(), prove(), sequence_interpolant(), tree_interpolant(), and Xor().

1553 def Not(a, ctx=None):
1554  """Create a Z3 not expression or probe.
1555 
1556  >>> p = Bool('p')
1557  >>> Not(Not(p))
1558  Not(Not(p))
1559  >>> simplify(Not(Not(p)))
1560  p
1561  """
1562  ctx = _get_ctx(_ctx_from_ast_arg_list([a], ctx))
1563  if is_probe(a):
1564  # Not is also used to build probes
1565  return Probe(Z3_probe_not(ctx.ref(), a.probe), ctx)
1566  else:
1567  s = BoolSort(ctx)
1568  a = s.cast(a)
1569  return BoolRef(Z3_mk_not(ctx.ref(), a.as_ast()), ctx)
1570 
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:1553
def is_probe(p)
Definition: z3py.py:7592
def BoolSort(ctx=None)
Definition: z3py.py:1435

◆ open_log()

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

Definition at line 93 of file z3py.py.

93 def open_log(fname):
94  """Log interaction to a file. This function must be invoked immediately after init(). """
95  Z3_open_log(fname)
96 
Z3_bool Z3_API Z3_open_log(Z3_string filename)
Log interaction to a file.
def open_log(fname)
Definition: z3py.py:93

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

9987 def Option(re):
9988  """Create the regular expression that optionally accepts the argument.
9989  >>> re = Option(Re("a"))
9990  >>> print(simplify(InRe("a", re)))
9991  True
9992  >>> print(simplify(InRe("", re)))
9993  True
9994  >>> print(simplify(InRe("aa", re)))
9995  False
9996  """
9997  return ReRef(Z3_mk_re_option(re.ctx_ref(), re.as_ast()), re.ctx)
9998 
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:9987

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

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

1611 def Or(*args):
1612  """Create a Z3 or-expression or or-probe.
1613 
1614  >>> p, q, r = Bools('p q r')
1615  >>> Or(p, q, r)
1616  Or(p, q, r)
1617  >>> P = BoolVector('p', 5)
1618  >>> Or(P)
1619  Or(p__0, p__1, p__2, p__3, p__4)
1620  """
1621  last_arg = None
1622  if len(args) > 0:
1623  last_arg = args[len(args)-1]
1624  if isinstance(last_arg, Context):
1625  ctx = args[len(args)-1]
1626  args = args[:len(args)-1]
1627  else:
1628  ctx = main_ctx()
1629  args = _get_args(args)
1630  ctx_args = _ctx_from_ast_arg_list(args, ctx)
1631  if __debug__:
1632  _z3_assert(ctx_args is None or ctx_args == ctx, "context mismatch")
1633  _z3_assert(ctx is not None, "At least one of the arguments must be a Z3 expression or probe")
1634  if _has_probe(args):
1635  return _probe_or(args, ctx)
1636  else:
1637  args = _coerce_expr_list(args, ctx)
1638  _args, sz = _to_ast_array(args)
1639  return BoolRef(Z3_mk_or(ctx.ref(), sz, _args), ctx)
1640 
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:192
def Or(args)
Definition: z3py.py:1611

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

7321 def OrElse(*ts, **ks):
7322  """Return a tactic that applies the tactics in `*ts` until one of them succeeds (it doesn't fail).
7323 
7324  >>> x = Int('x')
7325  >>> t = OrElse(Tactic('split-clause'), Tactic('skip'))
7326  >>> # Tactic split-clause fails if there is no clause in the given goal.
7327  >>> t(x == 0)
7328  [[x == 0]]
7329  >>> t(Or(x == 0, x == 1))
7330  [[x == 0], [x == 1]]
7331  """
7332  if __debug__:
7333  _z3_assert(len(ts) >= 2, "At least two arguments expected")
7334  ctx = ks.get('ctx', None)
7335  num = len(ts)
7336  r = ts[0]
7337  for i in range(num - 1):
7338  r = _or_else(r, ts[i+1], ctx)
7339  return r
7340 
def OrElse(ts, ks)
Definition: z3py.py:7321
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:2813

◆ ParAndThen()

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

Definition at line 7373 of file z3py.py.

7373 def ParAndThen(t1, t2, ctx=None):
7374  """Alias for ParThen(t1, t2, ctx)."""
7375  return ParThen(t1, t2, ctx)
7376 
def ParAndThen(t1, t2, ctx=None)
Definition: z3py.py:7373
def ParThen(t1, t2, ctx=None)
Definition: z3py.py:7359

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

7341 def ParOr(*ts, **ks):
7342  """Return a tactic that applies the tactics in `*ts` in parallel until one of them succeeds (it doesn't fail).
7343 
7344  >>> x = Int('x')
7345  >>> t = ParOr(Tactic('simplify'), Tactic('fail'))
7346  >>> t(x + 1 == 2)
7347  [[x == 1]]
7348  """
7349  if __debug__:
7350  _z3_assert(len(ts) >= 2, "At least two arguments expected")
7351  ctx = _get_ctx(ks.get('ctx', None))
7352  ts = [ _to_tactic(t, ctx) for t in ts ]
7353  sz = len(ts)
7354  _args = (TacticObj * sz)()
7355  for i in range(sz):
7356  _args[i] = ts[i].tactic
7357  return Tactic(Z3_tactic_par_or(ctx.ref(), sz, _args), ctx)
7358 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:2813
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:7341

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

8129 def parse_smt2_file(f, sorts={}, decls={}, ctx=None):
8130  """Parse a file in SMT 2.0 format using the given sorts and decls.
8131 
8132  This function is similar to parse_smt2_string().
8133  """
8134  ctx = _get_ctx(ctx)
8135  ssz, snames, ssorts = _dict2sarray(sorts, ctx)
8136  dsz, dnames, ddecls = _dict2darray(decls, ctx)
8137  try:
8138  return _to_expr_ref(Z3_parse_smtlib2_file(ctx.ref(), f, ssz, snames, ssorts, dsz, dnames, ddecls), ctx)
8139  except Z3Exception as e:
8140  _handle_parse_error(e, ctx)
8141 
Z3_ast 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.
def parse_smt2_file(f, sorts={}, decls={}, ctx=None)
Definition: z3py.py:8129

◆ 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))')
And(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 8106 of file z3py.py.

Referenced by parse_smt2_file().

8106 def parse_smt2_string(s, sorts={}, decls={}, ctx=None):
8107  """Parse a string in SMT 2.0 format using the given sorts and decls.
8108 
8109  The arguments sorts and decls are Python dictionaries used to initialize
8110  the symbol table used for the SMT 2.0 parser.
8111 
8112  >>> parse_smt2_string('(declare-const x Int) (assert (> x 0)) (assert (< x 10))')
8113  And(x > 0, x < 10)
8114  >>> x, y = Ints('x y')
8115  >>> f = Function('f', IntSort(), IntSort())
8116  >>> parse_smt2_string('(assert (> (+ foo (g bar)) 0))', decls={ 'foo' : x, 'bar' : y, 'g' : f})
8117  x + f(y) > 0
8118  >>> parse_smt2_string('(declare-const a U) (assert (> a 0))', sorts={ 'U' : IntSort() }) a > 0
8119  """
8120  ctx = _get_ctx(ctx)
8121  ssz, snames, ssorts = _dict2sarray(sorts, ctx)
8122  dsz, dnames, ddecls = _dict2darray(decls, ctx)
8123  try:
8124  return _to_expr_ref(Z3_parse_smtlib2_string(ctx.ref(), s, ssz, snames, ssorts, dsz, dnames, ddecls), ctx)
8125  except Z3Exception as e:
8126  _handle_parse_error(e, ctx)
8127 
8128 
def parse_smt2_string(s, sorts={}, decls={}, ctx=None)
Definition: z3py.py:8106

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

Referenced by ParAndThen().

7359 def ParThen(t1, t2, ctx=None):
7360  """Return a tactic that applies t1 and then t2 to every subgoal produced by t1. The subgoals are processed in parallel.
7361 
7362  >>> x, y = Ints('x y')
7363  >>> t = ParThen(Tactic('split-clause'), Tactic('propagate-values'))
7364  >>> t(And(Or(x == 1, x == 2), y == x + 1))
7365  [[x == 1, y == 2], [x == 2, y == 3]]
7366  """
7367  t1 = _to_tactic(t1, ctx)
7368  t2 = _to_tactic(t2, ctx)
7369  if __debug__:
7370  _z3_assert(t1.ctx == t2.ctx, "Context mismatch")
7371  return Tactic(Z3_tactic_par_and_then(t1.ctx.ref(), t1.tactic, t2.tactic), t1.ctx)
7372 
Z3_tactic Z3_API Z3_tactic_par_and_then(Z3_context c, Z3_tactic t1, Z3_tactic t2)
Return a tactic that applies t1 to a given goal and then t2 to every subgoal produced by t1...
def ParThen(t1, t2, ctx=None)
Definition: z3py.py:7359

◆ PbEq()

def z3py.PbEq (   args,
  k 
)
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 7909 of file z3py.py.

7909 def PbEq(args, k):
7910  """Create a Pseudo-Boolean inequality k constraint.
7911 
7912  >>> a, b, c = Bools('a b c')
7913  >>> f = PbEq(((a,1),(b,3),(c,2)), 3)
7914  """
7915  ctx, sz, _args, _coeffs = _pb_args_coeffs(args)
7916  return BoolRef(Z3_mk_pbeq(ctx.ref(), sz, _args, _coeffs, k), ctx)
7917 
7918 
def PbEq(args, k)
Definition: z3py.py:7909
Z3_ast Z3_API Z3_mk_pbeq(Z3_context c, unsigned num_args, Z3_ast const args[], int const coeffs[], int k)
Pseudo-Boolean relations.

◆ PbGe()

def z3py.PbGe (   args,
  k 
)
Create a Pseudo-Boolean inequality k constraint.

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

Definition at line 7900 of file z3py.py.

7900 def PbGe(args, k):
7901  """Create a Pseudo-Boolean inequality k constraint.
7902 
7903  >>> a, b, c = Bools('a b c')
7904  >>> f = PbGe(((a,1),(b,3),(c,2)), 3)
7905  """
7906  ctx, sz, _args, _coeffs = _pb_args_coeffs(args)
7907  return BoolRef(Z3_mk_pbge(ctx.ref(), sz, _args, _coeffs, k), ctx)
7908 
def PbGe(args, k)
Definition: z3py.py:7900
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 7891 of file z3py.py.

7891 def PbLe(args, k):
7892  """Create a Pseudo-Boolean inequality k constraint.
7893 
7894  >>> a, b, c = Bools('a b c')
7895  >>> f = PbLe(((a,1),(b,3),(c,2)), 3)
7896  """
7897  ctx, sz, _args, _coeffs = _pb_args_coeffs(args)
7898  return BoolRef(Z3_mk_pble(ctx.ref(), sz, _args, _coeffs, k), ctx)
7899 
def PbLe(args, k)
Definition: z3py.py:7891
Z3_ast Z3_API Z3_mk_pble(Z3_context c, unsigned num_args, Z3_ast const args[], int const coeffs[], int k)
Pseudo-Boolean relations.

◆ Plus()

def z3py.Plus (   re)
Create the regular expression accepting one or more repetitions of argument.
>>> re = Plus(Re("a"))
>>> print(simplify(InRe("aa", re)))
True
>>> print(simplify(InRe("ab", re)))
False
>>> print(simplify(InRe("", re)))
False

Definition at line 9975 of file z3py.py.

9975 def Plus(re):
9976  """Create the regular expression accepting one or more repetitions of argument.
9977  >>> re = Plus(Re("a"))
9978  >>> print(simplify(InRe("aa", re)))
9979  True
9980  >>> print(simplify(InRe("ab", re)))
9981  False
9982  >>> print(simplify(InRe("", re)))
9983  False
9984  """
9985  return ReRef(Z3_mk_re_plus(re.ctx_ref(), re.as_ast()), re.ctx)
9986 
def Plus(re)
Definition: z3py.py:9975
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 9792 of file z3py.py.

9792 def PrefixOf(a, b):
9793  """Check if 'a' is a prefix of 'b'
9794  >>> s1 = PrefixOf("ab", "abc")
9795  >>> simplify(s1)
9796  True
9797  >>> s2 = PrefixOf("bc", "abc")
9798  >>> simplify(s2)
9799  False
9800  """
9801  ctx = _get_ctx2(a, b)
9802  a = _coerce_seq(a, ctx)
9803  b = _coerce_seq(b, ctx)
9804  return BoolRef(Z3_mk_seq_prefix(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
9805 
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:9792

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

Referenced by describe_probes().

7618 def probe_description(name, ctx=None):
7619  """Return a short description for the probe named `name`.
7620 
7621  >>> d = probe_description('memory')
7622  """
7623  ctx = _get_ctx(ctx)
7624  return Z3_probe_get_descr(ctx.ref(), name)
7625 
def probe_description(name, ctx=None)
Definition: z3py.py:7618
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 7608 of file z3py.py.

Referenced by describe_probes().

7608 def probes(ctx=None):
7609  """Return a list of all available probes in Z3.
7610 
7611  >>> l = probes()
7612  >>> l.count('memory') == 1
7613  True
7614  """
7615  ctx = _get_ctx(ctx)
7616  return [ Z3_get_probe_name(ctx.ref(), i) for i in range(Z3_get_num_probes(ctx.ref())) ]
7617 
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:2813
def probes(ctx=None)
Definition: z3py.py:7608
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 7816 of file z3py.py.

Referenced by BitVecs().

7816 def Product(*args):
7817  """Create the product of the Z3 expressions.
7818 
7819  >>> a, b, c = Ints('a b c')
7820  >>> Product(a, b, c)
7821  a*b*c
7822  >>> Product([a, b, c])
7823  a*b*c
7824  >>> A = IntVector('a', 5)
7825  >>> Product(A)
7826  a__0*a__1*a__2*a__3*a__4
7827  """
7828  args = _get_args(args)
7829  if len(args) == 0:
7830  return 1
7831  ctx = _ctx_from_ast_arg_list(args)
7832  if ctx is None:
7833  return _reduce(lambda a, b: a * b, args, 1)
7834  args = _coerce_expr_list(args, ctx)
7835  if is_bv(args[0]):
7836  return _reduce(lambda a, b: a * b, args, 1)
7837  else:
7838  _args, sz = _to_ast_array(args)
7839  return ArithRef(Z3_mk_mul(ctx.ref(), sz, _args), ctx)
7840 
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:7816
def is_bv(a)
Definition: z3py.py:3522

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

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

7976 def prove(claim, **keywords):
7977  """Try to prove the given claim.
7978 
7979  This is a simple function for creating demonstrations. It tries to prove
7980  `claim` by showing the negation is unsatisfiable.
7981 
7982  >>> p, q = Bools('p q')
7983  >>> prove(Not(And(p, q)) == Or(Not(p), Not(q)))
7984  proved
7985  """
7986  if __debug__:
7987  _z3_assert(is_bool(claim), "Z3 Boolean expression expected")
7988  s = Solver()
7989  s.set(**keywords)
7990  s.add(Not(claim))
7991  if keywords.get('show', False):
7992  print(s)
7993  r = s.check()
7994  if r == unsat:
7995  print("proved")
7996  elif r == unknown:
7997  print("failed to prove")
7998  print(s.model())
7999  else:
8000  print("counterexample")
8001  print(s.model())
8002 
def prove(claim, keywords)
Definition: z3py.py:7976
def Not(a, ctx=None)
Definition: z3py.py:1553
def is_bool(a)
Definition: z3py.py:1335

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

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

2837 def Q(a, b, ctx=None):
2838  """Return a Z3 rational a/b.
2839 
2840  If `ctx=None`, then the global context is used.
2841 
2842  >>> Q(3,5)
2843  3/5
2844  >>> Q(3,5).sort()
2845  Real
2846  """
2847  return simplify(RatVal(a, b))
2848 
def simplify(a, arguments, keywords)
Utils.
Definition: z3py.py:7712
def RatVal(a, b, ctx=None)
Definition: z3py.py:2822
def Q(a, b, ctx=None)
Definition: z3py.py:2837

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

2822 def RatVal(a, b, ctx=None):
2823  """Return a Z3 rational a/b.
2824 
2825  If `ctx=None`, then the global context is used.
2826 
2827  >>> RatVal(3,5)
2828  3/5
2829  >>> RatVal(3,5).sort()
2830  Real
2831  """
2832  if __debug__:
2833  _z3_assert(_is_int(a) or isinstance(a, str), "First argument cannot be converted into an integer")
2834  _z3_assert(_is_int(b) or isinstance(b, str), "Second argument cannot be converted into an integer")
2835  return simplify(RealVal(a, ctx)/RealVal(b, ctx))
2836 
def simplify(a, arguments, keywords)
Utils.
Definition: z3py.py:7712
def RatVal(a, b, ctx=None)
Definition: z3py.py:2822
def RealVal(val, ctx=None)
Definition: z3py.py:2804

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

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

9905 def Re(s, ctx=None):
9906  """The regular expression that accepts sequence 's'
9907  >>> s1 = Re("ab")
9908  >>> s2 = Re(StringVal("ab"))
9909  >>> s3 = Re(Unit(BoolVal(True)))
9910  """
9911  s = _coerce_seq(s, ctx)
9912  return ReRef(Z3_mk_seq_to_re(s.ctx_ref(), s.as_ast()), s.ctx)
9913 
9914 
9915 
9916 
def Re(s, ctx=None)
Definition: z3py.py:9905
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 2897 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().

2897 def Real(name, ctx=None):
2898  """Return a real constant named `name`. If `ctx=None`, then the global context is used.
2899 
2900  >>> x = Real('x')
2901  >>> is_real(x)
2902  True
2903  >>> is_real(x + 1)
2904  True
2905  """
2906  ctx = _get_ctx(ctx)
2907  return ArithRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), RealSort(ctx).ast), ctx)
2908 
def RealSort(ctx=None)
Definition: z3py.py:2762
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:101
def Real(name, ctx=None)
Definition: z3py.py:2897

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

Referenced by is_div().

2909 def Reals(names, ctx=None):
2910  """Return a tuple of real constants.
2911 
2912  >>> x, y, z = Reals('x y z')
2913  >>> Sum(x, y, z)
2914  x + y + z
2915  >>> Sum(x, y, z).sort()
2916  Real
2917  """
2918  ctx = _get_ctx(ctx)
2919  if isinstance(names, str):
2920  names = names.split(" ")
2921  return [Real(name, ctx) for name in names]
2922 
def Real(name, ctx=None)
Definition: z3py.py:2897
def Reals(names, ctx=None)
Definition: z3py.py:2909

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

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

2762 def RealSort(ctx=None):
2763  """Return the real sort in the given context. If `ctx=None`, then the global context is used.
2764 
2765  >>> RealSort()
2766  Real
2767  >>> x = Const('x', RealSort())
2768  >>> is_real(x)
2769  True
2770  >>> is_int(x)
2771  False
2772  >>> x.sort() == RealSort()
2773  True
2774  """
2775  ctx = _get_ctx(ctx)
2776  return ArithSortRef(Z3_mk_real_sort(ctx.ref()), ctx)
2777 
def RealSort(ctx=None)
Definition: z3py.py:2762
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 2804 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().

2804 def RealVal(val, ctx=None):
2805  """Return a Z3 real value.
2806 
2807  `val` may be a Python int, long, float or string representing a number in decimal or rational notation.
2808  If `ctx=None`, then the global context is used.
2809 
2810  >>> RealVal(1)
2811  1
2812  >>> RealVal(1).sort()
2813  Real
2814  >>> RealVal("3/5")
2815  3/5
2816  >>> RealVal("1.5")
2817  3/2
2818  """
2819  ctx = _get_ctx(ctx)
2820  return RatNumRef(Z3_mk_numeral(ctx.ref(), str(val), RealSort(ctx).ast), ctx)
2821 
def RealSort(ctx=None)
Definition: z3py.py:2762
def RealVal(val, ctx=None)
Definition: z3py.py:2804
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 1256 of file z3py.py.

Referenced by RealVarVector().

1256 def RealVar(idx, ctx=None):
1257  """
1258  Create a real free variable. Free variables are used to create quantified formulas.
1259  They are also used to create polynomials.
1260 
1261  >>> RealVar(0)
1262  Var(0)
1263  """
1264  return Var(idx, RealSort(ctx))
1265 
def RealSort(ctx=None)
Definition: z3py.py:2762
def Var(idx, s)
Definition: z3py.py:1244
def RealVar(idx, ctx=None)
Definition: z3py.py:1256

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

1266 def RealVarVector(n, ctx=None):
1267  """
1268  Create a list of Real free variables.
1269  The variables have ids: 0, 1, ..., n-1
1270 
1271  >>> x0, x1, x2, x3 = RealVarVector(4)
1272  >>> x2
1273  Var(2)
1274  """
1275  return [ RealVar(i, ctx) for i in range(n) ]
1276 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:2813
def RealVarVector(n, ctx=None)
Definition: z3py.py:1266
def RealVar(idx, ctx=None)
Definition: z3py.py:1256

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

2923 def RealVector(prefix, sz, ctx=None):
2924  """Return a list of real constants of size `sz`.
2925 
2926  >>> X = RealVector('x', 3)
2927  >>> X
2928  [x__0, x__1, x__2]
2929  >>> Sum(X)
2930  x__0 + x__1 + x__2
2931  >>> Sum(X).sort()
2932  Real
2933  """
2934  return [ Real('%s__%s' % (prefix, i)) for i in range(sz) ]
2935 
def RealVector(prefix, sz, ctx=None)
Definition: z3py.py:2923
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:2813
def Real(name, ctx=None)
Definition: z3py.py:2897

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

7390 def Repeat(t, max=4294967295, ctx=None):
7391  """Return a tactic that keeps applying `t` until the goal is not modified anymore or the maximum number of iterations `max` is reached.
7392 
7393  >>> x, y = Ints('x y')
7394  >>> c = And(Or(x == 0, x == 1), Or(y == 0, y == 1), x > y)
7395  >>> t = Repeat(OrElse(Tactic('split-clause'), Tactic('skip')))
7396  >>> r = t(c)
7397  >>> for subgoal in r: print(subgoal)
7398  [x == 0, y == 0, x > y]
7399  [x == 0, y == 1, x > y]
7400  [x == 1, y == 0, x > y]
7401  [x == 1, y == 1, x > y]
7402  >>> t = Then(t, Tactic('propagate-values'))
7403  >>> t(c)
7404  [[x == 1, y == 0]]
7405  """
7406  t = _to_tactic(t, ctx)
7407  return Tactic(Z3_tactic_repeat(t.ctx.ref(), t.tactic, max), t.ctx)
7408 
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:7390

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

3961 def RepeatBitVec(n, a):
3962  """Return an expression representing `n` copies of `a`.
3963 
3964  >>> x = BitVec('x', 8)
3965  >>> n = RepeatBitVec(4, x)
3966  >>> n
3967  RepeatBitVec(4, x)
3968  >>> n.size()
3969  32
3970  >>> v0 = BitVecVal(10, 4)
3971  >>> print("%.x" % v0.as_long())
3972  a
3973  >>> v = simplify(RepeatBitVec(4, v0))
3974  >>> v.size()
3975  16
3976  >>> print("%.x" % v.as_long())
3977  aaaa
3978  """
3979  if __debug__:
3980  _z3_assert(_is_int(n), "First argument must be an integer")
3981  _z3_assert(is_bv(a), "Second argument must be a Z3 Bitvector expression")
3982  return BitVecRef(Z3_mk_repeat(a.ctx_ref(), n, a.as_ast()), a.ctx)
3983 
Z3_ast Z3_API Z3_mk_repeat(Z3_context c, unsigned i, Z3_ast t1)
Repeat the given bit-vector up length i.
def is_bv(a)
Definition: z3py.py:3522
def RepeatBitVec(n, a)
Definition: z3py.py:3961

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

9839 def Replace(s, src, dst):
9840  """Replace the first occurrence of 'src' by 'dst' in 's'
9841  >>> r = Replace("aaa", "a", "b")
9842  >>> simplify(r)
9843  "baa"
9844  """
9845  ctx = _get_ctx2(dst, s)
9846  if ctx is None and is_expr(src):
9847  ctx = src.ctx
9848  src = _coerce_seq(src, ctx)
9849  dst = _coerce_seq(dst, ctx)
9850  s = _coerce_seq(s, ctx)
9851  return SeqRef(Z3_mk_seq_replace(src.ctx_ref(), s.as_ast(), src.as_ast(), dst.as_ast()), s.ctx)
9852 
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:9839
def is_expr(a)
Definition: z3py.py:1033

◆ reset_params()

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

Definition at line 241 of file z3py.py.

241 def reset_params():
242  """Reset all global (or module) parameters.
243  """
245 
def reset_params()
Definition: z3py.py:241
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 9923 of file z3py.py.

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

9923 def ReSort(s):
9924  if is_ast(s):
9925  return ReSortRef(Z3_mk_re_sort(s.ctx.ref(), s.ast), s.ctx)
9926  if s is None or isinstance(s, Context):
9927  ctx = _get_ctx(s)
9928  return ReSortRef(Z3_mk_re_sort(ctx.ref(), Z3_mk_string_sort(ctx.ref())), s.ctx)
9929  raise Z3Exception("Regular expression sort constructor expects either a string or a context or no argument")
9930 
9931 
def ReSort(s)
Definition: z3py.py:9923
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:378
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 8662 of file z3py.py.

8662 def RNA (ctx=None):
8663  ctx = _get_ctx(ctx)
8664  return FPRMRef(Z3_mk_fpa_round_nearest_ties_to_away(ctx.ref()), ctx)
8665 
def RNA(ctx=None)
Definition: z3py.py:8662
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 8654 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().

8654 def RNE (ctx=None):
8655  ctx = _get_ctx(ctx)
8656  return FPRMRef(Z3_mk_fpa_round_nearest_ties_to_even(ctx.ref()), ctx)
8657 
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:8654

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

3875 def RotateLeft(a, b):
3876  """Return an expression representing `a` rotated to the left `b` times.
3877 
3878  >>> a, b = BitVecs('a b', 16)
3879  >>> RotateLeft(a, b)
3880  RotateLeft(a, b)
3881  >>> simplify(RotateLeft(a, 0))
3882  a
3883  >>> simplify(RotateLeft(a, 16))
3884  a
3885  """
3886  _check_bv_args(a, b)
3887  a, b = _coerce_exprs(a, b)
3888  return BitVecRef(Z3_mk_ext_rotate_left(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3889 
def RotateLeft(a, b)
Definition: z3py.py:3875
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 3890 of file z3py.py.

3890 def RotateRight(a, b):
3891  """Return an expression representing `a` rotated to the right `b` times.
3892 
3893  >>> a, b = BitVecs('a b', 16)
3894  >>> RotateRight(a, b)
3895  RotateRight(a, b)
3896  >>> simplify(RotateRight(a, 0))
3897  a
3898  >>> simplify(RotateRight(a, 16))
3899  a
3900  """
3901  _check_bv_args(a, b)
3902  a, b = _coerce_exprs(a, b)
3903  return BitVecRef(Z3_mk_ext_rotate_right(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3904 
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:3890

◆ RoundNearestTiesToAway()

def z3py.RoundNearestTiesToAway (   ctx = None)

Definition at line 8658 of file z3py.py.

8658 def RoundNearestTiesToAway(ctx=None):
8659  ctx = _get_ctx(ctx)
8660  return FPRMRef(Z3_mk_fpa_round_nearest_ties_to_away(ctx.ref()), ctx)
8661 
def RoundNearestTiesToAway(ctx=None)
Definition: z3py.py:8658
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 8650 of file z3py.py.

8650 def RoundNearestTiesToEven(ctx=None):
8651  ctx = _get_ctx(ctx)
8652  return FPRMRef(Z3_mk_fpa_round_nearest_ties_to_even(ctx.ref()), ctx)
8653 
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:8650

◆ RoundTowardNegative()

def z3py.RoundTowardNegative (   ctx = None)

Definition at line 8674 of file z3py.py.

8674 def RoundTowardNegative(ctx=None):
8675  ctx = _get_ctx(ctx)
8676  return FPRMRef(Z3_mk_fpa_round_toward_negative(ctx.ref()), ctx)
8677 
def RoundTowardNegative(ctx=None)
Definition: z3py.py:8674
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 8666 of file z3py.py.

8666 def RoundTowardPositive(ctx=None):
8667  ctx = _get_ctx(ctx)
8668  return FPRMRef(Z3_mk_fpa_round_toward_positive(ctx.ref()), ctx)
8669 
def RoundTowardPositive(ctx=None)
Definition: z3py.py:8666
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 8682 of file z3py.py.

8682 def RoundTowardZero(ctx=None):
8683  ctx = _get_ctx(ctx)
8684  return FPRMRef(Z3_mk_fpa_round_toward_zero(ctx.ref()), ctx)
8685 
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:8682

◆ RTN()

def z3py.RTN (   ctx = None)

Definition at line 8678 of file z3py.py.

8678 def RTN(ctx=None):
8679  ctx = _get_ctx(ctx)
8680  return FPRMRef(Z3_mk_fpa_round_toward_negative(ctx.ref()), ctx)
8681 
def RTN(ctx=None)
Definition: z3py.py:8678
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 8670 of file z3py.py.

8670 def RTP(ctx=None):
8671  ctx = _get_ctx(ctx)
8672  return FPRMRef(Z3_mk_fpa_round_toward_positive(ctx.ref()), ctx)
8673 
def RTP(ctx=None)
Definition: z3py.py:8670
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 8686 of file z3py.py.

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

8686 def RTZ(ctx=None):
8687  ctx = _get_ctx(ctx)
8688  return FPRMRef(Z3_mk_fpa_round_toward_zero(ctx.ref()), ctx)
8689 
def RTZ(ctx=None)
Definition: z3py.py:8686
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 4281 of file z3py.py.

4281 def Select(a, i):
4282  """Return a Z3 select array expression.
4283 
4284  >>> a = Array('a', IntSort(), IntSort())
4285  >>> i = Int('i')
4286  >>> Select(a, i)
4287  a[i]
4288  >>> eq(Select(a, i), a[i])
4289  True
4290  """
4291  if __debug__:
4292  _z3_assert(is_array(a), "First argument must be a Z3 array expression")
4293  return a[i]
4294 
4295 
def is_array(a)
Definition: z3py.py:4122
def Select(a, i)
Definition: z3py.py:4281

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

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

9652 def SeqSort(s):
9653  """Create a sequence sort over elements provided in the argument
9654  >>> s = SeqSort(IntSort())
9655  >>> s == Unit(IntVal(1)).sort()
9656  True
9657  """
9658  return SeqSortRef(Z3_mk_seq_sort(s.ctx_ref(), s.ast), s.ctx)
9659 
def SeqSort(s)
Definition: z3py.py:9652
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.

◆ sequence_interpolant()

def z3py.sequence_interpolant (   v,
  p = None,
  ctx = None 
)
Compute interpolant for a sequence of formulas.

If len(v) == N, and if the conjunction of the formulas in v is
unsatisfiable, the interpolant is a sequence of formulas w
such that len(w) = N-1 and v[0] implies w[0] and for i in 0..N-1:

1) w[i] & v[i+1] implies w[i+1] (or false if i+1 = N)
2) All uninterpreted symbols in w[i] occur in both v[0]..v[i]
and v[i+1]..v[n]

Requires len(v) >= 1.

If a & b is satisfiable, raises an object of class ModelRef
that represents a model of a & b.

If neither a proof of unsatisfiability nor a model is obtained
(for example, because of a timeout, or because models are disabled)
then None is returned.

If parameters p are supplied, these are used in creating the
solver that determines satisfiability.

x = Int('x')
y = Int('y')
print(sequence_interpolant([x < 0, y == x , y > 2]))
[Not(x >= 0), Not(y >= 0)]

Definition at line 8249 of file z3py.py.

8249 def sequence_interpolant(v,p=None,ctx=None):
8250  """Compute interpolant for a sequence of formulas.
8251 
8252  If len(v) == N, and if the conjunction of the formulas in v is
8253  unsatisfiable, the interpolant is a sequence of formulas w
8254  such that len(w) = N-1 and v[0] implies w[0] and for i in 0..N-1:
8255 
8256  1) w[i] & v[i+1] implies w[i+1] (or false if i+1 = N)
8257  2) All uninterpreted symbols in w[i] occur in both v[0]..v[i]
8258  and v[i+1]..v[n]
8259 
8260  Requires len(v) >= 1.
8261 
8262  If a & b is satisfiable, raises an object of class ModelRef
8263  that represents a model of a & b.
8264 
8265  If neither a proof of unsatisfiability nor a model is obtained
8266  (for example, because of a timeout, or because models are disabled)
8267  then None is returned.
8268 
8269  If parameters p are supplied, these are used in creating the
8270  solver that determines satisfiability.
8271 
8272  x = Int('x')
8273  y = Int('y')
8274  print(sequence_interpolant([x < 0, y == x , y > 2]))
8275  [Not(x >= 0), Not(y >= 0)]
8276  """
8277  f = v[0]
8278  for i in range(1,len(v)):
8279  f = And(Interpolant(f),v[i])
8280  return tree_interpolant(f,p,ctx)
8281 
8282 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:2813
def And(args)
Definition: z3py.py:1578
def Interpolant(a, ctx=None)
Definition: z3py.py:8142
def sequence_interpolant(v, p=None, ctx=None)
Definition: z3py.py:8249
def tree_interpolant(pat, p=None, ctx=None)
Definition: z3py.py:8156

◆ set_default_fp_sort()

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

Definition at line 8325 of file z3py.py.

8325 def set_default_fp_sort(ebits, sbits, ctx=None):
8326  global _dflt_fpsort_ebits
8327  global _dflt_fpsort_sbits
8328  _dflt_fpsort_ebits = ebits
8329  _dflt_fpsort_sbits = sbits
8330 
def set_default_fp_sort(ebits, sbits, ctx=None)
Definition: z3py.py:8325

◆ set_default_rounding_mode()

def z3py.set_default_rounding_mode (   rm,
  ctx = None 
)

Definition at line 8309 of file z3py.py.

8309 def set_default_rounding_mode(rm, ctx=None):
8310  global _dflt_rounding_mode
8311  if is_fprm_value(rm):
8312  _dflt_rounding_mode = rm.decl().kind()
8313  else:
8314  _z3_assert(_dflt_rounding_mode == Z3_OP_FPA_RM_TOWARD_ZERO or
8315  _dflt_rounding_mode == Z3_OP_FPA_RM_TOWARD_NEGATIVE or
8316  _dflt_rounding_mode == Z3_OP_FPA_RM_TOWARD_POSITIVE or
8317  _dflt_rounding_mode == Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN or
8318  _dflt_rounding_mode == Z3_OP_FPA_RM_NEAREST_TIES_TO_AWAY,
8319  "illegal rounding mode")
8320  _dflt_rounding_mode = rm
8321 
def set_default_rounding_mode(rm, ctx=None)
Definition: z3py.py:8309
def is_fprm_value(a)
Definition: z3py.py:8702

◆ set_option()

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

Definition at line 246 of file z3py.py.

246 def set_option(*args, **kws):
247  """Alias for 'set_param' for backward compatibility.
248  """
249  return set_param(*args, **kws)
250 
def set_option(args, kws)
Definition: z3py.py:246
def set_param(args, kws)
Definition: z3py.py:218

◆ set_param()

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

>>> set_param(precision=10)

Definition at line 218 of file z3py.py.

Referenced by set_option().

218 def set_param(*args, **kws):
219  """Set Z3 global (or module) parameters.
220 
221  >>> set_param(precision=10)
222  """
223  if __debug__:
224  _z3_assert(len(args) % 2 == 0, "Argument list must have an even number of elements.")
225  new_kws = {}
226  for k in kws:
227  v = kws[k]
228  if not set_pp_option(k, v):
229  new_kws[k] = v
230  for key in new_kws:
231  value = new_kws[key]
232  Z3_global_param_set(str(key).upper(), _to_param_value(value))
233  prev = None
234  for a in args:
235  if prev is None:
236  prev = a
237  else:
238  Z3_global_param_set(str(prev), _to_param_value(a))
239  prev = None
240 
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:218

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

3905 def SignExt(n, a):
3906  """Return a bit-vector expression with `n` extra sign-bits.
3907 
3908  >>> x = BitVec('x', 16)
3909  >>> n = SignExt(8, x)
3910  >>> n.size()
3911  24
3912  >>> n
3913  SignExt(8, x)
3914  >>> n.sort()
3915  BitVec(24)
3916  >>> v0 = BitVecVal(2, 2)
3917  >>> v0
3918  2
3919  >>> v0.size()
3920  2
3921  >>> v = simplify(SignExt(6, v0))
3922  >>> v
3923  254
3924  >>> v.size()
3925  8
3926  >>> print("%.x" % v.as_long())
3927  fe
3928  """
3929  if __debug__:
3930  _z3_assert(_is_int(n), "First argument must be an integer")
3931  _z3_assert(is_bv(a), "Second argument must be a Z3 Bitvector expression")
3932  return BitVecRef(Z3_mk_sign_ext(a.ctx_ref(), n, a.as_ast()), a.ctx)
3933 
def SignExt(n, a)
Definition: z3py.py:3905
Z3_ast Z3_API Z3_mk_sign_ext(Z3_context c, unsigned i, Z3_ast t1)
Sign-extend of the given bit-vector to the (signed) equivalent bit-vector of size m+i...
def is_bv(a)
Definition: z3py.py:3522

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

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

6463 def SimpleSolver(ctx=None):
6464  """Return a simple general purpose solver with limited amount of preprocessing.
6465 
6466  >>> s = SimpleSolver()
6467  >>> x = Int('x')
6468  >>> s.add(x > 0)
6469  >>> s.check()
6470  sat
6471  """
6472  ctx = _get_ctx(ctx)
6473  return Solver(Z3_mk_simple_solver(ctx.ref()), ctx)
6474 
Z3_solver Z3_API Z3_mk_simple_solver(Z3_context c)
Create a new incremental solver.
def SimpleSolver(ctx=None)
Definition: z3py.py:6463

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

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

7712 def simplify(a, *arguments, **keywords):
7713  """Simplify the expression `a` using the given options.
7714 
7715  This function has many options. Use `help_simplify` to obtain the complete list.
7716 
7717  >>> x = Int('x')
7718  >>> y = Int('y')
7719  >>> simplify(x + 1 + y + x + 1)
7720  2 + 2*x + y
7721  >>> simplify((x + 1)*(y + 1), som=True)
7722  1 + x + y + x*y
7723  >>> simplify(Distinct(x, y, 1), blast_distinct=True)
7724  And(Not(x == y), Not(x == 1), Not(y == 1))
7725  >>> simplify(And(x == 0, y == 1), elim_and=True)
7726  Not(Or(Not(x == 0), Not(y == 1)))
7727  """
7728  if __debug__:
7729  _z3_assert(is_expr(a), "Z3 expression expected")
7730  if len(arguments) > 0 or len(keywords) > 0:
7731  p = args2params(arguments, keywords, a.ctx)
7732  return _to_expr_ref(Z3_simplify_ex(a.ctx_ref(), a.as_ast(), p.params), a.ctx)
7733  else:
7734  return _to_expr_ref(Z3_simplify(a.ctx_ref(), a.as_ast()), a.ctx)
7735 
def simplify(a, arguments, keywords)
Utils.
Definition: z3py.py:7712
def args2params(arguments, keywords, ctx=None)
Definition: z3py.py:4744
Z3_ast Z3_API Z3_simplify_ex(Z3_context c, Z3_ast a, Z3_params p)
Interface to simplifier.
Z3_ast Z3_API Z3_simplify(Z3_context c, Z3_ast a)
Interface to simplifier.
def is_expr(a)
Definition: z3py.py:1033

◆ simplify_param_descrs()

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

Definition at line 7740 of file z3py.py.

7740 def simplify_param_descrs():
7741  """Return the set of parameter descriptions for Z3 `simplify` procedure."""
7742  return ParamDescrsRef(Z3_simplify_get_param_descrs(main_ctx().ref()), main_ctx())
7743 
def main_ctx()
Definition: z3py.py:192
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:7740

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

Referenced by BV2Int(), and IsInt().

7919 def solve(*args, **keywords):
7920  """Solve the constraints `*args`.
7921 
7922  This is a simple function for creating demonstrations. It creates a solver,
7923  configure it using the options in `keywords`, adds the constraints
7924  in `args`, and invokes check.
7925 
7926  >>> a = Int('a')
7927  >>> solve(a > 0, a < 2)
7928  [a = 1]
7929  """
7930  s = Solver()
7931  s.set(**keywords)
7932  s.add(*args)
7933  if keywords.get('show', False):
7934  print(s)
7935  r = s.check()
7936  if r == unsat:
7937  print("no solution")
7938  elif r == unknown:
7939  print("failed to solve")
7940  try:
7941  print(s.model())
7942  except Z3Exception:
7943  return
7944  else:
7945  print(s.model())
7946 
def solve(args, keywords)
Definition: z3py.py:7919

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

7947 def solve_using(s, *args, **keywords):
7948  """Solve the constraints `*args` using solver `s`.
7949 
7950  This is a simple function for creating demonstrations. It is similar to `solve`,
7951  but it uses the given solver `s`.
7952  It configures solver `s` using the options in `keywords`, adds the constraints
7953  in `args`, and invokes check.
7954  """
7955  if __debug__:
7956  _z3_assert(isinstance(s, Solver), "Solver object expected")
7957  s.set(**keywords)
7958  s.add(*args)
7959  if keywords.get('show', False):
7960  print("Problem:")
7961  print(s)
7962  r = s.check()
7963  if r == unsat:
7964  print("no solution")
7965  elif r == unknown:
7966  print("failed to solve")
7967  try:
7968  print(s.model())
7969  except Z3Exception:
7970  return
7971  else:
7972  if keywords.get('show', False):
7973  print("Solution:")
7974  print(s.model())
7975 
def solve_using(s, args, keywords)
Definition: z3py.py:7947

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

6443 def SolverFor(logic, ctx=None):
6444  """Create a solver customized for the given logic.
6445 
6446  The parameter `logic` is a string. It should be contains
6447  the name of a SMT-LIB logic.
6448  See http://www.smtlib.org/ for the name of all available logics.
6449 
6450  >>> s = SolverFor("QF_LIA")
6451  >>> x = Int('x')
6452  >>> s.add(x > 0)
6453  >>> s.add(x < 2)
6454  >>> s.check()
6455  sat
6456  >>> s.model()
6457  [x = 1]
6458  """
6459  ctx = _get_ctx(ctx)
6460  logic = to_symbol(logic)
6461  return Solver(Z3_mk_solver_for_logic(ctx.ref(), logic), ctx)
6462 
def to_symbol(s, ctx=None)
Definition: z3py.py:101
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:6443

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

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

2999 def Sqrt(a, ctx=None):
3000  """ Return a Z3 expression which represents the square root of a.
3001 
3002  >>> x = Real('x')
3003  >>> Sqrt(x)
3004  x**(1/2)
3005  """
3006  if not is_expr(a):
3007  ctx = _get_ctx(ctx)
3008  a = RealVal(a, ctx)
3009  return a ** "1/2"
3010 
def RealVal(val, ctx=None)
Definition: z3py.py:2804
def is_expr(a)
Definition: z3py.py:1033
def Sqrt(a, ctx=None)
Definition: z3py.py:2999

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

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

3824 def SRem(a, b):
3825  """Create the Z3 expression signed remainder.
3826 
3827  Use the operator % for signed modulus, and URem() for unsigned remainder.
3828 
3829  >>> x = BitVec('x', 32)
3830  >>> y = BitVec('y', 32)
3831  >>> SRem(x, y)
3832  SRem(x, y)
3833  >>> SRem(x, y).sort()
3834  BitVec(32)
3835  >>> (x % y).sexpr()
3836  '(bvsmod x y)'
3837  >>> SRem(x, y).sexpr()
3838  '(bvsrem x y)'
3839  """
3840  _check_bv_args(a, b)
3841  a, b = _coerce_exprs(a, b)
3842  return BitVecRef(Z3_mk_bvsrem(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3843 
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:3824

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

10003 def Star(re):
10004  """Create the regular expression accepting zero or more repetitions of argument.
10005  >>> re = Star(Re("a"))
10006  >>> print(simplify(InRe("aa", re)))
10007  True
10008  >>> print(simplify(InRe("ab", re)))
10009  False
10010  >>> print(simplify(InRe("", re)))
10011  True
10012  """
10013  return ReRef(Z3_mk_re_star(re.ctx_ref(), re.as_ast()), re.ctx)
10014 
def Star(re)
Definition: z3py.py:10003
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 4265 of file z3py.py.

Referenced by is_array(), and is_store().

4265 def Store(a, i, v):
4266  """Return a Z3 store array expression.
4267 
4268  >>> a = Array('a', IntSort(), IntSort())
4269  >>> i, v = Ints('i v')
4270  >>> s = Store(a, i, v)
4271  >>> s.sort()
4272  Array(Int, Int)
4273  >>> prove(s[i] == v)
4274  proved
4275  >>> j = Int('j')
4276  >>> prove(Implies(i != j, s[j] == a[j]))
4277  proved
4278  """
4279  return Update(a, i, v)
4280 
def Update(a, i, v)
Definition: z3py.py:4233
def Store(a, i, v)
Definition: z3py.py:4265

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

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

9738 def String(name, ctx=None):
9739  """Return a string constant named `name`. If `ctx=None`, then the global context is used.
9740 
9741  >>> x = String('x')
9742  """
9743  ctx = _get_ctx(ctx)
9744  return SeqRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), StringSort(ctx).ast), ctx)
9745 
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:101
def StringSort(ctx=None)
Definition: z3py.py:9642
def String(name, ctx=None)
Definition: z3py.py:9738

◆ Strings()

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

Definition at line 9746 of file z3py.py.

Referenced by Contains().

9746 def Strings(names, ctx=None):
9747  """Return a tuple of String constants. """
9748  ctx = _get_ctx(ctx)
9749  if isinstance(names, str):
9750  names = names.split(" ")
9751  return [String(name, ctx) for name in names]
9752 
def Strings(names, ctx=None)
Definition: z3py.py:9746
def String(name, ctx=None)
Definition: z3py.py:9738

◆ StringSort()

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

Definition at line 9642 of file z3py.py.

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

9642 def StringSort(ctx=None):
9643  """Create a string sort
9644  >>> s = StringSort()
9645  >>> print(s)
9646  String
9647  """
9648  ctx = _get_ctx(ctx)
9649  return SeqSortRef(Z3_mk_string_sort(ctx.ref()), ctx)
9650 
9651 
def StringSort(ctx=None)
Definition: z3py.py:9642
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 9733 of file z3py.py.

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

9733 def StringVal(s, ctx=None):
9734  """create a string expression"""
9735  ctx = _get_ctx(ctx)
9736  return SeqRef(Z3_mk_string(ctx.ref(), s), ctx)
9737 
Z3_ast Z3_API Z3_mk_string(Z3_context c, Z3_string s)
Create a string constant out of the string that is passed in.
def StringVal(s, ctx=None)
Definition: z3py.py:9733

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

9882 def StrToInt(s):
9883  """Convert string expression to integer
9884  >>> a = StrToInt("1")
9885  >>> simplify(1 == a)
9886  True
9887  >>> b = StrToInt("2")
9888  >>> simplify(1 == b)
9889  False
9890  >>> c = StrToInt(IntToStr(2))
9891  >>> simplify(1 == c)
9892  False
9893  """
9894  s = _coerce_seq(s)
9895  return ArithRef(Z3_mk_str_to_int(s.ctx_ref(), s.as_ast()), s.ctx)
9896 
9897 
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:9882

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

7744 def substitute(t, *m):
7745  """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.
7746 
7747  >>> x = Int('x')
7748  >>> y = Int('y')
7749  >>> substitute(x + 1, (x, y + 1))
7750  y + 1 + 1
7751  >>> f = Function('f', IntSort(), IntSort())
7752  >>> substitute(f(x) + f(y), (f(x), IntVal(1)), (f(y), IntVal(1)))
7753  1 + 1
7754  """
7755  if isinstance(m, tuple):
7756  m1 = _get_args(m)
7757  if isinstance(m1, list):
7758  m = m1
7759  if __debug__:
7760  _z3_assert(is_expr(t), "Z3 expression expected")
7761  _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.")
7762  num = len(m)
7763  _from = (Ast * num)()
7764  _to = (Ast * num)()
7765  for i in range(num):
7766  _from[i] = m[i][0].as_ast()
7767  _to[i] = m[i][1].as_ast()
7768  return _to_expr_ref(Z3_substitute(t.ctx.ref(), t.as_ast(), num, _from, _to), t.ctx)
7769 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:2813
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:7744
def eq(a, b)
Definition: z3py.py:398
def is_expr(a)
Definition: z3py.py:1033

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

7770 def substitute_vars(t, *m):
7771  """Substitute the free variables in t with the expression in m.
7772 
7773  >>> v0 = Var(0, IntSort())
7774  >>> v1 = Var(1, IntSort())
7775  >>> x = Int('x')
7776  >>> f = Function('f', IntSort(), IntSort(), IntSort())
7777  >>> # replace v0 with x+1 and v1 with x
7778  >>> substitute_vars(f(v0, v1), x + 1, x)
7779  f(x + 1, x)
7780  """
7781  if __debug__:
7782  _z3_assert(is_expr(t), "Z3 expression expected")
7783  _z3_assert(all([is_expr(n) for n in m]), "Z3 invalid substitution, list of expressions expected.")
7784  num = len(m)
7785  _to = (Ast * num)()
7786  for i in range(num):
7787  _to[i] = m[i].as_ast()
7788  return _to_expr_ref(Z3_substitute_vars(t.ctx.ref(), t.as_ast(), num, _to), t.ctx)
7789 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:2813
def substitute_vars(t, m)
Definition: z3py.py:7770
Z3_ast Z3_API Z3_substitute_vars(Z3_context c, Z3_ast a, unsigned num_exprs, Z3_ast const to[])
Substitute the free variables in a with the expressions in to. For every i smaller than num_exprs...
def is_expr(a)
Definition: z3py.py:1033

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

9806 def SuffixOf(a, b):
9807  """Check if 'a' is a suffix of 'b'
9808  >>> s1 = SuffixOf("ab", "abc")
9809  >>> simplify(s1)
9810  False
9811  >>> s2 = SuffixOf("bc", "abc")
9812  >>> simplify(s2)
9813  True
9814  """
9815  ctx = _get_ctx2(a, b)
9816  a = _coerce_seq(a, ctx)
9817  b = _coerce_seq(b, ctx)
9818  return BoolRef(Z3_mk_seq_suffix(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
9819 
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:9806

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

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

7790 def Sum(*args):
7791  """Create the sum of the Z3 expressions.
7792 
7793  >>> a, b, c = Ints('a b c')
7794  >>> Sum(a, b, c)
7795  a + b + c
7796  >>> Sum([a, b, c])
7797  a + b + c
7798  >>> A = IntVector('a', 5)
7799  >>> Sum(A)
7800  a__0 + a__1 + a__2 + a__3 + a__4
7801  """
7802  args = _get_args(args)
7803  if len(args) == 0:
7804  return 0
7805  ctx = _ctx_from_ast_arg_list(args)
7806  if ctx is None:
7807  return _reduce(lambda a, b: a + b, args, 0)
7808  args = _coerce_expr_list(args, ctx)
7809  if is_bv(args[0]):
7810  return _reduce(lambda a, b: a + b, args, 0)
7811  else:
7812  _args, sz = _to_ast_array(args)
7813  return ArithRef(Z3_mk_add(ctx.ref(), sz, _args), ctx)
7814 
7815 
def Sum(args)
Definition: z3py.py:7790
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:3522

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

Referenced by describe_tactics().

7427 def tactic_description(name, ctx=None):
7428  """Return a short description for the tactic named `name`.
7429 
7430  >>> d = tactic_description('simplify')
7431  """
7432  ctx = _get_ctx(ctx)
7433  return Z3_tactic_get_descr(ctx.ref(), name)
7434 
def tactic_description(name, ctx=None)
Definition: z3py.py:7427
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 7417 of file z3py.py.

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

7417 def tactics(ctx=None):
7418  """Return a list of all available tactics in Z3.
7419 
7420  >>> l = tactics()
7421  >>> l.count('simplify') == 1
7422  True
7423  """
7424  ctx = _get_ctx(ctx)
7425  return [ Z3_get_tactic_name(ctx.ref(), i) for i in range(Z3_get_num_tactics(ctx.ref())) ]
7426 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:2813
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:7417
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 7309 of file z3py.py.

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

7309 def Then(*ts, **ks):
7310  """Return a tactic that applies the tactics in `*ts` in sequence. Shorthand for AndThen(*ts, **ks).
7311 
7312  >>> x, y = Ints('x y')
7313  >>> t = Then(Tactic('simplify'), Tactic('solve-eqs'))
7314  >>> t(And(x == 0, y > x + 1))
7315  [[Not(y <= 1)]]
7316  >>> t(And(x == 0, y > x + 1)).as_expr()
7317  Not(y <= 1)
7318  """
7319  return AndThen(*ts, **ks)
7320 
def Then(ts, ks)
Definition: z3py.py:7309
def AndThen(ts, ks)
Definition: z3py.py:7290

◆ to_symbol()

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

Definition at line 101 of file z3py.py.

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

101 def to_symbol(s, ctx=None):
102  """Convert an integer or string into a Z3 symbol."""
103  if _is_int(s):
104  return Z3_mk_int_symbol(_get_ctx(ctx).ref(), s)
105  else:
106  return Z3_mk_string_symbol(_get_ctx(ctx).ref(), s)
107 
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:101
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 2966 of file z3py.py.

Referenced by is_to_int().

2966 def ToInt(a):
2967  """ Return the Z3 expression ToInt(a).
2968 
2969  >>> x = Real('x')
2970  >>> x.sort()
2971  Real
2972  >>> n = ToInt(x)
2973  >>> n
2974  ToInt(x)
2975  >>> n.sort()
2976  Int
2977  """
2978  if __debug__:
2979  _z3_assert(a.is_real(), "Z3 real expression expected.")
2980  ctx = a.ctx
2981  return ArithRef(Z3_mk_real2int(ctx.ref(), a.as_ast()), ctx)
2982 
Z3_ast Z3_API Z3_mk_real2int(Z3_context c, Z3_ast t1)
Coerce a real to an integer.
def ToInt(a)
Definition: z3py.py:2966

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

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

2949 def ToReal(a):
2950  """ Return the Z3 expression ToReal(a).
2951 
2952  >>> x = Int('x')
2953  >>> x.sort()
2954  Int
2955  >>> n = ToReal(x)
2956  >>> n
2957  ToReal(x)
2958  >>> n.sort()
2959  Real
2960  """
2961  if __debug__:
2962  _z3_assert(a.is_int(), "Z3 integer expression expected.")
2963  ctx = a.ctx
2964  return ArithRef(Z3_mk_int2real(ctx.ref(), a.as_ast()), ctx)
2965 
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:2949

◆ tree_interpolant()

def z3py.tree_interpolant (   pat,
  p = None,
  ctx = None 
)
Compute interpolant for a tree of formulas.

The input is an interpolation pattern over a set of formulas C.
The pattern pat is a formula combining the formulas in C using
logical conjunction and the "interp" operator (see Interp). This
interp operator is logically the identity operator. It marks the
sub-formulas of the pattern for which interpolants should be
computed. The interpolant is a map sigma from marked subformulas
to formulas, such that, for each marked subformula phi of pat
(where phi sigma is phi with sigma(psi) substituted for each
subformula psi of phi such that psi in dom(sigma)):

  1) phi sigma implies sigma(phi), and

  2) sigma(phi) is in the common uninterpreted vocabulary between
  the formulas of C occurring in phi and those not occurring in
  phi

  and moreover pat sigma implies false. In the simplest case
  an interpolant for the pattern "(and (interp A) B)" maps A
  to an interpolant for A /\ B.

  The return value is a vector of formulas representing sigma. This
  vector contains sigma(phi) for each marked subformula of pat, in
  pre-order traversal. This means that subformulas of phi occur before phi
  in the vector. Also, subformulas that occur multiply in pat will
  occur multiply in the result vector.

If pat is satisfiable, raises an object of class ModelRef
that represents a model of pat.

If neither a proof of unsatisfiability nor a model is obtained
(for example, because of a timeout, or because models are disabled)
then None is returned.

If parameters p are supplied, these are used in creating the
solver that determines satisfiability.

>>> x = Int('x')
>>> y = Int('y')
>>> print(tree_interpolant(And(Interpolant(x < 0), Interpolant(y > 2), x == y)))
[Not(x >= 0), Not(y <= 2)]

# >>> g = And(Interpolant(x<0),x<2)
# >>> try:
# ...     print tree_interpolant(g).sexpr()
# ... except ModelRef as m:
# ...     print m.sexpr()
(define-fun x () Int
  (- 1))

Definition at line 8156 of file z3py.py.

8156 def tree_interpolant(pat,p=None,ctx=None):
8157  """Compute interpolant for a tree of formulas.
8158 
8159  The input is an interpolation pattern over a set of formulas C.
8160  The pattern pat is a formula combining the formulas in C using
8161  logical conjunction and the "interp" operator (see Interp). This
8162  interp operator is logically the identity operator. It marks the
8163  sub-formulas of the pattern for which interpolants should be
8164  computed. The interpolant is a map sigma from marked subformulas
8165  to formulas, such that, for each marked subformula phi of pat
8166  (where phi sigma is phi with sigma(psi) substituted for each
8167  subformula psi of phi such that psi in dom(sigma)):
8168 
8169  1) phi sigma implies sigma(phi), and
8170 
8171  2) sigma(phi) is in the common uninterpreted vocabulary between
8172  the formulas of C occurring in phi and those not occurring in
8173  phi
8174 
8175  and moreover pat sigma implies false. In the simplest case
8176  an interpolant for the pattern "(and (interp A) B)" maps A
8177  to an interpolant for A /\ B.
8178 
8179  The return value is a vector of formulas representing sigma. This
8180  vector contains sigma(phi) for each marked subformula of pat, in
8181  pre-order traversal. This means that subformulas of phi occur before phi
8182  in the vector. Also, subformulas that occur multiply in pat will
8183  occur multiply in the result vector.
8184 
8185  If pat is satisfiable, raises an object of class ModelRef
8186  that represents a model of pat.
8187 
8188  If neither a proof of unsatisfiability nor a model is obtained
8189  (for example, because of a timeout, or because models are disabled)
8190  then None is returned.
8191 
8192  If parameters p are supplied, these are used in creating the
8193  solver that determines satisfiability.
8194 
8195  >>> x = Int('x')
8196  >>> y = Int('y')
8197  >>> print(tree_interpolant(And(Interpolant(x < 0), Interpolant(y > 2), x == y)))
8198  [Not(x >= 0), Not(y <= 2)]
8199 
8200  # >>> g = And(Interpolant(x<0),x<2)
8201  # >>> try:
8202  # ... print tree_interpolant(g).sexpr()
8203  # ... except ModelRef as m:
8204  # ... print m.sexpr()
8205  (define-fun x () Int
8206  (- 1))
8207  """
8208  f = pat
8209  ctx = _get_ctx(_ctx_from_ast_arg_list([f], ctx))
8210  ptr = (AstVectorObj * 1)()
8211  mptr = (Model * 1)()
8212  if p is None:
8213  p = ParamsRef(ctx)
8214  res = Z3_compute_interpolant(ctx.ref(),f.as_ast(),p.params,ptr,mptr)
8215  if res == Z3_L_FALSE:
8216  return AstVector(ptr[0],ctx)
8217  if mptr[0]:
8218  raise ModelRef(mptr[0], ctx)
8219  return None
8220 
Z3_lbool Z3_API Z3_compute_interpolant(Z3_context c, Z3_ast pat, Z3_params p, Z3_ast_vector *interp, Z3_model *model)
def tree_interpolant(pat, p=None, ctx=None)
Definition: z3py.py:8156

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

7409 def TryFor(t, ms, ctx=None):
7410  """Return a tactic that applies `t` to a given goal for `ms` milliseconds.
7411 
7412  If `t` does not terminate in `ms` milliseconds, then it fails.
7413  """
7414  t = _to_tactic(t, ctx)
7415  return Tactic(Z3_tactic_try_for(t.ctx.ref(), t.tactic, ms), t.ctx)
7416 
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:7409

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

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

3784 def UDiv(a, b):
3785  """Create the Z3 expression (unsigned) division `self / other`.
3786 
3787  Use the operator / for signed division.
3788 
3789  >>> x = BitVec('x', 32)
3790  >>> y = BitVec('y', 32)
3791  >>> UDiv(x, y)
3792  UDiv(x, y)
3793  >>> UDiv(x, y).sort()
3794  BitVec(32)
3795  >>> (x / y).sexpr()
3796  '(bvsdiv x y)'
3797  >>> UDiv(x, y).sexpr()
3798  '(bvudiv x y)'
3799  """
3800  _check_bv_args(a, b)
3801  a, b = _coerce_exprs(a, b)
3802  return BitVecRef(Z3_mk_bvudiv(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3803 
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:3784

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

Referenced by BitVecRef.__ge__().

3750 def UGE(a, b):
3751  """Create the Z3 expression (unsigned) `other >= self`.
3752 
3753  Use the operator >= for signed greater than or equal to.
3754 
3755  >>> x, y = BitVecs('x y', 32)
3756  >>> UGE(x, y)
3757  UGE(x, y)
3758  >>> (x >= y).sexpr()
3759  '(bvsge x y)'
3760  >>> UGE(x, y).sexpr()
3761  '(bvuge x y)'
3762  """
3763  _check_bv_args(a, b)
3764  a, b = _coerce_exprs(a, b)
3765  return BoolRef(Z3_mk_bvuge(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3766 
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:3750

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

Referenced by BitVecRef.__gt__().

3767 def UGT(a, b):
3768  """Create the Z3 expression (unsigned) `other > self`.
3769 
3770  Use the operator > for signed greater than.
3771 
3772  >>> x, y = BitVecs('x y', 32)
3773  >>> UGT(x, y)
3774  UGT(x, y)
3775  >>> (x > y).sexpr()
3776  '(bvsgt x y)'
3777  >>> UGT(x, y).sexpr()
3778  '(bvugt x y)'
3779  """
3780  _check_bv_args(a, b)
3781  a, b = _coerce_exprs(a, b)
3782  return BoolRef(Z3_mk_bvugt(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3783 
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:3767

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

Referenced by BitVecRef.__le__().

3716 def ULE(a, b):
3717  """Create the Z3 expression (unsigned) `other <= self`.
3718 
3719  Use the operator <= for signed less than or equal to.
3720 
3721  >>> x, y = BitVecs('x y', 32)
3722  >>> ULE(x, y)
3723  ULE(x, y)
3724  >>> (x <= y).sexpr()
3725  '(bvsle x y)'
3726  >>> ULE(x, y).sexpr()
3727  '(bvule x y)'
3728  """
3729  _check_bv_args(a, b)
3730  a, b = _coerce_exprs(a, b)
3731  return BoolRef(Z3_mk_bvule(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3732 
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:3716

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

Referenced by BitVecRef.__lt__().

3733 def ULT(a, b):
3734  """Create the Z3 expression (unsigned) `other < self`.
3735 
3736  Use the operator < for signed less than.
3737 
3738  >>> x, y = BitVecs('x y', 32)
3739  >>> ULT(x, y)
3740  ULT(x, y)
3741  >>> (x < y).sexpr()
3742  '(bvslt x y)'
3743  >>> ULT(x, y).sexpr()
3744  '(bvult x y)'
3745  """
3746  _check_bv_args(a, b)
3747  a, b = _coerce_exprs(a, b)
3748  return BoolRef(Z3_mk_bvult(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3749 
def ULT(a, b)
Definition: z3py.py:3733
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 9956 of file z3py.py.

Referenced by InRe().

9956 def Union(*args):
9957  """Create union of regular expressions.
9958  >>> re = Union(Re("a"), Re("b"), Re("c"))
9959  >>> print (simplify(InRe("d", re)))
9960  False
9961  """
9962  args = _get_args(args)
9963  sz = len(args)
9964  if __debug__:
9965  _z3_assert(sz > 0, "At least one argument expected.")
9966  _z3_assert(all([is_re(a) for a in args]), "All arguments must be regular expressions.")
9967  if sz == 1:
9968  return args[0]
9969  ctx = args[0].ctx
9970  v = (Ast * sz)()
9971  for i in range(sz):
9972  v[i] = args[i].as_ast()
9973  return ReRef(Z3_mk_re_union(ctx.ref(), sz, v), ctx)
9974 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:2813
def Union(args)
Definition: z3py.py:9956
def is_re(s)
Definition: z3py.py:9939
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 9788 of file z3py.py.

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

9788 def Unit(a):
9789  """Create a singleton sequence"""
9790  return SeqRef(Z3_mk_seq_unit(a.ctx_ref(), a.as_ast()), a.ctx)
9791 
def Unit(a)
Definition: z3py.py:9788
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 4233 of file z3py.py.

4233 def Update(a, i, v):
4234  """Return a Z3 store array expression.
4235 
4236  >>> a = Array('a', IntSort(), IntSort())
4237  >>> i, v = Ints('i v')
4238  >>> s = Update(a, i, v)
4239  >>> s.sort()
4240  Array(Int, Int)
4241  >>> prove(s[i] == v)
4242  proved
4243  >>> j = Int('j')
4244  >>> prove(Implies(i != j, s[j] == a[j]))
4245  proved
4246  """
4247  if __debug__:
4248  _z3_assert(is_array(a), "First argument must be a Z3 array expression")
4249  i = a.domain().cast(i)
4250  v = a.range().cast(v)
4251  ctx = a.ctx
4252  return _to_expr_ref(Z3_mk_store(ctx.ref(), a.as_ast(), i.as_ast(), v.as_ast()), ctx)
4253 
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:4122
def Update(a, i, v)
Definition: z3py.py:4233

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

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

3804 def URem(a, b):
3805  """Create the Z3 expression (unsigned) remainder `self % other`.
3806 
3807  Use the operator % for signed modulus, and SRem() for signed remainder.
3808 
3809  >>> x = BitVec('x', 32)
3810  >>> y = BitVec('y', 32)
3811  >>> URem(x, y)
3812  URem(x, y)
3813  >>> URem(x, y).sort()
3814  BitVec(32)
3815  >>> (x % y).sexpr()
3816  '(bvsmod x y)'
3817  >>> URem(x, y).sexpr()
3818  '(bvurem x y)'
3819  """
3820  _check_bv_args(a, b)
3821  a, b = _coerce_exprs(a, b)
3822  return BitVecRef(Z3_mk_bvurem(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3823 
def URem(a, b)
Definition: z3py.py:3804
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 1244 of file z3py.py.

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

1244 def Var(idx, s):
1245  """Create a Z3 free variable. Free variables are used to create quantified formulas.
1246 
1247  >>> Var(0, IntSort())
1248  Var(0)
1249  >>> eq(Var(0, IntSort()), Var(0, BoolSort()))
1250  False
1251  """
1252  if __debug__:
1253  _z3_assert(is_sort(s), "Z3 sort expected")
1254  return _to_expr_ref(Z3_mk_bound(s.ctx_ref(), idx, s.ast), s.ctx)
1255 
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:1244
def is_sort(s)
Definition: z3py.py:561

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

7678 def When(p, t, ctx=None):
7679  """Return a tactic that applies tactic `t` only if probe `p` evaluates to true. Otherwise, it returns the input goal unmodified.
7680 
7681  >>> t = When(Probe('size') > 2, Tactic('simplify'))
7682  >>> x, y = Ints('x y')
7683  >>> g = Goal()
7684  >>> g.add(x > 0)
7685  >>> g.add(y > 0)
7686  >>> t(g)
7687  [[x > 0, y > 0]]
7688  >>> g.add(x == y + 1)
7689  >>> t(g)
7690  [[Not(x <= 0), Not(y <= 0), x == 1 + y]]
7691  """
7692  p = _to_probe(p, ctx)
7693  t = _to_tactic(t, ctx)
7694  return Tactic(Z3_tactic_when(t.ctx.ref(), p.probe, t.tactic), t.ctx)
7695 
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:7678

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

Referenced by Goal.prec().

7377 def With(t, *args, **keys):
7378  """Return a tactic that applies tactic `t` using the given configuration options.
7379 
7380  >>> x, y = Ints('x y')
7381  >>> t = With(Tactic('simplify'), som=True)
7382  >>> t((x + 1)*(y + 2) == 0)
7383  [[2*x + y + x*y == -2]]
7384  """
7385  ctx = keys.pop('ctx', None)
7386  t = _to_tactic(t, ctx)
7387  p = args2params(args, keys, t.ctx)
7388  return Tactic(Z3_tactic_using_params(t.ctx.ref(), t.tactic, p.params), t.ctx)
7389 
def args2params(arguments, keywords, ctx=None)
Definition: z3py.py:4744
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:7377

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

1538 def Xor(a, b, ctx=None):
1539  """Create a Z3 Xor expression.
1540 
1541  >>> p, q = Bools('p q')
1542  >>> Xor(p, q)
1543  Xor(p, q)
1544  >>> simplify(Xor(p, q))
1545  Not(p) == q
1546  """
1547  ctx = _get_ctx(_ctx_from_ast_arg_list([a, b], ctx))
1548  s = BoolSort(ctx)
1549  a = s.cast(a)
1550  b = s.cast(b)
1551  return BoolRef(Z3_mk_xor(ctx.ref(), a.as_ast(), b.as_ast()), ctx)
1552 
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:1538
def BoolSort(ctx=None)
Definition: z3py.py:1435

◆ z3_error_handler()

def z3py.z3_error_handler (   c,
  e 
)

Definition at line 137 of file z3py.py.

137 def z3_error_handler(c, e):
138  # Do nothing error handler, just avoid exit(0)
139  # The wrappers in z3core.py will raise a Z3Exception if an error is detected
140  return
141 
def z3_error_handler(c, e)
Definition: z3py.py:137

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

3934 def ZeroExt(n, a):
3935  """Return a bit-vector expression with `n` extra zero-bits.
3936 
3937  >>> x = BitVec('x', 16)
3938  >>> n = ZeroExt(8, x)
3939  >>> n.size()
3940  24
3941  >>> n
3942  ZeroExt(8, x)
3943  >>> n.sort()
3944  BitVec(24)
3945  >>> v0 = BitVecVal(2, 2)
3946  >>> v0
3947  2
3948  >>> v0.size()
3949  2
3950  >>> v = simplify(ZeroExt(6, v0))
3951  >>> v
3952  2
3953  >>> v.size()
3954  8
3955  """
3956  if __debug__:
3957  _z3_assert(_is_int(n), "First argument must be an integer")
3958  _z3_assert(is_bv(a), "Second argument must be a Z3 Bitvector expression")
3959  return BitVecRef(Z3_mk_zero_ext(a.ctx_ref(), n, a.as_ast()), a.ctx)
3960 
def ZeroExt(n, a)
Definition: z3py.py:3934
def is_bv(a)
Definition: z3py.py:3522
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 6023 of file z3py.py.

◆ unknown

Definition at line 6025 of file z3py.py.

◆ unsat

Definition at line 6024 of file z3py.py.