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

Data Structures

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

Functions

def z3_debug
 
def enable_trace
 
def disable_trace
 
def get_version_string
 
def get_version
 
def get_full_version
 
def open_log
 
def append_log
 
def to_symbol
 
def z3_error_handler
 
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 RecFunction
 
def RecAddDefinition
 
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 FreshConst
 
def Var
 
def RealVar
 
def RealVarVector
 
def is_bool
 
def is_true
 
def is_false
 
def is_and
 
def is_or
 
def is_implies
 
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 mk_not
 
def And
 
def Or
 
def is_pattern
 
def MultiPattern
 
def is_quantifier
 
def ForAll
 
def Exists
 
def Lambda
 
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 Int2BV
 
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 BVAddNoOverflow
 
def BVAddNoUnderflow
 
def BVSubNoOverflow
 
def BVSubNoUnderflow
 
def BVSDivNoOverflow
 
def BVSNegNoOverflow
 
def BVMulNoOverflow
 
def BVMulNoUnderflow
 
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 Ext
 
def SetHasSize
 
def is_select
 
def is_store
 
def SetSort
 Sets. More...
 
def EmptySet
 
def FullSet
 
def SetUnion
 
def SetIntersect
 
def SetAdd
 
def SetDel
 
def SetComplement
 
def SetDifference
 
def IsMember
 
def IsSubset
 
def CreateDatatypes
 
def TupleSort
 
def DisjointSum
 
def EnumSort
 
def args2params
 
def Model
 
def is_as_array
 
def get_as_array_func
 
def SolverFor
 
def SimpleSolver
 
def FiniteDomainSort
 
def is_finite_domain_sort
 
def is_finite_domain
 
def FiniteDomainVal
 
def is_finite_domain_value
 
def AndThen
 
def Then
 
def OrElse
 
def ParOr
 
def ParThen
 
def ParAndThen
 
def With
 
def WithParams
 
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 AtMost
 
def AtLeast
 
def PbLe
 
def PbGe
 
def PbEq
 
def solve
 
def solve_using
 
def prove
 
def parse_smt2_string
 
def parse_smt2_file
 
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 FloatDouble
 
def Float128
 
def FloatQuadruple
 
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 fpIsInf
 
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 fpBVToFP
 
def fpFPToFP
 
def fpRealToFP
 
def fpSignedToFP
 
def fpUnsignedToFP
 
def fpToFPUnsigned
 
def fpToSBV
 
def fpToUBV
 
def fpToReal
 
def fpToIEEEBV
 
def StringSort
 
def SeqSort
 
def is_seq
 
def is_string
 
def is_string_value
 
def StringVal
 
def String
 
def SubString
 
def SubSeq
 
def Strings
 
def Empty
 
def Full
 
def Unit
 
def PrefixOf
 
def SuffixOf
 
def Contains
 
def Replace
 
def IndexOf
 
def IndexOf
 
def LastIndexOf
 
def Length
 
def StrToInt
 
def IntToStr
 
def Re
 
def ReSort
 
def is_re
 
def InRe
 
def Union
 
def Intersect
 
def Plus
 
def Option
 
def Complement
 
def Star
 
def Loop
 
def Range
 
def PartialOrder
 
def LinearOrder
 
def TreeOrder
 
def PiecewiseLinearOrder
 
def TransitiveClosure
 

Variables

 Z3_DEBUG = __debug__
 
 _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 1672 of file z3py.py.

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

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

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

Definition at line 7714 of file z3py.py.

Referenced by Then().

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

Definition at line 107 of file z3py.py.

108 def append_log(s):
109  """Append user-defined string to interaction log. """
110  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:107
def z3py.args2params (   arguments,
  keywords,
  ctx = None 
)
Convert python arguments into a Z3_params object.
A ':' is added to the keywords, and '_' is replaced with '-'

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

Definition at line 5050 of file z3py.py.

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

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

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

Definition at line 4383 of file z3py.py.

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

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

>>> A = ArraySort(IntSort(), BoolSort())
>>> A
Array(Int, Bool)
>>> A.domain()
Int
>>> A.range()
Bool
>>> AA = ArraySort(IntSort(), A)
>>> AA
Array(Int, Array(Int, Bool))

Definition at line 4351 of file z3py.py.

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

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

>>> a, b, c = Bools('a b c')
>>> f = AtLeast(a, b, c, 2)

Definition at line 8295 of file z3py.py.

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

>>> a, b, c = Bools('a b c')
>>> f = AtMost(a, b, c, 2)

Definition at line 8278 of file z3py.py.

8279 def AtMost(*args):
8280  """Create an at-most Pseudo-Boolean k constraint.
8281 
8282  >>> a, b, c = Bools('a b c')
8283  >>> f = AtMost(a, b, c, 2)
8284  """
8285  args = _get_args(args)
8286  if z3_debug():
8287  _z3_assert(len(args) > 1, "Non empty list of arguments expected")
8288  ctx = _ctx_from_ast_arg_list(args)
8289  if z3_debug():
8290  _z3_assert(ctx is not None, "At least one of the arguments must be a Z3 expression")
8291  args1 = _coerce_expr_list(args[:-1], ctx)
8292  k = args[-1]
8293  _args, sz = _to_ast_array(args1)
8294  return BoolRef(Z3_mk_atmost(ctx.ref(), sz, _args, k), ctx)
def z3_debug
Definition: z3py.py:58
Z3_ast Z3_API Z3_mk_atmost(Z3_context c, unsigned num_args, Z3_ast const args[], unsigned k)
Pseudo-Boolean relations.
def AtMost
Definition: z3py.py:8278
def z3py.BitVec (   name,
  bv,
  ctx = None 
)
Return a bit-vector constant named `name`. `bv` may be the number of bits of a bit-vector sort.
If `ctx=None`, then the global context is used.

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

Definition at line 3753 of file z3py.py.

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

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

>>> x, y, z = BitVecs('x y z', 16)
>>> x.size()
16
>>> x.sort()
BitVec(16)
>>> Sum(x, y, z)
0 + x + y + z
>>> Product(x, y, z)
1*x*y*z
>>> simplify(Product(x, y, z))
x*y*z

Definition at line 3776 of file z3py.py.

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

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

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

Definition at line 3723 of file z3py.py.

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

3724 def BitVecSort(sz, ctx=None):
3725  """Return a Z3 bit-vector sort of the given size. If `ctx=None`, then the global context is used.
3726 
3727  >>> Byte = BitVecSort(8)
3728  >>> Word = BitVecSort(16)
3729  >>> Byte
3730  BitVec(8)
3731  >>> x = Const('x', Byte)
3732  >>> eq(x, BitVec('x', 8))
3733  True
3734  """
3735  ctx = _get_ctx(ctx)
3736  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:3723
Bit-Vectors.
Definition: z3py.py:3173
def z3py.BitVecVal (   val,
  bv,
  ctx = None 
)
Return a bit-vector value with the given number of bits. If `ctx=None`, then the global context is used.

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

Definition at line 3737 of file z3py.py.

Referenced by BitVecRef.__lshift__(), BitVecRef.__rshift__(), BitVecNumRef.as_long(), BitVecNumRef.as_signed_long(), Concat(), fpBVToFP(), fpFP(), fpSignedToFP(), fpToFP(), fpUnsignedToFP(), is_bv_value(), LShR(), RepeatBitVec(), SignExt(), and ZeroExt().

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

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

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

`names` is a single string containing all names separated by blank spaces.
If `ctx=None`, then the global context is used.

>>> p, q, r = Bools('p q r')
>>> And(p, Or(q, r))
And(p, Or(q, r))

Definition at line 1569 of file z3py.py.

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

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

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

Definition at line 1523 of file z3py.py.

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

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

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

Definition at line 1540 of file z3py.py.

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

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

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

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

Definition at line 1584 of file z3py.py.

Referenced by And(), and Or().

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

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

Definition at line 3693 of file z3py.py.

3694 def BV2Int(a, is_signed=False):
3695  """Return the Z3 expression BV2Int(a).
3696 
3697  >>> b = BitVec('b', 3)
3698  >>> BV2Int(b).sort()
3699  Int
3700  >>> x = Int('x')
3701  >>> x > BV2Int(b)
3702  x > BV2Int(b)
3703  >>> x > BV2Int(b, is_signed=False)
3704  x > BV2Int(b)
3705  >>> x > BV2Int(b, is_signed=True)
3706  x > If(b < 0, BV2Int(b) - 8, BV2Int(b))
3707  >>> solve(x > BV2Int(b), b == 1, x < 3)
3708  [x = 2, b = 1]
3709  """
3710  if z3_debug():
3711  _z3_assert(is_bv(a), "Z3 bit-vector expression expected")
3712  ctx = a.ctx
3713  ## investigate problem with bv2int
3714  return ArithRef(Z3_mk_bv2int(ctx.ref(), a.as_ast(), is_signed), ctx)
def BV2Int
Definition: z3py.py:3693
def is_bv
Definition: z3py.py:3666
Z3_ast Z3_API Z3_mk_bv2int(Z3_context c, Z3_ast t1, bool is_signed)
Create an integer from the bit-vector argument t1. If is_signed is false, then the bit-vector t1 is t...
def z3_debug
Definition: z3py.py:58
def z3py.BVAddNoOverflow (   a,
  b,
  signed 
)
A predicate the determines that bit-vector addition does not overflow

Definition at line 4148 of file z3py.py.

4149 def BVAddNoOverflow(a, b, signed):
4150  """A predicate the determines that bit-vector addition does not overflow"""
4151  _check_bv_args(a, b)
4152  a, b = _coerce_exprs(a, b)
4153  return BoolRef(Z3_mk_bvadd_no_overflow(a.ctx_ref(), a.as_ast(), b.as_ast(), signed), a.ctx)
def BVAddNoOverflow
Definition: z3py.py:4148
Z3_ast Z3_API Z3_mk_bvadd_no_overflow(Z3_context c, Z3_ast t1, Z3_ast t2, bool is_signed)
Create a predicate that checks that the bit-wise addition of t1 and t2 does not overflow.
def z3py.BVAddNoUnderflow (   a,
  b 
)
A predicate the determines that signed bit-vector addition does not underflow

Definition at line 4154 of file z3py.py.

