Z3
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Data Structures | Functions | Variables
z3py Namespace Reference

Data Structures

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

Functions

def enable_trace
 
def disable_trace
 
def get_version_string
 
def get_version
 
def open_log
 
def append_log
 
def to_symbol
 
def main_ctx
 
def set_param
 
def reset_params
 
def set_option
 
def get_param
 
def is_ast
 
def eq
 
def is_sort
 
def DeclareSort
 
def is_func_decl
 
def Function
 
def is_expr
 
def is_app
 
def is_const
 
def is_var
 
def get_var_index
 
def is_app_of
 
def If
 
def Distinct
 
def Const
 
def Consts
 
def Var
 
def RealVar
 
def RealVarVector
 
def is_bool
 
def is_true
 
def is_false
 
def is_and
 
def is_or
 
def is_not
 
def is_eq
 
def is_distinct
 
def BoolSort
 
def BoolVal
 
def Bool
 
def Bools
 
def BoolVector
 
def FreshBool
 
def Implies
 
def Xor
 
def Not
 
def And
 
def Or
 
def is_pattern
 
def MultiPattern
 
def is_quantifier
 
def ForAll
 
def Exists
 
def is_arith_sort
 
def is_arith
 
def is_int
 
def is_real
 
def is_int_value
 
def is_rational_value
 
def is_algebraic_value
 
def is_add
 
def is_mul
 
def is_sub
 
def is_div
 
def is_idiv
 
def is_mod
 
def is_le
 
def is_lt
 
def is_ge
 
def is_gt
 
def is_is_int
 
def is_to_real
 
def is_to_int
 
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
 
def ToInt
 
def IsInt
 
def Sqrt
 
def Cbrt
 
def is_bv_sort
 
def is_bv
 
def is_bv_value
 
def BV2Int
 
def BitVecSort
 
def BitVecVal
 
def BitVec
 
def BitVecs
 
def Concat
 
def Extract
 
def ULE
 
def ULT
 
def UGE
 
def UGT
 
def UDiv
 
def URem
 
def SRem
 
def LShR
 
def RotateLeft
 
def RotateRight
 
def SignExt
 
def ZeroExt
 
def RepeatBitVec
 
def BVRedAnd
 
def BVRedOr
 
def is_array
 
def is_const_array
 
def is_K
 
def is_map
 
def is_default
 
def get_map_func
 
def ArraySort
 
def Array
 
def Update
 
def Default
 
def Store
 
def Select
 
def Map
 
def K
 
def is_select
 
def is_store
 
def CreateDatatypes
 
def EnumSort
 
def args2params
 
def is_as_array
 
def get_as_array_func
 
def SolverFor
 
def SimpleSolver
 
def FiniteDomainSort
 
def AndThen
 
def Then
 
def OrElse
 
def ParOr
 
def ParThen
 
def ParAndThen
 
def With
 
def Repeat
 
def TryFor
 
def tactics
 
def tactic_description
 
def describe_tactics
 
def is_probe
 
def probes
 
def probe_description
 
def describe_probes
 
def FailIf
 
def When
 
def Cond
 
def simplify
 Utils. More...
 
def help_simplify
 
def simplify_param_descrs
 
def substitute
 
def substitute_vars
 
def Sum
 
def Product
 
def solve
 
def solve_using
 
def prove
 
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
 
def is_fprm_sort
 
def RoundNearestTiesToEven
 
def RNE
 
def RoundNearestTiesToAway
 
def RNA
 
def RoundTowardPositive
 
def RTP
 
def RoundTowardNegative
 
def RTN
 
def RoundTowardZero
 
def RTZ
 
def is_fprm
 
def is_fprm_value
 
def is_fp
 
def is_fp_value
 
def FPSort
 
def fpNaN
 
def fpPlusInfinity
 
def fpMinusInfinity
 
def fpInfinity
 
def fpPlusZero
 
def fpMinusZero
 
def fpZero
 
def FPVal
 
def FP
 
def FPs
 
def fpAbs
 
def fpNeg
 
def fpAdd
 
def fpSub
 
def fpMul
 
def fpDiv
 
def fpRem
 
def fpMin
 
def fpMax
 
def fpFMA
 
def fpSqrt
 
def fpRoundToIntegral
 
def fpIsNaN
 
def fpIsInfinite
 
def fpIsZero
 
def fpIsNormal
 
def fpIsSubnormal
 
def fpIsNegative
 
def fpIsPositive
 
def fpLT
 
def fpLEQ
 
def fpGT
 
def fpGEQ
 
def fpEQ
 
def fpNEQ
 
def fpFP
 
def fpToFP
 
def fpToFPUnsigned
 
def fpToSBV
 
def fpToUBV
 
def fpToReal
 
def fpToIEEEBV
 

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

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

1490 def And(*args):
1491  """Create a Z3 and-expression or and-probe.
1492 
1493  >>> p, q, r = Bools('p q r')
1494  >>> And(p, q, r)
1495  And(p, q, r)
1496  >>> P = BoolVector('p', 5)
1497  >>> And(P)
1498  And(p__0, p__1, p__2, p__3, p__4)
1499  """
1500  last_arg = None
1501  if len(args) > 0:
1502  last_arg = args[len(args)-1]
1503  if isinstance(last_arg, Context):
1504  ctx = args[len(args)-1]
1505  args = args[:len(args)-1]
1506  else:
1507  ctx = main_ctx()
1508  args = _get_args(args)
1509  ctx_args = _ctx_from_ast_arg_list(args, ctx)
1510  if __debug__:
1511  _z3_assert(ctx_args == None or ctx_args == ctx, "context mismatch")
1512  _z3_assert(ctx != None, "At least one of the arguments must be a Z3 expression or probe")
1513  if _has_probe(args):
1514  return _probe_and(args, ctx)
1515  else:
1516  args = _coerce_expr_list(args, ctx)
1517  _args, sz = _to_ast_array(args)
1518  return BoolRef(Z3_mk_and(ctx.ref(), sz, _args), ctx)
def And
Definition: z3py.py:1489
Z3_ast Z3_API Z3_mk_and(Z3_context c, unsigned num_args, Z3_ast const args[])
Create an AST node representing args[0] and ... and args[num_args-1].The array args must have num_arg...
def main_ctx
Definition: z3py.py:188
def z3py.AndThen (   ts,
  ks 
)
Return a tactic that applies the tactics in `*ts` in sequence.

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

Definition at line 6759 of file z3py.py.

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

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

Definition at line 90 of file z3py.py.

90 
91 def append_log(s):
92  """Append user-defined string to interaction log. """
93  Z3_append_log(s)
void Z3_API Z3_append_log(Z3_string string)
Append user-defined string to interaction log.
def append_log
Definition: z3py.py:90
def z3py.args2params (   arguments,
  keywords,
  ctx = None 
)
Convert python arguments into a Z3_params object.
A ':' is added to the keywords, and '_' is replaced with '-'

>>> args2params(['model', True, 'relevancy', 2], {'elim_and' : True})
(params model true relevancy 2 elim_and true)

Definition at line 4527 of file z3py.py.

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

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

>>> a = Array('a', IntSort(), IntSort())
>>> a.sort()
Array(Int, Int)
>>> a[0]
a[0]

Definition at line 4025 of file z3py.py.

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

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

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

4005 def ArraySort(d, r):
4006  """Return the Z3 array sort with the given domain and range sorts.
4007 
4008  >>> A = ArraySort(IntSort(), BoolSort())
4009  >>> A
4010  Array(Int, Bool)
4011  >>> A.domain()
4012  Int
4013  >>> A.range()
4014  Bool
4015  >>> AA = ArraySort(IntSort(), A)
4016  >>> AA
4017  Array(Int, Array(Int, Bool))
4018  """
4019  if __debug__:
4020  _z3_assert(is_sort(d), "Z3 sort expected")
4021  _z3_assert(is_sort(r), "Z3 sort expected")
4022  _z3_assert(d.ctx == r.ctx, "Context mismatch")
4023  ctx = d.ctx
4024  return ArraySortRef(Z3_mk_array_sort(ctx.ref(), d.ast, r.ast), ctx)
def ArraySort
Definition: z3py.py:4004
Arrays.
Definition: z3py.py:3859
Z3_sort Z3_API Z3_mk_array_sort(Z3_context c, Z3_sort domain, Z3_sort range)
Create an array type.
def is_sort
Definition: z3py.py:530
def z3py.binary_interpolant (   a,
  b,
  p = None,
  ctx = None 
)
Compute an interpolant for a binary conjunction.

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

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

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

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

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

Definition at line 7590 of file z3py.py.

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

>>> x  = BitVec('x', 16)
>>> is_bv(x)
True
>>> x.size()
16
>>> x.sort()
BitVec(16)
>>> word = BitVecSort(16)
>>> x2 = BitVec('x', word)
>>> eq(x, x2)
True

Definition at line 3490 of file z3py.py.

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

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

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

3514 def BitVecs(names, bv, ctx=None):
3515  """Return a tuple of bit-vector constants of size bv.
3516 
3517  >>> x, y, z = BitVecs('x y z', 16)
3518  >>> x.size()
3519  16
3520  >>> x.sort()
3521  BitVec(16)
3522  >>> Sum(x, y, z)
3523  0 + x + y + z
3524  >>> Product(x, y, z)
3525  1*x*y*z
3526  >>> simplify(Product(x, y, z))
3527  x*y*z
3528  """
3529  ctx = _get_ctx(ctx)
3530  if isinstance(names, str):
3531  names = names.split(" ")
3532  return [BitVec(name, bv, ctx) for name in names]
def BitVec
Definition: z3py.py:3490
def BitVecs
Definition: z3py.py:3513
def z3py.BitVecSort (   sz,
  ctx = None 
)
Return a Z3 bit-vector sort of the given size. If `ctx=None`, then the global context is used.

>>> Byte = BitVecSort(8)
>>> Word = BitVecSort(16)
>>> Byte
BitVec(8)
>>> x = Const('x', Byte)
>>> eq(x, BitVec('x', 8))
True

Definition at line 3460 of file z3py.py.

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

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

>>> v = BitVecVal(10, 32)
>>> v
10
>>> print("0x%.8x" % v.as_long())
0x0000000a

Definition at line 3474 of file z3py.py.

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

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

>>> p = Bool('p')
>>> q = Bool('q')
>>> And(p, q)
And(p, q)

Definition at line 1381 of file z3py.py.

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

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

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

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

>>> BoolSort()
Bool
>>> p = Const('p', BoolSort())
>>> is_bool(p)
True
>>> r = Function('r', IntSort(), IntSort(), BoolSort())
>>> r(0, 1)
r(0, 1)
>>> is_bool(r(0, 1))
True

Definition at line 1346 of file z3py.py.

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

1347 def BoolSort(ctx=None):
1348  """Return the Boolean Z3 sort. If `ctx=None`, then the global context is used.
1349 
1350  >>> BoolSort()
1351  Bool
1352  >>> p = Const('p', BoolSort())
1353  >>> is_bool(p)
1354  True
1355  >>> r = Function('r', IntSort(), IntSort(), BoolSort())
1356  >>> r(0, 1)
1357  r(0, 1)
1358  >>> is_bool(r(0, 1))
1359  True
1360  """
1361  ctx = _get_ctx(ctx)
1362  return BoolSortRef(Z3_mk_bool_sort(ctx.ref()), ctx)
def BoolSort
Definition: z3py.py:1346
def is_bool
Definition: z3py.py:1246
def z3py.BoolVal (   val,
  ctx = None 
)
Return the Boolean value `True` or `False`. If `ctx=None`, then the global context is used.

>>> BoolVal(True)
True
>>> is_true(BoolVal(True))
True
>>> is_true(True)
False
>>> is_false(BoolVal(False))
True

Definition at line 1363 of file z3py.py.

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

1364 def BoolVal(val, ctx=None):
1365  """Return the Boolean value `True` or `False`. If `ctx=None`, then the global context is used.
1366 
1367  >>> BoolVal(True)
1368  True
1369  >>> is_true(BoolVal(True))
1370  True
1371  >>> is_true(True)
1372  False
1373  >>> is_false(BoolVal(False))
1374  True
1375  """
1376  ctx = _get_ctx(ctx)
1377  if val == False:
1378  return BoolRef(Z3_mk_false(ctx.ref()), ctx)
1379  else:
1380  return BoolRef(Z3_mk_true(ctx.ref()), ctx)
Z3_ast Z3_API Z3_mk_true(Z3_context c)
Create an AST node representing true.
Z3_ast Z3_API Z3_mk_false(Z3_context c)
Create an AST node representing false.
def BoolVal
Definition: z3py.py:1363
def z3py.BoolVector (   prefix,
  sz,
  ctx = None 
)
Return a list of Boolean constants of size `sz`.

The constants are named using the given prefix.
If `ctx=None`, then the global context is used.

>>> P = BoolVector('p', 3)
>>> P
[p__0, p__1, p__2]
>>> And(P)
And(p__0, p__1, p__2)

Definition at line 1407 of file z3py.py.

Referenced by And(), and Or().

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

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

Definition at line 3442 of file z3py.py.

3443 def BV2Int(a):
3444  """Return the Z3 expression BV2Int(a).
3445 
3446  >>> b = BitVec('b', 3)
3447  >>> BV2Int(b).sort()
3448  Int
3449  >>> x = Int('x')
3450  >>> x > BV2Int(b)
3451  x > BV2Int(b)
3452  >>> solve(x > BV2Int(b), b == 1, x < 3)
3453  [b = 1, x = 2]
3454  """
3455  if __debug__:
3456  _z3_assert(is_bv(a), "Z3 bit-vector expression expected")
3457  ctx = a.ctx
3458  ## investigate problem with bv2int
3459  return ArithRef(Z3_mk_bv2int(ctx.ref(), a.as_ast(), 0), ctx)
def BV2Int
Definition: z3py.py:3442
Z3_ast Z3_API Z3_mk_bv2int(Z3_context c, Z3_ast t1, Z3_bool is_signed)
Create an integer from the bit-vector argument t1. If is_signed is false, then the bit-vector t1 is t...
def is_bv
Definition: z3py.py:3415
def z3py.BVRedAnd (   a)
Return the reduction-and expression of `a`.

Definition at line 3841 of file z3py.py.

3842 def BVRedAnd(a):
3843  """Return the reduction-and expression of `a`."""
3844  if __debug__:
3845  _z3_assert(is_bv(a), "First argument must be a Z3 Bitvector expression")
3846  return BitVecRef(Z3_mk_bvredand(a.ctx_ref(), a.as_ast()), a.ctx)
Z3_ast Z3_API Z3_mk_bvredand(Z3_context c, Z3_ast t1)
Take conjunction of bits in vector, return vector of length 1.
def is_bv
Definition: z3py.py:3415
def BVRedAnd
Definition: z3py.py:3841
def z3py.BVRedOr (   a)
Return the reduction-or expression of `a`.

Definition at line 3847 of file z3py.py.

3848 def BVRedOr(a):
3849  """Return the reduction-or expression of `a`."""
3850  if __debug__:
3851  _z3_assert(is_bv(a), "First argument must be a Z3 Bitvector expression")
3852  return BitVecRef(Z3_mk_bvredor(a.ctx_ref(), a.as_ast()), a.ctx)
def is_bv
Definition: z3py.py:3415
def BVRedOr
Definition: z3py.py:3847
Z3_ast Z3_API Z3_mk_bvredor(Z3_context c, Z3_ast t1)
Take disjunction of bits in vector, return vector of length 1.
def z3py.Cbrt (   a,
  ctx = None 
)
Return a Z3 expression which represents the cubic root of a. 

>>> x = Real('x')
>>> Cbrt(x)
x**(1/3)

Definition at line 2904 of file z3py.py.

2905 def Cbrt(a, ctx=None):
2906  """ Return a Z3 expression which represents the cubic root of a.
2907 
2908  >>> x = Real('x')
2909  >>> Cbrt(x)
2910  x**(1/3)
2911  """
2912  if not is_expr(a):
2913  ctx = _get_ctx(ctx)
2914  a = RealVal(a, ctx)
2915  return a ** "1/3"
def Cbrt
Definition: z3py.py:2904
def is_expr
Definition: z3py.py:961
def RealVal
Definition: z3py.py:2697
def z3py.Concat (   args)
Create a Z3 bit-vector concatenation expression. 

>>> v = BitVecVal(1, 4)
>>> Concat(v, v+1, v)
Concat(Concat(1, 1 + 1), 1)
>>> simplify(Concat(v, v+1, v))
289
>>> print("%.3x" % simplify(Concat(v, v+1, v)).as_long())
121

Definition at line 3533 of file z3py.py.

Referenced by BitVecRef.size().

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

>>> t = Cond(Probe('is-qfnra'), Tactic('qfnra'), Tactic('smt'))

Definition at line 7162 of file z3py.py.

Referenced by If().

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

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

Definition at line 1145 of file z3py.py.

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

1146 def Const(name, sort):
1147  """Create a constant of the given sort.
1148 
1149  >>> Const('x', IntSort())
1150  x
1151  """
1152  if __debug__:
1153  _z3_assert(isinstance(sort, SortRef), "Z3 sort expected")
1154  ctx = sort.ctx
1155  return _to_expr_ref(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), sort.ast), ctx)
Z3_ast Z3_API Z3_mk_const(Z3_context c, Z3_symbol s, Z3_sort ty)
Declare and create a constant.
def Const
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().

1157 def Consts(names, sort):
1158  """Create a several constants of the given sort.
1159 
1160  `names` is a string containing the names of all constants to be created.
1161  Blank spaces separate the names of different constants.
1162 
1163  >>> x, y, z = Consts('x y z', IntSort())
1164  >>> x + y + z
1165  x + y + z
1166  """
1167  if isinstance(names, str):
1168  names = names.split(" ")
1169  return [Const(name, sort) for name in names]
def Consts
Definition: z3py.py:1156
def Const
Definition: z3py.py:1145
def z3py.CreateDatatypes (   ds)
Create mutually recursive Z3 datatypes using 1 or more Datatype helper objects.

In the following example we define a Tree-List using two mutually recursive datatypes.

