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  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  ScopedConstructor
 
class  ScopedConstructorList
 
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 open_log (fname)
 
def append_log (s)
 
def to_symbol (s, ctx=None)
 
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)
 
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 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 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 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 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 Float128 (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)
 
def fpNeg (a)
 
def fpAdd (rm, a, b)
 
def fpSub (rm, a, b)
 
def fpMul (rm, a, b)
 
def fpDiv (rm, a, b)
 
def fpRem (a, b)
 
def fpMin (a, b)
 
def fpMax (a, b)
 
def fpFMA (rm, a, b, c)
 
def fpSqrt (rm, a)
 
def fpRoundToIntegral (rm, a)
 
def fpIsNaN (a)
 
def fpIsInfinite (a)
 
def fpIsZero (a)
 
def fpIsNormal (a)
 
def fpIsSubnormal (a)
 
def fpIsNegative (a)
 
def fpIsPositive (a)
 
def fpLT (a, b)
 
def fpLEQ (a, b)
 
def fpGT (a, b)
 
def fpGEQ (a, b)
 
def fpEQ (a, b)
 
def fpNEQ (a, b)
 
def fpFP (sgn, exp, sig)
 
def fpToFP (a1, a2=None, a3=None)
 
def fpToFPUnsigned (rm, x, s)
 
def fpToSBV (rm, x, s)
 
def fpToUBV (rm, x, s)
 
def fpToReal (x)
 
def fpToIEEEBV (x)
 

Variables

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

Function Documentation

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

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

1489 def And(*args):
1490  """Create a Z3 and-expression or and-probe.
1491 
1492  >>> p, q, r = Bools('p q r')
1493  >>> And(p, q, r)
1494  And(p, q, r)
1495  >>> P = BoolVector('p', 5)
1496  >>> And(P)
1497  And(p__0, p__1, p__2, p__3, p__4)
1498  """
1499  last_arg = None
1500  if len(args) > 0:
1501  last_arg = args[len(args)-1]
1502  if isinstance(last_arg, Context):
1503  ctx = args[len(args)-1]
1504  args = args[:len(args)-1]
1505  else:
1506  ctx = main_ctx()
1507  args = _get_args(args)
1508  ctx_args = _ctx_from_ast_arg_list(args, ctx)
1509  if __debug__:
1510  _z3_assert(ctx_args == None or ctx_args == ctx, "context mismatch")
1511  _z3_assert(ctx != None, "At least one of the arguments must be a Z3 expression or probe")
1512  if _has_probe(args):
1513  return _probe_and(args, ctx)
1514  else:
1515  args = _coerce_expr_list(args, ctx)
1516  _args, sz = _to_ast_array(args)
1517  return BoolRef(Z3_mk_and(ctx.ref(), sz, _args), ctx)
1518 
def And(args)
Definition: z3py.py:1489
def main_ctx()
Definition: z3py.py:188
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].The array args must have num_arg...
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 6759 of file z3py.py.

Referenced by Context.Then(), and Then().

6759 def AndThen(*ts, **ks):
6760  """Return a tactic that applies the tactics in `*ts` in sequence.
6761 
6762  >>> x, y = Ints('x y')
6763  >>> t = AndThen(Tactic('simplify'), Tactic('solve-eqs'))
6764  >>> t(And(x == 0, y > x + 1))
6765  [[Not(y <= 1)]]
6766  >>> t(And(x == 0, y > x + 1)).as_expr()
6767  Not(y <= 1)
6768  """
6769  if __debug__:
6770  _z3_assert(len(ts) >= 2, "At least two arguments expected")
6771  ctx = ks.get('ctx', None)
6772  num = len(ts)
6773  r = ts[0]
6774  for i in range(num - 1):
6775  r = _and_then(r, ts[i+1], ctx)
6776  return r
6777 
def AndThen(ts, ks)
Definition: z3py.py:6759
def z3py.append_log (   s)
Append user-defined string to interaction log. 

Definition at line 90 of file z3py.py.

90 def append_log(s):
91  """Append user-defined string to interaction log. """
92  Z3_append_log(s)
93 
void Z3_API Z3_append_log(Z3_string string)
Append user-defined string to interaction log.
def append_log(s)
Definition: z3py.py:90
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 4527 of file z3py.py.

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

4527 def args2params(arguments, keywords, ctx=None):
4528  """Convert python arguments into a Z3_params object.
4529  A ':' is added to the keywords, and '_' is replaced with '-'
4530 
4531  >>> args2params(['model', True, 'relevancy', 2], {'elim_and' : True})
4532  (params model true relevancy 2 elim_and true)
4533  """
4534  if __debug__:
4535  _z3_assert(len(arguments) % 2 == 0, "Argument list must have an even number of elements.")
4536  prev = None
4537  r = ParamsRef(ctx)
4538  for a in arguments:
4539  if prev == None:
4540  prev = a
4541  else:
4542  r.set(prev, a)
4543  prev = None
4544  for k in keywords:
4545  v = keywords[k]
4546  r.set(k, v)
4547  return r
4548 
def args2params(arguments, keywords, ctx=None)
Definition: z3py.py:4527
Parameter Sets.
Definition: z3py.py:4490
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 4025 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().

4025 def Array(name, dom, rng):
4026  """Return an array constant named `name` with the given domain and range sorts.
4027 
4028  >>> a = Array('a', IntSort(), IntSort())
4029  >>> a.sort()
4030  Array(Int, Int)
4031  >>> a[0]
4032  a[0]
4033  """
4034  s = ArraySort(dom, rng)
4035  ctx = s.ctx
4036  return ArrayRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), s.ast), ctx)
4037 
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:94
def Array(name, dom, rng)
Definition: z3py.py:4025
def ArraySort(d, r)
Definition: z3py.py:4004
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 4004 of file z3py.py.

Referenced by Array(), ArraySortRef.domain(), Context.mkArraySort(), Context.MkArraySort(), ArraySortRef.range(), Sort.toString(), and Sort.ToString().

4004 def ArraySort(d, r):
4005  """Return the Z3 array sort with the given domain and range sorts.
4006 
4007  >>> A = ArraySort(IntSort(), BoolSort())
4008  >>> A
4009  Array(Int, Bool)
4010  >>> A.domain()
4011  Int
4012  >>> A.range()
4013  Bool
4014  >>> AA = ArraySort(IntSort(), A)
4015  >>> AA
4016  Array(Int, Array(Int, Bool))
4017  """
4018  if __debug__:
4019  _z3_assert(is_sort(d), "Z3 sort expected")
4020  _z3_assert(is_sort(r), "Z3 sort expected")
4021  _z3_assert(d.ctx == r.ctx, "Context mismatch")
4022  ctx = d.ctx
4023  return ArraySortRef(Z3_mk_array_sort(ctx.ref(), d.ast, r.ast), ctx)
4024 
Arrays.
Definition: z3py.py:3859
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:530
def ArraySort(d, r)
Definition: z3py.py:4004
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 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 7590 of file z3py.py.

7590 def binary_interpolant(a,b,p=None,ctx=None):
7591  """Compute an interpolant for a binary conjunction.
7592 
7593  If a & b is unsatisfiable, returns an interpolant for a & b.
7594  This is a formula phi such that
7595 
7596  1) a implies phi
7597  2) b implies not phi
7598  3) All the uninterpreted symbols of phi occur in both a and b.
7599 
7600  If a & b is satisfiable, raises an object of class ModelRef
7601  that represents a model of a &b.
7602 
7603  If parameters p are supplied, these are used in creating the
7604  solver that determines satisfiability.
7605 
7606  x = Int('x')
7607  print binary_interpolant(x<0,x>2)
7608  Not(x >= 0)
7609  """
7610  f = And(Interpolant(a),b)
7611  return tree_interpolant(f,p,ctx)[0]
7612 
def And(args)
Definition: z3py.py:1489
def binary_interpolant(a, b, p=None, ctx=None)
Definition: z3py.py:7590
def Interpolant(a, ctx=None)
Definition: z3py.py:7517
def tree_interpolant(pat, p=None, ctx=None)
Definition: z3py.py:7531
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 3490 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().

3490 def BitVec(name, bv, ctx=None):
3491  """Return a bit-vector constant named `name`. `bv` may be the number of bits of a bit-vector sort.
3492  If `ctx=None`, then the global context is used.
3493 
3494  >>> x = BitVec('x', 16)
3495  >>> is_bv(x)
3496  True
3497  >>> x.size()
3498  16
3499  >>> x.sort()
3500  BitVec(16)
3501  >>> word = BitVecSort(16)
3502  >>> x2 = BitVec('x', word)
3503  >>> eq(x, x2)
3504  True
3505  """
3506  if isinstance(bv, BitVecSortRef):
3507  ctx = bv.ctx
3508  else:
3509  ctx = _get_ctx(ctx)
3510  bv = BitVecSort(bv, ctx)
3511  return BitVecRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), bv.ast), ctx)
3512 
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:94
def BitVec(name, bv, ctx=None)
Definition: z3py.py:3490
def BitVecSort(sz, ctx=None)
Definition: z3py.py:3460
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 3513 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().

3513 def BitVecs(names, bv, ctx=None):
3514  """Return a tuple of bit-vector constants of size bv.
3515 
3516  >>> x, y, z = BitVecs('x y z', 16)
3517  >>> x.size()
3518  16
3519  >>> x.sort()
3520  BitVec(16)
3521  >>> Sum(x, y, z)
3522  0 + x + y + z
3523  >>> Product(x, y, z)
3524  1*x*y*z
3525  >>> simplify(Product(x, y, z))
3526  x*y*z
3527  """
3528  ctx = _get_ctx(ctx)
3529  if isinstance(names, str):
3530  names = names.split(" ")
3531  return [BitVec(name, bv, ctx) for name in names]
3532 
def BitVec(name, bv, ctx=None)
Definition: z3py.py:3490
def BitVecs(names, bv, ctx=None)
Definition: z3py.py:3513
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 3460 of file z3py.py.

Referenced by BitVec(), BitVecSortRef.cast(), fpToSBV(), fpToUBV(), is_bv_sort(), Context.mkBitVecSort(), Context.MkBitVecSort(), BitVecSortRef.size(), BitVecRef.sort(), Sort.toString(), and Sort.ToString().

3460 def BitVecSort(sz, ctx=None):
3461  """Return a Z3 bit-vector sort of the given size. If `ctx=None`, then the global context is used.
3462 
3463  >>> Byte = BitVecSort(8)
3464  >>> Word = BitVecSort(16)
3465  >>> Byte
3466  BitVec(8)
3467  >>> x = Const('x', Byte)
3468  >>> eq(x, BitVec('x', 8))
3469  True
3470  """
3471  ctx = _get_ctx(ctx)
3472  return BitVecSortRef(Z3_mk_bv_sort(ctx.ref(), sz), ctx)
3473 
Z3_sort Z3_API Z3_mk_bv_sort(Z3_context c, unsigned sz)
Create a bit-vector type of the given size.
Bit-Vectors.
Definition: z3py.py:2922
def BitVecSort(sz, ctx=None)
Definition: z3py.py:3460
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 3474 of file z3py.py.

Referenced by BitVecRef.__lshift__(), BitVecRef.__rshift__(), BitVecNumRef.as_long(), BitVecNumRef.as_signed_long(), Concat(), is_bv_value(), LShR(), RepeatBitVec(), SignExt(), and ZeroExt().

3474 def BitVecVal(val, bv, ctx=None):
3475  """Return a bit-vector value with the given number of bits. If `ctx=None`, then the global context is used.
3476 
3477  >>> v = BitVecVal(10, 32)
3478  >>> v
3479  10
3480  >>> print("0x%.8x" % v.as_long())
3481  0x0000000a
3482  """
3483  if is_bv_sort(bv):
3484  ctx = bv.ctx
3485  return BitVecNumRef(Z3_mk_numeral(ctx.ref(), _to_int_str(val), bv.ast), ctx)
3486  else:
3487  ctx = _get_ctx(ctx)
3488  return BitVecNumRef(Z3_mk_numeral(ctx.ref(), _to_int_str(val), BitVecSort(bv, ctx).ast), ctx)
3489 
def BitVecVal(val, bv, ctx=None)
Definition: z3py.py:3474
def is_bv_sort(s)
Definition: z3py.py:2954
def BitVecSort(sz, ctx=None)
Definition: z3py.py:3460
Z3_ast Z3_API Z3_mk_numeral(Z3_context c, Z3_string numeral, Z3_sort ty)
Create a numeral of a given sort.
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 1381 of file z3py.py.

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

1381 def Bool(name, ctx=None):
1382  """Return a Boolean constant named `name`. If `ctx=None`, then the global context is used.
1383 
1384  >>> p = Bool('p')
1385  >>> q = Bool('q')
1386  >>> And(p, q)
1387  And(p, q)
1388  """
1389  ctx = _get_ctx(ctx)
1390  return BoolRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), BoolSort(ctx).ast), ctx)
1391 
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:94
def Bool(name, ctx=None)
Definition: z3py.py:1381
def BoolSort(ctx=None)
Definition: z3py.py:1346
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 1392 of file z3py.py.

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

1392 def Bools(names, ctx=None):
1393  """Return a tuple of Boolean constants.
1394 
1395  `names` is a single string containing all names separated by blank spaces.
1396  If `ctx=None`, then the global context is used.
1397 
1398  >>> p, q, r = Bools('p q r')
1399  >>> And(p, Or(q, r))
1400  And(p, Or(q, r))
1401  """
1402  ctx = _get_ctx(ctx)
1403  if isinstance(names, str):
1404  names = names.split(" ")
1405  return [Bool(name, ctx) for name in names]
1406 
def Bools(names, ctx=None)
Definition: z3py.py:1392
def Bool(name, ctx=None)
Definition: z3py.py:1381
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 1346 of file z3py.py.

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

1346 def BoolSort(ctx=None):
1347  """Return the Boolean Z3 sort. If `ctx=None`, then the global context is used.
1348 
1349  >>> BoolSort()
1350  Bool
1351  >>> p = Const('p', BoolSort())
1352  >>> is_bool(p)
1353  True
1354  >>> r = Function('r', IntSort(), IntSort(), BoolSort())
1355  >>> r(0, 1)
1356  r(0, 1)
1357  >>> is_bool(r(0, 1))
1358  True
1359  """
1360  ctx = _get_ctx(ctx)
1361  return BoolSortRef(Z3_mk_bool_sort(ctx.ref()), ctx)
1362 
def is_bool(a)
Definition: z3py.py:1246
def BoolSort(ctx=None)
Definition: z3py.py:1346
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 1363 of file z3py.py.

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

1363 def BoolVal(val, ctx=None):
1364  """Return the Boolean value `True` or `False`. If `ctx=None`, then the global context is used.
1365 
1366  >>> BoolVal(True)
1367  True
1368  >>> is_true(BoolVal(True))
1369  True
1370  >>> is_true(True)
1371  False
1372  >>> is_false(BoolVal(False))
1373  True
1374  """
1375  ctx = _get_ctx(ctx)
1376  if val == False:
1377  return BoolRef(Z3_mk_false(ctx.ref()), ctx)
1378  else:
1379  return BoolRef(Z3_mk_true(ctx.ref()), ctx)
1380 
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:1363
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 1407 of file z3py.py.

Referenced by And(), and Or().

1407 def BoolVector(prefix, sz, ctx=None):
1408  """Return a list of Boolean constants of size `sz`.
1409 
1410  The constants are named using the given prefix.
1411  If `ctx=None`, then the global context is used.
1412 
1413  >>> P = BoolVector('p', 3)
1414  >>> P
1415  [p__0, p__1, p__2]
1416  >>> And(P)
1417  And(p__0, p__1, p__2)
1418  """
1419  return [ Bool('%s__%s' % (prefix, i)) for i in range(sz) ]
1420 
def BoolVector(prefix, sz, ctx=None)
Definition: z3py.py:1407
def Bool(name, ctx=None)
Definition: z3py.py:1381
def z3py.BV2Int (   a)
Return the Z3 expression BV2Int(a). 

>>> b = BitVec('b', 3)
>>> BV2Int(b).sort()
Int
>>> x = Int('x')
>>> x > BV2Int(b)
x > BV2Int(b)
>>> solve(x > BV2Int(b), b == 1, x < 3)
[b = 1, x = 2]

Definition at line 3442 of file z3py.py.

3442 def BV2Int(a):
3443  """Return the Z3 expression BV2Int(a).
3444 
3445  >>> b = BitVec('b', 3)
3446  >>> BV2Int(b).sort()
3447  Int
3448  >>> x = Int('x')
3449  >>> x > BV2Int(b)
3450  x > BV2Int(b)
3451  >>> solve(x > BV2Int(b), b == 1, x < 3)
3452  [b = 1, x = 2]
3453  """
3454  if __debug__:
3455  _z3_assert(is_bv(a), "Z3 bit-vector expression expected")
3456  ctx = a.ctx
3457  ## investigate problem with bv2int
3458  return ArithRef(Z3_mk_bv2int(ctx.ref(), a.as_ast(), 0), ctx)
3459 
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)
Definition: z3py.py:3442
def is_bv(a)
Definition: z3py.py:3415
def z3py.BVRedAnd (   a)
Return the reduction-and expression of `a`.

Definition at line 3841 of file z3py.py.

3841 def BVRedAnd(a):
3842  """Return the reduction-and expression of `a`."""
3843  if __debug__:
3844  _z3_assert(is_bv(a), "First argument must be a Z3 Bitvector expression")
3845  return BitVecRef(Z3_mk_bvredand(a.ctx_ref(), a.as_ast()), a.ctx)
3846 
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:3841
def is_bv(a)
Definition: z3py.py:3415
def z3py.BVRedOr (   a)
Return the reduction-or expression of `a`.

Definition at line 3847 of file z3py.py.

3847 def BVRedOr(a):
3848  """Return the reduction-or expression of `a`."""
3849  if __debug__:
3850  _z3_assert(is_bv(a), "First argument must be a Z3 Bitvector expression")
3851  return BitVecRef(Z3_mk_bvredor(a.ctx_ref(), a.as_ast()), a.ctx)
3852 
def BVRedOr(a)
Definition: z3py.py:3847
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:3415
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 2904 of file z3py.py.

2904 def Cbrt(a, ctx=None):
2905  """ Return a Z3 expression which represents the cubic root of a.
2906 
2907  >>> x = Real('x')
2908  >>> Cbrt(x)
2909  x**(1/3)
2910  """
2911  if not is_expr(a):
2912  ctx = _get_ctx(ctx)
2913  a = RealVal(a, ctx)
2914  return a ** "1/3"
2915 
def Cbrt(a, ctx=None)
Definition: z3py.py:2904
def RealVal(val, ctx=None)
Definition: z3py.py:2697
def is_expr(a)
Definition: z3py.py:961
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 3533 of file z3py.py.

Referenced by BitVecRef.size().

3533 def Concat(*args):
3534  """Create a Z3 bit-vector concatenation expression.
3535 
3536  >>> v = BitVecVal(1, 4)
3537  >>> Concat(v, v+1, v)
3538  Concat(Concat(1, 1 + 1), 1)
3539  >>> simplify(Concat(v, v+1, v))
3540  289
3541  >>> print("%.3x" % simplify(Concat(v, v+1, v)).as_long())
3542  121
3543  """
3544  args = _get_args(args)
3545  if __debug__:
3546  _z3_assert(all([is_bv(a) for a in args]), "All arguments must be Z3 bit-vector expressions.")
3547  _z3_assert(len(args) >= 2, "At least two arguments expected.")
3548  ctx = args[0].ctx
3549  r = args[0]
3550  for i in range(len(args) - 1):
3551  r = BitVecRef(Z3_mk_concat(ctx.ref(), r.as_ast(), args[i+1].as_ast()), ctx)
3552  return r
3553 
Z3_ast Z3_API Z3_mk_concat(Z3_context c, Z3_ast t1, Z3_ast t2)
Concatenate the given bit-vectors.
def is_bv(a)
Definition: z3py.py:3415
def Concat(args)
Definition: z3py.py:3533
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 7162 of file z3py.py.

Referenced by If().

7162 def Cond(p, t1, t2, ctx=None):
7163  """Return a tactic that applies tactic `t1` to a goal if probe `p` evaluates to true, and `t2` otherwise.
7164 
7165  >>> t = Cond(Probe('is-qfnra'), Tactic('qfnra'), Tactic('smt'))
7166  """
7167  p = _to_probe(p, ctx)
7168  t1 = _to_tactic(t1, ctx)
7169  t2 = _to_tactic(t2, ctx)
7170  return Tactic(Z3_tactic_cond(t1.ctx.ref(), p.probe, t1.tactic, t2.tactic), t1.ctx)
7171 
def Cond(p, t1, t2, ctx=None)
Definition: z3py.py:7162
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...
def z3py.Const (   name,
  sort 
)
Create a constant of the given sort.

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

Definition at line 1145 of file z3py.py.

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

1145 def Const(name, sort):
1146  """Create a constant of the given sort.
1147 
1148  >>> Const('x', IntSort())
1149  x
1150  """
1151  if __debug__:
1152  _z3_assert(isinstance(sort, SortRef), "Z3 sort expected")
1153  ctx = sort.ctx
1154  return _to_expr_ref(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), sort.ast), ctx)
1155 
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:94
def Const(name, sort)
Definition: z3py.py:1145
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 1156 of file z3py.py.

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

1156 def Consts(names, sort):
1157  """Create a several constants of the given sort.
1158 
1159  `names` is a string containing the names of all constants to be created.
1160  Blank spaces separate the names of different constants.
1161 
1162  >>> x, y, z = Consts('x y z', IntSort())
1163  >>> x + y + z
1164  x + y + z
1165  """
1166  if isinstance(names, str):
1167  names = names.split(" ")
1168  return [Const(name, sort) for name in names]
1169 
def Consts(names, sort)
Definition: z3py.py:1156
def Const(name, sort)
Definition: z3py.py:1145
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 4269 of file z3py.py.

Referenced by Datatype.create().

4270  """Create mutually recursive Z3 datatypes using 1 or more Datatype helper objects.
4271 
4272  In the following example we define a Tree-List using two mutually recursive datatypes.
4273 
4274  >>> TreeList = Datatype('TreeList')
4275  >>> Tree = Datatype('Tree')
4276  >>> # Tree has two constructors: leaf and node
4277  >>> Tree.declare('leaf', ('val', IntSort()))
4278  >>> # a node contains a list of trees
4279  >>> Tree.declare('node', ('children', TreeList))
4280  >>> TreeList.declare('nil')
4281  >>> TreeList.declare('cons', ('car', Tree), ('cdr', TreeList))
4282  >>> Tree, TreeList = CreateDatatypes(Tree, TreeList)
4283  >>> Tree.val(Tree.leaf(10))
4284  val(leaf(10))
4285  >>> simplify(Tree.val(Tree.leaf(10)))
4286  10
4287  >>> n1 = Tree.node(TreeList.cons(Tree.leaf(10), TreeList.cons(Tree.leaf(20), TreeList.nil)))
4288  >>> n1
4289  node(cons(leaf(10), cons(leaf(20), nil)))
4290  >>> n2 = Tree.node(TreeList.cons(n1, TreeList.nil))
4291  >>> simplify(n2 == n1)
4292  False
4293  >>> simplify(TreeList.car(Tree.children(n2)) == n1)
4294  True
4295  """
4296  ds = _get_args(ds)
4297  if __debug__:
4298  _z3_assert(len(ds) > 0, "At least one Datatype must be specified")
4299  _z3_assert(all([isinstance(d, Datatype) for d in ds]), "Arguments must be Datatypes")
4300  _z3_assert(all([d.ctx == ds[0].ctx for d in ds]), "Context mismatch")
4301  _z3_assert(all([d.constructors != [] for d in ds]), "Non-empty Datatypes expected")
4302  ctx = ds[0].ctx
4303  num = len(ds)
4304  names = (Symbol * num)()
4305  out = (Sort * num)()
4306  clists = (ConstructorList * num)()
4307  to_delete = []
4308  for i in range(num):
4309  d = ds[i]
4310  names[i] = to_symbol(d.name, ctx)
4311  num_cs = len(d.constructors)
4312  cs = (Constructor * num_cs)()
4313  for j in range(num_cs):
4314  c = d.constructors[j]
4315  cname = to_symbol(c[0], ctx)
4316  rname = to_symbol(c[1], ctx)
4317  fs = c[2]
4318  num_fs = len(fs)
4319  fnames = (Symbol * num_fs)()
4320  sorts = (Sort * num_fs)()
4321  refs = (ctypes.c_uint * num_fs)()
4322  for k in range(num_fs):
4323  fname = fs[k][0]
4324  ftype = fs[k][1]
4325  fnames[k] = to_symbol(fname, ctx)
4326  if isinstance(ftype, Datatype):
4327  if __debug__:
4328  _z3_assert(ds.count(ftype) == 1, "One and only one occurrence of each datatype is expected")
4329  sorts[k] = None
4330  refs[k] = ds.index(ftype)
4331  else:
4332  if __debug__:
4333  _z3_assert(is_sort(ftype), "Z3 sort expected")
4334  sorts[k] = ftype.ast
4335  refs[k] = 0
4336  cs[j] = Z3_mk_constructor(ctx.ref(), cname, rname, num_fs, fnames, sorts, refs)
4337  to_delete.append(ScopedConstructor(cs[j], ctx))
4338  clists[i] = Z3_mk_constructor_list(ctx.ref(), num_cs, cs)
4339  to_delete.append(ScopedConstructorList(clists[i], ctx))
4340  Z3_mk_datatypes(ctx.ref(), num, names, out, clists)
4341  result = []
4342  ## Create a field for every constructor, recognizer and accessor
4343  for i in range(num):
4344  dref = DatatypeSortRef(out[i], ctx)
4345  num_cs = dref.num_constructors()
4346  for j in range(num_cs):
4347  cref = dref.constructor(j)
4348  cref_name = cref.name()
4349  cref_arity = cref.arity()
4350  if cref.arity() == 0:
4351  cref = cref()
4352  setattr(dref, cref_name, cref)
4353  rref = dref.recognizer(j)
4354  setattr(dref, rref.name(), rref)
4355  for k in range(cref_arity):
4356  aref = dref.accessor(j, k)
4357  setattr(dref, aref.name(), aref)
4358  result.append(dref)
4359  return tuple(result)
4360 
def to_symbol(s, ctx=None)
Definition: z3py.py:94
def CreateDatatypes(ds)
Definition: z3py.py:4269
def is_sort(s)
Definition: z3py.py:530
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.
BEGIN_MLAPI_EXCLUDE 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.
Z3_constructor_list Z3_API Z3_mk_constructor_list(Z3_context c, unsigned num_constructors, Z3_constructor const constructors[])
Create list of constructors.
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 567 of file z3py.py.

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

