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  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  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
 
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
 
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
 
def Distinct (args)
 
def Const (name, sort)
 
def Consts (names, sort)
 
def Var (idx, s)
 
def RealVar
 
def RealVarVector
 
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
 
def BoolVal
 
def Bool
 
def Bools
 
def BoolVector
 
def FreshBool
 
def Implies
 
def Xor
 
def Not
 
def And (args)
 
def Or (args)
 
def is_pattern (a)
 
def MultiPattern (args)
 
def is_quantifier (a)
 
def ForAll
 
def Exists
 
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
 
def RealSort
 
def IntVal
 
def RealVal
 
def RatVal
 
def Q
 
def Int
 
def Ints
 
def IntVector
 
def FreshInt
 
def Real
 
def Reals
 
def RealVector
 
def FreshReal
 
def ToReal (a)
 
def ToInt (a)
 
def IsInt (a)
 
def Sqrt
 
def Cbrt
 
def is_bv_sort (s)
 
def is_bv (a)
 
def is_bv_value (a)
 
def BV2Int (a)
 
def BitVecSort
 
def BitVecVal
 
def BitVec
 
def BitVecs
 
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 get_map_func (a)
 
def ArraySort (d, r)
 
def Array (name, dom, rng)
 
def Update (a, i, v)
 
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
 
def args2params
 
def is_as_array (n)
 
def get_as_array_func (n)
 
def SolverFor
 
def SimpleSolver
 
def AndThen (ts, ks)
 
def Then (ts, ks)
 
def OrElse (ts, ks)
 
def ParOr (ts, ks)
 
def ParThen
 
def ParAndThen
 
def With (t, args, keys)
 
def Repeat
 
def TryFor
 
def tactics
 
def tactic_description
 
def describe_tactics ()
 
def is_probe (p)
 
def probes
 
def probe_description
 
def describe_probes ()
 
def FailIf
 
def When
 
def Cond
 
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
 
def parse_smt2_file
 
def Interpolant
 
def tree_interpolant
 
def binary_interpolant
 
def sequence_interpolant
 
def get_default_rounding_mode
 
def set_default_rounding_mode
 
def get_default_fp_sort
 
def set_default_fp_sort
 
def Float16
 
def FloatHalf
 
def Float32
 
def FloatSingle
 
def Float64
 
def Float128
 
def is_fp_sort (s)
 
def is_fprm_sort (s)
 
def RoundNearestTiesToEven
 
def RNE
 
def RoundNearestTiesToAway
 
def RNA
 
def RoundTowardPositive
 
def RTP
 
def RoundTowardNegative
 
def RTN
 
def RoundTowardZero
 
def RTZ
 
def is_fprm (a)
 
def is_fprm_value (a)
 
def is_fp (a)
 
def is_fp_value (a)
 
def FPSort
 
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
 
def FP
 
def FPs
 
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
 
def fpToFPUnsigned (rm, x, s)
 
def fpToSBV (rm, x, s)
 
def fpToUBV (rm, x, s)
 
def fpToReal (x)
 
def fpToIEEEBV (x)
 

Variables

tuple _error_handler_fptr = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_uint)
 
tuple _Z3Python_error_handler = _error_handler_fptr(_Z3python_error_handler_core)
 
 _main_ctx = None
 
tuple sat = CheckSatResult(Z3_L_TRUE)
 
tuple unsat = CheckSatResult(Z3_L_FALSE)
 
tuple unknown = CheckSatResult(Z3_L_UNDEF)
 
 _dflt_rounding_mode = Z3_OP_FPA_RM_TOWARD_ZERO
 Floating-Point Arithmetic. More...
 
int _dflt_fpsort_ebits = 11
 
int _dflt_fpsort_sbits = 53
 

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

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

1479 def And(*args):
1480  """Create a Z3 and-expression or and-probe.
1481 
1482  >>> p, q, r = Bools('p q r')
1483  >>> And(p, q, r)
1484  And(p, q, r)
1485  >>> P = BoolVector('p', 5)
1486  >>> And(P)
1487  And(p__0, p__1, p__2, p__3, p__4)
1488  """
1489  last_arg = None
1490  if len(args) > 0:
1491  last_arg = args[len(args)-1]
1492  if isinstance(last_arg, Context):
1493  ctx = args[len(args)-1]
1494  args = args[:len(args)-1]
1495  else:
1496  ctx = main_ctx()
1497  args = _get_args(args)
1498  ctx_args = _ctx_from_ast_arg_list(args, ctx)
1499  if __debug__:
1500  _z3_assert(ctx_args == None or ctx_args == ctx, "context mismatch")
1501  _z3_assert(ctx != None, "At least one of the arguments must be a Z3 expression or probe")
1502  if _has_probe(args):
1503  return _probe_and(args, ctx)
1504  else:
1505  args = _coerce_expr_list(args, ctx)
1506  _args, sz = _to_ast_array(args)
1507  return BoolRef(Z3_mk_and(ctx.ref(), sz, _args), ctx)
1508 
def And(args)
Definition: z3py.py:1479
def main_ctx()
Definition: z3py.py:188
Z3_ast Z3_API Z3_mk_and(__in Z3_context c, __in unsigned num_args, __in_ecount(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 6560 of file z3py.py.

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

6560 def AndThen(*ts, **ks):
6561  """Return a tactic that applies the tactics in `*ts` in sequence.
6562 
6563  >>> x, y = Ints('x y')
6564  >>> t = AndThen(Tactic('simplify'), Tactic('solve-eqs'))
6565  >>> t(And(x == 0, y > x + 1))
6566  [[Not(y <= 1)]]
6567  >>> t(And(x == 0, y > x + 1)).as_expr()
6568  Not(y <= 1)
6569  """
6570  if __debug__:
6571  _z3_assert(len(ts) >= 2, "At least two arguments expected")
6572  ctx = ks.get('ctx', None)
6573  num = len(ts)
6574  r = ts[0]
6575  for i in range(num - 1):
6576  r = _and_then(r, ts[i+1], ctx)
6577  return r
6578 
def AndThen(ts, ks)
Definition: z3py.py:6560
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(__in 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 4490 of file z3py.py.

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

4490 def args2params(arguments, keywords, ctx=None):
4491  """Convert python arguments into a Z3_params object.
4492  A ':' is added to the keywords, and '_' is replaced with '-'
4493 
4494  >>> args2params(['model', True, 'relevancy', 2], {'elim_and' : True})
4495  (params model true relevancy 2 elim_and true)
4496  """
4497  if __debug__:
4498  _z3_assert(len(arguments) % 2 == 0, "Argument list must have an even number of elements.")
4499  prev = None
4500  r = ParamsRef(ctx)
4501  for a in arguments:
4502  if prev == None:
4503  prev = a
4504  else:
4505  r.set(prev, a)
4506  prev = None
4507  for k in keywords:
4508  v = keywords[k]
4509  r.set(k, v)
4510  return r
4511 
def args2params
Definition: z3py.py:4490
Parameter Sets.
Definition: z3py.py:4453
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 3999 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().

3999 def Array(name, dom, rng):
4000  """Return an array constant named `name` with the given domain and range sorts.
4001 
4002  >>> a = Array('a', IntSort(), IntSort())
4003  >>> a.sort()
4004  Array(Int, Int)
4005  >>> a[0]
4006  a[0]
4007  """
4008  s = ArraySort(dom, rng)
4009  ctx = s.ctx
4010  return ArrayRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), s.ast), ctx)
4011 
Z3_ast Z3_API Z3_mk_const(__in Z3_context c, __in Z3_symbol s, __in Z3_sort ty)
Declare and create a constant.
def Array(name, dom, rng)
Definition: z3py.py:3999
def ArraySort(d, r)
Definition: z3py.py:3978
def to_symbol
Definition: z3py.py:94
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 3978 of file z3py.py.

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

3978 def ArraySort(d, r):
3979  """Return the Z3 array sort with the given domain and range sorts.
3980 
3981  >>> A = ArraySort(IntSort(), BoolSort())
3982  >>> A
3983  Array(Int, Bool)
3984  >>> A.domain()
3985  Int
3986  >>> A.range()
3987  Bool
3988  >>> AA = ArraySort(IntSort(), A)
3989  >>> AA
3990  Array(Int, Array(Int, Bool))
3991  """
3992  if __debug__:
3993  _z3_assert(is_sort(d), "Z3 sort expected")
3994  _z3_assert(is_sort(r), "Z3 sort expected")
3995  _z3_assert(d.ctx == r.ctx, "Context mismatch")
3996  ctx = d.ctx
3997  return ArraySortRef(Z3_mk_array_sort(ctx.ref(), d.ast, r.ast), ctx)
3998 
Z3_sort Z3_API Z3_mk_array_sort(__in Z3_context c, __in Z3_sort domain, __in Z3_sort range)
Create an array type.
Arrays.
Definition: z3py.py:3845
def is_sort(s)
Definition: z3py.py:532
def ArraySort(d, r)
Definition: z3py.py:3978
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 7391 of file z3py.py.

7391 def binary_interpolant(a,b,p=None,ctx=None):
7392  """Compute an interpolant for a binary conjunction.
7393 
7394  If a & b is unsatisfiable, returns an interpolant for a & b.
7395  This is a formula phi such that
7396 
7397  1) a implies phi
7398  2) b implies not phi
7399  3) All the uninterpreted symbols of phi occur in both a and b.
7400 
7401  If a & b is satisfiable, raises an object of class ModelRef
7402  that represents a model of a &b.
7403 
7404  If parameters p are supplied, these are used in creating the
7405  solver that determines satisfiability.
7406 
7407  x = Int('x')
7408  print binary_interpolant(x<0,x>2)
7409  Not(x >= 0)
7410  """
7411  f = And(Interpolant(a),b)
7412  return tree_interpolant(f,p,ctx)[0]
7413 
def And(args)
Definition: z3py.py:1479
def Interpolant
Definition: z3py.py:7318
def tree_interpolant
Definition: z3py.py:7332
def binary_interpolant
Definition: z3py.py:7391
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 3476 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(), FPs(), is_bv(), is_bv_value(), RepeatBitVec(), SignExt(), BitVecRef.size(), BitVecRef.sort(), SRem(), UDiv(), URem(), and ZeroExt().

3476 def BitVec(name, bv, ctx=None):
3477  """Return a bit-vector constant named `name`. `bv` may be the number of bits of a bit-vector sort.
3478  If `ctx=None`, then the global context is used.
3479 
3480  >>> x = BitVec('x', 16)
3481  >>> is_bv(x)
3482  True
3483  >>> x.size()
3484  16
3485  >>> x.sort()
3486  BitVec(16)
3487  >>> word = BitVecSort(16)
3488  >>> x2 = BitVec('x', word)
3489  >>> eq(x, x2)
3490  True
3491  """
3492  if isinstance(bv, BitVecSortRef):
3493  ctx = bv.ctx
3494  else:
3495  ctx = _get_ctx(ctx)
3496  bv = BitVecSort(bv, ctx)
3497  return BitVecRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), bv.ast), ctx)
3498 
Z3_ast Z3_API Z3_mk_const(__in Z3_context c, __in Z3_symbol s, __in Z3_sort ty)
Declare and create a constant.
def BitVecSort
Definition: z3py.py:3446
def BitVec
Definition: z3py.py:3476
def to_symbol
Definition: z3py.py:94
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 3499 of file z3py.py.

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

3499 def BitVecs(names, bv, ctx=None):
3500  """Return a tuple of bit-vector constants of size bv.
3501 
3502  >>> x, y, z = BitVecs('x y z', 16)
3503  >>> x.size()
3504  16
3505  >>> x.sort()
3506  BitVec(16)
3507  >>> Sum(x, y, z)
3508  0 + x + y + z
3509  >>> Product(x, y, z)
3510  1*x*y*z
3511  >>> simplify(Product(x, y, z))
3512  x*y*z
3513  """
3514  ctx = _get_ctx(ctx)
3515  if isinstance(names, str):
3516  names = names.split(" ")
3517  return [BitVec(name, bv, ctx) for name in names]
3518 
def BitVec
Definition: z3py.py:3476
def BitVecs
Definition: z3py.py:3499
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 3446 of file z3py.py.

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

3446 def BitVecSort(sz, ctx=None):
3447  """Return a Z3 bit-vector sort of the given size. If `ctx=None`, then the global context is used.
3448 
3449  >>> Byte = BitVecSort(8)
3450  >>> Word = BitVecSort(16)
3451  >>> Byte
3452  BitVec(8)
3453  >>> x = Const('x', Byte)
3454  >>> eq(x, BitVec('x', 8))
3455  True
3456  """
3457  ctx = _get_ctx(ctx)
3458  return BitVecSortRef(Z3_mk_bv_sort(ctx.ref(), sz), ctx)
3459 
Z3_sort Z3_API Z3_mk_bv_sort(__in Z3_context c, __in unsigned sz)
Create a bit-vector type of the given size.
def BitVecSort
Definition: z3py.py:3446
Bit-Vectors.
Definition: z3py.py:2908
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 3460 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().

3460 def BitVecVal(val, bv, ctx=None):
3461  """Return a bit-vector value with the given number of bits. If `ctx=None`, then the global context is used.
3462 
3463  >>> v = BitVecVal(10, 32)
3464  >>> v
3465  10
3466  >>> print("0x%.8x" % v.as_long())
3467  0x0000000a
3468  """
3469  if is_bv_sort(bv):
3470  ctx = bv.ctx
3471  return BitVecNumRef(Z3_mk_numeral(ctx.ref(), _to_int_str(val), bv.ast), ctx)
3472  else:
3473  ctx = _get_ctx(ctx)
3474  return BitVecNumRef(Z3_mk_numeral(ctx.ref(), _to_int_str(val), BitVecSort(bv, ctx).ast), ctx)
3475 
Z3_ast Z3_API Z3_mk_numeral(__in Z3_context c, __in Z3_string numeral, __in Z3_sort ty)
Create a numeral of a given sort.
def BitVecSort
Definition: z3py.py:3446
def BitVecVal
Definition: z3py.py:3460
def is_bv_sort(s)
Definition: z3py.py:2940
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 1371 of file z3py.py.

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

1371 def Bool(name, ctx=None):
1372  """Return a Boolean constant named `name`. If `ctx=None`, then the global context is used.
1373 
1374  >>> p = Bool('p')
1375  >>> q = Bool('q')
1376  >>> And(p, q)
1377  And(p, q)
1378  """
1379  ctx = _get_ctx(ctx)
1380  return BoolRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), BoolSort(ctx).ast), ctx)
1381 
Z3_ast Z3_API Z3_mk_const(__in Z3_context c, __in Z3_symbol s, __in Z3_sort ty)
Declare and create a constant.
def BoolSort
Definition: z3py.py:1336
def Bool
Definition: z3py.py:1371
def to_symbol
Definition: z3py.py:94
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 1382 of file z3py.py.

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

1382 def Bools(names, ctx=None):
1383  """Return a tuple of Boolean constants.
1384 
1385  `names` is a single string containing all names separated by blank spaces.
1386  If `ctx=None`, then the global context is used.
1387 
1388  >>> p, q, r = Bools('p q r')
1389  >>> And(p, Or(q, r))
1390  And(p, Or(q, r))
1391  """
1392  ctx = _get_ctx(ctx)
1393  if isinstance(names, str):
1394  names = names.split(" ")
1395  return [Bool(name, ctx) for name in names]
1396 
def Bools
Definition: z3py.py:1382
def Bool
Definition: z3py.py:1371
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 1336 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(), and ArrayRef.sort().

1336 def BoolSort(ctx=None):
1337  """Return the Boolean Z3 sort. If `ctx=None`, then the global context is used.
1338 
1339  >>> BoolSort()
1340  Bool
1341  >>> p = Const('p', BoolSort())
1342  >>> is_bool(p)
1343  True
1344  >>> r = Function('r', IntSort(), IntSort(), BoolSort())
1345  >>> r(0, 1)
1346  r(0, 1)
1347  >>> is_bool(r(0, 1))
1348  True
1349  """
1350  ctx = _get_ctx(ctx)
1351  return BoolSortRef(Z3_mk_bool_sort(ctx.ref()), ctx)
1352 
def BoolSort
Definition: z3py.py:1336
def is_bool(a)
Definition: z3py.py:1236
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 1353 of file z3py.py.

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

1353 def BoolVal(val, ctx=None):
1354  """Return the Boolean value `True` or `False`. If `ctx=None`, then the global context is used.
1355 
1356  >>> BoolVal(True)
1357  True
1358  >>> is_true(BoolVal(True))
1359  True
1360  >>> is_true(True)
1361  False
1362  >>> is_false(BoolVal(False))
1363  True
1364  """
1365  ctx = _get_ctx(ctx)
1366  if val == False:
1367  return BoolRef(Z3_mk_false(ctx.ref()), ctx)
1368  else:
1369  return BoolRef(Z3_mk_true(ctx.ref()), ctx)
1370 
def BoolVal
Definition: z3py.py:1353
Z3_ast Z3_API Z3_mk_true(__in Z3_context c)
Create an AST node representing true.
Z3_ast Z3_API Z3_mk_false(__in Z3_context c)
Create an AST node representing false.
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 1397 of file z3py.py.

Referenced by And(), and Or().

1397 def BoolVector(prefix, sz, ctx=None):
1398  """Return a list of Boolean constants of size `sz`.
1399 
1400  The constants are named using the given prefix.
1401  If `ctx=None`, then the global context is used.
1402 
1403  >>> P = BoolVector('p', 3)
1404  >>> P
1405  [p__0, p__1, p__2]
1406  >>> And(P)
1407  And(p__0, p__1, p__2)
1408  """
1409  return [ Bool('%s__%s' % (prefix, i)) for i in range(sz) ]
1410 
def Bool
Definition: z3py.py:1371
def BoolVector
Definition: z3py.py:1397
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 3428 of file z3py.py.