>>> TreeList = Datatype('TreeList')
>>> Tree     = Datatype('Tree')
>>> # Tree has two constructors: leaf and node
>>> Tree.declare('leaf', ('val', IntSort()))
>>> # a node contains a list of trees
>>> Tree.declare('node', ('children', TreeList))
>>> TreeList.declare('nil')
>>> TreeList.declare('cons', ('car', Tree), ('cdr', TreeList))
>>> Tree, TreeList = CreateDatatypes(Tree, TreeList)
>>> Tree.val(Tree.leaf(10))
val(leaf(10))
>>> simplify(Tree.val(Tree.leaf(10)))
10
>>> n1 = Tree.node(TreeList.cons(Tree.leaf(10), TreeList.cons(Tree.leaf(20), TreeList.nil)))
>>> n1
node(cons(leaf(10), cons(leaf(20), nil)))
>>> n2 = Tree.node(TreeList.cons(n1, TreeList.nil))
>>> simplify(n2 == n1)
False
>>> simplify(TreeList.car(Tree.children(n2)) == n1)
True

Definition at line 4269 of file z3py.py.

Referenced by Datatype.create().

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

If `ctx=None`, then the new sort is declared in the global Z3Py context.

>>> A = DeclareSort('A')
>>> a = Const('a', A)
>>> b = Const('b', A)
>>> a.sort() == A
True
>>> b.sort() == A
True
>>> a == b
a == b

Definition at line 567 of file z3py.py.

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

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

Definition at line 4059 of file z3py.py.

Referenced by is_default().

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

Definition at line 7092 of file z3py.py.

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

Definition at line 6904 of file z3py.py.

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

Definition at line 61 of file z3py.py.

61 
62 def disable_trace(msg):
63  Z3_disable_trace(msg)
void Z3_API Z3_disable_trace(Z3_string tag)
Disable tracing messages tagged as tag when Z3 is compiled in debug mode. It is a NOOP otherwise...
def disable_trace
Definition: z3py.py:61
def z3py.Distinct (   args)
Create a Z3 distinct expression. 

>>> x = Int('x')
>>> y = Int('y')
>>> Distinct(x, y)
x != y
>>> z = Int('z')
>>> Distinct(x, y, z)
Distinct(x, y, z)
>>> simplify(Distinct(x, y, z))
Distinct(x, y, z)
>>> simplify(Distinct(x, y, z), blast_distinct=True)
And(Not(x == y), Not(x == z), Not(y == z))

Definition at line 1114 of file z3py.py.

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

Definition at line 58 of file z3py.py.

58 
59 def enable_trace(msg):
60  Z3_enable_trace(msg)
void Z3_API Z3_enable_trace(Z3_string tag)
Enable tracing messages tagged as tag when Z3 is compiled in debug mode. It is a NOOP otherwise...
def enable_trace
Definition: z3py.py:58
def z3py.EnumSort (   name,
  values,
  ctx = None 
)
Return a new enumeration sort named `name` containing the given values.

The result is a pair (sort, list of constants).
Example:
    >>> Color, (red, green, blue) = EnumSort('Color', ['red', 'green', 'blue'])

Definition at line 4458 of file z3py.py.

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

4459 def EnumSort(name, values, ctx=None):
4460  """Return a new enumeration sort named `name` containing the given values.
4461 
4462  The result is a pair (sort, list of constants).
4463  Example:
4464  >>> Color, (red, green, blue) = EnumSort('Color', ['red', 'green', 'blue'])
4465  """
4466  if __debug__:
4467  _z3_assert(isinstance(name, str), "Name must be a string")
4468  _z3_assert(all([isinstance(v, str) for v in values]), "Eumeration sort values must be strings")
4469  _z3_assert(len(values) > 0, "At least one value expected")
4470  ctx = _get_ctx(ctx)
4471  num = len(values)
4472  _val_names = (Symbol * num)()
4473  for i in range(num):
4474  _val_names[i] = to_symbol(values[i])
4475  _values = (FuncDecl * num)()
4476  _testers = (FuncDecl * num)()
4477  name = to_symbol(name)
4478  S = DatatypeSortRef(Z3_mk_enumeration_sort(ctx.ref(), name, num, _val_names, _values, _testers), ctx)
4479  V = []
4480  for i in range(num):
4481  V.append(FuncDeclRef(_values[i], ctx))
4482  V = [a() for a in V]
4483  return S, V
Function Declarations.
Definition: z3py.py:591
def EnumSort
Definition: z3py.py:4458
def to_symbol
Definition: z3py.py:94
Z3_sort Z3_API Z3_mk_enumeration_sort(Z3_context c, Z3_symbol name, unsigned n, Z3_symbol const enum_names[], Z3_func_decl enum_consts[], Z3_func_decl enum_testers[])
Create a enumeration sort.
def z3py.eq (   a,
  b 
)
Return `True` if `a` and `b` are structurally identical AST nodes.

>>> x = Int('x')
>>> y = Int('y')
>>> eq(x, y)
False
>>> eq(x + 1, x + 1)
True
>>> eq(x + 1, 1 + x)
False
>>> eq(simplify(x + 1), simplify(1 + x))
True

Definition at line 371 of file z3py.py.

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

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)
def is_ast
Definition: z3py.py:351
def eq
Definition: z3py.py:371
def z3py.Exists (   vs,
  body,
  weight = 1,
  qid = "",
  skid = "",
  patterns = [],
  no_patterns = [] 
)
Create a Z3 exists formula.

The parameters `weight`, `qif`, `skid`, `patterns` and `no_patterns` are optional annotations.

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

>>> f = Function('f', IntSort(), IntSort(), IntSort())
>>> x = Int('x')
>>> y = Int('y')
>>> q = Exists([x, y], f(x, y) >= x, skid="foo")
>>> q
Exists([x, y], f(x, y) >= x)
>>> is_quantifier(q)
True
>>> r = Tactic('nnf')(q).as_expr()
>>> is_quantifier(r)
False

Definition at line 1829 of file z3py.py.

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

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

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

Definition at line 3554 of file z3py.py.

3555 def Extract(high, low, a):
3556  """Create a Z3 bit-vector extraction expression.
3557 
3558  >>> x = BitVec('x', 8)
3559  >>> Extract(6, 2, x)
3560  Extract(6, 2, x)
3561  >>> Extract(6, 2, x).sort()
3562  BitVec(5)
3563  """
3564  if __debug__:
3565  _z3_assert(low <= high, "First argument must be greater than or equal to second argument")
3566  _z3_assert(isinstance(high, int) and high >= 0 and isinstance(low, int) and low >= 0, "First and second arguments must be non negative integers")
3567  _z3_assert(is_bv(a), "Third argument must be a Z3 Bitvector expression")
3568  return BitVecRef(Z3_mk_extract(a.ctx_ref(), high, low, a.as_ast()), a.ctx)
def is_bv
Definition: z3py.py:3415
def Extract
Definition: z3py.py:3554
Z3_ast Z3_API Z3_mk_extract(Z3_context c, unsigned high, unsigned low, Z3_ast t1)
Extract the bits high down to low from a bitvector of size m to yield a new bitvector of size n...
def z3py.FailIf (   p,
  ctx = None 
)
Return a tactic that fails if the probe `p` evaluates to true. Otherwise, it returns the input goal unmodified.

In the following example, the tactic applies 'simplify' if and only if there are more than 2 constraints in the goal.

>>> t = OrElse(FailIf(Probe('size') > 2), Tactic('simplify'))
>>> x, y = Ints('x y')
>>> g = Goal()
>>> g.add(x > 0)
>>> g.add(y > 0)
>>> t(g)
[[x > 0, y > 0]]
>>> g.add(x == y + 1)
>>> t(g)
[[Not(x <= 0), Not(y <= 0), x == 1 + y]]

Definition at line 7125 of file z3py.py.

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

Definition at line 6389 of file z3py.py.

Referenced by Context.mkFiniteDomainSort(), and Context.MkFiniteDomainSort().

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

Definition at line 7764 of file z3py.py.

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

Definition at line 7734 of file z3py.py.

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

Definition at line 7744 of file z3py.py.

7745 def Float32(ctx=None):
7746  """Floating-point 32-bit (single) sort."""
7747  ctx = _get_ctx(ctx)
7748  return FPSortRef(Z3_mk_fpa_sort_32(ctx.ref()), ctx)
Z3_sort Z3_API Z3_mk_fpa_sort_32(Z3_context c)
Create the single-precision (32-bit) FloatingPoint sort.
def Float32
Definition: z3py.py:7744
FP Sorts.
Definition: z3py.py:7698
def z3py.Float64 (   ctx = None)
Floating-point 64-bit (double) sort.

Definition at line 7754 of file z3py.py.

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

Definition at line 7739 of file z3py.py.

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

Definition at line 7749 of file z3py.py.

7750 def FloatSingle(ctx=None):
7751  """Floating-point 32-bit (single) sort."""
7752  ctx = _get_ctx(ctx)
7753  return FPSortRef(Z3_mk_fpa_sort_single(ctx.ref()), ctx)
def FloatSingle
Definition: z3py.py:7749
Z3_sort Z3_API Z3_mk_fpa_sort_single(Z3_context c)
Create the single-precision (32-bit) FloatingPoint sort.
FP Sorts.
Definition: z3py.py:7698
def z3py.ForAll (   vs,
  body,
  weight = 1,
  qid = "",
  skid = "",
  patterns = [],
  no_patterns = [] 
)
Create a Z3 forall formula.

The parameters `weight`, `qif`, `skid`, `patterns` and `no_patterns` are optional annotations.

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

>>> f = Function('f', IntSort(), IntSort(), IntSort())
>>> x = Int('x')
>>> y = Int('y')
>>> ForAll([x, y], f(x, y) >= x)
ForAll([x, y], f(x, y) >= x)
>>> ForAll([x, y], f(x, y) >= x, patterns=[ f(x, y) ])
ForAll([x, y], f(x, y) >= x)
>>> ForAll([x, y], f(x, y) >= x, weight=10)
ForAll([x, y], f(x, y) >= x)

Definition at line 1810 of file z3py.py.

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

1811 def ForAll(vs, body, weight=1, qid="", skid="", patterns=[], no_patterns=[]):
1812  """Create a Z3 forall formula.
1813 
1814  The parameters `weight`, `qif`, `skid`, `patterns` and `no_patterns` are optional annotations.
1815 
1816  See http://rise4fun.com/Z3Py/tutorial/advanced for more details.
1817 
1818  >>> f = Function('f', IntSort(), IntSort(), IntSort())
1819  >>> x = Int('x')
1820  >>> y = Int('y')
1821  >>> ForAll([x, y], f(x, y) >= x)
1822  ForAll([x, y], f(x, y) >= x)
1823  >>> ForAll([x, y], f(x, y) >= x, patterns=[ f(x, y) ])
1824  ForAll([x, y], f(x, y) >= x)
1825  >>> ForAll([x, y], f(x, y) >= x, weight=10)
1826  ForAll([x, y], f(x, y) >= x)
1827  """
1828  return _mk_quantifier(True, vs, body, weight, qid, skid, patterns, no_patterns)
def ForAll
Definition: z3py.py:1810
def z3py.FP (   name,
  fpsort,
  ctx = None 
)
Return a floating-point constant named `name`. 
`fpsort` is the floating-point sort.
If `ctx=None`, then the global context is used.

>>> x  = FP('x', FPSort(8, 24))
>>> is_fp(x)
True
>>> x.ebits()
8
>>> x.sort()
FPSort(8, 24)
>>> word = FPSort(8, 24)
>>> x2 = FP('x', word)
>>> eq(x, x2)
True

Definition at line 8207 of file z3py.py.

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

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

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

>>> s = FPSort(8, 24)
>>> rm = RNE()
>>> x = FP('x', s)
>>> y = FP('y', s)
>>> fpAdd(rm, x, y)
fpAdd(RNE(), x, y)
>>> fpAdd(rm, x, y).sort()
FPSort(8, 24)

Definition at line 8299 of file z3py.py.

Referenced by FPs().

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

>>> s = FPSort(8, 24)
>>> rm = RNE()
>>> x = FP('x', s)
>>> y = FP('y', s)
>>> fpDiv(rm, x, y)
fpDiv(RNE(), x, y)
>>> fpDiv(rm, x, y).sort()
FPSort(8, 24)

Definition at line 8353 of file z3py.py.

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

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

Definition at line 8568 of file z3py.py.

Referenced by fpNEQ().

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

Definition at line 8421 of file z3py.py.

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

Definition at line 8596 of file z3py.py.

8597 def fpFP(sgn, exp, sig):
8598  """Create the Z3 floating-point value `fpFP(sgn, sig, exp)` from the three bit-vectorssgn, sig, and exp."""
8599  _z3_assert(is_bv(sgn) and is_bv(exp) and is_bv(sig), "sort mismatch")
8600  _z3_assert(sgn.sort().size() == 1, "sort mismatch")
8601  return FPRef(Z3_mk_fpa_fp(sgn.ctx_ref(), sgn.ast, exp.ast, sig.ast), sgn.ctx)
8602 
Z3_ast Z3_API Z3_mk_fpa_fp(Z3_context c, Z3_ast sgn, Z3_ast exp, Z3_ast sig)
Create an expression of FloatingPoint sort from three bit-vector expressions.
FP Expressions.
Definition: z3py.py:7800
def is_bv
Definition: z3py.py:3415
def fpFP
Definition: z3py.py:8596
def z3py.fpGEQ (   a,
  b 
)
Create the Z3 floating-point expression `other <= self`.

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

Definition at line 8553 of file z3py.py.

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

>>> x, y = FPs('x y', FPSort(8, 24))
>>> fpGT(x, y)
x > y
>>> (x > y).sexpr()
'(fp.gt x y)'

Definition at line 8539 of file z3py.py.

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

Definition at line 8160 of file z3py.py.

8161 def fpInfinity(s, negative):
8162  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
8163  _z3_assert(isinstance(negative, bool), "expected Boolean flag")
8164  return FPNumRef(Z3_mk_fpa_inf(s.ctx_ref(), s.ast, negative), s.ctx)
def fpInfinity
Definition: z3py.py:8160
FP Numerals.
Definition: z3py.py:8014
Z3_ast Z3_API Z3_mk_fpa_inf(Z3_context c, Z3_sort s, Z3_bool negative)
Create a floating-point infinity of sort s.
def z3py.fpIsInfinite (   a)
Create a Z3 floating-point isNaN expression.

Definition at line 8467 of file z3py.py.

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

Definition at line 8460 of file z3py.py.

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

Definition at line 8495 of file z3py.py.

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

Definition at line 8481 of file z3py.py.

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

Definition at line 8502 of file z3py.py.

8503 def fpIsPositive(a):
8504  """Create a Z3 floating-point isNaN expression.
8505  """
8506  if __debug__:
8507  _z3_assert(is_fp(a), "Argument must be Z3 floating-point expressions")
8508  return FPRef(Z3_mk_fpa_is_positive(a.ctx_ref(), a.as_ast()), a.ctx)
def is_fp
Definition: z3py.py:8092
def fpIsPositive
Definition: z3py.py:8502
FP Expressions.
Definition: z3py.py:7800
Z3_ast Z3_API Z3_mk_fpa_is_positive(Z3_context c, Z3_ast t)
Predicate indicating whether t is a positive floating-point number.
def z3py.fpIsSubnormal (   a)
Create a Z3 floating-point isNaN expression.

Definition at line 8488 of file z3py.py.

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

Definition at line 8474 of file z3py.py.

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

>>> x, y = FPs('x y', FPSort(8, 24))
>>> fpLEQ(x, y)
x <= y
>>> (x <= y).sexpr()
'(fp.leq x y)'

Definition at line 8526 of file z3py.py.

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

>>> x, y = FPs('x y', FPSort(8, 24))
>>> fpLT(x, y)
x < y
>>> (x <= y).sexpr()
'(fp.leq x y)'

Definition at line 8513 of file z3py.py.

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

>>> s = FPSort(8, 24)
>>> rm = RNE()
>>> x = FP('x', s)
>>> y = FP('y', s)
>>> fpMax(x, y)
fpMax(x, y)
>>> fpMax(x, y).sort()
FPSort(8, 24)

Definition at line 8404 of file z3py.py.

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

>>> s = FPSort(8, 24)
>>> rm = RNE()
>>> x = FP('x', s)
>>> y = FP('y', s)
>>> fpMin(x, y)
fpMin(x, y)
>>> fpMin(x, y).sort()
FPSort(8, 24)

Definition at line 8387 of file z3py.py.

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

Definition at line 8156 of file z3py.py.

8157 def fpMinusInfinity(s):
8158  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
8159  return FPNumRef(Z3_mk_fpa_inf(s.ctx_ref(), s.ast, True), s.ctx)
def fpMinusInfinity
Definition: z3py.py:8156
FP Numerals.
Definition: z3py.py:8014
Z3_ast Z3_API Z3_mk_fpa_inf(Z3_context c, Z3_sort s, Z3_bool negative)
Create a floating-point infinity of sort s.
def z3py.fpMinusZero (   s)

Definition at line 8169 of file z3py.py.

8170 def fpMinusZero(s):
8171  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
8172  return FPNumRef(Z3_mk_fpa_zero(s.ctx_ref(), s.ast, True), s.ctx)
def fpMinusZero
Definition: z3py.py:8169
FP Numerals.
Definition: z3py.py:8014
Z3_ast Z3_API Z3_mk_fpa_zero(Z3_context c, Z3_sort s, Z3_bool negative)
Create a floating-point zero of sort s.
def z3py.fpMul (   rm,
  a,
  b 
)
Create a Z3 floating-point multiplication expression.

>>> s = FPSort(8, 24)
>>> rm = RNE()
>>> x = FP('x', s)
>>> y = FP('y', s)
>>> fpMul(rm, x, y)
fpMul(RNE(), x, y)
>>> fpMul(rm, x, y).sort()
FPSort(8, 24)

Definition at line 8335 of file z3py.py.

Referenced by FPs().

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

Definition at line 8148 of file z3py.py.

8149 def fpNaN(s):
8150  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
8151  return FPNumRef(Z3_mk_fpa_nan(s.ctx_ref(), s.ast), s.ctx)
FP Numerals.
Definition: z3py.py:8014
def fpNaN
Definition: z3py.py:8148
Z3_ast Z3_API Z3_mk_fpa_nan(Z3_context c, Z3_sort s)
Create a floating-point NaN of sort s.
def z3py.fpNeg (   a)
Create a Z3 floating-point addition expression.

>>> s = FPSort(8, 24)
>>> rm = RNE()
>>> x = FP('x', s)
>>> fpNeg(x)
-x
>>> fpNeg(x).sort()
FPSort(8, 24)

Definition at line 8277 of file z3py.py.

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

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

Definition at line 8581 of file z3py.py.

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

Definition at line 8152 of file z3py.py.

8153 def fpPlusInfinity(s):
8154  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
8155  return FPNumRef(Z3_mk_fpa_inf(s.ctx_ref(), s.ast, False), s.ctx)
FP Numerals.
Definition: z3py.py:8014
Z3_ast Z3_API Z3_mk_fpa_inf(Z3_context c, Z3_sort s, Z3_bool negative)
Create a floating-point infinity of sort s.
def fpPlusInfinity
Definition: z3py.py:8152
def z3py.fpPlusZero (   s)