567 def DeclareSort(name, ctx=None):
568  """Create a new uninterpred sort named `name`.
569 
570  If `ctx=None`, then the new sort is declared in the global Z3Py context.
571 
572  >>> A = DeclareSort('A')
573  >>> a = Const('a', A)
574  >>> b = Const('b', A)
575  >>> a.sort() == A
576  True
577  >>> b.sort() == A
578  True
579  >>> a == b
580  a == b
581  """
582  ctx = _get_ctx(ctx)
583  return SortRef(Z3_mk_uninterpreted_sort(ctx.ref(), to_symbol(name, ctx)), ctx)
584 
def to_symbol(s, ctx=None)
Definition: z3py.py:94
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:567
def z3py.Default (   a)
Return a default value for array expression.  
>>> b = K(IntSort(), 1)  
>>> prove(Default(b) == 1)  
proved

Definition at line 4059 of file z3py.py.

Referenced by is_default().

4059 def Default(a):
4060  """ Return a default value for array expression.
4061  >>> b = K(IntSort(), 1)
4062  >>> prove(Default(b) == 1)
4063  proved
4064  """
4065  if __debug__:
4066  _z3_assert(is_array(a), "First argument must be a Z3 array expression")
4067  return a.mk_default()
4068 
4069 
def is_array(a)
Definition: z3py.py:3927
def Default(a)
Definition: z3py.py:4059
def z3py.describe_probes ( )
Display a (tabular) description of all available probes in Z3.

Definition at line 7092 of file z3py.py.

7093  """Display a (tabular) description of all available probes in Z3."""
7094  if in_html_mode():
7095  even = True
7096  print('<table border="1" cellpadding="2" cellspacing="0">')
7097  for p in probes():
7098  if even:
7099  print('<tr style="background-color:#CFCFCF">')
7100  even = False
7101  else:
7102  print('<tr>')
7103  even = True
7104  print('<td>%s</td><td>%s</td></tr>' % (p, insert_line_breaks(probe_description(p), 40)))
7105  print('</table>')
7106  else:
7107  for p in probes():
7108  print('%s : %s' % (p, probe_description(p)))
7109 
def probes(ctx=None)
Definition: z3py.py:7074
def probe_description(name, ctx=None)
Definition: z3py.py:7084
def describe_probes()
Definition: z3py.py:7092
def z3py.describe_tactics ( )
Display a (tabular) description of all available tactics in Z3.

Definition at line 6904 of file z3py.py.

6905  """Display a (tabular) description of all available tactics in Z3."""
6906  if in_html_mode():
6907  even = True
6908  print('<table border="1" cellpadding="2" cellspacing="0">')
6909  for t in tactics():
6910  if even:
6911  print('<tr style="background-color:#CFCFCF">')
6912  even = False
6913  else:
6914  print('<tr>')
6915  even = True
6916  print('<td>%s</td><td>%s</td></tr>' % (t, insert_line_breaks(tactic_description(t), 40)))
6917  print('</table>')
6918  else:
6919  for t in tactics():
6920  print('%s : %s' % (t, tactic_description(t)))
6921 
def tactics(ctx=None)
Definition: z3py.py:6886
def tactic_description(name, ctx=None)
Definition: z3py.py:6896
def describe_tactics()
Definition: z3py.py:6904
def z3py.disable_trace (   msg)

Definition at line 61 of file z3py.py.

61 def disable_trace(msg):
62  Z3_disable_trace(msg)
63 
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:61
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 1114 of file z3py.py.

1114 def Distinct(*args):
1115  """Create a Z3 distinct expression.
1116 
1117  >>> x = Int('x')
1118  >>> y = Int('y')
1119  >>> Distinct(x, y)
1120  x != y
1121  >>> z = Int('z')
1122  >>> Distinct(x, y, z)
1123  Distinct(x, y, z)
1124  >>> simplify(Distinct(x, y, z))
1125  Distinct(x, y, z)
1126  >>> simplify(Distinct(x, y, z), blast_distinct=True)
1127  And(Not(x == y), Not(x == z), Not(y == z))
1128  """
1129  args = _get_args(args)
1130  ctx = _ctx_from_ast_arg_list(args)
1131  if __debug__:
1132  _z3_assert(ctx != None, "At least one of the arguments must be a Z3 expression")
1133  args = _coerce_expr_list(args, ctx)
1134  _args, sz = _to_ast_array(args)
1135  return BoolRef(Z3_mk_distinct(ctx.ref(), sz, _args), ctx)
1136 
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]).The distinct construct is us...
def Distinct(args)
Definition: z3py.py:1114
def z3py.enable_trace (   msg)

Definition at line 58 of file z3py.py.

58 def enable_trace(msg):
59  Z3_enable_trace(msg)
60 
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:58
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 4458 of file z3py.py.

Referenced by Context.mkEnumSort(), Context.MkEnumSort(), and EnumSort.TesterDecl().

4458 def EnumSort(name, values, ctx=None):
4459  """Return a new enumeration sort named `name` containing the given values.
4460 
4461  The result is a pair (sort, list of constants).
4462  Example:
4463  >>> Color, (red, green, blue) = EnumSort('Color', ['red', 'green', 'blue'])
4464  """
4465  if __debug__:
4466  _z3_assert(isinstance(name, str), "Name must be a string")
4467  _z3_assert(all([isinstance(v, str) for v in values]), "Eumeration sort values must be strings")
4468  _z3_assert(len(values) > 0, "At least one value expected")
4469  ctx = _get_ctx(ctx)
4470  num = len(values)
4471  _val_names = (Symbol * num)()
4472  for i in range(num):
4473  _val_names[i] = to_symbol(values[i])
4474  _values = (FuncDecl * num)()
4475  _testers = (FuncDecl * num)()
4476  name = to_symbol(name)
4477  S = DatatypeSortRef(Z3_mk_enumeration_sort(ctx.ref(), name, num, _val_names, _values, _testers), ctx)
4478  V = []
4479  for i in range(num):
4480  V.append(FuncDeclRef(_values[i], ctx))
4481  V = [a() for a in V]
4482  return S, V
4483 
Function Declarations.
Definition: z3py.py:591
def to_symbol(s, ctx=None)
Definition: z3py.py:94
def EnumSort(name, values, ctx=None)
Definition: z3py.py:4458
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.
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 371 of file z3py.py.

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

371 def eq(a, b):
372  """Return `True` if `a` and `b` are structurally identical AST nodes.
373 
374  >>> x = Int('x')
375  >>> y = Int('y')
376  >>> eq(x, y)
377  False
378  >>> eq(x + 1, x + 1)
379  True
380  >>> eq(x + 1, 1 + x)
381  False
382  >>> eq(simplify(x + 1), simplify(1 + x))
383  True
384  """
385  if __debug__:
386  _z3_assert(is_ast(a) and is_ast(b), "Z3 ASTs expected")
387  return a.eq(b)
388 
def eq(a, b)
Definition: z3py.py:371
def is_ast(a)
Definition: z3py.py:351
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 1829 of file z3py.py.

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

1829 def Exists(vs, body, weight=1, qid="", skid="", patterns=[], no_patterns=[]):
1830  """Create a Z3 exists formula.
1831 
1832  The parameters `weight`, `qif`, `skid`, `patterns` and `no_patterns` are optional annotations.
1833 
1834  See http://rise4fun.com/Z3Py/tutorial/advanced for more details.
1835 
1836  >>> f = Function('f', IntSort(), IntSort(), IntSort())
1837  >>> x = Int('x')
1838  >>> y = Int('y')
1839  >>> q = Exists([x, y], f(x, y) >= x, skid="foo")
1840  >>> q
1841  Exists([x, y], f(x, y) >= x)
1842  >>> is_quantifier(q)
1843  True
1844  >>> r = Tactic('nnf')(q).as_expr()
1845  >>> is_quantifier(r)
1846  False
1847  """
1848  return _mk_quantifier(False, vs, body, weight, qid, skid, patterns, no_patterns)
1849 
def Exists(vs, body, weight=1, qid="", skid="", patterns=[], no_patterns=[])
Definition: z3py.py:1829
def z3py.Extract (   high,
  low,
  a 
)
Create a Z3 bit-vector extraction expression.

>>> x = BitVec('x', 8)
>>> Extract(6, 2, x)
Extract(6, 2, x)
>>> Extract(6, 2, x).sort()
BitVec(5)

Definition at line 3554 of file z3py.py.

3554 def Extract(high, low, a):
3555  """Create a Z3 bit-vector extraction expression.
3556 
3557  >>> x = BitVec('x', 8)
3558  >>> Extract(6, 2, x)
3559  Extract(6, 2, x)
3560  >>> Extract(6, 2, x).sort()
3561  BitVec(5)
3562  """
3563  if __debug__:
3564  _z3_assert(low <= high, "First argument must be greater than or equal to second argument")
3565  _z3_assert(isinstance(high, int) and high >= 0 and isinstance(low, int) and low >= 0, "First and second arguments must be non negative integers")
3566  _z3_assert(is_bv(a), "Third argument must be a Z3 Bitvector expression")
3567  return BitVecRef(Z3_mk_extract(a.ctx_ref(), high, low, a.as_ast()), a.ctx)
3568 
def Extract(high, low, a)
Definition: z3py.py:3554
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 bitvector of size m to yield a new bitvector of size n...
def is_bv(a)
Definition: z3py.py:3415
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 7125 of file z3py.py.

7125 def FailIf(p, ctx=None):
7126  """Return a tactic that fails if the probe `p` evaluates to true. Otherwise, it returns the input goal unmodified.
7127 
7128  In the following example, the tactic applies 'simplify' if and only if there are more than 2 constraints in the goal.
7129 
7130  >>> t = OrElse(FailIf(Probe('size') > 2), Tactic('simplify'))
7131  >>> x, y = Ints('x y')
7132  >>> g = Goal()
7133  >>> g.add(x > 0)
7134  >>> g.add(y > 0)
7135  >>> t(g)
7136  [[x > 0, y > 0]]
7137  >>> g.add(x == y + 1)
7138  >>> t(g)
7139  [[Not(x <= 0), Not(y <= 0), x == 1 + y]]
7140  """
7141  p = _to_probe(p, ctx)
7142  return Tactic(Z3_tactic_fail_if(p.ctx.ref(), p.probe), p.ctx)
7143 
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:7125
def z3py.FiniteDomainSort (   name,
  sz,
  ctx = None 
)
Create a named finite domain sort of a given size sz

Definition at line 6389 of file z3py.py.

Referenced by Context.mkFiniteDomainSort(), Context.MkFiniteDomainSort(), Sort.toString(), and Sort.ToString().

6389 def FiniteDomainSort(name, sz, ctx=None):
6390  """Create a named finite domain sort of a given size sz"""
6391  ctx = _get_ctx(ctx)
6392  return FiniteDomainSortRef(Z3_mk_finite_domain_sort(ctx.ref(), name, sz), ctx)
6393 
Z3_sort Z3_API Z3_mk_finite_domain_sort(Z3_context c, Z3_symbol name, unsigned __int64 size)
Create a named finite domain sort.
def FiniteDomainSort(name, sz, ctx=None)
Definition: z3py.py:6389
def z3py.Float128 (   ctx = None)
Floating-point 128-bit (quadruple) sort.

Definition at line 7764 of file z3py.py.

7764 def Float128(ctx=None):
7765  """Floating-point 128-bit (quadruple) sort."""
7766  ctx = _get_ctx(ctx)
7767  return FPSortRef(Z3_mk_fpa_sort_128(ctx.ref()), ctx)
7768 
def Float128(ctx=None)
Definition: z3py.py:7764
FP Sorts.
Definition: z3py.py:7698
Z3_sort Z3_API Z3_mk_fpa_sort_128(Z3_context c)
Create the quadruple-precision (128-bit) FloatingPoint sort.
def z3py.Float16 (   ctx = None)
Floating-point 16-bit (half) sort.

Definition at line 7734 of file z3py.py.

7734 def Float16(ctx=None):
7735  """Floating-point 16-bit (half) sort."""
7736  ctx = _get_ctx(ctx)
7737  return FPSortRef(Z3_mk_fpa_sort_16(ctx.ref()), ctx)
7738 
def Float16(ctx=None)
Definition: z3py.py:7734
FP Sorts.
Definition: z3py.py:7698
Z3_sort Z3_API Z3_mk_fpa_sort_16(Z3_context c)
Create the half-precision (16-bit) FloatingPoint sort.
def z3py.Float32 (   ctx = None)
Floating-point 32-bit (single) sort.

Definition at line 7744 of file z3py.py.

7744 def Float32(ctx=None):
7745  """Floating-point 32-bit (single) sort."""
7746  ctx = _get_ctx(ctx)
7747  return FPSortRef(Z3_mk_fpa_sort_32(ctx.ref()), ctx)
7748 
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:7744
FP Sorts.
Definition: z3py.py:7698
def z3py.Float64 (   ctx = None)
Floating-point 64-bit (double) sort.

Definition at line 7754 of file z3py.py.

7754 def Float64(ctx=None):
7755  """Floating-point 64-bit (double) sort."""
7756  ctx = _get_ctx(ctx)
7757  return FPSortRef(Z3_mk_fpa_sort_64(ctx.ref()), ctx)
7758 
def Float64(ctx=None)
Definition: z3py.py:7754
FP Sorts.
Definition: z3py.py:7698
Z3_sort Z3_API Z3_mk_fpa_sort_64(Z3_context c)
Create the double-precision (64-bit) FloatingPoint sort.
def z3py.FloatHalf (   ctx = None)
Floating-point 16-bit (half) sort.

Definition at line 7739 of file z3py.py.

7739 def FloatHalf(ctx=None):
7740  """Floating-point 16-bit (half) sort."""
7741  ctx = _get_ctx(ctx)
7742  return FPSortRef(Z3_mk_fpa_sort_half(ctx.ref()), ctx)
7743 
Z3_sort Z3_API Z3_mk_fpa_sort_half(Z3_context c)
Create the half-precision (16-bit) FloatingPoint sort.
FP Sorts.
Definition: z3py.py:7698
def FloatHalf(ctx=None)
Definition: z3py.py:7739
def FloatSingle (   ctx = None)
Floating-point 32-bit (single) sort.
Floating-point 64-bit (double) sort.
Floating-point 128-bit (quadruple) sort.

Definition at line 7749 of file z3py.py.

7749 def FloatSingle(ctx=None):
7750  """Floating-point 32-bit (single) sort."""
7751  ctx = _get_ctx(ctx)
7752  return FPSortRef(Z3_mk_fpa_sort_single(ctx.ref()), ctx)
7753 
def FloatSingle(ctx=None)
Definition: z3py.py:7749
Z3_sort Z3_API Z3_mk_fpa_sort_single(Z3_context c)
Create the single-precision (32-bit) FloatingPoint sort.
FP Sorts.
Definition: z3py.py:7698
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 1810 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().

1810 def ForAll(vs, body, weight=1, qid="", skid="", patterns=[], no_patterns=[]):
1811  """Create a Z3 forall formula.
1812 
1813  The parameters `weight`, `qif`, `skid`, `patterns` and `no_patterns` are optional annotations.
1814 
1815  See http://rise4fun.com/Z3Py/tutorial/advanced for more details.
1816 
1817  >>> f = Function('f', IntSort(), IntSort(), IntSort())
1818  >>> x = Int('x')
1819  >>> y = Int('y')
1820  >>> ForAll([x, y], f(x, y) >= x)
1821  ForAll([x, y], f(x, y) >= x)
1822  >>> ForAll([x, y], f(x, y) >= x, patterns=[ f(x, y) ])
1823  ForAll([x, y], f(x, y) >= x)
1824  >>> ForAll([x, y], f(x, y) >= x, weight=10)
1825  ForAll([x, y], f(x, y) >= x)
1826  """
1827  return _mk_quantifier(True, vs, body, weight, qid, skid, patterns, no_patterns)
1828 
def ForAll(vs, body, weight=1, qid="", skid="", patterns=[], no_patterns=[])
Definition: z3py.py:1810
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 8207 of file z3py.py.

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

8207 def FP(name, fpsort, ctx=None):
8208  """Return a floating-point constant named `name`.
8209  `fpsort` is the floating-point sort.
8210  If `ctx=None`, then the global context is used.
8211 
8212  >>> x = FP('x', FPSort(8, 24))
8213  >>> is_fp(x)
8214  True
8215  >>> x.ebits()
8216  8
8217  >>> x.sort()
8218  FPSort(8, 24)
8219  >>> word = FPSort(8, 24)
8220  >>> x2 = FP('x', word)
8221  >>> eq(x, x2)
8222  True
8223  """
8224  if isinstance(fpsort, FPSortRef):
8225  ctx = fpsort.ctx
8226  else:
8227  ctx = _get_ctx(ctx)
8228  return FPRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), fpsort.ast), ctx)
8229 
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:94
FP Expressions.
Definition: z3py.py:7800
def FP(name, fpsort, ctx=None)
Definition: z3py.py:8207
def z3py.fpAbs (   a)
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 8248 of file z3py.py.

8248 def fpAbs(a):
8249  """Create a Z3 floating-point absolute value expression.
8250 
8251  >>> s = FPSort(8, 24)
8252  >>> rm = RNE()
8253  >>> x = FPVal(1.0, s)
8254  >>> fpAbs(x)
8255  fpAbs(1)
8256  >>> y = FPVal(-20.0, s)
8257  >>> y
8258  -1.25*(2**4)
8259  >>> fpAbs(y)
8260  fpAbs(-1.25*(2**4))
8261  >>> fpAbs(-1.25*(2**4))
8262  fpAbs(-1.25*(2**4))
8263  >>> fpAbs(x).sort()
8264  FPSort(8, 24)
8265  """
8266  ctx = None
8267  if not is_expr(a):
8268  ctx =_get_ctx(ctx)
8269  s = get_default_fp_sort(ctx)
8270  a = FPVal(a, s)
8271  else:
8272  ctx = a.ctx
8273  if __debug__:
8274  _z3_assert(is_fp(a), "First argument must be Z3 floating-point expression")
8275  return FPRef(Z3_mk_fpa_abs(a.ctx_ref(), a.as_ast()), a.ctx)
8276 
def FPVal(sig, exp=None, fps=None, ctx=None)
Definition: z3py.py:8178
FP Expressions.
Definition: z3py.py:7800
def fpAbs(a)
Definition: z3py.py:8248
Z3_ast Z3_API Z3_mk_fpa_abs(Z3_context c, Z3_ast t)
Floating-point absolute value.
def get_default_fp_sort(ctx=None)
Definition: z3py.py:7681
def is_expr(a)
Definition: z3py.py:961
def is_fp(a)
Definition: z3py.py:8092
def z3py.fpAdd (   rm,
  a,
  b 
)
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(rm, x, y).sort()
FPSort(8, 24)

Definition at line 8299 of file z3py.py.

Referenced by FPs().

8299 def fpAdd(rm, a, b):
8300  """Create a Z3 floating-point addition expression.
8301 
8302  >>> s = FPSort(8, 24)
8303  >>> rm = RNE()
8304  >>> x = FP('x', s)
8305  >>> y = FP('y', s)
8306  >>> fpAdd(rm, x, y)
8307  fpAdd(RNE(), x, y)
8308  >>> fpAdd(rm, x, y).sort()
8309  FPSort(8, 24)
8310  """
8311  if __debug__:
8312  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
8313  _z3_assert(is_fp(a) or is_fp(b), "Second or third argument must be a Z3 floating-point expression")
8314  a, b = _coerce_exprs(a, b)
8315  return FPRef(Z3_mk_fpa_add(rm.ctx_ref(), rm.as_ast(), a.as_ast(), b.as_ast()), rm.ctx)
8316 
def fpAdd(rm, a, b)
Definition: z3py.py:8299
FP Expressions.
Definition: z3py.py:7800
Z3_ast Z3_API Z3_mk_fpa_add(Z3_context c, Z3_ast rm, Z3_ast t1, Z3_ast t2)
Floating-point addition.
def is_fprm(a)
Definition: z3py.py:7996
def is_fp(a)
Definition: z3py.py:8092
def z3py.fpDiv (   rm,
  a,
  b 
)
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 8353 of file z3py.py.