4155 def BVAddNoUnderflow(a, b):
4156  """A predicate the determines that signed bit-vector addition does not underflow"""
4157  _check_bv_args(a, b)
4158  a, b = _coerce_exprs(a, b)
4159  return BoolRef(Z3_mk_bvadd_no_underflow(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
def BVAddNoUnderflow
Definition: z3py.py:4154
Z3_ast Z3_API Z3_mk_bvadd_no_underflow(Z3_context c, Z3_ast t1, Z3_ast t2)
Create a predicate that checks that the bit-wise signed addition of t1 and t2 does not underflow...
def z3py.BVMulNoOverflow (   a,
  b,
  signed 
)
A predicate the determines that bit-vector multiplication does not overflow

Definition at line 4185 of file z3py.py.

4186 def BVMulNoOverflow(a, b, signed):
4187  """A predicate the determines that bit-vector multiplication does not overflow"""
4188  _check_bv_args(a, b)
4189  a, b = _coerce_exprs(a, b)
4190  return BoolRef(Z3_mk_bvmul_no_overflow(a.ctx_ref(), a.as_ast(), b.as_ast(), signed), a.ctx)
4191 
def BVMulNoOverflow
Definition: z3py.py:4185
Z3_ast Z3_API Z3_mk_bvmul_no_overflow(Z3_context c, Z3_ast t1, Z3_ast t2, bool is_signed)
Create a predicate that checks that the bit-wise multiplication of t1 and t2 does not overflow...
def z3py.BVMulNoUnderflow (   a,
  b 
)
A predicate the determines that bit-vector signed multiplication does not underflow

Definition at line 4192 of file z3py.py.

4193 def BVMulNoUnderflow(a, b):
4194  """A predicate the determines that bit-vector signed multiplication does not underflow"""
4195  _check_bv_args(a, b)
4196  a, b = _coerce_exprs(a, b)
4197  return BoolRef(Z3_mk_bvmul_no_underflow(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4198 
4199 
Z3_ast Z3_API Z3_mk_bvmul_no_underflow(Z3_context c, Z3_ast t1, Z3_ast t2)
Create a predicate that checks that the bit-wise signed multiplication of t1 and t2 does not underflo...
def BVMulNoUnderflow
Definition: z3py.py:4192
def z3py.BVRedAnd (   a)
Return the reduction-and expression of `a`.

Definition at line 4136 of file z3py.py.

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

Definition at line 4142 of file z3py.py.

4143 def BVRedOr(a):
4144  """Return the reduction-or expression of `a`."""
4145  if z3_debug():
4146  _z3_assert(is_bv(a), "First argument must be a Z3 Bitvector expression")
4147  return BitVecRef(Z3_mk_bvredor(a.ctx_ref(), a.as_ast()), a.ctx)
def is_bv
Definition: z3py.py:3666
def BVRedOr
Definition: z3py.py:4142
def z3_debug
Definition: z3py.py:58
Z3_ast Z3_API Z3_mk_bvredor(Z3_context c, Z3_ast t1)
Take disjunction of bits in vector, return vector of length 1.
def z3py.BVSDivNoOverflow (   a,
  b 
)
A predicate the determines that bit-vector signed division does not overflow

Definition at line 4173 of file z3py.py.

4174 def BVSDivNoOverflow(a, b):
4175  """A predicate the determines that bit-vector signed division does not overflow"""
4176  _check_bv_args(a, b)
4177  a, b = _coerce_exprs(a, b)
4178  return BoolRef(Z3_mk_bvsdiv_no_overflow(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
Z3_ast Z3_API Z3_mk_bvsdiv_no_overflow(Z3_context c, Z3_ast t1, Z3_ast t2)
Create a predicate that checks that the bit-wise signed division of t1 and t2 does not overflow...
def BVSDivNoOverflow
Definition: z3py.py:4173
def z3py.BVSNegNoOverflow (   a)
A predicate the determines that bit-vector unary negation does not overflow

Definition at line 4179 of file z3py.py.

4180 def BVSNegNoOverflow(a):
4181  """A predicate the determines that bit-vector unary negation does not overflow"""
4182  if z3_debug():
4183  _z3_assert(is_bv(a), "Argument should be a bit-vector")
4184  return BoolRef(Z3_mk_bvneg_no_overflow(a.ctx_ref(), a.as_ast()), a.ctx)
def BVSNegNoOverflow
Definition: z3py.py:4179
def is_bv
Definition: z3py.py:3666
Z3_ast Z3_API Z3_mk_bvneg_no_overflow(Z3_context c, Z3_ast t1)
Check that bit-wise negation does not overflow when t1 is interpreted as a signed bit-vector...
def z3_debug
Definition: z3py.py:58
def z3py.BVSubNoOverflow (   a,
  b 
)
A predicate the determines that bit-vector subtraction does not overflow

Definition at line 4160 of file z3py.py.

4161 def BVSubNoOverflow(a, b):
4162  """A predicate the determines that bit-vector subtraction does not overflow"""
4163  _check_bv_args(a, b)
4164  a, b = _coerce_exprs(a, b)
4165  return BoolRef(Z3_mk_bvsub_no_overflow(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4166 
def BVSubNoOverflow
Definition: z3py.py:4160
Z3_ast Z3_API Z3_mk_bvsub_no_overflow(Z3_context c, Z3_ast t1, Z3_ast t2)
Create a predicate that checks that the bit-wise signed subtraction of t1 and t2 does not overflow...
def z3py.BVSubNoUnderflow (   a,
  b,
  signed 
)
A predicate the determines that bit-vector subtraction does not underflow

Definition at line 4167 of file z3py.py.

4168 def BVSubNoUnderflow(a, b, signed):
4169  """A predicate the determines that bit-vector subtraction does not underflow"""
4170  _check_bv_args(a, b)
4171  a, b = _coerce_exprs(a, b)
4172  return BoolRef(Z3_mk_bvsub_no_underflow(a.ctx_ref(), a.as_ast(), b.as_ast(), signed), a.ctx)
def BVSubNoUnderflow
Definition: z3py.py:4167
Z3_ast Z3_API Z3_mk_bvsub_no_underflow(Z3_context c, Z3_ast t1, Z3_ast t2, bool is_signed)
Create a predicate that checks that the bit-wise subtraction of t1 and t2 does not underflow...
def z3py.Cbrt (   a,
  ctx = None 
)
Return a Z3 expression which represents the cubic root of a.

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

Definition at line 3155 of file z3py.py.

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

Definition at line 10337 of file z3py.py.

10338 def Complement(re):
10339  """Create the complement regular expression."""
10340  return ReRef(Z3_mk_re_complement(re.ctx_ref(), re.as_ast()), re.ctx)
def Complement
Definition: z3py.py:10337
Z3_ast Z3_API Z3_mk_re_complement(Z3_context c, Z3_ast re)
Create the complement of the regular language re.
def z3py.Concat (   args)
Create a Z3 bit-vector concatenation expression.

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

Definition at line 3796 of file z3py.py.

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

3797 def Concat(*args):
3798  """Create a Z3 bit-vector concatenation expression.
3799 
3800  >>> v = BitVecVal(1, 4)
3801  >>> Concat(v, v+1, v)
3802  Concat(Concat(1, 1 + 1), 1)
3803  >>> simplify(Concat(v, v+1, v))
3804  289
3805  >>> print("%.3x" % simplify(Concat(v, v+1, v)).as_long())
3806  121
3807  """
3808  args = _get_args(args)
3809  sz = len(args)
3810  if z3_debug():
3811  _z3_assert(sz >= 2, "At least two arguments expected.")
3812 
3813  ctx = None
3814  for a in args:
3815  if is_expr(a):
3816  ctx = a.ctx
3817  break
3818  if is_seq(args[0]) or isinstance(args[0], str):
3819  args = [_coerce_seq(s, ctx) for s in args]
3820  if z3_debug():
3821  _z3_assert(all([is_seq(a) for a in args]), "All arguments must be sequence expressions.")
3822  v = (Ast * sz)()
3823  for i in range(sz):
3824  v[i] = args[i].as_ast()
3825  return SeqRef(Z3_mk_seq_concat(ctx.ref(), sz, v), ctx)
3826 
3827  if is_re(args[0]):
3828  if z3_debug():
3829  _z3_assert(all([is_re(a) for a in args]), "All arguments must be regular expressions.")
3830  v = (Ast * sz)()
3831  for i in range(sz):
3832  v[i] = args[i].as_ast()
3833  return ReRef(Z3_mk_re_concat(ctx.ref(), sz, v), ctx)
3834 
3835  if z3_debug():
3836  _z3_assert(all([is_bv(a) for a in args]), "All arguments must be Z3 bit-vector expressions.")
3837  r = args[0]
3838  for i in range(sz - 1):
3839  r = BitVecRef(Z3_mk_concat(ctx.ref(), r.as_ast(), args[i+1].as_ast()), ctx)
3840  return r
Z3_ast Z3_API Z3_mk_seq_concat(Z3_context c, unsigned n, Z3_ast const args[])
Concatenate sequences.
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3358
Z3_ast Z3_API Z3_mk_concat(Z3_context c, Z3_ast t1, Z3_ast t2)
Concatenate the given bit-vectors.
def is_seq
Definition: z3py.py:10012
Z3_ast Z3_API Z3_mk_re_concat(Z3_context c, unsigned n, Z3_ast const args[])
Create the concatenation of the regular languages.
def is_bv
Definition: z3py.py:3666
def Concat
Definition: z3py.py:3796
def is_expr
Definition: z3py.py:1105
def is_re
Definition: z3py.py:10260
def z3_debug
Definition: z3py.py:58
def z3py.Cond (   p,
  t1,
  t2,
  ctx = None 
)
Return a tactic that applies tactic `t1` to a goal if probe `p` evaluates to true, and `t2` otherwise.

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

Definition at line 8133 of file z3py.py.

Referenced by If().

8134 def Cond(p, t1, t2, ctx=None):
8135  """Return a tactic that applies tactic `t1` to a goal if probe `p` evaluates to true, and `t2` otherwise.
8136 
8137  >>> t = Cond(Probe('is-qfnra'), Tactic('qfnra'), Tactic('smt'))
8138  """
8139  p = _to_probe(p, ctx)
8140  t1 = _to_tactic(t1, ctx)
8141  t2 = _to_tactic(t2, ctx)
8142  return Tactic(Z3_tactic_cond(t1.ctx.ref(), p.probe, t1.tactic, t2.tactic), t1.ctx)
def Cond
Definition: z3py.py:8133
Z3_tactic Z3_API Z3_tactic_cond(Z3_context c, Z3_probe p, Z3_tactic t1, Z3_tactic t2)
Return a tactic that applies t1 to a given goal if the probe p evaluates to true, and t2 if p evaluat...
def z3py.Const (   name,
  sort 
)
Create a constant of the given sort.

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

Definition at line 1291 of file z3py.py.

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

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

`names` is a string containing the names of all constants to be created.
Blank spaces separate the names of different constants.

>>> x, y, z = Consts('x y z', IntSort())
>>> x + y + z
x + y + z

Definition at line 1302 of file z3py.py.

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

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

Definition at line 10131 of file z3py.py.

10132 def Contains(a, b):
10133  """Check if 'a' contains 'b'
10134  >>> s1 = Contains("abc", "ab")
10135  >>> simplify(s1)
10136  True
10137  >>> s2 = Contains("abc", "bc")
10138  >>> simplify(s2)
10139  True
10140  >>> x, y, z = Strings('x y z')
10141  >>> s3 = Contains(Concat(x,y,z), y)
10142  >>> simplify(s3)
10143  True
10144  """
10145  ctx = _get_ctx2(a, b)
10146  a = _coerce_seq(a, ctx)
10147  b = _coerce_seq(b, ctx)
10148  return BoolRef(Z3_mk_seq_contains(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
10149 
def Contains
Definition: z3py.py:10131
Z3_ast Z3_API Z3_mk_seq_contains(Z3_context c, Z3_ast container, Z3_ast containee)
Check if container contains containee.
def z3py.CreateDatatypes (   ds)
Create mutually recursive Z3 datatypes using 1 or more Datatype helper objects.

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

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

Definition at line 4762 of file z3py.py.

Referenced by Datatype.create().

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

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

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

Definition at line 627 of file z3py.py.

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

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

Definition at line 4417 of file z3py.py.

Referenced by is_default().

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

Definition at line 8063 of file z3py.py.

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

Definition at line 7872 of file z3py.py.

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

Definition at line 72 of file z3py.py.

72 
73 def disable_trace(msg):
74  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:72
def z3py.DisjointSum (   name,
  sorts,
  ctx = None 
)
Create a named tagged union sort base on a set of underlying sorts
Example:
    >>> sum, ((inject0, extract0), (inject1, extract1)) = DisjointSum("+", [IntSort(), StringSort()])

Definition at line 4962 of file z3py.py.

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

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

Definition at line 1260 of file z3py.py.

1261 def Distinct(*args):
1262  """Create a Z3 distinct expression.
1263 
1264  >>> x = Int('x')
1265  >>> y = Int('y')
1266  >>> Distinct(x, y)
1267  x != y
1268  >>> z = Int('z')
1269  >>> Distinct(x, y, z)
1270  Distinct(x, y, z)
1271  >>> simplify(Distinct(x, y, z))
1272  Distinct(x, y, z)
1273  >>> simplify(Distinct(x, y, z), blast_distinct=True)
1274  And(Not(x == y), Not(x == z), Not(y == z))
1275  """
1276  args = _get_args(args)
1277  ctx = _ctx_from_ast_arg_list(args)
1278  if z3_debug():
1279  _z3_assert(ctx is not None, "At least one of the arguments must be a Z3 expression")
1280  args = _coerce_expr_list(args, ctx)
1281  _args, sz = _to_ast_array(args)
1282  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]).
def Distinct
Definition: z3py.py:1260
def z3_debug
Definition: z3py.py:58
def z3py.Empty (   s)
Create the empty sequence of the given sort
>>> e = Empty(StringSort())
>>> e2 = StringVal("")
>>> print(e.eq(e2))
True
>>> e3 = Empty(SeqSort(IntSort()))
>>> print(e3)
Empty(Seq(Int))
>>> e4 = Empty(ReSort(SeqSort(IntSort())))
>>> print(e4)
Empty(ReSort(Seq(Int)))

Definition at line 10066 of file z3py.py.

10067 def Empty(s):
10068  """Create the empty sequence of the given sort
10069  >>> e = Empty(StringSort())
10070  >>> e2 = StringVal("")
10071  >>> print(e.eq(e2))
10072  True
10073  >>> e3 = Empty(SeqSort(IntSort()))
10074  >>> print(e3)
10075  Empty(Seq(Int))
10076  >>> e4 = Empty(ReSort(SeqSort(IntSort())))
10077  >>> print(e4)
10078  Empty(ReSort(Seq(Int)))
10079  """
10080  if isinstance(s, SeqSortRef):
10081  return SeqRef(Z3_mk_seq_empty(s.ctx_ref(), s.ast), s.ctx)
10082  if isinstance(s, ReSortRef):
10083  return ReRef(Z3_mk_re_empty(s.ctx_ref(), s.ast), s.ctx)
10084  raise Z3Exception("Non-sequence, non-regular expression sort passed to Empty")
Z3_ast Z3_API Z3_mk_re_empty(Z3_context c, Z3_sort re)
Create an empty regular expression of sort re.
Z3_ast Z3_API Z3_mk_seq_empty(Z3_context c, Z3_sort seq)
Create an empty sequence of the sequence sort seq.
def Empty
Definition: z3py.py:10066
def z3py.EmptySet (   s)
Create the empty set
>>> EmptySet(IntSort())
K(Int, False)

Definition at line 4552 of file z3py.py.

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

Definition at line 69 of file z3py.py.

69 
70 def enable_trace(msg):
71  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:69
def z3py.EnumSort (   name,
  values,
  ctx = None 
)
Return a new enumeration sort named `name` containing the given values.

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

Definition at line 4974 of file z3py.py.

Referenced by Context.mkEnumSort().

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

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

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

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


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

Definition at line 2044 of file z3py.py.

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

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

Definition at line 4502 of file z3py.py.

4503 def Ext(a, b):
4504  """Return extensionality index for one-dimensional arrays.
4505  >> a, b = Consts('a b', SetSort(IntSort()))
4506  >> Ext(a, b)
4507  Ext(a, b)
4508  """
4509  ctx = a.ctx
4510  if z3_debug():
4511  _z3_assert(is_array(a) and is_array(b), "arguments must be arrays")
4512  return _to_expr_ref(Z3_mk_array_ext(ctx.ref(), a.as_ast(), b.as_ast()), ctx)
Z3_ast Z3_API Z3_mk_array_ext(Z3_context c, Z3_ast arg1, Z3_ast arg2)
Create array extensionality index given two arrays with the same sort. The meaning is given by the ax...
def Ext
Definition: z3py.py:4502
def z3_debug
Definition: z3py.py:58
def is_array
Definition: z3py.py:4274
def z3py.Extract (   high,
  low,
  a 
)
Create a Z3 bit-vector extraction expression, or create a string extraction expression.

>>> x = BitVec('x', 8)
>>> Extract(6, 2, x)
Extract(6, 2, x)
>>> Extract(6, 2, x).sort()
BitVec(5)
>>> simplify(Extract(StringVal("abcd"),2,1))
"c"

Definition at line 3841 of file z3py.py.

3842 def Extract(high, low, a):
3843  """Create a Z3 bit-vector extraction expression, or create a string extraction expression.
3844 
3845  >>> x = BitVec('x', 8)
3846  >>> Extract(6, 2, x)
3847  Extract(6, 2, x)
3848  >>> Extract(6, 2, x).sort()
3849  BitVec(5)
3850  >>> simplify(Extract(StringVal("abcd"),2,1))
3851  "c"
3852  """
3853  if isinstance(high, str):
3854  high = StringVal(high)
3855  if is_seq(high):
3856  s = high
3857  offset, length = _coerce_exprs(low, a, s.ctx)
3858  return SeqRef(Z3_mk_seq_extract(s.ctx_ref(), s.as_ast(), offset.as_ast(), length.as_ast()), s.ctx)
3859  if z3_debug():
3860  _z3_assert(low <= high, "First argument must be greater than or equal to second argument")
3861  _z3_assert(_is_int(high) and high >= 0 and _is_int(low) and low >= 0, "First and second arguments must be non negative integers")
3862  _z3_assert(is_bv(a), "Third argument must be a Z3 Bitvector expression")
3863  return BitVecRef(Z3_mk_extract(a.ctx_ref(), high, low, a.as_ast()), a.ctx)
def StringVal
Definition: z3py.py:10038
def is_seq
Definition: z3py.py:10012
def is_bv
Definition: z3py.py:3666
Z3_ast Z3_API Z3_mk_seq_extract(Z3_context c, Z3_ast s, Z3_ast offset, Z3_ast length)
Extract subsequence starting at offset of length.
def z3_debug
Definition: z3py.py:58
def Extract
Definition: z3py.py:3841
Z3_ast Z3_API Z3_mk_extract(Z3_context c, unsigned high, unsigned low, Z3_ast t1)
Extract the bits high down to low from a bit-vector of size m to yield a new bit-vector of size n...
def z3py.FailIf (   p,
  ctx = None 
)
Return a tactic that fails if the probe `p` evaluates to true. Otherwise, it returns the input goal unmodified.

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

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

Definition at line 8096 of file z3py.py.

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

Referenced by Context.mkFiniteDomainSort().

7189 def FiniteDomainSort(name, sz, ctx=None):
7190  """Create a named finite domain sort of a given size sz"""
7191  if not isinstance(name, Symbol):
7192  name = to_symbol(name)
7193  ctx = _get_ctx(ctx)
7194  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, uint64_t size)
Create a named finite domain sort.
def FiniteDomainSort
Definition: z3py.py:7188
def to_symbol
Definition: z3py.py:111
def z3py.FiniteDomainVal (   val,
  sort,
  ctx = None 
)
Return a Z3 finite-domain value. If `ctx=None`, then the global context is used.

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

Definition at line 7256 of file z3py.py.

7257 def FiniteDomainVal(val, sort, ctx=None):
7258  """Return a Z3 finite-domain value. If `ctx=None`, then the global context is used.
7259 
7260  >>> s = FiniteDomainSort('S', 256)
7261  >>> FiniteDomainVal(255, s)
7262  255
7263  >>> FiniteDomainVal('100', s)
7264  100
7265  """
7266  if z3_debug():
7267  _z3_assert(is_finite_domain_sort(sort), "Expected finite-domain sort" )
7268  ctx = sort.ctx
7269  return FiniteDomainNumRef(Z3_mk_numeral(ctx.ref(), _to_int_str(val), sort.ast), ctx)
def FiniteDomainVal
Definition: z3py.py:7256
def is_finite_domain_sort
Definition: z3py.py:7195
def z3_debug
Definition: z3py.py:58
Z3_ast Z3_API Z3_mk_numeral(Z3_context c, Z3_string numeral, Z3_sort ty)
Create a numeral of a given sort.
def z3py.Float128 (   ctx = None)
Floating-point 128-bit (quadruple) sort.

Definition at line 8720 of file z3py.py.

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

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

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

8701 def Float32(ctx=None):
8702  """Floating-point 32-bit (single) sort."""
8703  ctx = _get_ctx(ctx)
8704  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:8700
FP Sorts.
Definition: z3py.py:8655
def z3py.Float64 (   ctx = None)
Floating-point 64-bit (double) sort.

Definition at line 8710 of file z3py.py.

Referenced by fpFPToFP(), and fpToFP().

8711 def Float64(ctx=None):
8712  """Floating-point 64-bit (double) sort."""
8713  ctx = _get_ctx(ctx)
8714  return FPSortRef(Z3_mk_fpa_sort_64(ctx.ref()), ctx)
def Float64
Definition: z3py.py:8710
FP Sorts.
Definition: z3py.py:8655
Z3_sort Z3_API Z3_mk_fpa_sort_64(Z3_context c)
Create the double-precision (64-bit) FloatingPoint sort.
def z3py.FloatDouble (   ctx = None)
Floating-point 64-bit (double) sort.

Definition at line 8715 of file z3py.py.

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

8696 def FloatHalf(ctx=None):
8697  """Floating-point 16-bit (half) sort."""
8698  ctx = _get_ctx(ctx)
8699  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:8695
FP Sorts.
Definition: z3py.py:8655
def z3py.FloatQuadruple (   ctx = None)
Floating-point 128-bit (quadruple) sort.

Definition at line 8725 of file z3py.py.

8726 def FloatQuadruple(ctx=None):
8727  """Floating-point 128-bit (quadruple) sort."""
8728  ctx = _get_ctx(ctx)
8729  return FPSortRef(Z3_mk_fpa_sort_quadruple(ctx.ref()), ctx)
Z3_sort Z3_API Z3_mk_fpa_sort_quadruple(Z3_context c)
Create the quadruple-precision (128-bit) FloatingPoint sort.
def FloatQuadruple
Definition: z3py.py:8725
FP Sorts.
Definition: z3py.py:8655
def z3py.FloatSingle (   ctx = None)
Floating-point 32-bit (single) sort.

Definition at line 8705 of file z3py.py.

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

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

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

Definition at line 2027 of file z3py.py.

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

2028 def ForAll(vs, body, weight=1, qid="", skid="", patterns=[], no_patterns=[]):
2029  """Create a Z3 forall formula.
2030 
2031  The parameters `weight`, `qif`, `skid`, `patterns` and `no_patterns` are optional annotations.
2032 
2033  >>> f = Function('f', IntSort(), IntSort(), IntSort())
2034  >>> x = Int('x')
2035  >>> y = Int('y')
2036  >>> ForAll([x, y], f(x, y) >= x)
2037  ForAll([x, y], f(x, y) >= x)
2038  >>> ForAll([x, y], f(x, y) >= x, patterns=[ f(x, y) ])
2039  ForAll([x, y], f(x, y) >= x)
2040  >>> ForAll([x, y], f(x, y) >= x, weight=10)
2041  ForAll([x, y], f(x, y) >= x)
2042  """
2043  return _mk_quantifier(True, vs, body, weight, qid, skid, patterns, no_patterns)
def ForAll
Definition: z3py.py:2027
def z3py.FP (   name,
  fpsort,
  ctx = None 
)
Return a floating-point constant named `name`.
`fpsort` is the floating-point sort.
If `ctx=None`, then the global context is used.

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

Definition at line 9306 of file z3py.py.

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

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

>>> s = FPSort(8, 24)
>>> rm = RNE()
>>> x = FPVal(1.0, s)
>>> fpAbs(x)
fpAbs(1)
>>> y = FPVal(-20.0, s)
>>> y
-1.25*(2**4)
>>> fpAbs(y)
fpAbs(-1.25*(2**4))
>>> fpAbs(-1.25*(2**4))
fpAbs(-1.25*(2**4))
>>> fpAbs(x).sort()
FPSort(8, 24)

Definition at line 9347 of file z3py.py.

9348 def fpAbs(a, ctx=None):
9349  """Create a Z3 floating-point absolute value expression.
9350 
9351  >>> s = FPSort(8, 24)
9352  >>> rm = RNE()
9353  >>> x = FPVal(1.0, s)
9354  >>> fpAbs(x)
9355  fpAbs(1)
9356  >>> y = FPVal(-20.0, s)
9357  >>> y
9358  -1.25*(2**4)
9359  >>> fpAbs(y)
9360  fpAbs(-1.25*(2**4))
9361  >>> fpAbs(-1.25*(2**4))
9362  fpAbs(-1.25*(2**4))
9363  >>> fpAbs(x).sort()
9364  FPSort(8, 24)
9365  """
9366  ctx = _get_ctx(ctx)
9367  [a] = _coerce_fp_expr_list([a], ctx)
9368  return FPRef(Z3_mk_fpa_abs(ctx.ref(), a.as_ast()), ctx)
FP Expressions.
Definition: z3py.py:8756
Z3_ast Z3_API Z3_mk_fpa_abs(Z3_context c, Z3_ast t)
Floating-point absolute value.
def fpAbs
Definition: z3py.py:9347
def z3py.fpAdd (   rm,
  a,
  b,
  ctx = None 
)
Create a Z3 floating-point addition expression.

>>> s = FPSort(8, 24)
>>> rm = RNE()
>>> x = FP('x', s)
>>> y = FP('y', s)
>>> fpAdd(rm, x, y)
fpAdd(RNE(), x, y)
>>> fpAdd(RTZ(), x, y) # default rounding mode is RTZ
x + y
>>> fpAdd(rm, x, y).sort()
FPSort(8, 24)

Definition at line 9436 of file z3py.py.

Referenced by FPs().

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

>>> x_bv = BitVecVal(0x3F800000, 32)
>>> x_fp = fpBVToFP(x_bv, Float32())
>>> x_fp
fpToFP(1065353216)
>>> simplify(x_fp)
1

Definition at line 9733 of file z3py.py.

9734 def fpBVToFP(v, sort, ctx=None):
9735  """Create a Z3 floating-point conversion expression that represents the
9736  conversion from a bit-vector term to a floating-point term.
9737 
9738  >>> x_bv = BitVecVal(0x3F800000, 32)
9739  >>> x_fp = fpBVToFP(x_bv, Float32())
9740  >>> x_fp
9741  fpToFP(1065353216)
9742  >>> simplify(x_fp)
9743  1
9744  """
9745  _z3_assert(is_bv(v), "First argument must be a Z3 floating-point rounding mode expression.")
9746  _z3_assert(is_fp_sort(sort), "Second argument must be a Z3 floating-point sort.")
9747  ctx = _get_ctx(ctx)
9748  return FPRef(Z3_mk_fpa_to_fp_bv(ctx.ref(), v.ast, sort.ast), ctx)
FP Expressions.
Definition: z3py.py:8756
def is_bv
Definition: z3py.py:3666
Z3_ast Z3_API Z3_mk_fpa_to_fp_bv(Z3_context c, Z3_ast bv, Z3_sort s)
Conversion of a single IEEE 754-2008 bit-vector into a floating-point number.
def fpBVToFP
Definition: z3py.py:9733
def is_fp_sort
Definition: z3py.py:8734
def z3py.fpDiv (   rm,
  a,
  b,
  ctx = None 
)
Create a Z3 floating-point division expression.

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

Definition at line 9480 of file z3py.py.

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

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

Definition at line 9645 of file z3py.py.

Referenced by fpFP(), and fpNEQ().

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

Definition at line 9535 of file z3py.py.

9536 def fpFMA(rm, a, b, c, ctx=None):
9537  """Create a Z3 floating-point fused multiply-add expression.
9538  """
9539  return _mk_fp_tern(Z3_mk_fpa_fma, rm, a, b, c, ctx)
def fpFMA
Definition: z3py.py:9535
def z3py.fpFP (   sgn,
  exp,
  sig,
  ctx = None 
)
Create the Z3 floating-point value `fpFP(sgn, sig, exp)` from the three bit-vectors sgn, sig, and exp.

>>> s = FPSort(8, 24)
>>> x = fpFP(BitVecVal(1, 1), BitVecVal(2**7-1, 8), BitVecVal(2**22, 23))
>>> print(x)
fpFP(1, 127, 4194304)
>>> xv = FPVal(-1.5, s)
>>> print(xv)
-1.5
>>> slvr = Solver()
>>> slvr.add(fpEQ(x, xv))
>>> slvr.check()
sat
>>> xv = FPVal(+1.5, s)
>>> print(xv)
1.5
>>> slvr = Solver()
>>> slvr.add(fpEQ(x, xv))
>>> slvr.check()
unsat

Definition at line 9667 of file z3py.py.

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

>>> x_sgl = FPVal(1.0, Float32())
>>> x_dbl = fpFPToFP(RNE(), x_sgl, Float64())
>>> x_dbl
fpToFP(RNE(), 1)
>>> simplify(x_dbl)
1
>>> x_dbl.sort()
FPSort(11, 53)

Definition at line 9749 of file z3py.py.

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

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

Definition at line 9634 of file z3py.py.

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

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

Definition at line 9623 of file z3py.py.

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

Definition at line 9240 of file z3py.py.

9241 def fpInfinity(s, negative):
9242  """Create a Z3 floating-point +oo or -oo term."""
9243  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
9244  _z3_assert(isinstance(negative, bool), "expected Boolean flag")
9245  return FPNumRef(Z3_mk_fpa_inf(s.ctx_ref(), s.ast, negative), s.ctx)
def fpInfinity
Definition: z3py.py:9240
FP Numerals.
Definition: z3py.py:9000
Z3_ast Z3_API Z3_mk_fpa_inf(Z3_context c, Z3_sort s, bool negative)
Create a floating-point infinity of sort s.
def z3py.fpIsInf (   a,
  ctx = None 
)
Create a Z3 floating-point isInfinite expression.

>>> s = FPSort(8, 24)
>>> x = FP('x', s)
>>> fpIsInf(x)
fpIsInf(x)

Definition at line 9561 of file z3py.py.

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

>>> s = FPSort(8, 24)
>>> x = FP('x', s)
>>> y = FP('y', s)
>>> fpIsNaN(x)
fpIsNaN(x)

Definition at line 9550 of file z3py.py.

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

Definition at line 9586 of file z3py.py.

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

Definition at line 9576 of file z3py.py.

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

Definition at line 9591 of file z3py.py.

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

Definition at line 9581 of file z3py.py.

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

Definition at line 9571 of file z3py.py.

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

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

Definition at line 9612 of file z3py.py.

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

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

Definition at line 9601 of file z3py.py.

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

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

Definition at line 9521 of file z3py.py.

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

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

Definition at line 9507 of file z3py.py.

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

Definition at line 9235 of file z3py.py.

9236 def fpMinusInfinity(s):
9237  """Create a Z3 floating-point -oo term."""
9238  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
9239  return FPNumRef(Z3_mk_fpa_inf(s.ctx_ref(), s.ast, True), s.ctx)
def fpMinusInfinity
Definition: z3py.py:9235
FP Numerals.
Definition: z3py.py:9000
Z3_ast Z3_API Z3_mk_fpa_inf(Z3_context c, Z3_sort s, bool negative)
Create a floating-point infinity of sort s.
def z3py.fpMinusZero (   s)
Create a Z3 floating-point -0.0 term.

Definition at line 9251 of file z3py.py.

9252 def fpMinusZero(s):
9253  """Create a Z3 floating-point -0.0 term."""
9254  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
9255  return FPNumRef(Z3_mk_fpa_zero(s.ctx_ref(), s.ast, True), s.ctx)
def fpMinusZero
Definition: z3py.py:9251
FP Numerals.
Definition: z3py.py:9000
Z3_ast Z3_API Z3_mk_fpa_zero(Z3_context c, Z3_sort s, bool negative)
Create a floating-point zero of sort s.
def z3py.fpMul (   rm,
  a,
  b,
  ctx = None 
)
Create a Z3 floating-point multiplication expression.

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

Definition at line 9466 of file z3py.py.

Referenced by FPs().

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

>>> s = FPSort(8, 24)
>>> set_fpa_pretty(True)
>>> fpNaN(s)
NaN
>>> pb = get_fpa_pretty()
>>> set_fpa_pretty(False)
>>> fpNaN(s)
fpNaN(FPSort(8, 24))
>>> set_fpa_pretty(pb)

Definition at line 9203 of file z3py.py.

9204 def fpNaN(s):
9205  """Create a Z3 floating-point NaN term.
9206 
9207  >>> s = FPSort(8, 24)
9208  >>> set_fpa_pretty(True)
9209  >>> fpNaN(s)
9210  NaN
9211  >>> pb = get_fpa_pretty()
9212  >>> set_fpa_pretty(False)
9213  >>> fpNaN(s)
9214  fpNaN(FPSort(8, 24))
9215  >>> set_fpa_pretty(pb)
9216  """
9217  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
9218  return FPNumRef(Z3_mk_fpa_nan(s.ctx_ref(), s.ast), s.ctx)
FP Numerals.
Definition: z3py.py:9000
def fpNaN
Definition: z3py.py:9203
Z3_ast Z3_API Z3_mk_fpa_nan(Z3_context c, Z3_sort s)
Create a floating-point NaN of sort s.
def z3py.fpNeg (   a,
  ctx = None 
)
Create a Z3 floating-point addition expression.

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

Definition at line 9369 of file z3py.py.

9370 def fpNeg(a, ctx=None):
9371  """Create a Z3 floating-point addition expression.
9372 
9373  >>> s = FPSort(8, 24)
9374  >>> rm = RNE()
9375  >>> x = FP('x', s)
9376  >>> fpNeg(x)
9377  -x
9378  >>> fpNeg(x).sort()
9379  FPSort(8, 24)
9380  """
9381  ctx = _get_ctx(ctx)
9382  [a] = _coerce_fp_expr_list([a], ctx)
9383  return FPRef(Z3_mk_fpa_neg(ctx.ref(), a.as_ast()), ctx)
FP Expressions.
Definition: z3py.py:8756
Z3_ast Z3_API Z3_mk_fpa_neg(Z3_context c, Z3_ast t)
Floating-point negation.
def fpNeg
Definition: z3py.py:9369
def z3py.fpNEQ (   a,
  b,
  ctx = None 
)
Create the Z3 floating-point expression `Not(fpEQ(other, self))`.

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

Definition at line 9656 of file z3py.py.

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

>>> s = FPSort(8, 24)
>>> pb = get_fpa_pretty()
>>> set_fpa_pretty(True)
>>> fpPlusInfinity(s)
+oo
>>> set_fpa_pretty(False)
>>> fpPlusInfinity(s)
fpPlusInfinity(FPSort(8, 24))
>>> set_fpa_pretty(pb)

Definition at line 9219 of file z3py.py.

9220 def fpPlusInfinity(s):
9221  """Create a Z3 floating-point +oo term.
9222 
9223  >>> s = FPSort(8, 24)
9224  >>> pb = get_fpa_pretty()
9225  >>> set_fpa_pretty(True)
9226  >>> fpPlusInfinity(s)
9227  +oo
9228  >>> set_fpa_pretty(False)
9229  >>> fpPlusInfinity(s)
9230  fpPlusInfinity(FPSort(8, 24))
9231  >>> set_fpa_pretty(pb)
9232  """
9233  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
9234  return FPNumRef(Z3_mk_fpa_inf(s.ctx_ref(), s.ast, False), s.ctx)
FP Numerals.
Definition: z3py.py:9000
def fpPlusInfinity
Definition: z3py.py:9219
Z3_ast Z3_API Z3_mk_fpa_inf(Z3_context c, Z3_sort s, bool negative)
Create a floating-point infinity of sort s.
def z3py.fpPlusZero (   s)
Create a Z3 floating-point +0.0 term.

Definition at line 9246 of file z3py.py.

9247 def fpPlusZero(s):
9248  """Create a Z3 floating-point +0.0 term."""
9249  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
9250  return FPNumRef(Z3_mk_fpa_zero(s.ctx_ref(), s.ast, False), s.ctx)
def fpPlusZero
Definition: z3py.py:9246
FP Numerals.
Definition: z3py.py:9000
Z3_ast Z3_API Z3_mk_fpa_zero(Z3_context c, Z3_sort s, bool negative)
Create a floating-point zero of sort s.
def z3py.fpRealToFP (   rm,
  v,
  sort,
  ctx = None 
)
Create a Z3 floating-point conversion expression that represents the 
conversion from a real term to a floating-point term.

>>> x_r = RealVal(1.5)
>>> x_fp = fpRealToFP(RNE(), x_r, Float32())
>>> x_fp
fpToFP(RNE(), 3/2)
>>> simplify(x_fp)
1.5

Definition at line 9768 of file z3py.py.

9769 def fpRealToFP(rm, v, sort, ctx=None):
9770  """Create a Z3 floating-point conversion expression that represents the
9771  conversion from a real term to a floating-point term.
9772 
9773  >>> x_r = RealVal(1.5)
9774  >>> x_fp = fpRealToFP(RNE(), x_r, Float32())
9775  >>> x_fp
9776  fpToFP(RNE(), 3/2)
9777  >>> simplify(x_fp)
9778  1.5
9779  """
9780  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression.")
9781  _z3_assert(is_real(v), "Second argument must be a Z3 expression or real sort.")
9782  _z3_assert(is_fp_sort(sort), "Third argument must be a Z3 floating-point sort.")
9783  ctx = _get_ctx(ctx)
9784  return FPRef(Z3_mk_fpa_to_fp_real(ctx.ref(), rm.ast, v.ast, sort.ast), ctx)
FP Expressions.
Definition: z3py.py:8756
Z3_ast Z3_API Z3_mk_fpa_to_fp_real(Z3_context c, Z3_ast rm, Z3_ast t, Z3_sort s)
Conversion of a term of real sort into a term of FloatingPoint sort.
def fpRealToFP
Definition: z3py.py:9768
def is_fp_sort
Definition: z3py.py:8734
def is_real
Definition: z3py.py:2498
def is_fprm
Definition: z3py.py:8982
def z3py.fpRem (   a,
  b,
  ctx = None 
)
Create a Z3 floating-point remainder expression.

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

Definition at line 9494 of file z3py.py.

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

Definition at line 9545 of file z3py.py.

9546 def fpRoundToIntegral(rm, a, ctx=None):
9547  """Create a Z3 floating-point roundToIntegral expression.
9548  """
9549  return _mk_fp_unary(Z3_mk_fpa_round_to_integral, rm, a, ctx)
def fpRoundToIntegral
Definition: z3py.py:9545
def z3py.FPs (   names,
  fpsort,
  ctx = None 
)
Return an array of floating-point constants.

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

Definition at line 9329 of file z3py.py.

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

9330 def FPs(names, fpsort, ctx=None):
9331  """Return an array of floating-point constants.
9332 
9333  >>> x, y, z = FPs('x y z', FPSort(8, 24))
9334  >>> x.sort()
9335  FPSort(8, 24)
9336  >>> x.sbits()
9337  24
9338  >>> x.ebits()
9339  8
9340  >>> fpMul(RNE(), fpAdd(RNE(), x, y), z)
9341  fpMul(RNE(), fpAdd(RNE(), x, y), z)
9342  """
9343  ctx = _get_ctx(ctx)
9344  if isinstance(names, str):
9345  names = names.split(" ")
9346  return [FP(name, fpsort, ctx) for name in names]
def FP
Definition: z3py.py:9306
def FPs
Definition: z3py.py:9329
def z3py.fpSignedToFP (   rm,
  v,
  sort,
  ctx = None 
)
Create a Z3 floating-point conversion expression that represents the 
conversion from a signed bit-vector term (encoding an integer) to a floating-point term.

>>> x_signed = BitVecVal(-5, BitVecSort(32))
>>> x_fp = fpSignedToFP(RNE(), x_signed, Float32())
>>> x_fp
fpToFP(RNE(), 4294967291)
>>> simplify(x_fp)
-1.25*(2**2)

Definition at line 9785 of file z3py.py.

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

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

Definition at line 9145 of file z3py.py.

Referenced by FPRef.__add__(), FPRef.__div__(), FPRef.__mul__(), FPRef.__radd__(), FPRef.__rdiv__(), FPRef.__rmul__(), FPRef.__rsub__(), FPRef.__sub__(), FPSortRef.cast(), FPSortRef.ebits(), FPRef.ebits(), FPNumRef.exponent(), FP(), fpAbs(), fpAdd(), fpDiv(), fpEQ(), fpFP(), fpFPToFP(), fpGEQ(), fpGT(), fpIsInf(), fpIsNaN(), fpLEQ(), fpLT(), fpMax(), fpMin(), fpMul(), fpNaN(), fpNeg(), fpNEQ(), fpPlusInfinity(), fpRem(), FPs(), fpSub(), fpToFP(), fpToIEEEBV(), fpToReal(), fpToSBV(), fpToUBV(), FPVal(), is_fp(), is_fp_sort(), is_fp_value(), is_fprm_sort(), FPNumRef.isNegative(), Context.mkFPSort(), Context.mkFPSort128(), Context.mkFPSort16(), Context.mkFPSort32(), Context.mkFPSort64(), Context.mkFPSortDouble(), Context.mkFPSortHalf(), Context.mkFPSortQuadruple(), Context.mkFPSortSingle(), FPSortRef.sbits(), FPRef.sbits(), FPNumRef.sign_as_bv(), FPNumRef.significand(), FPNumRef.significand_as_bv(), and FPRef.sort().

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

Definition at line 9540 of file z3py.py.

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

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

Definition at line 9452 of file z3py.py.

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

From a bit-vector term in IEEE 754-2008 format:
>>> x = FPVal(1.0, Float32())
>>> x_bv = fpToIEEEBV(x)
>>> simplify(fpToFP(x_bv, Float32()))
1

From a floating-point term with different precision:
>>> x = FPVal(1.0, Float32())
>>> x_db = fpToFP(RNE(), x, Float64())
>>> x_db.sort()
FPSort(11, 53)

From a real term:
>>> x_r = RealVal(1.5)
>>> simplify(fpToFP(RNE(), x_r, Float32()))
1.5

From a signed bit-vector term:
>>> x_signed = BitVecVal(-5, BitVecSort(32))
>>> simplify(fpToFP(RNE(), x_signed, Float32()))
-1.25*(2**2)

Definition at line 9695 of file z3py.py.

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

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

Definition at line 9819 of file z3py.py.

Referenced by fpUnsignedToFP().

9820 def fpToFPUnsigned(rm, x, s, ctx=None):
9821  """Create a Z3 floating-point conversion expression, from unsigned bit-vector to floating-point expression."""
9822  if z3_debug():
9823  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
9824  _z3_assert(is_bv(x), "Second argument must be a Z3 bit-vector expression")
9825  _z3_assert(is_fp_sort(s), "Third argument must be Z3 floating-point sort")
9826  ctx = _get_ctx(ctx)
9827  return FPRef(Z3_mk_fpa_to_fp_unsigned(ctx.ref(), rm.ast, x.ast, s.ast), ctx)
FP Expressions.
Definition: z3py.py:8756
def is_bv
Definition: z3py.py:3666
def fpToFPUnsigned
Definition: z3py.py:9819
Z3_ast Z3_API Z3_mk_fpa_to_fp_unsigned(Z3_context c, Z3_ast rm, Z3_ast t, Z3_sort s)
Conversion of a 2's complement unsigned bit-vector term into a term of FloatingPoint sort...
def z3_debug
Definition: z3py.py:58
def is_fp_sort
Definition: z3py.py:8734
def is_fprm
Definition: z3py.py:8982
def z3py.fpToIEEEBV (   x,
  ctx = None 
)
\brief Conversion of a floating-point term into a bit-vector term in IEEE 754-2008 format.

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

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

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

Definition at line 9889 of file z3py.py.

Referenced by fpToFP().

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

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

Definition at line 9870 of file z3py.py.

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

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

Definition at line 9828 of file z3py.py.

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

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

Definition at line 9849 of file z3py.py.

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

>>> x_signed = BitVecVal(-5, BitVecSort(32))
>>> x_fp = fpUnsignedToFP(RNE(), x_signed, Float32())
>>> x_fp
fpToFPUnsigned(RNE(), 4294967291)
>>> simplify(x_fp)
1*(2**32)

Definition at line 9802 of file z3py.py.

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

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

Definition at line 9262 of file z3py.py.

Referenced by FPNumRef.exponent(), fpAbs(), fpFP(), fpFPToFP(), fpToFP(), is_fp_value(), FPNumRef.isNegative(), FPNumRef.sign_as_bv(), FPNumRef.significand(), and FPNumRef.significand_as_bv().

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

Definition at line 9256 of file z3py.py.

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

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

Definition at line 1316 of file z3py.py.

1317 def FreshConst(sort, prefix='c'):
1318  """Create a fresh constant of a specified sort"""
1319  ctx = _get_ctx(sort.ctx)
1320  return _to_expr_ref(Z3_mk_fresh_const(ctx.ref(), prefix, sort.ast), ctx)
def FreshConst
Definition: z3py.py:1316
Z3_ast Z3_API Z3_mk_fresh_const(Z3_context c, Z3_string prefix, Z3_sort ty)
Declare and create a fresh constant.
def z3py.FreshInt (   prefix = 'x',
  ctx = None 
)
Return a fresh integer constant in the given context using the given prefix.

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

Definition at line 3028 of file z3py.py.

3029 def FreshInt(prefix='x', ctx=None):
3030  """Return a fresh integer constant in the given context using the given prefix.
3031 
3032  >>> x = FreshInt()
3033  >>> y = FreshInt()
3034  >>> eq(x, y)
3035  False
3036  >>> x.sort()
3037  Int
3038  """
3039  ctx = _get_ctx(ctx)
3040  return ArithRef(Z3_mk_fresh_const(ctx.ref(), prefix, IntSort(ctx).ast), ctx)
def IntSort
Definition: z3py.py:2890
def FreshInt
Definition: z3py.py:3028
Z3_ast Z3_API Z3_mk_fresh_const(Z3_context c, Z3_string prefix, Z3_sort ty)
Declare and create a fresh constant.
def z3py.FreshReal (   prefix = 'b',
  ctx = None 
)
Return a fresh real constant in the given context using the given prefix.

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

Definition at line 3080 of file z3py.py.

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

Definition at line 10085 of file z3py.py.

10086 def Full(s):
10087  """Create the regular expression that accepts the universal language
10088  >>> e = Full(ReSort(SeqSort(IntSort())))
10089  >>> print(e)
10090  Full(ReSort(Seq(Int)))
10091  >>> e1 = Full(ReSort(StringSort()))
10092  >>> print(e1)
10093  Full(ReSort(String))
10094  """
10095  if isinstance(s, ReSortRef):
10096  return ReRef(Z3_mk_re_full(s.ctx_ref(), s.ast), s.ctx)
10097  raise Z3Exception("Non-sequence, non-regular expression sort passed to Full")
10098 
def Full
Definition: z3py.py:10085
Z3_ast Z3_API Z3_mk_re_full(Z3_context c, Z3_sort re)
Create an universal regular expression of sort re.
def z3py.FullSet (   s)
Create the full set
>>> FullSet(IntSort())
K(Int, True)

Definition at line 4560 of file z3py.py.

4561 def FullSet(s):
4562  """Create the full set
4563  >>> FullSet(IntSort())
4564  K(Int, True)
4565  """
4566  ctx = s.ctx
4567  return ArrayRef(Z3_mk_full_set(ctx.ref(), s.ast), ctx)
Z3_ast Z3_API Z3_mk_full_set(Z3_context c, Z3_sort domain)
Create the full set.
def FullSet
Definition: z3py.py:4560
def z3py.Function (   name,
  sig 
)
Create a new Z3 uninterpreted function with the given sorts.

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

Definition at line 789 of file z3py.py.

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

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

Definition at line 6224 of file z3py.py.

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

Definition at line 8614 of file z3py.py.

8615 def get_default_fp_sort(ctx=None):
8616  return FPSort(_dflt_fpsort_ebits, _dflt_fpsort_sbits, ctx)
def get_default_fp_sort
Definition: z3py.py:8614
def FPSort
Definition: z3py.py:9145
def z3py.get_default_rounding_mode (   ctx = None)
Retrieves the global default rounding mode.

Definition at line 8587 of file z3py.py.

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

Definition at line 91 of file z3py.py.

91 
92 def get_full_version():
93  return Z3_get_full_version()
94 
95 # We use _z3_assert instead of the assert command because we want to
# produce nice error messages in Z3Py at rise4fun.com
Z3_string Z3_API Z3_get_full_version(void)
Return a string that fully describes the version of Z3 in use.
def get_full_version
Definition: z3py.py:91
def z3py.get_map_func (   a)
Return the function declaration associated with a Z3 map array expression.

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

Definition at line 4334 of file z3py.py.

4335 def get_map_func(a):
4336  """Return the function declaration associated with a Z3 map array expression.
4337 
4338  >>> f = Function('f', IntSort(), IntSort())
4339  >>> b = Array('b', IntSort(), IntSort())
4340  >>> a = Map(f, b)
4341  >>> eq(f, get_map_func(a))
4342  True
4343  >>> get_map_func(a)
4344  f
4345  >>> get_map_func(a)(0)
4346  f(0)
4347  """
4348  if z3_debug():
4349  _z3_assert(is_map(a), "Z3 array map expression expected.")
4350  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:651
def is_map
Definition: z3py.py:4311
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:4334
Z3_ast Z3_API Z3_get_decl_ast_parameter(Z3_context c, Z3_func_decl d, unsigned idx)
Return the expression value associated with an expression parameter.
def z3_debug
Definition: z3py.py:58
def z3py.get_param (   name)
Return the value of a Z3 global (or module) parameter

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

Definition at line 272 of file z3py.py.

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

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

Definition at line 83 of file z3py.py.

83 
84 def get_version():
85  major = ctypes.c_uint(0)
86  minor = ctypes.c_uint(0)
87  build = ctypes.c_uint(0)
88  rev = ctypes.c_uint(0)
89  Z3_get_version(major, minor, build, rev)
90  return (major.value, minor.value, build.value, rev.value)
def get_version
Definition: z3py.py:83
void Z3_API Z3_get_version(unsigned *major, unsigned *minor, unsigned *build_number, unsigned *revision_number)
Return Z3 version number information.
def z3py.get_version_string ( )

Definition at line 75 of file z3py.py.

75 
76 def get_version_string():
77  major = ctypes.c_uint(0)
78  minor = ctypes.c_uint(0)
79  build = ctypes.c_uint(0)
80  rev = ctypes.c_uint(0)
81  Z3_get_version(major, minor, build, rev)
82  return "%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:75
def z3py.help_simplify ( )
Return a string describing all options available for Z3 `simplify` procedure.

Definition at line 8173 of file z3py.py.

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

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

Definition at line 1238 of file z3py.py.

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

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

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

Definition at line 1611 of file z3py.py.

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

1612 def Implies(a, b, ctx=None):
1613  """Create a Z3 implies expression.
1614 
1615  >>> p, q = Bools('p q')
1616  >>> Implies(p, q)
1617  Implies(p, q)
1618  >>> simplify(Implies(p, q))
1619  Or(Not(p), q)
1620  """
1621  ctx = _get_ctx(_ctx_from_ast_arg_list([a, b], ctx))
1622  s = BoolSort(ctx)
1623  a = s.cast(a)
1624  b = s.cast(b)
1625  return BoolRef(Z3_mk_implies(ctx.ref(), a.as_ast(), b.as_ast()), ctx)
def BoolSort
Definition: z3py.py:1523
def Implies
Definition: z3py.py:1611
Z3_ast Z3_API Z3_mk_implies(Z3_context c, Z3_ast t1, Z3_ast t2)
Create an AST node representing t1 implies t2.
def z3py.IndexOf (   s,
  substr 
)

Definition at line 10164 of file z3py.py.

Referenced by IndexOf().

10165 def IndexOf(s, substr):
10166  return IndexOf(s, substr, IntVal(0))
def IndexOf
Definition: z3py.py:10164
def IntVal
Definition: z3py.py:2937
def z3py.IndexOf (   s,
  substr,
  offset 
)
Retrieve the index of substring within a string starting at a specified offset.
>>> simplify(IndexOf("abcabc", "bc", 0))
1
>>> simplify(IndexOf("abcabc", "bc", 2))
4

Definition at line 10167 of file z3py.py.

10168 def IndexOf(s, substr, offset):
10169  """Retrieve the index of substring within a string starting at a specified offset.
10170  >>> simplify(IndexOf("abcabc", "bc", 0))
10171  1
10172  >>> simplify(IndexOf("abcabc", "bc", 2))
10173  4
10174  """
10175  ctx = None
10176  if is_expr(offset):
10177  ctx = offset.ctx
10178  ctx = _get_ctx2(s, substr, ctx)
10179  s = _coerce_seq(s, ctx)
10180  substr = _coerce_seq(substr, ctx)
10181  if _is_int(offset):
10182  offset = IntVal(offset, ctx)
10183  return ArithRef(Z3_mk_seq_index(s.ctx_ref(), s.as_ast(), substr.as_ast(), offset.as_ast()), s.ctx)
def is_expr
Definition: z3py.py:1105
Z3_ast Z3_API Z3_mk_seq_index(Z3_context c, Z3_ast s, Z3_ast substr, Z3_ast offset)
Return index of first occurrence of substr in s starting from offset offset. If s does not contain su...
def IndexOf
Definition: z3py.py:10164
def IntVal
Definition: z3py.py:2937
def z3py.InRe (   s,
  re 
)
Create regular expression membership test
>>> re = Union(Re("a"),Re("b"))
>>> print (simplify(InRe("a", re)))
True
>>> print (simplify(InRe("b", re)))
True
>>> print (simplify(InRe("c", re)))
False

Definition at line 10264 of file z3py.py.

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

10265 def InRe(s, re):
10266  """Create regular expression membership test
10267  >>> re = Union(Re("a"),Re("b"))
10268  >>> print (simplify(InRe("a", re)))
10269  True
10270  >>> print (simplify(InRe("b", re)))
10271  True
10272  >>> print (simplify(InRe("c", re)))
10273  False
10274  """
10275  s = _coerce_seq(s, re.ctx)
10276  return BoolRef(Z3_mk_seq_in_re(s.ctx_ref(), s.as_ast(), re.as_ast()), s.ctx)
def InRe
Definition: z3py.py:10264
Z3_ast Z3_API Z3_mk_seq_in_re(Z3_context c, Z3_ast seq, Z3_ast re)
Check if seq is in the language generated by the regular expression re.
def z3py.Int (   name,
  ctx = None 
)
Return an integer constant named `name`. If `ctx=None`, then the global context is used.

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

Definition at line 2993 of file z3py.py.

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

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

Definition at line 3715 of file z3py.py.

3716 def Int2BV(a, num_bits):
3717  """Return the z3 expression Int2BV(a, num_bits).
3718  It is a bit-vector of width num_bits and represents the
3719  modulo of a by 2^num_bits
3720  """
3721  ctx = a.ctx
3722  return BitVecRef(Z3_mk_int2bv(ctx.ref(), num_bits, a.as_ast()), ctx)
def Int2BV
Definition: z3py.py:3715
Z3_ast Z3_API Z3_mk_int2bv(Z3_context c, unsigned n, Z3_ast t1)
Create an n bit bit-vector from the integer argument t1.
def z3py.Intersect (   args)
Create intersection of regular expressions.
>>> re = Intersect(Re("a"), Re("b"), Re("c"))

Definition at line 10296 of file z3py.py.

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

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

Definition at line 3005 of file z3py.py.

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

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

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

Definition at line 2890 of file z3py.py.

Referenced by ArrayRef.__getitem__(), ModelRef.__getitem__(), ModelRef.__len__(), DatatypeSortRef.accessor(), FuncEntry.arg_value(), FuncInterp.arity(), Array(), ArraySort(), FuncEntry.as_list(), FuncInterp.as_list(), QuantifierRef.body(), ArithSortRef.cast(), QuantifierRef.children(), DatatypeSortRef.constructor(), Datatype.create(), CreateDatatypes(), Datatype.declare(), ModelRef.decls(), Default(), DisjointSum(), ArraySortRef.domain(), ArrayRef.domain(), FuncInterp.else_value(), Empty(), EmptySet(), FuncInterp.entry(), Exists(), Ext(), ForAll(), FreshInt(), Full(), FullSet(), ModelRef.get_interp(), get_map_func(), Context.getIntSort(), Int(), is_arith_sort(), is_array(), is_bv_sort(), is_const_array(), is_default(), QuantifierRef.is_exists(), QuantifierRef.is_forall(), is_fp_sort(), is_K(), QuantifierRef.is_lambda(), is_map(), is_pattern(), is_quantifier(), is_select(), is_store(), SeqSortRef.is_string(), IsMember(), IsSubset(), K(), Lambda(), Map(), Context.mkIntSort(), MultiPattern(), FuncEntry.num_args(), DatatypeSortRef.num_constructors(), FuncInterp.num_entries(), QuantifierRef.num_patterns(), QuantifierRef.num_vars(), QuantifierRef.pattern(), ArraySortRef.range(), ArrayRef.range(), DatatypeSortRef.recognizer(), Select(), SeqSort(), SetAdd(), SetComplement(), SetDel(), SetDifference(), SetIntersect(), SetUnion(), ArrayRef.sort(), Store(), TupleSort(), Update(), FuncEntry.value(), QuantifierRef.var_name(), QuantifierRef.var_sort(), and QuantifierRef.weight().

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

Definition at line 10218 of file z3py.py.

Referenced by StrToInt().

10219 def IntToStr(s):
10220  """Convert integer expression to string"""
10221  if not is_expr(s):
10222  s = _py2expr(s)
10223  return SeqRef(Z3_mk_int_to_str(s.ctx_ref(), s.as_ast()), s.ctx)
10224 
def IntToStr
Definition: z3py.py:10218
def is_expr
Definition: z3py.py:1105
Z3_ast Z3_API Z3_mk_int_to_str(Z3_context c, Z3_ast s)
Integer to string conversion.
def z3py.IntVal (   val,
  ctx = None 
)
Return a Z3 integer value. If `ctx=None`, then the global context is used.

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

Definition at line 2937 of file z3py.py.

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

2938 def IntVal(val, ctx=None):
2939  """Return a Z3 integer value. If `ctx=None`, then the global context is used.
2940 
2941  >>> IntVal(1)
2942  1
2943  >>> IntVal("100")
2944  100
2945  """
2946  ctx = _get_ctx(ctx)
2947  return IntNumRef(Z3_mk_numeral(ctx.ref(), _to_int_str(val), IntSort(ctx).ast), ctx)
def IntSort
Definition: z3py.py:2890
Z3_ast Z3_API Z3_mk_numeral(Z3_context c, Z3_string numeral, Z3_sort ty)
Create a numeral of a given sort.
def IntVal
Definition: z3py.py:2937
def z3py.IntVector (   prefix,
  sz,
  ctx = None 
)
Return a list of integer constants of size `sz`.

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

Definition at line 3017 of file z3py.py.

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

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

Definition at line 2579 of file z3py.py.

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

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

Definition at line 2566 of file z3py.py.

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

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

Definition at line 1459 of file z3py.py.

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

Note that, constants are function applications with 0 arguments.

>>> a = Int('a')
>>> is_app(a)
True
>>> is_app(a + 1)
True
>>> is_app(IntSort())
False
>>> is_app(1)
False
>>> is_app(IntVal(1))
True
>>> x = Int('x')
>>> is_app(ForAll(x, x >= 0))
False

Definition at line 1127 of file z3py.py.

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

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

>>> x = Int('x')
>>> n = x + 1
>>> is_app_of(n, Z3_OP_ADD)
True
>>> is_app_of(n, Z3_OP_MUL)
False

Definition at line 1226 of file z3py.py.

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

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

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

Definition at line 2460 of file z3py.py.

Referenced by is_algebraic_value().

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

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

Definition at line 2161 of file z3py.py.

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

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

Definition at line 4274 of file z3py.py.

Referenced by Default(), and Ext().

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

Definition at line 6220 of file z3py.py.

Referenced by get_as_array_func().

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

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

Definition at line 402 of file z3py.py.

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

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

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

Definition at line 1412 of file z3py.py.

Referenced by BoolSort(), and prove().

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

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

Definition at line 3666 of file z3py.py.

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

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

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

Definition at line 3205 of file z3py.py.

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

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

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

Definition at line 3679 of file z3py.py.

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

>>> a = Int('a')
>>> is_const(a)
True
>>> is_const(a + 1)
False
>>> is_const(1)
False
>>> is_const(IntVal(1))
True
>>> x = Int('x')
>>> is_const(ForAll(x, x >= 0))
False

Definition at line 1152 of file z3py.py.

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

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

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

Definition at line 4287 of file z3py.py.

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

Definition at line 4326 of file z3py.py.

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

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

Definition at line 1512 of file z3py.py.

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

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

Definition at line 2612 of file z3py.py.

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

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

Definition at line 1503 of file z3py.py.

Referenced by AstRef.__bool__().

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

>>> a = Int('a')
>>> is_expr(a)
True
>>> is_expr(a + 1)
True
>>> is_expr(IntSort())
False
>>> is_expr(1)
False
>>> is_expr(IntVal(1))
True
>>> x = Int('x')
>>> is_expr(ForAll(x, x >= 0))
True
>>> is_expr(FPVal(1.0))
True

Definition at line 1105 of file z3py.py.

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

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

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

Definition at line 1446 of file z3py.py.

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

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

>>> s = FiniteDomainSort('S', 100)
>>> b = Const('b', s)
>>> is_finite_domain(b)
True
>>> is_finite_domain(Int('x'))
False

Definition at line 7217 of file z3py.py.

Referenced by is_finite_domain_value().

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

>>> is_finite_domain_sort(FiniteDomainSort('S', 100))
True
>>> is_finite_domain_sort(IntSort())
False

Definition at line 7195 of file z3py.py.

Referenced by FiniteDomainVal().

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

>>> s = FiniteDomainSort('S', 100)
>>> b = Const('b', s)
>>> is_finite_domain_value(b)
False
>>> b = FiniteDomainVal(10, s)
>>> b
10
>>> is_finite_domain_value(b)
True

Definition at line 7270 of file z3py.py.

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

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

Definition at line 9118 of file z3py.py.

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

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

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

Definition at line 8734 of file z3py.py.

Referenced by fpBVToFP(), fpFPToFP(), fpRealToFP(), fpSignedToFP(), fpToFP(), fpToFPUnsigned(), fpUnsignedToFP(), and FPVal().

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

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

Definition at line 9131 of file z3py.py.

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

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

Definition at line 8982 of file z3py.py.

Referenced by fpFPToFP(), fpRealToFP(), fpSignedToFP(), fpToFP(), fpToFPUnsigned(), fpToSBV(), fpToUBV(), and fpUnsignedToFP().

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

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

Definition at line 8744 of file z3py.py.

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

Definition at line 8994 of file z3py.py.

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

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

Definition at line 777 of file z3py.py.

Referenced by prove().

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

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

Definition at line 2672 of file z3py.py.

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

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

Definition at line 2683 of file z3py.py.

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

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

Definition at line 2628 of file z3py.py.

Referenced by is_div().

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

>>> p, q = Bools('p q')
>>> is_implies(Implies(p, q))
True
>>> is_implies(And(p, q))
False

Definition at line 1481 of file z3py.py.

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

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

Definition at line 2480 of file z3py.py.

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

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

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

Definition at line 2522 of file z3py.py.

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

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

Definition at line 2694 of file z3py.py.

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

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

Definition at line 4299 of file z3py.py.

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

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

Definition at line 2650 of file z3py.py.

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

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

Definition at line 2661 of file z3py.py.

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

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

Definition at line 4311 of file z3py.py.

Referenced by get_map_func().

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

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

Definition at line 2639 of file z3py.py.

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

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

Definition at line 2590 of file z3py.py.

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

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

Definition at line 1492 of file z3py.py.

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

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

Definition at line 1470 of file z3py.py.

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

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

Definition at line 1751 of file z3py.py.

Referenced by MultiPattern().

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

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

Definition at line 8029 of file z3py.py.

Referenced by eq().

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

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

Definition at line 1980 of file z3py.py.

Referenced by Exists().

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

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

Definition at line 2545 of file z3py.py.

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

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

Definition at line 10260 of file z3py.py.

Referenced by Concat(), and Intersect().

10261 def is_re(s):
10262  return isinstance(s, ReRef)
10263 
def is_re
Definition: z3py.py:10260
def z3py.is_real (   a)
Return `True` if `a` is a real expression.

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

Definition at line 2498 of file z3py.py.

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

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

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

Definition at line 4518 of file z3py.py.

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

Definition at line 10012 of file z3py.py.

Referenced by Concat(), and Extract().

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

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

Definition at line 586 of file z3py.py.

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

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

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

Definition at line 4530 of file z3py.py.

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

Definition at line 10021 of file z3py.py.

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

Definition at line 10028 of file z3py.py.

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

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

Definition at line 2601 of file z3py.py.

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

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

Definition at line 2719 of file z3py.py.

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

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

Definition at line 2705 of file z3py.py.

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

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

Definition at line 1429 of file z3py.py.

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

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

Z3 uses de-Bruijn indices for representing bound variables in
quantifiers.

>>> x = Int('x')
>>> is_var(x)
False
>>> is_const(x)
True
>>> f = Function('f', IntSort(), IntSort())
>>> # Z3 replaces x with bound variables when ForAll is executed.
>>> q = ForAll(x, f(x) == x)
>>> b = q.body()
>>> b
f(Var(0)) == Var(0)
>>> b.arg(1)
Var(0)
>>> is_var(b.arg(1))
True

Definition at line 1170 of file z3py.py.

Referenced by get_var_index().

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

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

Definition at line 3127 of file z3py.py.

Referenced by is_is_int().

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

Definition at line 4631 of file z3py.py.

4632 def IsMember(e, s):
4633  """ Check if e is a member of set s
4634  >>> a = Const('a', SetSort(IntSort()))
4635  >>> IsMember(1, a)
4636  a[1]
4637  """
4638  ctx = _ctx_from_ast_arg_list([s,e])
4639  e = _py2expr(e, ctx)
4640  return BoolRef(Z3_mk_set_member(ctx.ref(), e.as_ast(), s.as_ast()), ctx)
def IsMember
Definition: z3py.py:4631
Z3_ast Z3_API Z3_mk_set_member(Z3_context c, Z3_ast elem, Z3_ast set)
Check for set membership.
def z3py.IsSubset (   a,
  b 
)
Check if a is a subset of b
>>> a = Const('a', SetSort(IntSort()))
>>> b = Const('b', SetSort(IntSort()))
>>> IsSubset(a, b)
subset(a, b)

Definition at line 4641 of file z3py.py.

4642 def IsSubset(a, b):
4643  """ Check if a is a subset of b
4644  >>> a = Const('a', SetSort(IntSort()))
4645  >>> b = Const('b', SetSort(IntSort()))
4646  >>> IsSubset(a, b)
4647  subset(a, b)
4648  """
4649  ctx = _ctx_from_ast_arg_list([a, b])
4650  return BoolRef(Z3_mk_set_subset(ctx.ref(), a.as_ast(), b.as_ast()), ctx)
4651 
Z3_ast Z3_API Z3_mk_set_subset(Z3_context c, Z3_ast arg1, Z3_ast arg2)
Check for subsetness of sets.
def IsSubset
Definition: z3py.py:4641
def z3py.K (   dom,
  v 
)
Return a Z3 constant array expression.

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

Definition at line 4481 of file z3py.py.

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

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

>>> f = Function('f', IntSort(), IntSort(), IntSort())
>>> mem0 = Array('mem0', IntSort(), IntSort())
>>> lo, hi, e, i = Ints('lo hi e i')
>>> mem1 = Lambda([i], If(And(lo <= i, i <= hi), e, mem0[i]))
>>> mem1
Lambda(i, If(And(lo <= i, i <= hi), e, mem0[i]))

Definition at line 2064 of file z3py.py.

Referenced by QuantifierRef.is_lambda().

2065 def Lambda(vs, body):
2066  """Create a Z3 lambda expression.
2067 
2068  >>> f = Function('f', IntSort(), IntSort(), IntSort())
2069  >>> mem0 = Array('mem0', IntSort(), IntSort())
2070  >>> lo, hi, e, i = Ints('lo hi e i')
2071  >>> mem1 = Lambda([i], If(And(lo <= i, i <= hi), e, mem0[i]))
2072  >>> mem1
2073  Lambda(i, If(And(lo <= i, i <= hi), e, mem0[i]))
2074  """
2075  ctx = body.ctx
2076  if is_app(vs):
2077  vs = [vs]
2078  num_vars = len(vs)
2079  _vs = (Ast * num_vars)()
2080  for i in range(num_vars):
2081  ## TODO: Check if is constant
2082  _vs[i] = vs[i].as_ast()
2083  return QuantifierRef(Z3_mk_lambda_const(ctx.ref(), num_vars, _vs, body.as_ast()), ctx)
def Lambda
Definition: z3py.py:2064
Quantifiers.
Definition: z3py.py:1803
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3358
Z3_ast Z3_API Z3_mk_lambda_const(Z3_context c, unsigned num_bound, Z3_app const bound[], Z3_ast body)
Create a lambda expression using a list of constants that form the set of bound variables.
def is_app
Definition: z3py.py:1127
def z3py.LastIndexOf (   s,
  substr 
)
Retrieve the last index of substring within a string

Definition at line 10184 of file z3py.py.

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

Definition at line 10193 of file z3py.py.

10194 def Length(s):
10195  """Obtain the length of a sequence 's'
10196  >>> l = Length(StringVal("abc"))
10197  >>> simplify(l)
10198  3
10199  """
10200  s = _coerce_seq(s)
10201  return ArithRef(Z3_mk_seq_length(s.ctx_ref(), s.as_ast()), s.ctx)
Z3_ast Z3_API Z3_mk_seq_length(Z3_context c, Z3_ast s)
Return the length of the sequence s.
def Length
Definition: z3py.py:10193
def z3py.LinearOrder (   a,
  index 
)

Definition at line 10382 of file z3py.py.

10383 def LinearOrder(a, index):
10384  return FuncDeclRef(Z3_mk_linear_order(a.ctx_ref(), a.ast, index), a.ctx);
Function Declarations.
Definition: z3py.py:651
def LinearOrder
Definition: z3py.py:10382
Z3_func_decl Z3_API Z3_mk_linear_order(Z3_context c, Z3_sort a, unsigned id)
declare a and b are in linear order over a relation indexed by id.
def z3py.Loop (   re,
  lo,
  hi = 0 
)
Create the regular expression accepting between a lower and upper bound repetitions
>>> re = Loop(Re("a"), 1, 3)
>>> print(simplify(InRe("aa", re)))
True
>>> print(simplify(InRe("aaaa", re)))
False
>>> print(simplify(InRe("", re)))
False

Definition at line 10353 of file z3py.py.

10354 def Loop(re, lo, hi=0):
10355  """Create the regular expression accepting between a lower and upper bound repetitions
10356  >>> re = Loop(Re("a"), 1, 3)
10357  >>> print(simplify(InRe("aa", re)))
10358  True
10359  >>> print(simplify(InRe("aaaa", re)))
10360  False
10361  >>> print(simplify(InRe("", re)))
10362  False
10363  """
10364  return ReRef(Z3_mk_re_loop(re.ctx_ref(), re.as_ast(), lo, hi), re.ctx)
Z3_ast Z3_API Z3_mk_re_loop(Z3_context c, Z3_ast r, unsigned lo, unsigned hi)
Create a regular expression loop. The supplied regular expression r is repeated between lo and hi tim...
def Loop
Definition: z3py.py:10353
def z3py.LShR (   a,
  b 
)
Create the Z3 expression logical right shift.

Use the operator >> for the arithmetical right shift.

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

Definition at line 3996 of file z3py.py.

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

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

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

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

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

Definition at line 4459 of file z3py.py.

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

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

Definition at line 1659 of file z3py.py.

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

Definition at line 6216 of file z3py.py.

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

6217 def Model(ctx = None):
6218  ctx = _get_ctx(ctx)
6219  return ModelRef(Z3_mk_model(ctx.ref()), ctx)
Z3_model Z3_API Z3_mk_model(Z3_context c)
Create a fresh model object. It has reference count 0.
def Model
Definition: z3py.py:6216
def z3py.MultiPattern (   args)
Create a Z3 multi-pattern using the given expressions `*args`

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

Definition at line 1768 of file z3py.py.

1769 def MultiPattern(*args):
1770  """Create a Z3 multi-pattern using the given expressions `*args`
1771 
1772  >>> f = Function('f', IntSort(), IntSort())
1773  >>> g = Function('g', IntSort(), IntSort())
1774  >>> x = Int('x')
1775  >>> q = ForAll(x, f(x) != g(x), patterns = [ MultiPattern(f(x), g(x)) ])
1776  >>> q
1777  ForAll(x, f(x) != g(x))
1778  >>> q.num_patterns()
1779  1
1780  >>> is_pattern(q.pattern(0))
1781  True
1782  >>> q.pattern(0)
1783  MultiPattern(f(Var(0)), g(Var(0)))
1784  """
1785  if z3_debug():
1786  _z3_assert(len(args) > 0, "At least one argument expected")
1787  _z3_assert(all([ is_expr(a) for a in args ]), "Z3 expressions expected")
1788  ctx = args[0].ctx
1789  args, sz = _to_ast_array(args)
1790  return PatternRef(Z3_mk_pattern(ctx.ref(), sz, args), ctx)
Patterns.
Definition: z3py.py:1741
def is_expr
Definition: z3py.py:1105
def MultiPattern
Definition: z3py.py:1768
def z3_debug
Definition: z3py.py:58
Z3_pattern Z3_API Z3_mk_pattern(Z3_context c, unsigned num_patterns, Z3_ast const terms[])
Create a pattern for quantifier instantiation.
def z3py.Not (   a,
  ctx = None 
)
Create a Z3 not expression or probe.

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

Definition at line 1641 of file z3py.py.

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

1642 def Not(a, ctx=None):
1643  """Create a Z3 not expression or probe.
1644 
1645  >>> p = Bool('p')
1646  >>> Not(Not(p))
1647  Not(Not(p))
1648  >>> simplify(Not(Not(p)))
1649  p
1650  """
1651  ctx = _get_ctx(_ctx_from_ast_arg_list([a], ctx))
1652  if is_probe(a):
1653  # Not is also used to build probes
1654  return Probe(Z3_probe_not(ctx.ref(), a.probe), ctx)
1655  else:
1656  s = BoolSort(ctx)
1657  a = s.cast(a)
1658  return BoolRef(Z3_mk_not(ctx.ref(), a.as_ast()), ctx)
def Not
Definition: z3py.py:1641
def BoolSort
Definition: z3py.py:1523
def is_probe
Definition: z3py.py:8029
Z3_probe Z3_API Z3_probe_not(Z3_context x, Z3_probe p)
Return a probe that evaluates to "true" when p does not evaluate to true.
Z3_ast Z3_API Z3_mk_not(Z3_context c, Z3_ast a)
Create an AST node representing not(a).
def z3py.open_log (   fname)
Log interaction to a file. This function must be invoked immediately after init(). 

Definition at line 103 of file z3py.py.

104 def open_log(fname):
105  """Log interaction to a file. This function must be invoked immediately after init(). """
106  Z3_open_log(fname)
bool Z3_API Z3_open_log(Z3_string filename)
Log interaction to a file.
def open_log
Definition: z3py.py:103
def z3py.Option (   re)
Create the regular expression that optionally accepts the argument.
>>> re = Option(Re("a"))
>>> print(simplify(InRe("a", re)))
True
>>> print(simplify(InRe("", re)))
True
>>> print(simplify(InRe("aa", re)))
False

Definition at line 10325 of file z3py.py.

10326 def Option(re):
10327  """Create the regular expression that optionally accepts the argument.
10328  >>> re = Option(Re("a"))
10329  >>> print(simplify(InRe("a", re)))
10330  True
10331  >>> print(simplify(InRe("", re)))
10332  True
10333  >>> print(simplify(InRe("aa", re)))
10334  False
10335  """
10336  return ReRef(Z3_mk_re_option(re.ctx_ref(), re.as_ast()), re.ctx)
def Option
Definition: z3py.py:10325
Z3_ast Z3_API Z3_mk_re_option(Z3_context c, Z3_ast re)
Create the regular language [re].
def z3py.Or (   args)
Create a Z3 or-expression or or-probe.

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

Definition at line 1705 of file z3py.py.

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

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

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

Definition at line 7745 of file z3py.py.

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

Definition at line 7797 of file z3py.py.

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

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

Definition at line 7765 of file z3py.py.

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

This function is similar to parse_smt2_string().

Definition at line 8564 of file z3py.py.

8565 def parse_smt2_file(f, sorts={}, decls={}, ctx=None):
8566  """Parse a file in SMT 2.0 format using the given sorts and decls.
8567 
8568  This function is similar to parse_smt2_string().
8569  """
8570  ctx = _get_ctx(ctx)
8571  ssz, snames, ssorts = _dict2sarray(sorts, ctx)
8572  dsz, dnames, ddecls = _dict2darray(decls, ctx)
8573  return AstVector(Z3_parse_smtlib2_file(ctx.ref(), f, ssz, snames, ssorts, dsz, dnames, ddecls), ctx)
8574 
Z3_ast_vector Z3_API Z3_parse_smtlib2_file(Z3_context c, Z3_string file_name, unsigned num_sorts, Z3_symbol const sort_names[], Z3_sort const sorts[], unsigned num_decls, Z3_symbol const decl_names[], Z3_func_decl const decls[])
Similar to Z3_parse_smtlib2_string, but reads the benchmark from a file.
def parse_smt2_file
Definition: z3py.py:8564
def z3py.parse_smt2_string (   s,
  sorts = {},
  decls = {},
  ctx = None 
)
Parse a string in SMT 2.0 format using the given sorts and decls.

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

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

Definition at line 8544 of file z3py.py.

Referenced by parse_smt2_file().

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

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

Definition at line 7783 of file z3py.py.

Referenced by ParAndThen().

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

Definition at line 10379 of file z3py.py.

10380 def PartialOrder(a, index):
10381  return FuncDeclRef(Z3_mk_partial_order(a.ctx_ref(), a.ast, index), a.ctx);
Function Declarations.
Definition: z3py.py:651
def PartialOrder
Definition: z3py.py:10379
Z3_func_decl Z3_API Z3_mk_partial_order(Z3_context c, Z3_sort a, unsigned id)
create a partial ordering relation over signature a and index id.
def z3py.PbEq (   args,
  k,
  ctx = None 
)
Create a Pseudo-Boolean inequality k constraint.

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

Definition at line 8351 of file z3py.py.

8352 def PbEq(args, k, ctx = None):
8353  """Create a Pseudo-Boolean inequality k constraint.
8354 
8355  >>> a, b, c = Bools('a b c')
8356  >>> f = PbEq(((a,1),(b,3),(c,2)), 3)
8357  """
8358  _z3_check_cint_overflow(k, "k")
8359  ctx, sz, _args, _coeffs = _pb_args_coeffs(args)
8360  return BoolRef(Z3_mk_pbeq(ctx.ref(), sz, _args, _coeffs, k), ctx)
8361 
Z3_ast Z3_API Z3_mk_pbeq(Z3_context c, unsigned num_args, Z3_ast const args[], int const coeffs[], int k)
Pseudo-Boolean relations.
def PbEq
Definition: z3py.py:8351
def z3py.PbGe (   args,
  k 
)
Create a Pseudo-Boolean inequality k constraint.

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

Definition at line 8341 of file z3py.py.

8342 def PbGe(args, k):
8343  """Create a Pseudo-Boolean inequality k constraint.
8344 
8345  >>> a, b, c = Bools('a b c')
8346  >>> f = PbGe(((a,1),(b,3),(c,2)), 3)
8347  """
8348  _z3_check_cint_overflow(k, "k")
8349  ctx, sz, _args, _coeffs = _pb_args_coeffs(args)
8350  return BoolRef(Z3_mk_pbge(ctx.ref(), sz, _args, _coeffs, k), ctx)
Z3_ast Z3_API Z3_mk_pbge(Z3_context c, unsigned num_args, Z3_ast const args[], int const coeffs[], int k)
Pseudo-Boolean relations.
def PbGe
Definition: z3py.py:8341
def z3py.PbLe (   args,
  k 
)
Create a Pseudo-Boolean inequality k constraint.

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

Definition at line 8331 of file z3py.py.

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

Definition at line 10388 of file z3py.py.

10389 def PiecewiseLinearOrder(a, index):
10390  return FuncDeclRef(Z3_mk_piecewise_linear_order(a.ctx_ref(), a.ast, index), a.ctx);
Function Declarations.
Definition: z3py.py:651
Z3_func_decl Z3_API Z3_mk_piecewise_linear_order(Z3_context c, Z3_sort a, unsigned id)
create a piecewise linear ordering relation over signature a and index id.
def PiecewiseLinearOrder
Definition: z3py.py:10388
def z3py.Plus (   re)
Create the regular expression accepting one or more repetitions of argument.
>>> re = Plus(Re("a"))
>>> print(simplify(InRe("aa", re)))
True
>>> print(simplify(InRe("ab", re)))
False
>>> print(simplify(InRe("", re)))
False

Definition at line 10313 of file z3py.py.

10314 def Plus(re):
10315  """Create the regular expression accepting one or more repetitions of argument.
10316  >>> re = Plus(Re("a"))
10317  >>> print(simplify(InRe("aa", re)))
10318  True
10319  >>> print(simplify(InRe("ab", re)))
10320  False
10321  >>> print(simplify(InRe("", re)))
10322  False
10323  """
10324  return ReRef(Z3_mk_re_plus(re.ctx_ref(), re.as_ast()), re.ctx)
Z3_ast Z3_API Z3_mk_re_plus(Z3_context c, Z3_ast re)
Create the regular language re+.
def Plus
Definition: z3py.py:10313
def z3py.PrefixOf (   a,
  b 
)
Check if 'a' is a prefix of 'b'
>>> s1 = PrefixOf("ab", "abc")
>>> simplify(s1)
True
>>> s2 = PrefixOf("bc", "abc")
>>> simplify(s2)
False

Definition at line 10103 of file z3py.py.

10104 def PrefixOf(a, b):
10105  """Check if 'a' is a prefix of 'b'
10106  >>> s1 = PrefixOf("ab", "abc")
10107  >>> simplify(s1)
10108  True
10109  >>> s2 = PrefixOf("bc", "abc")
10110  >>> simplify(s2)
10111  False
10112  """
10113  ctx = _get_ctx2(a, b)
10114  a = _coerce_seq(a, ctx)
10115  b = _coerce_seq(b, ctx)
10116  return BoolRef(Z3_mk_seq_prefix(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
Z3_ast Z3_API Z3_mk_seq_prefix(Z3_context c, Z3_ast prefix, Z3_ast s)
Check if prefix is a prefix of s.
def PrefixOf
Definition: z3py.py:10103
def z3py.probe_description (   name,
  ctx = None 
)
Return a short description for the probe named `name`.

>>> d = probe_description('memory')

Definition at line 8055 of file z3py.py.

Referenced by describe_probes().

8056 def probe_description(name, ctx=None):
8057  """Return a short description for the probe named `name`.
8058 
8059  >>> d = probe_description('memory')
8060  """
8061  ctx = _get_ctx(ctx)
8062  return Z3_probe_get_descr(ctx.ref(), name)
def probe_description
Definition: z3py.py:8055
Z3_string Z3_API Z3_probe_get_descr(Z3_context c, Z3_string name)
Return a string containing a description of the probe with the given name.
def z3py.probes (   ctx = None)
Return a list of all available probes in Z3.

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

Definition at line 8045 of file z3py.py.

Referenced by describe_probes().

8046 def probes(ctx=None):
8047  """Return a list of all available probes in Z3.
8048 
8049  >>> l = probes()
8050  >>> l.count('memory') == 1
8051  True
8052  """
8053  ctx = _get_ctx(ctx)
8054  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.
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3358
def probes
Definition: z3py.py:8045
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 8253 of file z3py.py.

Referenced by BitVecs().

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

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

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

Definition at line 8419 of file z3py.py.

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

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

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

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

Definition at line 2981 of file z3py.py.

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

2982 def Q(a, b, ctx=None):
2983  """Return a Z3 rational a/b.
2984 
2985  If `ctx=None`, then the global context is used.
2986 
2987  >>> Q(3,5)
2988  3/5
2989  >>> Q(3,5).sort()
2990  Real
2991  """
2992  return simplify(RatVal(a, b))
def Q
Definition: z3py.py:2981
def simplify
Utils.
Definition: z3py.py:8149
def RatVal
Definition: z3py.py:2966
def z3py.Range (   lo,
  hi,
  ctx = None 
)
Create the range regular expression over two sequences of length 1
>>> range = Range("a","z")
>>> print(simplify(InRe("b", range)))
True
>>> print(simplify(InRe("bb", range)))
False

Definition at line 10365 of file z3py.py.

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

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

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

Definition at line 2966 of file z3py.py.

Referenced by Q().

2967 def RatVal(a, b, ctx=None):
2968  """Return a Z3 rational a/b.
2969 
2970  If `ctx=None`, then the global context is used.
2971 
2972  >>> RatVal(3,5)
2973  3/5
2974  >>> RatVal(3,5).sort()
2975  Real
2976  """
2977  if z3_debug():
2978  _z3_assert(_is_int(a) or isinstance(a, str), "First argument cannot be converted into an integer")
2979  _z3_assert(_is_int(b) or isinstance(b, str), "Second argument cannot be converted into an integer")
2980  return simplify(RealVal(a, ctx)/RealVal(b, ctx))
def z3_debug
Definition: z3py.py:58
def simplify
Utils.
Definition: z3py.py:8149
def RealVal
Definition: z3py.py:2948
def RatVal
Definition: z3py.py:2966
def z3py.Re (   s,
  ctx = None 
)
The regular expression that accepts sequence 's'
>>> s1 = Re("ab")
>>> s2 = Re(StringVal("ab"))
>>> s3 = Re(Unit(BoolVal(True)))

Definition at line 10225 of file z3py.py.

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

10226 def Re(s, ctx=None):
10227  """The regular expression that accepts sequence 's'
10228  >>> s1 = Re("ab")
10229  >>> s2 = Re(StringVal("ab"))
10230  >>> s3 = Re(Unit(BoolVal(True)))
10231  """
10232  s = _coerce_seq(s, ctx)
10233  return ReRef(Z3_mk_seq_to_re(s.ctx_ref(), s.as_ast()), s.ctx)
10234 
10235 
10236 
def Re
Definition: z3py.py:10225
Z3_ast Z3_API Z3_mk_seq_to_re(Z3_context c, Z3_ast seq)
Create a regular expression that accepts the sequence seq.
def z3py.Real (   name,
  ctx = None 
)
Return a real constant named `name`. If `ctx=None`, then the global context is used.

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

Definition at line 3041 of file z3py.py.

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

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

>>> x, y, z = Reals('x y z')
>>> Sum(x, y, z)
x + y + z
>>> Sum(x, y, z).sort()
Real

Definition at line 3053 of file z3py.py.

Referenced by is_div().

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

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

Definition at line 2906 of file z3py.py.

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

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

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

2949 def RealVal(val, ctx=None):
2950  """Return a Z3 real value.
2951 
2952  `val` may be a Python int, long, float or string representing a number in decimal or rational notation.
2953  If `ctx=None`, then the global context is used.
2954 
2955  >>> RealVal(1)
2956  1
2957  >>> RealVal(1).sort()
2958  Real
2959  >>> RealVal("3/5")
2960  3/5
2961  >>> RealVal("1.5")
2962  3/2
2963  """
2964  ctx = _get_ctx(ctx)
2965  return RatNumRef(Z3_mk_numeral(ctx.ref(), str(val), RealSort(ctx).ast), ctx)
def RealSort
Definition: z3py.py:2906
def RealVal
Definition: z3py.py:2948
Z3_ast Z3_API Z3_mk_numeral(Z3_context c, Z3_string numeral, Z3_sort ty)
Create a numeral of a given sort.
def z3py.RealVar (   idx,
  ctx = None 
)
Create a real free variable. Free variables are used to create quantified formulas.
They are also used to create polynomials.

>>> RealVar(0)
Var(0)

Definition at line 1333 of file z3py.py.

Referenced by RealVarVector().

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

>>> x0, x1, x2, x3 = RealVarVector(4)
>>> x2
Var(2)

Definition at line 1343 of file z3py.py.

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

>>> X = RealVector('x', 3)
>>> X
[x__0, x__1, x__2]
>>> Sum(X)
x__0 + x__1 + x__2
>>> Sum(X).sort()
Real

Definition at line 3067 of file z3py.py.

3068 def RealVector(prefix, sz, ctx=None):
3069  """Return a list of real constants of size `sz`.
3070 
3071  >>> X = RealVector('x', 3)
3072  >>> X
3073  [x__0, x__1, x__2]
3074  >>> Sum(X)
3075  x__0 + x__1 + x__2
3076  >>> Sum(X).sort()
3077  Real
3078  """
3079  return [ Real('%s__%s' % (prefix, i)) for i in range(sz) ]
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3358
def Real
Definition: z3py.py:3041
def RealVector
Definition: z3py.py:3067
def z3py.RecAddDefinition (   f,
  args,
  body 
)
Set the body of a recursive function.
   Recursive definitions are only unfolded during search.
>>> ctx = Context()
>>> fac = RecFunction('fac', IntSort(ctx), IntSort(ctx))
>>> n = Int('n', ctx)
>>> RecAddDefinition(fac, n, If(n == 0, 1, n*fac(n-1)))
>>> simplify(fac(5))
fac(5)
>>> s = Solver(ctx=ctx)
>>> s.add(fac(n) < 3)
>>> s.check()
sat
>>> s.model().eval(fac(5))
120

Definition at line 831 of file z3py.py.

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

Definition at line 814 of file z3py.py.

815 def RecFunction(name, *sig):
816  """Create a new Z3 recursive with the given sorts."""
817  sig = _get_args(sig)
818  if z3_debug():
819  _z3_assert(len(sig) > 0, "At least two arguments expected")
820  arity = len(sig) - 1
821  rng = sig[arity]
822  if z3_debug():
823  _z3_assert(is_sort(rng), "Z3 sort expected")
824  dom = (Sort * arity)()
825  for i in range(arity):
826  if z3_debug():
827  _z3_assert(is_sort(sig[i]), "Z3 sort expected")
828  dom[i] = sig[i].ast
829  ctx = rng.ctx
830  return FuncDeclRef(Z3_mk_rec_func_decl(ctx.ref(), to_symbol(name, ctx), arity, dom, rng.ast), ctx)
Function Declarations.
Definition: z3py.py:651
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3358
def RecFunction
Definition: z3py.py:814
def z3_debug
Definition: z3py.py:58
def is_sort
Definition: z3py.py:586
def to_symbol
Definition: z3py.py:111
Z3_func_decl Z3_API Z3_mk_rec_func_decl(Z3_context c, Z3_symbol s, unsigned domain_size, Z3_sort const domain[], Z3_sort range)
Declare a recursive function.
def z3py.Repeat (   t,
  max = 4294967295,
  ctx = None 
)
Return a tactic that keeps applying `t` until the goal is not modified anymore or the maximum number of iterations `max` is reached.

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

Definition at line 7827 of file z3py.py.

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

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

Definition at line 10150 of file z3py.py.

10151 def Replace(s, src, dst):
10152  """Replace the first occurrence of 'src' by 'dst' in 's'
10153  >>> r = Replace("aaa", "a", "b")
10154  >>> simplify(r)
10155  "baa"
10156  """
10157  ctx = _get_ctx2(dst, s)
10158  if ctx is None and is_expr(src):
10159  ctx = src.ctx
10160  src = _coerce_seq(src, ctx)
10161  dst = _coerce_seq(dst, ctx)
10162  s = _coerce_seq(s, ctx)
10163  return SeqRef(Z3_mk_seq_replace(src.ctx_ref(), s.as_ast(), src.as_ast(), dst.as_ast()), s.ctx)
def Replace
Definition: z3py.py:10150
Z3_ast Z3_API Z3_mk_seq_replace(Z3_context c, Z3_ast s, Z3_ast src, Z3_ast dst)
Replace the first occurrence of src with dst in s.
def is_expr
Definition: z3py.py:1105
def z3py.reset_params ( )
Reset all global (or module) parameters.

Definition at line 262 of file z3py.py.

263 def reset_params():
264  """Reset all global (or module) parameters.
265  """
def reset_params
Definition: z3py.py:262
void Z3_API Z3_global_param_reset_all(void)
Restore the value of all global (and module) parameters. This command will not affect already created...
def z3py.ReSort (   s)

Definition at line 10245 of file z3py.py.

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

10246 def ReSort(s):
10247  if is_ast(s):
10248  return ReSortRef(Z3_mk_re_sort(s.ctx.ref(), s.ast), s.ctx)
10249  if s is None or isinstance(s, Context):
10250  ctx = _get_ctx(s)
10251  return ReSortRef(Z3_mk_re_sort(ctx.ref(), Z3_mk_string_sort(ctx.ref())), s.ctx)
10252  raise Z3Exception("Regular expression sort constructor expects either a string or a context or no argument")
10253 
def is_ast
Definition: z3py.py:402
Regular expressions.
Definition: z3py.py:10239
Z3_sort Z3_API Z3_mk_string_sort(Z3_context c)
Create a sort for 8 bit strings.
def ReSort
Definition: z3py.py:10245
Z3_sort Z3_API Z3_mk_re_sort(Z3_context c, Z3_sort seq)
Create a regular expression sort out of a sequence sort.
def z3py.RNA (   ctx = None)

Definition at line 8954 of file z3py.py.

Referenced by get_default_rounding_mode().

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

Definition at line 8946 of file z3py.py.

Referenced by fpAbs(), fpAdd(), fpDiv(), fpFPToFP(), fpMax(), fpMin(), fpMul(), fpNeg(), fpRealToFP(), FPs(), fpSignedToFP(), fpSub(), fpToFP(), fpUnsignedToFP(), get_default_rounding_mode(), is_fprm(), and is_fprm_sort().

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

4028 def RotateLeft(a, b):
4029  """Return an expression representing `a` rotated to the left `b` times.
4030 
4031  >>> a, b = BitVecs('a b', 16)
4032  >>> RotateLeft(a, b)
4033  RotateLeft(a, b)
4034  >>> simplify(RotateLeft(a, 0))
4035  a
4036  >>> simplify(RotateLeft(a, 16))
4037  a
4038  """
4039  _check_bv_args(a, b)
4040  a, b = _coerce_exprs(a, b)
4041  return BitVecRef(Z3_mk_ext_rotate_left(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
def RotateLeft
Definition: z3py.py:4027
Z3_ast Z3_API Z3_mk_ext_rotate_left(Z3_context c, Z3_ast t1, Z3_ast t2)
Rotate bits of t1 to the left t2 times.
def z3py.RotateRight (   a,
  b 
)
Return an expression representing `a` rotated to the right `b` times.

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

Definition at line 4042 of file z3py.py.

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

Definition at line 8950 of file z3py.py.

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

Definition at line 8942 of file z3py.py.

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

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

Definition at line 8958 of file z3py.py.

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

Definition at line 8974 of file z3py.py.

8975 def RoundTowardZero(ctx=None):
8976  ctx = _get_ctx(ctx)
8977  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:8974
def z3py.RTN (   ctx = None)

Definition at line 8970 of file z3py.py.

Referenced by get_default_rounding_mode().

8971 def RTN(ctx=None):
8972  ctx = _get_ctx(ctx)
8973  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:8970
def z3py.RTP (   ctx = None)

Definition at line 8962 of file z3py.py.

Referenced by get_default_rounding_mode().

8963 def RTP(ctx=None):
8964  ctx = _get_ctx(ctx)
8965  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:8962
def z3py.RTZ (   ctx = None)

Definition at line 8978 of file z3py.py.

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

8979 def RTZ(ctx=None):
8980  ctx = _get_ctx(ctx)
8981  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:8978
def z3py.Select (   a,
  i 
)
Return a Z3 select array expression.

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

Definition at line 4444 of file z3py.py.

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

Definition at line 9950 of file z3py.py.

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

9951 def SeqSort(s):
9952  """Create a sequence sort over elements provided in the argument
9953  >>> s = SeqSort(IntSort())
9954  >>> s == Unit(IntVal(1)).sort()
9955  True
9956  """
9957  return SeqSortRef(Z3_mk_seq_sort(s.ctx_ref(), s.ast), s.ctx)
def SeqSort
Definition: z3py.py:9950
Strings, Sequences and Regular expressions.
Definition: z3py.py:9922
Z3_sort Z3_API Z3_mk_seq_sort(Z3_context c, Z3_sort s)
Create a sequence sort out of the sort for the elements.
def z3py.set_default_fp_sort (   ebits,
  sbits,
  ctx = None 
)

Definition at line 8617 of file z3py.py.

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

Definition at line 8601 of file z3py.py.

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

Definition at line 267 of file z3py.py.

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

>>> set_param(precision=10)

Definition at line 239 of file z3py.py.

Referenced by set_option().

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

Definition at line 4592 of file z3py.py.

4593 def SetAdd(s, e):
4594  """ Add element e to set s
4595  >>> a = Const('a', SetSort(IntSort()))
4596  >>> SetAdd(a, 1)
4597  Store(a, 1, True)
4598  """
4599  ctx = _ctx_from_ast_arg_list([s,e])
4600  e = _py2expr(e, ctx)
4601  return ArrayRef(Z3_mk_set_add(ctx.ref(), s.as_ast(), e.as_ast()), ctx)
Z3_ast Z3_API Z3_mk_set_add(Z3_context c, Z3_ast set, Z3_ast elem)
Add an element to a set.
def SetAdd
Definition: z3py.py:4592
def z3py.SetComplement (   s)
The complement of set s
>>> a = Const('a', SetSort(IntSort()))
>>> SetComplement(a)
complement(a)

Definition at line 4612 of file z3py.py.

4613 def SetComplement(s):
4614  """ The complement of set s
4615  >>> a = Const('a', SetSort(IntSort()))
4616  >>> SetComplement(a)
4617  complement(a)
4618  """
4619  ctx = s.ctx
4620  return ArrayRef(Z3_mk_set_complement(ctx.ref(), s.as_ast()), ctx)
def SetComplement
Definition: z3py.py:4612
Z3_ast Z3_API Z3_mk_set_complement(Z3_context c, Z3_ast arg)
Take the complement of a set.
def z3py.SetDel (   s,
  e 
)
Remove element e to set s
>>> a = Const('a', SetSort(IntSort()))
>>> SetDel(a, 1)
Store(a, 1, False)

Definition at line 4602 of file z3py.py.

4603 def SetDel(s, e):
4604  """ Remove element e to set s
4605  >>> a = Const('a', SetSort(IntSort()))
4606  >>> SetDel(a, 1)
4607  Store(a, 1, False)
4608  """
4609  ctx = _ctx_from_ast_arg_list([s,e])
4610  e = _py2expr(e, ctx)
4611  return ArrayRef(Z3_mk_set_del(ctx.ref(), s.as_ast(), e.as_ast()), ctx)
def SetDel
Definition: z3py.py:4602
Z3_ast Z3_API Z3_mk_set_del(Z3_context c, Z3_ast set, Z3_ast elem)
Remove an element to a set.
def z3py.SetDifference (   a,
  b 
)
The set difference of a and b
>>> a = Const('a', SetSort(IntSort()))
>>> b = Const('b', SetSort(IntSort()))
>>> SetDifference(a, b)
setminus(a, b)

Definition at line 4621 of file z3py.py.

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

Definition at line 4513 of file z3py.py.

4514 def SetHasSize(a, k):
4515  ctx = a.ctx
4516  k = _py2expr(k, ctx)
4517  return _to_expr_ref(Z3_mk_set_has_size(ctx.ref(), a.as_ast(), k.as_ast()), ctx)
def SetHasSize
Definition: z3py.py:4513
Z3_ast Z3_API Z3_mk_set_has_size(Z3_context c, Z3_ast set, Z3_ast k)
Create predicate that holds if Boolean array set has k elements set to true.
def z3py.SetIntersect (   args)
Take the union of sets
>>> a = Const('a', SetSort(IntSort()))
>>> b = Const('b', SetSort(IntSort()))
>>> SetIntersect(a, b)
intersection(a, b)

Definition at line 4580 of file z3py.py.

4581 def SetIntersect(*args):
4582  """ Take the union of sets
4583  >>> a = Const('a', SetSort(IntSort()))
4584  >>> b = Const('b', SetSort(IntSort()))
4585  >>> SetIntersect(a, b)
4586  intersection(a, b)
4587  """
4588  args = _get_args(args)
4589  ctx = _ctx_from_ast_arg_list(args)
4590  _args, sz = _to_ast_array(args)
4591  return ArrayRef(Z3_mk_set_intersect(ctx.ref(), sz, _args), ctx)
Z3_ast Z3_API Z3_mk_set_intersect(Z3_context c, unsigned num_args, Z3_ast const args[])
Take the intersection of a list of sets.
def SetIntersect
Definition: z3py.py:4580
def z3py.SetSort (   s)

Sets.

Create a set sort over element sort s

Definition at line 4548 of file z3py.py.

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

4549 def SetSort(s):
4550  """ Create a set sort over element sort s"""
4551  return ArraySort(s, BoolSort())
def BoolSort
Definition: z3py.py:1523
def SetSort
Sets.
Definition: z3py.py:4548
def ArraySort
Definition: z3py.py:4351
def z3py.SetUnion (   args)
Take the union of sets
>>> a = Const('a', SetSort(IntSort()))
>>> b = Const('b', SetSort(IntSort()))
>>> SetUnion(a, b)
union(a, b)

Definition at line 4568 of file z3py.py.

4569 def SetUnion(*args):
4570  """ Take the union of sets
4571  >>> a = Const('a', SetSort(IntSort()))
4572  >>> b = Const('b', SetSort(IntSort()))
4573  >>> SetUnion(a, b)
4574  union(a, b)
4575  """
4576  args = _get_args(args)
4577  ctx = _ctx_from_ast_arg_list(args)
4578  _args, sz = _to_ast_array(args)
4579  return ArrayRef(Z3_mk_set_union(ctx.ref(), sz, _args), ctx)
Z3_ast Z3_API Z3_mk_set_union(Z3_context c, unsigned num_args, Z3_ast const args[])
Take the union of a list of sets.
def SetUnion
Definition: z3py.py:4568
def z3py.SignExt (   n,
  a 
)
Return a bit-vector expression with `n` extra sign-bits.

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

Definition at line 4057 of file z3py.py.

4058 def SignExt(n, a):
4059  """Return a bit-vector expression with `n` extra sign-bits.
4060 
4061  >>> x = BitVec('x', 16)
4062  >>> n = SignExt(8, x)
4063  >>> n.size()
4064  24
4065  >>> n
4066  SignExt(8, x)
4067  >>> n.sort()
4068  BitVec(24)
4069  >>> v0 = BitVecVal(2, 2)
4070  >>> v0
4071  2
4072  >>> v0.size()
4073  2
4074  >>> v = simplify(SignExt(6, v0))
4075  >>> v
4076  254
4077  >>> v.size()
4078  8
4079  >>> print("%.x" % v.as_long())
4080  fe
4081  """
4082  if z3_debug():
4083  _z3_assert(_is_int(n), "First argument must be an integer")
4084  _z3_assert(is_bv(a), "Second argument must be a Z3 Bitvector expression")
4085  return BitVecRef(Z3_mk_sign_ext(a.ctx_ref(), n, a.as_ast()), a.ctx)
def SignExt
Definition: z3py.py:4057
def is_bv
Definition: z3py.py:3666
Z3_ast Z3_API Z3_mk_sign_ext(Z3_context c, unsigned i, Z3_ast t1)
Sign-extend of the given bit-vector to the (signed) equivalent bit-vector of size m+i...
def z3_debug
Definition: z3py.py:58
def z3py.SimpleSolver (   ctx = None)
Return a simple general purpose solver with limited amount of preprocessing.

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

Definition at line 6898 of file z3py.py.

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

6899 def SimpleSolver(ctx=None):
6900  """Return a simple general purpose solver with limited amount of preprocessing.
6901 
6902  >>> s = SimpleSolver()
6903  >>> x = Int('x')
6904  >>> s.add(x > 0)
6905  >>> s.check()
6906  sat
6907  """
6908  ctx = _get_ctx(ctx)
6909  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:6898
def z3py.simplify (   a,
  arguments,
  keywords 
)

Utils.

Simplify the expression `a` using the given options.

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

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

Definition at line 8149 of file z3py.py.

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

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

Definition at line 8177 of file z3py.py.

8178 def simplify_param_descrs():
8179  """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:8177
def main_ctx
Definition: z3py.py:213
def z3py.solve (   args,
  keywords 
)
Solve the constraints `*args`.

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

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

Definition at line 8362 of file z3py.py.

Referenced by BV2Int(), and IsInt().

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

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

Definition at line 8390 of file z3py.py.

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

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

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

Definition at line 6878 of file z3py.py.

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

>>> x = Real('x')
>>> Sqrt(x)
x**(1/2)

Definition at line 3143 of file z3py.py.

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

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

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

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

Definition at line 3976 of file z3py.py.

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

3977 def SRem(a, b):
3978  """Create the Z3 expression signed remainder.
3979 
3980  Use the operator % for signed modulus, and URem() for unsigned remainder.
3981 
3982  >>> x = BitVec('x', 32)
3983  >>> y = BitVec('y', 32)
3984  >>> SRem(x, y)
3985  SRem(x, y)
3986  >>> SRem(x, y).sort()
3987  BitVec(32)
3988  >>> (x % y).sexpr()
3989  '(bvsmod x y)'
3990  >>> SRem(x, y).sexpr()
3991  '(bvsrem x y)'
3992  """
3993  _check_bv_args(a, b)
3994  a, b = _coerce_exprs(a, b)
3995  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's complement signed remainder (sign follows dividend).
def SRem
Definition: z3py.py:3976
def z3py.Star (   re)
Create the regular expression accepting zero or more repetitions of argument.
>>> re = Star(Re("a"))
>>> print(simplify(InRe("aa", re)))
True
>>> print(simplify(InRe("ab", re)))
False
>>> print(simplify(InRe("", re)))
True

Definition at line 10341 of file z3py.py.

10342 def Star(re):
10343  """Create the regular expression accepting zero or more repetitions of argument.
10344  >>> re = Star(Re("a"))
10345  >>> print(simplify(InRe("aa", re)))
10346  True
10347  >>> print(simplify(InRe("ab", re)))
10348  False
10349  >>> print(simplify(InRe("", re)))
10350  True
10351  """
10352  return ReRef(Z3_mk_re_star(re.ctx_ref(), re.as_ast()), re.ctx)
Z3_ast Z3_API Z3_mk_re_star(Z3_context c, Z3_ast re)
Create the regular language re*.
def Star
Definition: z3py.py:10341
def z3py.Store (   a,
  i,
  v 
)
Return a Z3 store array expression.

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

Definition at line 4428 of file z3py.py.

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

4429 def Store(a, i, v):
4430  """Return a Z3 store array expression.
4431 
4432  >>> a = Array('a', IntSort(), IntSort())
4433  >>> i, v = Ints('i v')
4434  >>> s = Store(a, i, v)
4435  >>> s.sort()
4436  Array(Int, Int)
4437  >>> prove(s[i] == v)
4438  proved
4439  >>> j = Int('j')
4440  >>> prove(Implies(i != j, s[j] == a[j]))
4441  proved
4442  """
4443  return Update(a, i, v)
def Update
Definition: z3py.py:4396
def Store
Definition: z3py.py:4428
def z3py.String (   name,
  ctx = None 
)
Return a string constant named `name`. If `ctx=None`, then the global context is used.

>>> x = String('x')

Definition at line 10043 of file z3py.py.

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

10044 def String(name, ctx=None):
10045  """Return a string constant named `name`. If `ctx=None`, then the global context is used.
10046 
10047  >>> x = String('x')
10048  """
10049  ctx = _get_ctx(ctx)
10050  return SeqRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), StringSort(ctx).ast), ctx)
Z3_ast Z3_API Z3_mk_const(Z3_context c, Z3_symbol s, Z3_sort ty)
Declare and create a constant.
def String
Definition: z3py.py:10043
def to_symbol
Definition: z3py.py:111
def StringSort
Definition: z3py.py:9940
def z3py.Strings (   names,
  ctx = None 
)
Return a tuple of String constants. 

Definition at line 10059 of file z3py.py.

Referenced by Contains().

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

Definition at line 9940 of file z3py.py.

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

9941 def StringSort(ctx=None):
9942  """Create a string sort
9943  >>> s = StringSort()
9944  >>> print(s)
9945  String
9946  """
9947  ctx = _get_ctx(ctx)
9948  return SeqSortRef(Z3_mk_string_sort(ctx.ref()), ctx)
9949 
Z3_sort Z3_API Z3_mk_string_sort(Z3_context c)
Create a sort for 8 bit strings.
Strings, Sequences and Regular expressions.
Definition: z3py.py:9922
def StringSort
Definition: z3py.py:9940
def z3py.StringVal (   s,
  ctx = None 
)
create a string expression

Definition at line 10038 of file z3py.py.

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

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

Definition at line 10202 of file z3py.py.

10203 def StrToInt(s):
10204  """Convert string expression to integer
10205  >>> a = StrToInt("1")
10206  >>> simplify(1 == a)
10207  True
10208  >>> b = StrToInt("2")
10209  >>> simplify(1 == b)
10210  False
10211  >>> c = StrToInt(IntToStr(2))
10212  >>> simplify(1 == c)
10213  False
10214  """
10215  s = _coerce_seq(s)
10216  return ArithRef(Z3_mk_str_to_int(s.ctx_ref(), s.as_ast()), s.ctx)
10217 
Z3_ast Z3_API Z3_mk_str_to_int(Z3_context c, Z3_ast s)
Convert string to integer.
def StrToInt
Definition: z3py.py:10202
def z3py.SubSeq (   s,
  offset,
  length 
)
Extract substring or subsequence starting at offset

Definition at line 10055 of file z3py.py.

10056 def SubSeq(s, offset, length):
10057  """Extract substring or subsequence starting at offset"""
10058  return Extract(s, offset, length)
def SubSeq
Definition: z3py.py:10055
def Extract
Definition: z3py.py:3841
def z3py.substitute (   t,
  m 
)
Apply substitution m on t, m is a list of pairs of the form (from, to). Every occurrence in t of from is replaced with to.

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

Definition at line 8181 of file z3py.py.

8182 def substitute(t, *m):
8183  """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.
8184 
8185  >>> x = Int('x')
8186  >>> y = Int('y')
8187  >>> substitute(x + 1, (x, y + 1))
8188  y + 1 + 1
8189  >>> f = Function('f', IntSort(), IntSort())
8190  >>> substitute(f(x) + f(y), (f(x), IntVal(1)), (f(y), IntVal(1)))
8191  1 + 1
8192  """
8193  if isinstance(m, tuple):
8194  m1 = _get_args(m)
8195  if isinstance(m1, list) and all(isinstance(p, tuple) for p in m1):
8196  m = m1
8197  if z3_debug():
8198  _z3_assert(is_expr(t), "Z3 expression expected")
8199  _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.")
8200  num = len(m)
8201  _from = (Ast * num)()
8202  _to = (Ast * num)()
8203  for i in range(num):
8204  _from[i] = m[i][0].as_ast()
8205  _to[i] = m[i][1].as_ast()
8206  return _to_expr_ref(Z3_substitute(t.ctx.ref(), t.as_ast(), num, _from, _to), t.ctx)
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3358
Z3_ast Z3_API Z3_substitute(Z3_context c, Z3_ast a, unsigned num_exprs, Z3_ast const from[], Z3_ast const to[])
Substitute every occurrence of from[i] in a with to[i], for i smaller than num_exprs. The result is the new AST. The arrays from and to must have size num_exprs. For every i smaller than num_exprs, we must have that sort of from[i] must be equal to sort of to[i].
def is_expr
Definition: z3py.py:1105
def substitute
Definition: z3py.py:8181
def z3_debug
Definition: z3py.py:58
def eq
Definition: z3py.py:422
def z3py.substitute_vars (   t,
  m 
)
Substitute the free variables in t with the expression in m.

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

Definition at line 8207 of file z3py.py.

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

Definition at line 10051 of file z3py.py.

10052 def SubString(s, offset, length):
10053  """Extract substring or subsequence starting at offset"""
10054  return Extract(s, offset, length)
def SubString
Definition: z3py.py:10051
def Extract
Definition: z3py.py:3841
def z3py.SuffixOf (   a,
  b 
)
Check if 'a' is a suffix of 'b'
>>> s1 = SuffixOf("ab", "abc")
>>> simplify(s1)
False
>>> s2 = SuffixOf("bc", "abc")
>>> simplify(s2)
True

Definition at line 10117 of file z3py.py.

10118 def SuffixOf(a, b):
10119  """Check if 'a' is a suffix of 'b'
10120  >>> s1 = SuffixOf("ab", "abc")
10121  >>> simplify(s1)
10122  False
10123  >>> s2 = SuffixOf("bc", "abc")
10124  >>> simplify(s2)
10125  True
10126  """
10127  ctx = _get_ctx2(a, b)
10128  a = _coerce_seq(a, ctx)
10129  b = _coerce_seq(b, ctx)
10130  return BoolRef(Z3_mk_seq_suffix(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
Z3_ast Z3_API Z3_mk_seq_suffix(Z3_context c, Z3_ast suffix, Z3_ast s)
Check if suffix is a suffix of s.
def SuffixOf
Definition: z3py.py:10117
def z3py.Sum (   args)
Create the sum of the Z3 expressions.

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

Definition at line 8227 of file z3py.py.

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

8228 def Sum(*args):
8229  """Create the sum of the Z3 expressions.
8230 
8231  >>> a, b, c = Ints('a b c')
8232  >>> Sum(a, b, c)
8233  a + b + c
8234  >>> Sum([a, b, c])
8235  a + b + c
8236  >>> A = IntVector('a', 5)
8237  >>> Sum(A)
8238  a__0 + a__1 + a__2 + a__3 + a__4
8239  """
8240  args = _get_args(args)
8241  if len(args) == 0:
8242  return 0
8243  ctx = _ctx_from_ast_arg_list(args)
8244  if ctx is None:
8245  return _reduce(lambda a, b: a + b, args, 0)
8246  args = _coerce_expr_list(args, ctx)
8247  if is_bv(args[0]):
8248  return _reduce(lambda a, b: a + b, args, 0)
8249  else:
8250  _args, sz = _to_ast_array(args)
8251  return ArithRef(Z3_mk_add(ctx.ref(), sz, _args), ctx)
8252 
Z3_ast Z3_API Z3_mk_add(Z3_context c, unsigned num_args, Z3_ast const args[])
Create an AST node representing args[0] + ... + args[num_args-1].
def is_bv
Definition: z3py.py:3666
def Sum
Definition: z3py.py:8227
def z3py.tactic_description (   name,
  ctx = None 
)
Return a short description for the tactic named `name`.

>>> d = tactic_description('simplify')

Definition at line 7864 of file z3py.py.

Referenced by describe_tactics().

7865 def tactic_description(name, ctx=None):
7866  """Return a short description for the tactic named `name`.
7867 
7868  >>> d = tactic_description('simplify')
7869  """
7870  ctx = _get_ctx(ctx)
7871  return Z3_tactic_get_descr(ctx.ref(), name)
def tactic_description
Definition: z3py.py:7864
Z3_string Z3_API Z3_tactic_get_descr(Z3_context c, Z3_string name)
Return a string containing a description of the tactic with the given name.
def z3py.tactics (   ctx = None)
Return a list of all available tactics in Z3.

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

Definition at line 7854 of file z3py.py.

Referenced by describe_tactics().

7855 def tactics(ctx=None):
7856  """Return a list of all available tactics in Z3.
7857 
7858  >>> l = tactics()
7859  >>> l.count('simplify') == 1
7860  True
7861  """
7862  ctx = _get_ctx(ctx)
7863  return [ Z3_get_tactic_name(ctx.ref(), i) for i in range(Z3_get_num_tactics(ctx.ref())) ]
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3358
Z3_string Z3_API Z3_get_tactic_name(Z3_context c, unsigned i)
Return the name of the idx tactic.
unsigned Z3_API Z3_get_num_tactics(Z3_context c)
Return the number of builtin tactics available in Z3.
def tactics
Definition: z3py.py:7854
def z3py.Then (   ts,
  ks 
)
Return a tactic that applies the tactics in `*ts` in sequence. Shorthand for AndThen(*ts, **ks).

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

Definition at line 7733 of file z3py.py.

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

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

Definition at line 111 of file z3py.py.

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

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

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

Definition at line 3110 of file z3py.py.

Referenced by is_to_int().

3111 def ToInt(a):
3112  """ Return the Z3 expression ToInt(a).
3113 
3114  >>> x = Real('x')
3115  >>> x.sort()
3116  Real
3117  >>> n = ToInt(x)
3118  >>> n
3119  ToInt(x)
3120  >>> n.sort()
3121  Int
3122  """
3123  if z3_debug():
3124  _z3_assert(a.is_real(), "Z3 real expression expected.")
3125  ctx = a.ctx
3126  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:3110
def z3_debug
Definition: z3py.py:58
def z3py.ToReal (   a)
Return the Z3 expression ToReal(a).

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

Definition at line 3093 of file z3py.py.

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

3094 def ToReal(a):
3095  """ Return the Z3 expression ToReal(a).
3096 
3097  >>> x = Int('x')
3098  >>> x.sort()
3099  Int
3100  >>> n = ToReal(x)
3101  >>> n
3102  ToReal(x)
3103  >>> n.sort()
3104  Real
3105  """
3106  if z3_debug():
3107  _z3_assert(a.is_int(), "Z3 integer expression expected.")
3108  ctx = a.ctx
3109  return ArithRef(Z3_mk_int2real(ctx.ref(), a.as_ast()), ctx)
def ToReal
Definition: z3py.py:3093
Z3_ast Z3_API Z3_mk_int2real(Z3_context c, Z3_ast t1)
Coerce an integer to a real.
def z3_debug
Definition: z3py.py:58
def z3py.TransitiveClosure (   f)
Given a binary relation R, such that the two arguments have the same sort
create the transitive closure relation R+.
The transitive closure R+ is a new relation.

Definition at line 10391 of file z3py.py.

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

Definition at line 10385 of file z3py.py.

10386 def TreeOrder(a, index):
10387  return FuncDeclRef(Z3_mk_tree_order(a.ctx_ref(), a.ast, index), a.ctx);
Function Declarations.
Definition: z3py.py:651
def TreeOrder
Definition: z3py.py:10385
Z3_func_decl Z3_API Z3_mk_tree_order(Z3_context c, Z3_sort a, unsigned id)
create a tree ordering lreation over signature a identified using index id.
def z3py.TryFor (   t,
  ms,
  ctx = None 
)
Return a tactic that applies `t` to a given goal for `ms` milliseconds.

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

Definition at line 7846 of file z3py.py.

7847 def TryFor(t, ms, ctx=None):
7848  """Return a tactic that applies `t` to a given goal for `ms` milliseconds.
7849 
7850  If `t` does not terminate in `ms` milliseconds, then it fails.
7851  """
7852  t = _to_tactic(t, ctx)
7853  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:7846
def z3py.TupleSort (   name,
  sorts,
  ctx = None 
)
Create a named tuple sort base on a set of underlying sorts
Example:
    >>> pair, mk_pair, (first, second) = TupleSort("pair", [IntSort(), StringSort()])

Definition at line 4951 of file z3py.py.

Referenced by Context.mkTupleSort().

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

Use the operator / for signed division.

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

Definition at line 3936 of file z3py.py.

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

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

Referenced by BitVecRef.__ge__().

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

Referenced by BitVecRef.__gt__().

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

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

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

Definition at line 3868 of file z3py.py.

Referenced by BitVecRef.__le__().

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

Referenced by BitVecRef.__lt__().

3886 def ULT(a, b):
3887  """Create the Z3 expression (unsigned) `other < self`.
3888 
3889  Use the operator < for signed less than.
3890 
3891  >>> x, y = BitVecs('x y', 32)
3892  >>> ULT(x, y)
3893  ULT(x, y)
3894  >>> (x < y).sexpr()
3895  '(bvslt x y)'
3896  >>> ULT(x, y).sexpr()
3897  '(bvult x y)'
3898  """
3899  _check_bv_args(a, b)
3900  a, b = _coerce_exprs(a, b)
3901  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:3885
def z3py.Union (   args)
Create union of regular expressions.
>>> re = Union(Re("a"), Re("b"), Re("c"))
>>> print (simplify(InRe("d", re)))
False

Definition at line 10277 of file z3py.py.

Referenced by InRe().

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

Definition at line 10099 of file z3py.py.

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

10100 def Unit(a):
10101  """Create a singleton sequence"""
10102  return SeqRef(Z3_mk_seq_unit(a.ctx_ref(), a.as_ast()), a.ctx)
def Unit
Definition: z3py.py:10099
Z3_ast Z3_API Z3_mk_seq_unit(Z3_context c, Z3_ast a)
Create a unit sequence of a.
def z3py.Update (   a,
  i,
  v 
)
Return a Z3 store array expression.

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

Definition at line 4396 of file z3py.py.

Referenced by Store().

4397 def Update(a, i, v):
4398  """Return a Z3 store array expression.
4399 
4400  >>> a = Array('a', IntSort(), IntSort())
4401  >>> i, v = Ints('i v')
4402  >>> s = Update(a, i, v)
4403  >>> s.sort()
4404  Array(Int, Int)
4405  >>> prove(s[i] == v)
4406  proved
4407  >>> j = Int('j')
4408  >>> prove(Implies(i != j, s[j] == a[j]))
4409  proved
4410  """
4411  if z3_debug():
4412  _z3_assert(is_array(a), "First argument must be a Z3 array expression")
4413  i = a.domain().cast(i)
4414  v = a.range().cast(v)
4415  ctx = a.ctx
4416  return _to_expr_ref(Z3_mk_store(ctx.ref(), a.as_ast(), i.as_ast(), v.as_ast()), ctx)
def Update
Definition: z3py.py:4396
Z3_ast Z3_API Z3_mk_store(Z3_context c, Z3_ast a, Z3_ast i, Z3_ast v)
Array update.
def z3_debug
Definition: z3py.py:58
def is_array
Definition: z3py.py:4274
def z3py.URem (   a,
  b 
)
Create the Z3 expression (unsigned) remainder `self % other`.

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

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

Definition at line 3956 of file z3py.py.

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

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

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

1322 def Var(idx, s):
1323  """Create a Z3 free variable. Free variables are used to create quantified formulas.
1324 
1325  >>> Var(0, IntSort())
1326  Var(0)
1327  >>> eq(Var(0, IntSort()), Var(0, BoolSort()))
1328  False
1329  """
1330  if z3_debug():
1331  _z3_assert(is_sort(s), "Z3 sort expected")
1332  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:1321
def z3_debug
Definition: z3py.py:58
def is_sort
Definition: z3py.py:586
def z3py.When (   p,
  t,
  ctx = None 
)
Return a tactic that applies tactic `t` only if probe `p` evaluates to true. Otherwise, it returns the input goal unmodified.

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

Definition at line 8115 of file z3py.py.

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

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

Definition at line 7801 of file z3py.py.

Referenced by Goal.prec().

7802 def With(t, *args, **keys):
7803  """Return a tactic that applies tactic `t` using the given configuration options.
7804 
7805  >>> x, y = Ints('x y')
7806  >>> t = With(Tactic('simplify'), som=True)
7807  >>> t((x + 1)*(y + 2) == 0)
7808  [[2*x + y + x*y == -2]]
7809  """
7810  ctx = keys.pop('ctx', None)
7811  t = _to_tactic(t, ctx)
7812  p = args2params(args, keys, t.ctx)
7813  return Tactic(Z3_tactic_using_params(t.ctx.ref(), t.tactic, p.params), t.ctx)
def With
Definition: z3py.py:7801
def args2params
Definition: z3py.py:5050
Z3_tactic Z3_API Z3_tactic_using_params(Z3_context c, Z3_tactic t, Z3_params p)
Return a tactic that applies t using the given set of parameters.
def z3py.WithParams (   t,
  p 
)
Return a tactic that applies tactic `t` using the given configuration options.

>>> x, y = Ints('x y')
>>> p = ParamsRef()
>>> p.set("som", True)
>>> t = WithParams(Tactic('simplify'), p)
>>> t((x + 1)*(y + 2) == 0)
[[2*x + y + x*y == -2]]

Definition at line 7814 of file z3py.py.

7815 def WithParams(t, p):
7816  """Return a tactic that applies tactic `t` using the given configuration options.
7817 
7818  >>> x, y = Ints('x y')
7819  >>> p = ParamsRef()
7820  >>> p.set("som", True)
7821  >>> t = WithParams(Tactic('simplify'), p)
7822  >>> t((x + 1)*(y + 2) == 0)
7823  [[2*x + y + x*y == -2]]
7824  """
7825  t = _to_tactic(t, None)
7826  return Tactic(Z3_tactic_using_params(t.ctx.ref(), t.tactic, p.params), t.ctx)
Z3_tactic Z3_API Z3_tactic_using_params(Z3_context c, Z3_tactic t, Z3_params p)
Return a tactic that applies t using the given set of parameters.
def WithParams
Definition: z3py.py:7814
def z3py.Xor (   a,
  b,
  ctx = None 
)
Create a Z3 Xor expression.

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

Definition at line 1626 of file z3py.py.

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

Definition at line 58 of file z3py.py.

Referenced by FuncDeclRef.__call__(), Probe.__call__(), Context.__init__(), And(), AndThen(), Tactic.apply(), ExprRef.arg(), args2params(), ArraySort(), AtLeast(), AtMost(), BV2Int(), BVRedAnd(), BVRedOr(), BVSNegNoOverflow(), SortRef.cast(), BoolSortRef.cast(), ExprRef.children(), Concat(), Const(), CreateDatatypes(), ExprRef.decl(), Default(), describe_probes(), Distinct(), FuncDeclRef.domain(), EnumSort(), AstRef.eq(), eq(), Ext(), Extract(), FiniteDomainVal(), fpToFPUnsigned(), fpToIEEEBV(), fpToReal(), fpToSBV(), fpToUBV(), Function(), get_as_array_func(), get_map_func(), get_var_index(), If(), Intersect(), is_sort(), IsInt(), K(), Map(), MultiPattern(), ExprRef.num_args(), Or(), OrElse(), Tactic.param_descrs(), ParOr(), ParThen(), prove(), RatVal(), RecFunction(), RepeatBitVec(), Select(), set_param(), SignExt(), simplify(), solve_using(), substitute(), substitute_vars(), ToInt(), ToReal(), AstRef.translate(), Union(), Update(), and Var().

58 
59 def z3_debug():
60  global Z3_DEBUG
61  return Z3_DEBUG
def z3_debug
Definition: z3py.py:58
def z3py.z3_error_handler (   c,
  e 
)

Definition at line 158 of file z3py.py.

159 def z3_error_handler(c, e):
160  # Do nothing error handler, just avoid exit(0)
161  # The wrappers in z3core.py will raise a Z3Exception if an error is detected
162  return
def z3_error_handler
Definition: z3py.py:158
def z3py.ZeroExt (   n,
  a 
)
Return a bit-vector expression with `n` extra zero-bits.

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

Definition at line 4086 of file z3py.py.

4087 def ZeroExt(n, a):
4088  """Return a bit-vector expression with `n` extra zero-bits.
4089 
4090  >>> x = BitVec('x', 16)
4091  >>> n = ZeroExt(8, x)
4092  >>> n.size()
4093  24
4094  >>> n
4095  ZeroExt(8, x)
4096  >>> n.sort()
4097  BitVec(24)
4098  >>> v0 = BitVecVal(2, 2)
4099  >>> v0
4100  2
4101  >>> v0.size()
4102  2
4103  >>> v = simplify(ZeroExt(6, v0))
4104  >>> v
4105  2
4106  >>> v.size()
4107  8
4108  """
4109  if z3_debug():
4110  _z3_assert(_is_int(n), "First argument must be an integer")
4111  _z3_assert(is_bv(a), "Second argument must be a Z3 Bitvector expression")
4112  return BitVecRef(Z3_mk_zero_ext(a.ctx_ref(), n, a.as_ast()), a.ctx)
def ZeroExt
Definition: z3py.py:4086
def is_bv
Definition: z3py.py:3666
def z3_debug
Definition: z3py.py:58
Z3_ast Z3_API Z3_mk_zero_ext(Z3_context c, unsigned i, Z3_ast t1)
Extend the given bit-vector with zeros to the (unsigned) equivalent bit-vector of size m+i...

Variable Documentation

int _dflt_fpsort_ebits = 11

Definition at line 8584 of file z3py.py.

int _dflt_fpsort_sbits = 53

Definition at line 8585 of file z3py.py.

_dflt_rounding_mode = Z3_OP_FPA_RM_TOWARD_ZERO

Floating-Point Arithmetic.

Definition at line 8583 of file z3py.py.

_main_ctx = None

Definition at line 212 of file z3py.py.

tuple sat = CheckSatResult(Z3_L_TRUE)

Definition at line 6405 of file z3py.py.

tuple unknown = CheckSatResult(Z3_L_UNDEF)

Definition at line 6407 of file z3py.py.

tuple unsat = CheckSatResult(Z3_L_FALSE)

Definition at line 6406 of file z3py.py.

Z3_DEBUG = __debug__

Definition at line 56 of file z3py.py.