Definition at line 8165 of file z3py.py.

8166 def fpPlusZero(s):
8167  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
8168  return FPNumRef(Z3_mk_fpa_zero(s.ctx_ref(), s.ast, False), s.ctx)
def fpPlusZero
Definition: z3py.py:8165
FP Numerals.
Definition: z3py.py:8014
Z3_ast Z3_API Z3_mk_fpa_zero(Z3_context c, Z3_sort s, Z3_bool negative)
Create a floating-point zero of sort s.
def z3py.fpRem (   a,
  b 
)
Create a Z3 floating-point remainder expression.

>>> s = FPSort(8, 24)
>>> x = FP('x', s)
>>> y = FP('y', s)
>>> fpRem(x, y)
fpRem(x, y)
>>> fpRem(x, y).sort()
FPSort(8, 24)

Definition at line 8371 of file z3py.py.

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

Definition at line 8445 of file z3py.py.

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

>>> x, y, z = FPs('x y z', FPSort(8, 24))
>>> x.sort()
FPSort(8, 24)
>>> x.sbits()
24
>>> x.ebits()
8
>>> fpMul(RNE(), fpAdd(RNE(), x, y), z)
fpMul(RNE(), fpAdd(RNE(), x, y), z)

Definition at line 8230 of file z3py.py.

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

8231 def FPs(names, fpsort, ctx=None):
8232  """Return an array of floating-point constants.
8233 
8234  >>> x, y, z = FPs('x y z', FPSort(8, 24))
8235  >>> x.sort()
8236  FPSort(8, 24)
8237  >>> x.sbits()
8238  24
8239  >>> x.ebits()
8240  8
8241  >>> fpMul(RNE(), fpAdd(RNE(), x, y), z)
8242  fpMul(RNE(), fpAdd(RNE(), x, y), z)
8243  """
8244  ctx = z3._get_ctx(ctx)
8245  if isinstance(names, str):
8246  names = names.split(" ")
8247  return [FP(name, fpsort, ctx) for name in names]
def FP
Definition: z3py.py:8207
def FPs
Definition: z3py.py:8230
def z3py.FPSort (   ebits,
  sbits,
  ctx = None 
)
Return a Z3 floating-point sort of the given sizes. If `ctx=None`, then the global context is used.

>>> Single = FPSort(8, 24)
>>> Double = FPSort(11, 53)
>>> Single
FPSort(8, 24)
>>> x = Const('x', Single)
>>> eq(x, FP('x', FPSort(8, 24)))
True

Definition at line 8119 of file z3py.py.

Referenced by FPRef.__add__(), FPRef.__mul__(), FPRef.__radd__(), FPRef.__rmul__(), FPRef.__rsub__(), FPRef.__sub__(), FPSortRef.cast(), FPSortRef.ebits(), FPRef.ebits(), FPNumRef.exponent(), FPNumRef.exponent_as_long(), FP(), fpAbs(), fpAdd(), fpDiv(), fpEQ(), fpGEQ(), fpGT(), fpLEQ(), fpLT(), fpMax(), fpMin(), fpMul(), fpNeg(), fpNEQ(), fpRem(), FPs(), fpSub(), fpToIEEEBV(), fpToReal(), fpToSBV(), fpToUBV(), FPVal(), is_fp(), is_fp_sort(), is_fp_value(), is_fprm_sort(), FPNumRef.isNegative(), Context.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().

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

Definition at line 8430 of file z3py.py.

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

>>> s = FPSort(8, 24)
>>> rm = RNE()
>>> x = FP('x', s)
>>> y = FP('y', s)
>>> fpSub(rm, x, y)
fpSub(RNE(), x, y)
>>> fpSub(rm, x, y).sort()
FPSort(8, 24)

Definition at line 8317 of file z3py.py.

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

Definition at line 8603 of file z3py.py.

8604 def fpToFP(a1, a2=None, a3=None):
8605  """Create a Z3 floating-point conversion expression from other terms."""
8606  if is_bv(a1) and is_fp_sort(a2):
8607  return FPRef(Z3_mk_fpa_to_fp_bv(a1.ctx_ref(), a1.ast, a2.ast), a1.ctx)
8608  elif is_fprm(a1) and is_fp(a2) and is_fp_sort(a3):
8609  return FPRef(Z3_mk_fpa_to_fp_float(a1.ctx_ref(), a1.ast, a2.ast, a3.ast), a1.ctx)
8610  elif is_fprm(a1) and is_real(a2) and is_fp_sort(a3):
8611  return FPRef(Z3_mk_fpa_to_fp_real(a1.ctx_ref(), a1.ast, a2.ast, a3.ast), a1.ctx)
8612  elif is_fprm(a1) and is_bv(a2) and is_fp_sort(a3):
8613  return FPRef(Z3_mk_fpa_to_fp_signed(a1.ctx_ref(), a1.ast, a2.ast, a3.ast), a1.ctx)
8614  else:
8615  raise Z3Exception("Unsupported combination of arguments for conversion to floating-point term.")
def fpToFP
Definition: z3py.py:8603
def is_fp
Definition: z3py.py:8092
FP Expressions.
Definition: z3py.py:7800
def is_bv
Definition: z3py.py:3415
Z3_ast Z3_API Z3_mk_fpa_to_fp_bv(Z3_context c, Z3_ast bv, Z3_sort s)
Conversion of a single IEEE 754-2008 bit-vector into a floating-point number.
Z3_ast Z3_API Z3_mk_fpa_to_fp_real(Z3_context c, Z3_ast rm, Z3_ast t, Z3_sort s)
Conversion of a term of real sort into a term of FloatingPoint sort.
Z3_ast Z3_API Z3_mk_fpa_to_fp_signed(Z3_context c, Z3_ast rm, Z3_ast t, Z3_sort s)
Conversion of a 2&#39;s complement signed bit-vector term into a term of FloatingPoint sort...
Z3_ast Z3_API Z3_mk_fpa_to_fp_float(Z3_context c, Z3_ast rm, Z3_ast t, Z3_sort s)
Conversion of a FloatingPoint term into another term of different FloatingPoint sort.
def is_fp_sort
Definition: z3py.py:7778
def is_real
Definition: z3py.py:2262
def is_fprm
Definition: z3py.py:7996
def z3py.fpToFPUnsigned (   rm,
  x,
  s 
)
Create a Z3 floating-point conversion expression, from unsigned bit-vector to floating-point expression.

Definition at line 8616 of file z3py.py.

8617 def fpToFPUnsigned(rm, x, s):
8618  """Create a Z3 floating-point conversion expression, from unsigned bit-vector to floating-point expression."""
8619  if __debug__:
8620  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
8621  _z3_assert(is_bv(x), "Second argument must be a Z3 bit-vector expression")
8622  _z3_assert(is_fp_sort(s), "Third argument must be Z3 floating-point sort")
8623  return FPRef(Z3_mk_fpa_to_fp_unsigned(rm.ctx_ref(), rm.ast, x.ast, s.ast), rm.ctx)
FP Expressions.
Definition: z3py.py:7800
def is_bv
Definition: z3py.py:3415
def fpToFPUnsigned
Definition: z3py.py:8616
Z3_ast Z3_API Z3_mk_fpa_to_fp_unsigned(Z3_context c, Z3_ast rm, Z3_ast t, Z3_sort s)
Conversion of a 2&#39;s complement unsigned bit-vector term into a term of FloatingPoint sort...
def is_fp_sort
Definition: z3py.py:7778
def is_fprm
Definition: z3py.py:7996
def z3py.fpToIEEEBV (   x)
\brief Conversion of a floating-point term into a bit-vector term in IEEE 754-2008 format.

The size of the resulting bit-vector is automatically determined. 

Note that IEEE 754-2008 allows multiple different representations of NaN. This conversion 
knows only one NaN and it will always produce the same bit-vector represenatation of 
that NaN.

>>> x = FP('x', FPSort(8, 24))
>>> y = fpToIEEEBV(x)
>>> print is_fp(x)
True
>>> print is_bv(y)
True
>>> print is_fp(y)
False
>>> print is_bv(x)
False

Definition at line 8682 of file z3py.py.

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

>>> x = FP('x', FPSort(8, 24))
>>> y = fpToReal(x)
>>> print is_fp(x)
True
>>> print is_real(y)
True
>>> print is_fp(y)
False
>>> print is_real(x)
False

Definition at line 8664 of file z3py.py.

8665 def fpToReal(x):
8666  """Create a Z3 floating-point conversion expression, from floating-point expression to real.
8667 
8668  >>> x = FP('x', FPSort(8, 24))
8669  >>> y = fpToReal(x)
8670  >>> print is_fp(x)
8671  True
8672  >>> print is_real(y)
8673  True
8674  >>> print is_fp(y)
8675  False
8676  >>> print is_real(x)
8677  False
8678  """
8679  if __debug__:
8680  _z3_assert(is_fp(x), "First argument must be a Z3 floating-point expression")
8681  return ArithRef(Z3_mk_fpa_to_real(x.ctx_ref(), x.ast), x.ctx)
Z3_ast Z3_API Z3_mk_fpa_to_real(Z3_context c, Z3_ast t)
Conversion of a floating-point term into a real-numbered term.
def is_fp
Definition: z3py.py:8092
def fpToReal
Definition: z3py.py:8664
def z3py.fpToSBV (   rm,
  x,
  s 
)
Create a Z3 floating-point conversion expression, from floating-point expression to signed bit-vector.

>>> x = FP('x', FPSort(8, 24))
>>> y = fpToSBV(RTZ(), x, BitVecSort(32))
>>> print is_fp(x)
True
>>> print is_bv(y)
True
>>> print is_fp(y)
False
>>> print is_bv(x)
False

Definition at line 8624 of file z3py.py.

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

>>> x = FP('x', FPSort(8, 24))
>>> y = fpToUBV(RTZ(), x, BitVecSort(32))
>>> print is_fp(x)
True
>>> print is_bv(y)
True
>>> print is_fp(y)
False
>>> print is_bv(x)
False

Definition at line 8644 of file z3py.py.

8645 def fpToUBV(rm, x, s):
8646  """Create a Z3 floating-point conversion expression, from floating-point expression to unsigned bit-vector.
8647 
8648  >>> x = FP('x', FPSort(8, 24))
8649  >>> y = fpToUBV(RTZ(), x, BitVecSort(32))
8650  >>> print is_fp(x)
8651  True
8652  >>> print is_bv(y)
8653  True
8654  >>> print is_fp(y)
8655  False
8656  >>> print is_bv(x)
8657  False
8658  """
8659  if __debug__:
8660  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
8661  _z3_assert(is_fp(x), "Second argument must be a Z3 floating-point expression")
8662  _z3_assert(is_bv_sort(s), "Third argument must be Z3 bit-vector sort")
8663  return BitVecRef(Z3_mk_fpa_to_ubv(rm.ctx_ref(), rm.ast, x.ast, s.size()), rm.ctx)
Z3_ast Z3_API Z3_mk_fpa_to_ubv(Z3_context c, Z3_ast rm, Z3_ast t, unsigned sz)
Conversion of a floating-point term into an unsigned bit-vector.
def is_fp
Definition: z3py.py:8092
def is_bv_sort
Definition: z3py.py:2954
def fpToUBV
Definition: z3py.py:8644
def is_fprm
Definition: z3py.py:7996
def z3py.FPVal (   sig,
  exp = None,
  fps = None,
  ctx = None 
)
Return a floating-point value of value `val` and sort `fps`. If `ctx=None`, then the global context is used.

>>> v = FPVal(20.0, FPSort(8, 24))
>>> v
1.25*(2**4)
>>> print("0x%.8x" % v.exponent_as_long())
0x00000004
>>> v = FPVal(2.25, FPSort(8, 24))
>>> v
1.125*(2**1)
>>> v = FPVal(-2.25, FPSort(8, 24))
>>> v
-1.125*(2**1)

Definition at line 8178 of file z3py.py.

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

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

Definition at line 8173 of file z3py.py.

8174 def fpZero(s, negative):
8175  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
8176  _z3_assert(isinstance(negative, bool), "expected Boolean flag")
8177  return FPNumRef(Z3_mk_fpa_zero(s.ctx_ref(), s.ast, negative), s.ctx)
def fpZero
Definition: z3py.py:8173
FP Numerals.
Definition: z3py.py:8014
Z3_ast Z3_API Z3_mk_fpa_zero(Z3_context c, Z3_sort s, Z3_bool negative)
Create a floating-point zero of sort s.
def z3py.FreshBool (   prefix = 'b',
  ctx = None 
)
Return a fresh Boolean constant in the given context using the given prefix.

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

>>> b1 = FreshBool()
>>> b2 = FreshBool()
>>> eq(b1, b2)
False

Definition at line 1421 of file z3py.py.

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

>>> x = FreshInt()
>>> y = FreshInt()
>>> eq(x, y)
False
>>> x.sort()
Int

Definition at line 2777 of file z3py.py.

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

>>> x = FreshReal()
>>> y = FreshReal()
>>> eq(x, y)
False
>>> x.sort()
Real

Definition at line 2829 of file z3py.py.

2830 def FreshReal(prefix='b', ctx=None):
2831  """Return a fresh real constant in the given context using the given prefix.
2832 
2833  >>> x = FreshReal()
2834  >>> y = FreshReal()
2835  >>> eq(x, y)
2836  False
2837  >>> x.sort()
2838  Real
2839  """
2840  ctx = _get_ctx(ctx)
2841  return ArithRef(Z3_mk_fresh_const(ctx.ref(), prefix, RealSort(ctx).ast), ctx)
def RealSort
Definition: z3py.py:2655
def FreshReal
Definition: z3py.py:2829
Z3_ast Z3_API Z3_mk_fresh_const(Z3_context c, Z3_string prefix, Z3_sort ty)
Declare and create a fresh constant.
def z3py.Function (   name,
  sig 
)
Create a new Z3 uninterpreted function with the given sorts. 

>>> f = Function('f', IntSort(), IntSort())
>>> f(f(0))
f(f(0))

Definition at line 705 of file z3py.py.

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

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

5594 def get_as_array_func(n):
5595  """Return the function declaration f associated with a Z3 expression of the form (_ as-array f)."""
5596  if __debug__:
5597  _z3_assert(is_as_array(n), "as-array Z3 expression expected.")
5598  return FuncDeclRef(Z3_get_as_array_func_decl(n.ctx.ref(), n.as_ast()), n.ctx)
Function Declarations.
Definition: z3py.py:591
Z3_func_decl Z3_API Z3_get_as_array_func_decl(Z3_context c, Z3_ast a)
Return the function declaration f associated with a (_ as_array f) node.
def get_as_array_func
Definition: z3py.py:5593
def is_as_array
Definition: z3py.py:5589
def z3py.get_default_fp_sort (   ctx = None)

Definition at line 7681 of file z3py.py.

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

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

Definition at line 7654 of file z3py.py.

7655 def get_default_rounding_mode(ctx=None):
7656  """Retrieves the global default rounding mode."""
7657  global _dflt_rounding_mode
7658  if _dflt_rounding_mode == Z3_OP_FPA_RM_TOWARD_ZERO:
7659  return RTZ(ctx)
7660  elif _dflt_rounding_mode == Z3_OP_FPA_RM_TOWARD_NEGATIVE:
7661  return RTN(ctx)
7662  elif _dflt_rounding_mode == Z3_OP_FPA_RM_TOWARD_POSITIVE:
7663  return RTP(ctx)
7664  elif _dflt_rounding_mode == Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN:
7665  return RNE(ctx)
7666  elif _dflt_rounding_mode == Z3_OP_FPA_RM_NEAREST_TIES_TO_AWAY:
7667  return RNA(ctx)
def RNE
Definition: z3py.py:7960
def RNA
Definition: z3py.py:7968
def get_default_rounding_mode
Definition: z3py.py:7654
def RTP
Definition: z3py.py:7976
def RTZ
Definition: z3py.py:7992
def RTN
Definition: z3py.py:7984
def z3py.get_map_func (   a)
Return the function declaration associated with a Z3 map array expression.

>>> f = Function('f', IntSort(), IntSort())
>>> b = Array('b', IntSort(), IntSort())
>>> a  = Map(f, b)
>>> eq(f, get_map_func(a))
True
>>> get_map_func(a)
f
>>> get_map_func(a)(0)
f(0)

Definition at line 3987 of file z3py.py.

3988 def get_map_func(a):
3989  """Return the function declaration associated with a Z3 map array expression.
3990 
3991  >>> f = Function('f', IntSort(), IntSort())
3992  >>> b = Array('b', IntSort(), IntSort())
3993  >>> a = Map(f, b)
3994  >>> eq(f, get_map_func(a))
3995  True
3996  >>> get_map_func(a)
3997  f
3998  >>> get_map_func(a)(0)
3999  f(0)
4000  """
4001  if __debug__:
4002  _z3_assert(is_map(a), "Z3 array map expression expected.")
4003  return FuncDeclRef(Z3_to_func_decl(a.ctx_ref(), Z3_get_decl_ast_parameter(a.ctx_ref(), a.decl().ast, 0)), a.ctx)
Function Declarations.
Definition: z3py.py:591
def is_map
Definition: z3py.py:3964
Z3_func_decl Z3_API Z3_to_func_decl(Z3_context c, Z3_ast a)
Convert an AST into a FUNC_DECL_AST. This is just type casting.
def get_map_func
Definition: z3py.py:3987
Z3_ast Z3_API Z3_get_decl_ast_parameter(Z3_context c, Z3_func_decl d, unsigned idx)
Return the expresson value associated with an expression parameter.
def z3py.get_param (   name)
Return the value of a Z3 global (or module) parameter

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

Definition at line 247 of file z3py.py.