8353 def fpDiv(rm, a, b):
8354  """Create a Z3 floating-point divison expression.
8355 
8356  >>> s = FPSort(8, 24)
8357  >>> rm = RNE()
8358  >>> x = FP('x', s)
8359  >>> y = FP('y', s)
8360  >>> fpDiv(rm, x, y)
8361  fpDiv(RNE(), x, y)
8362  >>> fpDiv(rm, x, y).sort()
8363  FPSort(8, 24)
8364  """
8365  if __debug__:
8366  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
8367  _z3_assert(is_fp(a) or is_fp(b), "Second or third argument must be a Z3 floating-point expression")
8368  a, b = _coerce_exprs(a, b)
8369  return FPRef(Z3_mk_fpa_div(rm.ctx_ref(), rm.as_ast(), a.as_ast(), b.as_ast()), rm.ctx)
8370 
FP Expressions.
Definition: z3py.py:7800
Z3_ast Z3_API Z3_mk_fpa_div(Z3_context c, Z3_ast rm, Z3_ast t1, Z3_ast t2)
Floating-point division.
def fpDiv(rm, a, b)
Definition: z3py.py:8353
def is_fprm(a)
Definition: z3py.py:7996
def is_fp(a)
Definition: z3py.py:8092
def z3py.fpEQ (   a,
  b 
)
Create the Z3 floating-point expression `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 8568 of file z3py.py.

Referenced by fpNEQ().

8568 def fpEQ(a, b):
8569  """Create the Z3 floating-point expression `other <= self`.
8570 
8571  >>> x, y = FPs('x y', FPSort(8, 24))
8572  >>> fpEQ(x, y)
8573  fpEQ(x, y)
8574  >>> fpEQ(x, y).sexpr()
8575  '(fp.eq x y)'
8576  """
8577  _check_fp_args(a, b)
8578  a, b = _coerce_exprs(a, b)
8579  return BoolRef(Z3_mk_fpa_eq(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
8580 
def fpEQ(a, b)
Definition: z3py.py:8568
Z3_ast Z3_API Z3_mk_fpa_eq(Z3_context c, Z3_ast t1, Z3_ast t2)
Floating-point equality.
def z3py.fpFMA (   rm,
  a,
  b,
  c 
)
Create a Z3 floating-point fused multiply-add expression.

Definition at line 8421 of file z3py.py.

8421 def fpFMA(rm, a, b, c):
8422  """Create a Z3 floating-point fused multiply-add expression.
8423  """
8424  if __debug__:
8425  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
8426  _z3_assert(is_fp(a) or is_fp(b) or is_fp(c), "Second, third, or fourth argument must be a Z3 floating-point expression")
8427  a, b, c = _coerce_expr_list([a, b, c])
8428  return FPRef(Z3_mk_fpa_fma(rm.ctx_ref(), rm.as_ast(), a.as_ast(), b.as_ast(), c.as_ast()), rm.ctx)
8429 
Z3_ast Z3_API Z3_mk_fpa_fma(Z3_context c, Z3_ast rm, Z3_ast t1, Z3_ast t2, Z3_ast t3)
Floating-point fused multiply-add.
FP Expressions.
Definition: z3py.py:7800
def fpFMA(rm, a, b, c)
Definition: z3py.py:8421
def is_fprm(a)
Definition: z3py.py:7996
def is_fp(a)
Definition: z3py.py:8092
def z3py.fpFP (   sgn,
  exp,
  sig 
)
Create the Z3 floating-point value `fpFP(sgn, sig, exp)` from the three bit-vectorssgn, sig, and exp.

Definition at line 8596 of file z3py.py.

8596 def fpFP(sgn, exp, sig):
8597  """Create the Z3 floating-point value `fpFP(sgn, sig, exp)` from the three bit-vectorssgn, sig, and exp."""
8598  _z3_assert(is_bv(sgn) and is_bv(exp) and is_bv(sig), "sort mismatch")
8599  _z3_assert(sgn.sort().size() == 1, "sort mismatch")
8600  return FPRef(Z3_mk_fpa_fp(sgn.ctx_ref(), sgn.ast, exp.ast, sig.ast), sgn.ctx)
8601 
8602 
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.
FP Expressions.
Definition: z3py.py:7800
def fpFP(sgn, exp, sig)
Definition: z3py.py:8596
def is_bv(a)
Definition: z3py.py:3415
def z3py.fpGEQ (   a,
  b 
)
Create the Z3 floating-point expression `other <= self`.

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

Definition at line 8553 of file z3py.py.

8553 def fpGEQ(a, b):
8554  """Create the Z3 floating-point expression `other <= self`.
8555 
8556  >>> x, y = FPs('x y', FPSort(8, 24))
8557  >>> x + y
8558  x + y
8559  >>> fpGEQ(x, y)
8560  x >= y
8561  >>> (x >= y).sexpr()
8562  '(fp.geq x y)'
8563  """
8564  _check_fp_args(a, b)
8565  a, b = _coerce_exprs(a, b)
8566  return BoolRef(Z3_mk_fpa_geq(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
8567 
def fpGEQ(a, b)
Definition: z3py.py:8553
Z3_ast Z3_API Z3_mk_fpa_geq(Z3_context c, Z3_ast t1, Z3_ast t2)
Floating-point greater than or equal.
def z3py.fpGT (   a,
  b 
)
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 8539 of file z3py.py.

8539 def fpGT(a, b):
8540  """Create the Z3 floating-point expression `other <= self`.
8541 
8542  >>> x, y = FPs('x y', FPSort(8, 24))
8543  >>> fpGT(x, y)
8544  x > y
8545  >>> (x > y).sexpr()
8546  '(fp.gt x y)'
8547  """
8548  _check_fp_args(a, b)
8549  a, b = _coerce_exprs(a, b)
8550  return BoolRef(Z3_mk_fpa_gt(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
8551 
8552 
def fpGT(a, b)
Definition: z3py.py:8539
Z3_ast Z3_API Z3_mk_fpa_gt(Z3_context c, Z3_ast t1, Z3_ast t2)
Floating-point greater than.
def z3py.fpInfinity (   s,
  negative 
)

Definition at line 8160 of file z3py.py.

8160 def fpInfinity(s, negative):
8161  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
8162  _z3_assert(isinstance(negative, bool), "expected Boolean flag")
8163  return FPNumRef(Z3_mk_fpa_inf(s.ctx_ref(), s.ast, negative), s.ctx)
8164 
FP Numerals.
Definition: z3py.py:8014
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:8160
def z3py.fpIsInfinite (   a)
Create a Z3 floating-point isNaN expression.

Definition at line 8467 of file z3py.py.

8468  """Create a Z3 floating-point isNaN expression.
8469  """
8470  if __debug__:
8471  _z3_assert(is_fp(a), "Argument must be Z3 floating-point expressions")
8472  return FPRef(Z3_mk_fpa_is_infinite(a.ctx_ref(), a.as_ast()), a.ctx)
8473 
FP Expressions.
Definition: z3py.py:7800
def fpIsInfinite(a)
Definition: z3py.py:8467
Z3_ast Z3_API Z3_mk_fpa_is_infinite(Z3_context c, Z3_ast t)
Predicate indicating whether t is a floating-point number representing +oo or -oo.
def is_fp(a)
Definition: z3py.py:8092
def z3py.fpIsNaN (   a)
Create a Z3 floating-point isNaN expression.

Definition at line 8460 of file z3py.py.

8460 def fpIsNaN(a):
8461  """Create a Z3 floating-point isNaN expression.
8462  """
8463  if __debug__:
8464  _z3_assert(is_fp(a), "Argument must be Z3 floating-point expressions")
8465  return FPRef(Z3_mk_fpa_is_nan(a.ctx_ref(), a.as_ast()), a.ctx)
8466 
FP Expressions.
Definition: z3py.py:7800
def fpIsNaN(a)
Definition: z3py.py:8460
Z3_ast Z3_API Z3_mk_fpa_is_nan(Z3_context c, Z3_ast t)
Predicate indicating whether t is a NaN.
def is_fp(a)
Definition: z3py.py:8092
def z3py.fpIsNegative (   a)
Create a Z3 floating-point isNaN expression.

Definition at line 8495 of file z3py.py.

8496  """Create a Z3 floating-point isNaN expression.
8497  """
8498  if __debug__:
8499  _z3_assert(is_fp(a), "Argument must be Z3 floating-point expressions")
8500  return FPRef(Z3_mk_fpa_is_negative(a.ctx_ref(), a.as_ast()), a.ctx)
8501 
FP Expressions.
Definition: z3py.py:7800
Z3_ast Z3_API Z3_mk_fpa_is_negative(Z3_context c, Z3_ast t)
Predicate indicating whether t is a negative floating-point number.
def fpIsNegative(a)
Definition: z3py.py:8495
def is_fp(a)
Definition: z3py.py:8092
def z3py.fpIsNormal (   a)
Create a Z3 floating-point isNaN expression.

Definition at line 8481 of file z3py.py.

8481 def fpIsNormal(a):
8482  """Create a Z3 floating-point isNaN expression.
8483  """
8484  if __debug__:
8485  _z3_assert(is_fp(a), "Argument must be Z3 floating-point expressions")
8486  return FPRef(Z3_mk_fpa_is_normal(a.ctx_ref(), a.as_ast()), a.ctx)
8487 
def fpIsNormal(a)
Definition: z3py.py:8481
FP Expressions.
Definition: z3py.py:7800
Z3_ast Z3_API Z3_mk_fpa_is_normal(Z3_context c, Z3_ast t)
Predicate indicating whether t is a normal floating-point number.
def is_fp(a)
Definition: z3py.py:8092
def z3py.fpIsPositive (   a)
Create a Z3 floating-point isNaN expression.

Definition at line 8502 of file z3py.py.

8503  """Create a Z3 floating-point isNaN expression.
8504  """
8505  if __debug__:
8506  _z3_assert(is_fp(a), "Argument must be Z3 floating-point expressions")
8507  return FPRef(Z3_mk_fpa_is_positive(a.ctx_ref(), a.as_ast()), a.ctx)
8508 
def fpIsPositive(a)
Definition: z3py.py:8502
FP Expressions.
Definition: z3py.py:7800
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 is_fp(a)
Definition: z3py.py:8092
def z3py.fpIsSubnormal (   a)
Create a Z3 floating-point isNaN expression.

Definition at line 8488 of file z3py.py.

8489  """Create a Z3 floating-point isNaN expression.
8490  """
8491  if __debug__:
8492  _z3_assert(is_fp(a), "Argument must be Z3 floating-point expressions")
8493  return FPRef(Z3_mk_fpa_is_subnormal(a.ctx_ref(), a.as_ast()), a.ctx)
8494 
FP Expressions.
Definition: z3py.py:7800
Z3_ast Z3_API Z3_mk_fpa_is_subnormal(Z3_context c, Z3_ast t)
Predicate indicating whether t is a subnormal floating-point number.
def fpIsSubnormal(a)
Definition: z3py.py:8488
def is_fp(a)
Definition: z3py.py:8092
def z3py.fpIsZero (   a)
Create a Z3 floating-point isNaN expression.

Definition at line 8474 of file z3py.py.

8474 def fpIsZero(a):
8475  """Create a Z3 floating-point isNaN expression.
8476  """
8477  if __debug__:
8478  _z3_assert(is_fp(a), "Argument must be Z3 floating-point expressions")
8479  return FPRef(Z3_mk_fpa_is_zero(a.ctx_ref(), a.as_ast()), a.ctx)
8480 
Z3_ast Z3_API Z3_mk_fpa_is_zero(Z3_context c, Z3_ast t)
Predicate indicating whether t is a floating-point number with zero value, i.e., +zero or -zero...
FP Expressions.
Definition: z3py.py:7800
def fpIsZero(a)
Definition: z3py.py:8474
def is_fp(a)
Definition: z3py.py:8092
def z3py.fpLEQ (   a,
  b 
)
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 8526 of file z3py.py.

8526 def fpLEQ(a, b):
8527  """Create the Z3 floating-point expression `other <= self`.
8528 
8529  >>> x, y = FPs('x y', FPSort(8, 24))
8530  >>> fpLEQ(x, y)
8531  x <= y
8532  >>> (x <= y).sexpr()
8533  '(fp.leq x y)'
8534  """
8535  _check_fp_args(a, b)
8536  a, b = _coerce_exprs(a, b)
8537  return BoolRef(Z3_mk_fpa_leq(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
8538 
def fpLEQ(a, b)
Definition: z3py.py:8526
Z3_ast Z3_API Z3_mk_fpa_leq(Z3_context c, Z3_ast t1, Z3_ast t2)
Floating-point less than or equal.
def z3py.fpLT (   a,
  b 
)
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.leq x y)'

Definition at line 8513 of file z3py.py.

8513 def fpLT(a, b):
8514  """Create the Z3 floating-point expression `other <= self`.
8515 
8516  >>> x, y = FPs('x y', FPSort(8, 24))
8517  >>> fpLT(x, y)
8518  x < y
8519  >>> (x <= y).sexpr()
8520  '(fp.leq x y)'
8521  """
8522  _check_fp_args(a, b)
8523  a, b = _coerce_exprs(a, b)
8524  return BoolRef(Z3_mk_fpa_lt(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
8525 
def fpLT(a, b)
Definition: z3py.py:8513
Z3_ast Z3_API Z3_mk_fpa_lt(Z3_context c, Z3_ast t1, Z3_ast t2)
Floating-point less than.
def z3py.fpMax (   a,
  b 
)
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 8404 of file z3py.py.

8404 def fpMax(a, b):
8405  """Create a Z3 floating-point maximum expression.
8406 
8407  >>> s = FPSort(8, 24)
8408  >>> rm = RNE()
8409  >>> x = FP('x', s)
8410  >>> y = FP('y', s)
8411  >>> fpMax(x, y)
8412  fpMax(x, y)
8413  >>> fpMax(x, y).sort()
8414  FPSort(8, 24)
8415  """
8416  if __debug__:
8417  _z3_assert(is_fp(a) or is_fp(b), "Second or third argument must be a Z3 floating-point expression")
8418  a, b = _coerce_exprs(a, b)
8419  return FPRef(Z3_mk_fpa_max(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
8420 
FP Expressions.
Definition: z3py.py:7800
Z3_ast Z3_API Z3_mk_fpa_max(Z3_context c, Z3_ast t1, Z3_ast t2)
Maximum of floating-point numbers.
def fpMax(a, b)
Definition: z3py.py:8404
def is_fp(a)
Definition: z3py.py:8092
def z3py.fpMin (   a,
  b 
)
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 8387 of file z3py.py.

8387 def fpMin(a, b):
8388  """Create a Z3 floating-point minimium expression.
8389 
8390  >>> s = FPSort(8, 24)
8391  >>> rm = RNE()
8392  >>> x = FP('x', s)
8393  >>> y = FP('y', s)
8394  >>> fpMin(x, y)
8395  fpMin(x, y)
8396  >>> fpMin(x, y).sort()
8397  FPSort(8, 24)
8398  """
8399  if __debug__:
8400  _z3_assert(is_fp(a) or is_fp(b), "Second or third argument must be a Z3 floating-point expression")
8401  a, b = _coerce_exprs(a, b)
8402  return FPRef(Z3_mk_fpa_min(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
8403 
FP Expressions.
Definition: z3py.py:7800
def fpMin(a, b)
Definition: z3py.py:8387
Z3_ast Z3_API Z3_mk_fpa_min(Z3_context c, Z3_ast t1, Z3_ast t2)
Minimum of floating-point numbers.
def is_fp(a)
Definition: z3py.py:8092
def z3py.fpMinusInfinity (   s)

Definition at line 8156 of file z3py.py.

8157  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
8158  return FPNumRef(Z3_mk_fpa_inf(s.ctx_ref(), s.ast, True), s.ctx)
8159 
def fpMinusInfinity(s)
Definition: z3py.py:8156
FP Numerals.
Definition: z3py.py:8014
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 z3py.fpMinusZero (   s)

Definition at line 8169 of file z3py.py.

8170  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
8171  return FPNumRef(Z3_mk_fpa_zero(s.ctx_ref(), s.ast, True), s.ctx)
8172 
def fpMinusZero(s)
Definition: z3py.py:8169
FP Numerals.
Definition: z3py.py:8014
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.
def z3py.fpMul (   rm,
  a,
  b 
)
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 8335 of file z3py.py.

Referenced by FPs().

8335 def fpMul(rm, a, b):
8336  """Create a Z3 floating-point multiplication expression.
8337 
8338  >>> s = FPSort(8, 24)
8339  >>> rm = RNE()
8340  >>> x = FP('x', s)
8341  >>> y = FP('y', s)
8342  >>> fpMul(rm, x, y)
8343  fpMul(RNE(), x, y)
8344  >>> fpMul(rm, x, y).sort()
8345  FPSort(8, 24)
8346  """
8347  if __debug__:
8348  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
8349  _z3_assert(is_fp(a) or is_fp(b), "Second or third argument must be a Z3 floating-point expression")
8350  a, b = _coerce_exprs(a, b)
8351  return FPRef(Z3_mk_fpa_mul(rm.ctx_ref(), rm.as_ast(), a.as_ast(), b.as_ast()), rm.ctx)
8352 
FP Expressions.
Definition: z3py.py:7800
Z3_ast Z3_API Z3_mk_fpa_mul(Z3_context c, Z3_ast rm, Z3_ast t1, Z3_ast t2)
Floating-point multiplication.
def fpMul(rm, a, b)
Definition: z3py.py:8335
def is_fprm(a)
Definition: z3py.py:7996
def is_fp(a)
Definition: z3py.py:8092
def z3py.fpNaN (   s)

Definition at line 8148 of file z3py.py.

8148 def fpNaN(s):
8149  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
8150  return FPNumRef(Z3_mk_fpa_nan(s.ctx_ref(), s.ast), s.ctx)
8151 
def fpNaN(s)
Definition: z3py.py:8148
FP Numerals.
Definition: z3py.py:8014
Z3_ast Z3_API Z3_mk_fpa_nan(Z3_context c, Z3_sort s)
Create a floating-point NaN of sort s.
def z3py.fpNeg (   a)
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 8277 of file z3py.py.

8277 def fpNeg(a):
8278  """Create a Z3 floating-point addition expression.
8279 
8280  >>> s = FPSort(8, 24)
8281  >>> rm = RNE()
8282  >>> x = FP('x', s)
8283  >>> fpNeg(x)
8284  -x
8285  >>> fpNeg(x).sort()
8286  FPSort(8, 24)
8287  """
8288  ctx = None
8289  if not is_expr(a):
8290  ctx =_get_ctx(ctx)
8291  s = get_default_fp_sort(ctx)
8292  a = FPVal(a, s)
8293  else:
8294  ctx = a.ctx
8295  if __debug__:
8296  _z3_assert(is_fp(a), "First argument must be Z3 floating-point expression")
8297  return FPRef(Z3_mk_fpa_neg(a.ctx_ref(), a.as_ast()), a.ctx)
8298 
def FPVal(sig, exp=None, fps=None, ctx=None)
Definition: z3py.py:8178
FP Expressions.
Definition: z3py.py:7800
def get_default_fp_sort(ctx=None)
Definition: z3py.py:7681
Z3_ast Z3_API Z3_mk_fpa_neg(Z3_context c, Z3_ast t)
Floating-point negation.
def fpNeg(a)
Definition: z3py.py:8277
def is_expr(a)
Definition: z3py.py:961
def is_fp(a)
Definition: z3py.py:8092
def z3py.fpNEQ (   a,
  b 
)
Create the Z3 floating-point expression `other <= self`.

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

Definition at line 8581 of file z3py.py.

8581 def fpNEQ(a, b):
8582  """Create the Z3 floating-point expression `other <= self`.
8583 
8584  >>> x, y = FPs('x y', FPSort(8, 24))
8585  >>> fpNEQ(x, y)
8586  Not(fpEQ(x, y))
8587  >>> (x != y).sexpr()
8588  '(not (fp.eq x y))'
8589  """
8590  _check_fp_args(a, b)
8591  a, b = _coerce_exprs(a, b)
8592  return Not(BoolRef(Z3_mk_fpa_eq(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx), a.ctx)
8593 
8594 
8595 
def fpNEQ(a, b)
Definition: z3py.py:8581
Z3_ast Z3_API Z3_mk_fpa_eq(Z3_context c, Z3_ast t1, Z3_ast t2)
Floating-point equality.
def Not(a, ctx=None)
Definition: z3py.py:1464
def z3py.fpPlusInfinity (   s)

Definition at line 8152 of file z3py.py.

8153  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
8154  return FPNumRef(Z3_mk_fpa_inf(s.ctx_ref(), s.ast, False), s.ctx)
8155 
def fpPlusInfinity(s)
Definition: z3py.py:8152
FP Numerals.
Definition: z3py.py:8014
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 z3py.fpPlusZero (   s)

Definition at line 8165 of file z3py.py.

8165 def fpPlusZero(s):
8166  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
8167  return FPNumRef(Z3_mk_fpa_zero(s.ctx_ref(), s.ast, False), s.ctx)
8168 
def fpPlusZero(s)
Definition: z3py.py:8165
FP Numerals.
Definition: z3py.py:8014
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.
def z3py.fpRem (   a,
  b 
)
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 8371 of file z3py.py.

8371 def fpRem(a, b):
8372  """Create a Z3 floating-point remainder expression.
8373 
8374  >>> s = FPSort(8, 24)
8375  >>> x = FP('x', s)
8376  >>> y = FP('y', s)
8377  >>> fpRem(x, y)
8378  fpRem(x, y)
8379  >>> fpRem(x, y).sort()
8380  FPSort(8, 24)
8381  """
8382  if __debug__:
8383  _z3_assert(is_fp(a) or is_fp(b), "Second or third argument must be a Z3 floating-point expression")
8384  a, b = _coerce_exprs(a, b)
8385  return FPRef(Z3_mk_fpa_rem(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
8386 
FP Expressions.
Definition: z3py.py:7800
def fpRem(a, b)
Definition: z3py.py:8371
Z3_ast Z3_API Z3_mk_fpa_rem(Z3_context c, Z3_ast t1, Z3_ast t2)
Floating-point remainder.
def is_fp(a)
Definition: z3py.py:8092
def z3py.fpRoundToIntegral (   rm,
  a 
)
Create a Z3 floating-point roundToIntegral expression.

Definition at line 8445 of file z3py.py.

8446  """Create a Z3 floating-point roundToIntegral expression.
8447  """
8448  ctx = None
8449  if not is_expr(a):
8450  ctx =_get_ctx(ctx)
8451  s = get_default_fp_sort(ctx)
8452  a = FPVal(a, s)
8453  else:
8454  ctx = a.ctx
8455  if __debug__:
8456  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
8457  _z3_assert(is_fp(a), "Second argument must be a Z3 floating-point expressions")
8458  return FPRef(Z3_mk_fpa_round_to_integral(rm.ctx_ref(), rm.as_ast(), a.as_ast()), rm.ctx)
8459 
def fpRoundToIntegral(rm, a)
Definition: z3py.py:8445
def FPVal(sig, exp=None, fps=None, ctx=None)
Definition: z3py.py:8178
Z3_ast Z3_API Z3_mk_fpa_round_to_integral(Z3_context c, Z3_ast rm, Z3_ast t)
Floating-point roundToIntegral. Rounds a floating-point number to the closest integer, again represented as a floating-point number.
FP Expressions.
Definition: z3py.py:7800
def get_default_fp_sort(ctx=None)
Definition: z3py.py:7681
def is_expr(a)
Definition: z3py.py:961
def is_fprm(a)
Definition: z3py.py:7996
def is_fp(a)
Definition: z3py.py:8092
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 8230 of file z3py.py.

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

8230 def FPs(names, fpsort, ctx=None):
8231  """Return an array of floating-point constants.
8232 
8233  >>> x, y, z = FPs('x y z', FPSort(8, 24))
8234  >>> x.sort()
8235  FPSort(8, 24)
8236  >>> x.sbits()
8237  24
8238  >>> x.ebits()
8239  8
8240  >>> fpMul(RNE(), fpAdd(RNE(), x, y), z)
8241  fpMul(RNE(), fpAdd(RNE(), x, y), z)
8242  """
8243  ctx = z3._get_ctx(ctx)
8244  if isinstance(names, str):
8245  names = names.split(" ")
8246  return [FP(name, fpsort, ctx) for name in names]
8247 
def FPs(names, fpsort, ctx=None)
Definition: z3py.py:8230
def FP(name, fpsort, ctx=None)
Definition: z3py.py:8207
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 8119 of file z3py.py.

Referenced by FPRef.__add__(), FPRef.__mul__(), FPRef.__radd__(), FPRef.__rmul__(), FPRef.__rsub__(), FPRef.__sub__(), FPSortRef.cast(), FPSortRef.ebits(), FPRef.ebits(), FPNumRef.exponent(), FPNumRef.exponent_as_long(), FP(), fpAbs(), fpAdd(), fpDiv(), fpEQ(), fpGEQ(), fpGT(), fpLEQ(), fpLT(), fpMax(), fpMin(), fpMul(), fpNeg(), fpNEQ(), fpRem(), FPs(), fpSub(), fpToIEEEBV(), fpToReal(), fpToSBV(), fpToUBV(), FPVal(), is_fp(), is_fp_sort(), is_fp_value(), is_fprm_sort(), FPNumRef.isNegative(), Context.MkFPRTZ(), Context.mkFPSort(), Context.mkFPSort128(), Context.MkFPSort128(), Context.mkFPSort16(), Context.MkFPSort16(), Context.mkFPSort32(), Context.MkFPSort32(), Context.mkFPSort64(), Context.MkFPSort64(), Context.mkFPSortDouble(), Context.MkFPSortDouble(), Context.mkFPSortHalf(), Context.MkFPSortHalf(), Context.mkFPSortQuadruple(), Context.MkFPSortQuadruple(), Context.mkFPSortSingle(), Context.MkFPSortSingle(), FPSortRef.sbits(), FPRef.sbits(), FPNumRef.sign(), FPNumRef.significand(), FPRef.sort(), Sort.toString(), and Sort.ToString().

8119 def FPSort(ebits, sbits, ctx=None):
8120  """Return a Z3 floating-point sort of the given sizes. If `ctx=None`, then the global context is used.
8121 
8122  >>> Single = FPSort(8, 24)
8123  >>> Double = FPSort(11, 53)
8124  >>> Single
8125  FPSort(8, 24)
8126  >>> x = Const('x', Single)
8127  >>> eq(x, FP('x', FPSort(8, 24)))
8128  True
8129  """
8130  ctx = z3._get_ctx(ctx)
8131  return FPSortRef(Z3_mk_fpa_sort(ctx.ref(), ebits, sbits), ctx)
8132 
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:8119
FP Sorts.
Definition: z3py.py:7698
def z3py.fpSqrt (   rm,
  a 
)
Create a Z3 floating-point square root expression.

Definition at line 8430 of file z3py.py.

8430 def fpSqrt(rm, a):
8431  """Create a Z3 floating-point square root expression.
8432  """
8433  ctx = None
8434  if not is_expr(a):
8435  ctx =_get_ctx(ctx)
8436  s = get_default_fp_sort(ctx)
8437  a = FPVal(a, s)
8438  else:
8439  ctx = a.ctx
8440  if __debug__:
8441  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
8442  _z3_assert(is_fp(a), "Second argument must be a Z3 floating-point expressions")
8443  return FPRef(Z3_mk_fpa_sqrt(rm.ctx_ref(), rm.as_ast(), a.as_ast()), rm.ctx)
8444 
def FPVal(sig, exp=None, fps=None, ctx=None)
Definition: z3py.py:8178
FP Expressions.
Definition: z3py.py:7800
def fpSqrt(rm, a)
Definition: z3py.py:8430
def get_default_fp_sort(ctx=None)
Definition: z3py.py:7681
def is_expr(a)
Definition: z3py.py:961
Z3_ast Z3_API Z3_mk_fpa_sqrt(Z3_context c, Z3_ast rm, Z3_ast t)
Floating-point square root.
def is_fprm(a)
Definition: z3py.py:7996
def is_fp(a)
Definition: z3py.py:8092
def z3py.fpSub (   rm,
  a,
  b 
)
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 8317 of file z3py.py.

8317 def fpSub(rm, a, b):
8318  """Create a Z3 floating-point subtraction expression.
8319 
8320  >>> s = FPSort(8, 24)
8321  >>> rm = RNE()
8322  >>> x = FP('x', s)
8323  >>> y = FP('y', s)
8324  >>> fpSub(rm, x, y)
8325  fpSub(RNE(), x, y)
8326  >>> fpSub(rm, x, y).sort()
8327  FPSort(8, 24)
8328  """
8329  if __debug__:
8330  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
8331  _z3_assert(is_fp(a) or is_fp(b), "Second or third argument must be a Z3 floating-point expression")
8332  a, b = _coerce_exprs(a, b)
8333  return FPRef(Z3_mk_fpa_sub(rm.ctx_ref(), rm.as_ast(), a.as_ast(), b.as_ast()), rm.ctx)
8334 
FP Expressions.
Definition: z3py.py:7800
def fpSub(rm, a, b)
Definition: z3py.py:8317
Z3_ast Z3_API Z3_mk_fpa_sub(Z3_context c, Z3_ast rm, Z3_ast t1, Z3_ast t2)
Floating-point subtraction.
def is_fprm(a)
Definition: z3py.py:7996
def is_fp(a)
Definition: z3py.py:8092
def z3py.fpToFP (   a1,
  a2 = None,
  a3 = None 
)
Create a Z3 floating-point conversion expression from other terms.

Definition at line 8603 of file z3py.py.

8603 def fpToFP(a1, a2=None, a3=None):
8604  """Create a Z3 floating-point conversion expression from other terms."""
8605  if is_bv(a1) and is_fp_sort(a2):
8606  return FPRef(Z3_mk_fpa_to_fp_bv(a1.ctx_ref(), a1.ast, a2.ast), a1.ctx)
8607  elif is_fprm(a1) and is_fp(a2) and is_fp_sort(a3):
8608  return FPRef(Z3_mk_fpa_to_fp_float(a1.ctx_ref(), a1.ast, a2.ast, a3.ast), a1.ctx)
8609  elif is_fprm(a1) and is_real(a2) and is_fp_sort(a3):
8610  return FPRef(Z3_mk_fpa_to_fp_real(a1.ctx_ref(), a1.ast, a2.ast, a3.ast), a1.ctx)
8611  elif is_fprm(a1) and is_bv(a2) and is_fp_sort(a3):
8612  return FPRef(Z3_mk_fpa_to_fp_signed(a1.ctx_ref(), a1.ast, a2.ast, a3.ast), a1.ctx)
8613  else:
8614  raise Z3Exception("Unsupported combination of arguments for conversion to floating-point term.")
8615 
FP Expressions.
Definition: z3py.py:7800
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 fpToFP(a1, a2=None, a3=None)
Definition: z3py.py:8603
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:2262
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:7778
def is_bv(a)
Definition: z3py.py:3415
def is_fprm(a)
Definition: z3py.py:7996
def is_fp(a)
Definition: z3py.py:8092
def z3py.fpToFPUnsigned (   rm,
  x,
  s 
)
Create a Z3 floating-point conversion expression, from unsigned bit-vector to floating-point expression.

Definition at line 8616 of file z3py.py.

8616 def fpToFPUnsigned(rm, x, s):
8617  """Create a Z3 floating-point conversion expression, from unsigned bit-vector to floating-point expression."""
8618  if __debug__:
8619  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
8620  _z3_assert(is_bv(x), "Second argument must be a Z3 bit-vector expression")
8621  _z3_assert(is_fp_sort(s), "Third argument must be Z3 floating-point sort")
8622  return FPRef(Z3_mk_fpa_to_fp_unsigned(rm.ctx_ref(), rm.ast, x.ast, s.ast), rm.ctx)
8623 
def fpToFPUnsigned(rm, x, s)
Definition: z3py.py:8616
FP Expressions.
Definition: z3py.py:7800
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:7778
def is_bv(a)
Definition: z3py.py:3415
def is_fprm(a)
Definition: z3py.py:7996
def z3py.fpToIEEEBV (   x)
\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 8682 of file z3py.py.

8682 def fpToIEEEBV(x):
8683  """\brief Conversion of a floating-point term into a bit-vector term in IEEE 754-2008 format.
8684 
8685  The size of the resulting bit-vector is automatically determined.
8686 
8687  Note that IEEE 754-2008 allows multiple different representations of NaN. This conversion
8688  knows only one NaN and it will always produce the same bit-vector represenatation of
8689  that NaN.
8690 
8691  >>> x = FP('x', FPSort(8, 24))
8692  >>> y = fpToIEEEBV(x)
8693  >>> print is_fp(x)
8694  True
8695  >>> print is_bv(y)
8696  True
8697  >>> print is_fp(y)
8698  False
8699  >>> print is_bv(x)
8700  False
8701  """
8702  if __debug__:
8703  _z3_assert(is_fp(x), "First argument must be a Z3 floating-point expression")
8704  return BitVecRef(Z3_mk_fpa_to_ieee_bv(x.ctx_ref(), x.ast), x.ctx)
8705 
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 fpToIEEEBV(x)
Definition: z3py.py:8682
def is_fp(a)
Definition: z3py.py:8092
def z3py.fpToReal (   x)
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 8664 of file z3py.py.

8664 def fpToReal(x):
8665  """Create a Z3 floating-point conversion expression, from floating-point expression to real.
8666 
8667  >>> x = FP('x', FPSort(8, 24))
8668  >>> y = fpToReal(x)
8669  >>> print is_fp(x)
8670  True
8671  >>> print is_real(y)
8672  True
8673  >>> print is_fp(y)
8674  False
8675  >>> print is_real(x)
8676  False
8677  """
8678  if __debug__:
8679  _z3_assert(is_fp(x), "First argument must be a Z3 floating-point expression")
8680  return ArithRef(Z3_mk_fpa_to_real(x.ctx_ref(), x.ast), x.ctx)
8681 
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)
Definition: z3py.py:8664
def is_fp(a)
Definition: z3py.py:8092
def z3py.fpToSBV (   rm,
  x,
  s 
)
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 8624 of file z3py.py.

8624 def fpToSBV(rm, x, s):
8625  """Create a Z3 floating-point conversion expression, from floating-point expression to signed bit-vector.
8626 
8627  >>> x = FP('x', FPSort(8, 24))
8628  >>> y = fpToSBV(RTZ(), x, BitVecSort(32))
8629  >>> print is_fp(x)
8630  True
8631  >>> print is_bv(y)
8632  True
8633  >>> print is_fp(y)
8634  False
8635  >>> print is_bv(x)
8636  False
8637  """
8638  if __debug__:
8639  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
8640  _z3_assert(is_fp(x), "Second argument must be a Z3 floating-point expression")
8641  _z3_assert(is_bv_sort(s), "Third argument must be Z3 bit-vector sort")
8642  return BitVecRef(Z3_mk_fpa_to_sbv(rm.ctx_ref(), rm.ast, x.ast, s.size()), rm.ctx)
8643 
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)
Definition: z3py.py:8624
def is_bv_sort(s)
Definition: z3py.py:2954
def is_fprm(a)
Definition: z3py.py:7996
def is_fp(a)
Definition: z3py.py:8092
def z3py.fpToUBV (   rm,
  x,
  s 
)
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 8644 of file z3py.py.

8644 def fpToUBV(rm, x, s):
8645  """Create a Z3 floating-point conversion expression, from floating-point expression to unsigned bit-vector.
8646 
8647  >>> x = FP('x', FPSort(8, 24))
8648  >>> y = fpToUBV(RTZ(), x, BitVecSort(32))
8649  >>> print is_fp(x)
8650  True
8651  >>> print is_bv(y)
8652  True
8653  >>> print is_fp(y)
8654  False
8655  >>> print is_bv(x)
8656  False
8657  """
8658  if __debug__:
8659  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
8660  _z3_assert(is_fp(x), "Second argument must be a Z3 floating-point expression")
8661  _z3_assert(is_bv_sort(s), "Third argument must be Z3 bit-vector sort")
8662  return BitVecRef(Z3_mk_fpa_to_ubv(rm.ctx_ref(), rm.ast, x.ast, s.size()), rm.ctx)
8663 
def fpToUBV(rm, x, s)
Definition: z3py.py:8644
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 is_bv_sort(s)
Definition: z3py.py:2954
def is_fprm(a)
Definition: z3py.py:7996
def is_fp(a)
Definition: z3py.py:8092
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())
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)

Definition at line 8178 of file z3py.py.

Referenced by fpAbs(), fpNeg(), fpRoundToIntegral(), fpSqrt(), and is_fp_value().

8178 def FPVal(sig, exp=None, fps=None, ctx=None):
8179  """Return a floating-point value of value `val` and sort `fps`. If `ctx=None`, then the global context is used.
8180 
8181  >>> v = FPVal(20.0, FPSort(8, 24))
8182  >>> v
8183  1.25*(2**4)
8184  >>> print("0x%.8x" % v.exponent_as_long())
8185  0x00000004
8186  >>> v = FPVal(2.25, FPSort(8, 24))
8187  >>> v
8188  1.125*(2**1)
8189  >>> v = FPVal(-2.25, FPSort(8, 24))
8190  >>> v
8191  -1.125*(2**1)
8192  """
8193  ctx = _get_ctx(ctx)
8194  if is_fp_sort(exp):
8195  fps = exp
8196  exp = None
8197  elif fps == None:
8198  fps = _dflt_fps(ctx)
8199  _z3_assert(is_fp_sort(fps), "sort mismatch")
8200  if exp == None:
8201  exp = 0
8202  val = _to_float_str(sig)
8203  val = val + 'p'
8204  val = val + _to_int_str(exp)
8205  return FPNumRef(Z3_mk_numeral(ctx.ref(), val, fps.ast), ctx)
8206 
def FPVal(sig, exp=None, fps=None, ctx=None)
Definition: z3py.py:8178
FP Numerals.
Definition: z3py.py:8014
def is_fp_sort(s)
Definition: z3py.py:7778
Z3_ast Z3_API Z3_mk_numeral(Z3_context c, Z3_string numeral, Z3_sort ty)
Create a numeral of a given sort.
def z3py.fpZero (   s,
  negative 
)

Definition at line 8173 of file z3py.py.

8173 def fpZero(s, negative):
8174  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
8175  _z3_assert(isinstance(negative, bool), "expected Boolean flag")
8176  return FPNumRef(Z3_mk_fpa_zero(s.ctx_ref(), s.ast, negative), s.ctx)
8177 
def fpZero(s, negative)
Definition: z3py.py:8173
FP Numerals.
Definition: z3py.py:8014
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.
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 1421 of file z3py.py.

1421 def FreshBool(prefix='b', ctx=None):
1422  """Return a fresh Boolean constant in the given context using the given prefix.
1423 
1424  If `ctx=None`, then the global context is used.
1425 
1426  >>> b1 = FreshBool()
1427  >>> b2 = FreshBool()
1428  >>> eq(b1, b2)
1429  False
1430  """
1431  ctx = _get_ctx(ctx)
1432  return BoolRef(Z3_mk_fresh_const(ctx.ref(), prefix, BoolSort(ctx).ast), ctx)
1433 
def FreshBool(prefix='b', ctx=None)
Definition: z3py.py:1421
def BoolSort(ctx=None)
Definition: z3py.py:1346
Z3_ast Z3_API Z3_mk_fresh_const(Z3_context c, Z3_string prefix, Z3_sort ty)
Declare and create a fresh constant.
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 2777 of file z3py.py.

2777 def FreshInt(prefix='x', ctx=None):
2778  """Return a fresh integer constant in the given context using the given prefix.
2779 
2780  >>> x = FreshInt()
2781  >>> y = FreshInt()
2782  >>> eq(x, y)
2783  False
2784  >>> x.sort()
2785  Int
2786  """
2787  ctx = _get_ctx(ctx)
2788  return ArithRef(Z3_mk_fresh_const(ctx.ref(), prefix, IntSort(ctx).ast), ctx)
2789 
def IntSort(ctx=None)
Definition: z3py.py:2639
def FreshInt(prefix='x', ctx=None)
Definition: z3py.py:2777
Z3_ast Z3_API Z3_mk_fresh_const(Z3_context c, Z3_string prefix, Z3_sort ty)
Declare and create a fresh constant.
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 2829 of file z3py.py.

2829 def FreshReal(prefix='b', ctx=None):
2830  """Return a fresh real constant in the given context using the given prefix.
2831 
2832  >>> x = FreshReal()
2833  >>> y = FreshReal()
2834  >>> eq(x, y)
2835  False
2836  >>> x.sort()
2837  Real
2838  """
2839  ctx = _get_ctx(ctx)
2840  return ArithRef(Z3_mk_fresh_const(ctx.ref(), prefix, RealSort(ctx).ast), ctx)
2841 
def FreshReal(prefix='b', ctx=None)
Definition: z3py.py:2829
def RealSort(ctx=None)
Definition: z3py.py:2655
Z3_ast Z3_API Z3_mk_fresh_const(Z3_context c, Z3_string prefix, Z3_sort ty)
Declare and create a fresh constant.
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 705 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().

705 def Function(name, *sig):
706  """Create a new Z3 uninterpreted function with the given sorts.
707 
708  >>> f = Function('f', IntSort(), IntSort())
709  >>> f(f(0))
710  f(f(0))
711  """
712  sig = _get_args(sig)
713  if __debug__:
714  _z3_assert(len(sig) > 0, "At least two arguments expected")
715  arity = len(sig) - 1
716  rng = sig[arity]
717  if __debug__:
718  _z3_assert(is_sort(rng), "Z3 sort expected")
719  dom = (Sort * arity)()
720  for i in range(arity):
721  if __debug__:
722  _z3_assert(is_sort(sig[i]), "Z3 sort expected")
723  dom[i] = sig[i].ast
724  ctx = rng.ctx
725  return FuncDeclRef(Z3_mk_func_decl(ctx.ref(), to_symbol(name, ctx), arity, dom, rng.ast), ctx)
726 
Function Declarations.
Definition: z3py.py:591
def Function(name, sig)
Definition: z3py.py:705
def to_symbol(s, ctx=None)
Definition: z3py.py:94
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:530
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 5593 of file z3py.py.

5594  """Return the function declaration f associated with a Z3 expression of the form (_ as-array f)."""
5595  if __debug__:
5596  _z3_assert(is_as_array(n), "as-array Z3 expression expected.")
5597  return FuncDeclRef(Z3_get_as_array_func_decl(n.ctx.ref(), n.as_ast()), n.ctx)
5598 
Function Declarations.
Definition: z3py.py:591
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:5593
def is_as_array(n)
Definition: z3py.py:5589
def z3py.get_default_fp_sort (   ctx = None)

Definition at line 7681 of file z3py.py.

Referenced by fpAbs(), fpNeg(), fpRoundToIntegral(), and fpSqrt().

7681 def get_default_fp_sort(ctx=None):
7682  return FPSort(_dflt_fpsort_ebits, _dflt_fpsort_sbits, ctx)
7683 
def FPSort(ebits, sbits, ctx=None)
Definition: z3py.py:8119
def get_default_fp_sort(ctx=None)
Definition: z3py.py:7681
def z3py.get_default_rounding_mode (   ctx = None)
Retrieves the global default rounding mode.

Definition at line 7654 of file z3py.py.

7655  """Retrieves the global default rounding mode."""
7656  global _dflt_rounding_mode
7657  if _dflt_rounding_mode == Z3_OP_FPA_RM_TOWARD_ZERO:
7658  return RTZ(ctx)
7659  elif _dflt_rounding_mode == Z3_OP_FPA_RM_TOWARD_NEGATIVE:
7660  return RTN(ctx)
7661  elif _dflt_rounding_mode == Z3_OP_FPA_RM_TOWARD_POSITIVE:
7662  return RTP(ctx)
7663  elif _dflt_rounding_mode == Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN:
7664  return RNE(ctx)
7665  elif _dflt_rounding_mode == Z3_OP_FPA_RM_NEAREST_TIES_TO_AWAY:
7666  return RNA(ctx)
7667 
def RTN(ctx=None)
Definition: z3py.py:7984
def RTZ(ctx=None)
Definition: z3py.py:7992
def RTP(ctx=None)
Definition: z3py.py:7976
def RNA(ctx=None)
Definition: z3py.py:7968
def get_default_rounding_mode(ctx=None)
Definition: z3py.py:7654
def RNE(ctx=None)
Definition: z3py.py:7960
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 3987 of file z3py.py.

3988  """Return the function declaration associated with a Z3 map array expression.
3989 
3990  >>> f = Function('f', IntSort(), IntSort())
3991  >>> b = Array('b', IntSort(), IntSort())
3992  >>> a = Map(f, b)
3993  >>> eq(f, get_map_func(a))
3994  True
3995  >>> get_map_func(a)
3996  f
3997  >>> get_map_func(a)(0)
3998  f(0)
3999  """
4000  if __debug__:
4001  _z3_assert(is_map(a), "Z3 array map expression expected.")
4002  return FuncDeclRef(Z3_to_func_decl(a.ctx_ref(), Z3_get_decl_ast_parameter(a.ctx_ref(), a.decl().ast, 0)), a.ctx)
4003 
Function Declarations.
Definition: z3py.py:591
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:3964
def get_map_func(a)
Definition: z3py.py:3987
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.
def z3py.get_param (   name)
Return the value of a Z3 global (or module) parameter

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

Definition at line 247 of file z3py.py.

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

1049  """Return the de-Bruijn index of the Z3 bounded variable `a`.
1050 
1051  >>> x = Int('x')
1052  >>> y = Int('y')
1053  >>> is_var(x)
1054  False
1055  >>> is_const(x)
1056  True
1057  >>> f = Function('f', IntSort(), IntSort(), IntSort())
1058  >>> # Z3 replaces x and y with bound variables when ForAll is executed.
1059  >>> q = ForAll([x, y], f(x, y) == x + y)
1060  >>> q.body()
1061  f(Var(1), Var(0)) == Var(1) + Var(0)
1062  >>> b = q.body()
1063  >>> b.arg(0)
1064  f(Var(1), Var(0))
1065  >>> v1 = b.arg(0).arg(0)
1066  >>> v2 = b.arg(0).arg(1)
1067  >>> v1
1068  Var(1)
1069  >>> v2
1070  Var(0)
1071  >>> get_var_index(v1)
1072  1
1073  >>> get_var_index(v2)
1074  0
1075  """
1076  if __debug__:
1077  _z3_assert(is_var(a), "Z3 bound variable expected")
1078  return int(Z3_get_index_value(a.ctx.ref(), a.as_ast()))
1079 
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:1048
def is_var(a)
Definition: z3py.py:1024
def z3py.get_version ( )

Definition at line 72 of file z3py.py.

73  major = ctypes.c_uint(0)
74  minor = ctypes.c_uint(0)
75  build = ctypes.c_uint(0)
76  rev = ctypes.c_uint(0)
77  Z3_get_version(major, minor, build, rev)
78  return (major.value, minor.value, build.value, rev.value)
79 
80 # We use _z3_assert instead of the assert command because we want to
81 # produce nice error messages in Z3Py at rise4fun.com
def get_version()
Definition: z3py.py:72
void Z3_API Z3_get_version(unsigned *major, unsigned *minor, unsigned *build_number, unsigned *revision_number)
Return Z3 version number information.
def z3py.get_version_string ( )

Definition at line 64 of file z3py.py.

65  major = ctypes.c_uint(0)
66  minor = ctypes.c_uint(0)
67  build = ctypes.c_uint(0)
68  rev = ctypes.c_uint(0)
69  Z3_get_version(major, minor, build, rev)
70  return "%s.%s.%s" % (major.value, minor.value, build.value)
71 
def get_version_string()
Definition: z3py.py:64
void Z3_API Z3_get_version(unsigned *major, unsigned *minor, unsigned *build_number, unsigned *revision_number)
Return Z3 version number information.
def z3py.help_simplify ( )
Return a string describing all options available for Z3 `simplify` procedure.

Definition at line 7202 of file z3py.py.

7203  """Return a string describing all options available for Z3 `simplify` procedure."""
7204  print(Z3_simplify_get_help(main_ctx().ref()))
7205 
def main_ctx()
Definition: z3py.py:188
def help_simplify()
Definition: z3py.py:7202
Z3_string Z3_API Z3_simplify_get_help(Z3_context c)
Return a string describing all available parameters.
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 1092 of file z3py.py.

1092 def If(a, b, c, ctx=None):
1093  """Create a Z3 if-then-else expression.
1094 
1095  >>> x = Int('x')
1096  >>> y = Int('y')
1097  >>> max = If(x > y, x, y)
1098  >>> max
1099  If(x > y, x, y)
1100  >>> simplify(max)
1101  If(x <= y, y, x)
1102  """
1103  if isinstance(a, Probe) or isinstance(b, Tactic) or isinstance(c, Tactic):
1104  return Cond(a, b, c, ctx)
1105  else:
1106  ctx = _get_ctx(_ctx_from_ast_arg_list([a, b, c], ctx))
1107  s = BoolSort(ctx)
1108  a = s.cast(a)
1109  b, c = _coerce_exprs(b, c, ctx)
1110  if __debug__:
1111  _z3_assert(a.ctx == b.ctx, "Context mismatch")
1112  return _to_expr_ref(Z3_mk_ite(ctx.ref(), a.as_ast(), b.as_ast(), c.as_ast()), ctx)
1113 
def If(a, b, c, ctx=None)
Definition: z3py.py:1092
def Cond(p, t1, t2, ctx=None)
Definition: z3py.py:7162
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:1346
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 1434 of file z3py.py.

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

1434 def Implies(a, b, ctx=None):
1435  """Create a Z3 implies expression.
1436 
1437  >>> p, q = Bools('p q')
1438  >>> Implies(p, q)
1439  Implies(p, q)
1440  >>> simplify(Implies(p, q))
1441  Or(Not(p), q)
1442  """
1443  ctx = _get_ctx(_ctx_from_ast_arg_list([a, b], ctx))
1444  s = BoolSort(ctx)
1445  a = s.cast(a)
1446  b = s.cast(b)
1447  return BoolRef(Z3_mk_implies(ctx.ref(), a.as_ast(), b.as_ast()), ctx)
1448 
def Implies(a, b, ctx=None)
Definition: z3py.py:1434
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:1346
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 2742 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().

2742 def Int(name, ctx=None):
2743  """Return an integer constant named `name`. If `ctx=None`, then the global context is used.
2744 
2745  >>> x = Int('x')
2746  >>> is_int(x)
2747  True
2748  >>> is_int(x + 1)
2749  True
2750  """
2751  ctx = _get_ctx(ctx)
2752  return ArithRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), IntSort(ctx).ast), ctx)
2753 
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:94
def Int(name, ctx=None)
Definition: z3py.py:2742
def IntSort(ctx=None)
Definition: z3py.py:2639
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 7517 of file z3py.py.

Referenced by binary_interpolant(), and tree_interpolant().

7517 def Interpolant(a,ctx=None):
7518  """Create an interpolation operator.
7519 
7520  The argument is an interpolation pattern (see tree_interpolant).
7521 
7522  >>> x = Int('x')
7523  >>> print Interpolant(x>0)
7524  interp(x > 0)
7525  """
7526  ctx = _get_ctx(_ctx_from_ast_arg_list([a], ctx))
7527  s = BoolSort(ctx)
7528  a = s.cast(a)
7529  return BoolRef(Z3_mk_interpolant(ctx.ref(), a.as_ast()), ctx)
7530 
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:7517
def BoolSort(ctx=None)
Definition: z3py.py:1346
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 2754 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().

2754 def Ints(names, ctx=None):
2755  """Return a tuple of Integer constants.
2756 
2757  >>> x, y, z = Ints('x y z')
2758  >>> Sum(x, y, z)
2759  x + y + z
2760  """
2761  ctx = _get_ctx(ctx)
2762  if isinstance(names, str):
2763  names = names.split(" ")
2764  return [Int(name, ctx) for name in names]
2765 
def Int(name, ctx=None)
Definition: z3py.py:2742
def Ints(names, ctx=None)
Definition: z3py.py:2754
def z3py.IntSort (   ctx = None)
Return the interger 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 2639 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(), FuncInterp.entry(), Exists(), ForAll(), FreshInt(), ModelRef.get_interp(), get_map_func(), Context.getIntSort(), Int(), 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(), K(), Map(), Context.mkIntSort(), 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(), ArrayRef.sort(), Store(), Sort.toString(), Sort.ToString(), Update(), FuncEntry.value(), QuantifierRef.var_name(), QuantifierRef.var_sort(), and QuantifierRef.weight().

2639 def IntSort(ctx=None):
2640  """Return the interger sort in the given context. If `ctx=None`, then the global context is used.
2641 
2642  >>> IntSort()
2643  Int
2644  >>> x = Const('x', IntSort())
2645  >>> is_int(x)
2646  True
2647  >>> x.sort() == IntSort()
2648  True
2649  >>> x.sort() == BoolSort()
2650  False
2651  """
2652  ctx = _get_ctx(ctx)
2653  return ArithSortRef(Z3_mk_int_sort(ctx.ref()), ctx)
2654 
Z3_sort Z3_API Z3_mk_int_sort(Z3_context c)
Create the integer type.
Arithmetic.
Definition: z3py.py:1856
def IntSort(ctx=None)
Definition: z3py.py:2639
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 2686 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(), AstMap.keys(), and AstMap.reset().

2686 def IntVal(val, ctx=None):
2687  """Return a Z3 integer value. If `ctx=None`, then the global context is used.
2688 
2689  >>> IntVal(1)
2690  1
2691  >>> IntVal("100")
2692  100
2693  """
2694  ctx = _get_ctx(ctx)
2695  return IntNumRef(Z3_mk_numeral(ctx.ref(), _to_int_str(val), IntSort(ctx).ast), ctx)
2696 
def IntVal(val, ctx=None)
Definition: z3py.py:2686
def IntSort(ctx=None)
Definition: z3py.py:2639
Z3_ast Z3_API Z3_mk_numeral(Z3_context c, Z3_string numeral, Z3_sort ty)
Create a numeral of a given sort.
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 2766 of file z3py.py.

2766 def IntVector(prefix, sz, ctx=None):
2767  """Return a list of integer constants of size `sz`.
2768 
2769  >>> X = IntVector('x', 3)
2770  >>> X
2771  [x__0, x__1, x__2]
2772  >>> Sum(X)
2773  x__0 + x__1 + x__2
2774  """
2775  return [ Int('%s__%s' % (prefix, i)) for i in range(sz) ]
2776 
def Int(name, ctx=None)
Definition: z3py.py:2742
def IntVector(prefix, sz, ctx=None)
Definition: z3py.py:2766
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 2343 of file z3py.py.

2343 def is_add(a):
2344  """Return `True` if `a` is an expression of the form b + c.
2345 
2346  >>> x, y = Ints('x y')
2347  >>> is_add(x + y)
2348  True
2349  >>> is_add(x - y)
2350  False
2351  """
2352  return is_app_of(a, Z3_OP_ADD)
2353 
def is_app_of(a, k)
Definition: z3py.py:1080
def is_add(a)
Definition: z3py.py:2343
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 2330 of file z3py.py.

2331  """Return `True` if `a` is an algerbraic value of sort Real.
2332 
2333  >>> is_algebraic_value(RealVal("3/5"))
2334  False
2335  >>> n = simplify(Sqrt(2))
2336  >>> n
2337  1.4142135623?
2338  >>> is_algebraic_value(n)
2339  True
2340  """
2341  return is_arith(a) and a.is_real() and _is_algebraic(a.ctx, a.as_ast())
2342 
def is_arith(a)
Definition: z3py.py:2224
def is_algebraic_value(a)
Definition: z3py.py:2330
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 1293 of file z3py.py.

1293 def is_and(a):
1294  """Return `True` if `a` is a Z3 and expression.
1295 
1296  >>> p, q = Bools('p q')
1297  >>> is_and(And(p, q))
1298  True
1299  >>> is_and(Or(p, q))
1300  False
1301  """
1302  return is_app_of(a, Z3_OP_AND)
1303 
def is_and(a)
Definition: z3py.py:1293
def is_app_of(a, k)
Definition: z3py.py:1080
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 981 of file z3py.py.

Referenced by ExprRef.arg(), ExprRef.children(), ExprRef.decl(), expr.hi(), is_app_of(), expr.is_const(), is_const(), expr.lo(), ExprRef.num_args(), and expr.operator Z3_app().

981 def is_app(a):
982  """Return `True` if `a` is a Z3 function application.
983 
984  Note that, constants are function applications with 0 arguments.
985 
986  >>> a = Int('a')
987  >>> is_app(a)
988  True
989  >>> is_app(a + 1)
990  True
991  >>> is_app(IntSort())
992  False
993  >>> is_app(1)
994  False
995  >>> is_app(IntVal(1))
996  True
997  >>> x = Int('x')
998  >>> is_app(ForAll(x, x >= 0))
999  False
1000  """
1001  if not isinstance(a, ExprRef):
1002  return False
1003  k = _ast_kind(a.ctx, a)
1004  return k == Z3_NUMERAL_AST or k == Z3_APP_AST
1005 
def is_app(a)
Definition: z3py.py:981
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 1080 of file z3py.py.

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

1080 def is_app_of(a, k):
1081  """Return `True` if `a` is an application of the given kind `k`.
1082 
1083  >>> x = Int('x')
1084  >>> n = x + 1
1085  >>> is_app_of(n, Z3_OP_ADD)
1086  True
1087  >>> is_app_of(n, Z3_OP_MUL)
1088  False
1089  """
1090  return is_app(a) and a.decl().kind() == k
1091 
def is_app(a)
Definition: z3py.py:981
def is_app_of(a, k)
Definition: z3py.py:1080
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 2224 of file z3py.py.

Referenced by is_algebraic_value().

2224 def is_arith(a):
2225  """Return `True` if `a` is an arithmetical expression.
2226 
2227  >>> x = Int('x')
2228  >>> is_arith(x)
2229  True
2230  >>> is_arith(x + 1)
2231  True
2232  >>> is_arith(1)
2233  False
2234  >>> is_arith(IntVal(1))
2235  True
2236  >>> y = Real('y')
2237  >>> is_arith(y)
2238  True
2239  >>> is_arith(y + 1)
2240  True
2241  """
2242  return isinstance(a, ArithRef)
2243 
def is_arith(a)
Definition: z3py.py:2224
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 1927 of file z3py.py.

1928  """Return `True` if s is an arithmetical sort (type).
1929 
1930  >>> is_arith_sort(IntSort())
1931  True
1932  >>> is_arith_sort(RealSort())
1933  True
1934  >>> is_arith_sort(BoolSort())
1935  False
1936  >>> n = Int('x') + 1
1937  >>> is_arith_sort(n.sort())
1938  True
1939  """
1940  return isinstance(s, ArithSortRef)
1941 
def is_arith_sort(s)
Definition: z3py.py:1927
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 3927 of file z3py.py.

Referenced by sort.array_domain(), sort.array_range(), and Default().

3927 def is_array(a):
3928  """Return `True` if `a` is a Z3 array expression.
3929 
3930  >>> a = Array('a', IntSort(), IntSort())
3931  >>> is_array(a)
3932  True
3933  >>> is_array(Store(a, 0, 1))
3934  True
3935  >>> is_array(a[0])
3936  False
3937  """
3938  return isinstance(a, ArrayRef)
3939 
def is_array(a)
Definition: z3py.py:3927
def z3py.is_as_array (   n)
Return true if n is a Z3 expression of the form (_ as-array f).

Definition at line 5589 of file z3py.py.

Referenced by get_as_array_func().

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

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

351 def is_ast(a):
352  """Return `True` if `a` is an AST node.
353 
354  >>> is_ast(10)
355  False
356  >>> is_ast(IntVal(10))
357  True
358  >>> is_ast(Int('x'))
359  True
360  >>> is_ast(BoolSort())
361  True
362  >>> is_ast(Function('f', IntSort(), IntSort()))
363  True
364  >>> is_ast("x")
365  False
366  >>> is_ast(Solver())
367  False
368  """
369  return isinstance(a, AstRef)
370 
def is_ast(a)
Definition: z3py.py:351
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 1246 of file z3py.py.

Referenced by BoolSort(), and prove().

1246 def is_bool(a):
1247  """Return `True` if `a` is a Z3 Boolean expression.
1248 
1249  >>> p = Bool('p')
1250  >>> is_bool(p)
1251  True
1252  >>> q = Bool('q')
1253  >>> is_bool(And(p, q))
1254  True
1255  >>> x = Real('x')
1256  >>> is_bool(x)
1257  False
1258  >>> is_bool(x == 0)
1259  True
1260  """
1261  return isinstance(a, BoolRef)
1262 
def is_bool(a)
Definition: z3py.py:1246
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 3415 of file z3py.py.

Referenced by BitVec(), BV2Int(), sort.bv_size(), BVRedAnd(), BVRedOr(), Concat(), Extract(), fpFP(), fpToFP(), fpToFPUnsigned(), fpToIEEEBV(), fpToSBV(), fpToUBV(), Product(), and Sum().

3415 def is_bv(a):
3416  """Return `True` if `a` is a Z3 bit-vector expression.
3417 
3418  >>> b = BitVec('b', 32)
3419  >>> is_bv(b)
3420  True
3421  >>> is_bv(b + 10)
3422  True
3423  >>> is_bv(Int('x'))
3424  False
3425  """
3426  return isinstance(a, BitVecRef)
3427 
def is_bv(a)
Definition: z3py.py:3415
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 2954 of file z3py.py.

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

2954 def is_bv_sort(s):
2955  """Return True if `s` is a Z3 bit-vector sort.
2956 
2957  >>> is_bv_sort(BitVecSort(32))
2958  True
2959  >>> is_bv_sort(IntSort())
2960  False
2961  """
2962  return isinstance(s, BitVecSortRef)
2963 
def is_bv_sort(s)
Definition: z3py.py:2954
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 3428 of file z3py.py.

3429  """Return `True` if `a` is a Z3 bit-vector numeral value.
3430 
3431  >>> b = BitVec('b', 32)
3432  >>> is_bv_value(b)
3433  False
3434  >>> b = BitVecVal(10, 32)
3435  >>> b
3436  10
3437  >>> is_bv_value(b)
3438  True
3439  """
3440  return is_bv(a) and _is_numeral(a.ctx, a.as_ast())
3441 
def is_bv_value(a)
Definition: z3py.py:3428
def is_bv(a)
Definition: z3py.py:3415
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 1006 of file z3py.py.

Referenced by prove().

1006 def is_const(a):
1007  """Return `True` if `a` is Z3 constant/variable expression.
1008 
1009  >>> a = Int('a')
1010  >>> is_const(a)
1011  True
1012  >>> is_const(a + 1)
1013  False
1014  >>> is_const(1)
1015  False
1016  >>> is_const(IntVal(1))
1017  True
1018  >>> x = Int('x')
1019  >>> is_const(ForAll(x, x >= 0))
1020  False
1021  """
1022  return is_app(a) and a.num_args() == 0
1023 
def is_app(a)
Definition: z3py.py:981
def is_const(a)
Definition: z3py.py:1006
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 3940 of file z3py.py.

3941  """Return `True` if `a` is a Z3 constant array.
3942 
3943  >>> a = K(IntSort(), 10)
3944  >>> is_const_array(a)
3945  True
3946  >>> a = Array('a', IntSort(), IntSort())
3947  >>> is_const_array(a)
3948  False
3949  """
3950  return is_app_of(a, Z3_OP_CONST_ARRAY)
3951 
def is_const_array(a)
Definition: z3py.py:3940
def is_app_of(a, k)
Definition: z3py.py:1080
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 3979 of file z3py.py.

3979 def is_default(a):
3980  """Return `True` if `a` is a Z3 default array expression.
3981  >>> d = Default(K(IntSort(), 10))
3982  >>> is_default(d)
3983  True
3984  """
3985  return is_app_of(a, Z3_OP_ARRAY_DEFAULT)
3986 
def is_default(a)
Definition: z3py.py:3979
def is_app_of(a, k)
Definition: z3py.py:1080
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 1335 of file z3py.py.

1336  """Return `True` if `a` is a Z3 distinct expression.
1337 
1338  >>> x, y, z = Ints('x y z')
1339  >>> is_distinct(x == y)
1340  False
1341  >>> is_distinct(Distinct(x, y, z))
1342  True
1343  """
1344  return is_app_of(a, Z3_OP_DISTINCT)
1345 
def is_distinct(a)
Definition: z3py.py:1335
def is_app_of(a, k)
Definition: z3py.py:1080
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 2376 of file z3py.py.

2376 def is_div(a):
2377  """Return `True` if `a` is an expression of the form b / c.
2378 
2379  >>> x, y = Reals('x y')
2380  >>> is_div(x / y)
2381  True
2382  >>> is_div(x + y)
2383  False
2384  >>> x, y = Ints('x y')
2385  >>> is_div(x / y)
2386  False
2387  >>> is_idiv(x / y)
2388  True
2389  """
2390  return is_app_of(a, Z3_OP_DIV)
2391 
def is_div(a)
Definition: z3py.py:2376
def is_app_of(a, k)
Definition: z3py.py:1080
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 1326 of file z3py.py.

1326 def is_eq(a):
1327  """Return `True` if `a` is a Z3 equality expression.
1328 
1329  >>> x, y = Ints('x y')
1330  >>> is_eq(x == y)
1331  True
1332  """
1333  return is_app_of(a, Z3_OP_EQ)
1334 
def is_eq(a)
Definition: z3py.py:1326
def is_app_of(a, k)
Definition: z3py.py:1080
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

Definition at line 961 of file z3py.py.

Referenced by SortRef.cast(), BoolSortRef.cast(), Cbrt(), ExprRef.children(), fpAbs(), fpNeg(), fpRoundToIntegral(), fpSqrt(), is_var(), simplify(), substitute(), and substitute_vars().

961 def is_expr(a):
962  """Return `True` if `a` is a Z3 expression.
963 
964  >>> a = Int('a')
965  >>> is_expr(a)
966  True
967  >>> is_expr(a + 1)
968  True
969  >>> is_expr(IntSort())
970  False
971  >>> is_expr(1)
972  False
973  >>> is_expr(IntVal(1))
974  True
975  >>> x = Int('x')
976  >>> is_expr(ForAll(x, x >= 0))
977  True
978  """
979  return isinstance(a, ExprRef)
980 
def is_expr(a)
Definition: z3py.py:961
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 1280 of file z3py.py.

Referenced by BoolVal().

1280 def is_false(a):
1281  """Return `True` if `a` is the Z3 false expression.
1282 
1283  >>> p = Bool('p')
1284  >>> is_false(p)
1285  False
1286  >>> is_false(False)
1287  False
1288  >>> is_false(BoolVal(False))
1289  True
1290  """
1291  return is_app_of(a, Z3_OP_FALSE)
1292 
def is_app_of(a, k)
Definition: z3py.py:1080
def is_false(a)
Definition: z3py.py:1280
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 8092 of file z3py.py.

Referenced by FP(), fpAbs(), fpAdd(), fpDiv(), fpFMA(), fpIsInfinite(), fpIsNaN(), fpIsNegative(), fpIsNormal(), fpIsPositive(), fpIsSubnormal(), fpIsZero(), fpMax(), fpMin(), fpMul(), fpNeg(), fpRem(), fpRoundToIntegral(), fpSqrt(), fpSub(), fpToFP(), fpToIEEEBV(), fpToReal(), fpToSBV(), and fpToUBV().

8092 def is_fp(a):
8093  """Return `True` if `a` is a Z3 floating-point expression.
8094 
8095  >>> b = FP('b', FPSort(8, 24))
8096  >>> is_fp(b)
8097  True
8098  >>> is_fp(b + 1.0)
8099  True
8100  >>> is_fp(Int('x'))
8101  False
8102  """
8103  return isinstance(a, FPRef)
8104 
def is_fp(a)
Definition: z3py.py:8092
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 7778 of file z3py.py.

Referenced by fpToFP(), fpToFPUnsigned(), and FPVal().

7778 def is_fp_sort(s):
7779  """Return True if `s` is a Z3 floating-point sort.
7780 
7781  >>> is_fp_sort(FPSort(8, 24))
7782  True
7783  >>> is_fp_sort(IntSort())
7784  False
7785  """
7786  return isinstance(s, FPSortRef)
7787 
def is_fp_sort(s)
Definition: z3py.py:7778
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 8105 of file z3py.py.

8106  """Return `True` if `a` is a Z3 floating-point numeral value.
8107 
8108  >>> b = FP('b', FPSort(8, 24))
8109  >>> is_fp_value(b)
8110  False
8111  >>> b = FPVal(1.0, FPSort(8, 24))
8112  >>> b
8113  1
8114  >>> is_fp_value(b)
8115  True
8116  """
8117  return is_fp(a) and _is_numeral(a.ctx, a.ast)
8118 
def is_fp_value(a)
Definition: z3py.py:8105
def is_fp(a)
Definition: z3py.py:8092
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 7996 of file z3py.py.

Referenced by fpAdd(), fpDiv(), fpFMA(), fpMul(), fpRoundToIntegral(), fpSqrt(), fpSub(), fpToFP(), fpToFPUnsigned(), fpToSBV(), and fpToUBV().

7996 def is_fprm(a):
7997  """Return `True` if `a` is a Z3 floating-point rounding mode expression.
7998 
7999  >>> rm = RNE()
8000  >>> is_fprm(rm)
8001  True
8002  >>> rm = 1.0
8003  >>> is_fprm(rm)
8004  False
8005  """
8006  return isinstance(a, FPRMRef)
8007 
def is_fprm(a)
Definition: z3py.py:7996
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 7788 of file z3py.py.

7789  """Return True if `s` is a Z3 floating-point rounding mode sort.
7790 
7791  >>> is_fprm_sort(FPSort(8, 24))
7792  False
7793  >>> is_fprm_sort(RNE().sort())
7794  True
7795  """
7796  return isinstance(s, FPRMSortRef)
7797 
def is_fprm_sort(s)
Definition: z3py.py:7788
def z3py.is_fprm_value (   a)
Return `True` if `a` is a Z3 floating-point rounding mode numeral value.

Definition at line 8008 of file z3py.py.

8009  """Return `True` if `a` is a Z3 floating-point rounding mode numeral value."""
8010  return is_fprm(a) and _is_numeral(a.ctx, a.ast)
8011 
def is_fprm_value(a)
Definition: z3py.py:8008
def is_fprm(a)
Definition: z3py.py:7996
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 693 of file z3py.py.

Referenced by prove().

694  """Return `True` if `a` is a Z3 function declaration.
695 
696  >>> f = Function('f', IntSort(), IntSort())
697  >>> is_func_decl(f)
698  True
699  >>> x = Real('x')
700  >>> is_func_decl(x)
701  False
702  """
703  return isinstance(a, FuncDeclRef)
704 
def is_func_decl(a)
Definition: z3py.py:693
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 2436 of file z3py.py.

2436 def is_ge(a):
2437  """Return `True` if `a` is an expression of the form b >= c.
2438 
2439  >>> x, y = Ints('x y')
2440  >>> is_ge(x >= y)
2441  True
2442  >>> is_ge(x == y)
2443  False
2444  """
2445  return is_app_of(a, Z3_OP_GE)
2446 
def is_ge(a)
Definition: z3py.py:2436
def is_app_of(a, k)
Definition: z3py.py:1080
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 2447 of file z3py.py.

2447 def is_gt(a):
2448  """Return `True` if `a` is an expression of the form b > c.
2449 
2450  >>> x, y = Ints('x y')
2451  >>> is_gt(x > y)
2452  True
2453  >>> is_gt(x == y)
2454  False
2455  """
2456  return is_app_of(a, Z3_OP_GT)
2457 
def is_gt(a)
Definition: z3py.py:2447
def is_app_of(a, k)
Definition: z3py.py:1080
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 2392 of file z3py.py.

Referenced by is_div().

2392 def is_idiv(a):
2393  """Return `True` if `a` is an expression of the form b div c.
2394 
2395  >>> x, y = Ints('x y')
2396  >>> is_idiv(x / y)
2397  True
2398  >>> is_idiv(x + y)
2399  False
2400  """
2401  return is_app_of(a, Z3_OP_IDIV)
2402 
def is_idiv(a)
Definition: z3py.py:2392
def is_app_of(a, k)
Definition: z3py.py:1080
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 2244 of file z3py.py.

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

2244 def is_int(a):
2245  """Return `True` if `a` is an integer expression.
2246 
2247  >>> x = Int('x')
2248  >>> is_int(x + 1)
2249  True
2250  >>> is_int(1)
2251  False
2252  >>> is_int(IntVal(1))
2253  True
2254  >>> y = Real('y')
2255  >>> is_int(y)
2256  False
2257  >>> is_int(y + 1)
2258  False
2259  """
2260  return is_arith(a) and a.is_int()
2261 
def is_arith(a)
Definition: z3py.py:2224
def is_int(a)
Definition: z3py.py:2244
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 2286 of file z3py.py.

2287  """Return `True` if `a` is an integer value of sort Int.
2288 
2289  >>> is_int_value(IntVal(1))
2290  True
2291  >>> is_int_value(1)
2292  False
2293  >>> is_int_value(Int('x'))
2294  False
2295  >>> n = Int('x') + 1
2296  >>> n
2297  x + 1
2298  >>> n.arg(1)
2299  1
2300  >>> is_int_value(n.arg(1))
2301  True
2302  >>> is_int_value(RealVal("1/3"))
2303  False
2304  >>> is_int_value(RealVal(1))
2305  False
2306  """
2307  return is_arith(a) and a.is_int() and _is_numeral(a.ctx, a.as_ast())
2308 
def is_int_value(a)
Definition: z3py.py:2286
def is_arith(a)
Definition: z3py.py:2224
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 2458 of file z3py.py.

2458 def is_is_int(a):
2459  """Return `True` if `a` is an expression of the form IsInt(b).
2460 
2461  >>> x = Real('x')
2462  >>> is_is_int(IsInt(x))
2463  True
2464  >>> is_is_int(x)
2465  False
2466  """
2467  return is_app_of(a, Z3_OP_IS_INT)
2468 
def is_app_of(a, k)
Definition: z3py.py:1080
def is_is_int(a)
Definition: z3py.py:2458
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 3952 of file z3py.py.

3952 def is_K(a):
3953  """Return `True` if `a` is a Z3 constant array.
3954 
3955  >>> a = K(IntSort(), 10)
3956  >>> is_K(a)
3957  True
3958  >>> a = Array('a', IntSort(), IntSort())
3959  >>> is_K(a)
3960  False
3961  """
3962  return is_app_of(a, Z3_OP_CONST_ARRAY)
3963 
def is_K(a)
Definition: z3py.py:3952
def is_app_of(a, k)
Definition: z3py.py:1080
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 2414 of file z3py.py.

2414 def is_le(a):
2415  """Return `True` if `a` is an expression of the form b <= c.
2416 
2417  >>> x, y = Ints('x y')
2418  >>> is_le(x <= y)
2419  True
2420  >>> is_le(x < y)
2421  False
2422  """
2423  return is_app_of(a, Z3_OP_LE)
2424 
def is_le(a)
Definition: z3py.py:2414
def is_app_of(a, k)
Definition: z3py.py:1080
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 2425 of file z3py.py.

2425 def is_lt(a):
2426  """Return `True` if `a` is an expression of the form b < c.
2427 
2428  >>> x, y = Ints('x y')
2429  >>> is_lt(x < y)
2430  True
2431  >>> is_lt(x == y)
2432  False
2433  """
2434  return is_app_of(a, Z3_OP_LT)
2435 
def is_lt(a)
Definition: z3py.py:2425
def is_app_of(a, k)
Definition: z3py.py:1080
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 3964 of file z3py.py.

Referenced by get_map_func().

3964 def is_map(a):
3965  """Return `True` if `a` is a Z3 map array expression.
3966 
3967  >>> f = Function('f', IntSort(), IntSort())
3968  >>> b = Array('b', IntSort(), IntSort())
3969  >>> a = Map(f, b)
3970  >>> a
3971  Map(f, b)
3972  >>> is_map(a)
3973  True
3974  >>> is_map(b)
3975  False
3976  """
3977  return is_app_of(a, Z3_OP_ARRAY_MAP)
3978 
def is_map(a)
Definition: z3py.py:3964
def is_app_of(a, k)
Definition: z3py.py:1080
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 2403 of file z3py.py.

2403 def is_mod(a):
2404  """Return `True` if `a` is an expression of the form b % c.
2405 
2406  >>> x, y = Ints('x y')
2407  >>> is_mod(x % y)
2408  True
2409  >>> is_mod(x + y)
2410  False
2411  """
2412  return is_app_of(a, Z3_OP_MOD)
2413 
def is_mod(a)
Definition: z3py.py:2403
def is_app_of(a, k)
Definition: z3py.py:1080
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 2354 of file z3py.py.

2354 def is_mul(a):
2355  """Return `True` if `a` is an expression of the form b * c.
2356 
2357  >>> x, y = Ints('x y')
2358  >>> is_mul(x * y)
2359  True
2360  >>> is_mul(x - y)
2361  False
2362  """
2363  return is_app_of(a, Z3_OP_MUL)
2364 
def is_app_of(a, k)
Definition: z3py.py:1080
def is_mul(a)
Definition: z3py.py:2354
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 1315 of file z3py.py.

1315 def is_not(a):
1316  """Return `True` if `a` is a Z3 not expression.
1317 
1318  >>> p = Bool('p')
1319  >>> is_not(p)
1320  False
1321  >>> is_not(Not(p))
1322  True
1323  """
1324  return is_app_of(a, Z3_OP_NOT)
1325 
def is_not(a)
Definition: z3py.py:1315
def is_app_of(a, k)
Definition: z3py.py:1080
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 1304 of file z3py.py.

1304 def is_or(a):
1305  """Return `True` if `a` is a Z3 or expression.
1306 
1307  >>> p, q = Bools('p q')
1308  >>> is_or(Or(p, q))
1309  True
1310  >>> is_or(And(p, q))
1311  False
1312  """
1313  return is_app_of(a, Z3_OP_OR)
1314 
def is_or(a)
Definition: z3py.py:1304
def is_app_of(a, k)
Definition: z3py.py:1080
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 1566 of file z3py.py.

Referenced by MultiPattern().

1566 def is_pattern(a):
1567  """Return `True` if `a` is a Z3 pattern (hint for quantifier instantiation.
1568 
1569  See http://rise4fun.com/Z3Py/tutorial/advanced for more details.
1570 
1571  >>> f = Function('f', IntSort(), IntSort())
1572  >>> x = Int('x')
1573  >>> q = ForAll(x, f(x) == 0, patterns = [ f(x) ])
1574  >>> q
1575  ForAll(x, f(x) == 0)
1576  >>> q.num_patterns()
1577  1
1578  >>> is_pattern(q.pattern(0))
1579  True
1580  >>> q.pattern(0)
1581  f(Var(0))
1582  """
1583  return isinstance(a, PatternRef)
1584 
def is_pattern(a)
Definition: z3py.py:1566
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 7058 of file z3py.py.

Referenced by eq().

7058 def is_probe(p):
7059  """Return `True` if `p` is a Z3 probe.
7060 
7061  >>> is_probe(Int('x'))
7062  False
7063  >>> is_probe(Probe('memory'))
7064  True
7065  """
7066  return isinstance(p, Probe)
7067 
def is_probe(p)
Definition: z3py.py:7058
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 1769 of file z3py.py.

Referenced by expr.body(), and Exists().

1770  """Return `True` if `a` is a Z3 quantifier.
1771 
1772  >>> f = Function('f', IntSort(), IntSort())
1773  >>> x = Int('x')
1774  >>> q = ForAll(x, f(x) == 0)
1775  >>> is_quantifier(q)
1776  True
1777  >>> is_quantifier(f(x))
1778  False
1779  """
1780  return isinstance(a, QuantifierRef)
1781 
def is_quantifier(a)
Definition: z3py.py:1769
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 2309 of file z3py.py.

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

2310  """Return `True` if `a` is rational value of sort Real.
2311 
2312  >>> is_rational_value(RealVal(1))
2313  True
2314  >>> is_rational_value(RealVal("3/5"))
2315  True
2316  >>> is_rational_value(IntVal(1))
2317  False
2318  >>> is_rational_value(1)
2319  False
2320  >>> n = Real('x') + 1
2321  >>> n.arg(1)
2322  1
2323  >>> is_rational_value(n.arg(1))
2324  True
2325  >>> is_rational_value(Real('x'))
2326  False
2327  """
2328  return is_arith(a) and a.is_real() and _is_numeral(a.ctx, a.as_ast())
2329 
def is_arith(a)
Definition: z3py.py:2224
def is_rational_value(a)
Definition: z3py.py:2309
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 2262 of file z3py.py.

Referenced by fpToFP(), fpToReal(), sort.is_arith(), Real(), and RealSort().

2262 def is_real(a):
2263  """Return `True` if `a` is a real expression.
2264 
2265  >>> x = Int('x')
2266  >>> is_real(x + 1)
2267  False
2268  >>> y = Real('y')
2269  >>> is_real(y)
2270  True
2271  >>> is_real(y + 1)
2272  True
2273  >>> is_real(1)
2274  False
2275  >>> is_real(RealVal(1))
2276  True
2277  """
2278  return is_arith(a) and a.is_real()
2279 
def is_real(a)
Definition: z3py.py:2262
def is_arith(a)
Definition: z3py.py:2224
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 4143 of file z3py.py.

4143 def is_select(a):
4144  """Return `True` if `a` is a Z3 array select application.
4145 
4146  >>> a = Array('a', IntSort(), IntSort())
4147  >>> is_select(a)
4148  False
4149  >>> i = Int('i')
4150  >>> is_select(a[i])
4151  True
4152  """
4153  return is_app_of(a, Z3_OP_SELECT)
4154 
def is_select(a)
Definition: z3py.py:4143
def is_app_of(a, k)
Definition: z3py.py:1080
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 530 of file z3py.py.

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

530 def is_sort(s):
531  """Return `True` if `s` is a Z3 sort.
532 
533  >>> is_sort(IntSort())
534  True
535  >>> is_sort(Int('x'))
536  False
537  >>> is_expr(Int('x'))
538  True
539  """
540  return isinstance(s, SortRef)
541 
def is_sort(s)
Definition: z3py.py:530
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 4155 of file z3py.py.

4155 def is_store(a):
4156  """Return `True` if `a` is a Z3 array store application.
4157 
4158  >>> a = Array('a', IntSort(), IntSort())
4159  >>> is_store(a)
4160  False
4161  >>> is_store(Store(a, 0, 1))
4162  True
4163  """
4164  return is_app_of(a, Z3_OP_STORE)
4165 
def is_store(a)
Definition: z3py.py:4155
def is_app_of(a, k)
Definition: z3py.py:1080
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 2365 of file z3py.py.

2365 def is_sub(a):
2366  """Return `True` if `a` is an expression of the form b - c.
2367 
2368  >>> x, y = Ints('x y')
2369  >>> is_sub(x - y)
2370  True
2371  >>> is_sub(x + y)
2372  False
2373  """
2374  return is_app_of(a, Z3_OP_SUB)
2375 
def is_app_of(a, k)
Definition: z3py.py:1080
def is_sub(a)
Definition: z3py.py:2365
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 2483 of file z3py.py.

2483 def is_to_int(a):
2484  """Return `True` if `a` is an expression of the form ToInt(b).
2485 
2486  >>> x = Real('x')
2487  >>> n = ToInt(x)
2488  >>> n
2489  ToInt(x)
2490  >>> is_to_int(n)
2491  True
2492  >>> is_to_int(x)
2493  False
2494  """
2495  return is_app_of(a, Z3_OP_TO_INT)
2496 
def is_app_of(a, k)
Definition: z3py.py:1080
def is_to_int(a)
Definition: z3py.py:2483
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 2469 of file z3py.py.

2469 def is_to_real(a):
2470  """Return `True` if `a` is an expression of the form ToReal(b).
2471 
2472  >>> x = Int('x')
2473  >>> n = ToReal(x)
2474  >>> n
2475  ToReal(x)
2476  >>> is_to_real(n)
2477  True
2478  >>> is_to_real(x)
2479  False
2480  """
2481  return is_app_of(a, Z3_OP_TO_REAL)
2482 
def is_to_real(a)
Definition: z3py.py:2469
def is_app_of(a, k)
Definition: z3py.py:1080
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 1263 of file z3py.py.

Referenced by BoolVal().

1263 def is_true(a):
1264  """Return `True` if `a` is the Z3 true expression.
1265 
1266  >>> p = Bool('p')
1267  >>> is_true(p)
1268  False
1269  >>> is_true(simplify(p == p))
1270  True
1271  >>> x = Real('x')
1272  >>> is_true(x == 0)
1273  False
1274  >>> # True is a Python Boolean expression
1275  >>> is_true(True)
1276  False
1277  """
1278  return is_app_of(a, Z3_OP_TRUE)
1279 
def is_true(a)
Definition: z3py.py:1263
def is_app_of(a, k)
Definition: z3py.py:1080
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 1024 of file z3py.py.

Referenced by get_var_index().

1024 def is_var(a):
1025  """Return `True` if `a` is variable.
1026 
1027  Z3 uses de-Bruijn indices for representing bound variables in
1028  quantifiers.
1029 
1030  >>> x = Int('x')
1031  >>> is_var(x)
1032  False
1033  >>> is_const(x)
1034  True
1035  >>> f = Function('f', IntSort(), IntSort())
1036  >>> # Z3 replaces x with bound variables when ForAll is executed.
1037  >>> q = ForAll(x, f(x) == x)
1038  >>> b = q.body()
1039  >>> b
1040  f(Var(0)) == Var(0)
1041  >>> b.arg(1)
1042  Var(0)
1043  >>> is_var(b.arg(1))
1044  True
1045  """
1046  return is_expr(a) and _ast_kind(a.ctx, a) == Z3_VAR_AST
1047 
def is_expr(a)
Definition: z3py.py:961
def is_var(a)
Definition: z3py.py:1024
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 2876 of file z3py.py.

Referenced by is_is_int().

2876 def IsInt(a):
2877  """ Return the Z3 predicate IsInt(a).
2878 
2879  >>> x = Real('x')
2880  >>> IsInt(x + "1/2")
2881  IsInt(x + 1/2)
2882  >>> solve(IsInt(x + "1/2"), x > 0, x < 1)
2883  [x = 1/2]
2884  >>> solve(IsInt(x + "1/2"), x > 0, x < 1, x != "1/2")
2885  no solution
2886  """
2887  if __debug__:
2888  _z3_assert(a.is_real(), "Z3 real expression expected.")
2889  ctx = a.ctx
2890  return BoolRef(Z3_mk_is_int(ctx.ref(), a.as_ast()), ctx)
2891 
def IsInt(a)
Definition: z3py.py:2876
Z3_ast Z3_API Z3_mk_is_int(Z3_context c, Z3_ast t1)
Check if a real number is an integer.
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 4122 of file z3py.py.

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

4122 def K(dom, v):
4123  """Return a Z3 constant array expression.
4124 
4125  >>> a = K(IntSort(), 10)
4126  >>> a
4127  K(Int, 10)
4128  >>> a.sort()
4129  Array(Int, Int)
4130  >>> i = Int('i')
4131  >>> a[i]
4132  K(Int, 10)[i]
4133  >>> simplify(a[i])
4134  10
4135  """
4136  if __debug__:
4137  _z3_assert(is_sort(dom), "Z3 sort expected")
4138  ctx = dom.ctx
4139  if not is_expr(v):
4140  v = _py2expr(v, ctx)
4141  return ArrayRef(Z3_mk_const_array(ctx.ref(), dom.ast, v.as_ast()), ctx)
4142 
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:530
def K(dom, v)
Definition: z3py.py:4122
def is_expr(a)
Definition: z3py.py:961
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 3701 of file z3py.py.

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

3701 def LShR(a, b):
3702  """Create the Z3 expression logical right shift.
3703 
3704  Use the operator >> for the arithmetical right shift.
3705 
3706  >>> x, y = BitVecs('x y', 32)
3707  >>> LShR(x, y)
3708  LShR(x, y)
3709  >>> (x >> y).sexpr()
3710  '(bvashr x y)'
3711  >>> LShR(x, y).sexpr()
3712  '(bvlshr x y)'
3713  >>> BitVecVal(4, 3)
3714  4
3715  >>> BitVecVal(4, 3).as_signed_long()
3716  -4
3717  >>> simplify(BitVecVal(4, 3) >> 1).as_signed_long()
3718  -2
3719  >>> simplify(BitVecVal(4, 3) >> 1)
3720  6
3721  >>> simplify(LShR(BitVecVal(4, 3), 1))
3722  2
3723  >>> simplify(BitVecVal(2, 3) >> 1)
3724  1
3725  >>> simplify(LShR(BitVecVal(2, 3), 1))
3726  1
3727  """
3728  _check_bv_args(a, b)
3729  a, b = _coerce_exprs(a, b)
3730  return BitVecRef(Z3_mk_bvlshr(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3731 
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:3701
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 188 of file z3py.py.

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

188 def main_ctx():
189  """Return a reference to the global Z3 context.
190 
191  >>> x = Real('x')
192  >>> x.ctx == main_ctx()
193  True
194  >>> c = Context()
195  >>> c == main_ctx()
196  False
197  >>> x2 = Real('x', c)
198  >>> x2.ctx == c
199  True
200  >>> eq(x, x2)
201  False
202  """
203  global _main_ctx
204  if _main_ctx == None:
205  _main_ctx = Context()
206  return _main_ctx
207 
def main_ctx()
Definition: z3py.py:188
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 4100 of file z3py.py.

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

4100 def Map(f, *args):
4101  """Return a Z3 map array expression.
4102 
4103  >>> f = Function('f', IntSort(), IntSort(), IntSort())
4104  >>> a1 = Array('a1', IntSort(), IntSort())
4105  >>> a2 = Array('a2', IntSort(), IntSort())
4106  >>> b = Map(f, a1, a2)
4107  >>> b
4108  Map(f, a1, a2)
4109  >>> prove(b[0] == f(a1[0], a2[0]))
4110  proved
4111  """
4112  args = _get_args(args)
4113  if __debug__:
4114  _z3_assert(len(args) > 0, "At least one Z3 array expression expected")
4115  _z3_assert(is_func_decl(f), "First argument must be a Z3 function declaration")
4116  _z3_assert(all([is_array(a) for a in args]), "Z3 array expected expected")
4117  _z3_assert(len(args) == f.arity(), "Number of arguments mismatch")
4118  _args, sz = _to_ast_array(args)
4119  ctx = f.ctx
4120  return ArrayRef(Z3_mk_map(ctx.ref(), f.ast, sz, _args), ctx)
4121 
def is_array(a)
Definition: z3py.py:3927
def Map(f, args)
Definition: z3py.py:4100
Z3_ast Z3_API Z3_mk_map(Z3_context c, Z3_func_decl f, unsigned n, Z3_ast const *args)
map f on the the argument arrays.
def is_func_decl(a)
Definition: z3py.py:693
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 1585 of file z3py.py.

1585 def MultiPattern(*args):
1586  """Create a Z3 multi-pattern using the given expressions `*args`
1587 
1588  See http://rise4fun.com/Z3Py/tutorial/advanced for more details.
1589 
1590  >>> f = Function('f', IntSort(), IntSort())
1591  >>> g = Function('g', IntSort(), IntSort())
1592  >>> x = Int('x')
1593  >>> q = ForAll(x, f(x) != g(x), patterns = [ MultiPattern(f(x), g(x)) ])
1594  >>> q
1595  ForAll(x, f(x) != g(x))
1596  >>> q.num_patterns()
1597  1
1598  >>> is_pattern(q.pattern(0))
1599  True
1600  >>> q.pattern(0)
1601  MultiPattern(f(Var(0)), g(Var(0)))
1602  """
1603  if __debug__:
1604  _z3_assert(len(args) > 0, "At least one argument expected")
1605  _z3_assert(all([ is_expr(a) for a in args ]), "Z3 expressions expected")
1606  ctx = args[0].ctx
1607  args, sz = _to_ast_array(args)
1608  return PatternRef(Z3_mk_pattern(ctx.ref(), sz, args), ctx)
1609 
Patterns.
Definition: z3py.py:1555
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:1585
def is_expr(a)
Definition: z3py.py:961
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 1464 of file z3py.py.

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

1464 def Not(a, ctx=None):
1465  """Create a Z3 not expression or probe.
1466 
1467  >>> p = Bool('p')
1468  >>> Not(Not(p))
1469  Not(Not(p))
1470  >>> simplify(Not(Not(p)))
1471  p
1472  """
1473  ctx = _get_ctx(_ctx_from_ast_arg_list([a], ctx))
1474  if is_probe(a):
1475  # Not is also used to build probes
1476  return Probe(Z3_probe_not(ctx.ref(), a.probe), ctx)
1477  else:
1478  s = BoolSort(ctx)
1479  a = s.cast(a)
1480  return BoolRef(Z3_mk_not(ctx.ref(), a.as_ast()), ctx)
1481 
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:1464
def is_probe(p)
Definition: z3py.py:7058
def BoolSort(ctx=None)
Definition: z3py.py:1346
def z3py.open_log (   fname)
Log interaction to a file. This function must be invoked immediately after init(). 

Definition at line 86 of file z3py.py.

86 def open_log(fname):
87  """Log interaction to a file. This function must be invoked immediately after init(). """
88  Z3_open_log(fname)
89 
Z3_bool Z3_API Z3_open_log(Z3_string filename)
Log interaction to a file.
def open_log(fname)
Definition: z3py.py:86
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 1519 of file z3py.py.

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

1519 def Or(*args):
1520  """Create a Z3 or-expression or or-probe.
1521 
1522  >>> p, q, r = Bools('p q r')
1523  >>> Or(p, q, r)
1524  Or(p, q, r)
1525  >>> P = BoolVector('p', 5)
1526  >>> Or(P)
1527  Or(p__0, p__1, p__2, p__3, p__4)
1528  """
1529  last_arg = None
1530  if len(args) > 0:
1531  last_arg = args[len(args)-1]
1532  if isinstance(last_arg, Context):
1533  ctx = args[len(args)-1]
1534  args = args[:len(args)-1]
1535  else:
1536  ctx = main_ctx()
1537  args = _get_args(args)
1538  ctx_args = _ctx_from_ast_arg_list(args, ctx)
1539  if __debug__:
1540  _z3_assert(ctx_args == None or ctx_args == ctx, "context mismatch")
1541  _z3_assert(ctx != None, "At least one of the arguments must be a Z3 expression or probe")
1542  if _has_probe(args):
1543  return _probe_or(args, ctx)
1544  else:
1545  args = _coerce_expr_list(args, ctx)
1546  _args, sz = _to_ast_array(args)
1547  return BoolRef(Z3_mk_or(ctx.ref(), sz, _args), ctx)
1548 
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].The array args must have num_args ...
def main_ctx()
Definition: z3py.py:188
def Or(args)
Definition: z3py.py:1519
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 6790 of file z3py.py.

6790 def OrElse(*ts, **ks):
6791  """Return a tactic that applies the tactics in `*ts` until one of them succeeds (it doesn't fail).
6792 
6793  >>> x = Int('x')
6794  >>> t = OrElse(Tactic('split-clause'), Tactic('skip'))
6795  >>> # Tactic split-clause fails if there is no clause in the given goal.
6796  >>> t(x == 0)
6797  [[x == 0]]
6798  >>> t(Or(x == 0, x == 1))
6799  [[x == 0], [x == 1]]
6800  """
6801  if __debug__:
6802  _z3_assert(len(ts) >= 2, "At least two arguments expected")
6803  ctx = ks.get('ctx', None)
6804  num = len(ts)
6805  r = ts[0]
6806  for i in range(num - 1):
6807  r = _or_else(r, ts[i+1], ctx)
6808  return r
6809 
def OrElse(ts, ks)
Definition: z3py.py:6790
def z3py.ParAndThen (   t1,
  t2,
  ctx = None 
)
Alias for ParThen(t1, t2, ctx).

Definition at line 6842 of file z3py.py.

6842 def ParAndThen(t1, t2, ctx=None):
6843  """Alias for ParThen(t1, t2, ctx)."""
6844  return ParThen(t1, t2, ctx)
6845 
def ParAndThen(t1, t2, ctx=None)
Definition: z3py.py:6842
def ParThen(t1, t2, ctx=None)
Definition: z3py.py:6828
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 6810 of file z3py.py.

6810 def ParOr(*ts, **ks):
6811  """Return a tactic that applies the tactics in `*ts` in parallel until one of them succeeds (it doesn't fail).
6812 
6813  >>> x = Int('x')
6814  >>> t = ParOr(Tactic('simplify'), Tactic('fail'))
6815  >>> t(x + 1 == 2)
6816  [[x == 1]]
6817  """
6818  if __debug__:
6819  _z3_assert(len(ts) >= 2, "At least two arguments expected")
6820  ctx = _get_ctx(ks.get('ctx', None))
6821  ts = [ _to_tactic(t, ctx) for t in ts ]
6822  sz = len(ts)
6823  _args = (TacticObj * sz)()
6824  for i in range(sz):
6825  _args[i] = ts[i].tactic
6826  return Tactic(Z3_tactic_par_or(ctx.ref(), sz, _args), ctx)
6827 
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:6810
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 7507 of file z3py.py.

7507 def parse_smt2_file(f, sorts={}, decls={}, ctx=None):
7508  """Parse a file in SMT 2.0 format using the given sorts and decls.
7509 
7510  This function is similar to parse_smt2_string().
7511  """
7512  ctx = _get_ctx(ctx)
7513  ssz, snames, ssorts = _dict2sarray(sorts, ctx)
7514  dsz, dnames, ddecls = _dict2darray(decls, ctx)
7515  return _to_expr_ref(Z3_parse_smtlib2_file(ctx.ref(), f, ssz, snames, ssorts, dsz, dnames, ddecls), ctx)
7516 
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:7507
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 7487 of file z3py.py.

Referenced by parse_smt2_file().

7487 def parse_smt2_string(s, sorts={}, decls={}, ctx=None):
7488  """Parse a string in SMT 2.0 format using the given sorts and decls.
7489 
7490  The arguments sorts and decls are Python dictionaries used to initialize
7491  the symbol table used for the SMT 2.0 parser.
7492 
7493  >>> parse_smt2_string('(declare-const x Int) (assert (> x 0)) (assert (< x 10))')
7494  And(x > 0, x < 10)
7495  >>> x, y = Ints('x y')
7496  >>> f = Function('f', IntSort(), IntSort())
7497  >>> parse_smt2_string('(assert (> (+ foo (g bar)) 0))', decls={ 'foo' : x, 'bar' : y, 'g' : f})
7498  x + f(y) > 0
7499  >>> parse_smt2_string('(declare-const a U) (assert (> a 0))', sorts={ 'U' : IntSort() })
7500  a > 0
7501  """
7502  ctx = _get_ctx(ctx)
7503  ssz, snames, ssorts = _dict2sarray(sorts, ctx)
7504  dsz, dnames, ddecls = _dict2darray(decls, ctx)
7505  return _to_expr_ref(Z3_parse_smtlib2_string(ctx.ref(), s, ssz, snames, ssorts, dsz, dnames, ddecls), ctx)
7506 
def parse_smt2_string(s, sorts={}, decls={}, ctx=None)
Definition: z3py.py:7487
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 6828 of file z3py.py.

Referenced by ParAndThen().

6828 def ParThen(t1, t2, ctx=None):
6829  """Return a tactic that applies t1 and then t2 to every subgoal produced by t1. The subgoals are processed in parallel.
6830 
6831  >>> x, y = Ints('x y')
6832  >>> t = ParThen(Tactic('split-clause'), Tactic('propagate-values'))
6833  >>> t(And(Or(x == 1, x == 2), y == x + 1))
6834  [[x == 1, y == 2], [x == 2, y == 3]]
6835  """
6836  t1 = _to_tactic(t1, ctx)
6837  t2 = _to_tactic(t2, ctx)
6838  if __debug__:
6839  _z3_assert(t1.ctx == t2.ctx, "Context mismatch")
6840  return Tactic(Z3_tactic_par_and_then(t1.ctx.ref(), t1.tactic, t2.tactic), t1.ctx)
6841 
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:6828
def z3py.probe_description (   name,
  ctx = None 
)
Return a short description for the probe named `name`.

>>> d = probe_description('memory')

Definition at line 7084 of file z3py.py.

Referenced by describe_probes().

7084 def probe_description(name, ctx=None):
7085  """Return a short description for the probe named `name`.
7086 
7087  >>> d = probe_description('memory')
7088  """
7089  ctx = _get_ctx(ctx)
7090  return Z3_probe_get_descr(ctx.ref(), name)
7091 
def probe_description(name, ctx=None)
Definition: z3py.py:7084
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.
def z3py.probes (   ctx = None)
Return a list of all available probes in Z3.

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

Definition at line 7074 of file z3py.py.

Referenced by describe_probes().

7074 def probes(ctx=None):
7075  """Return a list of all available probes in Z3.
7076 
7077  >>> l = probes()
7078  >>> l.count('memory') == 1
7079  True
7080  """
7081  ctx = _get_ctx(ctx)
7082  return [ Z3_get_probe_name(ctx.ref(), i) for i in range(Z3_get_num_probes(ctx.ref())) ]
7083 
Z3_string Z3_API Z3_get_probe_name(Z3_context c, unsigned i)
Return the name of the i probe.
def probes(ctx=None)
Definition: z3py.py:7074
unsigned Z3_API Z3_get_num_probes(Z3_context c)
Return the number of builtin probes available in Z3.
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 7281 of file z3py.py.

Referenced by BitVecs().

7281 def Product(*args):
7282  """Create the product of the Z3 expressions.
7283 
7284  >>> a, b, c = Ints('a b c')
7285  >>> Product(a, b, c)
7286  a*b*c
7287  >>> Product([a, b, c])
7288  a*b*c
7289  >>> A = IntVector('a', 5)
7290  >>> Product(A)
7291  a__0*a__1*a__2*a__3*a__4
7292  """
7293  args = _get_args(args)
7294  if __debug__:
7295  _z3_assert(len(args) > 0, "Non empty list of arguments expected")
7296  ctx = _ctx_from_ast_arg_list(args)
7297  if __debug__:
7298  _z3_assert(ctx != None, "At least one of the arguments must be a Z3 expression")
7299  args = _coerce_expr_list(args, ctx)
7300  if is_bv(args[0]):
7301  return _reduce(lambda a, b: a * b, args, 1)
7302  else:
7303  _args, sz = _to_ast_array(args)
7304  return ArithRef(Z3_mk_mul(ctx.ref(), sz, _args), ctx)
7305 
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].The array args must have num_args el...
def Product(args)
Definition: z3py.py:7281
def is_bv(a)
Definition: z3py.py:3415
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 7363 of file z3py.py.

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

7363 def prove(claim, **keywords):
7364  """Try to prove the given claim.
7365 
7366  This is a simple function for creating demonstrations. It tries to prove
7367  `claim` by showing the negation is unsatisfiable.
7368 
7369  >>> p, q = Bools('p q')
7370  >>> prove(Not(And(p, q)) == Or(Not(p), Not(q)))
7371  proved
7372  """
7373  if __debug__:
7374  _z3_assert(is_bool(claim), "Z3 Boolean expression expected")
7375  s = Solver()
7376  s.set(**keywords)
7377  s.add(Not(claim))
7378  if keywords.get('show', False):
7379  print(s)
7380  r = s.check()
7381  if r == unsat:
7382  print("proved")
7383  elif r == unknown:
7384  print("failed to prove")
7385  print(s.model())
7386  else:
7387  print("counterexample")
7388  print(s.model())
7389 
def prove(claim, keywords)
Definition: z3py.py:7363
def Not(a, ctx=None)
Definition: z3py.py:1464
def is_bool(a)
Definition: z3py.py:1246
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 2730 of file z3py.py.

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

2730 def Q(a, b, ctx=None):
2731  """Return a Z3 rational a/b.
2732 
2733  If `ctx=None`, then the global context is used.
2734 
2735  >>> Q(3,5)
2736  3/5
2737  >>> Q(3,5).sort()
2738  Real
2739  """
2740  return simplify(RatVal(a, b))
2741 
def simplify(a, arguments, keywords)
Utils.
Definition: z3py.py:7178
def RatVal(a, b, ctx=None)
Definition: z3py.py:2715
def Q(a, b, ctx=None)
Definition: z3py.py:2730
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 2715 of file z3py.py.

Referenced by Q().

2715 def RatVal(a, b, ctx=None):
2716  """Return a Z3 rational a/b.
2717 
2718  If `ctx=None`, then the global context is used.
2719 
2720  >>> RatVal(3,5)
2721  3/5
2722  >>> RatVal(3,5).sort()
2723  Real
2724  """
2725  if __debug__:
2726  _z3_assert(_is_int(a) or isinstance(a, str), "First argument cannot be converted into an integer")
2727  _z3_assert(_is_int(b) or isinstance(b, str), "Second argument cannot be converted into an integer")
2728  return simplify(RealVal(a, ctx)/RealVal(b, ctx))
2729 
def simplify(a, arguments, keywords)
Utils.
Definition: z3py.py:7178
def RatVal(a, b, ctx=None)
Definition: z3py.py:2715
def RealVal(val, ctx=None)
Definition: z3py.py:2697
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 2790 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().

2790 def Real(name, ctx=None):
2791  """Return a real constant named `name`. If `ctx=None`, then the global context is used.
2792 
2793  >>> x = Real('x')
2794  >>> is_real(x)
2795  True
2796  >>> is_real(x + 1)
2797  True
2798  """
2799  ctx = _get_ctx(ctx)
2800  return ArithRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), RealSort(ctx).ast), ctx)
2801 
def RealSort(ctx=None)
Definition: z3py.py:2655
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:94
def Real(name, ctx=None)
Definition: z3py.py:2790
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 2802 of file z3py.py.

Referenced by is_div().

2802 def Reals(names, ctx=None):
2803  """Return a tuple of real constants.
2804 
2805  >>> x, y, z = Reals('x y z')
2806  >>> Sum(x, y, z)
2807  x + y + z
2808  >>> Sum(x, y, z).sort()
2809  Real
2810  """
2811  ctx = _get_ctx(ctx)
2812  if isinstance(names, str):
2813  names = names.split(" ")
2814  return [Real(name, ctx) for name in names]
2815 
def Real(name, ctx=None)
Definition: z3py.py:2790
def Reals(names, ctx=None)
Definition: z3py.py:2802
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 2655 of file z3py.py.

Referenced by ArithSortRef.cast(), FreshReal(), Context.getRealSort(), is_arith_sort(), Context.mkRealSort(), Context.MkRealSort(), Real(), RealVar(), Sort.toString(), Sort.ToString(), and QuantifierRef.var_sort().

2655 def RealSort(ctx=None):
2656  """Return the real sort in the given context. If `ctx=None`, then the global context is used.
2657 
2658  >>> RealSort()
2659  Real
2660  >>> x = Const('x', RealSort())
2661  >>> is_real(x)
2662  True
2663  >>> is_int(x)
2664  False
2665  >>> x.sort() == RealSort()
2666  True
2667  """
2668  ctx = _get_ctx(ctx)
2669  return ArithSortRef(Z3_mk_real_sort(ctx.ref()), ctx)
2670 
def RealSort(ctx=None)
Definition: z3py.py:2655
Arithmetic.
Definition: z3py.py:1856
Z3_sort Z3_API Z3_mk_real_sort(Z3_context c)
Create the real type.
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 2697 of file z3py.py.

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

2697 def RealVal(val, ctx=None):
2698  """Return a Z3 real value.
2699 
2700  `val` may be a Python int, long, float or string representing a number in decimal or rational notation.
2701  If `ctx=None`, then the global context is used.
2702 
2703  >>> RealVal(1)
2704  1
2705  >>> RealVal(1).sort()
2706  Real
2707  >>> RealVal("3/5")
2708  3/5
2709  >>> RealVal("1.5")
2710  3/2
2711  """
2712  ctx = _get_ctx(ctx)
2713  return RatNumRef(Z3_mk_numeral(ctx.ref(), str(val), RealSort(ctx).ast), ctx)
2714 
def RealSort(ctx=None)
Definition: z3py.py:2655
def RealVal(val, ctx=None)
Definition: z3py.py:2697
Z3_ast Z3_API Z3_mk_numeral(Z3_context c, Z3_string numeral, Z3_sort ty)
Create a numeral of a given sort.
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 1182 of file z3py.py.

Referenced by RealVarVector().

1182 def RealVar(idx, ctx=None):
1183  """
1184  Create a real free variable. Free variables are used to create quantified formulas.
1185  They are also used to create polynomials.
1186 
1187  >>> RealVar(0)
1188  Var(0)
1189  """
1190  return Var(idx, RealSort(ctx))
1191 
def RealSort(ctx=None)
Definition: z3py.py:2655
def Var(idx, s)
Definition: z3py.py:1170
def RealVar(idx, ctx=None)
Definition: z3py.py:1182
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 1192 of file z3py.py.

1192 def RealVarVector(n, ctx=None):
1193  """
1194  Create a list of Real free variables.
1195  The variables have ids: 0, 1, ..., n-1
1196 
1197  >>> x0, x1, x2, x3 = RealVarVector(4)
1198  >>> x2
1199  Var(2)
1200  """
1201  return [ RealVar(i, ctx) for i in range(n) ]
1202 
def RealVarVector(n, ctx=None)
Definition: z3py.py:1192
def RealVar(idx, ctx=None)
Definition: z3py.py:1182
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 2816 of file z3py.py.

2816 def RealVector(prefix, sz, ctx=None):
2817  """Return a list of real constants of size `sz`.
2818 
2819  >>> X = RealVector('x', 3)
2820  >>> X
2821  [x__0, x__1, x__2]
2822  >>> Sum(X)
2823  x__0 + x__1 + x__2
2824  >>> Sum(X).sort()
2825  Real
2826  """
2827  return [ Real('%s__%s' % (prefix, i)) for i in range(sz) ]
2828 
def RealVector(prefix, sz, ctx=None)
Definition: z3py.py:2816
def Real(name, ctx=None)
Definition: z3py.py:2790
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 6859 of file z3py.py.

6859 def Repeat(t, max=4294967295, ctx=None):
6860  """Return a tactic that keeps applying `t` until the goal is not modified anymore or the maximum number of iterations `max` is reached.
6861 
6862  >>> x, y = Ints('x y')
6863  >>> c = And(Or(x == 0, x == 1), Or(y == 0, y == 1), x > y)
6864  >>> t = Repeat(OrElse(Tactic('split-clause'), Tactic('skip')))
6865  >>> r = t(c)
6866  >>> for subgoal in r: print(subgoal)
6867  [x == 0, y == 0, x > y]
6868  [x == 0, y == 1, x > y]
6869  [x == 1, y == 0, x > y]
6870  [x == 1, y == 1, x > y]
6871  >>> t = Then(t, Tactic('propagate-values'))
6872  >>> t(c)
6873  [[x == 1, y == 0]]
6874  """
6875  t = _to_tactic(t, ctx)
6876  return Tactic(Z3_tactic_repeat(t.ctx.ref(), t.tactic, max), t.ctx)
6877 
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:6859
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 3818 of file z3py.py.

3818 def RepeatBitVec(n, a):
3819  """Return an expression representing `n` copies of `a`.
3820 
3821  >>> x = BitVec('x', 8)
3822  >>> n = RepeatBitVec(4, x)
3823  >>> n
3824  RepeatBitVec(4, x)
3825  >>> n.size()
3826  32
3827  >>> v0 = BitVecVal(10, 4)
3828  >>> print("%.x" % v0.as_long())
3829  a
3830  >>> v = simplify(RepeatBitVec(4, v0))
3831  >>> v.size()
3832  16
3833  >>> print("%.x" % v.as_long())
3834  aaaa
3835  """
3836  if __debug__:
3837  _z3_assert(isinstance(n, int), "First argument must be an integer")
3838  _z3_assert(is_bv(a), "Second argument must be a Z3 Bitvector expression")
3839  return BitVecRef(Z3_mk_repeat(a.ctx_ref(), n, a.as_ast()), a.ctx)
3840 
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:3415
def RepeatBitVec(n, a)
Definition: z3py.py:3818
def z3py.reset_params ( )
Reset all global (or module) parameters.

Definition at line 237 of file z3py.py.

238  """Reset all global (or module) parameters.
239  """
241 
def reset_params()
Definition: z3py.py:237
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...
def z3py.RNA (   ctx = None)

Definition at line 7968 of file z3py.py.

Referenced by get_default_rounding_mode().

7968 def RNA (ctx=None):
7969  ctx = _get_ctx(ctx)
7970  return FPRMRef(Z3_mk_fpa_round_nearest_ties_to_away(ctx.ref()), ctx)
7971 
def RNA(ctx=None)
Definition: z3py.py:7968
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...
def z3py.RNE (   ctx = None)

Definition at line 7960 of file z3py.py.

Referenced by fpAbs(), fpAdd(), fpDiv(), fpMax(), fpMin(), fpMul(), fpNeg(), FPs(), fpSub(), get_default_rounding_mode(), is_fprm(), and is_fprm_sort().

7960 def RNE (ctx=None):
7961  ctx = _get_ctx(ctx)
7962  return FPRMRef(Z3_mk_fpa_round_nearest_ties_to_even(ctx.ref()), ctx)
7963 
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:7960
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 3732 of file z3py.py.

3732 def RotateLeft(a, b):
3733  """Return an expression representing `a` rotated to the left `b` times.
3734 
3735  >>> a, b = BitVecs('a b', 16)
3736  >>> RotateLeft(a, b)
3737  RotateLeft(a, b)
3738  >>> simplify(RotateLeft(a, 0))
3739  a
3740  >>> simplify(RotateLeft(a, 16))
3741  a
3742  """
3743  _check_bv_args(a, b)
3744  a, b = _coerce_exprs(a, b)
3745  return BitVecRef(Z3_mk_ext_rotate_left(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3746 
def RotateLeft(a, b)
Definition: z3py.py:3732
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.
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 3747 of file z3py.py.

3747 def RotateRight(a, b):
3748  """Return an expression representing `a` rotated to the right `b` times.
3749 
3750  >>> a, b = BitVecs('a b', 16)
3751  >>> RotateRight(a, b)
3752  RotateRight(a, b)
3753  >>> simplify(RotateRight(a, 0))
3754  a
3755  >>> simplify(RotateRight(a, 16))
3756  a
3757  """
3758  _check_bv_args(a, b)
3759  a, b = _coerce_exprs(a, b)
3760  return BitVecRef(Z3_mk_ext_rotate_right(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3761 
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:3747
def z3py.RoundNearestTiesToAway (   ctx = None)

Definition at line 7964 of file z3py.py.

7965  ctx = _get_ctx(ctx)
7966  return FPRMRef(Z3_mk_fpa_round_nearest_ties_to_away(ctx.ref()), ctx)
7967 
def RoundNearestTiesToAway(ctx=None)
Definition: z3py.py:7964
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...
def z3py.RoundNearestTiesToEven (   ctx = None)

Definition at line 7956 of file z3py.py.

7957  ctx = _get_ctx(ctx)
7958  return FPRMRef(Z3_mk_fpa_round_nearest_ties_to_even(ctx.ref()), ctx)
7959 
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:7956
def z3py.RoundTowardNegative (   ctx = None)

Definition at line 7980 of file z3py.py.

7980 def RoundTowardNegative(ctx=None):
7981  ctx = _get_ctx(ctx)
7982  return FPRMRef(Z3_mk_fpa_round_toward_negative(ctx.ref()), ctx)
7983 
def RoundTowardNegative(ctx=None)
Definition: z3py.py:7980
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...
def z3py.RoundTowardPositive (   ctx = None)

Definition at line 7972 of file z3py.py.

7972 def RoundTowardPositive(ctx=None):
7973  ctx = _get_ctx(ctx)
7974  return FPRMRef(Z3_mk_fpa_round_toward_positive(ctx.ref()), ctx)
7975 
def RoundTowardPositive(ctx=None)
Definition: z3py.py:7972
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...
def z3py.RoundTowardZero (   ctx = None)

Definition at line 7988 of file z3py.py.

7988 def RoundTowardZero(ctx=None):
7989  ctx = _get_ctx(ctx)
7990  return FPRMRef(Z3_mk_fpa_round_toward_zero(ctx.ref()), ctx)
7991 
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:7988
def z3py.RTN (   ctx = None)

Definition at line 7984 of file z3py.py.

Referenced by get_default_rounding_mode().

7984 def RTN(ctx=None):
7985  ctx = _get_ctx(ctx)
7986  return FPRMRef(Z3_mk_fpa_round_toward_negative(ctx.ref()), ctx)
7987 
def RTN(ctx=None)
Definition: z3py.py:7984
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...
def z3py.RTP (   ctx = None)

Definition at line 7976 of file z3py.py.

Referenced by get_default_rounding_mode().

7976 def RTP(ctx=None):
7977  ctx = _get_ctx(ctx)
7978  return FPRMRef(Z3_mk_fpa_round_toward_positive(ctx.ref()), ctx)
7979 
def RTP(ctx=None)
Definition: z3py.py:7976
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...
def z3py.RTZ (   ctx = None)

Definition at line 7992 of file z3py.py.

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

7992 def RTZ(ctx=None):
7993  ctx = _get_ctx(ctx)
7994  return FPRMRef(Z3_mk_fpa_round_toward_zero(ctx.ref()), ctx)
7995 
def RTZ(ctx=None)
Definition: z3py.py:7992
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 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 4086 of file z3py.py.

4086 def Select(a, i):
4087  """Return a Z3 select array expression.
4088 
4089  >>> a = Array('a', IntSort(), IntSort())
4090  >>> i = Int('i')
4091  >>> Select(a, i)
4092  a[i]
4093  >>> eq(Select(a, i), a[i])
4094  True
4095  """
4096  if __debug__:
4097  _z3_assert(is_array(a), "First argument must be a Z3 array expression")
4098  return a[i]
4099 
def is_array(a)
Definition: z3py.py:3927
def Select(a, i)
Definition: z3py.py:4086
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 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 7613 of file z3py.py.

7613 def sequence_interpolant(v,p=None,ctx=None):
7614  """Compute interpolant for a sequence of formulas.
7615 
7616  If len(v) == N, and if the conjunction of the formulas in v is
7617  unsatisfiable, the interpolant is a sequence of formulas w
7618  such that len(w) = N-1 and v[0] implies w[0] and for i in 0..N-1:
7619 
7620  1) w[i] & v[i+1] implies w[i+1] (or false if i+1 = N)
7621  2) All uninterpreted symbols in w[i] occur in both v[0]..v[i]
7622  and v[i+1]..v[n]
7623 
7624  Requires len(v) >= 1.
7625 
7626  If a & b is satisfiable, raises an object of class ModelRef
7627  that represents a model of a & b.
7628 
7629  If parameters p are supplied, these are used in creating the
7630  solver that determines satisfiability.
7631 
7632  >>> x = Int('x')
7633  >>> y = Int('y')
7634  >>> print sequence_interpolant([x < 0, y == x , y > 2])
7635  [Not(x >= 0), Not(y >= 0)]
7636  """
7637  f = v[0]
7638  for i in range(1,len(v)):
7639  f = And(Interpolant(f),v[i])
7640  return tree_interpolant(f,p,ctx)
7641 
def And(args)
Definition: z3py.py:1489
def Interpolant(a, ctx=None)
Definition: z3py.py:7517
def sequence_interpolant(v, p=None, ctx=None)
Definition: z3py.py:7613
def tree_interpolant(pat, p=None, ctx=None)
Definition: z3py.py:7531
def z3py.set_default_fp_sort (   ebits,
  sbits,
  ctx = None 
)

Definition at line 7684 of file z3py.py.

7684 def set_default_fp_sort(ebits, sbits, ctx=None):
7685  global _dflt_fpsort_ebits
7686  global _dflt_fpsort_sbits
7687  _dflt_fpsort_ebits = ebits
7688  _dflt_fpsort_sbits = sbits
7689 
def set_default_fp_sort(ebits, sbits, ctx=None)
Definition: z3py.py:7684
def z3py.set_default_rounding_mode (   rm,
  ctx = None 
)

Definition at line 7668 of file z3py.py.

7668 def set_default_rounding_mode(rm, ctx=None):
7669  global _dflt_rounding_mode
7670  if is_fprm_value(rm):
7671  _dflt_rounding_mode = rm.decl().kind()
7672  else:
7673  _z3_assert(_dflt_rounding_mode == Z3_OP_FPA_RM_TOWARD_ZERO or
7674  _dflt_rounding_mode == Z3_OP_FPA_RM_TOWARD_NEGATIVE or
7675  _dflt_rounding_mode == Z3_OP_FPA_RM_TOWARD_POSITIVE or
7676  _dflt_rounding_mode == Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN or
7677  _dflt_rounding_mode == Z3_OP_FPA_RM_NEAREST_TIES_TO_AWAY,
7678  "illegal rounding mode")
7679  _dflt_rounding_mode = rm
7680 
def set_default_rounding_mode(rm, ctx=None)
Definition: z3py.py:7668
def is_fprm_value(a)
Definition: z3py.py:8008
def z3py.set_option (   args,
  kws 
)
Alias for 'set_param' for backward compatibility.

Definition at line 242 of file z3py.py.

242 def set_option(*args, **kws):
243  """Alias for 'set_param' for backward compatibility.
244  """
245  return set_param(*args, **kws)
246 
def set_option(args, kws)
Definition: z3py.py:242
def set_param(args, kws)
Definition: z3py.py:214
def z3py.set_param (   args,
  kws 
)
Set Z3 global (or module) parameters.

>>> set_param(precision=10)

Definition at line 214 of file z3py.py.

Referenced by set_option().

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

3762 def SignExt(n, a):
3763  """Return a bit-vector expression with `n` extra sign-bits.
3764 
3765  >>> x = BitVec('x', 16)
3766  >>> n = SignExt(8, x)
3767  >>> n.size()
3768  24
3769  >>> n
3770  SignExt(8, x)
3771  >>> n.sort()
3772  BitVec(24)
3773  >>> v0 = BitVecVal(2, 2)
3774  >>> v0
3775  2
3776  >>> v0.size()
3777  2
3778  >>> v = simplify(SignExt(6, v0))
3779  >>> v
3780  254
3781  >>> v.size()
3782  8
3783  >>> print("%.x" % v.as_long())
3784  fe
3785  """
3786  if __debug__:
3787  _z3_assert(isinstance(n, int), "First argument must be an integer")
3788  _z3_assert(is_bv(a), "Second argument must be a Z3 Bitvector expression")
3789  return BitVecRef(Z3_mk_sign_ext(a.ctx_ref(), n, a.as_ast()), a.ctx)
3790 
def SignExt(n, a)
Definition: z3py.py:3762
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 bitvector of size m+i, where m is the size of the given bit-vector.
def is_bv(a)
Definition: z3py.py:3415
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 6131 of file z3py.py.

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

6131 def SimpleSolver(ctx=None):
6132  """Return a simple general purpose solver with limited amount of preprocessing.
6133 
6134  >>> s = SimpleSolver()
6135  >>> x = Int('x')
6136  >>> s.add(x > 0)
6137  >>> s.check()
6138  sat
6139  """
6140  ctx = _get_ctx(ctx)
6141  return Solver(Z3_mk_simple_solver(ctx.ref()), ctx)
6142 
Z3_solver Z3_API Z3_mk_simple_solver(Z3_context c)
Create a new (incremental) solver.
def SimpleSolver(ctx=None)
Definition: z3py.py:6131
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 7178 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(), CreateDatatypes(), Implies(), is_algebraic_value(), K(), LShR(), Not(), Q(), RatVal(), DatatypeSortRef.recognizer(), RepeatBitVec(), RotateLeft(), RotateRight(), SignExt(), Xor(), and ZeroExt().

7178 def simplify(a, *arguments, **keywords):
7179  """Simplify the expression `a` using the given options.
7180 
7181  This function has many options. Use `help_simplify` to obtain the complete list.
7182 
7183  >>> x = Int('x')
7184  >>> y = Int('y')
7185  >>> simplify(x + 1 + y + x + 1)
7186  2 + 2*x + y
7187  >>> simplify((x + 1)*(y + 1), som=True)
7188  1 + x + y + x*y
7189  >>> simplify(Distinct(x, y, 1), blast_distinct=True)
7190  And(Not(x == y), Not(x == 1), Not(y == 1))
7191  >>> simplify(And(x == 0, y == 1), elim_and=True)
7192  Not(Or(Not(x == 0), Not(y == 1)))
7193  """
7194  if __debug__:
7195  _z3_assert(is_expr(a), "Z3 expression expected")
7196  if len(arguments) > 0 or len(keywords) > 0:
7197  p = args2params(arguments, keywords, a.ctx)
7198  return _to_expr_ref(Z3_simplify_ex(a.ctx_ref(), a.as_ast(), p.params), a.ctx)
7199  else:
7200  return _to_expr_ref(Z3_simplify(a.ctx_ref(), a.as_ast()), a.ctx)
7201 
def simplify(a, arguments, keywords)
Utils.
Definition: z3py.py:7178
def args2params(arguments, keywords, ctx=None)
Definition: z3py.py:4527
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:961
def z3py.simplify_param_descrs ( )
Return the set of parameter descriptions for Z3 `simplify` procedure.

Definition at line 7206 of file z3py.py.

7207  """Return the set of parameter descriptions for Z3 `simplify` procedure."""
7209 
def main_ctx()
Definition: z3py.py:188
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:7206
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 7306 of file z3py.py.

Referenced by BV2Int(), and IsInt().

7306 def solve(*args, **keywords):
7307  """Solve the constraints `*args`.
7308 
7309  This is a simple function for creating demonstrations. It creates a solver,
7310  configure it using the options in `keywords`, adds the constraints
7311  in `args`, and invokes check.
7312 
7313  >>> a = Int('a')
7314  >>> solve(a > 0, a < 2)
7315  [a = 1]
7316  """
7317  s = Solver()
7318  s.set(**keywords)
7319  s.add(*args)
7320  if keywords.get('show', False):
7321  print(s)
7322  r = s.check()
7323  if r == unsat:
7324  print("no solution")
7325  elif r == unknown:
7326  print("failed to solve")
7327  try:
7328  print(s.model())
7329  except Z3Exception:
7330  return
7331  else:
7332  print(s.model())
7333 
def solve(args, keywords)
Definition: z3py.py:7306
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 7334 of file z3py.py.

7334 def solve_using(s, *args, **keywords):
7335  """Solve the constraints `*args` using solver `s`.
7336 
7337  This is a simple function for creating demonstrations. It is similar to `solve`,
7338  but it uses the given solver `s`.
7339  It configures solver `s` using the options in `keywords`, adds the constraints
7340  in `args`, and invokes check.
7341  """
7342  if __debug__:
7343  _z3_assert(isinstance(s, Solver), "Solver object expected")
7344  s.set(**keywords)
7345  s.add(*args)
7346  if keywords.get('show', False):
7347  print("Problem:")
7348  print(s)
7349  r = s.check()
7350  if r == unsat:
7351  print("no solution")
7352  elif r == unknown:
7353  print("failed to solve")
7354  try:
7355  print(s.model())
7356  except Z3Exception:
7357  return
7358  else:
7359  if keywords.get('show', False):
7360  print("Solution:")
7361  print(s.model())
7362 
def solve_using(s, args, keywords)
Definition: z3py.py:7334
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 6111 of file z3py.py.

6111 def SolverFor(logic, ctx=None):
6112  """Create a solver customized for the given logic.
6113 
6114  The parameter `logic` is a string. It should be contains
6115  the name of a SMT-LIB logic.
6116  See http://www.smtlib.org/ for the name of all available logics.
6117 
6118  >>> s = SolverFor("QF_LIA")
6119  >>> x = Int('x')
6120  >>> s.add(x > 0)
6121  >>> s.add(x < 2)
6122  >>> s.check()
6123  sat
6124  >>> s.model()
6125  [x = 1]
6126  """
6127  ctx = _get_ctx(ctx)
6128  logic = to_symbol(logic)
6129  return Solver(Z3_mk_solver_for_logic(ctx.ref(), logic), ctx)
6130 
def to_symbol(s, ctx=None)
Definition: z3py.py:94
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:6111
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 2892 of file z3py.py.

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

2892 def Sqrt(a, ctx=None):
2893  """ Return a Z3 expression which represents the square root of a.
2894 
2895  >>> x = Real('x')
2896  >>> Sqrt(x)
2897  x**(1/2)
2898  """
2899  if not is_expr(a):
2900  ctx = _get_ctx(ctx)
2901  a = RealVal(a, ctx)
2902  return a ** "1/2"
2903 
def RealVal(val, ctx=None)
Definition: z3py.py:2697
def is_expr(a)
Definition: z3py.py:961
def Sqrt(a, ctx=None)
Definition: z3py.py:2892
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 3681 of file z3py.py.

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

3681 def SRem(a, b):
3682  """Create the Z3 expression signed remainder.
3683 
3684  Use the operator % for signed modulus, and URem() for unsigned remainder.
3685 
3686  >>> x = BitVec('x', 32)
3687  >>> y = BitVec('y', 32)
3688  >>> SRem(x, y)
3689  SRem(x, y)
3690  >>> SRem(x, y).sort()
3691  BitVec(32)
3692  >>> (x % y).sexpr()
3693  '(bvsmod x y)'
3694  >>> SRem(x, y).sexpr()
3695  '(bvsrem x y)'
3696  """
3697  _check_bv_args(a, b)
3698  a, b = _coerce_exprs(a, b)
3699  return BitVecRef(Z3_mk_bvsrem(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3700 
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:3681
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 4070 of file z3py.py.

Referenced by is_array(), and is_store().

4070 def Store(a, i, v):
4071  """Return a Z3 store array expression.
4072 
4073  >>> a = Array('a', IntSort(), IntSort())
4074  >>> i, v = Ints('i v')
4075  >>> s = Store(a, i, v)
4076  >>> s.sort()
4077  Array(Int, Int)
4078  >>> prove(s[i] == v)
4079  proved
4080  >>> j = Int('j')
4081  >>> prove(Implies(i != j, s[j] == a[j]))
4082  proved
4083  """
4084  return Update(a, i, v)
4085 
def Update(a, i, v)
Definition: z3py.py:4038
def Store(a, i, v)
Definition: z3py.py:4070
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 7210 of file z3py.py.

Referenced by expr.simplify().

7210 def substitute(t, *m):
7211  """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.
7212 
7213  >>> x = Int('x')
7214  >>> y = Int('y')
7215  >>> substitute(x + 1, (x, y + 1))
7216  y + 1 + 1
7217  >>> f = Function('f', IntSort(), IntSort())
7218  >>> substitute(f(x) + f(y), (f(x), IntVal(1)), (f(y), IntVal(1)))
7219  1 + 1
7220  """
7221  if isinstance(m, tuple):
7222  m1 = _get_args(m)
7223  if isinstance(m1, list):
7224  m = m1
7225  if __debug__:
7226  _z3_assert(is_expr(t), "Z3 expression expected")
7227  _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.")
7228  num = len(m)
7229  _from = (Ast * num)()
7230  _to = (Ast * num)()
7231  for i in range(num):
7232  _from[i] = m[i][0].as_ast()
7233  _to[i] = m[i][1].as_ast()
7234  return _to_expr_ref(Z3_substitute(t.ctx.ref(), t.as_ast(), num, _from, _to), t.ctx)
7235 
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:7210
def eq(a, b)
Definition: z3py.py:371
def is_expr(a)
Definition: z3py.py:961
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 7236 of file z3py.py.

7236 def substitute_vars(t, *m):
7237  """Substitute the free variables in t with the expression in m.
7238 
7239  >>> v0 = Var(0, IntSort())
7240  >>> v1 = Var(1, IntSort())
7241  >>> x = Int('x')
7242  >>> f = Function('f', IntSort(), IntSort(), IntSort())
7243  >>> # replace v0 with x+1 and v1 with x
7244  >>> substitute_vars(f(v0, v1), x + 1, x)
7245  f(x + 1, x)
7246  """
7247  if __debug__:
7248  _z3_assert(is_expr(t), "Z3 expression expected")
7249  _z3_assert(all([is_expr(n) for n in m]), "Z3 invalid substitution, list of expressions expected.")
7250  num = len(m)
7251  _to = (Ast * num)()
7252  for i in range(num):
7253  _to[i] = m[i].as_ast()
7254  return _to_expr_ref(Z3_substitute_vars(t.ctx.ref(), t.as_ast(), num, _to), t.ctx)
7255 
def substitute_vars(t, m)
Definition: z3py.py:7236
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:961
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 7256 of file z3py.py.

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

7256 def Sum(*args):
7257  """Create the sum of the Z3 expressions.
7258 
7259  >>> a, b, c = Ints('a b c')
7260  >>> Sum(a, b, c)
7261  a + b + c
7262  >>> Sum([a, b, c])
7263  a + b + c
7264  >>> A = IntVector('a', 5)
7265  >>> Sum(A)
7266  a__0 + a__1 + a__2 + a__3 + a__4
7267  """
7268  args = _get_args(args)
7269  if __debug__:
7270  _z3_assert(len(args) > 0, "Non empty list of arguments expected")
7271  ctx = _ctx_from_ast_arg_list(args)
7272  if __debug__:
7273  _z3_assert(ctx != None, "At least one of the arguments must be a Z3 expression")
7274  args = _coerce_expr_list(args, ctx)
7275  if is_bv(args[0]):
7276  return _reduce(lambda a, b: a + b, args, 0)
7277  else:
7278  _args, sz = _to_ast_array(args)
7279  return ArithRef(Z3_mk_add(ctx.ref(), sz, _args), ctx)
7280 
def Sum(args)
Definition: z3py.py:7256
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].The array args must have num_args el...
def is_bv(a)
Definition: z3py.py:3415
def z3py.tactic_description (   name,
  ctx = None 
)
Return a short description for the tactic named `name`.

>>> d = tactic_description('simplify')

Definition at line 6896 of file z3py.py.

Referenced by describe_tactics().

6896 def tactic_description(name, ctx=None):
6897  """Return a short description for the tactic named `name`.
6898 
6899  >>> d = tactic_description('simplify')
6900  """
6901  ctx = _get_ctx(ctx)
6902  return Z3_tactic_get_descr(ctx.ref(), name)
6903 
def tactic_description(name, ctx=None)
Definition: z3py.py:6896
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.
def z3py.tactics (   ctx = None)
Return a list of all available tactics in Z3.

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

Definition at line 6886 of file z3py.py.

Referenced by describe_tactics().

6886 def tactics(ctx=None):
6887  """Return a list of all available tactics in Z3.
6888 
6889  >>> l = tactics()
6890  >>> l.count('simplify') == 1
6891  True
6892  """
6893  ctx = _get_ctx(ctx)
6894  return [ Z3_get_tactic_name(ctx.ref(), i) for i in range(Z3_get_num_tactics(ctx.ref())) ]
6895 
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:6886
unsigned Z3_API Z3_get_num_tactics(Z3_context c)
Return the number of builtin tactics available in Z3.
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 6778 of file z3py.py.

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

6778 def Then(*ts, **ks):
6779  """Return a tactic that applies the tactics in `*ts` in sequence. Shorthand for AndThen(*ts, **ks).
6780 
6781  >>> x, y = Ints('x y')
6782  >>> t = Then(Tactic('simplify'), Tactic('solve-eqs'))
6783  >>> t(And(x == 0, y > x + 1))
6784  [[Not(y <= 1)]]
6785  >>> t(And(x == 0, y > x + 1)).as_expr()
6786  Not(y <= 1)
6787  """
6788  return AndThen(*ts, **ks)
6789 
def Then(ts, ks)
Definition: z3py.py:6778
def AndThen(ts, ks)
Definition: z3py.py:6759
def z3py.to_symbol (   s,
  ctx = None 
)
Convert an integer or string into a Z3 symbol.

Definition at line 94 of file z3py.py.

Referenced by Fixedpoint.add_rule(), Optimize.add_soft(), Array(), BitVec(), Bool(), Const(), CreateDatatypes(), DeclareSort(), EnumSort(), FP(), Function(), Int(), prove(), Real(), Fixedpoint.set_predicate_representation(), SolverFor(), and Fixedpoint.update_rule().

94 def to_symbol(s, ctx=None):
95  """Convert an integer or string into a Z3 symbol."""
96  if isinstance(s, int):
97  return Z3_mk_int_symbol(_get_ctx(ctx).ref(), s)
98  else:
99  return Z3_mk_string_symbol(_get_ctx(ctx).ref(), s)
100 
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:94
Z3_symbol Z3_API Z3_mk_int_symbol(Z3_context c, int i)
Create a Z3 symbol using an integer.
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 2859 of file z3py.py.

Referenced by is_to_int().

2859 def ToInt(a):
2860  """ Return the Z3 expression ToInt(a).
2861 
2862  >>> x = Real('x')
2863  >>> x.sort()
2864  Real
2865  >>> n = ToInt(x)
2866  >>> n
2867  ToInt(x)
2868  >>> n.sort()
2869  Int
2870  """
2871  if __debug__:
2872  _z3_assert(a.is_real(), "Z3 real expression expected.")
2873  ctx = a.ctx
2874  return ArithRef(Z3_mk_real2int(ctx.ref(), a.as_ast()), ctx)
2875 
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:2859
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 2842 of file z3py.py.

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

2842 def ToReal(a):
2843  """ Return the Z3 expression ToReal(a).
2844 
2845  >>> x = Int('x')
2846  >>> x.sort()
2847  Int
2848  >>> n = ToReal(x)
2849  >>> n
2850  ToReal(x)
2851  >>> n.sort()
2852  Real
2853  """
2854  if __debug__:
2855  _z3_assert(a.is_int(), "Z3 integer expression expected.")
2856  ctx = a.ctx
2857  return ArithRef(Z3_mk_int2real(ctx.ref(), a.as_ast()), ctx)
2858 
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:2842
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 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 7531 of file z3py.py.

Referenced by binary_interpolant(), and sequence_interpolant().

7531 def tree_interpolant(pat,p=None,ctx=None):
7532  """Compute interpolant for a tree of formulas.
7533 
7534  The input is an interpolation pattern over a set of formulas C.
7535  The pattern pat is a formula combining the formulas in C using
7536  logical conjunction and the "interp" operator (see Interp). This
7537  interp operator is logically the identity operator. It marks the
7538  sub-formulas of the pattern for which interpolants should be
7539  computed. The interpolant is a map sigma from marked subformulas
7540  to formulas, such that, for each marked subformula phi of pat
7541  (where phi sigma is phi with sigma(psi) substituted for each
7542  subformula psi of phi such that psi in dom(sigma)):
7543 
7544  1) phi sigma implies sigma(phi), and
7545 
7546  2) sigma(phi) is in the common uninterpreted vocabulary between
7547  the formulas of C occurring in phi and those not occurring in
7548  phi
7549 
7550  and moreover pat sigma implies false. In the simplest case
7551  an interpolant for the pattern "(and (interp A) B)" maps A
7552  to an interpolant for A /\ B.
7553 
7554  The return value is a vector of formulas representing sigma. This
7555  vector contains sigma(phi) for each marked subformula of pat, in
7556  pre-order traversal. This means that subformulas of phi occur before phi
7557  in the vector. Also, subformulas that occur multiply in pat will
7558  occur multiply in the result vector.
7559 
7560  If pat is satisfiable, raises an object of class ModelRef
7561  that represents a model of pat.
7562 
7563  If parameters p are supplied, these are used in creating the
7564  solver that determines satisfiability.
7565 
7566  >>> x = Int('x')
7567  >>> y = Int('y')
7568  >>> print tree_interpolant(And(Interpolant(x < 0), Interpolant(y > 2), x == y))
7569  [Not(x >= 0), Not(y <= 2)]
7570 
7571  >>> g = And(Interpolant(x<0),x<2)
7572  >>> try:
7573  ... print tree_interpolant(g).sexpr()
7574  ... except ModelRef as m:
7575  ... print m.sexpr()
7576  (define-fun x () Int
7577  (- 1))
7578  """
7579  f = pat
7580  ctx = _get_ctx(_ctx_from_ast_arg_list([f], ctx))
7581  ptr = (AstVectorObj * 1)()
7582  mptr = (Model * 1)()
7583  if p == None:
7584  p = ParamsRef(ctx)
7585  res = Z3_compute_interpolant(ctx.ref(),f.as_ast(),p.params,ptr,mptr)
7586  if res == Z3_L_FALSE:
7587  return AstVector(ptr[0],ctx)
7588  raise ModelRef(mptr[0], ctx)
7589 
Z3_lbool Z3_API Z3_compute_interpolant(Z3_context c, Z3_ast pat, Z3_params p, Z3_ast_vector *interp, Z3_model *model)
Parameter Sets.
Definition: z3py.py:4490
def tree_interpolant(pat, p=None, ctx=None)
Definition: z3py.py:7531
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 6878 of file z3py.py.

6878 def TryFor(t, ms, ctx=None):
6879  """Return a tactic that applies `t` to a given goal for `ms` milliseconds.
6880 
6881  If `t` does not terminate in `ms` milliseconds, then it fails.
6882  """
6883  t = _to_tactic(t, ctx)
6884  return Tactic(Z3_tactic_try_for(t.ctx.ref(), t.tactic, ms), t.ctx)
6885 
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:6878
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 3641 of file z3py.py.

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

3641 def UDiv(a, b):
3642  """Create the Z3 expression (unsigned) division `self / other`.
3643 
3644  Use the operator / for signed division.
3645 
3646  >>> x = BitVec('x', 32)
3647  >>> y = BitVec('y', 32)
3648  >>> UDiv(x, y)
3649  UDiv(x, y)
3650  >>> UDiv(x, y).sort()
3651  BitVec(32)
3652  >>> (x / y).sexpr()
3653  '(bvsdiv x y)'
3654  >>> UDiv(x, y).sexpr()
3655  '(bvudiv x y)'
3656  """
3657  _check_bv_args(a, b)
3658  a, b = _coerce_exprs(a, b)
3659  return BitVecRef(Z3_mk_bvudiv(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3660 
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:3641
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 3607 of file z3py.py.

Referenced by BitVecRef.__ge__().

3607 def UGE(a, b):
3608  """Create the Z3 expression (unsigned) `other >= self`.
3609 
3610  Use the operator >= for signed greater than or equal to.
3611 
3612  >>> x, y = BitVecs('x y', 32)
3613  >>> UGE(x, y)
3614  UGE(x, y)
3615  >>> (x >= y).sexpr()
3616  '(bvsge x y)'
3617  >>> UGE(x, y).sexpr()
3618  '(bvuge x y)'
3619  """
3620  _check_bv_args(a, b)
3621  a, b = _coerce_exprs(a, b)
3622  return BoolRef(Z3_mk_bvuge(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3623 
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:3607
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 3624 of file z3py.py.

Referenced by BitVecRef.__gt__().

3624 def UGT(a, b):
3625  """Create the Z3 expression (unsigned) `other > self`.
3626 
3627  Use the operator > for signed greater than.
3628 
3629  >>> x, y = BitVecs('x y', 32)
3630  >>> UGT(x, y)
3631  UGT(x, y)
3632  >>> (x > y).sexpr()
3633  '(bvsgt x y)'
3634  >>> UGT(x, y).sexpr()
3635  '(bvugt x y)'
3636  """
3637  _check_bv_args(a, b)
3638  a, b = _coerce_exprs(a, b)
3639  return BoolRef(Z3_mk_bvugt(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3640 
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:3624
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 3573 of file z3py.py.

Referenced by BitVecRef.__le__().

3573 def ULE(a, b):
3574  """Create the Z3 expression (unsigned) `other <= self`.
3575 
3576  Use the operator <= for signed less than or equal to.
3577 
3578  >>> x, y = BitVecs('x y', 32)
3579  >>> ULE(x, y)
3580  ULE(x, y)
3581  >>> (x <= y).sexpr()
3582  '(bvsle x y)'
3583  >>> ULE(x, y).sexpr()
3584  '(bvule x y)'
3585  """
3586  _check_bv_args(a, b)
3587  a, b = _coerce_exprs(a, b)
3588  return BoolRef(Z3_mk_bvule(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3589 
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:3573
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 3590 of file z3py.py.

Referenced by BitVecRef.__lt__().

3590 def ULT(a, b):
3591  """Create the Z3 expression (unsigned) `other < self`.
3592 
3593  Use the operator < for signed less than.
3594 
3595  >>> x, y = BitVecs('x y', 32)
3596  >>> ULT(x, y)
3597  ULT(x, y)
3598  >>> (x < y).sexpr()
3599  '(bvslt x y)'
3600  >>> ULT(x, y).sexpr()
3601  '(bvult x y)'
3602  """
3603  _check_bv_args(a, b)
3604  a, b = _coerce_exprs(a, b)
3605  return BoolRef(Z3_mk_bvult(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3606 
def ULT(a, b)
Definition: z3py.py:3590
Z3_ast Z3_API Z3_mk_bvult(Z3_context c, Z3_ast t1, Z3_ast t2)
Unsigned less than.
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 4038 of file z3py.py.

Referenced by Store().

4038 def Update(a, i, v):
4039  """Return a Z3 store array expression.
4040 
4041  >>> a = Array('a', IntSort(), IntSort())
4042  >>> i, v = Ints('i v')
4043  >>> s = Update(a, i, v)
4044  >>> s.sort()
4045  Array(Int, Int)
4046  >>> prove(s[i] == v)
4047  proved
4048  >>> j = Int('j')
4049  >>> prove(Implies(i != j, s[j] == a[j]))
4050  proved
4051  """
4052  if __debug__:
4053  _z3_assert(is_array(a), "First argument must be a Z3 array expression")
4054  i = a.domain().cast(i)
4055  v = a.range().cast(v)
4056  ctx = a.ctx
4057  return _to_expr_ref(Z3_mk_store(ctx.ref(), a.as_ast(), i.as_ast(), v.as_ast()), ctx)
4058 
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:3927
def Update(a, i, v)
Definition: z3py.py:4038
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 3661 of file z3py.py.

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

3661 def URem(a, b):
3662  """Create the Z3 expression (unsigned) remainder `self % other`.
3663 
3664  Use the operator % for signed modulus, and SRem() for signed remainder.
3665 
3666  >>> x = BitVec('x', 32)
3667  >>> y = BitVec('y', 32)
3668  >>> URem(x, y)
3669  URem(x, y)
3670  >>> URem(x, y).sort()
3671  BitVec(32)
3672  >>> (x % y).sexpr()
3673  '(bvsmod x y)'
3674  >>> URem(x, y).sexpr()
3675  '(bvurem x y)'
3676  """
3677  _check_bv_args(a, b)
3678  a, b = _coerce_exprs(a, b)
3679  return BitVecRef(Z3_mk_bvurem(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3680 
def URem(a, b)
Definition: z3py.py:3661
Z3_ast Z3_API Z3_mk_bvurem(Z3_context c, Z3_ast t1, Z3_ast t2)
Unsigned remainder.
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 1170 of file z3py.py.

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

1170 def Var(idx, s):
1171  """Create a Z3 free variable. Free variables are used to create quantified formulas.
1172 
1173  >>> Var(0, IntSort())
1174  Var(0)
1175  >>> eq(Var(0, IntSort()), Var(0, BoolSort()))
1176  False
1177  """
1178  if __debug__:
1179  _z3_assert(is_sort(s), "Z3 sort expected")
1180  return _to_expr_ref(Z3_mk_bound(s.ctx_ref(), idx, s.ast), s.ctx)
1181 
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:1170
def is_sort(s)
Definition: z3py.py:530
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 7144 of file z3py.py.

7144 def When(p, t, ctx=None):
7145  """Return a tactic that applies tactic `t` only if probe `p` evaluates to true. Otherwise, it returns the input goal unmodified.
7146 
7147  >>> t = When(Probe('size') > 2, Tactic('simplify'))
7148  >>> x, y = Ints('x y')
7149  >>> g = Goal()
7150  >>> g.add(x > 0)
7151  >>> g.add(y > 0)
7152  >>> t(g)
7153  [[x > 0, y > 0]]
7154  >>> g.add(x == y + 1)
7155  >>> t(g)
7156  [[Not(x <= 0), Not(y <= 0), x == 1 + y]]
7157  """
7158  p = _to_probe(p, ctx)
7159  t = _to_tactic(t, ctx)
7160  return Tactic(Z3_tactic_when(t.ctx.ref(), p.probe, t.tactic), t.ctx)
7161 
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:7144
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 6846 of file z3py.py.

Referenced by Goal.prec().

6846 def With(t, *args, **keys):
6847  """Return a tactic that applies tactic `t` using the given configuration options.
6848 
6849  >>> x, y = Ints('x y')
6850  >>> t = With(Tactic('simplify'), som=True)
6851  >>> t((x + 1)*(y + 2) == 0)
6852  [[2*x + y + x*y == -2]]
6853  """
6854  ctx = keys.get('ctx', None)
6855  t = _to_tactic(t, ctx)
6856  p = args2params(args, keys, t.ctx)
6857  return Tactic(Z3_tactic_using_params(t.ctx.ref(), t.tactic, p.params), t.ctx)
6858 
def args2params(arguments, keywords, ctx=None)
Definition: z3py.py:4527
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:6846
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 1449 of file z3py.py.

1449 def Xor(a, b, ctx=None):
1450  """Create a Z3 Xor expression.
1451 
1452  >>> p, q = Bools('p q')
1453  >>> Xor(p, q)
1454  Xor(p, q)
1455  >>> simplify(Xor(p, q))
1456  Not(p) == q
1457  """
1458  ctx = _get_ctx(_ctx_from_ast_arg_list([a, b], ctx))
1459  s = BoolSort(ctx)
1460  a = s.cast(a)
1461  b = s.cast(b)
1462  return BoolRef(Z3_mk_xor(ctx.ref(), a.as_ast(), b.as_ast()), ctx)
1463 
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:1449
def BoolSort(ctx=None)
Definition: z3py.py:1346
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 3791 of file z3py.py.

3791 def ZeroExt(n, a):
3792  """Return a bit-vector expression with `n` extra zero-bits.
3793 
3794  >>> x = BitVec('x', 16)
3795  >>> n = ZeroExt(8, x)
3796  >>> n.size()
3797  24
3798  >>> n
3799  ZeroExt(8, x)
3800  >>> n.sort()
3801  BitVec(24)
3802  >>> v0 = BitVecVal(2, 2)
3803  >>> v0
3804  2
3805  >>> v0.size()
3806  2
3807  >>> v = simplify(ZeroExt(6, v0))
3808  >>> v
3809  2
3810  >>> v.size()
3811  8
3812  """
3813  if __debug__:
3814  _z3_assert(isinstance(n, int), "First argument must be an integer")
3815  _z3_assert(is_bv(a), "Second argument must be a Z3 Bitvector expression")
3816  return BitVecRef(Z3_mk_zero_ext(a.ctx_ref(), n, a.as_ast()), a.ctx)
3817 
def ZeroExt(n, a)
Definition: z3py.py:3791
def is_bv(a)
Definition: z3py.py:3415
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 bitvector of size m+i...

Variable Documentation

sat = CheckSatResult(Z3_L_TRUE)

Definition at line 5771 of file z3py.py.

unknown = CheckSatResult(Z3_L_UNDEF)

Definition at line 5773 of file z3py.py.

unsat = CheckSatResult(Z3_L_FALSE)

Definition at line 5772 of file z3py.py.