3428 def BV2Int(a):
3429  """Return the Z3 expression BV2Int(a).
3430 
3431  >>> b = BitVec('b', 3)
3432  >>> BV2Int(b).sort()
3433  Int
3434  >>> x = Int('x')
3435  >>> x > BV2Int(b)
3436  x > BV2Int(b)
3437  >>> solve(x > BV2Int(b), b == 1, x < 3)
3438  [b = 1, x = 2]
3439  """
3440  if __debug__:
3441  _z3_assert(is_bv(a), "Z3 bit-vector expression expected")
3442  ctx = a.ctx
3443  ## investigate problem with bv2int
3444  return ArithRef(Z3_mk_bv2int(ctx.ref(), a.as_ast(), 0), ctx)
3445 
Z3_ast Z3_API Z3_mk_bv2int(__in Z3_context c, __in 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:3428
def is_bv(a)
Definition: z3py.py:3401
def z3py.BVRedAnd (   a)
Return the reduction-and expression of `a`.

Definition at line 3827 of file z3py.py.

3827 def BVRedAnd(a):
3828  """Return the reduction-and expression of `a`."""
3829  if __debug__:
3830  _z3_assert(is_bv(a), "First argument must be a Z3 Bitvector expression")
3831  return BitVecRef(Z3_mk_bvredand(a.ctx_ref(), a.as_ast()), a.ctx)
3832 
def BVRedAnd(a)
Definition: z3py.py:3827
def is_bv(a)
Definition: z3py.py:3401
Z3_ast Z3_API Z3_mk_bvredand(__in Z3_context c, __in Z3_ast t1)
Take conjunction of bits in vector, return vector of length 1.
def z3py.BVRedOr (   a)
Return the reduction-or expression of `a`.

Definition at line 3833 of file z3py.py.

3833 def BVRedOr(a):
3834  """Return the reduction-or expression of `a`."""
3835  if __debug__:
3836  _z3_assert(is_bv(a), "First argument must be a Z3 Bitvector expression")
3837  return BitVecRef(Z3_mk_bvredor(a.ctx_ref(), a.as_ast()), a.ctx)
3838 
def BVRedOr(a)
Definition: z3py.py:3833
Z3_ast Z3_API Z3_mk_bvredor(__in Z3_context c, __in Z3_ast t1)
Take disjunction of bits in vector, return vector of length 1.
def is_bv(a)
Definition: z3py.py:3401
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 2890 of file z3py.py.

2890 def Cbrt(a, ctx=None):
2891  """ Return a Z3 expression which represents the cubic root of a.
2892 
2893  >>> x = Real('x')
2894  >>> Cbrt(x)
2895  x**(1/3)
2896  """
2897  if not is_expr(a):
2898  ctx = _get_ctx(ctx)
2899  a = RealVal(a, ctx)
2900  return a ** "1/3"
2901 
def Cbrt
Definition: z3py.py:2890
def RealVal
Definition: z3py.py:2683
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 3519 of file z3py.py.

Referenced by BitVecRef.size().

3519 def Concat(*args):
3520  """Create a Z3 bit-vector concatenation expression.
3521 
3522  >>> v = BitVecVal(1, 4)
3523  >>> Concat(v, v+1, v)
3524  Concat(Concat(1, 1 + 1), 1)
3525  >>> simplify(Concat(v, v+1, v))
3526  289
3527  >>> print("%.3x" % simplify(Concat(v, v+1, v)).as_long())
3528  121
3529  """
3530  args = _get_args(args)
3531  if __debug__:
3532  _z3_assert(all([is_bv(a) for a in args]), "All arguments must be Z3 bit-vector expressions.")
3533  _z3_assert(len(args) >= 2, "At least two arguments expected.")
3534  ctx = args[0].ctx
3535  r = args[0]
3536  for i in range(len(args) - 1):
3537  r = BitVecRef(Z3_mk_concat(ctx.ref(), r.as_ast(), args[i+1].as_ast()), ctx)
3538  return r
3539 
Z3_ast Z3_API Z3_mk_concat(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Concatenate the given bit-vectors.
def is_bv(a)
Definition: z3py.py:3401
def Concat(args)
Definition: z3py.py:3519
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 6963 of file z3py.py.

Referenced by If().

6963 def Cond(p, t1, t2, ctx=None):
6964  """Return a tactic that applies tactic `t1` to a goal if probe `p` evaluates to true, and `t2` otherwise.
6965 
6966  >>> t = Cond(Probe('is-qfnra'), Tactic('qfnra'), Tactic('smt'))
6967  """
6968  p = _to_probe(p, ctx)
6969  t1 = _to_tactic(t1, ctx)
6970  t2 = _to_tactic(t2, ctx)
6971  return Tactic(Z3_tactic_cond(t1.ctx.ref(), p.probe, t1.tactic, t2.tactic), t1.ctx)
6972 
Z3_tactic Z3_API Z3_tactic_cond(__in Z3_context c, __in Z3_probe p, __in Z3_tactic t1, __in 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 Cond
Definition: z3py.py:6963
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(__in Z3_context c, __in Z3_symbol s, __in Z3_sort ty)
Declare and create a constant.
def Const(name, sort)
Definition: z3py.py:1145
def to_symbol
Definition: z3py.py:94
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 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 4232 of file z3py.py.

Referenced by Datatype.create().

4233  """Create mutually recursive Z3 datatypes using 1 or more Datatype helper objects.
4234 
4235  In the following example we define a Tree-List using two mutually recursive datatypes.
4236 
4237  >>> TreeList = Datatype('TreeList')
4238  >>> Tree = Datatype('Tree')
4239  >>> # Tree has two constructors: leaf and node
4240  >>> Tree.declare('leaf', ('val', IntSort()))
4241  >>> # a node contains a list of trees
4242  >>> Tree.declare('node', ('children', TreeList))
4243  >>> TreeList.declare('nil')
4244  >>> TreeList.declare('cons', ('car', Tree), ('cdr', TreeList))
4245  >>> Tree, TreeList = CreateDatatypes(Tree, TreeList)
4246  >>> Tree.val(Tree.leaf(10))
4247  val(leaf(10))
4248  >>> simplify(Tree.val(Tree.leaf(10)))
4249  10
4250  >>> n1 = Tree.node(TreeList.cons(Tree.leaf(10), TreeList.cons(Tree.leaf(20), TreeList.nil)))
4251  >>> n1
4252  node(cons(leaf(10), cons(leaf(20), nil)))
4253  >>> n2 = Tree.node(TreeList.cons(n1, TreeList.nil))
4254  >>> simplify(n2 == n1)
4255  False
4256  >>> simplify(TreeList.car(Tree.children(n2)) == n1)
4257  True
4258  """
4259  ds = _get_args(ds)
4260  if __debug__:
4261  _z3_assert(len(ds) > 0, "At least one Datatype must be specified")
4262  _z3_assert(all([isinstance(d, Datatype) for d in ds]), "Arguments must be Datatypes")
4263  _z3_assert(all([d.ctx == ds[0].ctx for d in ds]), "Context mismatch")
4264  _z3_assert(all([d.constructors != [] for d in ds]), "Non-empty Datatypes expected")
4265  ctx = ds[0].ctx
4266  num = len(ds)
4267  names = (Symbol * num)()
4268  out = (Sort * num)()
4269  clists = (ConstructorList * num)()
4270  to_delete = []
4271  for i in range(num):
4272  d = ds[i]
4273  names[i] = to_symbol(d.name, ctx)
4274  num_cs = len(d.constructors)
4275  cs = (Constructor * num_cs)()
4276  for j in range(num_cs):
4277  c = d.constructors[j]
4278  cname = to_symbol(c[0], ctx)
4279  rname = to_symbol(c[1], ctx)
4280  fs = c[2]
4281  num_fs = len(fs)
4282  fnames = (Symbol * num_fs)()
4283  sorts = (Sort * num_fs)()
4284  refs = (ctypes.c_uint * num_fs)()
4285  for k in range(num_fs):
4286  fname = fs[k][0]
4287  ftype = fs[k][1]
4288  fnames[k] = to_symbol(fname, ctx)
4289  if isinstance(ftype, Datatype):
4290  if __debug__:
4291  _z3_assert(ds.count(ftype) == 1, "One and only one occurrence of each datatype is expected")
4292  sorts[k] = None
4293  refs[k] = ds.index(ftype)
4294  else:
4295  if __debug__:
4296  _z3_assert(is_sort(ftype), "Z3 sort expected")
4297  sorts[k] = ftype.ast
4298  refs[k] = 0
4299  cs[j] = Z3_mk_constructor(ctx.ref(), cname, rname, num_fs, fnames, sorts, refs)
4300  to_delete.append(ScopedConstructor(cs[j], ctx))
4301  clists[i] = Z3_mk_constructor_list(ctx.ref(), num_cs, cs)
4302  to_delete.append(ScopedConstructorList(clists[i], ctx))
4303  Z3_mk_datatypes(ctx.ref(), num, names, out, clists)
4304  result = []
4305  ## Create a field for every constructor, recognizer and accessor
4306  for i in range(num):
4307  dref = DatatypeSortRef(out[i], ctx)
4308  num_cs = dref.num_constructors()
4309  for j in range(num_cs):
4310  cref = dref.constructor(j)
4311  cref_name = cref.name()
4312  cref_arity = cref.arity()
4313  if cref.arity() == 0:
4314  cref = cref()
4315  setattr(dref, cref_name, cref)
4316  rref = dref.recognizer(j)
4317  setattr(dref, rref.name(), rref)
4318  for k in range(cref_arity):
4319  aref = dref.accessor(j, k)
4320  setattr(dref, aref.name(), aref)
4321  result.append(dref)
4322  return tuple(result)
4323 
def CreateDatatypes(ds)
Definition: z3py.py:4232
def is_sort(s)
Definition: z3py.py:532
BEGIN_MLAPI_EXCLUDE Z3_constructor Z3_API Z3_mk_constructor(__in Z3_context c, __in Z3_symbol name, __in Z3_symbol recognizer, __in unsigned num_fields, __in_ecount(num_fields) Z3_symbol const field_names[], __in_ecount(num_fields) Z3_sort_opt const sorts[], __in_ecount(num_fields) unsigned sort_refs[])
Create a constructor.
void Z3_API Z3_mk_datatypes(__in Z3_context c, __in unsigned num_sorts, __in_ecount(num_sorts) Z3_symbol const sort_names[], __out_ecount(num_sorts) Z3_sort sorts[], __inout_ecount(num_sorts) Z3_constructor_list constructor_lists[])
Create mutually recursive datatypes.
def to_symbol
Definition: z3py.py:94
Z3_constructor_list Z3_API Z3_mk_constructor_list(__in Z3_context c, __in unsigned num_constructors, __in_ecount(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 
Z3_sort Z3_API Z3_mk_uninterpreted_sort(__in Z3_context c, __in Z3_symbol s)
Create a free (uninterpreted) type using the given name (symbol).
def DeclareSort
Definition: z3py.py:567
def to_symbol
Definition: z3py.py:94
def z3py.describe_probes ( )
Display a (tabular) description of all available probes in Z3.

Definition at line 6893 of file z3py.py.

6894  """Display a (tabular) description of all available probes in Z3."""
6895  if in_html_mode():
6896  even = True
6897  print('<table border="1" cellpadding="2" cellspacing="0">')
6898  for p in probes():
6899  if even:
6900  print('<tr style="background-color:#CFCFCF">')
6901  even = False
6902  else:
6903  print('<tr>')
6904  even = True
6905  print('<td>%s</td><td>%s</td></tr>' % (p, insert_line_breaks(probe_description(p), 40)))
6906  print('</table>')
6907  else:
6908  for p in probes():
6909  print('%s : %s' % (p, probe_description(p)))
6910 
def probe_description
Definition: z3py.py:6885
def probes
Definition: z3py.py:6875
def describe_probes()
Definition: z3py.py:6893
def z3py.describe_tactics ( )
Display a (tabular) description of all available tactics in Z3.

Definition at line 6705 of file z3py.py.

6706  """Display a (tabular) description of all available tactics in Z3."""
6707  if in_html_mode():
6708  even = True
6709  print('<table border="1" cellpadding="2" cellspacing="0">')
6710  for t in tactics():
6711  if even:
6712  print('<tr style="background-color:#CFCFCF">')
6713  even = False
6714  else:
6715  print('<tr>')
6716  even = True
6717  print('<td>%s</td><td>%s</td></tr>' % (t, insert_line_breaks(tactic_description(t), 40)))
6718  print('</table>')
6719  else:
6720  for t in tactics():
6721  print('%s : %s' % (t, tactic_description(t)))
6722 
def describe_tactics()
Definition: z3py.py:6705
def tactic_description
Definition: z3py.py:6697
def tactics
Definition: z3py.py:6687
def z3py.disable_trace (   msg)

Definition at line 61 of file z3py.py.

61 def disable_trace(msg):
62  Z3_disable_trace(msg)
63 
def disable_trace(msg)
Definition: z3py.py:61
void Z3_API Z3_disable_trace(__in Z3_string tag)
Disable tracing messages tagged as tag when Z3 is compiled in debug mode. It is a NOOP otherwise...
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(__in Z3_context c, __in unsigned num_args, __in_ecount(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(__in 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 4421 of file z3py.py.

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

4421 def EnumSort(name, values, ctx=None):
4422  """Return a new enumeration sort named `name` containing the given values.
4423 
4424  The result is a pair (sort, list of constants).
4425  Example:
4426  >>> Color, (red, green, blue) = EnumSort('Color', ['red', 'green', 'blue'])
4427  """
4428  if __debug__:
4429  _z3_assert(isinstance(name, str), "Name must be a string")
4430  _z3_assert(all([isinstance(v, str) for v in values]), "Eumeration sort values must be strings")
4431  _z3_assert(len(values) > 0, "At least one value expected")
4432  ctx = _get_ctx(ctx)
4433  num = len(values)
4434  _val_names = (Symbol * num)()
4435  for i in range(num):
4436  _val_names[i] = to_symbol(values[i])
4437  _values = (FuncDecl * num)()
4438  _testers = (FuncDecl * num)()
4439  name = to_symbol(name)
4440  S = DatatypeSortRef(Z3_mk_enumeration_sort(ctx.ref(), name, num, _val_names, _values, _testers), ctx)
4441  V = []
4442  for i in range(num):
4443  V.append(FuncDeclRef(_values[i], ctx))
4444  V = [a() for a in V]
4445  return S, V
4446 
Function Declarations.
Definition: z3py.py:591
Z3_sort Z3_API Z3_mk_enumeration_sort(__in Z3_context c, __in Z3_symbol name, __in unsigned n, __in_ecount(n) Z3_symbol const enum_names[], __out_ecount(n) Z3_func_decl enum_consts[], __out_ecount(n) Z3_func_decl enum_testers[])
Create a enumeration sort.
def EnumSort
Definition: z3py.py:4421
def to_symbol
Definition: z3py.py:94
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 372 of file z3py.py.

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

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

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

1819 def Exists(vs, body, weight=1, qid="", skid="", patterns=[], no_patterns=[]):
1820  """Create a Z3 exists formula.
1821 
1822  The parameters `weight`, `qif`, `skid`, `patterns` and `no_patterns` are optional annotations.
1823 
1824  See http://rise4fun.com/Z3Py/tutorial/advanced for more details.
1825 
1826  >>> f = Function('f', IntSort(), IntSort(), IntSort())
1827  >>> x = Int('x')
1828  >>> y = Int('y')
1829  >>> q = Exists([x, y], f(x, y) >= x, skid="foo")
1830  >>> q
1831  Exists([x, y], f(x, y) >= x)
1832  >>> is_quantifier(q)
1833  True
1834  >>> r = Tactic('nnf')(q).as_expr()
1835  >>> is_quantifier(r)
1836  False
1837  """
1838  return _mk_quantifier(False, vs, body, weight, qid, skid, patterns, no_patterns)
1839 
def Exists
Definition: z3py.py:1819
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 3540 of file z3py.py.

3540 def Extract(high, low, a):
3541  """Create a Z3 bit-vector extraction expression.
3542 
3543  >>> x = BitVec('x', 8)
3544  >>> Extract(6, 2, x)
3545  Extract(6, 2, x)
3546  >>> Extract(6, 2, x).sort()
3547  BitVec(5)
3548  """
3549  if __debug__:
3550  _z3_assert(low <= high, "First argument must be greater than or equal to second argument")
3551  _z3_assert(isinstance(high, int) and high >= 0 and isinstance(low, int) and low >= 0, "First and second arguments must be non negative integers")
3552  _z3_assert(is_bv(a), "Third argument must be a Z3 Bitvector expression")
3553  return BitVecRef(Z3_mk_extract(a.ctx_ref(), high, low, a.as_ast()), a.ctx)
3554 
def Extract(high, low, a)
Definition: z3py.py:3540
Z3_ast Z3_API Z3_mk_extract(__in Z3_context c, __in unsigned high, __in unsigned low, __in 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:3401
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 6926 of file z3py.py.

6926 def FailIf(p, ctx=None):
6927  """Return a tactic that fails if the probe `p` evaluates to true. Otherwise, it returns the input goal unmodified.
6928 
6929  In the following example, the tactic applies 'simplify' if and only if there are more than 2 constraints in the goal.
6930 
6931  >>> t = OrElse(FailIf(Probe('size') > 2), Tactic('simplify'))
6932  >>> x, y = Ints('x y')
6933  >>> g = Goal()
6934  >>> g.add(x > 0)
6935  >>> g.add(y > 0)
6936  >>> t(g)
6937  [[x > 0, y > 0]]
6938  >>> g.add(x == y + 1)
6939  >>> t(g)
6940  [[Not(x <= 0), Not(y <= 0), x == 1 + y]]
6941  """
6942  p = _to_probe(p, ctx)
6943  return Tactic(Z3_tactic_fail_if(p.ctx.ref(), p.probe), p.ctx)
6944 
Z3_tactic Z3_API Z3_tactic_fail_if(__in Z3_context c, __in Z3_probe p)
Return a tactic that fails if the probe p evaluates to false.
def FailIf
Definition: z3py.py:6926
def z3py.Float128 (   ctx = None)
Floating-point 128-bit (quadruple) sort.

Definition at line 7565 of file z3py.py.

7565 def Float128(ctx=None):
7566  """Floating-point 128-bit (quadruple) sort."""
7567  ctx = _get_ctx(ctx)
7568  return FPSortRef(Z3_mk_fpa_sort_128(ctx.ref()), ctx)
7569 
Z3_sort Z3_API Z3_mk_fpa_sort_128(__in Z3_context c)
Create the quadruple-precision (128-bit) FloatingPoint sort.
def Float128
Definition: z3py.py:7565
FP Sorts.
Definition: z3py.py:7499
def z3py.Float16 (   ctx = None)
Floating-point 16-bit (half) sort.

Definition at line 7535 of file z3py.py.

7535 def Float16(ctx=None):
7536  """Floating-point 16-bit (half) sort."""
7537  ctx = _get_ctx(ctx)
7538  return FPSortRef(Z3_mk_fpa_sort_16(ctx.ref()), ctx)
7539 
FP Sorts.
Definition: z3py.py:7499
def Float16
Definition: z3py.py:7535
Z3_sort Z3_API Z3_mk_fpa_sort_16(__in 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 7545 of file z3py.py.

7545 def Float32(ctx=None):
7546  """Floating-point 32-bit (single) sort."""
7547  ctx = _get_ctx(ctx)
7548  return FPSortRef(Z3_mk_fpa_sort_32(ctx.ref()), ctx)
7549 
Z3_sort Z3_API Z3_mk_fpa_sort_32(__in Z3_context c)
Create the single-precision (32-bit) FloatingPoint sort.
def Float32
Definition: z3py.py:7545
FP Sorts.
Definition: z3py.py:7499
def z3py.Float64 (   ctx = None)
Floating-point 64-bit (double) sort.

Definition at line 7555 of file z3py.py.

7555 def Float64(ctx=None):
7556  """Floating-point 64-bit (double) sort."""
7557  ctx = _get_ctx(ctx)
7558  return FPSortRef(Z3_mk_fpa_sort_64(ctx.ref()), ctx)
7559 
Z3_sort Z3_API Z3_mk_fpa_sort_64(__in Z3_context c)
Create the double-precision (64-bit) FloatingPoint sort.
def Float64
Definition: z3py.py:7555
FP Sorts.
Definition: z3py.py:7499
def z3py.FloatHalf (   ctx = None)
Floating-point 16-bit (half) sort.

Definition at line 7540 of file z3py.py.

7540 def FloatHalf(ctx=None):
7541  """Floating-point 16-bit (half) sort."""
7542  ctx = _get_ctx(ctx)
7543  return FPSortRef(Z3_mk_fpa_sort_half(ctx.ref()), ctx)
7544 
Z3_sort Z3_API Z3_mk_fpa_sort_half(__in Z3_context c)
Create the half-precision (16-bit) FloatingPoint sort.
def FloatHalf
Definition: z3py.py:7540
FP Sorts.
Definition: z3py.py:7499
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 7550 of file z3py.py.

7550 def FloatSingle(ctx=None):
7551  """Floating-point 32-bit (single) sort."""
7552  ctx = _get_ctx(ctx)
7553  return FPSortRef(Z3_mk_fpa_sort_single(ctx.ref()), ctx)
7554 
def FloatSingle
Definition: z3py.py:7550
Z3_sort Z3_API Z3_mk_fpa_sort_single(__in Z3_context c)
Create the single-precision (32-bit) FloatingPoint sort.
FP Sorts.
Definition: z3py.py:7499
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 1800 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().

1800 def ForAll(vs, body, weight=1, qid="", skid="", patterns=[], no_patterns=[]):
1801  """Create a Z3 forall formula.
1802 
1803  The parameters `weight`, `qif`, `skid`, `patterns` and `no_patterns` are optional annotations.
1804 
1805  See http://rise4fun.com/Z3Py/tutorial/advanced for more details.
1806 
1807  >>> f = Function('f', IntSort(), IntSort(), IntSort())
1808  >>> x = Int('x')
1809  >>> y = Int('y')
1810  >>> ForAll([x, y], f(x, y) >= x)
1811  ForAll([x, y], f(x, y) >= x)
1812  >>> ForAll([x, y], f(x, y) >= x, patterns=[ f(x, y) ])
1813  ForAll([x, y], f(x, y) >= x)
1814  >>> ForAll([x, y], f(x, y) >= x, weight=10)
1815  ForAll([x, y], f(x, y) >= x)
1816  """
1817  return _mk_quantifier(True, vs, body, weight, qid, skid, patterns, no_patterns)
1818 
def ForAll
Definition: z3py.py:1800
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 8008 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().

8008 def FP(name, fpsort, ctx=None):
8009  """Return a floating-point constant named `name`.
8010  `fpsort` is the floating-point sort.
8011  If `ctx=None`, then the global context is used.
8012 
8013  >>> x = FP('x', FPSort(8, 24))
8014  >>> is_fp(x)
8015  True
8016  >>> x.ebits()
8017  8
8018  >>> x.sort()
8019  FPSort(8, 24)
8020  >>> word = FPSort(8, 24)
8021  >>> x2 = FP('x', word)
8022  >>> eq(x, x2)
8023  True
8024  """
8025  ctx = fpsort.ctx
8026  return FPRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), fpsort.ast), ctx)
8027 
Z3_ast Z3_API Z3_mk_const(__in Z3_context c, __in Z3_symbol s, __in Z3_sort ty)
Declare and create a constant.
def FP
Definition: z3py.py:8008
FP Expressions.
Definition: z3py.py:7601
def to_symbol
Definition: z3py.py:94
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 8048 of file z3py.py.

8048 def fpAbs(a):
8049  """Create a Z3 floating-point absolute value expression.
8050 
8051  >>> s = FPSort(8, 24)
8052  >>> rm = RNE()
8053  >>> x = FPVal(1.0, s)
8054  >>> fpAbs(x)
8055  fpAbs(1)
8056  >>> y = FPVal(-20.0, s)
8057  >>> y
8058  -1.25*(2**4)
8059  >>> fpAbs(y)
8060  fpAbs(-1.25*(2**4))
8061  >>> fpAbs(-1.25*(2**4))
8062  fpAbs(-1.25*(2**4))
8063  >>> fpAbs(x).sort()
8064  FPSort(8, 24)
8065  """
8066  ctx = None
8067  if not is_expr(a):
8068  ctx =_get_ctx(ctx)
8069  s = get_default_fp_sort(ctx)
8070  a = FPVal(a, s)
8071  else:
8072  ctx = a.ctx
8073  if __debug__:
8074  _z3_assert(is_fp(a), "First argument must be Z3 floating-point expression")
8075  return FPRef(Z3_mk_fpa_abs(a.ctx_ref(), a.as_ast()), a.ctx)
8076 
FP Expressions.
Definition: z3py.py:7601
def fpAbs(a)
Definition: z3py.py:8048
def FPVal
Definition: z3py.py:7979
def get_default_fp_sort
Definition: z3py.py:7482
def is_expr(a)
Definition: z3py.py:961
def is_fp(a)
Definition: z3py.py:7893
Z3_ast Z3_API Z3_mk_fpa_abs(__in Z3_context c, __in Z3_ast t)
Floating-point absolute value.
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 8099 of file z3py.py.

8099 def fpAdd(rm, a, b):
8100  """Create a Z3 floating-point addition expression.
8101 
8102  >>> s = FPSort(8, 24)
8103  >>> rm = RNE()
8104  >>> x = FP('x', s)
8105  >>> y = FP('y', s)
8106  >>> fpAdd(rm, x, y)
8107  fpAdd(RNE(), x, y)
8108  >>> fpAdd(rm, x, y).sort()
8109  FPSort(8, 24)
8110  """
8111  if __debug__:
8112  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
8113  _z3_assert(is_fp(a) or is_fp(b), "Second or third argument must be a Z3 floating-point expression")
8114  a, b = _coerce_exprs(a, b)
8115  return FPRef(Z3_mk_fpa_add(rm.ctx_ref(), rm.as_ast(), a.as_ast(), b.as_ast()), rm.ctx)
8116 
def fpAdd(rm, a, b)
Definition: z3py.py:8099
FP Expressions.
Definition: z3py.py:7601
Z3_ast Z3_API Z3_mk_fpa_add(__in Z3_context c, __in Z3_ast rm, __in Z3_ast t1, __in Z3_ast t2)
Floating-point addition.
def is_fprm(a)
Definition: z3py.py:7797
def is_fp(a)
Definition: z3py.py:7893
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 8153 of file z3py.py.

8153 def fpDiv(rm, a, b):
8154  """Create a Z3 floating-point divison expression.
8155 
8156  >>> s = FPSort(8, 24)
8157  >>> rm = RNE()
8158  >>> x = FP('x', s)
8159  >>> y = FP('y', s)
8160  >>> fpDiv(rm, x, y)
8161  fpDiv(RNE(), x, y)
8162  >>> fpDiv(rm, x, y).sort()
8163  FPSort(8, 24)
8164  """
8165  if __debug__:
8166  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
8167  _z3_assert(is_fp(a) or is_fp(b), "Second or third argument must be a Z3 floating-point expression")
8168  a, b = _coerce_exprs(a, b)
8169  return FPRef(Z3_mk_fpa_div(rm.ctx_ref(), rm.as_ast(), a.as_ast(), b.as_ast()), rm.ctx)
8170 
FP Expressions.
Definition: z3py.py:7601
Z3_ast Z3_API Z3_mk_fpa_div(__in Z3_context c, __in Z3_ast rm, __in Z3_ast t1, __in Z3_ast t2)
Floating-point division.
def fpDiv(rm, a, b)
Definition: z3py.py:8153
def is_fprm(a)
Definition: z3py.py:7797
def is_fp(a)
Definition: z3py.py:7893
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 8368 of file z3py.py.

Referenced by fpNEQ().

8368 def fpEQ(a, b):
8369  """Create the Z3 floating-point expression `other <= self`.
8370 
8371  >>> x, y = FPs('x y', FPSort(8, 24))
8372  >>> fpEQ(x, y)
8373  fpEQ(x, y)
8374  >>> fpEQ(x, y).sexpr()
8375  '(fp.eq x y)'
8376  """
8377  _check_fp_args(a, b)
8378  a, b = _coerce_exprs(a, b)
8379  return BoolRef(Z3_mk_fpa_eq(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
8380 
Z3_ast Z3_API Z3_mk_fpa_eq(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Floating-point equality.
def fpEQ(a, b)
Definition: z3py.py:8368
def z3py.fpFMA (   rm,
  a,
  b,
  c 
)
Create a Z3 floating-point fused multiply-add expression.

Definition at line 8221 of file z3py.py.

8221 def fpFMA(rm, a, b, c):
8222  """Create a Z3 floating-point fused multiply-add expression.
8223  """
8224  if __debug__:
8225  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
8226  _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")
8227  a, b, c = _coerce_expr_list([a, b, c])
8228  return FPRef(Z3_mk_fpa_fma(rm.ctx_ref(), rm.as_ast(), a.as_ast(), b.as_ast(), c.as_ast()), rm.ctx)
8229 
FP Expressions.
Definition: z3py.py:7601
def fpFMA(rm, a, b, c)
Definition: z3py.py:8221
Z3_ast Z3_API Z3_mk_fpa_fma(__in Z3_context c, __in Z3_ast rm, __in Z3_ast t1, __in Z3_ast t2, __in Z3_ast t3)
Floating-point fused multiply-add.
def is_fprm(a)
Definition: z3py.py:7797
def is_fp(a)
Definition: z3py.py:7893
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 8396 of file z3py.py.

8396 def fpFP(sgn, exp, sig):
8397  """Create the Z3 floating-point value `fpFP(sgn, sig, exp)` from the three bit-vectorssgn, sig, and exp."""
8398  _z3_assert(is_bv(sgn) and is_bv(exp) and is_bv(sig), "sort mismatch")
8399  _z3_assert(sgn.sort().size() == 1, "sort mismatch")
8400  return FPRef(Z3_mk_fpa_fp(sgn.ctx_ref(), sgn.ast, exp.ast, sig.ast), sgn.ctx)
8401 
8402 
FP Expressions.
Definition: z3py.py:7601
def fpFP(sgn, exp, sig)
Definition: z3py.py:8396
Z3_ast Z3_API Z3_mk_fpa_fp(__in Z3_context c, __in Z3_ast sgn, __in Z3_ast exp, __in Z3_ast sig)
Create an expression of FloatingPoint sort from three bit-vector expressions.
def is_bv(a)
Definition: z3py.py:3401
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 8353 of file z3py.py.

8353 def fpGEQ(a, b):
8354  """Create the Z3 floating-point expression `other <= self`.
8355 
8356  >>> x, y = FPs('x y', FPSort(8, 24))
8357  >>> x + y
8358  x + y
8359  >>> fpGEQ(x, y)
8360  x >= y
8361  >>> (x >= y).sexpr()
8362  '(fp.geq x y)'
8363  """
8364  _check_fp_args(a, b)
8365  a, b = _coerce_exprs(a, b)
8366  return BoolRef(Z3_mk_fpa_geq(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
8367 
Z3_ast Z3_API Z3_mk_fpa_geq(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Floating-point greater than or equal.
def fpGEQ(a, b)
Definition: z3py.py:8353
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 8339 of file z3py.py.

8339 def fpGT(a, b):
8340  """Create the Z3 floating-point expression `other <= self`.
8341 
8342  >>> x, y = FPs('x y', FPSort(8, 24))
8343  >>> fpGT(x, y)
8344  x > y
8345  >>> (x > y).sexpr()
8346  '(fp.gt x y)'
8347  """
8348  _check_fp_args(a, b)
8349  a, b = _coerce_exprs(a, b)
8350  return BoolRef(Z3_mk_fpa_gt(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
8351 
8352 
def fpGT(a, b)
Definition: z3py.py:8339
Z3_ast Z3_API Z3_mk_fpa_gt(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Floating-point greater than.
def z3py.fpInfinity (   s,
  negative 
)

Definition at line 7961 of file z3py.py.

7961 def fpInfinity(s, negative):
7962  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
7963  _z3_assert(isinstance(negative, bool), "expected Boolean flag")
7964  return FPNumRef(Z3_mk_fpa_inf(s.ctx_ref(), s.ast, negative), s.ctx)
7965 
Z3_ast Z3_API Z3_mk_fpa_inf(__in Z3_context c, __in Z3_sort s, __in Z3_bool negative)
Create a floating-point infinity of sort s.
FP Numerals.
Definition: z3py.py:7815
def fpInfinity(s, negative)
Definition: z3py.py:7961
def z3py.fpIsInfinite (   a)
Create a Z3 floating-point isNaN expression.

Definition at line 8267 of file z3py.py.

8268  """Create a Z3 floating-point isNaN expression.
8269  """
8270  if __debug__:
8271  _z3_assert(is_fp(a), "Argument must be Z3 floating-point expressions")
8272  return FPRef(Z3_mk_fpa_is_infinite(a.ctx_ref(), a.as_ast()), a.ctx)
8273 
FP Expressions.
Definition: z3py.py:7601
def fpIsInfinite(a)
Definition: z3py.py:8267
Z3_ast Z3_API Z3_mk_fpa_is_infinite(__in Z3_context c, __in Z3_ast t)
Predicate indicating whether t is a floating-point number representing +oo or -oo.
def is_fp(a)
Definition: z3py.py:7893
def z3py.fpIsNaN (   a)
Create a Z3 floating-point isNaN expression.

Definition at line 8260 of file z3py.py.

8260 def fpIsNaN(a):
8261  """Create a Z3 floating-point isNaN expression.
8262  """
8263  if __debug__:
8264  _z3_assert(is_fp(a), "Argument must be Z3 floating-point expressions")
8265  return FPRef(Z3_mk_fpa_is_nan(a.ctx_ref(), a.as_ast()), a.ctx)
8266 
FP Expressions.
Definition: z3py.py:7601
def fpIsNaN(a)
Definition: z3py.py:8260
Z3_ast Z3_API Z3_mk_fpa_is_nan(__in Z3_context c, __in Z3_ast t)
Predicate indicating whether t is a NaN.
def is_fp(a)
Definition: z3py.py:7893
def z3py.fpIsNegative (   a)
Create a Z3 floating-point isNaN expression.

Definition at line 8295 of file z3py.py.

8296  """Create a Z3 floating-point isNaN expression.
8297  """
8298  if __debug__:
8299  _z3_assert(is_fp(a), "Argument must be Z3 floating-point expressions")
8300  return FPRef(Z3_mk_fpa_is_negative(a.ctx_ref(), a.as_ast()), a.ctx)
8301 
FP Expressions.
Definition: z3py.py:7601
Z3_ast Z3_API Z3_mk_fpa_is_negative(__in Z3_context c, __in Z3_ast t)
Predicate indicating whether t is a negative floating-point number.
def fpIsNegative(a)
Definition: z3py.py:8295
def is_fp(a)
Definition: z3py.py:7893
def z3py.fpIsNormal (   a)
Create a Z3 floating-point isNaN expression.

Definition at line 8281 of file z3py.py.

8281 def fpIsNormal(a):
8282  """Create a Z3 floating-point isNaN expression.
8283  """
8284  if __debug__:
8285  _z3_assert(is_fp(a), "Argument must be Z3 floating-point expressions")
8286  return FPRef(Z3_mk_fpa_is_normal(a.ctx_ref(), a.as_ast()), a.ctx)
8287 
Z3_ast Z3_API Z3_mk_fpa_is_normal(__in Z3_context c, __in Z3_ast t)
Predicate indicating whether t is a normal floating-point number.
def fpIsNormal(a)
Definition: z3py.py:8281
FP Expressions.
Definition: z3py.py:7601
def is_fp(a)
Definition: z3py.py:7893
def z3py.fpIsPositive (   a)
Create a Z3 floating-point isNaN expression.

Definition at line 8302 of file z3py.py.

8303  """Create a Z3 floating-point isNaN expression.
8304  """
8305  if __debug__:
8306  _z3_assert(is_fp(a), "Argument must be Z3 floating-point expressions")
8307  return FPRef(Z3_mk_fpa_is_positive(a.ctx_ref(), a.as_ast()), a.ctx)
8308 
def fpIsPositive(a)
Definition: z3py.py:8302
FP Expressions.
Definition: z3py.py:7601
Z3_ast Z3_API Z3_mk_fpa_is_positive(__in Z3_context c, __in Z3_ast t)
Predicate indicating whether t is a positive floating-point number.
def is_fp(a)
Definition: z3py.py:7893
def z3py.fpIsSubnormal (   a)
Create a Z3 floating-point isNaN expression.

Definition at line 8288 of file z3py.py.

8289  """Create a Z3 floating-point isNaN expression.
8290  """
8291  if __debug__:
8292  _z3_assert(is_fp(a), "Argument must be Z3 floating-point expressions")
8293  return FPRef(Z3_mk_fpa_is_subnormal(a.ctx_ref(), a.as_ast()), a.ctx)
8294 
Z3_ast Z3_API Z3_mk_fpa_is_subnormal(__in Z3_context c, __in Z3_ast t)
Predicate indicating whether t is a subnormal floating-point number.
FP Expressions.
Definition: z3py.py:7601
def fpIsSubnormal(a)
Definition: z3py.py:8288
def is_fp(a)
Definition: z3py.py:7893
def z3py.fpIsZero (   a)
Create a Z3 floating-point isNaN expression.

Definition at line 8274 of file z3py.py.

8274 def fpIsZero(a):
8275  """Create a Z3 floating-point isNaN expression.
8276  """
8277  if __debug__:
8278  _z3_assert(is_fp(a), "Argument must be Z3 floating-point expressions")
8279  return FPRef(Z3_mk_fpa_is_zero(a.ctx_ref(), a.as_ast()), a.ctx)
8280 
FP Expressions.
Definition: z3py.py:7601
Z3_ast Z3_API Z3_mk_fpa_is_zero(__in Z3_context c, __in Z3_ast t)
Predicate indicating whether t is a floating-point number with zero value, i.e., +zero or -zero...
def fpIsZero(a)
Definition: z3py.py:8274
def is_fp(a)
Definition: z3py.py:7893
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 8326 of file z3py.py.

8326 def fpLEQ(a, b):
8327  """Create the Z3 floating-point expression `other <= self`.
8328 
8329  >>> x, y = FPs('x y', FPSort(8, 24))
8330  >>> fpLEQ(x, y)
8331  x <= y
8332  >>> (x <= y).sexpr()
8333  '(fp.leq x y)'
8334  """
8335  _check_fp_args(a, b)
8336  a, b = _coerce_exprs(a, b)
8337  return BoolRef(Z3_mk_fpa_leq(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
8338 
def fpLEQ(a, b)
Definition: z3py.py:8326
Z3_ast Z3_API Z3_mk_fpa_leq(__in Z3_context c, __in Z3_ast t1, __in 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 8313 of file z3py.py.

8313 def fpLT(a, b):
8314  """Create the Z3 floating-point expression `other <= self`.
8315 
8316  >>> x, y = FPs('x y', FPSort(8, 24))
8317  >>> fpLT(x, y)
8318  x < y
8319  >>> (x <= y).sexpr()
8320  '(fp.leq x y)'
8321  """
8322  _check_fp_args(a, b)
8323  a, b = _coerce_exprs(a, b)
8324  return BoolRef(Z3_mk_fpa_lt(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
8325 
def fpLT(a, b)
Definition: z3py.py:8313
Z3_ast Z3_API Z3_mk_fpa_lt(__in Z3_context c, __in Z3_ast t1, __in 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 8204 of file z3py.py.

8204 def fpMax(a, b):
8205  """Create a Z3 floating-point maximum expression.
8206 
8207  >>> s = FPSort(8, 24)
8208  >>> rm = RNE()
8209  >>> x = FP('x', s)
8210  >>> y = FP('y', s)
8211  >>> fpMax(x, y)
8212  fpMax(x, y)
8213  >>> fpMax(x, y).sort()
8214  FPSort(8, 24)
8215  """
8216  if __debug__:
8217  _z3_assert(is_fp(a) or is_fp(b), "Second or third argument must be a Z3 floating-point expression")
8218  a, b = _coerce_exprs(a, b)
8219  return FPRef(Z3_mk_fpa_max(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
8220 
FP Expressions.
Definition: z3py.py:7601
def fpMax(a, b)
Definition: z3py.py:8204
Z3_ast Z3_API Z3_mk_fpa_max(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Maximum of floating-point numbers.
def is_fp(a)
Definition: z3py.py:7893
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 8187 of file z3py.py.

8187 def fpMin(a, b):
8188  """Create a Z3 floating-point minimium expression.
8189 
8190  >>> s = FPSort(8, 24)
8191  >>> rm = RNE()
8192  >>> x = FP('x', s)
8193  >>> y = FP('y', s)
8194  >>> fpMin(x, y)
8195  fpMin(x, y)
8196  >>> fpMin(x, y).sort()
8197  FPSort(8, 24)
8198  """
8199  if __debug__:
8200  _z3_assert(is_fp(a) or is_fp(b), "Second or third argument must be a Z3 floating-point expression")
8201  a, b = _coerce_exprs(a, b)
8202  return FPRef(Z3_mk_fpa_min(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
8203 
Z3_ast Z3_API Z3_mk_fpa_min(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Minimum of floating-point numbers.
FP Expressions.
Definition: z3py.py:7601
def fpMin(a, b)
Definition: z3py.py:8187
def is_fp(a)
Definition: z3py.py:7893
def z3py.fpMinusInfinity (   s)

Definition at line 7957 of file z3py.py.

7958  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
7959  return FPNumRef(Z3_mk_fpa_inf(s.ctx_ref(), s.ast, True), s.ctx)
7960 
def fpMinusInfinity(s)
Definition: z3py.py:7957
Z3_ast Z3_API Z3_mk_fpa_inf(__in Z3_context c, __in Z3_sort s, __in Z3_bool negative)
Create a floating-point infinity of sort s.
FP Numerals.
Definition: z3py.py:7815
def z3py.fpMinusZero (   s)

Definition at line 7970 of file z3py.py.

7971  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
7972  return FPNumRef(Z3_mk_fpa_zero(s.ctx_ref(), s.ast, True), s.ctx)
7973 
def fpMinusZero(s)
Definition: z3py.py:7970
FP Numerals.
Definition: z3py.py:7815
Z3_ast Z3_API Z3_mk_fpa_zero(__in Z3_context c, __in Z3_sort s, __in 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 8135 of file z3py.py.

8135 def fpMul(rm, a, b):
8136  """Create a Z3 floating-point multiplication expression.
8137 
8138  >>> s = FPSort(8, 24)
8139  >>> rm = RNE()
8140  >>> x = FP('x', s)
8141  >>> y = FP('y', s)
8142  >>> fpMul(rm, x, y)
8143  fpMul(RNE(), x, y)
8144  >>> fpMul(rm, x, y).sort()
8145  FPSort(8, 24)
8146  """
8147  if __debug__:
8148  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
8149  _z3_assert(is_fp(a) or is_fp(b), "Second or third argument must be a Z3 floating-point expression")
8150  a, b = _coerce_exprs(a, b)
8151  return FPRef(Z3_mk_fpa_mul(rm.ctx_ref(), rm.as_ast(), a.as_ast(), b.as_ast()), rm.ctx)
8152 
FP Expressions.
Definition: z3py.py:7601
def fpMul(rm, a, b)
Definition: z3py.py:8135
Z3_ast Z3_API Z3_mk_fpa_mul(__in Z3_context c, __in Z3_ast rm, __in Z3_ast t1, __in Z3_ast t2)
Floating-point multiplication.
def is_fprm(a)
Definition: z3py.py:7797
def is_fp(a)
Definition: z3py.py:7893
def z3py.fpNaN (   s)

Definition at line 7949 of file z3py.py.

7949 def fpNaN(s):
7950  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
7951  return FPNumRef(Z3_mk_fpa_nan(s.ctx_ref(), s.ast), s.ctx)
7952 
Z3_ast Z3_API Z3_mk_fpa_nan(__in Z3_context c, __in Z3_sort s)
Create a floating-point NaN of sort s.
def fpNaN(s)
Definition: z3py.py:7949
FP Numerals.
Definition: z3py.py:7815
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 8077 of file z3py.py.

8077 def fpNeg(a):
8078  """Create a Z3 floating-point addition expression.
8079 
8080  >>> s = FPSort(8, 24)
8081  >>> rm = RNE()
8082  >>> x = FP('x', s)
8083  >>> fpNeg(x)
8084  -x
8085  >>> fpNeg(x).sort()
8086  FPSort(8, 24)
8087  """
8088  ctx = None
8089  if not is_expr(a):
8090  ctx =_get_ctx(ctx)
8091  s = get_default_fp_sort(ctx)
8092  a = FPVal(a, s)
8093  else:
8094  ctx = a.ctx
8095  if __debug__:
8096  _z3_assert(is_fp(a), "First argument must be Z3 floating-point expression")
8097  return FPRef(Z3_mk_fpa_neg(a.ctx_ref(), a.as_ast()), a.ctx)
8098 
FP Expressions.
Definition: z3py.py:7601
def FPVal
Definition: z3py.py:7979
Z3_ast Z3_API Z3_mk_fpa_neg(__in Z3_context c, __in Z3_ast t)
Floating-point negation.
def get_default_fp_sort
Definition: z3py.py:7482
def fpNeg(a)
Definition: z3py.py:8077
def is_expr(a)
Definition: z3py.py:961
def is_fp(a)
Definition: z3py.py:7893
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 8381 of file z3py.py.

8381 def fpNEQ(a, b):
8382  """Create the Z3 floating-point expression `other <= self`.
8383 
8384  >>> x, y = FPs('x y', FPSort(8, 24))
8385  >>> fpNEQ(x, y)
8386  Not(fpEQ(x, y))
8387  >>> (x != y).sexpr()
8388  '(not (fp.eq x y))'
8389  """
8390  _check_fp_args(a, b)
8391  a, b = _coerce_exprs(a, b)
8392  return Not(BoolRef(Z3_mk_fpa_eq(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx), a.ctx)
8393 
8394 
8395 
def Not
Definition: z3py.py:1454
Z3_ast Z3_API Z3_mk_fpa_eq(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Floating-point equality.
def fpNEQ(a, b)
Definition: z3py.py:8381
def z3py.fpPlusInfinity (   s)

Definition at line 7953 of file z3py.py.

7954  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
7955  return FPNumRef(Z3_mk_fpa_inf(s.ctx_ref(), s.ast, False), s.ctx)
7956 
def fpPlusInfinity(s)
Definition: z3py.py:7953
Z3_ast Z3_API Z3_mk_fpa_inf(__in Z3_context c, __in Z3_sort s, __in Z3_bool negative)
Create a floating-point infinity of sort s.
FP Numerals.
Definition: z3py.py:7815
def z3py.fpPlusZero (   s)

Definition at line 7966 of file z3py.py.

7966 def fpPlusZero(s):
7967  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
7968  return FPNumRef(Z3_mk_fpa_zero(s.ctx_ref(), s.ast, False), s.ctx)
7969 
def fpPlusZero(s)
Definition: z3py.py:7966
FP Numerals.
Definition: z3py.py:7815
Z3_ast Z3_API Z3_mk_fpa_zero(__in Z3_context c, __in Z3_sort s, __in 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 8171 of file z3py.py.

8171 def fpRem(a, b):
8172  """Create a Z3 floating-point remainder expression.
8173 
8174  >>> s = FPSort(8, 24)
8175  >>> x = FP('x', s)
8176  >>> y = FP('y', s)
8177  >>> fpRem(x, y)
8178  fpRem(x, y)
8179  >>> fpRem(x, y).sort()
8180  FPSort(8, 24)
8181  """
8182  if __debug__:
8183  _z3_assert(is_fp(a) or is_fp(b), "Second or third argument must be a Z3 floating-point expression")
8184  a, b = _coerce_exprs(a, b)
8185  return FPRef(Z3_mk_fpa_rem(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
8186 
FP Expressions.
Definition: z3py.py:7601
def fpRem(a, b)
Definition: z3py.py:8171
Z3_ast Z3_API Z3_mk_fpa_rem(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Floating-point remainder.
def is_fp(a)
Definition: z3py.py:7893
def z3py.fpRoundToIntegral (   rm,
  a 
)
Create a Z3 floating-point roundToIntegral expression.

Definition at line 8245 of file z3py.py.

8246  """Create a Z3 floating-point roundToIntegral expression.
8247  """
8248  ctx = None
8249  if not is_expr(a):
8250  ctx =_get_ctx(ctx)
8251  s = get_default_fp_sort(ctx)
8252  a = FPVal(a, s)
8253  else:
8254  ctx = a.ctx
8255  if __debug__:
8256  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
8257  _z3_assert(is_fp(a), "Second argument must be a Z3 floating-point expressions")
8258  return FPRef(Z3_mk_fpa_round_to_integral(rm.ctx_ref(), rm.as_ast(), a.as_ast()), rm.ctx)
8259 
def fpRoundToIntegral(rm, a)
Definition: z3py.py:8245
FP Expressions.
Definition: z3py.py:7601
def FPVal
Definition: z3py.py:7979
def get_default_fp_sort
Definition: z3py.py:7482
def is_expr(a)
Definition: z3py.py:961
Z3_ast Z3_API Z3_mk_fpa_round_to_integral(__in Z3_context c, __in Z3_ast rm, __in Z3_ast t)
Floating-point roundToIntegral. Rounds a floating-point number to the closest integer, again represented as a floating-point number.
def is_fprm(a)
Definition: z3py.py:7797
def is_fp(a)
Definition: z3py.py:7893
def z3py.FPs (   names,
  fpsort,
  ctx = None 
)
Return an array of floating-point constants.

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

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

8028 def FPs(names, fpsort, ctx=None):
8029  """Return an array of floating-point constants.
8030 
8031  >>> x, y, z = BitVecs('x y z', 16)
8032  >>> x.size()
8033  16
8034  >>> x.sort()
8035  BitVec(16)
8036  >>> Sum(x, y, z)
8037  0 + x + y + z
8038  >>> Product(x, y, z)
8039  1*x*y*z
8040  >>> simplify(Product(x, y, z))
8041  x*y*z
8042  """
8043  ctx = z3._get_ctx(ctx)
8044  if isinstance(names, str):
8045  names = names.split(" ")
8046  return [FP(name, fpsort, ctx) for name in names]
8047 
def FP
Definition: z3py.py:8008
def FPs
Definition: z3py.py:8028
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 7920 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(), fpSub(), fpToIEEEBV(), fpToReal(), fpToSBV(), fpToUBV(), FPVal(), is_fp(), is_fp_sort(), is_fp_value(), is_fprm_sort(), FPNumRef.isNegative(), 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(), and FPRef.sort().

7920 def FPSort(ebits, sbits, ctx=None):
7921  """Return a Z3 floating-point sort of the given sizes. If `ctx=None`, then the global context is used.
7922 
7923  >>> Single = FPSort(8, 24)
7924  >>> Double = FPSort(11, 53)
7925  >>> Single
7926  FPSort(8, 24)
7927  >>> x = Const('x', Single)
7928  >>> eq(x, FP('x', FPSort(8, 24)))
7929  True
7930  """
7931  ctx = z3._get_ctx(ctx)
7932  return FPSortRef(Z3_mk_fpa_sort(ctx.ref(), ebits, sbits), ctx)
7933 
Z3_sort Z3_API Z3_mk_fpa_sort(__in Z3_context c, __in unsigned ebits, __in unsigned sbits)
Create a FloatingPoint sort.
FP Sorts.
Definition: z3py.py:7499
def FPSort
Definition: z3py.py:7920
def z3py.fpSqrt (   rm,
  a 
)
Create a Z3 floating-point square root expression.

Definition at line 8230 of file z3py.py.

8230 def fpSqrt(rm, a):
8231  """Create a Z3 floating-point square root expression.
8232  """
8233  ctx = None
8234  if not is_expr(a):
8235  ctx =_get_ctx(ctx)
8236  s = get_default_fp_sort(ctx)
8237  a = FPVal(a, s)
8238  else:
8239  ctx = a.ctx
8240  if __debug__:
8241  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
8242  _z3_assert(is_fp(a), "Second argument must be a Z3 floating-point expressions")
8243  return FPRef(Z3_mk_fpa_sqrt(rm.ctx_ref(), rm.as_ast(), a.as_ast()), rm.ctx)
8244 
FP Expressions.
Definition: z3py.py:7601
def fpSqrt(rm, a)
Definition: z3py.py:8230
def FPVal
Definition: z3py.py:7979
Z3_ast Z3_API Z3_mk_fpa_sqrt(__in Z3_context c, __in Z3_ast rm, __in Z3_ast t)
Floating-point square root.
def get_default_fp_sort
Definition: z3py.py:7482
def is_expr(a)
Definition: z3py.py:961
def is_fprm(a)
Definition: z3py.py:7797
def is_fp(a)
Definition: z3py.py:7893
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 8117 of file z3py.py.

8117 def fpSub(rm, a, b):
8118  """Create a Z3 floating-point subtraction expression.
8119 
8120  >>> s = FPSort(8, 24)
8121  >>> rm = RNE()
8122  >>> x = FP('x', s)
8123  >>> y = FP('y', s)
8124  >>> fpSub(rm, x, y)
8125  fpSub(RNE(), x, y)
8126  >>> fpSub(rm, x, y).sort()
8127  FPSort(8, 24)
8128  """
8129  if __debug__:
8130  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
8131  _z3_assert(is_fp(a) or is_fp(b), "Second or third argument must be a Z3 floating-point expression")
8132  a, b = _coerce_exprs(a, b)
8133  return FPRef(Z3_mk_fpa_sub(rm.ctx_ref(), rm.as_ast(), a.as_ast(), b.as_ast()), rm.ctx)
8134 
FP Expressions.
Definition: z3py.py:7601
def fpSub(rm, a, b)
Definition: z3py.py:8117
Z3_ast Z3_API Z3_mk_fpa_sub(__in Z3_context c, __in Z3_ast rm, __in Z3_ast t1, __in Z3_ast t2)
Floating-point subtraction.
def is_fprm(a)
Definition: z3py.py:7797
def is_fp(a)
Definition: z3py.py:7893
def z3py.fpToFP (   a1,
  a2 = None,
  a3 = None 
)
Create a Z3 floating-point conversion expression from other terms.

Definition at line 8403 of file z3py.py.

8403 def fpToFP(a1, a2=None, a3=None):
8404  """Create a Z3 floating-point conversion expression from other terms."""
8405  if is_bv(a1) and is_fp_sort(a2):
8406  return FPRef(Z3_mk_fpa_to_fp_bv(a1.ctx_ref(), a1.ast, a2.ast), a1.ctx)
8407  elif is_fprm(a1) and is_fp(a2) and is_fp_sort(a3):
8408  return FPRef(Z3_mk_fpa_to_fp_float(a1.ctx_ref(), a1.ast, a2.ast, a3.ast), a1.ctx)
8409  elif is_fprm(a1) and is_real(a2) and is_fp_sort(a3):
8410  return FPRef(Z3_mk_fpa_to_fp_real(a1.ctx_ref(), a1.ast, a2.ast, a3.ast), a1.ctx)
8411  elif is_fprm(a1) and is_bv(a2) and is_fp_sort(a3):
8412  return FPRef(Z3_mk_fpa_to_fp_signed(a1.ctx_ref(), a1.ast, a2.ast, a3.ast), a1.ctx)
8413  else:
8414  raise Z3Exception("Unsupported combination of arguments for conversion to floating-point term.")
8415 
Z3_ast Z3_API Z3_mk_fpa_to_fp_bv(__in Z3_context c, __in Z3_ast bv, __in Z3_sort s)
Conversion of a single IEEE 754-2008 bit-vector into a floating-point number.
def fpToFP
Definition: z3py.py:8403
Z3_ast Z3_API Z3_mk_fpa_to_fp_real(__in Z3_context c, __in Z3_ast rm, __in Z3_ast t, __in Z3_sort s)
Conversion of a term of real sort into a term of FloatingPoint sort.
FP Expressions.
Definition: z3py.py:7601
def is_real(a)
Definition: z3py.py:2248
Z3_ast Z3_API Z3_mk_fpa_to_fp_signed(__in Z3_context c, __in Z3_ast rm, __in Z3_ast t, __in Z3_sort s)
Conversion of a 2's complement signed bit-vector term into a term of FloatingPoint sort...
Z3_ast Z3_API Z3_mk_fpa_to_fp_float(__in Z3_context c, __in Z3_ast rm, __in Z3_ast t, __in Z3_sort s)
Conversion of a FloatingPoint term into another term of different FloatingPoint sort.
def is_fp_sort(s)
Definition: z3py.py:7579
def is_bv(a)
Definition: z3py.py:3401
def is_fprm(a)
Definition: z3py.py:7797
def is_fp(a)
Definition: z3py.py:7893
def z3py.fpToFPUnsigned (   rm,
  x,
  s 
)
Create a Z3 floating-point conversion expression, from unsigned bit-vector to floating-point expression.

Definition at line 8416 of file z3py.py.

8416 def fpToFPUnsigned(rm, x, s):
8417  """Create a Z3 floating-point conversion expression, from unsigned bit-vector to floating-point expression."""
8418  if __debug__:
8419  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
8420  _z3_assert(is_bv(x), "Second argument must be a Z3 bit-vector expression")
8421  _z3_assert(is_fp_sort(s), "Third argument must be Z3 floating-point sort")
8422  return FPRef(Z3_mk_fpa_to_fp_unsigned(rm.ctx_ref(), rm.ast, x.ast, s.ast), rm.ctx)
8423 
def fpToFPUnsigned(rm, x, s)
Definition: z3py.py:8416
Z3_ast Z3_API Z3_mk_fpa_to_fp_unsigned(__in Z3_context c, __in Z3_ast rm, __in Z3_ast t, __in Z3_sort s)
Conversion of a 2's complement unsigned bit-vector term into a term of FloatingPoint sort...
FP Expressions.
Definition: z3py.py:7601
def is_fp_sort(s)
Definition: z3py.py:7579
def is_bv(a)
Definition: z3py.py:3401
def is_fprm(a)
Definition: z3py.py:7797
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 8482 of file z3py.py.

8482 def fpToIEEEBV(x):
8483  """\brief Conversion of a floating-point term into a bit-vector term in IEEE 754-2008 format.
8484 
8485  The size of the resulting bit-vector is automatically determined.
8486 
8487  Note that IEEE 754-2008 allows multiple different representations of NaN. This conversion
8488  knows only one NaN and it will always produce the same bit-vector represenatation of
8489  that NaN.
8490 
8491  >>> x = FP('x', FPSort(8, 24))
8492  >>> y = fpToIEEEBV(x)
8493  >>> print is_fp(x)
8494  True
8495  >>> print is_bv(y)
8496  True
8497  >>> print is_fp(y)
8498  False
8499  >>> print is_bv(x)
8500  False
8501  """
8502  if __debug__:
8503  _z3_assert(is_fp(x), "First argument must be a Z3 floating-point expression")
8504  return BitVecRef(Z3_mk_fpa_to_ieee_bv(x.ctx_ref(), x.ast), x.ctx)
8505 
def fpToIEEEBV(x)
Definition: z3py.py:8482
Z3_ast Z3_API Z3_mk_fpa_to_ieee_bv(__in Z3_context c, __in Z3_ast t)
Conversion of a floating-point term into a bit-vector term in IEEE 754-2008 format.
def is_fp(a)
Definition: z3py.py:7893
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 8464 of file z3py.py.

8464 def fpToReal(x):
8465  """Create a Z3 floating-point conversion expression, from floating-point expression to real.
8466 
8467  >>> x = FP('x', FPSort(8, 24))
8468  >>> y = fpToReal(x)
8469  >>> print is_fp(x)
8470  True
8471  >>> print is_real(y)
8472  True
8473  >>> print is_fp(y)
8474  False
8475  >>> print is_real(x)
8476  False
8477  """
8478  if __debug__:
8479  _z3_assert(is_fp(x), "First argument must be a Z3 floating-point expression")
8480  return ArithRef(Z3_mk_fpa_to_real(x.ctx_ref(), x.ast), x.ctx)
8481 
Z3_ast Z3_API Z3_mk_fpa_to_real(__in Z3_context c, __in Z3_ast t)
Conversion of a floating-point term into a real-numbered term.
def fpToReal(x)
Definition: z3py.py:8464
def is_fp(a)
Definition: z3py.py:7893
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 8424 of file z3py.py.

8424 def fpToSBV(rm, x, s):
8425  """Create a Z3 floating-point conversion expression, from floating-point expression to signed bit-vector.
8426 
8427  >>> x = FP('x', FPSort(8, 24))
8428  >>> y = fpToSBV(RTZ(), x, BitVecSort(32))
8429  >>> print is_fp(x)
8430  True
8431  >>> print is_bv(y)
8432  True
8433  >>> print is_fp(y)
8434  False
8435  >>> print is_bv(x)
8436  False
8437  """
8438  if __debug__:
8439  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
8440  _z3_assert(is_fp(x), "Second argument must be a Z3 floating-point expression")
8441  _z3_assert(is_bv_sort(s), "Third argument must be Z3 bit-vector sort")
8442  return BitVecRef(Z3_mk_fpa_to_sbv(rm.ctx_ref(), rm.ast, x.ast, s.size()), rm.ctx)
8443 
Z3_ast Z3_API Z3_mk_fpa_to_sbv(__in Z3_context c, __in Z3_ast rm, __in Z3_ast t, __in unsigned sz)
Conversion of a floating-point term into a signed bit-vector.
def fpToSBV(rm, x, s)
Definition: z3py.py:8424
def is_bv_sort(s)
Definition: z3py.py:2940
def is_fprm(a)
Definition: z3py.py:7797
def is_fp(a)
Definition: z3py.py:7893
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 8444 of file z3py.py.

8444 def fpToUBV(rm, x, s):
8445  """Create a Z3 floating-point conversion expression, from floating-point expression to unsigned bit-vector.
8446 
8447  >>> x = FP('x', FPSort(8, 24))
8448  >>> y = fpToUBV(RTZ(), x, BitVecSort(32))
8449  >>> print is_fp(x)
8450  True
8451  >>> print is_bv(y)
8452  True
8453  >>> print is_fp(y)
8454  False
8455  >>> print is_bv(x)
8456  False
8457  """
8458  if __debug__:
8459  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
8460  _z3_assert(is_fp(x), "Second argument must be a Z3 floating-point expression")
8461  _z3_assert(is_bv_sort(s), "Third argument must be Z3 bit-vector sort")
8462  return BitVecRef(Z3_mk_fpa_to_ubv(rm.ctx_ref(), rm.ast, x.ast, s.size()), rm.ctx)
8463 
def fpToUBV(rm, x, s)
Definition: z3py.py:8444
Z3_ast Z3_API Z3_mk_fpa_to_ubv(__in Z3_context c, __in Z3_ast rm, __in Z3_ast t, __in unsigned sz)
Conversion of a floating-point term into an unsigned bit-vector.
def is_bv_sort(s)
Definition: z3py.py:2940
def is_fprm(a)
Definition: z3py.py:7797
def is_fp(a)
Definition: z3py.py:7893
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 7979 of file z3py.py.

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

7979 def FPVal(sig, exp=None, fps=None, ctx=None):
7980  """Return a floating-point value of value `val` and sort `fps`. If `ctx=None`, then the global context is used.
7981 
7982  >>> v = FPVal(20.0, FPSort(8, 24))
7983  >>> v
7984  1.25*(2**4)
7985  >>> print("0x%.8x" % v.exponent_as_long())
7986  0x00000004
7987  >>> v = FPVal(2.25, FPSort(8, 24))
7988  >>> v
7989  1.125*(2**1)
7990  >>> v = FPVal(-2.25, FPSort(8, 24))
7991  >>> v
7992  -1.125*(2**1)
7993  """
7994  ctx = _get_ctx(ctx)
7995  if is_fp_sort(exp):
7996  fps = exp
7997  exp = None
7998  elif fps == None:
7999  fps = _dflt_fps(ctx)
8000  _z3_assert(is_fp_sort(fps), "sort mismatch")
8001  if exp == None:
8002  exp = 0
8003  val = _to_float_str(sig)
8004  val = val + 'p'
8005  val = val + _to_int_str(exp)
8006  return FPNumRef(Z3_mk_numeral(ctx.ref(), val, fps.ast), ctx)
8007 
Z3_ast Z3_API Z3_mk_numeral(__in Z3_context c, __in Z3_string numeral, __in Z3_sort ty)
Create a numeral of a given sort.
def FPVal
Definition: z3py.py:7979
FP Numerals.
Definition: z3py.py:7815
def is_fp_sort(s)
Definition: z3py.py:7579
def z3py.fpZero (   s,
  negative 
)

Definition at line 7974 of file z3py.py.

7974 def fpZero(s, negative):
7975  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
7976  _z3_assert(isinstance(negative, bool), "expected Boolean flag")
7977  return FPNumRef(Z3_mk_fpa_zero(s.ctx_ref(), s.ast, negative), s.ctx)
7978 
def fpZero(s, negative)
Definition: z3py.py:7974
FP Numerals.
Definition: z3py.py:7815
Z3_ast Z3_API Z3_mk_fpa_zero(__in Z3_context c, __in Z3_sort s, __in 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 1411 of file z3py.py.

1411 def FreshBool(prefix='b', ctx=None):
1412  """Return a fresh Boolean constant in the given context using the given prefix.
1413 
1414  If `ctx=None`, then the global context is used.
1415 
1416  >>> b1 = FreshBool()
1417  >>> b2 = FreshBool()
1418  >>> eq(b1, b2)
1419  False
1420  """
1421  ctx = _get_ctx(ctx)
1422  return BoolRef(Z3_mk_fresh_const(ctx.ref(), prefix, BoolSort(ctx).ast), ctx)
1423 
def BoolSort
Definition: z3py.py:1336
Z3_ast Z3_API Z3_mk_fresh_const(__in Z3_context c, __in Z3_string prefix, __in Z3_sort ty)
Declare and create a fresh constant.
def FreshBool
Definition: z3py.py:1411
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 2763 of file z3py.py.

2763 def FreshInt(prefix='x', ctx=None):
2764  """Return a fresh integer constant in the given context using the given prefix.
2765 
2766  >>> x = FreshInt()
2767  >>> y = FreshInt()
2768  >>> eq(x, y)
2769  False
2770  >>> x.sort()
2771  Int
2772  """
2773  ctx = _get_ctx(ctx)
2774  return ArithRef(Z3_mk_fresh_const(ctx.ref(), prefix, IntSort(ctx).ast), ctx)
2775 
def IntSort
Definition: z3py.py:2625
Z3_ast Z3_API Z3_mk_fresh_const(__in Z3_context c, __in Z3_string prefix, __in Z3_sort ty)
Declare and create a fresh constant.
def FreshInt
Definition: z3py.py:2763
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 2815 of file z3py.py.

2815 def FreshReal(prefix='b', ctx=None):
2816  """Return a fresh real constant in the given context using the given prefix.
2817 
2818  >>> x = FreshReal()
2819  >>> y = FreshReal()
2820  >>> eq(x, y)
2821  False
2822  >>> x.sort()
2823  Real
2824  """
2825  ctx = _get_ctx(ctx)
2826  return ArithRef(Z3_mk_fresh_const(ctx.ref(), prefix, RealSort(ctx).ast), ctx)
2827 
def RealSort
Definition: z3py.py:2641
Z3_ast Z3_API Z3_mk_fresh_const(__in Z3_context c, __in Z3_string prefix, __in Z3_sort ty)
Declare and create a fresh constant.
def FreshReal
Definition: z3py.py:2815
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 is_sort(s)
Definition: z3py.py:532
Z3_func_decl Z3_API Z3_mk_func_decl(__in Z3_context c, __in Z3_symbol s, __in unsigned domain_size, __in_ecount(domain_size) Z3_sort const domain[], __in Z3_sort range)
Declare a constant or function.
def to_symbol
Definition: z3py.py:94
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 5556 of file z3py.py.

5557  """Return the function declaration f associated with a Z3 expression of the form (_ as-array f)."""
5558  if __debug__:
5559  _z3_assert(is_as_array(n), "as-array Z3 expression expected.")
5560  return FuncDeclRef(Z3_get_as_array_func_decl(n.ctx.ref(), n.as_ast()), n.ctx)
5561 
Function Declarations.
Definition: z3py.py:591
Z3_func_decl Z3_API Z3_get_as_array_func_decl(__in Z3_context c, __in Z3_ast a)
Return the function declaration f associated with a (_ as_array f) node.
def get_as_array_func(n)
Definition: z3py.py:5556
def is_as_array(n)
Definition: z3py.py:5552
def z3py.get_default_fp_sort (   ctx = None)

Definition at line 7482 of file z3py.py.

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

7482 def get_default_fp_sort(ctx=None):
7483  return FPSort(_dflt_fpsort_ebits, _dflt_fpsort_sbits, ctx)
7484 
def get_default_fp_sort
Definition: z3py.py:7482
def FPSort
Definition: z3py.py:7920
def z3py.get_default_rounding_mode (   ctx = None)
Retrieves the global default rounding mode.

Definition at line 7455 of file z3py.py.

7456  """Retrieves the global default rounding mode."""
7457  global _dflt_rounding_mode
7458  if _dflt_rounding_mode == Z3_OP_FPA_RM_TOWARD_ZERO:
7459  return RTZ(ctx)
7460  elif _dflt_rounding_mode == Z3_OP_FPA_RM_TOWARD_NEGATIVE:
7461  return RTN(ctx)
7462  elif _dflt_rounding_mode == Z3_OP_FPA_RM_TOWARD_POSITIVE:
7463  return RTP(ctx)
7464  elif _dflt_rounding_mode == Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN:
7465  return RNE(ctx)
7466  elif _dflt_rounding_mode == Z3_OP_FPA_RM_NEAREST_TIES_TO_AWAY:
7467  return RNA(ctx)
7468 
def RNE
Definition: z3py.py:7761
def RNA
Definition: z3py.py:7769
def get_default_rounding_mode
Definition: z3py.py:7455
def RTP
Definition: z3py.py:7777
def RTZ
Definition: z3py.py:7793
def RTN
Definition: z3py.py:7785
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 3961 of file z3py.py.

3962  """Return the function declaration associated with a Z3 map array expression.
3963 
3964  >>> f = Function('f', IntSort(), IntSort())
3965  >>> b = Array('b', IntSort(), IntSort())
3966  >>> a = Map(f, b)
3967  >>> eq(f, get_map_func(a))
3968  True
3969  >>> get_map_func(a)
3970  f
3971  >>> get_map_func(a)(0)
3972  f(0)
3973  """
3974  if __debug__:
3975  _z3_assert(is_map(a), "Z3 array map expression expected.")
3976  return FuncDeclRef(Z3_to_func_decl(a.ctx_ref(), Z3_get_decl_ast_parameter(a.ctx_ref(), a.decl().ast, 0)), a.ctx)
3977 
Function Declarations.
Definition: z3py.py:591
def is_map(a)
Definition: z3py.py:3946
def get_map_func(a)
Definition: z3py.py:3961
Z3_ast Z3_API Z3_get_decl_ast_parameter(__in Z3_context c, __in Z3_func_decl d, unsigned idx)
Return the expresson value associated with an expression parameter.
Z3_func_decl Z3_API Z3_to_func_decl(__in Z3_context c, __in Z3_ast a)
Convert an AST into a FUNC_DECL_AST. This is just type casting.
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(__in Z3_string param_id, __out 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(__in Z3_context c, __in 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
void Z3_API Z3_get_version(__out unsigned *major, __out unsigned *minor, __out unsigned *build_number, __out unsigned *revision_number)
Return Z3 version number information.
def get_version()
Definition: z3py.py:72
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(__out unsigned *major, __out unsigned *minor, __out unsigned *build_number, __out 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 7003 of file z3py.py.

7004  """Return a string describing all options available for Z3 `simplify` procedure."""
7005  print(Z3_simplify_get_help(main_ctx().ref()))
7006 
def main_ctx()
Definition: z3py.py:188
def help_simplify()
Definition: z3py.py:7003
Z3_string Z3_API Z3_simplify_get_help(__in 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 BoolSort
Definition: z3py.py:1336
def If
Definition: z3py.py:1092
Z3_ast Z3_API Z3_mk_ite(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2, __in Z3_ast t3)
Create an AST node representing an if-then-else: ite(t1, t2, t3).
def Cond
Definition: z3py.py:6963
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 1424 of file z3py.py.

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

1424 def Implies(a, b, ctx=None):
1425  """Create a Z3 implies expression.
1426 
1427  >>> p, q = Bools('p q')
1428  >>> Implies(p, q)
1429  Implies(p, q)
1430  >>> simplify(Implies(p, q))
1431  Or(Not(p), q)
1432  """
1433  ctx = _get_ctx(_ctx_from_ast_arg_list([a, b], ctx))
1434  s = BoolSort(ctx)
1435  a = s.cast(a)
1436  b = s.cast(b)
1437  return BoolRef(Z3_mk_implies(ctx.ref(), a.as_ast(), b.as_ast()), ctx)
1438 
def BoolSort
Definition: z3py.py:1336
def Implies
Definition: z3py.py:1424
Z3_ast Z3_API Z3_mk_implies(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Create an AST node representing t1 implies t2.
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 2728 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().

2728 def Int(name, ctx=None):
2729  """Return an integer constant named `name`. If `ctx=None`, then the global context is used.
2730 
2731  >>> x = Int('x')
2732  >>> is_int(x)
2733  True
2734  >>> is_int(x + 1)
2735  True
2736  """
2737  ctx = _get_ctx(ctx)
2738  return ArithRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), IntSort(ctx).ast), ctx)
2739 
Z3_ast Z3_API Z3_mk_const(__in Z3_context c, __in Z3_symbol s, __in Z3_sort ty)
Declare and create a constant.
def IntSort
Definition: z3py.py:2625
def Int
Definition: z3py.py:2728
def to_symbol
Definition: z3py.py:94
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 7318 of file z3py.py.

Referenced by binary_interpolant(), and tree_interpolant().

7318 def Interpolant(a,ctx=None):
7319  """Create an interpolation operator.
7320 
7321  The argument is an interpolation pattern (see tree_interpolant).
7322 
7323  >>> x = Int('x')
7324  >>> print Interpolant(x>0)
7325  interp(x > 0)
7326  """
7327  ctx = _get_ctx(_ctx_from_ast_arg_list([a], ctx))
7328  s = BoolSort(ctx)
7329  a = s.cast(a)
7330  return BoolRef(Z3_mk_interpolant(ctx.ref(), a.as_ast()), ctx)
7331 
def BoolSort
Definition: z3py.py:1336
def Interpolant
Definition: z3py.py:7318
Z3_ast Z3_API Z3_mk_interpolant(__in Z3_context c, __in Z3_ast a)
Create an AST node marking a formula position for interpolation.
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 2740 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().

2740 def Ints(names, ctx=None):
2741  """Return a tuple of Integer constants.
2742 
2743  >>> x, y, z = Ints('x y z')
2744  >>> Sum(x, y, z)
2745  x + y + z
2746  """
2747  ctx = _get_ctx(ctx)
2748  if isinstance(names, str):
2749  names = names.split(" ")
2750  return [Int(name, ctx) for name in names]
2751 
def Ints
Definition: z3py.py:2740
def Int
Definition: z3py.py:2728
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 2625 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(), 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(), 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(), Update(), FuncEntry.value(), QuantifierRef.var_name(), QuantifierRef.var_sort(), and QuantifierRef.weight().

2625 def IntSort(ctx=None):
2626  """Return the interger sort in the given context. If `ctx=None`, then the global context is used.
2627 
2628  >>> IntSort()
2629  Int
2630  >>> x = Const('x', IntSort())
2631  >>> is_int(x)
2632  True
2633  >>> x.sort() == IntSort()
2634  True
2635  >>> x.sort() == BoolSort()
2636  False
2637  """
2638  ctx = _get_ctx(ctx)
2639  return ArithSortRef(Z3_mk_int_sort(ctx.ref()), ctx)
2640 
def IntSort
Definition: z3py.py:2625
Arithmetic.
Definition: z3py.py:1846
Z3_sort Z3_API Z3_mk_int_sort(__in Z3_context c)
Create the integer type.
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 2672 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().

2672 def IntVal(val, ctx=None):
2673  """Return a Z3 integer value. If `ctx=None`, then the global context is used.
2674 
2675  >>> IntVal(1)
2676  1
2677  >>> IntVal("100")
2678  100
2679  """
2680  ctx = _get_ctx(ctx)
2681  return IntNumRef(Z3_mk_numeral(ctx.ref(), _to_int_str(val), IntSort(ctx).ast), ctx)
2682 
def IntSort
Definition: z3py.py:2625
Z3_ast Z3_API Z3_mk_numeral(__in Z3_context c, __in Z3_string numeral, __in Z3_sort ty)
Create a numeral of a given sort.
def IntVal
Definition: z3py.py:2672
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 2752 of file z3py.py.

2752 def IntVector(prefix, sz, ctx=None):
2753  """Return a list of integer constants of size `sz`.
2754 
2755  >>> X = IntVector('x', 3)
2756  >>> X
2757  [x__0, x__1, x__2]
2758  >>> Sum(X)
2759  x__0 + x__1 + x__2
2760  """
2761  return [ Int('%s__%s' % (prefix, i)) for i in range(sz) ]
2762 
def Int
Definition: z3py.py:2728
def IntVector
Definition: z3py.py:2752
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 2329 of file z3py.py.

2329 def is_add(a):
2330  """Return `True` if `a` is an expression of the form b + c.
2331 
2332  >>> x, y = Ints('x y')
2333  >>> is_add(x + y)
2334  True
2335  >>> is_add(x - y)
2336  False
2337  """
2338  return is_app_of(a, Z3_OP_ADD)
2339 
def is_app_of(a, k)
Definition: z3py.py:1080
def is_add(a)
Definition: z3py.py:2329
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 2316 of file z3py.py.

2317  """Return `True` if `a` is an algerbraic value of sort Real.
2318 
2319  >>> is_algebraic_value(RealVal("3/5"))
2320  False
2321  >>> n = simplify(Sqrt(2))
2322  >>> n
2323  1.4142135623?
2324  >>> is_algebraic_value(n)
2325  True
2326  """
2327  return is_arith(a) and a.is_real() and _is_algebraic(a.ctx, a.as_ast())
2328 
def is_arith(a)
Definition: z3py.py:2210
def is_algebraic_value(a)
Definition: z3py.py:2316
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 1283 of file z3py.py.

1283 def is_and(a):
1284  """Return `True` if `a` is a Z3 and expression.
1285 
1286  >>> p, q = Bools('p q')
1287  >>> is_and(And(p, q))
1288  True
1289  >>> is_and(Or(p, q))
1290  False
1291  """
1292  return is_app_of(a, Z3_OP_AND)
1293 
def is_and(a)
Definition: z3py.py:1283
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(), is_app_of(), is_const(), and ExprRef.num_args().

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

Referenced by is_algebraic_value().

2210 def is_arith(a):
2211  """Return `True` if `a` is an arithmetical expression.
2212 
2213  >>> x = Int('x')
2214  >>> is_arith(x)
2215  True
2216  >>> is_arith(x + 1)
2217  True
2218  >>> is_arith(1)
2219  False
2220  >>> is_arith(IntVal(1))
2221  True
2222  >>> y = Real('y')
2223  >>> is_arith(y)
2224  True
2225  >>> is_arith(y + 1)
2226  True
2227  """
2228  return isinstance(a, ArithRef)
2229 
def is_arith(a)
Definition: z3py.py:2210
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 1913 of file z3py.py.

1914  """Return `True` if s is an arithmetical sort (type).
1915 
1916  >>> is_arith_sort(IntSort())
1917  True
1918  >>> is_arith_sort(RealSort())
1919  True
1920  >>> is_arith_sort(BoolSort())
1921  False
1922  >>> n = Int('x') + 1
1923  >>> is_arith_sort(n.sort())
1924  True
1925  """
1926  return isinstance(s, ArithSortRef)
1927 
def is_arith_sort(s)
Definition: z3py.py:1913
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 3909 of file z3py.py.

3909 def is_array(a):
3910  """Return `True` if `a` is a Z3 array expression.
3911 
3912  >>> a = Array('a', IntSort(), IntSort())
3913  >>> is_array(a)
3914  True
3915  >>> is_array(Store(a, 0, 1))
3916  True
3917  >>> is_array(a[0])
3918  False
3919  """
3920  return isinstance(a, ArrayRef)
3921 
def is_array(a)
Definition: z3py.py:3909
def z3py.is_as_array (   n)
Return true if n is a Z3 expression of the form (_ as-array f).

Definition at line 5552 of file z3py.py.

Referenced by get_as_array_func().

5553  """Return true if n is a Z3 expression of the form (_ as-array f)."""
5554  return isinstance(n, ExprRef) and Z3_is_as_array(n.ctx.ref(), n.as_ast())
5555 
Z3_bool Z3_API Z3_is_as_array(__in Z3_context c, __in Z3_ast a)
The (_ as-array f) AST node is a construct for assigning interpretations for arrays in Z3...
def is_as_array(n)
Definition: z3py.py:5552
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 352 of file z3py.py.

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

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

Referenced by BoolSort(), and prove().

1236 def is_bool(a):
1237  """Return `True` if `a` is a Z3 Boolean expression.
1238 
1239  >>> p = Bool('p')
1240  >>> is_bool(p)
1241  True
1242  >>> q = Bool('q')
1243  >>> is_bool(And(p, q))
1244  True
1245  >>> x = Real('x')
1246  >>> is_bool(x)
1247  False
1248  >>> is_bool(x == 0)
1249  True
1250  """
1251  return isinstance(a, BoolRef)
1252 
def is_bool(a)
Definition: z3py.py:1236
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 3401 of file z3py.py.

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

3401 def is_bv(a):
3402  """Return `True` if `a` is a Z3 bit-vector expression.
3403 
3404  >>> b = BitVec('b', 32)
3405  >>> is_bv(b)
3406  True
3407  >>> is_bv(b + 10)
3408  True
3409  >>> is_bv(Int('x'))
3410  False
3411  """
3412  return isinstance(a, BitVecRef)
3413 
def is_bv(a)
Definition: z3py.py:3401
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 2940 of file z3py.py.

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

2940 def is_bv_sort(s):
2941  """Return True if `s` is a Z3 bit-vector sort.
2942 
2943  >>> is_bv_sort(BitVecSort(32))
2944  True
2945  >>> is_bv_sort(IntSort())
2946  False
2947  """
2948  return isinstance(s, BitVecSortRef)
2949 
def is_bv_sort(s)
Definition: z3py.py:2940
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 3414 of file z3py.py.

3415  """Return `True` if `a` is a Z3 bit-vector numeral value.
3416 
3417  >>> b = BitVec('b', 32)
3418  >>> is_bv_value(b)
3419  False
3420  >>> b = BitVecVal(10, 32)
3421  >>> b
3422  10
3423  >>> is_bv_value(b)
3424  True
3425  """
3426  return is_bv(a) and _is_numeral(a.ctx, a.as_ast())
3427 
def is_bv_value(a)
Definition: z3py.py:3414
def is_bv(a)
Definition: z3py.py:3401
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 3922 of file z3py.py.

3923  """Return `True` if `a` is a Z3 constant array.
3924 
3925  >>> a = K(IntSort(), 10)
3926  >>> is_const_array(a)
3927  True
3928  >>> a = Array('a', IntSort(), IntSort())
3929  >>> is_const_array(a)
3930  False
3931  """
3932  return is_app_of(a, Z3_OP_CONST_ARRAY)
3933 
def is_const_array(a)
Definition: z3py.py:3922
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 1325 of file z3py.py.

1326  """Return `True` if `a` is a Z3 distinct expression.
1327 
1328  >>> x, y, z = Ints('x y z')
1329  >>> is_distinct(x == y)
1330  False
1331  >>> is_distinct(Distinct(x, y, z))
1332  True
1333  """
1334  return is_app_of(a, Z3_OP_DISTINCT)
1335 
def is_distinct(a)
Definition: z3py.py:1325
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 2362 of file z3py.py.

2362 def is_div(a):
2363  """Return `True` if `a` is an expression of the form b / c.
2364 
2365  >>> x, y = Reals('x y')
2366  >>> is_div(x / y)
2367  True
2368  >>> is_div(x + y)
2369  False
2370  >>> x, y = Ints('x y')
2371  >>> is_div(x / y)
2372  False
2373  >>> is_idiv(x / y)
2374  True
2375  """
2376  return is_app_of(a, Z3_OP_DIV)
2377 
def is_div(a)
Definition: z3py.py:2362
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 1316 of file z3py.py.

1316 def is_eq(a):
1317  """Return `True` if `a` is a Z3 equality expression.
1318 
1319  >>> x, y = Ints('x y')
1320  >>> is_eq(x == y)
1321  True
1322  """
1323  return is_app_of(a, Z3_OP_EQ)
1324 
def is_eq(a)
Definition: z3py.py:1316
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 1270 of file z3py.py.

Referenced by BoolVal().

1270 def is_false(a):
1271  """Return `True` if `a` is the Z3 false expression.
1272 
1273  >>> p = Bool('p')
1274  >>> is_false(p)
1275  False
1276  >>> is_false(False)
1277  False
1278  >>> is_false(BoolVal(False))
1279  True
1280  """
1281  return is_app_of(a, Z3_OP_FALSE)
1282 
def is_app_of(a, k)
Definition: z3py.py:1080
def is_false(a)
Definition: z3py.py:1270
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 7893 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().

7893 def is_fp(a):
7894  """Return `True` if `a` is a Z3 floating-point expression.
7895 
7896  >>> b = FP('b', FPSort(8, 24))
7897  >>> is_fp(b)
7898  True
7899  >>> is_fp(b + 1.0)
7900  True
7901  >>> is_fp(Int('x'))
7902  False
7903  """
7904  return isinstance(a, FPRef)
7905 
def is_fp(a)
Definition: z3py.py:7893
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 7579 of file z3py.py.

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

7579 def is_fp_sort(s):
7580  """Return True if `s` is a Z3 floating-point sort.
7581 
7582  >>> is_fp_sort(FPSort(8, 24))
7583  True
7584  >>> is_fp_sort(IntSort())
7585  False
7586  """
7587  return isinstance(s, FPSortRef)
7588 
def is_fp_sort(s)
Definition: z3py.py:7579
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 7906 of file z3py.py.

7907  """Return `True` if `a` is a Z3 floating-point numeral value.
7908 
7909  >>> b = FP('b', FPSort(8, 24))
7910  >>> is_fp_value(b)
7911  False
7912  >>> b = FPVal(1.0, FPSort(8, 24))
7913  >>> b
7914  1
7915  >>> is_fp_value(b)
7916  True
7917  """
7918  return is_fp(a) and _is_numeral(a.ctx, a.ast)
7919 
def is_fp_value(a)
Definition: z3py.py:7906
def is_fp(a)
Definition: z3py.py:7893
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 7797 of file z3py.py.

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

7797 def is_fprm(a):
7798  """Return `True` if `a` is a Z3 floating-point rounding mode expression.
7799 
7800  >>> rm = RNE()
7801  >>> is_fprm(rm)
7802  True
7803  >>> rm = 1.0
7804  >>> is_fprm(rm)
7805  False
7806  """
7807  return isinstance(a, FPRMRef)
7808 
def is_fprm(a)
Definition: z3py.py:7797
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 7589 of file z3py.py.

7590  """Return True if `s` is a Z3 floating-point rounding mode sort.
7591 
7592  >>> is_fprm_sort(FPSort(8, 24))
7593  False
7594  >>> is_fprm_sort(RNE().sort())
7595  True
7596  """
7597  return isinstance(s, FPRMSortRef)
7598 
def is_fprm_sort(s)
Definition: z3py.py:7589
def z3py.is_fprm_value (   a)
Return `True` if `a` is a Z3 floating-point rounding mode numeral value.

Definition at line 7809 of file z3py.py.

7810  """Return `True` if `a` is a Z3 floating-point rounding mode numeral value."""
7811  return is_fprm(a) and _is_numeral(a.ctx, a.ast)
7812 
def is_fprm_value(a)
Definition: z3py.py:7809
def is_fprm(a)
Definition: z3py.py:7797
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 2422 of file z3py.py.

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

2433 def is_gt(a):
2434  """Return `True` if `a` is an expression of the form b > c.
2435 
2436  >>> x, y = Ints('x y')
2437  >>> is_gt(x > y)
2438  True
2439  >>> is_gt(x == y)
2440  False
2441  """
2442  return is_app_of(a, Z3_OP_GT)
2443 
def is_gt(a)
Definition: z3py.py:2433
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 2378 of file z3py.py.

Referenced by is_div().

2378 def is_idiv(a):
2379  """Return `True` if `a` is an expression of the form b div c.
2380 
2381  >>> x, y = Ints('x y')
2382  >>> is_idiv(x / y)
2383  True
2384  >>> is_idiv(x + y)
2385  False
2386  """
2387  return is_app_of(a, Z3_OP_IDIV)
2388 
def is_idiv(a)
Definition: z3py.py:2378
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 2230 of file z3py.py.

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

2230 def is_int(a):
2231  """Return `True` if `a` is an integer expression.
2232 
2233  >>> x = Int('x')
2234  >>> is_int(x + 1)
2235  True
2236  >>> is_int(1)
2237  False
2238  >>> is_int(IntVal(1))
2239  True
2240  >>> y = Real('y')
2241  >>> is_int(y)
2242  False
2243  >>> is_int(y + 1)
2244  False
2245  """
2246  return is_arith(a) and a.is_int()
2247 
def is_arith(a)
Definition: z3py.py:2210
def is_int(a)
Definition: z3py.py:2230
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 2272 of file z3py.py.

2273  """Return `True` if `a` is an integer value of sort Int.
2274 
2275  >>> is_int_value(IntVal(1))
2276  True
2277  >>> is_int_value(1)
2278  False
2279  >>> is_int_value(Int('x'))
2280  False
2281  >>> n = Int('x') + 1
2282  >>> n
2283  x + 1
2284  >>> n.arg(1)
2285  1
2286  >>> is_int_value(n.arg(1))
2287  True
2288  >>> is_int_value(RealVal("1/3"))
2289  False
2290  >>> is_int_value(RealVal(1))
2291  False
2292  """
2293  return is_arith(a) and a.is_int() and _is_numeral(a.ctx, a.as_ast())
2294 
def is_int_value(a)
Definition: z3py.py:2272
def is_arith(a)
Definition: z3py.py:2210
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 2444 of file z3py.py.

2444 def is_is_int(a):
2445  """Return `True` if `a` is an expression of the form IsInt(b).
2446 
2447  >>> x = Real('x')
2448  >>> is_is_int(IsInt(x))
2449  True
2450  >>> is_is_int(x)
2451  False
2452  """
2453  return is_app_of(a, Z3_OP_IS_INT)
2454 
def is_app_of(a, k)
Definition: z3py.py:1080
def is_is_int(a)
Definition: z3py.py:2444
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 3934 of file z3py.py.

3934 def is_K(a):
3935  """Return `True` if `a` is a Z3 constant array.
3936 
3937  >>> a = K(IntSort(), 10)
3938  >>> is_K(a)
3939  True
3940  >>> a = Array('a', IntSort(), IntSort())
3941  >>> is_K(a)
3942  False
3943  """
3944  return is_app_of(a, Z3_OP_CONST_ARRAY)
3945 
def is_K(a)
Definition: z3py.py:3934
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 2400 of file z3py.py.

2400 def is_le(a):
2401  """Return `True` if `a` is an expression of the form b <= c.
2402 
2403  >>> x, y = Ints('x y')
2404  >>> is_le(x <= y)
2405  True
2406  >>> is_le(x < y)
2407  False
2408  """
2409  return is_app_of(a, Z3_OP_LE)
2410 
def is_le(a)
Definition: z3py.py:2400
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 2411 of file z3py.py.

2411 def is_lt(a):
2412  """Return `True` if `a` is an expression of the form b < c.
2413 
2414  >>> x, y = Ints('x y')
2415  >>> is_lt(x < y)
2416  True
2417  >>> is_lt(x == y)
2418  False
2419  """
2420  return is_app_of(a, Z3_OP_LT)
2421 
def is_lt(a)
Definition: z3py.py:2411
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 3946 of file z3py.py.

Referenced by get_map_func().

3946 def is_map(a):
3947  """Return `True` if `a` is a Z3 map array expression.
3948 
3949  >>> f = Function('f', IntSort(), IntSort())
3950  >>> b = Array('b', IntSort(), IntSort())
3951  >>> a = Map(f, b)
3952  >>> a
3953  Map(f, b)
3954  >>> is_map(a)
3955  True
3956  >>> is_map(b)
3957  False
3958  """
3959  return is_app_of(a, Z3_OP_ARRAY_MAP)
3960 
def is_map(a)
Definition: z3py.py:3946
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 2389 of file z3py.py.

2389 def is_mod(a):
2390  """Return `True` if `a` is an expression of the form b % c.
2391 
2392  >>> x, y = Ints('x y')
2393  >>> is_mod(x % y)
2394  True
2395  >>> is_mod(x + y)
2396  False
2397  """
2398  return is_app_of(a, Z3_OP_MOD)
2399 
def is_mod(a)
Definition: z3py.py:2389
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 2340 of file z3py.py.

2340 def is_mul(a):
2341  """Return `True` if `a` is an expression of the form b * c.
2342 
2343  >>> x, y = Ints('x y')
2344  >>> is_mul(x * y)
2345  True
2346  >>> is_mul(x - y)
2347  False
2348  """
2349  return is_app_of(a, Z3_OP_MUL)
2350 
def is_app_of(a, k)
Definition: z3py.py:1080
def is_mul(a)
Definition: z3py.py:2340
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 1305 of file z3py.py.

1305 def is_not(a):
1306  """Return `True` if `a` is a Z3 not expression.
1307 
1308  >>> p = Bool('p')
1309  >>> is_not(p)
1310  False
1311  >>> is_not(Not(p))
1312  True
1313  """
1314  return is_app_of(a, Z3_OP_NOT)
1315 
def is_not(a)
Definition: z3py.py:1305
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 1294 of file z3py.py.

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

Referenced by MultiPattern().

1556 def is_pattern(a):
1557  """Return `True` if `a` is a Z3 pattern (hint for quantifier instantiation.
1558 
1559  See http://rise4fun.com/Z3Py/tutorial/advanced for more details.
1560 
1561  >>> f = Function('f', IntSort(), IntSort())
1562  >>> x = Int('x')
1563  >>> q = ForAll(x, f(x) == 0, patterns = [ f(x) ])
1564  >>> q
1565  ForAll(x, f(x) == 0)
1566  >>> q.num_patterns()
1567  1
1568  >>> is_pattern(q.pattern(0))
1569  True
1570  >>> q.pattern(0)
1571  f(Var(0))
1572  """
1573  return isinstance(a, PatternRef)
1574 
def is_pattern(a)
Definition: z3py.py:1556
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 6859 of file z3py.py.

Referenced by eq().

6859 def is_probe(p):
6860  """Return `True` if `p` is a Z3 probe.
6861 
6862  >>> is_probe(Int('x'))
6863  False
6864  >>> is_probe(Probe('memory'))
6865  True
6866  """
6867  return isinstance(p, Probe)
6868 
def is_probe(p)
Definition: z3py.py:6859
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 1759 of file z3py.py.

Referenced by Exists().

1760  """Return `True` if `a` is a Z3 quantifier.
1761 
1762  >>> f = Function('f', IntSort(), IntSort())
1763  >>> x = Int('x')
1764  >>> q = ForAll(x, f(x) == 0)
1765  >>> is_quantifier(q)
1766  True
1767  >>> is_quantifier(f(x))
1768  False
1769  """
1770  return isinstance(a, QuantifierRef)
1771 
def is_quantifier(a)
Definition: z3py.py:1759
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 2295 of file z3py.py.

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

2296  """Return `True` if `a` is rational value of sort Real.
2297 
2298  >>> is_rational_value(RealVal(1))
2299  True
2300  >>> is_rational_value(RealVal("3/5"))
2301  True
2302  >>> is_rational_value(IntVal(1))
2303  False
2304  >>> is_rational_value(1)
2305  False
2306  >>> n = Real('x') + 1
2307  >>> n.arg(1)
2308  1
2309  >>> is_rational_value(n.arg(1))
2310  True
2311  >>> is_rational_value(Real('x'))
2312  False
2313  """
2314  return is_arith(a) and a.is_real() and _is_numeral(a.ctx, a.as_ast())
2315 
def is_arith(a)
Definition: z3py.py:2210
def is_rational_value(a)
Definition: z3py.py:2295
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 2248 of file z3py.py.

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

2248 def is_real(a):
2249  """Return `True` if `a` is a real expression.
2250 
2251  >>> x = Int('x')
2252  >>> is_real(x + 1)
2253  False
2254  >>> y = Real('y')
2255  >>> is_real(y)
2256  True
2257  >>> is_real(y + 1)
2258  True
2259  >>> is_real(1)
2260  False
2261  >>> is_real(RealVal(1))
2262  True
2263  """
2264  return is_arith(a) and a.is_real()
2265 
def is_real(a)
Definition: z3py.py:2248
def is_arith(a)
Definition: z3py.py:2210
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 4106 of file z3py.py.

4106 def is_select(a):
4107  """Return `True` if `a` is a Z3 array select application.
4108 
4109  >>> a = Array('a', IntSort(), IntSort())
4110  >>> is_select(a)
4111  False
4112  >>> i = Int('i')
4113  >>> is_select(a[i])
4114  True
4115  """
4116  return is_app_of(a, Z3_OP_SELECT)
4117 
def is_select(a)
Definition: z3py.py:4106
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 532 of file z3py.py.

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

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

4118 def is_store(a):
4119  """Return `True` if `a` is a Z3 array store application.
4120 
4121  >>> a = Array('a', IntSort(), IntSort())
4122  >>> is_store(a)
4123  False
4124  >>> is_store(Store(a, 0, 1))
4125  True
4126  """
4127  return is_app_of(a, Z3_OP_STORE)
4128 
def is_store(a)
Definition: z3py.py:4118
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 2351 of file z3py.py.

2351 def is_sub(a):
2352  """Return `True` if `a` is an expression of the form b - c.
2353 
2354  >>> x, y = Ints('x y')
2355  >>> is_sub(x - y)
2356  True
2357  >>> is_sub(x + y)
2358  False
2359  """
2360  return is_app_of(a, Z3_OP_SUB)
2361 
def is_app_of(a, k)
Definition: z3py.py:1080
def is_sub(a)
Definition: z3py.py:2351
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 2469 of file z3py.py.

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

2455 def is_to_real(a):
2456  """Return `True` if `a` is an expression of the form ToReal(b).
2457 
2458  >>> x = Int('x')
2459  >>> n = ToReal(x)
2460  >>> n
2461  ToReal(x)
2462  >>> is_to_real(n)
2463  True
2464  >>> is_to_real(x)
2465  False
2466  """
2467  return is_app_of(a, Z3_OP_TO_REAL)
2468 
def is_to_real(a)
Definition: z3py.py:2455
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 1253 of file z3py.py.

Referenced by BoolVal().

1253 def is_true(a):
1254  """Return `True` if `a` is the Z3 true expression.
1255 
1256  >>> p = Bool('p')
1257  >>> is_true(p)
1258  False
1259  >>> is_true(simplify(p == p))
1260  True
1261  >>> x = Real('x')
1262  >>> is_true(x == 0)
1263  False
1264  >>> # True is a Python Boolean expression
1265  >>> is_true(True)
1266  False
1267  """
1268  return is_app_of(a, Z3_OP_TRUE)
1269 
def is_true(a)
Definition: z3py.py:1253
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 2862 of file z3py.py.

Referenced by is_is_int().

2862 def IsInt(a):
2863  """ Return the Z3 predicate IsInt(a).
2864 
2865  >>> x = Real('x')
2866  >>> IsInt(x + "1/2")
2867  IsInt(x + 1/2)
2868  >>> solve(IsInt(x + "1/2"), x > 0, x < 1)
2869  [x = 1/2]
2870  >>> solve(IsInt(x + "1/2"), x > 0, x < 1, x != "1/2")
2871  no solution
2872  """
2873  if __debug__:
2874  _z3_assert(a.is_real(), "Z3 real expression expected.")
2875  ctx = a.ctx
2876  return BoolRef(Z3_mk_is_int(ctx.ref(), a.as_ast()), ctx)
2877 
def IsInt(a)
Definition: z3py.py:2862
Z3_ast Z3_API Z3_mk_is_int(__in Z3_context c, __in 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 4085 of file z3py.py.

Referenced by is_const_array(), and is_K().

4085 def K(dom, v):
4086  """Return a Z3 constant array expression.
4087 
4088  >>> a = K(IntSort(), 10)
4089  >>> a
4090  K(Int, 10)
4091  >>> a.sort()
4092  Array(Int, Int)
4093  >>> i = Int('i')
4094  >>> a[i]
4095  K(Int, 10)[i]
4096  >>> simplify(a[i])
4097  10
4098  """
4099  if __debug__:
4100  _z3_assert(is_sort(dom), "Z3 sort expected")
4101  ctx = dom.ctx
4102  if not is_expr(v):
4103  v = _py2expr(v, ctx)
4104  return ArrayRef(Z3_mk_const_array(ctx.ref(), dom.ast, v.as_ast()), ctx)
4105 
def is_sort(s)
Definition: z3py.py:532
def K(dom, v)
Definition: z3py.py:4085
def is_expr(a)
Definition: z3py.py:961
Z3_ast Z3_API Z3_mk_const_array(__in Z3_context c, __in Z3_sort domain, __in Z3_ast v)
Create the constant array.
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 3687 of file z3py.py.

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

3687 def LShR(a, b):
3688  """Create the Z3 expression logical right shift.
3689 
3690  Use the operator >> for the arithmetical right shift.
3691 
3692  >>> x, y = BitVecs('x y', 32)
3693  >>> LShR(x, y)
3694  LShR(x, y)
3695  >>> (x >> y).sexpr()
3696  '(bvashr x y)'
3697  >>> LShR(x, y).sexpr()
3698  '(bvlshr x y)'
3699  >>> BitVecVal(4, 3)
3700  4
3701  >>> BitVecVal(4, 3).as_signed_long()
3702  -4
3703  >>> simplify(BitVecVal(4, 3) >> 1).as_signed_long()
3704  -2
3705  >>> simplify(BitVecVal(4, 3) >> 1)
3706  6
3707  >>> simplify(LShR(BitVecVal(4, 3), 1))
3708  2
3709  >>> simplify(BitVecVal(2, 3) >> 1)
3710  1
3711  >>> simplify(LShR(BitVecVal(2, 3), 1))
3712  1
3713  """
3714  _check_bv_args(a, b)
3715  a, b = _coerce_exprs(a, b)
3716  return BitVecRef(Z3_mk_bvlshr(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3717 
def LShR(a, b)
Definition: z3py.py:3687
Z3_ast Z3_API Z3_mk_bvlshr(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Logical shift right.
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 4063 of file z3py.py.

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

4063 def Map(f, *args):
4064  """Return a Z3 map array expression.
4065 
4066  >>> f = Function('f', IntSort(), IntSort(), IntSort())
4067  >>> a1 = Array('a1', IntSort(), IntSort())
4068  >>> a2 = Array('a2', IntSort(), IntSort())
4069  >>> b = Map(f, a1, a2)
4070  >>> b
4071  Map(f, a1, a2)
4072  >>> prove(b[0] == f(a1[0], a2[0]))
4073  proved
4074  """
4075  args = _get_args(args)
4076  if __debug__:
4077  _z3_assert(len(args) > 0, "At least one Z3 array expression expected")
4078  _z3_assert(is_func_decl(f), "First argument must be a Z3 function declaration")
4079  _z3_assert(all([is_array(a) for a in args]), "Z3 array expected expected")
4080  _z3_assert(len(args) == f.arity(), "Number of arguments mismatch")
4081  _args, sz = _to_ast_array(args)
4082  ctx = f.ctx
4083  return ArrayRef(Z3_mk_map(ctx.ref(), f.ast, sz, _args), ctx)
4084 
def is_array(a)
Definition: z3py.py:3909
Z3_ast Z3_API Z3_mk_map(__in Z3_context c, __in Z3_func_decl f, unsigned n, __in Z3_ast const *args)
map f on the the argument arrays.
def Map(f, args)
Definition: z3py.py:4063
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 1575 of file z3py.py.

1575 def MultiPattern(*args):
1576  """Create a Z3 multi-pattern using the given expressions `*args`
1577 
1578  See http://rise4fun.com/Z3Py/tutorial/advanced for more details.
1579 
1580  >>> f = Function('f', IntSort(), IntSort())
1581  >>> g = Function('g', IntSort(), IntSort())
1582  >>> x = Int('x')
1583  >>> q = ForAll(x, f(x) != g(x), patterns = [ MultiPattern(f(x), g(x)) ])
1584  >>> q
1585  ForAll(x, f(x) != g(x))
1586  >>> q.num_patterns()
1587  1
1588  >>> is_pattern(q.pattern(0))
1589  True
1590  >>> q.pattern(0)
1591  MultiPattern(f(Var(0)), g(Var(0)))
1592  """
1593  if __debug__:
1594  _z3_assert(len(args) > 0, "At least one argument expected")
1595  _z3_assert(all([ is_expr(a) for a in args ]), "Z3 expressions expected")
1596  ctx = args[0].ctx
1597  args, sz = _to_ast_array(args)
1598  return PatternRef(Z3_mk_pattern(ctx.ref(), sz, args), ctx)
1599 
Z3_pattern Z3_API Z3_mk_pattern(__in Z3_context c, __in unsigned num_patterns, __in_ecount(num_patterns) Z3_ast const terms[])
Create a pattern for quantifier instantiation.
Patterns.
Definition: z3py.py:1545
def MultiPattern(args)
Definition: z3py.py:1575
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 1454 of file z3py.py.

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

1454 def Not(a, ctx=None):
1455  """Create a Z3 not expression or probe.
1456 
1457  >>> p = Bool('p')
1458  >>> Not(Not(p))
1459  Not(Not(p))
1460  >>> simplify(Not(Not(p)))
1461  p
1462  """
1463  ctx = _get_ctx(_ctx_from_ast_arg_list([a], ctx))
1464  if is_probe(a):
1465  # Not is also used to build probes
1466  return Probe(Z3_probe_not(ctx.ref(), a.probe), ctx)
1467  else:
1468  s = BoolSort(ctx)
1469  a = s.cast(a)
1470  return BoolRef(Z3_mk_not(ctx.ref(), a.as_ast()), ctx)
1471 
def Not
Definition: z3py.py:1454
def BoolSort
Definition: z3py.py:1336
Z3_probe Z3_API Z3_probe_not(__in Z3_context x, __in Z3_probe p)
Return a probe that evaluates to "true" when p does not evaluate to true.
Z3_ast Z3_API Z3_mk_not(__in Z3_context c, __in Z3_ast a)
Create an AST node representing not(a).
def is_probe(p)
Definition: z3py.py:6859
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(__in 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 1509 of file z3py.py.

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

1509 def Or(*args):
1510  """Create a Z3 or-expression or or-probe.
1511 
1512  >>> p, q, r = Bools('p q r')
1513  >>> Or(p, q, r)
1514  Or(p, q, r)
1515  >>> P = BoolVector('p', 5)
1516  >>> Or(P)
1517  Or(p__0, p__1, p__2, p__3, p__4)
1518  """
1519  last_arg = None
1520  if len(args) > 0:
1521  last_arg = args[len(args)-1]
1522  if isinstance(last_arg, Context):
1523  ctx = args[len(args)-1]
1524  args = args[:len(args)-1]
1525  else:
1526  ctx = main_ctx()
1527  args = _get_args(args)
1528  ctx_args = _ctx_from_ast_arg_list(args, ctx)
1529  if __debug__:
1530  _z3_assert(ctx_args == None or ctx_args == ctx, "context mismatch")
1531  _z3_assert(ctx != None, "At least one of the arguments must be a Z3 expression or probe")
1532  if _has_probe(args):
1533  return _probe_or(args, ctx)
1534  else:
1535  args = _coerce_expr_list(args, ctx)
1536  _args, sz = _to_ast_array(args)
1537  return BoolRef(Z3_mk_or(ctx.ref(), sz, _args), ctx)
1538 
def main_ctx()
Definition: z3py.py:188
def Or(args)
Definition: z3py.py:1509
Z3_ast Z3_API Z3_mk_or(__in Z3_context c, __in unsigned num_args, __in_ecount(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 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 6591 of file z3py.py.

6591 def OrElse(*ts, **ks):
6592  """Return a tactic that applies the tactics in `*ts` until one of them succeeds (it doesn't fail).
6593 
6594  >>> x = Int('x')
6595  >>> t = OrElse(Tactic('split-clause'), Tactic('skip'))
6596  >>> # Tactic split-clause fails if there is no clause in the given goal.
6597  >>> t(x == 0)
6598  [[x == 0]]
6599  >>> t(Or(x == 0, x == 1))
6600  [[x == 0], [x == 1]]
6601  """
6602  if __debug__:
6603  _z3_assert(len(ts) >= 2, "At least two arguments expected")
6604  ctx = ks.get('ctx', None)
6605  num = len(ts)
6606  r = ts[0]
6607  for i in range(num - 1):
6608  r = _or_else(r, ts[i+1], ctx)
6609  return r
6610 
def OrElse(ts, ks)
Definition: z3py.py:6591
def z3py.ParAndThen (   t1,
  t2,
  ctx = None 
)
Alias for ParThen(t1, t2, ctx).

Definition at line 6643 of file z3py.py.

6643 def ParAndThen(t1, t2, ctx=None):
6644  """Alias for ParThen(t1, t2, ctx)."""
6645  return ParThen(t1, t2, ctx)
6646 
def ParThen
Definition: z3py.py:6629
def ParAndThen
Definition: z3py.py:6643
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 6611 of file z3py.py.

6611 def ParOr(*ts, **ks):
6612  """Return a tactic that applies the tactics in `*ts` in parallel until one of them succeeds (it doesn't fail).
6613 
6614  >>> x = Int('x')
6615  >>> t = ParOr(Tactic('simplify'), Tactic('fail'))
6616  >>> t(x + 1 == 2)
6617  [[x == 1]]
6618  """
6619  if __debug__:
6620  _z3_assert(len(ts) >= 2, "At least two arguments expected")
6621  ctx = _get_ctx(ks.get('ctx', None))
6622  ts = [ _to_tactic(t, ctx) for t in ts ]
6623  sz = len(ts)
6624  _args = (TacticObj * sz)()
6625  for i in range(sz):
6626  _args[i] = ts[i].tactic
6627  return Tactic(Z3_tactic_par_or(ctx.ref(), sz, _args), ctx)
6628 
def ParOr(ts, ks)
Definition: z3py.py:6611
Z3_tactic Z3_API Z3_tactic_par_or(__in Z3_context c, __in unsigned num, __in_ecount(num) Z3_tactic const ts[])
Return a tactic that applies the given tactics in parallel.
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 7308 of file z3py.py.

7308 def parse_smt2_file(f, sorts={}, decls={}, ctx=None):
7309  """Parse a file in SMT 2.0 format using the given sorts and decls.
7310 
7311  This function is similar to parse_smt2_string().
7312  """
7313  ctx = _get_ctx(ctx)
7314  ssz, snames, ssorts = _dict2sarray(sorts, ctx)
7315  dsz, dnames, ddecls = _dict2darray(decls, ctx)
7316  return _to_expr_ref(Z3_parse_smtlib2_file(ctx.ref(), f, ssz, snames, ssorts, dsz, dnames, ddecls), ctx)
7317 
Z3_ast Z3_API Z3_parse_smtlib2_file(__in Z3_context c, __in Z3_string file_name, __in unsigned num_sorts, __in_ecount(num_sorts) Z3_symbol const sort_names[], __in_ecount(num_sorts) Z3_sort const sorts[], __in unsigned num_decls, __in_ecount(num_decls) Z3_symbol const decl_names[], __in_ecount(num_decls) Z3_func_decl const decls[])
Similar to Z3_parse_smtlib2_string, but reads the benchmark from a file.
def parse_smt2_file
Definition: z3py.py:7308
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 7288 of file z3py.py.

Referenced by parse_smt2_file().

7288 def parse_smt2_string(s, sorts={}, decls={}, ctx=None):
7289  """Parse a string in SMT 2.0 format using the given sorts and decls.
7290 
7291  The arguments sorts and decls are Python dictionaries used to initialize
7292  the symbol table used for the SMT 2.0 parser.
7293 
7294  >>> parse_smt2_string('(declare-const x Int) (assert (> x 0)) (assert (< x 10))')
7295  And(x > 0, x < 10)
7296  >>> x, y = Ints('x y')
7297  >>> f = Function('f', IntSort(), IntSort())
7298  >>> parse_smt2_string('(assert (> (+ foo (g bar)) 0))', decls={ 'foo' : x, 'bar' : y, 'g' : f})
7299  x + f(y) > 0
7300  >>> parse_smt2_string('(declare-const a U) (assert (> a 0))', sorts={ 'U' : IntSort() })
7301  a > 0
7302  """
7303  ctx = _get_ctx(ctx)
7304  ssz, snames, ssorts = _dict2sarray(sorts, ctx)
7305  dsz, dnames, ddecls = _dict2darray(decls, ctx)
7306  return _to_expr_ref(Z3_parse_smtlib2_string(ctx.ref(), s, ssz, snames, ssorts, dsz, dnames, ddecls), ctx)
7307 
def parse_smt2_string
Definition: z3py.py:7288
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 6629 of file z3py.py.

Referenced by ParAndThen().

6629 def ParThen(t1, t2, ctx=None):
6630  """Return a tactic that applies t1 and then t2 to every subgoal produced by t1. The subgoals are processed in parallel.
6631 
6632  >>> x, y = Ints('x y')
6633  >>> t = ParThen(Tactic('split-clause'), Tactic('propagate-values'))
6634  >>> t(And(Or(x == 1, x == 2), y == x + 1))
6635  [[x == 1, y == 2], [x == 2, y == 3]]
6636  """
6637  t1 = _to_tactic(t1, ctx)
6638  t2 = _to_tactic(t2, ctx)
6639  if __debug__:
6640  _z3_assert(t1.ctx == t2.ctx, "Context mismatch")
6641  return Tactic(Z3_tactic_par_and_then(t1.ctx.ref(), t1.tactic, t2.tactic), t1.ctx)
6642 
Z3_tactic Z3_API Z3_tactic_par_and_then(__in Z3_context c, __in Z3_tactic t1, __in Z3_tactic t2)
Return a tactic that applies t1 to a given goal and then t2 to every subgoal produced by t1...
def ParThen
Definition: z3py.py:6629
def z3py.probe_description (   name,
  ctx = None 
)
Return a short description for the probe named `name`.

>>> d = probe_description('memory')

Definition at line 6885 of file z3py.py.

Referenced by describe_probes().

6885 def probe_description(name, ctx=None):
6886  """Return a short description for the probe named `name`.
6887 
6888  >>> d = probe_description('memory')
6889  """
6890  ctx = _get_ctx(ctx)
6891  return Z3_probe_get_descr(ctx.ref(), name)
6892 
Z3_string Z3_API Z3_probe_get_descr(__in Z3_context c, __in Z3_string name)
Return a string containing a description of the probe with the given name.
def probe_description
Definition: z3py.py:6885
def z3py.probes (   ctx = None)
Return a list of all available probes in Z3.

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

Definition at line 6875 of file z3py.py.

Referenced by describe_probes().

6875 def probes(ctx=None):
6876  """Return a list of all available probes in Z3.
6877 
6878  >>> l = probes()
6879  >>> l.count('memory') == 1
6880  True
6881  """
6882  ctx = _get_ctx(ctx)
6883  return [ Z3_get_probe_name(ctx.ref(), i) for i in range(Z3_get_num_probes(ctx.ref())) ]
6884 
Z3_string Z3_API Z3_get_probe_name(__in Z3_context c, unsigned i)
Return the name of the i probe.
def probes
Definition: z3py.py:6875
unsigned Z3_API Z3_get_num_probes(__in 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 7082 of file z3py.py.

Referenced by BitVecs(), and FPs().

7082 def Product(*args):
7083  """Create the product of the Z3 expressions.
7084 
7085  >>> a, b, c = Ints('a b c')
7086  >>> Product(a, b, c)
7087  a*b*c
7088  >>> Product([a, b, c])
7089  a*b*c
7090  >>> A = IntVector('a', 5)
7091  >>> Product(A)
7092  a__0*a__1*a__2*a__3*a__4
7093  """
7094  args = _get_args(args)
7095  if __debug__:
7096  _z3_assert(len(args) > 0, "Non empty list of arguments expected")
7097  ctx = _ctx_from_ast_arg_list(args)
7098  if __debug__:
7099  _z3_assert(ctx != None, "At least one of the arguments must be a Z3 expression")
7100  args = _coerce_expr_list(args, ctx)
7101  if is_bv(args[0]):
7102  return _reduce(lambda a, b: a * b, args, 1)
7103  else:
7104  _args, sz = _to_ast_array(args)
7105  return ArithRef(Z3_mk_mul(ctx.ref(), sz, _args), ctx)
7106 
Z3_ast Z3_API Z3_mk_mul(__in Z3_context c, __in unsigned num_args, __in_ecount(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:7082
def is_bv(a)
Definition: z3py.py:3401
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 7164 of file z3py.py.

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

7164 def prove(claim, **keywords):
7165  """Try to prove the given claim.
7166 
7167  This is a simple function for creating demonstrations. It tries to prove
7168  `claim` by showing the negation is unsatisfiable.
7169 
7170  >>> p, q = Bools('p q')
7171  >>> prove(Not(And(p, q)) == Or(Not(p), Not(q)))
7172  proved
7173  """
7174  if __debug__:
7175  _z3_assert(is_bool(claim), "Z3 Boolean expression expected")
7176  s = Solver()
7177  s.set(**keywords)
7178  s.add(Not(claim))
7179  if keywords.get('show', False):
7180  print(s)
7181  r = s.check()
7182  if r == unsat:
7183  print("proved")
7184  elif r == unknown:
7185  print("failed to prove")
7186  print(s.model())
7187  else:
7188  print("counterexample")
7189  print(s.model())
7190 
def Not
Definition: z3py.py:1454
def prove(claim, keywords)
Definition: z3py.py:7164
def is_bool(a)
Definition: z3py.py:1236
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 2716 of file z3py.py.

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

2716 def Q(a, b, ctx=None):
2717  """Return a Z3 rational a/b.
2718 
2719  If `ctx=None`, then the global context is used.
2720 
2721  >>> Q(3,5)
2722  3/5
2723  >>> Q(3,5).sort()
2724  Real
2725  """
2726  return simplify(RatVal(a, b))
2727 
def simplify(a, arguments, keywords)
Utils.
Definition: z3py.py:6979
def Q
Definition: z3py.py:2716
def RatVal
Definition: z3py.py:2701
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 2701 of file z3py.py.

Referenced by Q().

2701 def RatVal(a, b, ctx=None):
2702  """Return a Z3 rational a/b.
2703 
2704  If `ctx=None`, then the global context is used.
2705 
2706  >>> RatVal(3,5)
2707  3/5
2708  >>> RatVal(3,5).sort()
2709  Real
2710  """
2711  if __debug__:
2712  _z3_assert(_is_int(a) or isinstance(a, str), "First argument cannot be converted into an integer")
2713  _z3_assert(_is_int(b) or isinstance(b, str), "Second argument cannot be converted into an integer")
2714  return simplify(RealVal(a, ctx)/RealVal(b, ctx))
2715 
def simplify(a, arguments, keywords)
Utils.
Definition: z3py.py:6979
def RealVal
Definition: z3py.py:2683
def RatVal
Definition: z3py.py:2701
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 2776 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().

2776 def Real(name, ctx=None):
2777  """Return a real constant named `name`. If `ctx=None`, then the global context is used.
2778 
2779  >>> x = Real('x')
2780  >>> is_real(x)
2781  True
2782  >>> is_real(x + 1)
2783  True
2784  """
2785  ctx = _get_ctx(ctx)
2786  return ArithRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), RealSort(ctx).ast), ctx)
2787 
Z3_ast Z3_API Z3_mk_const(__in Z3_context c, __in Z3_symbol s, __in Z3_sort ty)
Declare and create a constant.
def RealSort
Definition: z3py.py:2641
def Real
Definition: z3py.py:2776
def to_symbol
Definition: z3py.py:94
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 2788 of file z3py.py.

Referenced by is_div().

2788 def Reals(names, ctx=None):
2789  """Return a tuple of real constants.
2790 
2791  >>> x, y, z = Reals('x y z')
2792  >>> Sum(x, y, z)
2793  x + y + z
2794  >>> Sum(x, y, z).sort()
2795  Real
2796  """
2797  ctx = _get_ctx(ctx)
2798  if isinstance(names, str):
2799  names = names.split(" ")
2800  return [Real(name, ctx) for name in names]
2801 
def Real
Definition: z3py.py:2776
def Reals
Definition: z3py.py:2788
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 2641 of file z3py.py.

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

2641 def RealSort(ctx=None):
2642  """Return the real sort in the given context. If `ctx=None`, then the global context is used.
2643 
2644  >>> RealSort()
2645  Real
2646  >>> x = Const('x', RealSort())
2647  >>> is_real(x)
2648  True
2649  >>> is_int(x)
2650  False
2651  >>> x.sort() == RealSort()
2652  True
2653  """
2654  ctx = _get_ctx(ctx)
2655  return ArithSortRef(Z3_mk_real_sort(ctx.ref()), ctx)
2656 
def RealSort
Definition: z3py.py:2641
Z3_sort Z3_API Z3_mk_real_sort(__in Z3_context c)
Create the real type.
Arithmetic.
Definition: z3py.py:1846
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 2683 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().

2683 def RealVal(val, ctx=None):
2684  """Return a Z3 real value.
2685 
2686  `val` may be a Python int, long, float or string representing a number in decimal or rational notation.
2687  If `ctx=None`, then the global context is used.
2688 
2689  >>> RealVal(1)
2690  1
2691  >>> RealVal(1).sort()
2692  Real
2693  >>> RealVal("3/5")
2694  3/5
2695  >>> RealVal("1.5")
2696  3/2
2697  """
2698  ctx = _get_ctx(ctx)
2699  return RatNumRef(Z3_mk_numeral(ctx.ref(), str(val), RealSort(ctx).ast), ctx)
2700 
def RealSort
Definition: z3py.py:2641
Z3_ast Z3_API Z3_mk_numeral(__in Z3_context c, __in Z3_string numeral, __in Z3_sort ty)
Create a numeral of a given sort.
def RealVal
Definition: z3py.py:2683
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
Definition: z3py.py:2641
def Var(idx, s)
Definition: z3py.py:1170
def RealVar
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
Definition: z3py.py:1192
def RealVar
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 2802 of file z3py.py.

2802 def RealVector(prefix, sz, ctx=None):
2803  """Return a list of real constants of size `sz`.
2804 
2805  >>> X = RealVector('x', 3)
2806  >>> X
2807  [x__0, x__1, x__2]
2808  >>> Sum(X)
2809  x__0 + x__1 + x__2
2810  >>> Sum(X).sort()
2811  Real
2812  """
2813  return [ Real('%s__%s' % (prefix, i)) for i in range(sz) ]
2814 
def Real
Definition: z3py.py:2776
def RealVector
Definition: z3py.py:2802
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 6660 of file z3py.py.

6660 def Repeat(t, max=4294967295, ctx=None):
6661  """Return a tactic that keeps applying `t` until the goal is not modified anymore or the maximum number of iterations `max` is reached.
6662 
6663  >>> x, y = Ints('x y')
6664  >>> c = And(Or(x == 0, x == 1), Or(y == 0, y == 1), x > y)
6665  >>> t = Repeat(OrElse(Tactic('split-clause'), Tactic('skip')))
6666  >>> r = t(c)
6667  >>> for subgoal in r: print(subgoal)
6668  [x == 0, y == 0, x > y]
6669  [x == 0, y == 1, x > y]
6670  [x == 1, y == 0, x > y]
6671  [x == 1, y == 1, x > y]
6672  >>> t = Then(t, Tactic('propagate-values'))
6673  >>> t(c)
6674  [[x == 1, y == 0]]
6675  """
6676  t = _to_tactic(t, ctx)
6677  return Tactic(Z3_tactic_repeat(t.ctx.ref(), t.tactic, max), t.ctx)
6678 
Z3_tactic Z3_API Z3_tactic_repeat(__in Z3_context c, __in 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
Definition: z3py.py:6660
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 3804 of file z3py.py.

3804 def RepeatBitVec(n, a):
3805  """Return an expression representing `n` copies of `a`.
3806 
3807  >>> x = BitVec('x', 8)
3808  >>> n = RepeatBitVec(4, x)
3809  >>> n
3810  RepeatBitVec(4, x)
3811  >>> n.size()
3812  32
3813  >>> v0 = BitVecVal(10, 4)
3814  >>> print("%.x" % v0.as_long())
3815  a
3816  >>> v = simplify(RepeatBitVec(4, v0))
3817  >>> v.size()
3818  16
3819  >>> print("%.x" % v.as_long())
3820  aaaa
3821  """
3822  if __debug__:
3823  _z3_assert(isinstance(n, int), "First argument must be an integer")
3824  _z3_assert(is_bv(a), "Second argument must be a Z3 Bitvector expression")
3825  return BitVecRef(Z3_mk_repeat(a.ctx_ref(), n, a.as_ast()), a.ctx)
3826 
Z3_ast Z3_API Z3_mk_repeat(__in Z3_context c, __in unsigned i, __in Z3_ast t1)
Repeat the given bit-vector up length i.
def is_bv(a)
Definition: z3py.py:3401
def RepeatBitVec(n, a)
Definition: z3py.py:3804
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 7769 of file z3py.py.

Referenced by get_default_rounding_mode().

7769 def RNA (ctx=None):
7770  ctx = _get_ctx(ctx)
7771  return FPRMRef(Z3_mk_fpa_round_nearest_ties_to_away(ctx.ref()), ctx)
7772 
def RNA
Definition: z3py.py:7769
Z3_ast Z3_API Z3_mk_fpa_round_nearest_ties_to_away(__in Z3_context c)
Create a numeral of RoundingMode sort which represents the NearestTiesToAway rounding mode...
def z3py.RNE (   ctx = None)

Definition at line 7761 of file z3py.py.

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

7761 def RNE (ctx=None):
7762  ctx = _get_ctx(ctx)
7763  return FPRMRef(Z3_mk_fpa_round_nearest_ties_to_even(ctx.ref()), ctx)
7764 
def RNE
Definition: z3py.py:7761
Z3_ast Z3_API Z3_mk_fpa_round_nearest_ties_to_even(__in Z3_context c)
Create a numeral of RoundingMode sort which represents the NearestTiesToEven rounding mode...
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 3718 of file z3py.py.

3718 def RotateLeft(a, b):
3719  """Return an expression representing `a` rotated to the left `b` times.
3720 
3721  >>> a, b = BitVecs('a b', 16)
3722  >>> RotateLeft(a, b)
3723  RotateLeft(a, b)
3724  >>> simplify(RotateLeft(a, 0))
3725  a
3726  >>> simplify(RotateLeft(a, 16))
3727  a
3728  """
3729  _check_bv_args(a, b)
3730  a, b = _coerce_exprs(a, b)
3731  return BitVecRef(Z3_mk_ext_rotate_left(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3732 
def RotateLeft(a, b)
Definition: z3py.py:3718
Z3_ast Z3_API Z3_mk_ext_rotate_left(__in Z3_context c, __in Z3_ast t1, __in 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 3733 of file z3py.py.

3733 def RotateRight(a, b):
3734  """Return an expression representing `a` rotated to the right `b` times.
3735 
3736  >>> a, b = BitVecs('a b', 16)
3737  >>> RotateRight(a, b)
3738  RotateRight(a, b)
3739  >>> simplify(RotateRight(a, 0))
3740  a
3741  >>> simplify(RotateRight(a, 16))
3742  a
3743  """
3744  _check_bv_args(a, b)
3745  a, b = _coerce_exprs(a, b)
3746  return BitVecRef(Z3_mk_ext_rotate_right(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3747 
Z3_ast Z3_API Z3_mk_ext_rotate_right(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Rotate bits of t1 to the right t2 times.
def RotateRight(a, b)
Definition: z3py.py:3733
def z3py.RoundNearestTiesToAway (   ctx = None)

Definition at line 7765 of file z3py.py.

7766  ctx = _get_ctx(ctx)
7767  return FPRMRef(Z3_mk_fpa_round_nearest_ties_to_away(ctx.ref()), ctx)
7768 
def RoundNearestTiesToAway
Definition: z3py.py:7765
Z3_ast Z3_API Z3_mk_fpa_round_nearest_ties_to_away(__in Z3_context c)
Create a numeral of RoundingMode sort which represents the NearestTiesToAway rounding mode...
def z3py.RoundNearestTiesToEven (   ctx = None)

Definition at line 7757 of file z3py.py.

7758  ctx = _get_ctx(ctx)
7759  return FPRMRef(Z3_mk_fpa_round_nearest_ties_to_even(ctx.ref()), ctx)
7760 
def RoundNearestTiesToEven
Definition: z3py.py:7757
Z3_ast Z3_API Z3_mk_fpa_round_nearest_ties_to_even(__in Z3_context c)
Create a numeral of RoundingMode sort which represents the NearestTiesToEven rounding mode...
def z3py.RoundTowardNegative (   ctx = None)

Definition at line 7781 of file z3py.py.

7781 def RoundTowardNegative(ctx=None):
7782  ctx = _get_ctx(ctx)
7783  return FPRMRef(Z3_mk_fpa_round_toward_negative(ctx.ref()), ctx)
7784 
def RoundTowardNegative
Definition: z3py.py:7781
Z3_ast Z3_API Z3_mk_fpa_round_toward_negative(__in Z3_context c)
Create a numeral of RoundingMode sort which represents the TowardNegative rounding mode...
def z3py.RoundTowardPositive (   ctx = None)

Definition at line 7773 of file z3py.py.

7773 def RoundTowardPositive(ctx=None):
7774  ctx = _get_ctx(ctx)
7775  return FPRMRef(Z3_mk_fpa_round_toward_positive(ctx.ref()), ctx)
7776 
def RoundTowardPositive
Definition: z3py.py:7773
Z3_ast Z3_API Z3_mk_fpa_round_toward_positive(__in Z3_context c)
Create a numeral of RoundingMode sort which represents the TowardPositive rounding mode...
def z3py.RoundTowardZero (   ctx = None)

Definition at line 7789 of file z3py.py.

7789 def RoundTowardZero(ctx=None):
7790  ctx = _get_ctx(ctx)
7791  return FPRMRef(Z3_mk_fpa_round_toward_zero(ctx.ref()), ctx)
7792 
Z3_ast Z3_API Z3_mk_fpa_round_toward_zero(__in Z3_context c)
Create a numeral of RoundingMode sort which represents the TowardZero rounding mode.
def RoundTowardZero
Definition: z3py.py:7789
def z3py.RTN (   ctx = None)

Definition at line 7785 of file z3py.py.

Referenced by get_default_rounding_mode().

7785 def RTN(ctx=None):
7786  ctx = _get_ctx(ctx)
7787  return FPRMRef(Z3_mk_fpa_round_toward_negative(ctx.ref()), ctx)
7788 
def RTN
Definition: z3py.py:7785
Z3_ast Z3_API Z3_mk_fpa_round_toward_negative(__in Z3_context c)
Create a numeral of RoundingMode sort which represents the TowardNegative rounding mode...
def z3py.RTP (   ctx = None)

Definition at line 7777 of file z3py.py.

Referenced by get_default_rounding_mode().

7777 def RTP(ctx=None):
7778  ctx = _get_ctx(ctx)
7779  return FPRMRef(Z3_mk_fpa_round_toward_positive(ctx.ref()), ctx)
7780 
Z3_ast Z3_API Z3_mk_fpa_round_toward_positive(__in Z3_context c)
Create a numeral of RoundingMode sort which represents the TowardPositive rounding mode...
def RTP
Definition: z3py.py:7777
def z3py.RTZ (   ctx = None)

Definition at line 7793 of file z3py.py.

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

7793 def RTZ(ctx=None):
7794  ctx = _get_ctx(ctx)
7795  return FPRMRef(Z3_mk_fpa_round_toward_zero(ctx.ref()), ctx)
7796 
Z3_ast Z3_API Z3_mk_fpa_round_toward_zero(__in Z3_context c)
Create a numeral of RoundingMode sort which represents the TowardZero rounding mode.
def RTZ
Definition: z3py.py:7793
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 4049 of file z3py.py.

4049 def Select(a, i):
4050  """Return a Z3 select array expression.
4051 
4052  >>> a = Array('a', IntSort(), IntSort())
4053  >>> i = Int('i')
4054  >>> Select(a, i)
4055  a[i]
4056  >>> eq(Select(a, i), a[i])
4057  True
4058  """
4059  if __debug__:
4060  _z3_assert(is_array(a), "First argument must be a Z3 array expression")
4061  return a[i]
4062 
def is_array(a)
Definition: z3py.py:3909
def Select(a, i)
Definition: z3py.py:4049
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 7414 of file z3py.py.

7414 def sequence_interpolant(v,p=None,ctx=None):
7415  """Compute interpolant for a sequence of formulas.
7416 
7417  If len(v) == N, and if the conjunction of the formulas in v is
7418  unsatisfiable, the interpolant is a sequence of formulas w
7419  such that len(w) = N-1 and v[0] implies w[0] and for i in 0..N-1:
7420 
7421  1) w[i] & v[i+1] implies w[i+1] (or false if i+1 = N)
7422  2) All uninterpreted symbols in w[i] occur in both v[0]..v[i]
7423  and v[i+1]..v[n]
7424 
7425  Requires len(v) >= 1.
7426 
7427  If a & b is satisfiable, raises an object of class ModelRef
7428  that represents a model of a & b.
7429 
7430  If parameters p are supplied, these are used in creating the
7431  solver that determines satisfiability.
7432 
7433  >>> x = Int('x')
7434  >>> y = Int('y')
7435  >>> print sequence_interpolant([x < 0, y == x , y > 2])
7436  [Not(x >= 0), Not(y >= 0)]
7437  """
7438  f = v[0]
7439  for i in range(1,len(v)):
7440  f = And(Interpolant(f),v[i])
7441  return tree_interpolant(f,p,ctx)
7442 
def And(args)
Definition: z3py.py:1479
def sequence_interpolant
Definition: z3py.py:7414
def Interpolant
Definition: z3py.py:7318
def tree_interpolant
Definition: z3py.py:7332
def z3py.set_default_fp_sort (   ebits,
  sbits,
  ctx = None 
)

Definition at line 7485 of file z3py.py.

7485 def set_default_fp_sort(ebits, sbits, ctx=None):
7486  global _dflt_fpsort_ebits
7487  global _dflt_fpsort_sbits
7488  _dflt_fpsort_ebits = ebits
7489  _dflt_fpsort_sbits = sbits
7490 
def set_default_fp_sort
Definition: z3py.py:7485
def z3py.set_default_rounding_mode (   rm,
  ctx = None 
)

Definition at line 7469 of file z3py.py.

7469 def set_default_rounding_mode(rm, ctx=None):
7470  global _dflt_rounding_mode
7471  if is_fprm_value(rm):
7472  _dflt_rounding_mode = rm.decl().kind()
7473  else:
7474  _z3_assert(_dflt_rounding_mode == Z3_OP_FPA_RM_TOWARD_ZERO or
7475  _dflt_rounding_mode == Z3_OP_FPA_RM_TOWARD_NEGATIVE or
7476  _dflt_rounding_mode == Z3_OP_FPA_RM_TOWARD_POSITIVE or
7477  _dflt_rounding_mode == Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN or
7478  _dflt_rounding_mode == Z3_OP_FPA_RM_NEAREST_TIES_TO_AWAY,
7479  "illegal rounding mode")
7480  _dflt_rounding_mode = rm
7481 
def is_fprm_value(a)
Definition: z3py.py:7809
def set_default_rounding_mode
Definition: z3py.py:7469
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 
def set_param(args, kws)
Definition: z3py.py:214
void Z3_API Z3_global_param_set(__in Z3_string param_id, __in Z3_string param_value)
Set a global (or module) parameter. This setting is shared by all Z3 contexts.
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 3748 of file z3py.py.

3748 def SignExt(n, a):
3749  """Return a bit-vector expression with `n` extra sign-bits.
3750 
3751  >>> x = BitVec('x', 16)
3752  >>> n = SignExt(8, x)
3753  >>> n.size()
3754  24
3755  >>> n
3756  SignExt(8, x)
3757  >>> n.sort()
3758  BitVec(24)
3759  >>> v0 = BitVecVal(2, 2)
3760  >>> v0
3761  2
3762  >>> v0.size()
3763  2
3764  >>> v = simplify(SignExt(6, v0))
3765  >>> v
3766  254
3767  >>> v.size()
3768  8
3769  >>> print("%.x" % v.as_long())
3770  fe
3771  """
3772  if __debug__:
3773  _z3_assert(isinstance(n, int), "First argument must be an integer")
3774  _z3_assert(is_bv(a), "Second argument must be a Z3 Bitvector expression")
3775  return BitVecRef(Z3_mk_sign_ext(a.ctx_ref(), n, a.as_ast()), a.ctx)
3776 
def SignExt(n, a)
Definition: z3py.py:3748
Z3_ast Z3_API Z3_mk_sign_ext(__in Z3_context c, __in unsigned i, __in 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:3401
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 6096 of file z3py.py.

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

6096 def SimpleSolver(ctx=None):
6097  """Return a simple general purpose solver with limited amount of preprocessing.
6098 
6099  >>> s = SimpleSolver()
6100  >>> x = Int('x')
6101  >>> s.add(x > 0)
6102  >>> s.check()
6103  sat
6104  """
6105  ctx = _get_ctx(ctx)
6106  return Solver(Z3_mk_simple_solver(ctx.ref()), ctx)
6107 
Z3_solver Z3_API Z3_mk_simple_solver(__in Z3_context c)
Create a new (incremental) solver.
def SimpleSolver
Definition: z3py.py:6096
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 6979 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(), FPs(), Implies(), is_algebraic_value(), K(), LShR(), Not(), Q(), RatVal(), DatatypeSortRef.recognizer(), RepeatBitVec(), RotateLeft(), RotateRight(), SignExt(), Xor(), and ZeroExt().

6979 def simplify(a, *arguments, **keywords):
6980  """Simplify the expression `a` using the given options.
6981 
6982  This function has many options. Use `help_simplify` to obtain the complete list.
6983 
6984  >>> x = Int('x')
6985  >>> y = Int('y')
6986  >>> simplify(x + 1 + y + x + 1)
6987  2 + 2*x + y
6988  >>> simplify((x + 1)*(y + 1), som=True)
6989  1 + x + y + x*y
6990  >>> simplify(Distinct(x, y, 1), blast_distinct=True)
6991  And(Not(x == y), Not(x == 1), Not(y == 1))
6992  >>> simplify(And(x == 0, y == 1), elim_and=True)
6993  Not(Or(Not(x == 0), Not(y == 1)))
6994  """
6995  if __debug__:
6996  _z3_assert(is_expr(a), "Z3 expression expected")
6997  if len(arguments) > 0 or len(keywords) > 0:
6998  p = args2params(arguments, keywords, a.ctx)
6999  return _to_expr_ref(Z3_simplify_ex(a.ctx_ref(), a.as_ast(), p.params), a.ctx)
7000  else:
7001  return _to_expr_ref(Z3_simplify(a.ctx_ref(), a.as_ast()), a.ctx)
7002 
def simplify(a, arguments, keywords)
Utils.
Definition: z3py.py:6979
def args2params
Definition: z3py.py:4490
Z3_ast Z3_API Z3_simplify(__in Z3_context c, __in Z3_ast a)
Interface to simplifier.
def is_expr(a)
Definition: z3py.py:961
Z3_ast Z3_API Z3_simplify_ex(__in Z3_context c, __in Z3_ast a, __in Z3_params p)
Interface to simplifier.
def z3py.simplify_param_descrs ( )
Return the set of parameter descriptions for Z3 `simplify` procedure.

Definition at line 7007 of file z3py.py.

7008  """Return the set of parameter descriptions for Z3 `simplify` procedure."""
7010 
def main_ctx()
Definition: z3py.py:188
def simplify_param_descrs()
Definition: z3py.py:7007
Z3_param_descrs Z3_API Z3_simplify_get_param_descrs(__in Z3_context c)
Return the parameter description set for the simplify procedure.
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 7107 of file z3py.py.

Referenced by BV2Int(), and IsInt().

7107 def solve(*args, **keywords):
7108  """Solve the constraints `*args`.
7109 
7110  This is a simple function for creating demonstrations. It creates a solver,
7111  configure it using the options in `keywords`, adds the constraints
7112  in `args`, and invokes check.
7113 
7114  >>> a = Int('a')
7115  >>> solve(a > 0, a < 2)
7116  [a = 1]
7117  """
7118  s = Solver()
7119  s.set(**keywords)
7120  s.add(*args)
7121  if keywords.get('show', False):
7122  print(s)
7123  r = s.check()
7124  if r == unsat:
7125  print("no solution")
7126  elif r == unknown:
7127  print("failed to solve")
7128  try:
7129  print(s.model())
7130  except Z3Exception:
7131  return
7132  else:
7133  print(s.model())
7134 
def solve(args, keywords)
Definition: z3py.py:7107
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 7135 of file z3py.py.

7135 def solve_using(s, *args, **keywords):
7136  """Solve the constraints `*args` using solver `s`.
7137 
7138  This is a simple function for creating demonstrations. It is similar to `solve`,
7139  but it uses the given solver `s`.
7140  It configures solver `s` using the options in `keywords`, adds the constraints
7141  in `args`, and invokes check.
7142  """
7143  if __debug__:
7144  _z3_assert(isinstance(s, Solver), "Solver object expected")
7145  s.set(**keywords)
7146  s.add(*args)
7147  if keywords.get('show', False):
7148  print("Problem:")
7149  print(s)
7150  r = s.check()
7151  if r == unsat:
7152  print("no solution")
7153  elif r == unknown:
7154  print("failed to solve")
7155  try:
7156  print(s.model())
7157  except Z3Exception:
7158  return
7159  else:
7160  if keywords.get('show', False):
7161  print("Solution:")
7162  print(s.model())
7163 
def solve_using(s, args, keywords)
Definition: z3py.py:7135
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 6076 of file z3py.py.

6076 def SolverFor(logic, ctx=None):
6077  """Create a solver customized for the given logic.
6078 
6079  The parameter `logic` is a string. It should be contains
6080  the name of a SMT-LIB logic.
6081  See http://www.smtlib.org/ for the name of all available logics.
6082 
6083  >>> s = SolverFor("QF_LIA")
6084  >>> x = Int('x')
6085  >>> s.add(x > 0)
6086  >>> s.add(x < 2)
6087  >>> s.check()
6088  sat
6089  >>> s.model()
6090  [x = 1]
6091  """
6092  ctx = _get_ctx(ctx)
6093  logic = to_symbol(logic)
6094  return Solver(Z3_mk_solver_for_logic(ctx.ref(), logic), ctx)
6095 
def SolverFor
Definition: z3py.py:6076
Z3_solver Z3_API Z3_mk_solver_for_logic(__in Z3_context c, __in Z3_symbol logic)
Create a new solver customized for the given logic. It behaves like Z3_mk_solver if the logic is unkn...
def to_symbol
Definition: z3py.py:94
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 2878 of file z3py.py.

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

2878 def Sqrt(a, ctx=None):
2879  """ Return a Z3 expression which represents the square root of a.
2880 
2881  >>> x = Real('x')
2882  >>> Sqrt(x)
2883  x**(1/2)
2884  """
2885  if not is_expr(a):
2886  ctx = _get_ctx(ctx)
2887  a = RealVal(a, ctx)
2888  return a ** "1/2"
2889 
def RealVal
Definition: z3py.py:2683
def is_expr(a)
Definition: z3py.py:961
def Sqrt
Definition: z3py.py:2878
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 3667 of file z3py.py.

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

3667 def SRem(a, b):
3668  """Create the Z3 expression signed remainder.
3669 
3670  Use the operator % for signed modulus, and URem() for unsigned remainder.
3671 
3672  >>> x = BitVec('x', 32)
3673  >>> y = BitVec('y', 32)
3674  >>> SRem(x, y)
3675  SRem(x, y)
3676  >>> SRem(x, y).sort()
3677  BitVec(32)
3678  >>> (x % y).sexpr()
3679  '(bvsmod x y)'
3680  >>> SRem(x, y).sexpr()
3681  '(bvsrem x y)'
3682  """
3683  _check_bv_args(a, b)
3684  a, b = _coerce_exprs(a, b)
3685  return BitVecRef(Z3_mk_bvsrem(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3686 
Z3_ast Z3_API Z3_mk_bvsrem(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Two's complement signed remainder (sign follows dividend).
def SRem(a, b)
Definition: z3py.py:3667
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 4033 of file z3py.py.

Referenced by is_array(), and is_store().

4033 def Store(a, i, v):
4034  """Return a Z3 store array expression.
4035 
4036  >>> a = Array('a', IntSort(), IntSort())
4037  >>> i, v = Ints('i v')
4038  >>> s = Store(a, i, v)
4039  >>> s.sort()
4040  Array(Int, Int)
4041  >>> prove(s[i] == v)
4042  proved
4043  >>> j = Int('j')
4044  >>> prove(Implies(i != j, s[j] == a[j]))
4045  proved
4046  """
4047  return Update(a, i, v)
4048 
def Update(a, i, v)
Definition: z3py.py:4012
def Store(a, i, v)
Definition: z3py.py:4033
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 7011 of file z3py.py.

7011 def substitute(t, *m):
7012  """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.
7013 
7014  >>> x = Int('x')
7015  >>> y = Int('y')
7016  >>> substitute(x + 1, (x, y + 1))
7017  y + 1 + 1
7018  >>> f = Function('f', IntSort(), IntSort())
7019  >>> substitute(f(x) + f(y), (f(x), IntVal(1)), (f(y), IntVal(1)))
7020  1 + 1
7021  """
7022  if isinstance(m, tuple):
7023  m1 = _get_args(m)
7024  if isinstance(m1, list):
7025  m = m1
7026  if __debug__:
7027  _z3_assert(is_expr(t), "Z3 expression expected")
7028  _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.")
7029  num = len(m)
7030  _from = (Ast * num)()
7031  _to = (Ast * num)()
7032  for i in range(num):
7033  _from[i] = m[i][0].as_ast()
7034  _to[i] = m[i][1].as_ast()
7035  return _to_expr_ref(Z3_substitute(t.ctx.ref(), t.as_ast(), num, _from, _to), t.ctx)
7036 
Z3_ast Z3_API Z3_substitute(__in Z3_context c, __in Z3_ast a, __in unsigned num_exprs, __in_ecount(num_exprs) Z3_ast const from[], __in_ecount(num_exprs) 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:7011
def eq(a, b)
Definition: z3py.py:372
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 7037 of file z3py.py.

7037 def substitute_vars(t, *m):
7038  """Substitute the free variables in t with the expression in m.
7039 
7040  >>> v0 = Var(0, IntSort())
7041  >>> v1 = Var(1, IntSort())
7042  >>> x = Int('x')
7043  >>> f = Function('f', IntSort(), IntSort(), IntSort())
7044  >>> # replace v0 with x+1 and v1 with x
7045  >>> substitute_vars(f(v0, v1), x + 1, x)
7046  f(x + 1, x)
7047  """
7048  if __debug__:
7049  _z3_assert(is_expr(t), "Z3 expression expected")
7050  _z3_assert(all([is_expr(n) for n in m]), "Z3 invalid substitution, list of expressions expected.")
7051  num = len(m)
7052  _to = (Ast * num)()
7053  for i in range(num):
7054  _to[i] = m[i].as_ast()
7055  return _to_expr_ref(Z3_substitute_vars(t.ctx.ref(), t.as_ast(), num, _to), t.ctx)
7056 
Z3_ast Z3_API Z3_substitute_vars(__in Z3_context c, __in Z3_ast a, __in unsigned num_exprs, __in_ecount(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 substitute_vars(t, m)
Definition: z3py.py:7037
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 7057 of file z3py.py.

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

7057 def Sum(*args):
7058  """Create the sum of the Z3 expressions.
7059 
7060  >>> a, b, c = Ints('a b c')
7061  >>> Sum(a, b, c)
7062  a + b + c
7063  >>> Sum([a, b, c])
7064  a + b + c
7065  >>> A = IntVector('a', 5)
7066  >>> Sum(A)
7067  a__0 + a__1 + a__2 + a__3 + a__4
7068  """
7069  args = _get_args(args)
7070  if __debug__:
7071  _z3_assert(len(args) > 0, "Non empty list of arguments expected")
7072  ctx = _ctx_from_ast_arg_list(args)
7073  if __debug__:
7074  _z3_assert(ctx != None, "At least one of the arguments must be a Z3 expression")
7075  args = _coerce_expr_list(args, ctx)
7076  if is_bv(args[0]):
7077  return _reduce(lambda a, b: a + b, args, 0)
7078  else:
7079  _args, sz = _to_ast_array(args)
7080  return ArithRef(Z3_mk_add(ctx.ref(), sz, _args), ctx)
7081 
def Sum(args)
Definition: z3py.py:7057
def is_bv(a)
Definition: z3py.py:3401
Z3_ast Z3_API Z3_mk_add(__in Z3_context c, __in unsigned num_args, __in_ecount(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 z3py.tactic_description (   name,
  ctx = None 
)
Return a short description for the tactic named `name`.

>>> d = tactic_description('simplify')

Definition at line 6697 of file z3py.py.

Referenced by describe_tactics().

6697 def tactic_description(name, ctx=None):
6698  """Return a short description for the tactic named `name`.
6699 
6700  >>> d = tactic_description('simplify')
6701  """
6702  ctx = _get_ctx(ctx)
6703  return Z3_tactic_get_descr(ctx.ref(), name)
6704 
Z3_string Z3_API Z3_tactic_get_descr(__in Z3_context c, __in Z3_string name)
Return a string containing a description of the tactic with the given name.
def tactic_description
Definition: z3py.py:6697
def z3py.tactics (   ctx = None)
Return a list of all available tactics in Z3.

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

Definition at line 6687 of file z3py.py.

Referenced by describe_tactics().

6687 def tactics(ctx=None):
6688  """Return a list of all available tactics in Z3.
6689 
6690  >>> l = tactics()
6691  >>> l.count('simplify') == 1
6692  True
6693  """
6694  ctx = _get_ctx(ctx)
6695  return [ Z3_get_tactic_name(ctx.ref(), i) for i in range(Z3_get_num_tactics(ctx.ref())) ]
6696 
Z3_string Z3_API Z3_get_tactic_name(__in Z3_context c, unsigned i)
Return the name of the idx tactic.
unsigned Z3_API Z3_get_num_tactics(__in Z3_context c)
Return the number of builtin tactics available in Z3.
def tactics
Definition: z3py.py:6687
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 6579 of file z3py.py.

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

6579 def Then(*ts, **ks):
6580  """Return a tactic that applies the tactics in `*ts` in sequence. Shorthand for AndThen(*ts, **ks).
6581 
6582  >>> x, y = Ints('x y')
6583  >>> t = Then(Tactic('simplify'), Tactic('solve-eqs'))
6584  >>> t(And(x == 0, y > x + 1))
6585  [[Not(y <= 1)]]
6586  >>> t(And(x == 0, y > x + 1)).as_expr()
6587  Not(y <= 1)
6588  """
6589  return AndThen(*ts, **ks)
6590 
def Then(ts, ks)
Definition: z3py.py:6579
def AndThen(ts, ks)
Definition: z3py.py:6560
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(), 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(__in Z3_context c, __in Z3_string s)
Create a Z3 symbol using a C string.
def to_symbol
Definition: z3py.py:94
Z3_symbol Z3_API Z3_mk_int_symbol(__in Z3_context c, __in 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 2845 of file z3py.py.

Referenced by is_to_int().

2845 def ToInt(a):
2846  """ Return the Z3 expression ToInt(a).
2847 
2848  >>> x = Real('x')
2849  >>> x.sort()
2850  Real
2851  >>> n = ToInt(x)
2852  >>> n
2853  ToInt(x)
2854  >>> n.sort()
2855  Int
2856  """
2857  if __debug__:
2858  _z3_assert(a.is_real(), "Z3 real expression expected.")
2859  ctx = a.ctx
2860  return ArithRef(Z3_mk_real2int(ctx.ref(), a.as_ast()), ctx)
2861 
Z3_ast Z3_API Z3_mk_real2int(__in Z3_context c, __in Z3_ast t1)
Coerce a real to an integer.
def ToInt(a)
Definition: z3py.py:2845
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 2828 of file z3py.py.

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

2828 def ToReal(a):
2829  """ Return the Z3 expression ToReal(a).
2830 
2831  >>> x = Int('x')
2832  >>> x.sort()
2833  Int
2834  >>> n = ToReal(x)
2835  >>> n
2836  ToReal(x)
2837  >>> n.sort()
2838  Real
2839  """
2840  if __debug__:
2841  _z3_assert(a.is_int(), "Z3 integer expression expected.")
2842  ctx = a.ctx
2843  return ArithRef(Z3_mk_int2real(ctx.ref(), a.as_ast()), ctx)
2844 
Z3_ast Z3_API Z3_mk_int2real(__in Z3_context c, __in Z3_ast t1)
Coerce an integer to a real.
def ToReal(a)
Definition: z3py.py:2828
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 7332 of file z3py.py.

Referenced by binary_interpolant(), and sequence_interpolant().

7332 def tree_interpolant(pat,p=None,ctx=None):
7333  """Compute interpolant for a tree of formulas.
7334 
7335  The input is an interpolation pattern over a set of formulas C.
7336  The pattern pat is a formula combining the formulas in C using
7337  logical conjunction and the "interp" operator (see Interp). This
7338  interp operator is logically the identity operator. It marks the
7339  sub-formulas of the pattern for which interpolants should be
7340  computed. The interpolant is a map sigma from marked subformulas
7341  to formulas, such that, for each marked subformula phi of pat
7342  (where phi sigma is phi with sigma(psi) substituted for each
7343  subformula psi of phi such that psi in dom(sigma)):
7344 
7345  1) phi sigma implies sigma(phi), and
7346 
7347  2) sigma(phi) is in the common uninterpreted vocabulary between
7348  the formulas of C occurring in phi and those not occurring in
7349  phi
7350 
7351  and moreover pat sigma implies false. In the simplest case
7352  an interpolant for the pattern "(and (interp A) B)" maps A
7353  to an interpolant for A /\ B.
7354 
7355  The return value is a vector of formulas representing sigma. This
7356  vector contains sigma(phi) for each marked subformula of pat, in
7357  pre-order traversal. This means that subformulas of phi occur before phi
7358  in the vector. Also, subformulas that occur multiply in pat will
7359  occur multiply in the result vector.
7360 
7361  If pat is satisfiable, raises an object of class ModelRef
7362  that represents a model of pat.
7363 
7364  If parameters p are supplied, these are used in creating the
7365  solver that determines satisfiability.
7366 
7367  >>> x = Int('x')
7368  >>> y = Int('y')
7369  >>> print tree_interpolant(And(Interpolant(x < 0), Interpolant(y > 2), x == y))
7370  [Not(x >= 0), Not(y <= 2)]
7371 
7372  >>> g = And(Interpolant(x<0),x<2)
7373  >>> try:
7374  ... print tree_interpolant(g).sexpr()
7375  ... except ModelRef as m:
7376  ... print m.sexpr()
7377  (define-fun x () Int
7378  (- 1))
7379  """
7380  f = pat
7381  ctx = _get_ctx(_ctx_from_ast_arg_list([f], ctx))
7382  ptr = (AstVectorObj * 1)()
7383  mptr = (Model * 1)()
7384  if p == None:
7385  p = ParamsRef(ctx)
7386  res = Z3_compute_interpolant(ctx.ref(),f.as_ast(),p.params,ptr,mptr)
7387  if res == Z3_L_FALSE:
7388  return AstVector(ptr[0],ctx)
7389  raise ModelRef(mptr[0], ctx)
7390 
Parameter Sets.
Definition: z3py.py:4453
def tree_interpolant
Definition: z3py.py:7332
Z3_lbool Z3_API Z3_compute_interpolant(__in Z3_context c, __in Z3_ast pat, __in Z3_params p, __out Z3_ast_vector *interp, __out Z3_model *model)
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 6679 of file z3py.py.

6679 def TryFor(t, ms, ctx=None):
6680  """Return a tactic that applies `t` to a given goal for `ms` milliseconds.
6681 
6682  If `t` does not terminate in `ms` milliseconds, then it fails.
6683  """
6684  t = _to_tactic(t, ctx)
6685  return Tactic(Z3_tactic_try_for(t.ctx.ref(), t.tactic, ms), t.ctx)
6686 
Z3_tactic Z3_API Z3_tactic_try_for(__in Z3_context c, __in Z3_tactic t, __in 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
Definition: z3py.py:6679
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 3627 of file z3py.py.

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

3627 def UDiv(a, b):
3628  """Create the Z3 expression (unsigned) division `self / other`.
3629 
3630  Use the operator / for signed division.
3631 
3632  >>> x = BitVec('x', 32)
3633  >>> y = BitVec('y', 32)
3634  >>> UDiv(x, y)
3635  UDiv(x, y)
3636  >>> UDiv(x, y).sort()
3637  BitVec(32)
3638  >>> (x / y).sexpr()
3639  '(bvsdiv x y)'
3640  >>> UDiv(x, y).sexpr()
3641  '(bvudiv x y)'
3642  """
3643  _check_bv_args(a, b)
3644  a, b = _coerce_exprs(a, b)
3645  return BitVecRef(Z3_mk_bvudiv(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3646 
Z3_ast Z3_API Z3_mk_bvudiv(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Unsigned division.
def UDiv(a, b)
Definition: z3py.py:3627
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 3593 of file z3py.py.

Referenced by BitVecRef.__ge__().

3593 def UGE(a, b):
3594  """Create the Z3 expression (unsigned) `other >= self`.
3595 
3596  Use the operator >= for signed greater than or equal to.
3597 
3598  >>> x, y = BitVecs('x y', 32)
3599  >>> UGE(x, y)
3600  UGE(x, y)
3601  >>> (x >= y).sexpr()
3602  '(bvsge x y)'
3603  >>> UGE(x, y).sexpr()
3604  '(bvuge x y)'
3605  """
3606  _check_bv_args(a, b)
3607  a, b = _coerce_exprs(a, b)
3608  return BoolRef(Z3_mk_bvuge(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3609 
def UGE(a, b)
Definition: z3py.py:3593
Z3_ast Z3_API Z3_mk_bvuge(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Unsigned greater than or equal to.
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 3610 of file z3py.py.

Referenced by BitVecRef.__gt__().

3610 def UGT(a, b):
3611  """Create the Z3 expression (unsigned) `other > self`.
3612 
3613  Use the operator > for signed greater than.
3614 
3615  >>> x, y = BitVecs('x y', 32)
3616  >>> UGT(x, y)
3617  UGT(x, y)
3618  >>> (x > y).sexpr()
3619  '(bvsgt x y)'
3620  >>> UGT(x, y).sexpr()
3621  '(bvugt x y)'
3622  """
3623  _check_bv_args(a, b)
3624  a, b = _coerce_exprs(a, b)
3625  return BoolRef(Z3_mk_bvugt(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3626 
Z3_ast Z3_API Z3_mk_bvugt(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Unsigned greater than.
def UGT(a, b)
Definition: z3py.py:3610
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 3559 of file z3py.py.

Referenced by BitVecRef.__le__().

3559 def ULE(a, b):
3560  """Create the Z3 expression (unsigned) `other <= self`.
3561 
3562  Use the operator <= for signed less than or equal to.
3563 
3564  >>> x, y = BitVecs('x y', 32)
3565  >>> ULE(x, y)
3566  ULE(x, y)
3567  >>> (x <= y).sexpr()
3568  '(bvsle x y)'
3569  >>> ULE(x, y).sexpr()
3570  '(bvule x y)'
3571  """
3572  _check_bv_args(a, b)
3573  a, b = _coerce_exprs(a, b)
3574  return BoolRef(Z3_mk_bvule(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3575 
Z3_ast Z3_API Z3_mk_bvule(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Unsigned less than or equal to.
def ULE(a, b)
Definition: z3py.py:3559
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 3576 of file z3py.py.

Referenced by BitVecRef.__lt__().

3576 def ULT(a, b):
3577  """Create the Z3 expression (unsigned) `other < self`.
3578 
3579  Use the operator < for signed less than.
3580 
3581  >>> x, y = BitVecs('x y', 32)
3582  >>> ULT(x, y)
3583  ULT(x, y)
3584  >>> (x < y).sexpr()
3585  '(bvslt x y)'
3586  >>> ULT(x, y).sexpr()
3587  '(bvult x y)'
3588  """
3589  _check_bv_args(a, b)
3590  a, b = _coerce_exprs(a, b)
3591  return BoolRef(Z3_mk_bvult(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3592 
def ULT(a, b)
Definition: z3py.py:3576
Z3_ast Z3_API Z3_mk_bvult(__in Z3_context c, __in Z3_ast t1, __in 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 4012 of file z3py.py.

Referenced by Store().

4012 def Update(a, i, v):
4013  """Return a Z3 store array expression.
4014 
4015  >>> a = Array('a', IntSort(), IntSort())
4016  >>> i, v = Ints('i v')
4017  >>> s = Update(a, i, v)
4018  >>> s.sort()
4019  Array(Int, Int)
4020  >>> prove(s[i] == v)
4021  proved
4022  >>> j = Int('j')
4023  >>> prove(Implies(i != j, s[j] == a[j]))
4024  proved
4025  """
4026  if __debug__:
4027  _z3_assert(is_array(a), "First argument must be a Z3 array expression")
4028  i = a.domain().cast(i)
4029  v = a.range().cast(v)
4030  ctx = a.ctx
4031  return _to_expr_ref(Z3_mk_store(ctx.ref(), a.as_ast(), i.as_ast(), v.as_ast()), ctx)
4032 
def is_array(a)
Definition: z3py.py:3909
def Update(a, i, v)
Definition: z3py.py:4012
Z3_ast Z3_API Z3_mk_store(__in Z3_context c, __in Z3_ast a, __in Z3_ast i, __in Z3_ast v)
Array update.
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 3647 of file z3py.py.

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

3647 def URem(a, b):
3648  """Create the Z3 expression (unsigned) remainder `self % other`.
3649 
3650  Use the operator % for signed modulus, and SRem() for signed remainder.
3651 
3652  >>> x = BitVec('x', 32)
3653  >>> y = BitVec('y', 32)
3654  >>> URem(x, y)
3655  URem(x, y)
3656  >>> URem(x, y).sort()
3657  BitVec(32)
3658  >>> (x % y).sexpr()
3659  '(bvsmod x y)'
3660  >>> URem(x, y).sexpr()
3661  '(bvurem x y)'
3662  """
3663  _check_bv_args(a, b)
3664  a, b = _coerce_exprs(a, b)
3665  return BitVecRef(Z3_mk_bvurem(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
3666 
Z3_ast Z3_API Z3_mk_bvurem(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Unsigned remainder.
def URem(a, b)
Definition: z3py.py:3647
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(__in Z3_context c, __in unsigned index, __in Z3_sort ty)
Create a bound variable.
def Var(idx, s)
Definition: z3py.py:1170
def is_sort(s)
Definition: z3py.py:532
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 6945 of file z3py.py.

6945 def When(p, t, ctx=None):
6946  """Return a tactic that applies tactic `t` only if probe `p` evaluates to true. Otherwise, it returns the input goal unmodified.
6947 
6948  >>> t = When(Probe('size') > 2, Tactic('simplify'))
6949  >>> x, y = Ints('x y')
6950  >>> g = Goal()
6951  >>> g.add(x > 0)
6952  >>> g.add(y > 0)
6953  >>> t(g)
6954  [[x > 0, y > 0]]
6955  >>> g.add(x == y + 1)
6956  >>> t(g)
6957  [[Not(x <= 0), Not(y <= 0), x == 1 + y]]
6958  """
6959  p = _to_probe(p, ctx)
6960  t = _to_tactic(t, ctx)
6961  return Tactic(Z3_tactic_when(t.ctx.ref(), p.probe, t.tactic), t.ctx)
6962 
def When
Definition: z3py.py:6945
Z3_tactic Z3_API Z3_tactic_when(__in Z3_context c, __in Z3_probe p, __in 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 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 6647 of file z3py.py.

Referenced by Goal.prec().

6647 def With(t, *args, **keys):
6648  """Return a tactic that applies tactic `t` using the given configuration options.
6649 
6650  >>> x, y = Ints('x y')
6651  >>> t = With(Tactic('simplify'), som=True)
6652  >>> t((x + 1)*(y + 2) == 0)
6653  [[2*x + y + x*y == -2]]
6654  """
6655  ctx = keys.get('ctx', None)
6656  t = _to_tactic(t, ctx)
6657  p = args2params(args, keys, t.ctx)
6658  return Tactic(Z3_tactic_using_params(t.ctx.ref(), t.tactic, p.params), t.ctx)
6659 
def args2params
Definition: z3py.py:4490
Z3_tactic Z3_API Z3_tactic_using_params(__in Z3_context c, __in Z3_tactic t, __in Z3_params p)
Return a tactic that applies t using the given set of parameters.
def With(t, args, keys)
Definition: z3py.py:6647
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 1439 of file z3py.py.

1439 def Xor(a, b, ctx=None):
1440  """Create a Z3 Xor expression.
1441 
1442  >>> p, q = Bools('p q')
1443  >>> Xor(p, q)
1444  Xor(p, q)
1445  >>> simplify(Xor(p, q))
1446  Not(p) == q
1447  """
1448  ctx = _get_ctx(_ctx_from_ast_arg_list([a, b], ctx))
1449  s = BoolSort(ctx)
1450  a = s.cast(a)
1451  b = s.cast(b)
1452  return BoolRef(Z3_mk_xor(ctx.ref(), a.as_ast(), b.as_ast()), ctx)
1453 
def BoolSort
Definition: z3py.py:1336
def Xor
Definition: z3py.py:1439
Z3_ast Z3_API Z3_mk_xor(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Create an AST node representing t1 xor t2.
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 3777 of file z3py.py.

3777 def ZeroExt(n, a):
3778  """Return a bit-vector expression with `n` extra zero-bits.
3779 
3780  >>> x = BitVec('x', 16)
3781  >>> n = ZeroExt(8, x)
3782  >>> n.size()
3783  24
3784  >>> n
3785  ZeroExt(8, x)
3786  >>> n.sort()
3787  BitVec(24)
3788  >>> v0 = BitVecVal(2, 2)
3789  >>> v0
3790  2
3791  >>> v0.size()
3792  2
3793  >>> v = simplify(ZeroExt(6, v0))
3794  >>> v
3795  2
3796  >>> v.size()
3797  8
3798  """
3799  if __debug__:
3800  _z3_assert(isinstance(n, int), "First argument must be an integer")
3801  _z3_assert(is_bv(a), "Second argument must be a Z3 Bitvector expression")
3802  return BitVecRef(Z3_mk_zero_ext(a.ctx_ref(), n, a.as_ast()), a.ctx)
3803 
Z3_ast Z3_API Z3_mk_zero_ext(__in Z3_context c, __in unsigned i, __in Z3_ast t1)
Extend the given bit-vector with zeros to the (unsigned) equivalent bitvector of size m+i...
def ZeroExt(n, a)
Definition: z3py.py:3777
def is_bv(a)
Definition: z3py.py:3401

Variable Documentation

int _dflt_fpsort_ebits = 11

Definition at line 7452 of file z3py.py.

int _dflt_fpsort_sbits = 53

Definition at line 7453 of file z3py.py.

_dflt_rounding_mode = Z3_OP_FPA_RM_TOWARD_ZERO

Floating-Point Arithmetic.

Definition at line 7451 of file z3py.py.

tuple _error_handler_fptr = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_uint)

Definition at line 108 of file z3py.py.

_main_ctx = None

Definition at line 187 of file z3py.py.

tuple _Z3Python_error_handler = _error_handler_fptr(_Z3python_error_handler_core)

Definition at line 126 of file z3py.py.

tuple sat = CheckSatResult(Z3_L_TRUE)

Definition at line 5734 of file z3py.py.

tuple unknown = CheckSatResult(Z3_L_UNDEF)

Definition at line 5736 of file z3py.py.

tuple unsat = CheckSatResult(Z3_L_FALSE)

Definition at line 5735 of file z3py.py.