248 def get_param(name):
249  """Return the value of a Z3 global (or module) parameter
250 
251  >>> get_param('nlsat.reorder')
252  'true'
253  """
254  ptr = (ctypes.c_char_p * 1)()
255  if Z3_global_param_get(str(name), ptr):
256  r = z3core._to_pystr(ptr[0])
257  return r
258  raise Z3Exception("failed to retrieve value for '%s'" % name)
def get_param
Definition: z3py.py:247
Z3_bool Z3_API Z3_global_param_get(Z3_string param_id, Z3_string_ptr param_value)
Get a global (or module) parameter.
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 def get_var_index(a):
1050  """Return the de-Bruijn index of the Z3 bounded variable `a`.
1051 
1052  >>> x = Int('x')
1053  >>> y = Int('y')
1054  >>> is_var(x)
1055  False
1056  >>> is_const(x)
1057  True
1058  >>> f = Function('f', IntSort(), IntSort(), IntSort())
1059  >>> # Z3 replaces x and y with bound variables when ForAll is executed.
1060  >>> q = ForAll([x, y], f(x, y) == x + y)
1061  >>> q.body()
1062  f(Var(1), Var(0)) == Var(1) + Var(0)
1063  >>> b = q.body()
1064  >>> b.arg(0)
1065  f(Var(1), Var(0))
1066  >>> v1 = b.arg(0).arg(0)
1067  >>> v2 = b.arg(0).arg(1)
1068  >>> v1
1069  Var(1)
1070  >>> v2
1071  Var(0)
1072  >>> get_var_index(v1)
1073  1
1074  >>> get_var_index(v2)
1075  0
1076  """
1077  if __debug__:
1078  _z3_assert(is_var(a), "Z3 bound variable expected")
1079  return int(Z3_get_index_value(a.ctx.ref(), a.as_ast()))
def is_var
Definition: z3py.py:1024
unsigned Z3_API Z3_get_index_value(Z3_context c, Z3_ast a)
Return index of de-Brujin bound variable.
def get_var_index
Definition: z3py.py:1048
def z3py.get_version ( )

Definition at line 72 of file z3py.py.

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

Definition at line 64 of file z3py.py.

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

Definition at line 7202 of file z3py.py.

7203 def help_simplify():
7204  """Return a string describing all options available for Z3 `simplify` procedure."""
7205  print(Z3_simplify_get_help(main_ctx().ref()))
def main_ctx
Definition: z3py.py:188
def help_simplify
Definition: z3py.py:7202
Z3_string Z3_API Z3_simplify_get_help(Z3_context c)
Return a string describing all available parameters.
def z3py.If (   a,
  b,
  c,
  ctx = None 
)
Create a Z3 if-then-else expression. 

>>> x = Int('x')
>>> y = Int('y')
>>> max = If(x > y, x, y)
>>> max
If(x > y, x, y)
>>> simplify(max)
If(x <= y, y, x)

Definition at line 1092 of file z3py.py.

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

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

Definition at line 1434 of file z3py.py.

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

1435 def Implies(a, b, ctx=None):
1436  """Create a Z3 implies expression.
1437 
1438  >>> p, q = Bools('p q')
1439  >>> Implies(p, q)
1440  Implies(p, q)
1441  >>> simplify(Implies(p, q))
1442  Or(Not(p), q)
1443  """
1444  ctx = _get_ctx(_ctx_from_ast_arg_list([a, b], ctx))
1445  s = BoolSort(ctx)
1446  a = s.cast(a)
1447  b = s.cast(b)
1448  return BoolRef(Z3_mk_implies(ctx.ref(), a.as_ast(), b.as_ast()), ctx)
def BoolSort
Definition: z3py.py:1346
def Implies
Definition: z3py.py:1434
Z3_ast Z3_API Z3_mk_implies(Z3_context c, Z3_ast t1, Z3_ast t2)
Create an AST node representing t1 implies t2.
def z3py.Int (   name,
  ctx = None 
)
Return an integer constant named `name`. If `ctx=None`, then the global context is used.

>>> x = Int('x')
>>> is_int(x)
True
>>> is_int(x + 1)
True

Definition at line 2742 of file z3py.py.

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

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

Referenced by binary_interpolant(), and tree_interpolant().

7518 def Interpolant(a,ctx=None):
7519  """Create an interpolation operator.
7520 
7521  The argument is an interpolation pattern (see tree_interpolant).
7522 
7523  >>> x = Int('x')
7524  >>> print Interpolant(x>0)
7525  interp(x > 0)
7526  """
7527  ctx = _get_ctx(_ctx_from_ast_arg_list([a], ctx))
7528  s = BoolSort(ctx)
7529  a = s.cast(a)
7530  return BoolRef(Z3_mk_interpolant(ctx.ref(), a.as_ast()), ctx)
Z3_ast Z3_API Z3_mk_interpolant(Z3_context c, Z3_ast a)
Create an AST node marking a formula position for interpolation.
def BoolSort
Definition: z3py.py:1346
def Interpolant
Definition: z3py.py:7517
def z3py.Ints (   names,
  ctx = None 
)
Return a tuple of Integer constants. 

>>> x, y, z = Ints('x y z')
>>> Sum(x, y, z)
x + y + z

Definition at line 2754 of file z3py.py.

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

2755 def Ints(names, ctx=None):
2756  """Return a tuple of Integer constants.
2757 
2758  >>> x, y, z = Ints('x y z')
2759  >>> Sum(x, y, z)
2760  x + y + z
2761  """
2762  ctx = _get_ctx(ctx)
2763  if isinstance(names, str):
2764  names = names.split(" ")
2765  return [Int(name, ctx) for name in names]
def Ints
Definition: z3py.py:2754
def Int
Definition: z3py.py:2742
def z3py.IntSort (   ctx = None)
Return the interger sort in the given context. If `ctx=None`, then the global context is used.

>>> IntSort()
Int
>>> x = Const('x', IntSort())
>>> is_int(x)
True
>>> x.sort() == IntSort()
True
>>> x.sort() == BoolSort()
False

Definition at line 2639 of file z3py.py.

Referenced by ArrayRef.__getitem__(), ModelRef.__getitem__(), ModelRef.__len__(), DatatypeSortRef.accessor(), FuncEntry.arg_value(), FuncInterp.arity(), Array(), ArraySort(), FuncEntry.as_list(), FuncInterp.as_list(), QuantifierRef.body(), ArithSortRef.cast(), QuantifierRef.children(), DatatypeSortRef.constructor(), Datatype.create(), CreateDatatypes(), Datatype.declare(), ModelRef.decls(), Default(), ArraySortRef.domain(), ArrayRef.domain(), FuncInterp.else_value(), FuncInterp.entry(), Exists(), ForAll(), FreshInt(), ModelRef.get_interp(), get_map_func(), Context.getIntSort(), Int(), is_arith_sort(), is_array(), is_bv_sort(), is_const_array(), is_default(), QuantifierRef.is_forall(), is_fp_sort(), is_K(), is_map(), is_pattern(), is_quantifier(), is_select(), is_store(), K(), Map(), Context.mkIntSort(), Context.MkIntSort(), MultiPattern(), FuncEntry.num_args(), DatatypeSortRef.num_constructors(), FuncInterp.num_entries(), QuantifierRef.num_patterns(), QuantifierRef.num_vars(), QuantifierRef.pattern(), ArraySortRef.range(), ArrayRef.range(), DatatypeSortRef.recognizer(), Select(), ArrayRef.sort(), Store(), Update(), FuncEntry.value(), QuantifierRef.var_name(), QuantifierRef.var_sort(), and QuantifierRef.weight().

2640 def IntSort(ctx=None):
2641  """Return the interger sort in the given context. If `ctx=None`, then the global context is used.
2642 
2643  >>> IntSort()
2644  Int
2645  >>> x = Const('x', IntSort())
2646  >>> is_int(x)
2647  True
2648  >>> x.sort() == IntSort()
2649  True
2650  >>> x.sort() == BoolSort()
2651  False
2652  """
2653  ctx = _get_ctx(ctx)
2654  return ArithSortRef(Z3_mk_int_sort(ctx.ref()), ctx)
def IntSort
Definition: z3py.py:2639
Z3_sort Z3_API Z3_mk_int_sort(Z3_context c)
Create the integer type.
Arithmetic.
Definition: z3py.py:1856
def z3py.IntVal (   val,
  ctx = None 
)
Return a Z3 integer value. If `ctx=None`, then the global context is used.

>>> IntVal(1)
1
>>> IntVal("100")
100

Definition at line 2686 of file z3py.py.

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

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

>>> X = IntVector('x', 3)
>>> X
[x__0, x__1, x__2]
>>> Sum(X)
x__0 + x__1 + x__2

Definition at line 2766 of file z3py.py.

2767 def IntVector(prefix, sz, ctx=None):
2768  """Return a list of integer constants of size `sz`.
2769 
2770  >>> X = IntVector('x', 3)
2771  >>> X
2772  [x__0, x__1, x__2]
2773  >>> Sum(X)
2774  x__0 + x__1 + x__2
2775  """
2776  return [ Int('%s__%s' % (prefix, i)) for i in range(sz) ]
def Int
Definition: z3py.py:2742
def IntVector
Definition: z3py.py:2766
def z3py.is_add (   a)
Return `True` if `a` is an expression of the form b + c.

>>> x, y = Ints('x y')
>>> is_add(x + y)
True
>>> is_add(x - y)
False

Definition at line 2343 of file z3py.py.

2344 def is_add(a):
2345  """Return `True` if `a` is an expression of the form b + c.
2346 
2347  >>> x, y = Ints('x y')
2348  >>> is_add(x + y)
2349  True
2350  >>> is_add(x - y)
2351  False
2352  """
2353  return is_app_of(a, Z3_OP_ADD)
def is_add
Definition: z3py.py:2343
def is_app_of
Definition: z3py.py:1080
def z3py.is_algebraic_value (   a)
Return `True` if `a` is an algerbraic value of sort Real.

>>> is_algebraic_value(RealVal("3/5"))
False
>>> n = simplify(Sqrt(2))
>>> n
1.4142135623?
>>> is_algebraic_value(n)
True

Definition at line 2330 of file z3py.py.

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

>>> p, q = Bools('p q')
>>> is_and(And(p, q))
True
>>> is_and(Or(p, q))
False

Definition at line 1293 of file z3py.py.

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

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

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

>>> x = Int('x')
>>> is_arith(x)
True
>>> is_arith(x + 1)
True
>>> is_arith(1)
False
>>> is_arith(IntVal(1))
True
>>> y = Real('y')
>>> is_arith(y)
True
>>> is_arith(y + 1)
True

Definition at line 2224 of file z3py.py.

Referenced by is_algebraic_value().

2225 def is_arith(a):
2226  """Return `True` if `a` is an arithmetical expression.
2227 
2228  >>> x = Int('x')
2229  >>> is_arith(x)
2230  True
2231  >>> is_arith(x + 1)
2232  True
2233  >>> is_arith(1)
2234  False
2235  >>> is_arith(IntVal(1))
2236  True
2237  >>> y = Real('y')
2238  >>> is_arith(y)
2239  True
2240  >>> is_arith(y + 1)
2241  True
2242  """
2243  return isinstance(a, ArithRef)
def is_arith
Definition: z3py.py:2224
def z3py.is_arith_sort (   s)
Return `True` if s is an arithmetical sort (type).

>>> is_arith_sort(IntSort())
True
>>> is_arith_sort(RealSort())
True
>>> is_arith_sort(BoolSort())
False
>>> n = Int('x') + 1
>>> is_arith_sort(n.sort())
True

Definition at line 1927 of file z3py.py.

1928 def is_arith_sort(s):
1929  """Return `True` if s is an arithmetical sort (type).
1930 
1931  >>> is_arith_sort(IntSort())
1932  True
1933  >>> is_arith_sort(RealSort())
1934  True
1935  >>> is_arith_sort(BoolSort())
1936  False
1937  >>> n = Int('x') + 1
1938  >>> is_arith_sort(n.sort())
1939  True
1940  """
1941  return isinstance(s, ArithSortRef)
def is_arith_sort
Definition: z3py.py:1927
def z3py.is_array (   a)
Return `True` if `a` is a Z3 array expression.

>>> a = Array('a', IntSort(), IntSort())
>>> is_array(a)
True
>>> is_array(Store(a, 0, 1))
True
>>> is_array(a[0])
False

Definition at line 3927 of file z3py.py.

Referenced by Default().

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

Definition at line 5589 of file z3py.py.

Referenced by get_as_array_func().

5590 def is_as_array(n):
5591  """Return true if n is a Z3 expression of the form (_ as-array f)."""
5592  return isinstance(n, ExprRef) and Z3_is_as_array(n.ctx.ref(), n.as_ast())
def is_as_array
Definition: z3py.py:5589
Z3_bool Z3_API Z3_is_as_array(Z3_context c, Z3_ast a)
The (_ as-array f) AST node is a construct for assigning interpretations for arrays in Z3...
def z3py.is_ast (   a)
Return `True` if `a` is an AST node.

>>> is_ast(10)
False
>>> is_ast(IntVal(10))
True
>>> is_ast(Int('x'))
True
>>> is_ast(BoolSort())
True
>>> is_ast(Function('f', IntSort(), IntSort()))
True
>>> is_ast("x")
False
>>> is_ast(Solver())
False

Definition at line 351 of file z3py.py.

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

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)
def is_ast
Definition: z3py.py:351
def z3py.is_bool (   a)
Return `True` if `a` is a Z3 Boolean expression.

>>> p = Bool('p')
>>> is_bool(p)
True
>>> q = Bool('q')
>>> is_bool(And(p, q))
True
>>> x = Real('x')
>>> is_bool(x)
False
>>> is_bool(x == 0)
True

Definition at line 1246 of file z3py.py.

Referenced by BoolSort(), and prove().

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

>>> b = BitVec('b', 32)
>>> is_bv(b)
True
>>> is_bv(b + 10)
True
>>> is_bv(Int('x'))
False

Definition at line 3415 of file z3py.py.

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

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

>>> is_bv_sort(BitVecSort(32))
True
>>> is_bv_sort(IntSort())
False

Definition at line 2954 of file z3py.py.

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

2955 def is_bv_sort(s):
2956  """Return True if `s` is a Z3 bit-vector sort.
2957 
2958  >>> is_bv_sort(BitVecSort(32))
2959  True
2960  >>> is_bv_sort(IntSort())
2961  False
2962  """
2963  return isinstance(s, BitVecSortRef)
def is_bv_sort
Definition: z3py.py:2954
def z3py.is_bv_value (   a)
Return `True` if `a` is a Z3 bit-vector numeral value.

>>> b = BitVec('b', 32)
>>> is_bv_value(b)
False
>>> b = BitVecVal(10, 32)
>>> b
10
>>> is_bv_value(b)
True

Definition at line 3428 of file z3py.py.

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

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

>>> a = K(IntSort(), 10)
>>> is_const_array(a)
True
>>> a = Array('a', IntSort(), IntSort())
>>> is_const_array(a)
False

Definition at line 3940 of file z3py.py.

3941 def is_const_array(a):
3942  """Return `True` if `a` is a Z3 constant array.
3943 
3944  >>> a = K(IntSort(), 10)
3945  >>> is_const_array(a)
3946  True
3947  >>> a = Array('a', IntSort(), IntSort())
3948  >>> is_const_array(a)
3949  False
3950  """
3951  return is_app_of(a, Z3_OP_CONST_ARRAY)
def is_app_of
Definition: z3py.py:1080
def is_const_array
Definition: z3py.py:3940
def z3py.is_default (   a)
Return `True` if `a` is a Z3 default array expression.
>>> d = Default(K(IntSort(), 10))
>>> is_default(d)
True

Definition at line 3979 of file z3py.py.

3980 def is_default(a):
3981  """Return `True` if `a` is a Z3 default array expression.
3982  >>> d = Default(K(IntSort(), 10))
3983  >>> is_default(d)
3984  True
3985  """
3986  return is_app_of(a, Z3_OP_ARRAY_DEFAULT)
def is_app_of
Definition: z3py.py:1080
def is_default
Definition: z3py.py:3979
def z3py.is_distinct (   a)
Return `True` if `a` is a Z3 distinct expression.

>>> x, y, z = Ints('x y z')
>>> is_distinct(x == y)
False
>>> is_distinct(Distinct(x, y, z))
True

Definition at line 1335 of file z3py.py.

1336 def is_distinct(a):
1337  """Return `True` if `a` is a Z3 distinct expression.
1338 
1339  >>> x, y, z = Ints('x y z')
1340  >>> is_distinct(x == y)
1341  False
1342  >>> is_distinct(Distinct(x, y, z))
1343  True
1344  """
1345  return is_app_of(a, Z3_OP_DISTINCT)
def is_distinct
Definition: z3py.py:1335
def is_app_of
Definition: z3py.py:1080
def z3py.is_div (   a)
Return `True` if `a` is an expression of the form b / c.

>>> x, y = Reals('x y')
>>> is_div(x / y)
True
>>> is_div(x + y)
False
>>> x, y = Ints('x y')
>>> is_div(x / y)
False
>>> is_idiv(x / y)
True

Definition at line 2376 of file z3py.py.

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

>>> x, y = Ints('x y')
>>> is_eq(x == y)
True

Definition at line 1326 of file z3py.py.

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

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

>>> p = Bool('p')
>>> is_false(p)
False
>>> is_false(False)
False
>>> is_false(BoolVal(False))
True

Definition at line 1280 of file z3py.py.

Referenced by BoolVal().

1281 def is_false(a):
1282  """Return `True` if `a` is the Z3 false expression.
1283 
1284  >>> p = Bool('p')
1285  >>> is_false(p)
1286  False
1287  >>> is_false(False)
1288  False
1289  >>> is_false(BoolVal(False))
1290  True
1291  """
1292  return is_app_of(a, Z3_OP_FALSE)
def is_false
Definition: z3py.py:1280
def is_app_of
Definition: z3py.py:1080
def z3py.is_fp (   a)
Return `True` if `a` is a Z3 floating-point expression.

>>> b = FP('b', FPSort(8, 24))
>>> is_fp(b)
True
>>> is_fp(b + 1.0)
True
>>> is_fp(Int('x'))
False

Definition at line 8092 of file z3py.py.

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

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

>>> is_fp_sort(FPSort(8, 24))
True
>>> is_fp_sort(IntSort())
False

Definition at line 7778 of file z3py.py.

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

7779 def is_fp_sort(s):
7780  """Return True if `s` is a Z3 floating-point sort.
7781 
7782  >>> is_fp_sort(FPSort(8, 24))
7783  True
7784  >>> is_fp_sort(IntSort())
7785  False
7786  """
7787  return isinstance(s, FPSortRef)
def is_fp_sort
Definition: z3py.py:7778
def z3py.is_fp_value (   a)
Return `True` if `a` is a Z3 floating-point numeral value.

>>> b = FP('b', FPSort(8, 24))
>>> is_fp_value(b)
False
>>> b = FPVal(1.0, FPSort(8, 24))
>>> b
1
>>> is_fp_value(b)
True

Definition at line 8105 of file z3py.py.

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

>>> rm = RNE()
>>> is_fprm(rm)
True
>>> rm = 1.0
>>> is_fprm(rm)
False

Definition at line 7996 of file z3py.py.

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

7997 def is_fprm(a):
7998  """Return `True` if `a` is a Z3 floating-point rounding mode expression.
7999 
8000  >>> rm = RNE()
8001  >>> is_fprm(rm)
8002  True
8003  >>> rm = 1.0
8004  >>> is_fprm(rm)
8005  False
8006  """
8007  return isinstance(a, FPRMRef)
def is_fprm
Definition: z3py.py:7996
def z3py.is_fprm_sort (   s)
Return True if `s` is a Z3 floating-point rounding mode sort.

>>> is_fprm_sort(FPSort(8, 24))
False
>>> is_fprm_sort(RNE().sort())
True

Definition at line 7788 of file z3py.py.

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

Definition at line 8008 of file z3py.py.

8009 def is_fprm_value(a):
8010  """Return `True` if `a` is a Z3 floating-point rounding mode numeral value."""
8011  return is_fprm(a) and _is_numeral(a.ctx, a.ast)
def is_fprm_value
Definition: z3py.py:8008
def is_fprm
Definition: z3py.py:7996
def z3py.is_func_decl (   a)
Return `True` if `a` is a Z3 function declaration.

>>> f = Function('f', IntSort(), IntSort())
>>> is_func_decl(f)
True
>>> x = Real('x')
>>> is_func_decl(x)
False

Definition at line 693 of file z3py.py.

Referenced by prove().

694 def is_func_decl(a):
695  """Return `True` if `a` is a Z3 function declaration.
696 
697  >>> f = Function('f', IntSort(), IntSort())
698  >>> is_func_decl(f)
699  True
700  >>> x = Real('x')
701  >>> is_func_decl(x)
702  False
703  """
704  return isinstance(a, FuncDeclRef)
def is_func_decl
Definition: z3py.py:693
def z3py.is_ge (   a)
Return `True` if `a` is an expression of the form b >= c.

>>> x, y = Ints('x y')
>>> is_ge(x >= y)
True
>>> is_ge(x == y)
False

Definition at line 2436 of file z3py.py.

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

>>> x, y = Ints('x y')
>>> is_gt(x > y)
True
>>> is_gt(x == y)
False

Definition at line 2447 of file z3py.py.

2448 def is_gt(a):
2449  """Return `True` if `a` is an expression of the form b > c.
2450 
2451  >>> x, y = Ints('x y')
2452  >>> is_gt(x > y)
2453  True
2454  >>> is_gt(x == y)
2455  False
2456  """
2457  return is_app_of(a, Z3_OP_GT)
def is_app_of
Definition: z3py.py:1080
def is_gt
Definition: z3py.py:2447
def z3py.is_idiv (   a)
Return `True` if `a` is an expression of the form b div c.

>>> x, y = Ints('x y')
>>> is_idiv(x / y)
True
>>> is_idiv(x + y)
False

Definition at line 2392 of file z3py.py.

Referenced by is_div().

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

>>> x = Int('x')
>>> is_int(x + 1)
True
>>> is_int(1)
False
>>> is_int(IntVal(1))
True
>>> y = Real('y')
>>> is_int(y)
False
>>> is_int(y + 1)
False

Definition at line 2244 of file z3py.py.

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

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

>>> is_int_value(IntVal(1))
True
>>> is_int_value(1)
False
>>> is_int_value(Int('x'))
False
>>> n = Int('x') + 1
>>> n
x + 1
>>> n.arg(1)
1
>>> is_int_value(n.arg(1))
True
>>> is_int_value(RealVal("1/3"))
False
>>> is_int_value(RealVal(1))
False

Definition at line 2286 of file z3py.py.

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

>>> x = Real('x')
>>> is_is_int(IsInt(x))
True
>>> is_is_int(x)
False

Definition at line 2458 of file z3py.py.

2459 def is_is_int(a):
2460  """Return `True` if `a` is an expression of the form IsInt(b).
2461 
2462  >>> x = Real('x')
2463  >>> is_is_int(IsInt(x))
2464  True
2465  >>> is_is_int(x)
2466  False
2467  """
2468  return is_app_of(a, Z3_OP_IS_INT)
def is_is_int
Definition: z3py.py:2458
def is_app_of
Definition: z3py.py:1080
def z3py.is_K (   a)
Return `True` if `a` is a Z3 constant array.

>>> a = K(IntSort(), 10)
>>> is_K(a)
True
>>> a = Array('a', IntSort(), IntSort())
>>> is_K(a)
False

Definition at line 3952 of file z3py.py.

3953 def is_K(a):
3954  """Return `True` if `a` is a Z3 constant array.
3955 
3956  >>> a = K(IntSort(), 10)
3957  >>> is_K(a)
3958  True
3959  >>> a = Array('a', IntSort(), IntSort())
3960  >>> is_K(a)
3961  False
3962  """
3963  return is_app_of(a, Z3_OP_CONST_ARRAY)
def is_app_of
Definition: z3py.py:1080
def is_K
Definition: z3py.py:3952
def z3py.is_le (   a)
Return `True` if `a` is an expression of the form b <= c.

>>> x, y = Ints('x y')
>>> is_le(x <= y)
True
>>> is_le(x < y)
False

Definition at line 2414 of file z3py.py.

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

>>> x, y = Ints('x y')
>>> is_lt(x < y)
True
>>> is_lt(x == y)
False

Definition at line 2425 of file z3py.py.

2426 def is_lt(a):
2427  """Return `True` if `a` is an expression of the form b < c.
2428 
2429  >>> x, y = Ints('x y')
2430  >>> is_lt(x < y)
2431  True
2432  >>> is_lt(x == y)
2433  False
2434  """
2435  return is_app_of(a, Z3_OP_LT)
def is_lt
Definition: z3py.py:2425
def is_app_of
Definition: z3py.py:1080
def z3py.is_map (   a)
Return `True` if `a` is a Z3 map array expression. 

>>> f = Function('f', IntSort(), IntSort())
>>> b = Array('b', IntSort(), IntSort())
>>> a  = Map(f, b)
>>> a
Map(f, b)
>>> is_map(a)
True
>>> is_map(b)
False

Definition at line 3964 of file z3py.py.

Referenced by get_map_func().

3965 def is_map(a):
3966  """Return `True` if `a` is a Z3 map array expression.
3967 
3968  >>> f = Function('f', IntSort(), IntSort())
3969  >>> b = Array('b', IntSort(), IntSort())
3970  >>> a = Map(f, b)
3971  >>> a
3972  Map(f, b)
3973  >>> is_map(a)
3974  True
3975  >>> is_map(b)
3976  False
3977  """
3978  return is_app_of(a, Z3_OP_ARRAY_MAP)
def is_map
Definition: z3py.py:3964
def is_app_of
Definition: z3py.py:1080
def z3py.is_mod (   a)
Return `True` if `a` is an expression of the form b % c.

>>> x, y = Ints('x y')
>>> is_mod(x % y)
True
>>> is_mod(x + y)
False

Definition at line 2403 of file z3py.py.

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

>>> x, y = Ints('x y')
>>> is_mul(x * y)
True
>>> is_mul(x - y)
False

Definition at line 2354 of file z3py.py.

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

>>> p = Bool('p')
>>> is_not(p)
False
>>> is_not(Not(p))
True

Definition at line 1315 of file z3py.py.

1316 def is_not(a):
1317  """Return `True` if `a` is a Z3 not expression.
1318 
1319  >>> p = Bool('p')
1320  >>> is_not(p)
1321  False
1322  >>> is_not(Not(p))
1323  True
1324  """
1325  return is_app_of(a, Z3_OP_NOT)
def is_not
Definition: z3py.py:1315
def is_app_of
Definition: z3py.py:1080
def z3py.is_or (   a)
Return `True` if `a` is a Z3 or expression.

>>> p, q = Bools('p q')
>>> is_or(Or(p, q))
True
>>> is_or(And(p, q))
False

Definition at line 1304 of file z3py.py.

1305 def is_or(a):
1306  """Return `True` if `a` is a Z3 or expression.
1307 
1308  >>> p, q = Bools('p q')
1309  >>> is_or(Or(p, q))
1310  True
1311  >>> is_or(And(p, q))
1312  False
1313  """
1314  return is_app_of(a, Z3_OP_OR)
def is_app_of
Definition: z3py.py:1080
def is_or
Definition: z3py.py:1304
def z3py.is_pattern (   a)
Return `True` if `a` is a Z3 pattern (hint for quantifier instantiation.

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

>>> f = Function('f', IntSort(), IntSort())
>>> x = Int('x')
>>> q = ForAll(x, f(x) == 0, patterns = [ f(x) ])
>>> q
ForAll(x, f(x) == 0)
>>> q.num_patterns()
1
>>> is_pattern(q.pattern(0))
True
>>> q.pattern(0)
f(Var(0))

Definition at line 1566 of file z3py.py.

Referenced by MultiPattern().

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

>>> is_probe(Int('x'))
False
>>> is_probe(Probe('memory'))
True

Definition at line 7058 of file z3py.py.

Referenced by eq().

7059 def is_probe(p):
7060  """Return `True` if `p` is a Z3 probe.
7061 
7062  >>> is_probe(Int('x'))
7063  False
7064  >>> is_probe(Probe('memory'))
7065  True
7066  """
7067  return isinstance(p, Probe)
def is_probe
Definition: z3py.py:7058
def z3py.is_quantifier (   a)
Return `True` if `a` is a Z3 quantifier.

>>> f = Function('f', IntSort(), IntSort())
>>> x = Int('x')
>>> q = ForAll(x, f(x) == 0)
>>> is_quantifier(q)
True
>>> is_quantifier(f(x))
False

Definition at line 1769 of file z3py.py.

Referenced by Exists().

1770 def is_quantifier(a):
1771  """Return `True` if `a` is a Z3 quantifier.
1772 
1773  >>> f = Function('f', IntSort(), IntSort())
1774  >>> x = Int('x')
1775  >>> q = ForAll(x, f(x) == 0)
1776  >>> is_quantifier(q)
1777  True
1778  >>> is_quantifier(f(x))
1779  False
1780  """
1781  return isinstance(a, QuantifierRef)
def is_quantifier
Definition: z3py.py:1769
def z3py.is_rational_value (   a)
Return `True` if `a` is rational value of sort Real.

>>> is_rational_value(RealVal(1))
True
>>> is_rational_value(RealVal("3/5"))
True
>>> is_rational_value(IntVal(1))
False
>>> is_rational_value(1)
False
>>> n = Real('x') + 1
>>> n.arg(1)
1
>>> is_rational_value(n.arg(1))
True
>>> is_rational_value(Real('x'))
False

Definition at line 2309 of file z3py.py.

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

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

>>> x = Int('x')
>>> is_real(x + 1)
False
>>> y = Real('y')
>>> is_real(y)
True
>>> is_real(y + 1)
True
>>> is_real(1)
False
>>> is_real(RealVal(1))
True

Definition at line 2262 of file z3py.py.

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

2263 def is_real(a):
2264  """Return `True` if `a` is a real expression.
2265 
2266  >>> x = Int('x')
2267  >>> is_real(x + 1)
2268  False
2269  >>> y = Real('y')
2270  >>> is_real(y)
2271  True
2272  >>> is_real(y + 1)
2273  True
2274  >>> is_real(1)
2275  False
2276  >>> is_real(RealVal(1))
2277  True
2278  """
2279  return is_arith(a) and a.is_real()
def is_arith
Definition: z3py.py:2224
def is_real
Definition: z3py.py:2262
def z3py.is_select (   a)
Return `True` if `a` is a Z3 array select application.

>>> a = Array('a', IntSort(), IntSort())
>>> is_select(a)
False
>>> i = Int('i')
>>> is_select(a[i])
True

Definition at line 4143 of file z3py.py.

4144 def is_select(a):
4145  """Return `True` if `a` is a Z3 array select application.
4146 
4147  >>> a = Array('a', IntSort(), IntSort())
4148  >>> is_select(a)
4149  False
4150  >>> i = Int('i')
4151  >>> is_select(a[i])
4152  True
4153  """
4154  return is_app_of(a, Z3_OP_SELECT)
def is_select
Definition: z3py.py:4143
def is_app_of
Definition: z3py.py:1080
def z3py.is_sort (   s)
Return `True` if `s` is a Z3 sort.

>>> is_sort(IntSort())
True
>>> is_sort(Int('x'))
False
>>> is_expr(Int('x'))
True

Definition at line 530 of file z3py.py.

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

531 def is_sort(s):
532  """Return `True` if `s` is a Z3 sort.
533 
534  >>> is_sort(IntSort())
535  True
536  >>> is_sort(Int('x'))
537  False
538  >>> is_expr(Int('x'))
539  True
540  """
541  return isinstance(s, SortRef)
def is_sort
Definition: z3py.py:530
def z3py.is_store (   a)
Return `True` if `a` is a Z3 array store application.

>>> a = Array('a', IntSort(), IntSort())
>>> is_store(a)
False
>>> is_store(Store(a, 0, 1))
True

Definition at line 4155 of file z3py.py.

4156 def is_store(a):
4157  """Return `True` if `a` is a Z3 array store application.
4158 
4159  >>> a = Array('a', IntSort(), IntSort())
4160  >>> is_store(a)
4161  False
4162  >>> is_store(Store(a, 0, 1))
4163  True
4164  """
4165  return is_app_of(a, Z3_OP_STORE)
def is_store
Definition: z3py.py:4155
def is_app_of
Definition: z3py.py:1080
def z3py.is_sub (   a)
Return `True` if `a` is an expression of the form b - c.

>>> x, y = Ints('x y')
>>> is_sub(x - y)
True
>>> is_sub(x + y)
False

Definition at line 2365 of file z3py.py.

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

>>> x = Real('x')
>>> n = ToInt(x)
>>> n
ToInt(x)
>>> is_to_int(n)
True
>>> is_to_int(x)
False

Definition at line 2483 of file z3py.py.

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

>>> x = Int('x')
>>> n = ToReal(x)
>>> n
ToReal(x)
>>> is_to_real(n)
True
>>> is_to_real(x)
False

Definition at line 2469 of file z3py.py.

2470 def is_to_real(a):
2471  """Return `True` if `a` is an expression of the form ToReal(b).
2472 
2473  >>> x = Int('x')
2474  >>> n = ToReal(x)
2475  >>> n
2476  ToReal(x)
2477  >>> is_to_real(n)
2478  True
2479  >>> is_to_real(x)
2480  False
2481  """
2482  return is_app_of(a, Z3_OP_TO_REAL)
def is_app_of
Definition: z3py.py:1080
def is_to_real
Definition: z3py.py:2469
def z3py.is_true (   a)
Return `True` if `a` is the Z3 true expression.

>>> p = Bool('p')
>>> is_true(p)
False
>>> is_true(simplify(p == p))
True
>>> x = Real('x')
>>> is_true(x == 0)
False
>>> # True is a Python Boolean expression
>>> is_true(True)
False

Definition at line 1263 of file z3py.py.

Referenced by BoolVal().

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

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

>>> x = Real('x')
>>> IsInt(x + "1/2")
IsInt(x + 1/2)
>>> solve(IsInt(x + "1/2"), x > 0, x < 1)
[x = 1/2]
>>> solve(IsInt(x + "1/2"), x > 0, x < 1, x != "1/2")
no solution

Definition at line 2876 of file z3py.py.

Referenced by is_is_int().

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

>>> a = K(IntSort(), 10)
>>> a
K(Int, 10)
>>> a.sort()
Array(Int, Int)
>>> i = Int('i')
>>> a[i]
K(Int, 10)[i]
>>> simplify(a[i])
10

Definition at line 4122 of file z3py.py.

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

4123 def K(dom, v):
4124  """Return a Z3 constant array expression.
4125 
4126  >>> a = K(IntSort(), 10)
4127  >>> a
4128  K(Int, 10)
4129  >>> a.sort()
4130  Array(Int, Int)
4131  >>> i = Int('i')
4132  >>> a[i]
4133  K(Int, 10)[i]
4134  >>> simplify(a[i])
4135  10
4136  """
4137  if __debug__:
4138  _z3_assert(is_sort(dom), "Z3 sort expected")
4139  ctx = dom.ctx
4140  if not is_expr(v):
4141  v = _py2expr(v, ctx)
4142  return ArrayRef(Z3_mk_const_array(ctx.ref(), dom.ast, v.as_ast()), ctx)
Z3_ast Z3_API Z3_mk_const_array(Z3_context c, Z3_sort domain, Z3_ast v)
Create the constant array.
def K
Definition: z3py.py:4122
def is_expr
Definition: z3py.py:961
def is_sort
Definition: z3py.py:530
def z3py.LShR (   a,
  b 
)
Create the Z3 expression logical right shift.

Use the operator >> for the arithmetical right shift.

>>> x, y = BitVecs('x y', 32)
>>> LShR(x, y)
LShR(x, y)
>>> (x >> y).sexpr()
'(bvashr x y)'
>>> LShR(x, y).sexpr()
'(bvlshr x y)'
>>> BitVecVal(4, 3)
4
>>> BitVecVal(4, 3).as_signed_long()
-4
>>> simplify(BitVecVal(4, 3) >> 1).as_signed_long()
-2
>>> simplify(BitVecVal(4, 3) >> 1)
6
>>> simplify(LShR(BitVecVal(4, 3), 1))
2
>>> simplify(BitVecVal(2, 3) >> 1)
1
>>> simplify(LShR(BitVecVal(2, 3), 1))
1

Definition at line 3701 of file z3py.py.

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

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

189 def main_ctx():
190  """Return a reference to the global Z3 context.
191 
192  >>> x = Real('x')
193  >>> x.ctx == main_ctx()
194  True
195  >>> c = Context()
196  >>> c == main_ctx()
197  False
198  >>> x2 = Real('x', c)
199  >>> x2.ctx == c
200  True
201  >>> eq(x, x2)
202  False
203  """
204  global _main_ctx
205  if _main_ctx == None:
206  _main_ctx = Context()
207  return _main_ctx
def main_ctx
Definition: z3py.py:188
def z3py.Map (   f,
  args 
)
Return a Z3 map array expression. 

>>> f = Function('f', IntSort(), IntSort(), IntSort())
>>> a1 = Array('a1', IntSort(), IntSort())
>>> a2 = Array('a2', IntSort(), IntSort())
>>> b  = Map(f, a1, a2)
>>> b
Map(f, a1, a2)
>>> prove(b[0] == f(a1[0], a2[0]))
proved

Definition at line 4100 of file z3py.py.

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

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

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

>>> f = Function('f', IntSort(), IntSort())
>>> g = Function('g', IntSort(), IntSort())
>>> x = Int('x')
>>> q = ForAll(x, f(x) != g(x), patterns = [ MultiPattern(f(x), g(x)) ])
>>> q
ForAll(x, f(x) != g(x))
>>> q.num_patterns()
1
>>> is_pattern(q.pattern(0))
True
>>> q.pattern(0)
MultiPattern(f(Var(0)), g(Var(0)))

Definition at line 1585 of file z3py.py.

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

>>> p = Bool('p')
>>> Not(Not(p))
Not(Not(p))
>>> simplify(Not(Not(p)))
p

Definition at line 1464 of file z3py.py.

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

1465 def Not(a, ctx=None):
1466  """Create a Z3 not expression or probe.
1467 
1468  >>> p = Bool('p')
1469  >>> Not(Not(p))
1470  Not(Not(p))
1471  >>> simplify(Not(Not(p)))
1472  p
1473  """
1474  ctx = _get_ctx(_ctx_from_ast_arg_list([a], ctx))
1475  if is_probe(a):
1476  # Not is also used to build probes
1477  return Probe(Z3_probe_not(ctx.ref(), a.probe), ctx)
1478  else:
1479  s = BoolSort(ctx)
1480  a = s.cast(a)
1481  return BoolRef(Z3_mk_not(ctx.ref(), a.as_ast()), ctx)
def Not
Definition: z3py.py:1464
def BoolSort
Definition: z3py.py:1346
def is_probe
Definition: z3py.py:7058
Z3_probe Z3_API Z3_probe_not(Z3_context x, Z3_probe p)
Return a probe that evaluates to &quot;true&quot; when p does not evaluate to true.
Z3_ast Z3_API Z3_mk_not(Z3_context c, Z3_ast a)
Create an AST node representing not(a).
def 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 
87 def open_log(fname):
88  """Log interaction to a file. This function must be invoked immediately after init(). """
89  Z3_open_log(fname)
Z3_bool Z3_API Z3_open_log(Z3_string filename)
Log interaction to a file.
def open_log
Definition: z3py.py:86
def z3py.Or (   args)
Create a Z3 or-expression or or-probe. 

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

Definition at line 1519 of file z3py.py.

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

1520 def Or(*args):
1521  """Create a Z3 or-expression or or-probe.
1522 
1523  >>> p, q, r = Bools('p q r')
1524  >>> Or(p, q, r)
1525  Or(p, q, r)
1526  >>> P = BoolVector('p', 5)
1527  >>> Or(P)
1528  Or(p__0, p__1, p__2, p__3, p__4)
1529  """
1530  last_arg = None
1531  if len(args) > 0:
1532  last_arg = args[len(args)-1]
1533  if isinstance(last_arg, Context):
1534  ctx = args[len(args)-1]
1535  args = args[:len(args)-1]
1536  else:
1537  ctx = main_ctx()
1538  args = _get_args(args)
1539  ctx_args = _ctx_from_ast_arg_list(args, ctx)
1540  if __debug__:
1541  _z3_assert(ctx_args == None or ctx_args == ctx, "context mismatch")
1542  _z3_assert(ctx != None, "At least one of the arguments must be a Z3 expression or probe")
1543  if _has_probe(args):
1544  return _probe_or(args, ctx)
1545  else:
1546  args = _coerce_expr_list(args, ctx)
1547  _args, sz = _to_ast_array(args)
1548  return BoolRef(Z3_mk_or(ctx.ref(), sz, _args), ctx)
Z3_ast Z3_API Z3_mk_or(Z3_context c, unsigned num_args, Z3_ast const args[])
Create an AST node representing args[0] or ... or args[num_args-1].The array args must have num_args ...
def main_ctx
Definition: z3py.py:188
def Or
Definition: z3py.py:1519
def z3py.OrElse (   ts,
  ks 
)
Return a tactic that applies the tactics in `*ts` until one of them succeeds (it doesn't fail).

>>> x = Int('x')
>>> t = OrElse(Tactic('split-clause'), Tactic('skip'))
>>> # Tactic split-clause fails if there is no clause in the given goal.
>>> t(x == 0)
[[x == 0]]
>>> t(Or(x == 0, x == 1))
[[x == 0], [x == 1]]

Definition at line 6790 of file z3py.py.

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

Definition at line 6842 of file z3py.py.

6843 def ParAndThen(t1, t2, ctx=None):
6844  """Alias for ParThen(t1, t2, ctx)."""
6845  return ParThen(t1, t2, ctx)
def ParThen
Definition: z3py.py:6828
def ParAndThen
Definition: z3py.py:6842
def z3py.ParOr (   ts,
  ks 
)
Return a tactic that applies the tactics in `*ts` in parallel until one of them succeeds (it doesn't fail).

>>> x = Int('x')
>>> t = ParOr(Tactic('simplify'), Tactic('fail'))
>>> t(x + 1 == 2)
[[x == 1]]

Definition at line 6810 of file z3py.py.

6811 def ParOr(*ts, **ks):
6812  """Return a tactic that applies the tactics in `*ts` in parallel until one of them succeeds (it doesn't fail).
6813 
6814  >>> x = Int('x')
6815  >>> t = ParOr(Tactic('simplify'), Tactic('fail'))
6816  >>> t(x + 1 == 2)
6817  [[x == 1]]
6818  """
6819  if __debug__:
6820  _z3_assert(len(ts) >= 2, "At least two arguments expected")
6821  ctx = _get_ctx(ks.get('ctx', None))
6822  ts = [ _to_tactic(t, ctx) for t in ts ]
6823  sz = len(ts)
6824  _args = (TacticObj * sz)()
6825  for i in range(sz):
6826  _args[i] = ts[i].tactic
6827  return Tactic(Z3_tactic_par_or(ctx.ref(), sz, _args), ctx)
def ParOr
Definition: z3py.py:6810
Z3_tactic Z3_API Z3_tactic_par_or(Z3_context c, unsigned num, Z3_tactic const ts[])
Return a tactic that applies the given tactics in parallel.
def z3py.parse_smt2_file (   f,
  sorts = {},
  decls = {},
  ctx = None 
)
Parse a file in SMT 2.0 format using the given sorts and decls.

This function is similar to parse_smt2_string().

Definition at line 7507 of file z3py.py.

7508 def parse_smt2_file(f, sorts={}, decls={}, ctx=None):
7509  """Parse a file in SMT 2.0 format using the given sorts and decls.
7510 
7511  This function is similar to parse_smt2_string().
7512  """
7513  ctx = _get_ctx(ctx)
7514  ssz, snames, ssorts = _dict2sarray(sorts, ctx)
7515  dsz, dnames, ddecls = _dict2darray(decls, ctx)
7516  return _to_expr_ref(Z3_parse_smtlib2_file(ctx.ref(), f, ssz, snames, ssorts, dsz, dnames, ddecls), ctx)
Z3_ast Z3_API Z3_parse_smtlib2_file(Z3_context c, Z3_string file_name, unsigned num_sorts, Z3_symbol const sort_names[], Z3_sort const sorts[], unsigned num_decls, Z3_symbol const decl_names[], Z3_func_decl const decls[])
Similar to Z3_parse_smtlib2_string, but reads the benchmark from a file.
def parse_smt2_file
Definition: z3py.py:7507
def z3py.parse_smt2_string (   s,
  sorts = {},
  decls = {},
  ctx = None 
)
Parse a string in SMT 2.0 format using the given sorts and decls.

The arguments sorts and decls are Python dictionaries used to initialize
the symbol table used for the SMT 2.0 parser.

>>> parse_smt2_string('(declare-const x Int) (assert (> x 0)) (assert (< x 10))')
And(x > 0, x < 10)
>>> x, y = Ints('x y')
>>> f = Function('f', IntSort(), IntSort())
>>> parse_smt2_string('(assert (> (+ foo (g bar)) 0))', decls={ 'foo' : x, 'bar' : y, 'g' : f})
x + f(y) > 0
>>> parse_smt2_string('(declare-const a U) (assert (> a 0))', sorts={ 'U' : IntSort() })
a > 0

Definition at line 7487 of file z3py.py.

Referenced by parse_smt2_file().

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

>>> x, y = Ints('x y')
>>> t = ParThen(Tactic('split-clause'), Tactic('propagate-values'))
>>> t(And(Or(x == 1, x == 2), y == x + 1))
[[x == 1, y == 2], [x == 2, y == 3]]

Definition at line 6828 of file z3py.py.

Referenced by ParAndThen().

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

>>> d = probe_description('memory')

Definition at line 7084 of file z3py.py.

Referenced by describe_probes().

7085 def probe_description(name, ctx=None):
7086  """Return a short description for the probe named `name`.
7087 
7088  >>> d = probe_description('memory')
7089  """
7090  ctx = _get_ctx(ctx)
7091  return Z3_probe_get_descr(ctx.ref(), name)
def probe_description
Definition: z3py.py:7084
Z3_string Z3_API Z3_probe_get_descr(Z3_context c, Z3_string name)
Return a string containing a description of the probe with the given name.
def z3py.probes (   ctx = None)
Return a list of all available probes in Z3.

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

Definition at line 7074 of file z3py.py.

Referenced by describe_probes().

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

>>> a, b, c = Ints('a b c')
>>> Product(a, b, c)
a*b*c
>>> Product([a, b, c])
a*b*c
>>> A = IntVector('a', 5)
>>> Product(A)
a__0*a__1*a__2*a__3*a__4

Definition at line 7281 of file z3py.py.

Referenced by BitVecs().

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

This is a simple function for creating demonstrations.  It tries to prove
`claim` by showing the negation is unsatisfiable.

>>> p, q = Bools('p q')
>>> prove(Not(And(p, q)) == Or(Not(p), Not(q)))
proved

Definition at line 7363 of file z3py.py.

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

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

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

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

Definition at line 2730 of file z3py.py.

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

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

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

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

Definition at line 2715 of file z3py.py.

Referenced by Q().

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

>>> x = Real('x')
>>> is_real(x)
True
>>> is_real(x + 1)
True

Definition at line 2790 of file z3py.py.

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

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

Referenced by is_div().

2803 def Reals(names, ctx=None):
2804  """Return a tuple of real constants.
2805 
2806  >>> x, y, z = Reals('x y z')
2807  >>> Sum(x, y, z)
2808  x + y + z
2809  >>> Sum(x, y, z).sort()
2810  Real
2811  """
2812  ctx = _get_ctx(ctx)
2813  if isinstance(names, str):
2814  names = names.split(" ")
2815  return [Real(name, ctx) for name in names]
def Real
Definition: z3py.py:2790
def Reals
Definition: z3py.py:2802
def z3py.RealSort (   ctx = None)
Return the real sort in the given context. If `ctx=None`, then the global context is used.

>>> RealSort()
Real
>>> x = Const('x', RealSort())
>>> is_real(x)
True
>>> is_int(x)
False
>>> x.sort() == RealSort()
True

Definition at line 2655 of file z3py.py.

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

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

`val` may be a Python int, long, float or string representing a number in decimal or rational notation.
If `ctx=None`, then the global context is used.

>>> RealVal(1)
1
>>> RealVal(1).sort()
Real
>>> RealVal("3/5")
3/5
>>> RealVal("1.5")
3/2

Definition at line 2697 of file z3py.py.

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

2698 def RealVal(val, ctx=None):
2699  """Return a Z3 real value.
2700 
2701  `val` may be a Python int, long, float or string representing a number in decimal or rational notation.
2702  If `ctx=None`, then the global context is used.
2703 
2704  >>> RealVal(1)
2705  1
2706  >>> RealVal(1).sort()
2707  Real
2708  >>> RealVal("3/5")
2709  3/5
2710  >>> RealVal("1.5")
2711  3/2
2712  """
2713  ctx = _get_ctx(ctx)
2714  return RatNumRef(Z3_mk_numeral(ctx.ref(), str(val), RealSort(ctx).ast), ctx)
def RealSort
Definition: z3py.py:2655
def RealVal
Definition: z3py.py:2697
Z3_ast Z3_API Z3_mk_numeral(Z3_context c, Z3_string numeral, Z3_sort ty)
Create a numeral of a given sort.
def z3py.RealVar (   idx,
  ctx = None 
)
Create a real free variable. Free variables are used to create quantified formulas.
They are also used to create polynomials.

>>> RealVar(0)
Var(0)

Definition at line 1182 of file z3py.py.

Referenced by RealVarVector().

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

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

2817 def RealVector(prefix, sz, ctx=None):
2818  """Return a list of real constants of size `sz`.
2819 
2820  >>> X = RealVector('x', 3)
2821  >>> X
2822  [x__0, x__1, x__2]
2823  >>> Sum(X)
2824  x__0 + x__1 + x__2
2825  >>> Sum(X).sort()
2826  Real
2827  """
2828  return [ Real('%s__%s' % (prefix, i)) for i in range(sz) ]
def Real
Definition: z3py.py:2790
def RealVector
Definition: z3py.py:2816
def z3py.Repeat (   t,
  max = 4294967295,
  ctx = None 
)
Return a tactic that keeps applying `t` until the goal is not modified anymore or the maximum number of iterations `max` is reached.

>>> x, y = Ints('x y')
>>> c = And(Or(x == 0, x == 1), Or(y == 0, y == 1), x > y)
>>> t = Repeat(OrElse(Tactic('split-clause'), Tactic('skip')))
>>> r = t(c)
>>> for subgoal in r: print(subgoal)
[x == 0, y == 0, x > y]
[x == 0, y == 1, x > y]
[x == 1, y == 0, x > y]
[x == 1, y == 1, x > y]
>>> t = Then(t, Tactic('propagate-values'))
>>> t(c)
[[x == 1, y == 0]]

Definition at line 6859 of file z3py.py.

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

>>> x = BitVec('x', 8)
>>> n = RepeatBitVec(4, x)
>>> n
RepeatBitVec(4, x)
>>> n.size()
32
>>> v0 = BitVecVal(10, 4)
>>> print("%.x" % v0.as_long())
a
>>> v = simplify(RepeatBitVec(4, v0))
>>> v.size()
16
>>> print("%.x" % v.as_long())
aaaa

Definition at line 3818 of file z3py.py.

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

Definition at line 237 of file z3py.py.

238 def reset_params():
239  """Reset all global (or module) parameters.
240  """
def reset_params
Definition: z3py.py:237
void Z3_API Z3_global_param_reset_all(void)
Restore the value of all global (and module) parameters. This command will not affect already created...
def z3py.RNA (   ctx = None)

Definition at line 7968 of file z3py.py.

Referenced by get_default_rounding_mode().

7969 def RNA (ctx=None):
7970  ctx = _get_ctx(ctx)
7971  return FPRMRef(Z3_mk_fpa_round_nearest_ties_to_away(ctx.ref()), ctx)
def RNA
Definition: z3py.py:7968
Z3_ast Z3_API Z3_mk_fpa_round_nearest_ties_to_away(Z3_context c)
Create a numeral of RoundingMode sort which represents the NearestTiesToAway rounding mode...
def z3py.RNE (   ctx = None)

Definition at line 7960 of file z3py.py.

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

7961 def RNE (ctx=None):
7962  ctx = _get_ctx(ctx)
7963  return FPRMRef(Z3_mk_fpa_round_nearest_ties_to_even(ctx.ref()), ctx)
def RNE
Definition: z3py.py:7960
Z3_ast Z3_API Z3_mk_fpa_round_nearest_ties_to_even(Z3_context c)
Create a numeral of RoundingMode sort which represents the NearestTiesToEven rounding mode...
def z3py.RotateLeft (   a,
  b 
)
Return an expression representing `a` rotated to the left `b` times.

>>> a, b = BitVecs('a b', 16)
>>> RotateLeft(a, b)
RotateLeft(a, b)
>>> simplify(RotateLeft(a, 0))
a
>>> simplify(RotateLeft(a, 16))
a

Definition at line 3732 of file z3py.py.

3733 def RotateLeft(a, b):
3734  """Return an expression representing `a` rotated to the left `b` times.
3735 
3736  >>> a, b = BitVecs('a b', 16)
3737  >>> RotateLeft(a, b)
3738  RotateLeft(a, b)
3739  >>> simplify(RotateLeft(a, 0))
3740  a
3741  >>> simplify(RotateLeft(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_left(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
def RotateLeft
Definition: z3py.py:3732
Z3_ast Z3_API Z3_mk_ext_rotate_left(Z3_context c, Z3_ast t1, Z3_ast t2)
Rotate bits of t1 to the left t2 times.
def z3py.RotateRight (   a,
  b 
)
Return an expression representing `a` rotated to the right `b` times.

>>> a, b = BitVecs('a b', 16)
>>> RotateRight(a, b)
RotateRight(a, b)
>>> simplify(RotateRight(a, 0))
a
>>> simplify(RotateRight(a, 16))
a

Definition at line 3747 of file z3py.py.

3748 def RotateRight(a, b):
3749  """Return an expression representing `a` rotated to the right `b` times.
3750 
3751  >>> a, b = BitVecs('a b', 16)
3752  >>> RotateRight(a, b)
3753  RotateRight(a, b)
3754  >>> simplify(RotateRight(a, 0))
3755  a
3756  >>> simplify(RotateRight(a, 16))
3757  a
3758  """
3759  _check_bv_args(a, b)
3760  a, b = _coerce_exprs(a, b)
3761  return BitVecRef(Z3_mk_ext_rotate_right(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
Z3_ast Z3_API Z3_mk_ext_rotate_right(Z3_context c, Z3_ast t1, Z3_ast t2)
Rotate bits of t1 to the right t2 times.
def RotateRight
Definition: z3py.py:3747
def z3py.RoundNearestTiesToAway (   ctx = None)

Definition at line 7964 of file z3py.py.

7965 def RoundNearestTiesToAway(ctx=None):
7966  ctx = _get_ctx(ctx)
7967  return FPRMRef(Z3_mk_fpa_round_nearest_ties_to_away(ctx.ref()), ctx)
def RoundNearestTiesToAway
Definition: z3py.py:7964
Z3_ast Z3_API Z3_mk_fpa_round_nearest_ties_to_away(Z3_context c)
Create a numeral of RoundingMode sort which represents the NearestTiesToAway rounding mode...
def z3py.RoundNearestTiesToEven (   ctx = None)

Definition at line 7956 of file z3py.py.

7957 def RoundNearestTiesToEven(ctx=None):
7958  ctx = _get_ctx(ctx)
7959  return FPRMRef(Z3_mk_fpa_round_nearest_ties_to_even(ctx.ref()), ctx)
def RoundNearestTiesToEven
Definition: z3py.py:7956
Z3_ast Z3_API Z3_mk_fpa_round_nearest_ties_to_even(Z3_context c)
Create a numeral of RoundingMode sort which represents the NearestTiesToEven rounding mode...
def z3py.RoundTowardNegative (   ctx = None)

Definition at line 7980 of file z3py.py.

7981 def RoundTowardNegative(ctx=None):
7982  ctx = _get_ctx(ctx)
7983  return FPRMRef(Z3_mk_fpa_round_toward_negative(ctx.ref()), ctx)
def RoundTowardNegative
Definition: z3py.py:7980
Z3_ast Z3_API Z3_mk_fpa_round_toward_negative(Z3_context c)
Create a numeral of RoundingMode sort which represents the TowardNegative rounding mode...
def z3py.RoundTowardPositive (   ctx = None)

Definition at line 7972 of file z3py.py.

7973 def RoundTowardPositive(ctx=None):
7974  ctx = _get_ctx(ctx)
7975  return FPRMRef(Z3_mk_fpa_round_toward_positive(ctx.ref()), ctx)
def RoundTowardPositive
Definition: z3py.py:7972
Z3_ast Z3_API Z3_mk_fpa_round_toward_positive(Z3_context c)
Create a numeral of RoundingMode sort which represents the TowardPositive rounding mode...
def z3py.RoundTowardZero (   ctx = None)

Definition at line 7988 of file z3py.py.

7989 def RoundTowardZero(ctx=None):
7990  ctx = _get_ctx(ctx)
7991  return FPRMRef(Z3_mk_fpa_round_toward_zero(ctx.ref()), ctx)
Z3_ast Z3_API Z3_mk_fpa_round_toward_zero(Z3_context c)
Create a numeral of RoundingMode sort which represents the TowardZero rounding mode.
def RoundTowardZero
Definition: z3py.py:7988
def z3py.RTN (   ctx = None)

Definition at line 7984 of file z3py.py.

Referenced by get_default_rounding_mode().

7985 def RTN(ctx=None):
7986  ctx = _get_ctx(ctx)
7987  return FPRMRef(Z3_mk_fpa_round_toward_negative(ctx.ref()), ctx)
Z3_ast Z3_API Z3_mk_fpa_round_toward_negative(Z3_context c)
Create a numeral of RoundingMode sort which represents the TowardNegative rounding mode...
def RTN
Definition: z3py.py:7984
def z3py.RTP (   ctx = None)

Definition at line 7976 of file z3py.py.

Referenced by get_default_rounding_mode().

7977 def RTP(ctx=None):
7978  ctx = _get_ctx(ctx)
7979  return FPRMRef(Z3_mk_fpa_round_toward_positive(ctx.ref()), ctx)
Z3_ast Z3_API Z3_mk_fpa_round_toward_positive(Z3_context c)
Create a numeral of RoundingMode sort which represents the TowardPositive rounding mode...
def RTP
Definition: z3py.py:7976
def z3py.RTZ (   ctx = None)

Definition at line 7992 of file z3py.py.

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

7993 def RTZ(ctx=None):
7994  ctx = _get_ctx(ctx)
7995  return FPRMRef(Z3_mk_fpa_round_toward_zero(ctx.ref()), ctx)
Z3_ast Z3_API Z3_mk_fpa_round_toward_zero(Z3_context c)
Create a numeral of RoundingMode sort which represents the TowardZero rounding mode.
def RTZ
Definition: z3py.py:7992
def z3py.Select (   a,
  i 
)
Return a Z3 select array expression.

>>> a = Array('a', IntSort(), IntSort())
>>> i = Int('i')
>>> Select(a, i)
a[i]
>>> eq(Select(a, i), a[i])
True

Definition at line 4086 of file z3py.py.

4087 def Select(a, i):
4088  """Return a Z3 select array expression.
4089 
4090  >>> a = Array('a', IntSort(), IntSort())
4091  >>> i = Int('i')
4092  >>> Select(a, i)
4093  a[i]
4094  >>> eq(Select(a, i), a[i])
4095  True
4096  """
4097  if __debug__:
4098  _z3_assert(is_array(a), "First argument must be a Z3 array expression")
4099  return a[i]
def Select
Definition: z3py.py:4086
def is_array
Definition: z3py.py:3927
def z3py.sequence_interpolant (   v,
  p = None,
  ctx = None 
)
Compute interpolant for a sequence of formulas.

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

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

Requires len(v) >= 1. 

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

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

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

Definition at line 7613 of file z3py.py.

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

Definition at line 7684 of file z3py.py.

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

Definition at line 7668 of file z3py.py.

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

Definition at line 242 of file z3py.py.

243 def set_option(*args, **kws):
244  """Alias for 'set_param' for backward compatibility.
245  """
246  return set_param(*args, **kws)
def set_option
Definition: z3py.py:242
def set_param
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().

215 def set_param(*args, **kws):
216  """Set Z3 global (or module) parameters.
217 
218  >>> set_param(precision=10)
219  """
220  if __debug__:
221  _z3_assert(len(args) % 2 == 0, "Argument list must have an even number of elements.")
222  new_kws = {}
223  for k in kws:
224  v = kws[k]
225  if not set_pp_option(k, v):
226  new_kws[k] = v
227  for key in new_kws:
228  value = new_kws[key]
229  Z3_global_param_set(str(key).upper(), _to_param_value(value))
230  prev = None
231  for a in args:
232  if prev == None:
233  prev = a
234  else:
235  Z3_global_param_set(str(prev), _to_param_value(a))
236  prev = None
void Z3_API Z3_global_param_set(Z3_string param_id, Z3_string param_value)
Set a global (or module) parameter. This setting is shared by all Z3 contexts.
def set_param
Definition: z3py.py:214
def z3py.SignExt (   n,
  a 
)
Return a bit-vector expression with `n` extra sign-bits.

>>> x = BitVec('x', 16)
>>> n = SignExt(8, x)
>>> n.size()
24
>>> n
SignExt(8, x)
>>> n.sort()
BitVec(24)
>>> v0 = BitVecVal(2, 2)
>>> v0
2
>>> v0.size()
2
>>> v  = simplify(SignExt(6, v0))
>>> v
254
>>> v.size()
8
>>> print("%.x" % v.as_long())
fe

Definition at line 3762 of file z3py.py.

3763 def SignExt(n, a):
3764  """Return a bit-vector expression with `n` extra sign-bits.
3765 
3766  >>> x = BitVec('x', 16)
3767  >>> n = SignExt(8, x)
3768  >>> n.size()
3769  24
3770  >>> n
3771  SignExt(8, x)
3772  >>> n.sort()
3773  BitVec(24)
3774  >>> v0 = BitVecVal(2, 2)
3775  >>> v0
3776  2
3777  >>> v0.size()
3778  2
3779  >>> v = simplify(SignExt(6, v0))
3780  >>> v
3781  254
3782  >>> v.size()
3783  8
3784  >>> print("%.x" % v.as_long())
3785  fe
3786  """
3787  if __debug__:
3788  _z3_assert(isinstance(n, int), "First argument must be an integer")
3789  _z3_assert(is_bv(a), "Second argument must be a Z3 Bitvector expression")
3790  return BitVecRef(Z3_mk_sign_ext(a.ctx_ref(), n, a.as_ast()), a.ctx)
def SignExt
Definition: z3py.py:3762
def is_bv
Definition: z3py.py:3415
Z3_ast Z3_API Z3_mk_sign_ext(Z3_context c, unsigned i, Z3_ast t1)
Sign-extend of the given bit-vector to the (signed) equivalent bitvector of size m+i, where m is the size of the given bit-vector.
def z3py.SimpleSolver (   ctx = None)
Return a simple general purpose solver with limited amount of preprocessing.

>>> s = SimpleSolver()
>>> x = Int('x')
>>> s.add(x > 0)
>>> s.check()
sat

Definition at line 6131 of file z3py.py.

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

6132 def SimpleSolver(ctx=None):
6133  """Return a simple general purpose solver with limited amount of preprocessing.
6134 
6135  >>> s = SimpleSolver()
6136  >>> x = Int('x')
6137  >>> s.add(x > 0)
6138  >>> s.check()
6139  sat
6140  """
6141  ctx = _get_ctx(ctx)
6142  return Solver(Z3_mk_simple_solver(ctx.ref()), ctx)
Z3_solver Z3_API Z3_mk_simple_solver(Z3_context c)
Create a new (incremental) solver.
def SimpleSolver
Definition: z3py.py:6131
def z3py.simplify (   a,
  arguments,
  keywords 
)

Utils.

Simplify the expression `a` using the given options.

This function has many options. Use `help_simplify` to obtain the complete list.

>>> x = Int('x')
>>> y = Int('y')
>>> simplify(x + 1 + y + x + 1)
2 + 2*x + y
>>> simplify((x + 1)*(y + 1), som=True)
1 + x + y + x*y
>>> simplify(Distinct(x, y, 1), blast_distinct=True)
And(Not(x == y), Not(x == 1), Not(y == 1))
>>> simplify(And(x == 0, y == 1), elim_and=True)
Not(Or(Not(x == 0), Not(y == 1)))

Definition at line 7178 of file z3py.py.

Referenced by BitVecRef.__invert__(), BitVecRef.__lshift__(), ArithRef.__mod__(), ArithRef.__neg__(), BitVecRef.__neg__(), ArithRef.__pow__(), ArithRef.__rpow__(), BitVecRef.__rshift__(), AlgebraicNumRef.approx(), AlgebraicNumRef.as_decimal(), BitVecs(), Concat(), CreateDatatypes(), Implies(), is_algebraic_value(), K(), LShR(), Not(), Q(), RatVal(), DatatypeSortRef.recognizer(), RepeatBitVec(), RotateLeft(), RotateRight(), SignExt(), Xor(), and ZeroExt().

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

Definition at line 7206 of file z3py.py.

7207 def simplify_param_descrs():
7208  """Return the set of parameter descriptions for Z3 `simplify` procedure."""
Z3_param_descrs Z3_API Z3_simplify_get_param_descrs(Z3_context c)
Return the parameter description set for the simplify procedure.
def simplify_param_descrs
Definition: z3py.py:7206
def main_ctx
Definition: z3py.py:188
def z3py.solve (   args,
  keywords 
)
Solve the constraints `*args`.

This is a simple function for creating demonstrations. It creates a solver,
configure it using the options in `keywords`, adds the constraints
in `args`, and invokes check.

>>> a = Int('a')
>>> solve(a > 0, a < 2)
[a = 1]

Definition at line 7306 of file z3py.py.

Referenced by BV2Int(), and IsInt().

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

This is a simple function for creating demonstrations. It is similar to `solve`,
but it uses the given solver `s`.
It configures solver `s` using the options in `keywords`, adds the constraints
in `args`, and invokes check.

Definition at line 7334 of file z3py.py.

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

The parameter `logic` is a string. It should be contains
the name of a SMT-LIB logic.
See http://www.smtlib.org/ for the name of all available logics.

>>> s = SolverFor("QF_LIA")
>>> x = Int('x')
>>> s.add(x > 0)
>>> s.add(x < 2)
>>> s.check()
sat
>>> s.model()
[x = 1]

Definition at line 6111 of file z3py.py.

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

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

2893 def Sqrt(a, ctx=None):
2894  """ Return a Z3 expression which represents the square root of a.
2895 
2896  >>> x = Real('x')
2897  >>> Sqrt(x)
2898  x**(1/2)
2899  """
2900  if not is_expr(a):
2901  ctx = _get_ctx(ctx)
2902  a = RealVal(a, ctx)
2903  return a ** "1/2"
def is_expr
Definition: z3py.py:961
def RealVal
Definition: z3py.py:2697
def Sqrt
Definition: z3py.py:2892
def z3py.SRem (   a,
  b 
)
Create the Z3 expression signed remainder.

Use the operator % for signed modulus, and URem() for unsigned remainder.

>>> x = BitVec('x', 32)
>>> y = BitVec('y', 32)
>>> SRem(x, y)
SRem(x, y)
>>> SRem(x, y).sort()
BitVec(32)
>>> (x % y).sexpr()
'(bvsmod x y)'
>>> SRem(x, y).sexpr()
'(bvsrem x y)'

Definition at line 3681 of file z3py.py.

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

3682 def SRem(a, b):
3683  """Create the Z3 expression signed remainder.
3684 
3685  Use the operator % for signed modulus, and URem() for unsigned remainder.
3686 
3687  >>> x = BitVec('x', 32)
3688  >>> y = BitVec('y', 32)
3689  >>> SRem(x, y)
3690  SRem(x, y)
3691  >>> SRem(x, y).sort()
3692  BitVec(32)
3693  >>> (x % y).sexpr()
3694  '(bvsmod x y)'
3695  >>> SRem(x, y).sexpr()
3696  '(bvsrem x y)'
3697  """
3698  _check_bv_args(a, b)
3699  a, b = _coerce_exprs(a, b)
3700  return BitVecRef(Z3_mk_bvsrem(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
Z3_ast Z3_API Z3_mk_bvsrem(Z3_context c, Z3_ast t1, Z3_ast t2)
Two&#39;s complement signed remainder (sign follows dividend).
def SRem
Definition: z3py.py:3681
def z3py.Store (   a,
  i,
  v 
)
Return a Z3 store array expression.

>>> a    = Array('a', IntSort(), IntSort())
>>> i, v = Ints('i v')
>>> s    = Store(a, i, v)
>>> s.sort()
Array(Int, Int)
>>> prove(s[i] == v)
proved
>>> j    = Int('j')
>>> prove(Implies(i != j, s[j] == a[j]))
proved

Definition at line 4070 of file z3py.py.

Referenced by is_array(), and is_store().

4071 def Store(a, i, v):
4072  """Return a Z3 store array expression.
4073 
4074  >>> a = Array('a', IntSort(), IntSort())
4075  >>> i, v = Ints('i v')
4076  >>> s = Store(a, i, v)
4077  >>> s.sort()
4078  Array(Int, Int)
4079  >>> prove(s[i] == v)
4080  proved
4081  >>> j = Int('j')
4082  >>> prove(Implies(i != j, s[j] == a[j]))
4083  proved
4084  """
4085  return Update(a, i, v)
def Update
Definition: z3py.py:4038
def Store
Definition: z3py.py:4070
def z3py.substitute (   t,
  m 
)
Apply substitution m on t, m is a list of pairs of the form (from, to). Every occurrence in t of from is replaced with to.

>>> x = Int('x')
>>> y = Int('y')
>>> substitute(x + 1, (x, y + 1))
y + 1 + 1
>>> f = Function('f', IntSort(), IntSort())
>>> substitute(f(x) + f(y), (f(x), IntVal(1)), (f(y), IntVal(1)))
1 + 1

Definition at line 7210 of file z3py.py.

7211 def substitute(t, *m):
7212  """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.
7213 
7214  >>> x = Int('x')
7215  >>> y = Int('y')
7216  >>> substitute(x + 1, (x, y + 1))
7217  y + 1 + 1
7218  >>> f = Function('f', IntSort(), IntSort())
7219  >>> substitute(f(x) + f(y), (f(x), IntVal(1)), (f(y), IntVal(1)))
7220  1 + 1
7221  """
7222  if isinstance(m, tuple):
7223  m1 = _get_args(m)
7224  if isinstance(m1, list):
7225  m = m1
7226  if __debug__:
7227  _z3_assert(is_expr(t), "Z3 expression expected")
7228  _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.")
7229  num = len(m)
7230  _from = (Ast * num)()
7231  _to = (Ast * num)()
7232  for i in range(num):
7233  _from[i] = m[i][0].as_ast()
7234  _to[i] = m[i][1].as_ast()
7235  return _to_expr_ref(Z3_substitute(t.ctx.ref(), t.as_ast(), num, _from, _to), t.ctx)
Z3_ast Z3_API Z3_substitute(Z3_context c, Z3_ast a, unsigned num_exprs, Z3_ast const from[], Z3_ast const to[])
Substitute every occurrence of from[i] in a with to[i], for i smaller than num_exprs. The result is the new AST. The arrays from and to must have size num_exprs. For every i smaller than num_exprs, we must have that sort of from[i] must be equal to sort of to[i].
def is_expr
Definition: z3py.py:961
def substitute
Definition: z3py.py:7210
def eq
Definition: z3py.py:371
def z3py.substitute_vars (   t,
  m 
)
Substitute the free variables in t with the expression in m.

>>> v0 = Var(0, IntSort())
>>> v1 = Var(1, IntSort())
>>> x  = Int('x')
>>> f  = Function('f', IntSort(), IntSort(), IntSort())
>>> # replace v0 with x+1 and v1 with x
>>> substitute_vars(f(v0, v1), x + 1, x)
f(x + 1, x)

Definition at line 7236 of file z3py.py.

7237 def substitute_vars(t, *m):
7238  """Substitute the free variables in t with the expression in m.
7239 
7240  >>> v0 = Var(0, IntSort())
7241  >>> v1 = Var(1, IntSort())
7242  >>> x = Int('x')
7243  >>> f = Function('f', IntSort(), IntSort(), IntSort())
7244  >>> # replace v0 with x+1 and v1 with x
7245  >>> substitute_vars(f(v0, v1), x + 1, x)
7246  f(x + 1, x)
7247  """
7248  if __debug__:
7249  _z3_assert(is_expr(t), "Z3 expression expected")
7250  _z3_assert(all([is_expr(n) for n in m]), "Z3 invalid substitution, list of expressions expected.")
7251  num = len(m)
7252  _to = (Ast * num)()
7253  for i in range(num):
7254  _to[i] = m[i].as_ast()
7255  return _to_expr_ref(Z3_substitute_vars(t.ctx.ref(), t.as_ast(), num, _to), t.ctx)
Z3_ast Z3_API Z3_substitute_vars(Z3_context c, Z3_ast a, unsigned num_exprs, Z3_ast const to[])
Substitute the free variables in a with the expressions in to. For every i smaller than num_exprs...
def is_expr
Definition: z3py.py:961
def substitute_vars
Definition: z3py.py:7236
def z3py.Sum (   args)
Create the sum of the Z3 expressions. 

>>> a, b, c = Ints('a b c')
>>> Sum(a, b, c)
a + b + c
>>> Sum([a, b, c])
a + b + c
>>> A = IntVector('a', 5)
>>> Sum(A)
a__0 + a__1 + a__2 + a__3 + a__4

Definition at line 7256 of file z3py.py.

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

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

>>> d = tactic_description('simplify')

Definition at line 6896 of file z3py.py.

Referenced by describe_tactics().

6897 def tactic_description(name, ctx=None):
6898  """Return a short description for the tactic named `name`.
6899 
6900  >>> d = tactic_description('simplify')
6901  """
6902  ctx = _get_ctx(ctx)
6903  return Z3_tactic_get_descr(ctx.ref(), name)
def tactic_description
Definition: z3py.py:6896
Z3_string Z3_API Z3_tactic_get_descr(Z3_context c, Z3_string name)
Return a string containing a description of the tactic with the given name.
def z3py.tactics (   ctx = None)
Return a list of all available tactics in Z3.

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

Definition at line 6886 of file z3py.py.

Referenced by describe_tactics().

6887 def tactics(ctx=None):
6888  """Return a list of all available tactics in Z3.
6889 
6890  >>> l = tactics()
6891  >>> l.count('simplify') == 1
6892  True
6893  """
6894  ctx = _get_ctx(ctx)
6895  return [ Z3_get_tactic_name(ctx.ref(), i) for i in range(Z3_get_num_tactics(ctx.ref())) ]
Z3_string Z3_API Z3_get_tactic_name(Z3_context c, unsigned i)
Return the name of the idx tactic.
unsigned Z3_API Z3_get_num_tactics(Z3_context c)
Return the number of builtin tactics available in Z3.
def tactics
Definition: z3py.py:6886
def z3py.Then (   ts,
  ks 
)
Return a tactic that applies the tactics in `*ts` in sequence. Shorthand for AndThen(*ts, **ks).

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

Definition at line 6778 of file z3py.py.

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

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

Definition at line 94 of file z3py.py.

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

94 
95 def to_symbol(s, ctx=None):
96  """Convert an integer or string into a Z3 symbol."""
97  if isinstance(s, int):
98  return Z3_mk_int_symbol(_get_ctx(ctx).ref(), s)
99  else:
100  return Z3_mk_string_symbol(_get_ctx(ctx).ref(), s)
Z3_symbol Z3_API Z3_mk_string_symbol(Z3_context c, Z3_string s)
Create a Z3 symbol using a C string.
Z3_symbol Z3_API Z3_mk_int_symbol(Z3_context c, int i)
Create a Z3 symbol using an integer.
def to_symbol
Definition: z3py.py:94
def z3py.ToInt (   a)
Return the Z3 expression ToInt(a). 

>>> x = Real('x')
>>> x.sort()
Real
>>> n = ToInt(x)
>>> n
ToInt(x)
>>> n.sort()
Int

Definition at line 2859 of file z3py.py.

Referenced by is_to_int().

2860 def ToInt(a):
2861  """ Return the Z3 expression ToInt(a).
2862 
2863  >>> x = Real('x')
2864  >>> x.sort()
2865  Real
2866  >>> n = ToInt(x)
2867  >>> n
2868  ToInt(x)
2869  >>> n.sort()
2870  Int
2871  """
2872  if __debug__:
2873  _z3_assert(a.is_real(), "Z3 real expression expected.")
2874  ctx = a.ctx
2875  return ArithRef(Z3_mk_real2int(ctx.ref(), a.as_ast()), ctx)
Z3_ast Z3_API Z3_mk_real2int(Z3_context c, Z3_ast t1)
Coerce a real to an integer.
def ToInt
Definition: z3py.py:2859
def z3py.ToReal (   a)
Return the Z3 expression ToReal(a). 

>>> x = Int('x')
>>> x.sort()
Int
>>> n = ToReal(x)
>>> n
ToReal(x)
>>> n.sort()
Real

Definition at line 2842 of file z3py.py.

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

2843 def ToReal(a):
2844  """ Return the Z3 expression ToReal(a).
2845 
2846  >>> x = Int('x')
2847  >>> x.sort()
2848  Int
2849  >>> n = ToReal(x)
2850  >>> n
2851  ToReal(x)
2852  >>> n.sort()
2853  Real
2854  """
2855  if __debug__:
2856  _z3_assert(a.is_int(), "Z3 integer expression expected.")
2857  ctx = a.ctx
2858  return ArithRef(Z3_mk_int2real(ctx.ref(), a.as_ast()), ctx)
def ToReal
Definition: z3py.py:2842
Z3_ast Z3_API Z3_mk_int2real(Z3_context c, Z3_ast t1)
Coerce an integer to a real.
def z3py.tree_interpolant (   pat,
  p = None,
  ctx = None 
)
Compute interpolant for a tree of formulas.

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

  1) phi sigma implies sigma(phi), and

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

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

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

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

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

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

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

Definition at line 7531 of file z3py.py.

Referenced by binary_interpolant(), and sequence_interpolant().

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

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

Definition at line 6878 of file z3py.py.

6879 def TryFor(t, ms, ctx=None):
6880  """Return a tactic that applies `t` to a given goal for `ms` milliseconds.
6881 
6882  If `t` does not terminate in `ms` milliseconds, then it fails.
6883  """
6884  t = _to_tactic(t, ctx)
6885  return Tactic(Z3_tactic_try_for(t.ctx.ref(), t.tactic, ms), t.ctx)
Z3_tactic Z3_API Z3_tactic_try_for(Z3_context c, Z3_tactic t, unsigned ms)
Return a tactic that applies t to a given goal for ms milliseconds. If t does not terminate in ms mil...
def TryFor
Definition: z3py.py:6878
def z3py.UDiv (   a,
  b 
)
Create the Z3 expression (unsigned) division `self / other`.

Use the operator / for signed division.

>>> x = BitVec('x', 32)
>>> y = BitVec('y', 32)
>>> UDiv(x, y)
UDiv(x, y)
>>> UDiv(x, y).sort()
BitVec(32)
>>> (x / y).sexpr()
'(bvsdiv x y)'
>>> UDiv(x, y).sexpr()
'(bvudiv x y)'

Definition at line 3641 of file z3py.py.

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

3642 def UDiv(a, b):
3643  """Create the Z3 expression (unsigned) division `self / other`.
3644 
3645  Use the operator / for signed division.
3646 
3647  >>> x = BitVec('x', 32)
3648  >>> y = BitVec('y', 32)
3649  >>> UDiv(x, y)
3650  UDiv(x, y)
3651  >>> UDiv(x, y).sort()
3652  BitVec(32)
3653  >>> (x / y).sexpr()
3654  '(bvsdiv x y)'
3655  >>> UDiv(x, y).sexpr()
3656  '(bvudiv x y)'
3657  """
3658  _check_bv_args(a, b)
3659  a, b = _coerce_exprs(a, b)
3660  return BitVecRef(Z3_mk_bvudiv(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
def UDiv
Definition: z3py.py:3641
Z3_ast Z3_API Z3_mk_bvudiv(Z3_context c, Z3_ast t1, Z3_ast t2)
Unsigned division.
def z3py.UGE (   a,
  b 
)
Create the Z3 expression (unsigned) `other >= self`.

Use the operator >= for signed greater than or equal to.

>>> x, y = BitVecs('x y', 32)
>>> UGE(x, y)
UGE(x, y)
>>> (x >= y).sexpr()
'(bvsge x y)'
>>> UGE(x, y).sexpr()
'(bvuge x y)'

Definition at line 3607 of file z3py.py.

Referenced by BitVecRef.__ge__().

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

Referenced by BitVecRef.__gt__().

3625 def UGT(a, b):
3626  """Create the Z3 expression (unsigned) `other > self`.
3627 
3628  Use the operator > for signed greater than.
3629 
3630  >>> x, y = BitVecs('x y', 32)
3631  >>> UGT(x, y)
3632  UGT(x, y)
3633  >>> (x > y).sexpr()
3634  '(bvsgt x y)'
3635  >>> UGT(x, y).sexpr()
3636  '(bvugt x y)'
3637  """
3638  _check_bv_args(a, b)
3639  a, b = _coerce_exprs(a, b)
3640  return BoolRef(Z3_mk_bvugt(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
Z3_ast Z3_API Z3_mk_bvugt(Z3_context c, Z3_ast t1, Z3_ast t2)
Unsigned greater than.
def UGT
Definition: z3py.py:3624
def z3py.ULE (   a,
  b 
)
Create the Z3 expression (unsigned) `other <= self`.

Use the operator <= for signed less than or equal to.

>>> x, y = BitVecs('x y', 32)
>>> ULE(x, y)
ULE(x, y)
>>> (x <= y).sexpr()
'(bvsle x y)'
>>> ULE(x, y).sexpr()
'(bvule x y)'

Definition at line 3573 of file z3py.py.

Referenced by BitVecRef.__le__().

3574 def ULE(a, b):
3575  """Create the Z3 expression (unsigned) `other <= self`.
3576 
3577  Use the operator <= for signed less than or equal to.
3578 
3579  >>> x, y = BitVecs('x y', 32)
3580  >>> ULE(x, y)
3581  ULE(x, y)
3582  >>> (x <= y).sexpr()
3583  '(bvsle x y)'
3584  >>> ULE(x, y).sexpr()
3585  '(bvule x y)'
3586  """
3587  _check_bv_args(a, b)
3588  a, b = _coerce_exprs(a, b)
3589  return BoolRef(Z3_mk_bvule(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
def ULE
Definition: z3py.py:3573
Z3_ast Z3_API Z3_mk_bvule(Z3_context c, Z3_ast t1, Z3_ast t2)
Unsigned less than or equal to.
def z3py.ULT (   a,
  b 
)
Create the Z3 expression (unsigned) `other < self`.

Use the operator < for signed less than.

>>> x, y = BitVecs('x y', 32)
>>> ULT(x, y)
ULT(x, y)
>>> (x < y).sexpr()
'(bvslt x y)'
>>> ULT(x, y).sexpr()
'(bvult x y)'

Definition at line 3590 of file z3py.py.

Referenced by BitVecRef.__lt__().

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

>>> a    = Array('a', IntSort(), IntSort())
>>> i, v = Ints('i v')
>>> s    = Update(a, i, v)
>>> s.sort()
Array(Int, Int)
>>> prove(s[i] == v)
proved
>>> j    = Int('j')
>>> prove(Implies(i != j, s[j] == a[j]))
proved

Definition at line 4038 of file z3py.py.

Referenced by Store().

4039 def Update(a, i, v):
4040  """Return a Z3 store array expression.
4041 
4042  >>> a = Array('a', IntSort(), IntSort())
4043  >>> i, v = Ints('i v')
4044  >>> s = Update(a, i, v)
4045  >>> s.sort()
4046  Array(Int, Int)
4047  >>> prove(s[i] == v)
4048  proved
4049  >>> j = Int('j')
4050  >>> prove(Implies(i != j, s[j] == a[j]))
4051  proved
4052  """
4053  if __debug__:
4054  _z3_assert(is_array(a), "First argument must be a Z3 array expression")
4055  i = a.domain().cast(i)
4056  v = a.range().cast(v)
4057  ctx = a.ctx
4058  return _to_expr_ref(Z3_mk_store(ctx.ref(), a.as_ast(), i.as_ast(), v.as_ast()), ctx)
def Update
Definition: z3py.py:4038
Z3_ast Z3_API Z3_mk_store(Z3_context c, Z3_ast a, Z3_ast i, Z3_ast v)
Array update.
def is_array
Definition: z3py.py:3927
def z3py.URem (   a,
  b 
)
Create the Z3 expression (unsigned) remainder `self % other`.

Use the operator % for signed modulus, and SRem() for signed remainder.

>>> x = BitVec('x', 32)
>>> y = BitVec('y', 32)
>>> URem(x, y)
URem(x, y)
>>> URem(x, y).sort()
BitVec(32)
>>> (x % y).sexpr()
'(bvsmod x y)'
>>> URem(x, y).sexpr()
'(bvurem x y)'

Definition at line 3661 of file z3py.py.

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

3662 def URem(a, b):
3663  """Create the Z3 expression (unsigned) remainder `self % other`.
3664 
3665  Use the operator % for signed modulus, and SRem() for signed remainder.
3666 
3667  >>> x = BitVec('x', 32)
3668  >>> y = BitVec('y', 32)
3669  >>> URem(x, y)
3670  URem(x, y)
3671  >>> URem(x, y).sort()
3672  BitVec(32)
3673  >>> (x % y).sexpr()
3674  '(bvsmod x y)'
3675  >>> URem(x, y).sexpr()
3676  '(bvurem x y)'
3677  """
3678  _check_bv_args(a, b)
3679  a, b = _coerce_exprs(a, b)
3680  return BitVecRef(Z3_mk_bvurem(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
def URem
Definition: z3py.py:3661
Z3_ast Z3_API Z3_mk_bvurem(Z3_context c, Z3_ast t1, Z3_ast t2)
Unsigned remainder.
def z3py.Var (   idx,
  s 
)
Create a Z3 free variable. Free variables are used to create quantified formulas.

>>> Var(0, IntSort())
Var(0)
>>> eq(Var(0, IntSort()), Var(0, BoolSort()))
False

Definition at line 1170 of file z3py.py.

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

1171 def Var(idx, s):
1172  """Create a Z3 free variable. Free variables are used to create quantified formulas.
1173 
1174  >>> Var(0, IntSort())
1175  Var(0)
1176  >>> eq(Var(0, IntSort()), Var(0, BoolSort()))
1177  False
1178  """
1179  if __debug__:
1180  _z3_assert(is_sort(s), "Z3 sort expected")
1181  return _to_expr_ref(Z3_mk_bound(s.ctx_ref(), idx, s.ast), s.ctx)
Z3_ast Z3_API Z3_mk_bound(Z3_context c, unsigned index, Z3_sort ty)
Create a bound variable.
def Var
Definition: z3py.py:1170
def is_sort
Definition: z3py.py:530
def z3py.When (   p,
  t,
  ctx = None 
)
Return a tactic that applies tactic `t` only if probe `p` evaluates to true. Otherwise, it returns the input goal unmodified.

>>> t = When(Probe('size') > 2, Tactic('simplify'))
>>> x, y = Ints('x y')
>>> g = Goal()
>>> g.add(x > 0)
>>> g.add(y > 0)
>>> t(g)
[[x > 0, y > 0]]
>>> g.add(x == y + 1)
>>> t(g)
[[Not(x <= 0), Not(y <= 0), x == 1 + y]]

Definition at line 7144 of file z3py.py.

7145 def When(p, t, ctx=None):
7146  """Return a tactic that applies tactic `t` only if probe `p` evaluates to true. Otherwise, it returns the input goal unmodified.
7147 
7148  >>> t = When(Probe('size') > 2, Tactic('simplify'))
7149  >>> x, y = Ints('x y')
7150  >>> g = Goal()
7151  >>> g.add(x > 0)
7152  >>> g.add(y > 0)
7153  >>> t(g)
7154  [[x > 0, y > 0]]
7155  >>> g.add(x == y + 1)
7156  >>> t(g)
7157  [[Not(x <= 0), Not(y <= 0), x == 1 + y]]
7158  """
7159  p = _to_probe(p, ctx)
7160  t = _to_tactic(t, ctx)
7161  return Tactic(Z3_tactic_when(t.ctx.ref(), p.probe, t.tactic), t.ctx)
Z3_tactic Z3_API Z3_tactic_when(Z3_context c, Z3_probe p, Z3_tactic t)
Return a tactic that applies t to a given goal is the probe p evaluates to true. If p evaluates to fa...
def When
Definition: z3py.py:7144
def z3py.With (   t,
  args,
  keys 
)
Return a tactic that applies tactic `t` using the given configuration options.

>>> x, y = Ints('x y')
>>> t = With(Tactic('simplify'), som=True)
>>> t((x + 1)*(y + 2) == 0)
[[2*x + y + x*y == -2]]

Definition at line 6846 of file z3py.py.

Referenced by Goal.prec().

6847 def With(t, *args, **keys):
6848  """Return a tactic that applies tactic `t` using the given configuration options.
6849 
6850  >>> x, y = Ints('x y')
6851  >>> t = With(Tactic('simplify'), som=True)
6852  >>> t((x + 1)*(y + 2) == 0)
6853  [[2*x + y + x*y == -2]]
6854  """
6855  ctx = keys.get('ctx', None)
6856  t = _to_tactic(t, ctx)
6857  p = args2params(args, keys, t.ctx)
6858  return Tactic(Z3_tactic_using_params(t.ctx.ref(), t.tactic, p.params), t.ctx)
def With
Definition: z3py.py:6846
def args2params
Definition: z3py.py:4527
Z3_tactic Z3_API Z3_tactic_using_params(Z3_context c, Z3_tactic t, Z3_params p)
Return a tactic that applies t using the given set of parameters.
def z3py.Xor (   a,
  b,
  ctx = None 
)
Create a Z3 Xor expression.

>>> p, q = Bools('p q')
>>> Xor(p, q)
Xor(p, q)
>>> simplify(Xor(p, q))
Not(p) == q

Definition at line 1449 of file z3py.py.

1450 def Xor(a, b, ctx=None):
1451  """Create a Z3 Xor expression.
1452 
1453  >>> p, q = Bools('p q')
1454  >>> Xor(p, q)
1455  Xor(p, q)
1456  >>> simplify(Xor(p, q))
1457  Not(p) == q
1458  """
1459  ctx = _get_ctx(_ctx_from_ast_arg_list([a, b], ctx))
1460  s = BoolSort(ctx)
1461  a = s.cast(a)
1462  b = s.cast(b)
1463  return BoolRef(Z3_mk_xor(ctx.ref(), a.as_ast(), b.as_ast()), ctx)
def BoolSort
Definition: z3py.py:1346
Z3_ast Z3_API Z3_mk_xor(Z3_context c, Z3_ast t1, Z3_ast t2)
Create an AST node representing t1 xor t2.
def Xor
Definition: z3py.py:1449
def z3py.ZeroExt (   n,
  a 
)
Return a bit-vector expression with `n` extra zero-bits.

>>> x = BitVec('x', 16)
>>> n = ZeroExt(8, x)
>>> n.size()
24
>>> n
ZeroExt(8, x)
>>> n.sort()
BitVec(24)
>>> v0 = BitVecVal(2, 2)
>>> v0
2
>>> v0.size()
2
>>> v  = simplify(ZeroExt(6, v0))
>>> v
2
>>> v.size()
8

Definition at line 3791 of file z3py.py.

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

Variable Documentation

int _dflt_fpsort_ebits = 11

Definition at line 7651 of file z3py.py.

int _dflt_fpsort_sbits = 53

Definition at line 7652 of file z3py.py.

_dflt_rounding_mode = Z3_OP_FPA_RM_TOWARD_ZERO

Floating-Point Arithmetic.

Definition at line 7650 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 5771 of file z3py.py.

tuple unknown = CheckSatResult(Z3_L_UNDEF)

Definition at line 5773 of file z3py.py.

tuple unsat = CheckSatResult(Z3_L_FALSE)

Definition at line 5772 of file z3py.py.