Z3
Data Structures | Functions | Variables
z3py Namespace Reference

Data Structures

class  AlgebraicNumRef
 
class  ApplyResult
 
class  ArithRef
 
class  ArithSortRef
 Arithmetic. More...
 
class  ArrayRef
 
class  ArraySortRef
 Arrays. More...
 
class  AstMap
 
class  AstRef
 
class  AstVector
 
class  BitVecNumRef
 
class  BitVecRef
 
class  BitVecSortRef
 Bit-Vectors. More...
 
class  BoolRef
 
class  BoolSortRef
 Booleans. More...
 
class  CharRef
 
class  CharSortRef
 
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
 
class  FPRef
 
class  FPRMRef
 
class  FPRMSortRef
 
class  FPSortRef
 
class  FuncDeclRef
 Function Declarations. More...
 
class  FuncEntry
 
class  FuncInterp
 
class  Goal
 
class  IntNumRef
 
class  ModelRef
 
class  OnClause
 
class  Optimize
 
class  OptimizeObjective
 Optimize. More...
 
class  ParamDescrsRef
 
class  ParamsRef
 Parameter Sets. More...
 
class  ParserContext
 
class  PatternRef
 Patterns. More...
 
class  Probe
 
class  PropClosures
 
class  QuantifierRef
 Quantifiers. More...
 
class  RatNumRef
 
class  ReRef
 
class  ReSortRef
 
class  ScopedConstructor
 
class  ScopedConstructorList
 
class  SeqRef
 
class  SeqSortRef
 Strings, Sequences and Regular expressions. More...
 
class  Simplifier
 
class  Solver
 
class  SortRef
 
class  Statistics
 Statistics. More...
 
class  Tactic
 
class  TypeVarRef
 
class  UserPropagateBase
 
class  Z3PPObject
 ASTs base class. More...
 

Functions

def z3_debug ()
 
def enable_trace (msg)
 
def disable_trace (msg)
 
def get_version_string ()
 
def get_version ()
 
def get_full_version ()
 
def open_log (fname)
 
def append_log (s)
 
def to_symbol
 
def z3_error_handler (c, e)
 
def main_ctx ()
 
def get_ctx (ctx)
 
def set_param (args, kws)
 
def reset_params ()
 
def set_option (args, kws)
 
def get_param (name)
 
def is_ast
 
def eq
 
def is_sort
 
def DeclareSort
 
def DeclareTypeVar
 
def is_func_decl (a)
 
def Function (name, sig)
 
def FreshFunction (sig)
 
def RecFunction (name, sig)
 
def RecAddDefinition (f, args, body)
 
def deserialize (st)
 
def is_expr (a)
 
def is_app (a)
 
def is_const (a)
 
def is_var (a)
 
def get_var_index (a)
 
def is_app_of (a, k)
 
def If
 
def Distinct (args)
 
def Const (name, sort)
 
def Consts (names, sort)
 
def 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 (a)
 
def And (args)
 
def Or (args)
 
def is_pattern (a)
 
def MultiPattern (args)
 
def is_quantifier (a)
 
def ForAll
 
def Exists
 
def Lambda (vs, body)
 
def is_arith_sort
 
def is_arith (a)
 
def is_int (a)
 
def is_real (a)
 
def is_int_value (a)
 
def is_rational_value (a)
 
def is_algebraic_value (a)
 
def is_add
 
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 (a)
 
def ToInt (a)
 
def IsInt (a)
 
def Sqrt
 
def Cbrt
 
def is_bv_sort (s)
 
def is_bv (a)
 
def is_bv_value (a)
 
def BV2Int
 
def Int2BV (a, num_bits)
 
def BitVecSort
 
def BitVecVal
 
def BitVec
 
def BitVecs
 
def Concat (args)
 
def Extract (high, low, a)
 
def ULE (a, b)
 
def ULT (a, b)
 
def UGE (a, b)
 
def UGT (a, b)
 
def UDiv (a, b)
 
def URem (a, b)
 
def SRem (a, b)
 
def LShR (a, b)
 
def RotateLeft (a, b)
 
def RotateRight (a, b)
 
def SignExt (n, a)
 
def ZeroExt (n, a)
 
def RepeatBitVec (n, a)
 
def BVRedAnd (a)
 
def BVRedOr (a)
 
def BVAddNoOverflow (a, b, signed)
 
def BVAddNoUnderflow (a, b)
 
def BVSubNoOverflow (a, b)
 
def BVSubNoUnderflow (a, b, signed)
 
def BVSDivNoOverflow (a, b)
 
def BVSNegNoOverflow (a)
 
def BVMulNoOverflow (a, b, signed)
 
def BVMulNoUnderflow (a, b)
 
def is_array_sort (a)
 
def is_array
 
def is_const_array (a)
 
def is_K (a)
 
def is_map (a)
 
def is_default (a)
 
def get_map_func (a)
 
def ArraySort (sig)
 
def Array (name, sorts)
 
def Update (a, args)
 
def Default (a)
 
def Store (a, args)
 
def Select (a, args)
 
def Map (f, args)
 
def K (dom, v)
 
def Ext (a, b)
 
def is_select (a)
 
def is_store (a)
 
def SetSort (s)
 Sets. More...
 
def EmptySet (s)
 
def FullSet (s)
 
def SetUnion (args)
 
def SetIntersect (args)
 
def SetAdd (s, e)
 
def SetDel (s, e)
 
def SetComplement (s)
 
def SetDifference (a, b)
 
def IsMember (e, s)
 
def IsSubset (a, b)
 
def CreateDatatypes (ds)
 
def DatatypeSort
 
def TupleSort
 
def DisjointSum
 
def EnumSort
 
def args2params
 
def Model
 
def is_as_array (n)
 
def get_as_array_func (n)
 
def SolverFor
 
def SimpleSolver
 
def FiniteDomainSort
 
def is_finite_domain_sort (s)
 
def is_finite_domain (a)
 
def FiniteDomainVal
 
def is_finite_domain_value (a)
 
def AndThen (ts, ks)
 
def Then (ts, ks)
 
def OrElse (ts, ks)
 
def ParOr (ts, ks)
 
def ParThen
 
def ParAndThen
 
def With (t, args, keys)
 
def WithParams (t, p)
 
def Repeat
 
def TryFor
 
def tactics
 
def tactic_description
 
def describe_tactics ()
 
def is_probe (p)
 
def probes
 
def probe_description
 
def describe_probes ()
 
def FailIf
 
def When
 
def Cond
 
def simplify (a, arguments, keywords)
 Utils. More...
 
def help_simplify ()
 
def simplify_param_descrs ()
 
def substitute (t, m)
 
def substitute_vars (t, m)
 
def substitute_funs (t, m)
 
def Sum (args)
 
def Product (args)
 
def Abs (arg)
 
def AtMost (args)
 
def AtLeast (args)
 
def PbLe (args, k)
 
def PbGe (args, k)
 
def PbEq
 
def solve (args, keywords)
 
def solve_using (s, args, keywords)
 
def prove (claim, show=False, keywords)
 
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 (s)
 
def is_fprm_sort (s)
 
def RoundNearestTiesToEven
 
def RNE
 
def RoundNearestTiesToAway
 
def RNA
 
def RoundTowardPositive
 
def RTP
 
def RoundTowardNegative
 
def RTN
 
def RoundTowardZero
 
def RTZ
 
def is_fprm (a)
 
def is_fprm_value (a)
 
def is_fp (a)
 
def is_fp_value (a)
 
def FPSort
 
def fpNaN (s)
 
def fpPlusInfinity (s)
 
def fpMinusInfinity (s)
 
def fpInfinity (s, negative)
 
def fpPlusZero (s)
 
def fpMinusZero (s)
 
def fpZero (s, negative)
 
def FPVal
 
def FP
 
def FPs
 
def fpAbs
 
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 CharSort
 
def SeqSort (s)
 
def CharVal
 
def CharFromBv (bv)
 
def CharToBv
 
def CharToInt
 
def CharIsDigit
 
def is_seq (a)
 
def is_string
 
def is_string_value
 
def StringVal
 
def String
 
def Strings
 
def SubString (s, offset, length)
 
def SubSeq (s, offset, length)
 
def Empty (s)
 
def Full (s)
 
def Unit (a)
 
def PrefixOf (a, b)
 
def SuffixOf (a, b)
 
def Contains (a, b)
 
def Replace (s, src, dst)
 
def IndexOf
 
def LastIndexOf (s, substr)
 
def Length (s)
 
def SeqMap (f, s)
 
def SeqMapI (f, i, s)
 
def SeqFoldLeft (f, a, s)
 
def SeqFoldLeftI (f, i, a, s)
 
def StrToInt (s)
 
def IntToStr (s)
 
def StrToCode (s)
 
def StrFromCode (c)
 
def Re
 
def ReSort (s)
 
def is_re (s)
 
def InRe (s, re)
 
def Union (args)
 
def Intersect (args)
 
def Plus (re)
 
def Option (re)
 
def Complement (re)
 
def Star (re)
 
def Loop
 
def Range
 
def Diff
 
def AllChar
 
def PartialOrder (a, index)
 
def LinearOrder (a, index)
 
def TreeOrder (a, index)
 
def PiecewiseLinearOrder (a, index)
 
def TransitiveClosure (f)
 
def to_Ast (ptr)
 
def to_ContextObj (ptr)
 
def to_AstVectorObj (ptr)
 
def on_clause_eh (ctx, p, n, dep, clause)
 
def ensure_prop_closures ()
 
def user_prop_push (ctx, cb)
 
def user_prop_pop (ctx, cb, num_scopes)
 
def user_prop_fresh (ctx, _new_ctx)
 
def user_prop_fixed (ctx, cb, id, value)
 
def user_prop_created (ctx, cb, id)
 
def user_prop_final (ctx, cb)
 
def user_prop_eq (ctx, cb, x, y)
 
def user_prop_diseq (ctx, cb, x, y)
 
def user_prop_decide (ctx, cb, t_ref, idx, phase)
 
def user_prop_binding (ctx, cb, q_ref, inst_ref)
 
def PropagateFunction (name, sig)
 

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)
 
dictionary _on_models = {}
 
tuple _on_model_eh = on_model_eh_type(_global_on_model)
 
 _dflt_rounding_mode = Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN
 Floating-Point Arithmetic. More...
 
int _dflt_fpsort_ebits = 11
 
int _dflt_fpsort_sbits = 53
 
tuple _ROUNDING_MODES
 
 _my_hacky_class = None
 
tuple _on_clause_eh = Z3_on_clause_eh(on_clause_eh)
 
 _prop_closures = None
 
tuple _user_prop_push = Z3_push_eh(user_prop_push)
 
tuple _user_prop_pop = Z3_pop_eh(user_prop_pop)
 
tuple _user_prop_fresh = Z3_fresh_eh(user_prop_fresh)
 
tuple _user_prop_fixed = Z3_fixed_eh(user_prop_fixed)
 
tuple _user_prop_created = Z3_created_eh(user_prop_created)
 
tuple _user_prop_final = Z3_final_eh(user_prop_final)
 
tuple _user_prop_eq = Z3_eq_eh(user_prop_eq)
 
tuple _user_prop_diseq = Z3_eq_eh(user_prop_diseq)
 
tuple _user_prop_decide = Z3_decide_eh(user_prop_decide)
 
tuple _user_prop_binding = Z3_on_binding_eh(user_prop_binding)
 

Function Documentation

def z3py.Abs (   arg)
Create the absolute value of an arithmetic expression

Definition at line 9335 of file z3py.py.

Referenced by ArithRef.__abs__().

9335 def Abs(arg):
9336  """Create the absolute value of an arithmetic expression"""
9337  return If(arg > 0, arg, -arg)
9338 
9339 
def If
Definition: z3py.py:1484
def Abs(arg)
Definition: z3py.py:9335
def z3py.AllChar (   regex_sort,
  ctx = None 
)
Create a regular expression that accepts all single character strings

Definition at line 11772 of file z3py.py.

11772 def AllChar(regex_sort, ctx=None):
11773  """Create a regular expression that accepts all single character strings
11774  """
11775  return ReRef(Z3_mk_re_allchar(regex_sort.ctx_ref(), regex_sort.ast), regex_sort.ctx)
11776 
11777 # Special Relations
11778 
11779 
Z3_ast Z3_API Z3_mk_re_allchar(Z3_context c, Z3_sort regex_sort)
Create a regular expression that accepts all singleton sequences of the regular expression sort...
def AllChar
Definition: z3py.py:11772
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 1982 of file z3py.py.

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

1982 def And(*args):
1983  """Create a Z3 and-expression or and-probe.
1984 
1985  >>> p, q, r = Bools('p q r')
1986  >>> And(p, q, r)
1987  And(p, q, r)
1988  >>> P = BoolVector('p', 5)
1989  >>> And(P)
1990  And(p__0, p__1, p__2, p__3, p__4)
1991  """
1992  last_arg = None
1993  if len(args) > 0:
1994  last_arg = args[len(args) - 1]
1995  if isinstance(last_arg, Context):
1996  ctx = args[len(args) - 1]
1997  args = args[:len(args) - 1]
1998  elif len(args) == 1 and isinstance(args[0], AstVector):
1999  ctx = args[0].ctx
2000  args = [a for a in args[0]]
2001  else:
2002  ctx = None
2003  args = _get_args(args)
2004  ctx = _get_ctx(_ctx_from_ast_arg_list(args, ctx))
2005  if z3_debug():
2006  _z3_assert(ctx is not None, "At least one of the arguments must be a Z3 expression or probe")
2007  if _has_probe(args):
2008  return _probe_and(args, ctx)
2009  else:
2010  args = _coerce_expr_list(args, ctx)
2011  _args, sz = _to_ast_array(args)
2012  return BoolRef(Z3_mk_and(ctx.ref(), sz, _args), ctx)
2013 
2014 
def And(args)
Definition: z3py.py:1982
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 z3_debug()
Definition: z3py.py:70
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 8700 of file z3py.py.

Referenced by Then().

8700 def AndThen(*ts, **ks):
8701  """Return a tactic that applies the tactics in `*ts` in sequence.
8702 
8703  >>> x, y = Ints('x y')
8704  >>> t = AndThen(Tactic('simplify'), Tactic('solve-eqs'))
8705  >>> t(And(x == 0, y > x + 1))
8706  [[Not(y <= 1)]]
8707  >>> t(And(x == 0, y > x + 1)).as_expr()
8708  Not(y <= 1)
8709  """
8710  if z3_debug():
8711  _z3_assert(len(ts) >= 2, "At least two arguments expected")
8712  ctx = ks.get("ctx", None)
8713  num = len(ts)
8714  r = ts[0]
8715  for i in range(num - 1):
8716  r = _and_then(r, ts[i + 1], ctx)
8717  return r
8718 
8719 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:4343
def AndThen(ts, ks)
Definition: z3py.py:8700
def z3_debug()
Definition: z3py.py:70
def z3py.append_log (   s)
Append user-defined string to interaction log. 

Definition at line 127 of file z3py.py.

127 def append_log(s):
128  """Append user-defined string to interaction log. """
129  Z3_append_log(s)
130 
131 
void Z3_API Z3_append_log(Z3_string string)
Append user-defined string to interaction log.
def append_log(s)
Definition: z3py.py:127
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 5695 of file z3py.py.

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

5695 def args2params(arguments, keywords, ctx=None):
5696  """Convert python arguments into a Z3_params object.
5697  A ':' is added to the keywords, and '_' is replaced with '-'
5698 
5699  >>> args2params(['model', True, 'relevancy', 2], {'elim_and' : True})
5700  (params model true relevancy 2 elim_and true)
5701  """
5702  if z3_debug():
5703  _z3_assert(len(arguments) % 2 == 0, "Argument list must have an even number of elements.")
5704  prev = None
5705  r = ParamsRef(ctx)
5706  for a in arguments:
5707  if prev is None:
5708  prev = a
5709  else:
5710  r.set(prev, a)
5711  prev = None
5712  for k in keywords:
5713  v = keywords[k]
5714  r.set(k, v)
5715  return r
5716 
5717 
def args2params
Definition: z3py.py:5695
Parameter Sets.
Definition: z3py.py:5649
def z3_debug()
Definition: z3py.py:70
def z3py.Array (   name,
  sorts 
)
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 4923 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().

4923 def Array(name, *sorts):
4924  """Return an array constant named `name` with the given domain and range sorts.
4925 
4926  >>> a = Array('a', IntSort(), IntSort())
4927  >>> a.sort()
4928  Array(Int, Int)
4929  >>> a[0]
4930  a[0]
4931  """
4932  s = ArraySort(sorts)
4933  ctx = s.ctx
4934  return ArrayRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), s.ast), ctx)
4935 
4936 
Z3_ast Z3_API Z3_mk_const(Z3_context c, Z3_symbol s, Z3_sort ty)
Declare and create a constant.
def ArraySort(sig)
Definition: z3py.py:4890
def Array(name, sorts)
Definition: z3py.py:4923
def to_symbol
Definition: z3py.py:132
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 4890 of file z3py.py.

Referenced by SortRef.__gt__(), Array(), ArraySortRef.domain(), and ArraySortRef.range().

4890 def ArraySort(*sig):
4891  """Return the Z3 array sort with the given domain and range sorts.
4892 
4893  >>> A = ArraySort(IntSort(), BoolSort())
4894  >>> A
4895  Array(Int, Bool)
4896  >>> A.domain()
4897  Int
4898  >>> A.range()
4899  Bool
4900  >>> AA = ArraySort(IntSort(), A)
4901  >>> AA
4902  Array(Int, Array(Int, Bool))
4903  """
4904  sig = _get_args(sig)
4905  if z3_debug():
4906  _z3_assert(len(sig) > 1, "At least two arguments expected")
4907  arity = len(sig) - 1
4908  r = sig[arity]
4909  d = sig[0]
4910  if z3_debug():
4911  for s in sig:
4912  _z3_assert(is_sort(s), "Z3 sort expected")
4913  _z3_assert(s.ctx == r.ctx, "Context mismatch")
4914  ctx = d.ctx
4915  if len(sig) == 2:
4916  return ArraySortRef(Z3_mk_array_sort(ctx.ref(), d.ast, r.ast), ctx)
4917  dom = (Sort * arity)()
4918  for i in range(arity):
4919  dom[i] = sig[i].ast
4920  return ArraySortRef(Z3_mk_array_sort_n(ctx.ref(), arity, dom, r.ast), ctx)
4921 
4922 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:4343
def ArraySort(sig)
Definition: z3py.py:4890
Arrays.
Definition: z3py.py:4711
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:70
def is_sort
Definition: z3py.py:682
def z3py.AtLeast (   args)
Create an at-least Pseudo-Boolean k constraint.

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

Definition at line 9358 of file z3py.py.

9358 def AtLeast(*args):
9359  """Create an at-least Pseudo-Boolean k constraint.
9360 
9361  >>> a, b, c = Bools('a b c')
9362  >>> f = AtLeast(a, b, c, 2)
9363  """
9364  args = _get_args(args)
9365  if z3_debug():
9366  _z3_assert(len(args) > 1, "Non empty list of arguments expected")
9367  ctx = _ctx_from_ast_arg_list(args)
9368  if z3_debug():
9369  _z3_assert(ctx is not None, "At least one of the arguments must be a Z3 expression")
9370  args1 = _coerce_expr_list(args[:-1], ctx)
9371  k = args[-1]
9372  _args, sz = _to_ast_array(args1)
9373  return BoolRef(Z3_mk_atleast(ctx.ref(), sz, _args, k), ctx)
9374 
9375 
def AtLeast(args)
Definition: z3py.py:9358
def z3_debug()
Definition: z3py.py:70
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 9340 of file z3py.py.

9340 def AtMost(*args):
9341  """Create an at-most Pseudo-Boolean k constraint.
9342 
9343  >>> a, b, c = Bools('a b c')
9344  >>> f = AtMost(a, b, c, 2)
9345  """
9346  args = _get_args(args)
9347  if z3_debug():
9348  _z3_assert(len(args) > 1, "Non empty list of arguments expected")
9349  ctx = _ctx_from_ast_arg_list(args)
9350  if z3_debug():
9351  _z3_assert(ctx is not None, "At least one of the arguments must be a Z3 expression")
9352  args1 = _coerce_expr_list(args[:-1], ctx)
9353  k = args[-1]
9354  _args, sz = _to_ast_array(args1)
9355  return BoolRef(Z3_mk_atmost(ctx.ref(), sz, _args, k), ctx)
9356 
9357 
def AtMost(args)
Definition: z3py.py:9340
def z3_debug()
Definition: z3py.py:70
Z3_ast Z3_API Z3_mk_atmost(Z3_context c, unsigned num_args, Z3_ast const args[], unsigned k)
Pseudo-Boolean relations.
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 4204 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().

4204 def BitVec(name, bv, ctx=None):
4205  """Return a bit-vector constant named `name`. `bv` may be the number of bits of a bit-vector sort.
4206  If `ctx=None`, then the global context is used.
4207 
4208  >>> x = BitVec('x', 16)
4209  >>> is_bv(x)
4210  True
4211  >>> x.size()
4212  16
4213  >>> x.sort()
4214  BitVec(16)
4215  >>> word = BitVecSort(16)
4216  >>> x2 = BitVec('x', word)
4217  >>> eq(x, x2)
4218  True
4219  """
4220  if isinstance(bv, BitVecSortRef):
4221  ctx = bv.ctx
4222  else:
4223  ctx = _get_ctx(ctx)
4224  bv = BitVecSort(bv, ctx)
4225  return BitVecRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), bv.ast), ctx)
4226 
4227 
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:4172
def BitVec
Definition: z3py.py:4204
def to_symbol
Definition: z3py.py:132
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 4228 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().

4228 def BitVecs(names, bv, ctx=None):
4229  """Return a tuple of bit-vector constants of size bv.
4230 
4231  >>> x, y, z = BitVecs('x y z', 16)
4232  >>> x.size()
4233  16
4234  >>> x.sort()
4235  BitVec(16)
4236  >>> Sum(x, y, z)
4237  0 + x + y + z
4238  >>> Product(x, y, z)
4239  1*x*y*z
4240  >>> simplify(Product(x, y, z))
4241  x*y*z
4242  """
4243  ctx = _get_ctx(ctx)
4244  if isinstance(names, str):
4245  names = names.split(" ")
4246  return [BitVec(name, bv, ctx) for name in names]
4247 
4248 
def BitVec
Definition: z3py.py:4204
def BitVecs
Definition: z3py.py:4228
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 4172 of file z3py.py.

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

4172 def BitVecSort(sz, ctx=None):
4173  """Return a Z3 bit-vector sort of the given size. If `ctx=None`, then the global context is used.
4174 
4175  >>> Byte = BitVecSort(8)
4176  >>> Word = BitVecSort(16)
4177  >>> Byte
4178  BitVec(8)
4179  >>> x = Const('x', Byte)
4180  >>> eq(x, BitVec('x', 8))
4181  True
4182  """
4183  ctx = _get_ctx(ctx)
4184  return BitVecSortRef(Z3_mk_bv_sort(ctx.ref(), sz), ctx)
4185 
4186 
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:4172
Bit-Vectors.
Definition: z3py.py:3605
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 4187 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().

4187 def BitVecVal(val, bv, ctx=None):
4188  """Return a bit-vector value with the given number of bits. If `ctx=None`, then the global context is used.
4189 
4190  >>> v = BitVecVal(10, 32)
4191  >>> v
4192  10
4193  >>> print("0x%.8x" % v.as_long())
4194  0x0000000a
4195  """
4196  if is_bv_sort(bv):
4197  ctx = bv.ctx
4198  return BitVecNumRef(Z3_mk_numeral(ctx.ref(), _to_int_str(val), bv.ast), ctx)
4199  else:
4200  ctx = _get_ctx(ctx)
4201  return BitVecNumRef(Z3_mk_numeral(ctx.ref(), _to_int_str(val), BitVecSort(bv, ctx).ast), ctx)
4202 
4203 
def BitVecSort
Definition: z3py.py:4172
def BitVecVal
Definition: z3py.py:4187
def is_bv_sort(s)
Definition: z3py.py:3638
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 1861 of file z3py.py.

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

1861 def Bool(name, ctx=None):
1862  """Return a Boolean constant named `name`. If `ctx=None`, then the global context is used.
1863 
1864  >>> p = Bool('p')
1865  >>> q = Bool('q')
1866  >>> And(p, q)
1867  And(p, q)
1868  """
1869  ctx = _get_ctx(ctx)
1870  return BoolRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), BoolSort(ctx).ast), ctx)
1871 
1872 
def BoolSort
Definition: z3py.py:1824
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:1861
def to_symbol
Definition: z3py.py:132
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 1873 of file z3py.py.

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

1873 def Bools(names, ctx=None):
1874  """Return a tuple of Boolean constants.
1875 
1876  `names` is a single string containing all names separated by blank spaces.
1877  If `ctx=None`, then the global context is used.
1878 
1879  >>> p, q, r = Bools('p q r')
1880  >>> And(p, Or(q, r))
1881  And(p, Or(q, r))
1882  """
1883  ctx = _get_ctx(ctx)
1884  if isinstance(names, str):
1885  names = names.split(" ")
1886  return [Bool(name, ctx) for name in names]
1887 
1888 
def Bools
Definition: z3py.py:1873
def Bool
Definition: z3py.py:1861
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 1824 of file z3py.py.

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

1824 def BoolSort(ctx=None):
1825  """Return the Boolean Z3 sort. If `ctx=None`, then the global context is used.
1826 
1827  >>> BoolSort()
1828  Bool
1829  >>> p = Const('p', BoolSort())
1830  >>> is_bool(p)
1831  True
1832  >>> r = Function('r', IntSort(), IntSort(), BoolSort())
1833  >>> r(0, 1)
1834  r(0, 1)
1835  >>> is_bool(r(0, 1))
1836  True
1837  """
1838  ctx = _get_ctx(ctx)
1839  return BoolSortRef(Z3_mk_bool_sort(ctx.ref()), ctx)
1840 
1841 
def BoolSort
Definition: z3py.py:1824
def is_bool
Definition: z3py.py:1704
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 1842 of file z3py.py.

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

1842 def BoolVal(val, ctx=None):
1843  """Return the Boolean value `True` or `False`. If `ctx=None`, then the global context is used.
1844 
1845  >>> BoolVal(True)
1846  True
1847  >>> is_true(BoolVal(True))
1848  True
1849  >>> is_true(True)
1850  False
1851  >>> is_false(BoolVal(False))
1852  True
1853  """
1854  ctx = _get_ctx(ctx)
1855  if val:
1856  return BoolRef(Z3_mk_true(ctx.ref()), ctx)
1857  else:
1858  return BoolRef(Z3_mk_false(ctx.ref()), ctx)
1859 
1860 
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:1842
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 1889 of file z3py.py.

Referenced by And(), and Or().

1889 def BoolVector(prefix, sz, ctx=None):
1890  """Return a list of Boolean constants of size `sz`.
1891 
1892  The constants are named using the given prefix.
1893  If `ctx=None`, then the global context is used.
1894 
1895  >>> P = BoolVector('p', 3)
1896  >>> P
1897  [p__0, p__1, p__2]
1898  >>> And(P)
1899  And(p__0, p__1, p__2)
1900  """
1901  return [Bool("%s__%s" % (prefix, i)) for i in range(sz)]
1902 
1903 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:4343
def Bool
Definition: z3py.py:1861
def BoolVector
Definition: z3py.py:1889
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 4140 of file z3py.py.

4140 def BV2Int(a, is_signed=False):
4141  """Return the Z3 expression BV2Int(a).
4142 
4143  >>> b = BitVec('b', 3)
4144  >>> BV2Int(b).sort()
4145  Int
4146  >>> x = Int('x')
4147  >>> x > BV2Int(b)
4148  x > BV2Int(b)
4149  >>> x > BV2Int(b, is_signed=False)
4150  x > BV2Int(b)
4151  >>> x > BV2Int(b, is_signed=True)
4152  x > If(b < 0, BV2Int(b) - 8, BV2Int(b))
4153  >>> solve(x > BV2Int(b), b == 1, x < 3)
4154  [x = 2, b = 1]
4155  """
4156  if z3_debug():
4157  _z3_assert(is_bv(a), "First argument must be a Z3 bit-vector expression")
4158  ctx = a.ctx
4159  # investigate problem with bv2int
4160  return ArithRef(Z3_mk_bv2int(ctx.ref(), a.as_ast(), is_signed), ctx)
4161 
4162 
def BV2Int
Definition: z3py.py:4140
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:70
def is_bv(a)
Definition: z3py.py:4111
def z3py.BVAddNoOverflow (   a,
  b,
  signed 
)
A predicate the determines that bit-vector addition does not overflow

Definition at line 4649 of file z3py.py.

4649 def BVAddNoOverflow(a, b, signed):
4650  """A predicate the determines that bit-vector addition does not overflow"""
4651  _check_bv_args(a, b)
4652  a, b = _coerce_exprs(a, b)
4653  return BoolRef(Z3_mk_bvadd_no_overflow(a.ctx_ref(), a.as_ast(), b.as_ast(), signed), a.ctx)
4654 
4655 
def BVAddNoOverflow(a, b, signed)
Definition: z3py.py:4649
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 4656 of file z3py.py.

4657  """A predicate the determines that signed bit-vector addition does not underflow"""
4658  _check_bv_args(a, b)
4659  a, b = _coerce_exprs(a, b)
4660  return BoolRef(Z3_mk_bvadd_no_underflow(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4661 
4662 
def BVAddNoUnderflow(a, b)
Definition: z3py.py:4656
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 4691 of file z3py.py.

4691 def BVMulNoOverflow(a, b, signed):
4692  """A predicate the determines that bit-vector multiplication does not overflow"""
4693  _check_bv_args(a, b)
4694  a, b = _coerce_exprs(a, b)
4695  return BoolRef(Z3_mk_bvmul_no_overflow(a.ctx_ref(), a.as_ast(), b.as_ast(), signed), a.ctx)
4696 
4697 
def BVMulNoOverflow(a, b, signed)
Definition: z3py.py:4691
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 4698 of file z3py.py.

4699  """A predicate the determines that bit-vector signed multiplication does not underflow"""
4700  _check_bv_args(a, b)
4701  a, b = _coerce_exprs(a, b)
4702  return BoolRef(Z3_mk_bvmul_no_underflow(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4703 
4704 
Z3_ast Z3_API Z3_mk_bvmul_no_underflow(Z3_context c, Z3_ast t1, Z3_ast t2)
Create a predicate that checks that the bit-wise signed multiplication of t1 and t2 does not underflo...
def BVMulNoUnderflow(a, b)
Definition: z3py.py:4698
def z3py.BVRedAnd (   a)
Return the reduction-and expression of `a`.

Definition at line 4635 of file z3py.py.

4635 def BVRedAnd(a):
4636  """Return the reduction-and expression of `a`."""
4637  if z3_debug():
4638  _z3_assert(is_bv(a), "First argument must be a Z3 bit-vector expression")
4639  return BitVecRef(Z3_mk_bvredand(a.ctx_ref(), a.as_ast()), a.ctx)
4640 
4641 
Z3_ast Z3_API Z3_mk_bvredand(Z3_context c, Z3_ast t1)
Take conjunction of bits in vector, return vector of length 1.
def BVRedAnd(a)
Definition: z3py.py:4635
def z3_debug()
Definition: z3py.py:70
def is_bv(a)
Definition: z3py.py:4111
def z3py.BVRedOr (   a)
Return the reduction-or expression of `a`.

Definition at line 4642 of file z3py.py.

4642 def BVRedOr(a):
4643  """Return the reduction-or expression of `a`."""
4644  if z3_debug():
4645  _z3_assert(is_bv(a), "First argument must be a Z3 bit-vector expression")
4646  return BitVecRef(Z3_mk_bvredor(a.ctx_ref(), a.as_ast()), a.ctx)
4647 
4648 
def BVRedOr(a)
Definition: z3py.py:4642
def z3_debug()
Definition: z3py.py:70
Z3_ast Z3_API Z3_mk_bvredor(Z3_context c, Z3_ast t1)
Take disjunction of bits in vector, return vector of length 1.
def is_bv(a)
Definition: z3py.py:4111
def z3py.BVSDivNoOverflow (   a,
  b 
)
A predicate the determines that bit-vector signed division does not overflow

Definition at line 4677 of file z3py.py.

4678  """A predicate the determines that bit-vector signed division does not overflow"""
4679  _check_bv_args(a, b)
4680  a, b = _coerce_exprs(a, b)
4681  return BoolRef(Z3_mk_bvsdiv_no_overflow(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4682 
4683 
def BVSDivNoOverflow(a, b)
Definition: z3py.py:4677
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 z3py.BVSNegNoOverflow (   a)
A predicate the determines that bit-vector unary negation does not overflow

Definition at line 4684 of file z3py.py.

4685  """A predicate the determines that bit-vector unary negation does not overflow"""
4686  if z3_debug():
4687  _z3_assert(is_bv(a), "First argument must be a Z3 bit-vector expression")
4688  return BoolRef(Z3_mk_bvneg_no_overflow(a.ctx_ref(), a.as_ast()), a.ctx)
4689 
4690 
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:70
def BVSNegNoOverflow(a)
Definition: z3py.py:4684
def is_bv(a)
Definition: z3py.py:4111
def z3py.BVSubNoOverflow (   a,
  b 
)
A predicate the determines that bit-vector subtraction does not overflow

Definition at line 4663 of file z3py.py.

4664  """A predicate the determines that bit-vector subtraction does not overflow"""
4665  _check_bv_args(a, b)
4666  a, b = _coerce_exprs(a, b)
4667  return BoolRef(Z3_mk_bvsub_no_overflow(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4668 
4669 
def BVSubNoOverflow(a, b)
Definition: z3py.py:4663
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 4670 of file z3py.py.

4670 def BVSubNoUnderflow(a, b, signed):
4671  """A predicate the determines that bit-vector subtraction does not underflow"""
4672  _check_bv_args(a, b)
4673  a, b = _coerce_exprs(a, b)
4674  return BoolRef(Z3_mk_bvsub_no_underflow(a.ctx_ref(), a.as_ast(), b.as_ast(), signed), a.ctx)
4675 
4676 
def BVSubNoUnderflow(a, b, signed)
Definition: z3py.py:4670
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 3586 of file z3py.py.

3586 def Cbrt(a, ctx=None):
3587  """ Return a Z3 expression which represents the cubic root of a.
3588 
3589  >>> x = Real('x')
3590  >>> Cbrt(x)
3591  x**(1/3)
3592  """
3593  if not is_expr(a):
3594  ctx = _get_ctx(ctx)
3595  a = RealVal(a, ctx)
3596  return a ** "1/3"
3597 
def Cbrt
Definition: z3py.py:3586
def RealVal
Definition: z3py.py:3356
def is_expr(a)
Definition: z3py.py:1345
def z3py.CharFromBv (   bv)

Definition at line 11272 of file z3py.py.

11272 def CharFromBv(bv):
11273  if not is_expr(bv):
11274  raise Z3Exception("Bit-vector expression needed")
11275  return _to_expr_ref(Z3_mk_char_from_bv(bv.ctx_ref(), bv.as_ast()), bv.ctx)
11276 
Z3_ast Z3_API Z3_mk_char_from_bv(Z3_context c, Z3_ast bv)
Create a character from a bit-vector (code point).
def CharFromBv(bv)
Definition: z3py.py:11272
def is_expr(a)
Definition: z3py.py:1345
def z3py.CharIsDigit (   ch,
  ctx = None 
)

Definition at line 11285 of file z3py.py.

11285 def CharIsDigit(ch, ctx=None):
11286  ch = _coerce_char(ch, ctx)
11287  return ch.is_digit()
11288 
def CharIsDigit
Definition: z3py.py:11285
def z3py.CharSort (   ctx = None)
Create a character sort
>>> ch = CharSort()
>>> print(ch)
Char

Definition at line 11168 of file z3py.py.

11168 def CharSort(ctx=None):
11169  """Create a character sort
11170  >>> ch = CharSort()
11171  >>> print(ch)
11172  Char
11173  """
11174  ctx = _get_ctx(ctx)
11175  return CharSortRef(Z3_mk_char_sort(ctx.ref()), ctx)
11176 
11177 
def CharSort
Definition: z3py.py:11168
Z3_sort Z3_API Z3_mk_char_sort(Z3_context c)
Create a sort for unicode characters.
def z3py.CharToBv (   ch,
  ctx = None 
)

Definition at line 11277 of file z3py.py.

11277 def CharToBv(ch, ctx=None):
11278  ch = _coerce_char(ch, ctx)
11279  return ch.to_bv()
11280 
def CharToBv
Definition: z3py.py:11277
def z3py.CharToInt (   ch,
  ctx = None 
)

Definition at line 11281 of file z3py.py.

11281 def CharToInt(ch, ctx=None):
11282  ch = _coerce_char(ch, ctx)
11283  return ch.to_int()
11284 
def CharToInt
Definition: z3py.py:11281
def z3py.CharVal (   ch,
  ctx = None 
)

Definition at line 11264 of file z3py.py.

11264 def CharVal(ch, ctx=None):
11265  ctx = _get_ctx(ctx)
11266  if isinstance(ch, str):
11267  ch = ord(ch)
11268  if not isinstance(ch, int):
11269  raise Z3Exception("character value should be an ordinal")
11270  return _to_expr_ref(Z3_mk_char(ctx.ref(), ch), ctx)
11271 
Z3_ast Z3_API Z3_mk_char(Z3_context c, unsigned ch)
Create a character literal.
def CharVal
Definition: z3py.py:11264
def z3py.Complement (   re)
Create the complement regular expression.

Definition at line 11714 of file z3py.py.

11714 def Complement(re):
11715  """Create the complement regular expression."""
11716  return ReRef(Z3_mk_re_complement(re.ctx_ref(), re.as_ast()), re.ctx)
11717 
11718 
Z3_ast Z3_API Z3_mk_re_complement(Z3_context c, Z3_ast re)
Create the complement of the regular language re.
def Complement(re)
Definition: z3py.py:11714
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 4249 of file z3py.py.

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

4249 def Concat(*args):
4250  """Create a Z3 bit-vector concatenation expression.
4251 
4252  >>> v = BitVecVal(1, 4)
4253  >>> Concat(v, v+1, v)
4254  Concat(Concat(1, 1 + 1), 1)
4255  >>> simplify(Concat(v, v+1, v))
4256  289
4257  >>> print("%.3x" % simplify(Concat(v, v+1, v)).as_long())
4258  121
4259  """
4260  args = _get_args(args)
4261  sz = len(args)
4262  if z3_debug():
4263  _z3_assert(sz >= 2, "At least two arguments expected.")
4264 
4265  ctx = None
4266  for a in args:
4267  if is_expr(a):
4268  ctx = a.ctx
4269  break
4270  if is_seq(args[0]) or isinstance(args[0], str):
4271  args = [_coerce_seq(s, ctx) for s in args]
4272  if z3_debug():
4273  _z3_assert(all([is_seq(a) for a in args]), "All arguments must be sequence expressions.")
4274  v = (Ast * sz)()
4275  for i in range(sz):
4276  v[i] = args[i].as_ast()
4277  return SeqRef(Z3_mk_seq_concat(ctx.ref(), sz, v), ctx)
4278 
4279  if is_re(args[0]):
4280  if z3_debug():
4281  _z3_assert(all([is_re(a) for a in args]), "All arguments must be regular expressions.")
4282  v = (Ast * sz)()
4283  for i in range(sz):
4284  v[i] = args[i].as_ast()
4285  return ReRef(Z3_mk_re_concat(ctx.ref(), sz, v), ctx)
4286 
4287  if z3_debug():
4288  _z3_assert(all([is_bv(a) for a in args]), "All arguments must be Z3 bit-vector expressions.")
4289  r = args[0]
4290  for i in range(sz - 1):
4291  r = BitVecRef(Z3_mk_concat(ctx.ref(), r.as_ast(), args[i + 1].as_ast()), ctx)
4292  return r
4293 
4294 
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:4343
Z3_ast Z3_API Z3_mk_concat(Z3_context c, Z3_ast t1, Z3_ast t2)
Concatenate the given bit-vectors.
Z3_ast Z3_API Z3_mk_re_concat(Z3_context c, unsigned n, Z3_ast const args[])
Create the concatenation of the regular languages.
def is_re(s)
Definition: z3py.py:11628
def z3_debug()
Definition: z3py.py:70
def is_expr(a)
Definition: z3py.py:1345
def is_bv(a)
Definition: z3py.py:4111
def Concat(args)
Definition: z3py.py:4249
def is_seq(a)
Definition: z3py.py:11310
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 9157 of file z3py.py.

Referenced by If().

9157 def Cond(p, t1, t2, ctx=None):
9158  """Return a tactic that applies tactic `t1` to a goal if probe `p` evaluates to true, and `t2` otherwise.
9159 
9160  >>> t = Cond(Probe('is-qfnra'), Tactic('qfnra'), Tactic('smt'))
9161  """
9162  p = _to_probe(p, ctx)
9163  t1 = _to_tactic(t1, ctx)
9164  t2 = _to_tactic(t2, ctx)
9165  return Tactic(Z3_tactic_cond(t1.ctx.ref(), p.probe, t1.tactic, t2.tactic), t1.ctx)
9166 
def Cond
Definition: z3py.py:9157
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 1540 of file z3py.py.

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

1540 def Const(name, sort):
1541  """Create a constant of the given sort.
1542 
1543  >>> Const('x', IntSort())
1544  x
1545  """
1546  if z3_debug():
1547  _z3_assert(isinstance(sort, SortRef), "Z3 sort expected")
1548  ctx = sort.ctx
1549  return _to_expr_ref(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), sort.ast), ctx)
1550 
1551 
Z3_ast Z3_API Z3_mk_const(Z3_context c, Z3_symbol s, Z3_sort ty)
Declare and create a constant.
def Const(name, sort)
Definition: z3py.py:1540
def z3_debug()
Definition: z3py.py:70
def to_symbol
Definition: z3py.py:132
def z3py.Consts (   names,
  sort 
)
Create 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 1552 of file z3py.py.

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

1552 def Consts(names, sort):
1553  """Create several constants of the given sort.
1554 
1555  `names` is a string containing the names of all constants to be created.
1556  Blank spaces separate the names of different constants.
1557 
1558  >>> x, y, z = Consts('x y z', IntSort())
1559  >>> x + y + z
1560  x + y + z
1561  """
1562  if isinstance(names, str):
1563  names = names.split(" ")
1564  return [Const(name, sort) for name in names]
1565 
1566 
def Consts(names, sort)
Definition: z3py.py:1552
def Const(name, sort)
Definition: z3py.py:1540
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 11459 of file z3py.py.

11459 def Contains(a, b):
11460  """Check if 'a' contains 'b'
11461  >>> s1 = Contains("abc", "ab")
11462  >>> simplify(s1)
11463  True
11464  >>> s2 = Contains("abc", "bc")
11465  >>> simplify(s2)
11466  True
11467  >>> x, y, z = Strings('x y z')
11468  >>> s3 = Contains(Concat(x,y,z), y)
11469  >>> simplify(s3)
11470  True
11471  """
11472  ctx = _get_ctx2(a, b)
11473  a = _coerce_seq(a, ctx)
11474  b = _coerce_seq(b, ctx)
11475  return BoolRef(Z3_mk_seq_contains(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
11476 
11477 
def Contains(a, b)
Definition: z3py.py:11459
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 5341 of file z3py.py.

Referenced by Datatype.create().

5342  """Create mutually recursive Z3 datatypes using 1 or more Datatype helper objects.
5343 
5344  In the following example we define a Tree-List using two mutually recursive datatypes.
5345 
5346  >>> TreeList = Datatype('TreeList')
5347  >>> Tree = Datatype('Tree')
5348  >>> # Tree has two constructors: leaf and node
5349  >>> Tree.declare('leaf', ('val', IntSort()))
5350  >>> # a node contains a list of trees
5351  >>> Tree.declare('node', ('children', TreeList))
5352  >>> TreeList.declare('nil')
5353  >>> TreeList.declare('cons', ('car', Tree), ('cdr', TreeList))
5354  >>> Tree, TreeList = CreateDatatypes(Tree, TreeList)
5355  >>> Tree.val(Tree.leaf(10))
5356  val(leaf(10))
5357  >>> simplify(Tree.val(Tree.leaf(10)))
5358  10
5359  >>> n1 = Tree.node(TreeList.cons(Tree.leaf(10), TreeList.cons(Tree.leaf(20), TreeList.nil)))
5360  >>> n1
5361  node(cons(leaf(10), cons(leaf(20), nil)))
5362  >>> n2 = Tree.node(TreeList.cons(n1, TreeList.nil))
5363  >>> simplify(n2 == n1)
5364  False
5365  >>> simplify(TreeList.car(Tree.children(n2)) == n1)
5366  True
5367  """
5368  ds = _get_args(ds)
5369  if z3_debug():
5370  _z3_assert(len(ds) > 0, "At least one Datatype must be specified")
5371  _z3_assert(all([isinstance(d, Datatype) for d in ds]), "Arguments must be Datatypes")
5372  _z3_assert(all([d.ctx == ds[0].ctx for d in ds]), "Context mismatch")
5373  _z3_assert(all([d.constructors != [] for d in ds]), "Non-empty Datatypes expected")
5374  ctx = ds[0].ctx
5375  num = len(ds)
5376  names = (Symbol * num)()
5377  out = (Sort * num)()
5378  clists = (ConstructorList * num)()
5379  to_delete = []
5380  for i in range(num):
5381  d = ds[i]
5382  names[i] = to_symbol(d.name, ctx)
5383  num_cs = len(d.constructors)
5384  cs = (Constructor * num_cs)()
5385  for j in range(num_cs):
5386  c = d.constructors[j]
5387  cname = to_symbol(c[0], ctx)
5388  rname = to_symbol(c[1], ctx)
5389  fs = c[2]
5390  num_fs = len(fs)
5391  fnames = (Symbol * num_fs)()
5392  sorts = (Sort * num_fs)()
5393  refs = (ctypes.c_uint * num_fs)()
5394  for k in range(num_fs):
5395  fname = fs[k][0]
5396  ftype = fs[k][1]
5397  fnames[k] = to_symbol(fname, ctx)
5398  if isinstance(ftype, Datatype):
5399  if z3_debug():
5400  _z3_assert(
5401  ds.count(ftype) == 1,
5402  "One and only one occurrence of each datatype is expected",
5403  )
5404  sorts[k] = None
5405  refs[k] = ds.index(ftype)
5406  else:
5407  if z3_debug():
5408  _z3_assert(is_sort(ftype), "Z3 sort expected")
5409  sorts[k] = ftype.ast
5410  refs[k] = 0
5411  cs[j] = Z3_mk_constructor(ctx.ref(), cname, rname, num_fs, fnames, sorts, refs)
5412  to_delete.append(ScopedConstructor(cs[j], ctx))
5413  clists[i] = Z3_mk_constructor_list(ctx.ref(), num_cs, cs)
5414  to_delete.append(ScopedConstructorList(clists[i], ctx))
5415  Z3_mk_datatypes(ctx.ref(), num, names, out, clists)
5416  result = []
5417  # Create a field for every constructor, recognizer and accessor
5418  for i in range(num):
5419  dref = DatatypeSortRef(out[i], ctx)
5420  num_cs = dref.num_constructors()
5421  for j in range(num_cs):
5422  cref = dref.constructor(j)
5423  cref_name = cref.name()
5424  cref_arity = cref.arity()
5425  if cref.arity() == 0:
5426  cref = cref()
5427  setattr(dref, cref_name, cref)
5428  rref = dref.recognizer(j)
5429  setattr(dref, "is_" + cref_name, rref)
5430  for k in range(cref_arity):
5431  aref = dref.accessor(j, k)
5432  setattr(dref, aref.name(), aref)
5433  result.append(dref)
5434  return tuple(result)
5435 
5436 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:4343
def CreateDatatypes(ds)
Definition: z3py.py:5341
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 const sorts[], unsigned sort_refs[])
Create a constructor.
def z3_debug()
Definition: z3py.py:70
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 is_sort
Definition: z3py.py:682
def to_symbol
Definition: z3py.py:132
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.DatatypeSort (   name,
  params = None,
  ctx = None 
)
Create a reference to a sort that was declared, or will be declared, as a recursive datatype.

Args:
    name: name of the datatype sort
    params: optional list/tuple of sort parameters for parametric datatypes
    ctx: Z3 context (optional)

Example:
    >>> # Non-parametric datatype
    >>> TreeRef = DatatypeSort('Tree')
    >>> # Parametric datatype with one parameter
    >>> ListIntRef = DatatypeSort('List', [IntSort()])
    >>> # Parametric datatype with multiple parameters
    >>> PairRef = DatatypeSort('Pair', [IntSort(), BoolSort()])

Definition at line 5567 of file z3py.py.

5567 def DatatypeSort(name, params=None, ctx=None):
5568  """Create a reference to a sort that was declared, or will be declared, as a recursive datatype.
5569 
5570  Args:
5571  name: name of the datatype sort
5572  params: optional list/tuple of sort parameters for parametric datatypes
5573  ctx: Z3 context (optional)
5574 
5575  Example:
5576  >>> # Non-parametric datatype
5577  >>> TreeRef = DatatypeSort('Tree')
5578  >>> # Parametric datatype with one parameter
5579  >>> ListIntRef = DatatypeSort('List', [IntSort()])
5580  >>> # Parametric datatype with multiple parameters
5581  >>> PairRef = DatatypeSort('Pair', [IntSort(), BoolSort()])
5582  """
5583  ctx = _get_ctx(ctx)
5584  if params is None or len(params) == 0:
5585  return DatatypeSortRef(Z3_mk_datatype_sort(ctx.ref(), to_symbol(name, ctx), 0, (Sort * 0)()), ctx)
5586  else:
5587  _params = (Sort * len(params))()
5588  for i in range(len(params)):
5589  _params[i] = params[i].ast
5590  return DatatypeSortRef(Z3_mk_datatype_sort(ctx.ref(), to_symbol(name, ctx), len(params), _params), ctx)
5591 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:4343
Z3_sort Z3_API Z3_mk_datatype_sort(Z3_context c, Z3_symbol name, unsigned num_params, Z3_sort const params[])
create a forward reference to a recursive datatype being declared. The forward reference can be used ...
def DatatypeSort
Definition: z3py.py:5567
def to_symbol
Definition: z3py.py:132
def z3py.DeclareSort (   name,
  ctx = None,
  SortRef 
)
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 730 of file z3py.py.

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

730 def DeclareSort(name, ctx= None) -> SortRef:
731  """Create a new uninterpreted sort named `name`.
732 
733  If `ctx=None`, then the new sort is declared in the global Z3Py context.
734 
735  >>> A = DeclareSort('A')
736  >>> a = Const('a', A)
737  >>> b = Const('b', A)
738  >>> a.sort() == A
739  True
740  >>> b.sort() == A
741  True
742  >>> a == b
743  a == b
744  """
745  ctx = _get_ctx(ctx)
746  return SortRef(Z3_mk_uninterpreted_sort(ctx.ref(), to_symbol(name, ctx)), ctx)
747 
def DeclareSort
Definition: z3py.py:730
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:132
def z3py.DeclareTypeVar (   name,
  ctx = None 
)
Create a new type variable named `name`.

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

Definition at line 758 of file z3py.py.

758 def DeclareTypeVar(name, ctx=None):
759  """Create a new type variable named `name`.
760 
761  If `ctx=None`, then the new sort is declared in the global Z3Py context.
762 
763  """
764  ctx = _get_ctx(ctx)
765  return TypeVarRef(Z3_mk_type_variable(ctx.ref(), to_symbol(name, ctx)), ctx)
766 
767 
def DeclareTypeVar
Definition: z3py.py:758
Z3_sort Z3_API Z3_mk_type_variable(Z3_context c, Z3_symbol s)
Create a type variable.
def to_symbol
Definition: z3py.py:132
def z3py.Default (   a)
Return a default value for array expression.
>>> b = K(IntSort(), 1)
>>> prove(Default(b) == 1)
proved

Definition at line 4969 of file z3py.py.

Referenced by is_default().

4969 def Default(a):
4970  """ Return a default value for array expression.
4971  >>> b = K(IntSort(), 1)
4972  >>> prove(Default(b) == 1)
4973  proved
4974  """
4975  if z3_debug():
4976  _z3_assert(is_array_sort(a), "First argument must be a Z3 array expression")
4977  return a.default()
4978 
4979 
def is_array_sort(a)
Definition: z3py.py:4797
def Default(a)
Definition: z3py.py:4969
def z3_debug()
Definition: z3py.py:70
def z3py.describe_probes ( )
Display a (tabular) description of all available probes in Z3.

Definition at line 9078 of file z3py.py.

9079  """Display a (tabular) description of all available probes in Z3."""
9080  if in_html_mode():
9081  even = True
9082  print('<table border="1" cellpadding="2" cellspacing="0">')
9083  for p in probes():
9084  if even:
9085  print('<tr style="background-color:#CFCFCF">')
9086  even = False
9087  else:
9088  print("<tr>")
9089  even = True
9090  print("<td>%s</td><td>%s</td></tr>" % (p, insert_line_breaks(probe_description(p), 40)))
9091  print("</table>")
9092  else:
9093  for p in probes():
9094  print("%s : %s" % (p, probe_description(p)))
9095 
9096 
def probe_description
Definition: z3py.py:9069
def probes
Definition: z3py.py:9058
def describe_probes()
Definition: z3py.py:9078
def z3py.describe_tactics ( )
Display a (tabular) description of all available tactics in Z3.

Definition at line 8872 of file z3py.py.

8873  """Display a (tabular) description of all available tactics in Z3."""
8874  if in_html_mode():
8875  even = True
8876  print('<table border="1" cellpadding="2" cellspacing="0">')
8877  for t in tactics():
8878  if even:
8879  print('<tr style="background-color:#CFCFCF">')
8880  even = False
8881  else:
8882  print("<tr>")
8883  even = True
8884  print("<td>%s</td><td>%s</td></tr>" % (t, insert_line_breaks(tactic_description(t), 40)))
8885  print("</table>")
8886  else:
8887  for t in tactics():
8888  print("%s : %s" % (t, tactic_description(t)))
8889 
8890 
def describe_tactics()
Definition: z3py.py:8872
def tactic_description
Definition: z3py.py:8863
def tactics
Definition: z3py.py:8852
def z3py.deserialize (   st)
inverse function to the serialize method on ExprRef.
It is made available to make it easier for users to serialize expressions back and forth between
strings. Solvers can be serialized using the 'sexpr()' method.

Definition at line 1207 of file z3py.py.

1207 def deserialize(st):
1208  """inverse function to the serialize method on ExprRef.
1209  It is made available to make it easier for users to serialize expressions back and forth between
1210  strings. Solvers can be serialized using the 'sexpr()' method.
1211  """
1212  s = Solver()
1213  s.from_string(st)
1214  if len(s.assertions()) != 1:
1215  raise Z3Exception("single assertion expected")
1216  fml = s.assertions()[0]
1217  if fml.num_args() != 1:
1218  raise Z3Exception("dummy function 'F' expected")
1219  return fml.arg(0)
1220 
def deserialize(st)
Definition: z3py.py:1207
def z3py.Diff (   a,
  b,
  ctx = None 
)
Create the difference regular expression

Definition at line 11764 of file z3py.py.

11764 def Diff(a, b, ctx=None):
11765  """Create the difference regular expression
11766  """
11767  if z3_debug():
11768  _z3_assert(is_expr(a), "expression expected")
11769  _z3_assert(is_expr(b), "expression expected")
11770  return ReRef(Z3_mk_re_diff(a.ctx_ref(), a.ast, b.ast), a.ctx)
11771 
def Diff
Definition: z3py.py:11764
def z3_debug()
Definition: z3py.py:70
def is_expr(a)
Definition: z3py.py:1345
Z3_ast Z3_API Z3_mk_re_diff(Z3_context c, Z3_ast re1, Z3_ast re2)
Create the difference of regular expressions.
def z3py.disable_trace (   msg)

Definition at line 87 of file z3py.py.

87 def disable_trace(msg):
88  Z3_disable_trace(msg)
89 
90 
void Z3_API Z3_disable_trace(Z3_string tag)
Disable tracing messages tagged as tag when Z3 is compiled in debug mode. It is a NOOP otherwise...
def disable_trace(msg)
Definition: z3py.py:87
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 5604 of file z3py.py.

5604 def DisjointSum(name, sorts, ctx=None):
5605  """Create a named tagged union sort base on a set of underlying sorts
5606  Example:
5607  >>> sum, ((inject0, extract0), (inject1, extract1)) = DisjointSum("+", [IntSort(), StringSort()])
5608  """
5609  sum = Datatype(name, ctx)
5610  for i in range(len(sorts)):
5611  sum.declare("inject%d" % i, ("project%d" % i, sorts[i]))
5612  sum = sum.create()
5613  return sum, [(sum.constructor(i), sum.accessor(i, 0)) for i in range(len(sorts))]
5614 
5615 
def DisjointSum
Definition: z3py.py:5604
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:4343
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 1507 of file z3py.py.

1507 def Distinct(*args):
1508  """Create a Z3 distinct expression.
1509 
1510  >>> x = Int('x')
1511  >>> y = Int('y')
1512  >>> Distinct(x, y)
1513  x != y
1514  >>> z = Int('z')
1515  >>> Distinct(x, y, z)
1516  Distinct(x, y, z)
1517  >>> simplify(Distinct(x, y, z))
1518  Distinct(x, y, z)
1519  >>> simplify(Distinct(x, y, z), blast_distinct=True)
1520  And(Not(x == y), Not(x == z), Not(y == z))
1521  """
1522  args = _get_args(args)
1523  ctx = _ctx_from_ast_arg_list(args)
1524  if z3_debug():
1525  _z3_assert(ctx is not None, "At least one of the arguments must be a Z3 expression")
1526  args = _coerce_expr_list(args, ctx)
1527  _args, sz = _to_ast_array(args)
1528  return BoolRef(Z3_mk_distinct(ctx.ref(), sz, _args), ctx)
1529 
1530 
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 z3_debug()
Definition: z3py.py:70
def Distinct(args)
Definition: z3py.py:1507
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 11389 of file z3py.py.

11389 def Empty(s):
11390  """Create the empty sequence of the given sort
11391  >>> e = Empty(StringSort())
11392  >>> e2 = StringVal("")
11393  >>> print(e.eq(e2))
11394  True
11395  >>> e3 = Empty(SeqSort(IntSort()))
11396  >>> print(e3)
11397  Empty(Seq(Int))
11398  >>> e4 = Empty(ReSort(SeqSort(IntSort())))
11399  >>> print(e4)
11400  Empty(ReSort(Seq(Int)))
11401  """
11402  if isinstance(s, SeqSortRef):
11403  return SeqRef(Z3_mk_seq_empty(s.ctx_ref(), s.ast), s.ctx)
11404  if isinstance(s, ReSortRef):
11405  return ReRef(Z3_mk_re_empty(s.ctx_ref(), s.ast), s.ctx)
11406  raise Z3Exception("Non-sequence, non-regular expression sort passed to Empty")
11407 
11408 
Z3_ast Z3_API Z3_mk_re_empty(Z3_context c, Z3_sort re)
Create an empty regular expression of sort re.
Z3_ast Z3_API Z3_mk_seq_empty(Z3_context c, Z3_sort seq)
Create an empty sequence of the sequence sort seq.
def Empty(s)
Definition: z3py.py:11389
def z3py.EmptySet (   s)
Create the empty set
>>> EmptySet(IntSort())
K(Int, False)

Definition at line 5105 of file z3py.py.

5105 def EmptySet(s):
5106  """Create the empty set
5107  >>> EmptySet(IntSort())
5108  K(Int, False)
5109  """
5110  ctx = s.ctx
5111  return ArrayRef(Z3_mk_empty_set(ctx.ref(), s.ast), ctx)
5112 
5113 
Z3_ast Z3_API Z3_mk_empty_set(Z3_context c, Z3_sort domain)
Create the empty set.
def EmptySet(s)
Definition: z3py.py:5105
def z3py.enable_trace (   msg)

Definition at line 83 of file z3py.py.

83 def enable_trace(msg):
84  Z3_enable_trace(msg)
85 
86 
void Z3_API Z3_enable_trace(Z3_string tag)
Enable tracing messages tagged as tag when Z3 is compiled in debug mode. It is a NOOP otherwise...
def enable_trace(msg)
Definition: z3py.py:83
def z3py.ensure_prop_closures ( )

Definition at line 11883 of file z3py.py.

11884  global _prop_closures
11885  if _prop_closures is None:
11886  _prop_closures = PropClosures()
11887 
11888 
def ensure_prop_closures()
Definition: z3py.py:11883
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 5616 of file z3py.py.

5616 def EnumSort(name, values, ctx=None):
5617  """Return a new enumeration sort named `name` containing the given values.
5618 
5619  The result is a pair (sort, list of constants).
5620  Example:
5621  >>> Color, (red, green, blue) = EnumSort('Color', ['red', 'green', 'blue'])
5622  """
5623  if z3_debug():
5624  _z3_assert(isinstance(name, str), "Name must be a string")
5625  _z3_assert(all([isinstance(v, str) for v in values]), "Enumeration sort values must be strings")
5626  _z3_assert(len(values) > 0, "At least one value expected")
5627  ctx = _get_ctx(ctx)
5628  num = len(values)
5629  _val_names = (Symbol * num)()
5630  for i in range(num):
5631  _val_names[i] = to_symbol(values[i], ctx)
5632  _values = (FuncDecl * num)()
5633  _testers = (FuncDecl * num)()
5634  name = to_symbol(name, ctx)
5635  S = DatatypeSortRef(Z3_mk_enumeration_sort(ctx.ref(), name, num, _val_names, _values, _testers), ctx)
5636  V = []
5637  for i in range(num):
5638  V.append(FuncDeclRef(_values[i], ctx))
5639  V = [a() for a in V]
5640  return S, V
5641 
Function Declarations.
Definition: z3py.py:775
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:4343
def EnumSort
Definition: z3py.py:5616
def z3_debug()
Definition: z3py.py:70
def to_symbol
Definition: z3py.py:132
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)

Definition at line 503 of file z3py.py.

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

503 def eq(a : AstRef, b : AstRef) -> bool:
504  """Return `True` if `a` and `b` are structurally identical AST nodes.
505 
506  >>> x = Int('x')
507  >>> y = Int('y')
508  >>> eq(x, y)
509  False
510  >>> eq(x + 1, x + 1)
511  True
512  >>> eq(x + 1, 1 + x)
513  False
514  >>> eq(simplify(x + 1), simplify(1 + x))
515  True
516  """
517  if z3_debug():
518  _z3_assert(is_ast(a) and is_ast(b), "Z3 ASTs expected")
519  return a.eq(b)
520 
521 
def is_ast
Definition: z3py.py:482
def z3_debug()
Definition: z3py.py:70
def eq
Definition: z3py.py:503
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 2383 of file z3py.py.

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

2383 def Exists(vs, body, weight=1, qid="", skid="", patterns=[], no_patterns=[]):
2384  """Create a Z3 exists formula.
2385 
2386  The parameters `weight`, `qif`, `skid`, `patterns` and `no_patterns` are optional annotations.
2387 
2388 
2389  >>> f = Function('f', IntSort(), IntSort(), IntSort())
2390  >>> x = Int('x')
2391  >>> y = Int('y')
2392  >>> q = Exists([x, y], f(x, y) >= x, skid="foo")
2393  >>> q
2394  Exists([x, y], f(x, y) >= x)
2395  >>> is_quantifier(q)
2396  True
2397  >>> r = Tactic('nnf')(q).as_expr()
2398  >>> is_quantifier(r)
2399  False
2400  """
2401  return _mk_quantifier(False, vs, body, weight, qid, skid, patterns, no_patterns)
2402 
2403 
def Exists
Definition: z3py.py:2383
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 5058 of file z3py.py.

5058 def Ext(a, b):
5059  """Return extensionality index for one-dimensional arrays.
5060  >> a, b = Consts('a b', SetSort(IntSort()))
5061  >> Ext(a, b)
5062  Ext(a, b)
5063  """
5064  ctx = a.ctx
5065  if z3_debug():
5066  _z3_assert(is_array_sort(a) and (is_array(b) or b.is_lambda()), "arguments must be arrays")
5067  return _to_expr_ref(Z3_mk_array_ext(ctx.ref(), a.as_ast(), b.as_ast()), ctx)
5068 
Z3_ast Z3_API Z3_mk_array_ext(Z3_context c, Z3_ast arg1, Z3_ast arg2)
Create array extensionality index given two arrays with the same sort. The meaning is given by the ax...
def is_array_sort(a)
Definition: z3py.py:4797
def z3_debug()
Definition: z3py.py:70
def Ext(a, b)
Definition: z3py.py:5058
def is_array
Definition: z3py.py:4801
def z3py.Extract (   high,
  low,
  a 
)
Create a Z3 bit-vector extraction expression or sequence extraction expression.

Extract is overloaded to work with both bit-vectors and sequences:

**Bit-vector extraction**: Extract(high, low, bitvector)
    Extracts bits from position `high` down to position `low` (both inclusive).
    - high: int - the highest bit position to extract (0-indexed from right)
    - low: int - the lowest bit position to extract (0-indexed from right)  
    - bitvector: BitVecRef - the bit-vector to extract from
    Returns a new bit-vector containing bits [high:low]

**Sequence extraction**: Extract(sequence, offset, length)
    Extracts a subsequence starting at the given offset with the specified length.
    The functions SubString and SubSeq are redirected to this form of Extract.
    - sequence: SeqRef or str - the sequence to extract from
    - offset: int - the starting position (0-indexed)
    - length: int - the number of elements to extract
    Returns a new sequence containing the extracted subsequence

>>> # Bit-vector extraction examples
>>> x = BitVec('x', 8)
>>> Extract(6, 2, x)  # Extract bits 6 down to 2 (5 bits total)
Extract(6, 2, x)
>>> Extract(6, 2, x).sort()  # Result is a 5-bit vector
BitVec(5)
>>> Extract(7, 0, x)  # Extract all 8 bits
Extract(7, 0, x)
>>> Extract(3, 3, x)  # Extract single bit at position 3
Extract(3, 3, x)

>>> # Sequence extraction examples  
>>> s = StringVal("hello")
>>> Extract(s, 1, 3)  # Extract 3 characters starting at position 1
str.substr("hello", 1, 3)
>>> simplify(Extract(StringVal("abcd"), 2, 1))  # Extract 1 character at position 2
"c"
>>> simplify(Extract(StringVal("abcd"), 0, 2))  # Extract first 2 characters  
"ab"

Definition at line 4295 of file z3py.py.

Referenced by SubSeq(), and SubString().

4295 def Extract(high, low, a):
4296  """Create a Z3 bit-vector extraction expression or sequence extraction expression.
4297 
4298  Extract is overloaded to work with both bit-vectors and sequences:
4299 
4300  **Bit-vector extraction**: Extract(high, low, bitvector)
4301  Extracts bits from position `high` down to position `low` (both inclusive).
4302  - high: int - the highest bit position to extract (0-indexed from right)
4303  - low: int - the lowest bit position to extract (0-indexed from right)
4304  - bitvector: BitVecRef - the bit-vector to extract from
4305  Returns a new bit-vector containing bits [high:low]
4306 
4307  **Sequence extraction**: Extract(sequence, offset, length)
4308  Extracts a subsequence starting at the given offset with the specified length.
4309  The functions SubString and SubSeq are redirected to this form of Extract.
4310  - sequence: SeqRef or str - the sequence to extract from
4311  - offset: int - the starting position (0-indexed)
4312  - length: int - the number of elements to extract
4313  Returns a new sequence containing the extracted subsequence
4314 
4315  >>> # Bit-vector extraction examples
4316  >>> x = BitVec('x', 8)
4317  >>> Extract(6, 2, x) # Extract bits 6 down to 2 (5 bits total)
4318  Extract(6, 2, x)
4319  >>> Extract(6, 2, x).sort() # Result is a 5-bit vector
4320  BitVec(5)
4321  >>> Extract(7, 0, x) # Extract all 8 bits
4322  Extract(7, 0, x)
4323  >>> Extract(3, 3, x) # Extract single bit at position 3
4324  Extract(3, 3, x)
4325 
4326  >>> # Sequence extraction examples
4327  >>> s = StringVal("hello")
4328  >>> Extract(s, 1, 3) # Extract 3 characters starting at position 1
4329  str.substr("hello", 1, 3)
4330  >>> simplify(Extract(StringVal("abcd"), 2, 1)) # Extract 1 character at position 2
4331  "c"
4332  >>> simplify(Extract(StringVal("abcd"), 0, 2)) # Extract first 2 characters
4333  "ab"
4334  """
4335  if isinstance(high, str):
4336  high = StringVal(high)
4337  if is_seq(high):
4338  s = high
4339  offset, length = _coerce_exprs(low, a, s.ctx)
4340  return SeqRef(Z3_mk_seq_extract(s.ctx_ref(), s.as_ast(), offset.as_ast(), length.as_ast()), s.ctx)
4341  if z3_debug():
4342  _z3_assert(low <= high, "First argument must be greater than or equal to second argument")
4343  _z3_assert(_is_int(high) and high >= 0 and _is_int(low) and low >= 0,
4344  "First and second arguments must be non negative integers")
4345  _z3_assert(is_bv(a), "Third argument must be a Z3 bit-vector expression")
4346  return BitVecRef(Z3_mk_extract(a.ctx_ref(), high, low, a.as_ast()), a.ctx)
4347 
4348 
def StringVal
Definition: z3py.py:11337
def Extract(high, low, a)
Definition: z3py.py:4295
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:70
Z3_ast Z3_API Z3_mk_extract(Z3_context c, unsigned high, unsigned low, Z3_ast t1)
Extract the bits high down to low from a bit-vector of size m to yield a new bit-vector of size n...
def is_bv(a)
Definition: z3py.py:4111
def is_seq(a)
Definition: z3py.py:11310
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 9115 of file z3py.py.

9115 def FailIf(p, ctx=None):
9116  """Return a tactic that fails if the probe `p` evaluates to true.
9117  Otherwise, it returns the input goal unmodified.
9118 
9119  In the following example, the tactic applies 'simplify' if and only if there are
9120  more than 2 constraints in the goal.
9121 
9122  >>> t = OrElse(FailIf(Probe('size') > 2), Tactic('simplify'))
9123  >>> x, y = Ints('x y')
9124  >>> g = Goal()
9125  >>> g.add(x > 0)
9126  >>> g.add(y > 0)
9127  >>> t(g)
9128  [[x > 0, y > 0]]
9129  >>> g.add(x == y + 1)
9130  >>> t(g)
9131  [[Not(x <= 0), Not(y <= 0), x == 1 + y]]
9132  """
9133  p = _to_probe(p, ctx)
9134  return Tactic(Z3_tactic_fail_if(p.ctx.ref(), p.probe), p.ctx)
9135 
9136 
def FailIf
Definition: z3py.py:9115
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 8044 of file z3py.py.

8044 def FiniteDomainSort(name, sz, ctx=None):
8045  """Create a named finite domain sort of a given size sz"""
8046  if not isinstance(name, Symbol):
8047  name = to_symbol(name)
8048  ctx = _get_ctx(ctx)
8049  return FiniteDomainSortRef(Z3_mk_finite_domain_sort(ctx.ref(), name, sz), ctx)
8050 
8051 
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:8044
def to_symbol
Definition: z3py.py:132
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 8114 of file z3py.py.

8114 def FiniteDomainVal(val, sort, ctx=None):
8115  """Return a Z3 finite-domain value. If `ctx=None`, then the global context is used.
8116 
8117  >>> s = FiniteDomainSort('S', 256)
8118  >>> FiniteDomainVal(255, s)
8119  255
8120  >>> FiniteDomainVal('100', s)
8121  100
8122  """
8123  if z3_debug():
8124  _z3_assert(is_finite_domain_sort(sort), "Expected finite-domain sort")
8125  ctx = sort.ctx
8126  return FiniteDomainNumRef(Z3_mk_numeral(ctx.ref(), _to_int_str(val), sort.ast), ctx)
8127 
8128 
def FiniteDomainVal
Definition: z3py.py:8114
def is_finite_domain_sort(s)
Definition: z3py.py:8052
def z3_debug()
Definition: z3py.py:70
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 9843 of file z3py.py.

9843 def Float128(ctx=None):
9844  """Floating-point 128-bit (quadruple) sort."""
9845  ctx = _get_ctx(ctx)
9846  return FPSortRef(Z3_mk_fpa_sort_128(ctx.ref()), ctx)
9847 
9848 
def Float128
Definition: z3py.py:9843
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 9807 of file z3py.py.

9807 def Float16(ctx=None):
9808  """Floating-point 16-bit (half) sort."""
9809  ctx = _get_ctx(ctx)
9810  return FPSortRef(Z3_mk_fpa_sort_16(ctx.ref()), ctx)
9811 
9812 
def Float16
Definition: z3py.py:9807
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 9819 of file z3py.py.

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

9819 def Float32(ctx=None):
9820  """Floating-point 32-bit (single) sort."""
9821  ctx = _get_ctx(ctx)
9822  return FPSortRef(Z3_mk_fpa_sort_32(ctx.ref()), ctx)
9823 
9824 
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:9819
def z3py.Float64 (   ctx = None)
Floating-point 64-bit (double) sort.

Definition at line 9831 of file z3py.py.

Referenced by fpFPToFP(), and fpToFP().

9831 def Float64(ctx=None):
9832  """Floating-point 64-bit (double) sort."""
9833  ctx = _get_ctx(ctx)
9834  return FPSortRef(Z3_mk_fpa_sort_64(ctx.ref()), ctx)
9835 
9836 
def Float64
Definition: z3py.py:9831
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 9837 of file z3py.py.

9837 def FloatDouble(ctx=None):
9838  """Floating-point 64-bit (double) sort."""
9839  ctx = _get_ctx(ctx)
9840  return FPSortRef(Z3_mk_fpa_sort_double(ctx.ref()), ctx)
9841 
9842 
def FloatDouble
Definition: z3py.py:9837
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 9813 of file z3py.py.

9813 def FloatHalf(ctx=None):
9814  """Floating-point 16-bit (half) sort."""
9815  ctx = _get_ctx(ctx)
9816  return FPSortRef(Z3_mk_fpa_sort_half(ctx.ref()), ctx)
9817 
9818 
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:9813
def z3py.FloatQuadruple (   ctx = None)
Floating-point 128-bit (quadruple) sort.

Definition at line 9849 of file z3py.py.

9849 def FloatQuadruple(ctx=None):
9850  """Floating-point 128-bit (quadruple) sort."""
9851  ctx = _get_ctx(ctx)
9852  return FPSortRef(Z3_mk_fpa_sort_quadruple(ctx.ref()), ctx)
9853 
9854 
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:9849
def z3py.FloatSingle (   ctx = None)
Floating-point 32-bit (single) sort.

Definition at line 9825 of file z3py.py.

9825 def FloatSingle(ctx=None):
9826  """Floating-point 32-bit (single) sort."""
9827  ctx = _get_ctx(ctx)
9828  return FPSortRef(Z3_mk_fpa_sort_single(ctx.ref()), ctx)
9829 
9830 
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:9825
def z3py.ForAll (   vs,
  body,
  weight = 1,
  qid = "",
  skid = "",
  patterns = [],
  no_patterns = [] 
)
Create a Z3 forall formula.

The parameters `weight`, `qid`, `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 2365 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().

2365 def ForAll(vs, body, weight=1, qid="", skid="", patterns=[], no_patterns=[]):
2366  """Create a Z3 forall formula.
2367 
2368  The parameters `weight`, `qid`, `skid`, `patterns` and `no_patterns` are optional annotations.
2369 
2370  >>> f = Function('f', IntSort(), IntSort(), IntSort())
2371  >>> x = Int('x')
2372  >>> y = Int('y')
2373  >>> ForAll([x, y], f(x, y) >= x)
2374  ForAll([x, y], f(x, y) >= x)
2375  >>> ForAll([x, y], f(x, y) >= x, patterns=[ f(x, y) ])
2376  ForAll([x, y], f(x, y) >= x)
2377  >>> ForAll([x, y], f(x, y) >= x, weight=10)
2378  ForAll([x, y], f(x, y) >= x)
2379  """
2380  return _mk_quantifier(True, vs, body, weight, qid, skid, patterns, no_patterns)
2381 
2382 
def ForAll
Definition: z3py.py:2365
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 10485 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().

10485 def FP(name, fpsort, ctx=None):
10486  """Return a floating-point constant named `name`.
10487  `fpsort` is the floating-point sort.
10488  If `ctx=None`, then the global context is used.
10489 
10490  >>> x = FP('x', FPSort(8, 24))
10491  >>> is_fp(x)
10492  True
10493  >>> x.ebits()
10494  8
10495  >>> x.sort()
10496  FPSort(8, 24)
10497  >>> word = FPSort(8, 24)
10498  >>> x2 = FP('x', word)
10499  >>> eq(x, x2)
10500  True
10501  """
10502  if isinstance(fpsort, FPSortRef) and ctx is None:
10503  ctx = fpsort.ctx
10504  else:
10505  ctx = _get_ctx(ctx)
10506  return FPRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), fpsort.ast), ctx)
10507 
10508 
def FP
Definition: z3py.py:10485
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:132
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 10528 of file z3py.py.

10528 def fpAbs(a, ctx=None):
10529  """Create a Z3 floating-point absolute value expression.
10530 
10531  >>> s = FPSort(8, 24)
10532  >>> rm = RNE()
10533  >>> x = FPVal(1.0, s)
10534  >>> fpAbs(x)
10535  fpAbs(1)
10536  >>> y = FPVal(-20.0, s)
10537  >>> y
10538  -1.25*(2**4)
10539  >>> fpAbs(y)
10540  fpAbs(-1.25*(2**4))
10541  >>> fpAbs(-1.25*(2**4))
10542  fpAbs(-1.25*(2**4))
10543  >>> fpAbs(x).sort()
10544  FPSort(8, 24)
10545  """
10546  ctx = _get_ctx(ctx)
10547  [a] = _coerce_fp_expr_list([a], ctx)
10548  return FPRef(Z3_mk_fpa_abs(ctx.ref(), a.as_ast()), ctx)
10549 
10550 
Z3_ast Z3_API Z3_mk_fpa_abs(Z3_context c, Z3_ast t)
Floating-point absolute value.
def fpAbs
Definition: z3py.py:10528
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)
x + y
>>> fpAdd(RTZ(), x, y) # default rounding mode is RTZ
fpAdd(RTZ(), x, y)
>>> fpAdd(rm, x, y).sort()
FPSort(8, 24)

Definition at line 10619 of file z3py.py.

Referenced by FPs().

10619 def fpAdd(rm, a, b, ctx=None):
10620  """Create a Z3 floating-point addition expression.
10621 
10622  >>> s = FPSort(8, 24)
10623  >>> rm = RNE()
10624  >>> x = FP('x', s)
10625  >>> y = FP('y', s)
10626  >>> fpAdd(rm, x, y)
10627  x + y
10628  >>> fpAdd(RTZ(), x, y) # default rounding mode is RTZ
10629  fpAdd(RTZ(), x, y)
10630  >>> fpAdd(rm, x, y).sort()
10631  FPSort(8, 24)
10632  """
10633  return _mk_fp_bin(Z3_mk_fpa_add, rm, a, b, ctx)
10634 
10635 
def fpAdd
Definition: z3py.py:10619
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 10941 of file z3py.py.

10941 def fpBVToFP(v, sort, ctx=None):
10942  """Create a Z3 floating-point conversion expression that represents the
10943  conversion from a bit-vector term to a floating-point term.
10944 
10945  >>> x_bv = BitVecVal(0x3F800000, 32)
10946  >>> x_fp = fpBVToFP(x_bv, Float32())
10947  >>> x_fp
10948  fpToFP(1065353216)
10949  >>> simplify(x_fp)
10950  1
10951  """
10952  _z3_assert(is_bv(v), "First argument must be a Z3 bit-vector expression")
10953  _z3_assert(is_fp_sort(sort), "Second argument must be a Z3 floating-point sort.")
10954  ctx = _get_ctx(ctx)
10955  return FPRef(Z3_mk_fpa_to_fp_bv(ctx.ref(), v.ast, sort.ast), ctx)
10956 
10957 
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:10941
def is_fp_sort(s)
Definition: z3py.py:9859
def is_bv(a)
Definition: z3py.py:4111
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)
x / y
>>> fpDiv(rm, x, y).sort()
FPSort(8, 24)

Definition at line 10666 of file z3py.py.

10666 def fpDiv(rm, a, b, ctx=None):
10667  """Create a Z3 floating-point division expression.
10668 
10669  >>> s = FPSort(8, 24)
10670  >>> rm = RNE()
10671  >>> x = FP('x', s)
10672  >>> y = FP('y', s)
10673  >>> fpDiv(rm, x, y)
10674  x / y
10675  >>> fpDiv(rm, x, y).sort()
10676  FPSort(8, 24)
10677  """
10678  return _mk_fp_bin(Z3_mk_fpa_div, rm, a, b, ctx)
10679 
10680 
def fpDiv
Definition: z3py.py:10666
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 10849 of file z3py.py.

Referenced by fpFP(), and fpNEQ().

10849 def fpEQ(a, b, ctx=None):
10850  """Create the Z3 floating-point expression `fpEQ(other, self)`.
10851 
10852  >>> x, y = FPs('x y', FPSort(8, 24))
10853  >>> fpEQ(x, y)
10854  fpEQ(x, y)
10855  >>> fpEQ(x, y).sexpr()
10856  '(fp.eq x y)'
10857  """
10858  return _mk_fp_bin_pred(Z3_mk_fpa_eq, a, b, ctx)
10859 
10860 
def fpEQ
Definition: z3py.py:10849
def z3py.fpFMA (   rm,
  a,
  b,
  c,
  ctx = None 
)
Create a Z3 floating-point fused multiply-add expression.

Definition at line 10725 of file z3py.py.

10725 def fpFMA(rm, a, b, c, ctx=None):
10726  """Create a Z3 floating-point fused multiply-add expression.
10727  """
10728  return _mk_fp_tern(Z3_mk_fpa_fma, rm, a, b, c, ctx)
10729 
10730 
def fpFMA
Definition: z3py.py:10725
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 10873 of file z3py.py.

10873 def fpFP(sgn, exp, sig, ctx=None):
10874  """Create the Z3 floating-point value `fpFP(sgn, sig, exp)` from the three bit-vectors sgn, sig, and exp.
10875 
10876  >>> s = FPSort(8, 24)
10877  >>> x = fpFP(BitVecVal(1, 1), BitVecVal(2**7-1, 8), BitVecVal(2**22, 23))
10878  >>> print(x)
10879  fpFP(1, 127, 4194304)
10880  >>> xv = FPVal(-1.5, s)
10881  >>> print(xv)
10882  -1.5
10883  >>> slvr = Solver()
10884  >>> slvr.add(fpEQ(x, xv))
10885  >>> slvr.check()
10886  sat
10887  >>> xv = FPVal(+1.5, s)
10888  >>> print(xv)
10889  1.5
10890  >>> slvr = Solver()
10891  >>> slvr.add(fpEQ(x, xv))
10892  >>> slvr.check()
10893  unsat
10894  """
10895  _z3_assert(is_bv(sgn) and is_bv(exp) and is_bv(sig), "sort mismatch")
10896  _z3_assert(sgn.sort().size() == 1, "sort mismatch")
10897  ctx = _get_ctx(ctx)
10898  _z3_assert(ctx == sgn.ctx == exp.ctx == sig.ctx, "context mismatch")
10899  return FPRef(Z3_mk_fpa_fp(ctx.ref(), sgn.ast, exp.ast, sig.ast), ctx)
10900 
10901 
Z3_ast Z3_API Z3_mk_fpa_fp(Z3_context c, Z3_ast sgn, Z3_ast exp, Z3_ast sig)
Create an expression of FloatingPoint sort from three bit-vector expressions.
def fpFP
Definition: z3py.py:10873
def is_bv(a)
Definition: z3py.py:4111
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 10958 of file z3py.py.

10958 def fpFPToFP(rm, v, sort, ctx=None):
10959  """Create a Z3 floating-point conversion expression that represents the
10960  conversion from a floating-point term to a floating-point term of different precision.
10961 
10962  >>> x_sgl = FPVal(1.0, Float32())
10963  >>> x_dbl = fpFPToFP(RNE(), x_sgl, Float64())
10964  >>> x_dbl
10965  fpToFP(RNE(), 1)
10966  >>> simplify(x_dbl)
10967  1
10968  >>> x_dbl.sort()
10969  FPSort(11, 53)
10970  """
10971  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression.")
10972  _z3_assert(is_fp(v), "Second argument must be a Z3 floating-point expression.")
10973  _z3_assert(is_fp_sort(sort), "Third argument must be a Z3 floating-point sort.")
10974  ctx = _get_ctx(ctx)
10975  return FPRef(Z3_mk_fpa_to_fp_float(ctx.ref(), rm.ast, v.ast, sort.ast), ctx)
10976 
10977 
def fpFPToFP
Definition: z3py.py:10958
Z3_ast Z3_API Z3_mk_fpa_to_fp_float(Z3_context c, Z3_ast rm, Z3_ast t, Z3_sort s)
Conversion of a FloatingPoint term into another term of different FloatingPoint sort.
def is_fp_sort(s)
Definition: z3py.py:9859
def is_fprm(a)
Definition: z3py.py:10119
def is_fp(a)
Definition: z3py.py:10285
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 10837 of file z3py.py.

10837 def fpGEQ(a, b, ctx=None):
10838  """Create the Z3 floating-point expression `other >= self`.
10839 
10840  >>> x, y = FPs('x y', FPSort(8, 24))
10841  >>> fpGEQ(x, y)
10842  x >= y
10843  >>> (x >= y).sexpr()
10844  '(fp.geq x y)'
10845  """
10846  return _mk_fp_bin_pred(Z3_mk_fpa_geq, a, b, ctx)
10847 
10848 
def fpGEQ
Definition: z3py.py:10837
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 10825 of file z3py.py.

10825 def fpGT(a, b, ctx=None):
10826  """Create the Z3 floating-point expression `other > self`.
10827 
10828  >>> x, y = FPs('x y', FPSort(8, 24))
10829  >>> fpGT(x, y)
10830  x > y
10831  >>> (x > y).sexpr()
10832  '(fp.gt x y)'
10833  """
10834  return _mk_fp_bin_pred(Z3_mk_fpa_gt, a, b, ctx)
10835 
10836 
def fpGT
Definition: z3py.py:10825
def z3py.fpInfinity (   s,
  negative 
)
Create a Z3 floating-point +oo or -oo term.

Definition at line 10413 of file z3py.py.

10413 def fpInfinity(s, negative):
10414  """Create a Z3 floating-point +oo or -oo term."""
10415  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
10416  _z3_assert(isinstance(negative, bool), "expected Boolean flag")
10417  return FPNumRef(Z3_mk_fpa_inf(s.ctx_ref(), s.ast, negative), s.ctx)
10418 
10419 
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 fpInfinity(s, negative)
Definition: z3py.py:10413
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 10755 of file z3py.py.

10755 def fpIsInf(a, ctx=None):
10756  """Create a Z3 floating-point isInfinite expression.
10757 
10758  >>> s = FPSort(8, 24)
10759  >>> x = FP('x', s)
10760  >>> fpIsInf(x)
10761  fpIsInf(x)
10762  """
10763  return _mk_fp_unary_pred(Z3_mk_fpa_is_infinite, a, ctx)
10764 
10765 
def fpIsInf
Definition: z3py.py:10755
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 10743 of file z3py.py.

10743 def fpIsNaN(a, ctx=None):
10744  """Create a Z3 floating-point isNaN expression.
10745 
10746  >>> s = FPSort(8, 24)
10747  >>> x = FP('x', s)
10748  >>> y = FP('y', s)
10749  >>> fpIsNaN(x)
10750  fpIsNaN(x)
10751  """
10752  return _mk_fp_unary_pred(Z3_mk_fpa_is_nan, a, ctx)
10753 
10754 
def fpIsNaN
Definition: z3py.py:10743
def z3py.fpIsNegative (   a,
  ctx = None 
)
Create a Z3 floating-point isNegative expression.

Definition at line 10784 of file z3py.py.

10784 def fpIsNegative(a, ctx=None):
10785  """Create a Z3 floating-point isNegative expression.
10786  """
10787  return _mk_fp_unary_pred(Z3_mk_fpa_is_negative, a, ctx)
10788 
10789 
def fpIsNegative
Definition: z3py.py:10784
def z3py.fpIsNormal (   a,
  ctx = None 
)
Create a Z3 floating-point isNormal expression.

Definition at line 10772 of file z3py.py.

10772 def fpIsNormal(a, ctx=None):
10773  """Create a Z3 floating-point isNormal expression.
10774  """
10775  return _mk_fp_unary_pred(Z3_mk_fpa_is_normal, a, ctx)
10776 
10777 
def fpIsNormal
Definition: z3py.py:10772
def z3py.fpIsPositive (   a,
  ctx = None 
)
Create a Z3 floating-point isPositive expression.

Definition at line 10790 of file z3py.py.

10790 def fpIsPositive(a, ctx=None):
10791  """Create a Z3 floating-point isPositive expression.
10792  """
10793  return _mk_fp_unary_pred(Z3_mk_fpa_is_positive, a, ctx)
10794 
10795 
def fpIsPositive
Definition: z3py.py:10790
def z3py.fpIsSubnormal (   a,
  ctx = None 
)
Create a Z3 floating-point isSubnormal expression.

Definition at line 10778 of file z3py.py.

10778 def fpIsSubnormal(a, ctx=None):
10779  """Create a Z3 floating-point isSubnormal expression.
10780  """
10781  return _mk_fp_unary_pred(Z3_mk_fpa_is_subnormal, a, ctx)
10782 
10783 
def fpIsSubnormal
Definition: z3py.py:10778
def z3py.fpIsZero (   a,
  ctx = None 
)
Create a Z3 floating-point isZero expression.

Definition at line 10766 of file z3py.py.

10766 def fpIsZero(a, ctx=None):
10767  """Create a Z3 floating-point isZero expression.
10768  """
10769  return _mk_fp_unary_pred(Z3_mk_fpa_is_zero, a, ctx)
10770 
10771 
def fpIsZero
Definition: z3py.py:10766
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 10813 of file z3py.py.

10813 def fpLEQ(a, b, ctx=None):
10814  """Create the Z3 floating-point expression `other <= self`.
10815 
10816  >>> x, y = FPs('x y', FPSort(8, 24))
10817  >>> fpLEQ(x, y)
10818  x <= y
10819  >>> (x <= y).sexpr()
10820  '(fp.leq x y)'
10821  """
10822  return _mk_fp_bin_pred(Z3_mk_fpa_leq, a, b, ctx)
10823 
10824 
def fpLEQ
Definition: z3py.py:10813
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 10801 of file z3py.py.

10801 def fpLT(a, b, ctx=None):
10802  """Create the Z3 floating-point expression `other < self`.
10803 
10804  >>> x, y = FPs('x y', FPSort(8, 24))
10805  >>> fpLT(x, y)
10806  x < y
10807  >>> (x < y).sexpr()
10808  '(fp.lt x y)'
10809  """
10810  return _mk_fp_bin_pred(Z3_mk_fpa_lt, a, b, ctx)
10811 
10812 
def fpLT
Definition: z3py.py:10801
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 10710 of file z3py.py.

10710 def fpMax(a, b, ctx=None):
10711  """Create a Z3 floating-point maximum expression.
10712 
10713  >>> s = FPSort(8, 24)
10714  >>> rm = RNE()
10715  >>> x = FP('x', s)
10716  >>> y = FP('y', s)
10717  >>> fpMax(x, y)
10718  fpMax(x, y)
10719  >>> fpMax(x, y).sort()
10720  FPSort(8, 24)
10721  """
10722  return _mk_fp_bin_norm(Z3_mk_fpa_max, a, b, ctx)
10723 
10724 
def fpMax
Definition: z3py.py:10710
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 10695 of file z3py.py.

10695 def fpMin(a, b, ctx=None):
10696  """Create a Z3 floating-point minimum expression.
10697 
10698  >>> s = FPSort(8, 24)
10699  >>> rm = RNE()
10700  >>> x = FP('x', s)
10701  >>> y = FP('y', s)
10702  >>> fpMin(x, y)
10703  fpMin(x, y)
10704  >>> fpMin(x, y).sort()
10705  FPSort(8, 24)
10706  """
10707  return _mk_fp_bin_norm(Z3_mk_fpa_min, a, b, ctx)
10708 
10709 
def fpMin
Definition: z3py.py:10695
def z3py.fpMinusInfinity (   s)
Create a Z3 floating-point -oo term.

Definition at line 10407 of file z3py.py.

10408  """Create a Z3 floating-point -oo term."""
10409  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
10410  return FPNumRef(Z3_mk_fpa_inf(s.ctx_ref(), s.ast, True), s.ctx)
10411 
10412 
def fpMinusInfinity(s)
Definition: z3py.py:10407
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 10426 of file z3py.py.

10427  """Create a Z3 floating-point -0.0 term."""
10428  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
10429  return FPNumRef(Z3_mk_fpa_zero(s.ctx_ref(), s.ast, True), s.ctx)
10430 
10431 
def fpMinusZero(s)
Definition: z3py.py:10426
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)
x * y
>>> fpMul(rm, x, y).sort()
FPSort(8, 24)

Definition at line 10651 of file z3py.py.

Referenced by FPs().

10651 def fpMul(rm, a, b, ctx=None):
10652  """Create a Z3 floating-point multiplication expression.
10653 
10654  >>> s = FPSort(8, 24)
10655  >>> rm = RNE()
10656  >>> x = FP('x', s)
10657  >>> y = FP('y', s)
10658  >>> fpMul(rm, x, y)
10659  x * y
10660  >>> fpMul(rm, x, y).sort()
10661  FPSort(8, 24)
10662  """
10663  return _mk_fp_bin(Z3_mk_fpa_mul, rm, a, b, ctx)
10664 
10665 
def fpMul
Definition: z3py.py:10651
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 10373 of file z3py.py.

10373 def fpNaN(s):
10374  """Create a Z3 floating-point NaN term.
10375 
10376  >>> s = FPSort(8, 24)
10377  >>> set_fpa_pretty(True)
10378  >>> fpNaN(s)
10379  NaN
10380  >>> pb = get_fpa_pretty()
10381  >>> set_fpa_pretty(False)
10382  >>> fpNaN(s)
10383  fpNaN(FPSort(8, 24))
10384  >>> set_fpa_pretty(pb)
10385  """
10386  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
10387  return FPNumRef(Z3_mk_fpa_nan(s.ctx_ref(), s.ast), s.ctx)
10388 
10389 
def fpNaN(s)
Definition: z3py.py:10373
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 10551 of file z3py.py.

10551 def fpNeg(a, ctx=None):
10552  """Create a Z3 floating-point addition expression.
10553 
10554  >>> s = FPSort(8, 24)
10555  >>> rm = RNE()
10556  >>> x = FP('x', s)
10557  >>> fpNeg(x)
10558  -x
10559  >>> fpNeg(x).sort()
10560  FPSort(8, 24)
10561  """
10562  ctx = _get_ctx(ctx)
10563  [a] = _coerce_fp_expr_list([a], ctx)
10564  return FPRef(Z3_mk_fpa_neg(ctx.ref(), a.as_ast()), ctx)
10565 
10566 
Z3_ast Z3_API Z3_mk_fpa_neg(Z3_context c, Z3_ast t)
Floating-point negation.
def fpNeg
Definition: z3py.py:10551
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 10861 of file z3py.py.

10861 def fpNEQ(a, b, ctx=None):
10862  """Create the Z3 floating-point expression `Not(fpEQ(other, self))`.
10863 
10864  >>> x, y = FPs('x y', FPSort(8, 24))
10865  >>> fpNEQ(x, y)
10866  Not(fpEQ(x, y))
10867  >>> (x != y).sexpr()
10868  '(distinct x y)'
10869  """
10870  return Not(fpEQ(a, b, ctx))
10871 
10872 
def Not
Definition: z3py.py:1948
def fpEQ
Definition: z3py.py:10849
def fpNEQ
Definition: z3py.py:10861
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 10390 of file z3py.py.

10391  """Create a Z3 floating-point +oo term.
10392 
10393  >>> s = FPSort(8, 24)
10394  >>> pb = get_fpa_pretty()
10395  >>> set_fpa_pretty(True)
10396  >>> fpPlusInfinity(s)
10397  +oo
10398  >>> set_fpa_pretty(False)
10399  >>> fpPlusInfinity(s)
10400  fpPlusInfinity(FPSort(8, 24))
10401  >>> set_fpa_pretty(pb)
10402  """
10403  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
10404  return FPNumRef(Z3_mk_fpa_inf(s.ctx_ref(), s.ast, False), s.ctx)
10405 
10406 
def fpPlusInfinity(s)
Definition: z3py.py:10390
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 10420 of file z3py.py.

10420 def fpPlusZero(s):
10421  """Create a Z3 floating-point +0.0 term."""
10422  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
10423  return FPNumRef(Z3_mk_fpa_zero(s.ctx_ref(), s.ast, False), s.ctx)
10424 
10425 
def fpPlusZero(s)
Definition: z3py.py:10420
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 10978 of file z3py.py.

10978 def fpRealToFP(rm, v, sort, ctx=None):
10979  """Create a Z3 floating-point conversion expression that represents the
10980  conversion from a real term to a floating-point term.
10981 
10982  >>> x_r = RealVal(1.5)
10983  >>> x_fp = fpRealToFP(RNE(), x_r, Float32())
10984  >>> x_fp
10985  fpToFP(RNE(), 3/2)
10986  >>> simplify(x_fp)
10987  1.5
10988  """
10989  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression.")
10990  _z3_assert(is_real(v), "Second argument must be a Z3 expression or real sort.")
10991  _z3_assert(is_fp_sort(sort), "Third argument must be a Z3 floating-point sort.")
10992  ctx = _get_ctx(ctx)
10993  return FPRef(Z3_mk_fpa_to_fp_real(ctx.ref(), rm.ast, v.ast, sort.ast), ctx)
10994 
10995 
Z3_ast Z3_API Z3_mk_fpa_to_fp_real(Z3_context c, Z3_ast rm, Z3_ast t, Z3_sort s)
Conversion of a term of real sort into a term of FloatingPoint sort.
def is_real(a)
Definition: z3py.py:2859
def fpRealToFP
Definition: z3py.py:10978
def is_fp_sort(s)
Definition: z3py.py:9859
def is_fprm(a)
Definition: z3py.py:10119
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 10681 of file z3py.py.

10681 def fpRem(a, b, ctx=None):
10682  """Create a Z3 floating-point remainder expression.
10683 
10684  >>> s = FPSort(8, 24)
10685  >>> x = FP('x', s)
10686  >>> y = FP('y', s)
10687  >>> fpRem(x, y)
10688  fpRem(x, y)
10689  >>> fpRem(x, y).sort()
10690  FPSort(8, 24)
10691  """
10692  return _mk_fp_bin_norm(Z3_mk_fpa_rem, a, b, ctx)
10693 
10694 
def fpRem
Definition: z3py.py:10681
def z3py.fpRoundToIntegral (   rm,
  a,
  ctx = None 
)
Create a Z3 floating-point roundToIntegral expression.

Definition at line 10737 of file z3py.py.

10737 def fpRoundToIntegral(rm, a, ctx=None):
10738  """Create a Z3 floating-point roundToIntegral expression.
10739  """
10740  return _mk_fp_unary(Z3_mk_fpa_round_to_integral, rm, a, ctx)
10741 
10742 
def fpRoundToIntegral
Definition: z3py.py:10737
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)
(x + y) * z

Definition at line 10509 of file z3py.py.

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

10509 def FPs(names, fpsort, ctx=None):
10510  """Return an array of floating-point constants.
10511 
10512  >>> x, y, z = FPs('x y z', FPSort(8, 24))
10513  >>> x.sort()
10514  FPSort(8, 24)
10515  >>> x.sbits()
10516  24
10517  >>> x.ebits()
10518  8
10519  >>> fpMul(RNE(), fpAdd(RNE(), x, y), z)
10520  (x + y) * z
10521  """
10522  ctx = _get_ctx(ctx)
10523  if isinstance(names, str):
10524  names = names.split(" ")
10525  return [FP(name, fpsort, ctx) for name in names]
10526 
10527 
def FP
Definition: z3py.py:10485
def FPs
Definition: z3py.py:10509
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 10996 of file z3py.py.

10996 def fpSignedToFP(rm, v, sort, ctx=None):
10997  """Create a Z3 floating-point conversion expression that represents the
10998  conversion from a signed bit-vector term (encoding an integer) to a floating-point term.
10999 
11000  >>> x_signed = BitVecVal(-5, BitVecSort(32))
11001  >>> x_fp = fpSignedToFP(RNE(), x_signed, Float32())
11002  >>> x_fp
11003  fpToFP(RNE(), 4294967291)
11004  >>> simplify(x_fp)
11005  -1.25*(2**2)
11006  """
11007  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression.")
11008  _z3_assert(is_bv(v), "Second argument must be a Z3 bit-vector expression")
11009  _z3_assert(is_fp_sort(sort), "Third argument must be a Z3 floating-point sort.")
11010  ctx = _get_ctx(ctx)
11011  return FPRef(Z3_mk_fpa_to_fp_signed(ctx.ref(), rm.ast, v.ast, sort.ast), ctx)
11012 
11013 
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:10996
def is_fp_sort(s)
Definition: z3py.py:9859
def is_bv(a)
Definition: z3py.py:4111
def is_fprm(a)
Definition: z3py.py:10119
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 10314 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(), FPSortRef.sbits(), FPRef.sbits(), FPNumRef.sign_as_bv(), FPNumRef.significand(), FPNumRef.significand_as_bv(), and FPRef.sort().

10314 def FPSort(ebits, sbits, ctx=None):
10315  """Return a Z3 floating-point sort of the given sizes. If `ctx=None`, then the global context is used.
10316 
10317  >>> Single = FPSort(8, 24)
10318  >>> Double = FPSort(11, 53)
10319  >>> Single
10320  FPSort(8, 24)
10321  >>> x = Const('x', Single)
10322  >>> eq(x, FP('x', FPSort(8, 24)))
10323  True
10324  """
10325  ctx = _get_ctx(ctx)
10326  return FPSortRef(Z3_mk_fpa_sort(ctx.ref(), ebits, sbits), ctx)
10327 
10328 
Z3_sort Z3_API Z3_mk_fpa_sort(Z3_context c, unsigned ebits, unsigned sbits)
Create a FloatingPoint sort.
def FPSort
Definition: z3py.py:10314
def z3py.fpSqrt (   rm,
  a,
  ctx = None 
)
Create a Z3 floating-point square root expression.

Definition at line 10731 of file z3py.py.

10731 def fpSqrt(rm, a, ctx=None):
10732  """Create a Z3 floating-point square root expression.
10733  """
10734  return _mk_fp_unary(Z3_mk_fpa_sqrt, rm, a, ctx)
10735 
10736 
def fpSqrt
Definition: z3py.py:10731
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)
x - y
>>> fpSub(rm, x, y).sort()
FPSort(8, 24)

Definition at line 10636 of file z3py.py.

10636 def fpSub(rm, a, b, ctx=None):
10637  """Create a Z3 floating-point subtraction expression.
10638 
10639  >>> s = FPSort(8, 24)
10640  >>> rm = RNE()
10641  >>> x = FP('x', s)
10642  >>> y = FP('y', s)
10643  >>> fpSub(rm, x, y)
10644  x - y
10645  >>> fpSub(rm, x, y).sort()
10646  FPSort(8, 24)
10647  """
10648  return _mk_fp_bin(Z3_mk_fpa_sub, rm, a, b, ctx)
10649 
10650 
def fpSub
Definition: z3py.py:10636
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 10902 of file z3py.py.

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

10902 def fpToFP(a1, a2=None, a3=None, ctx=None):
10903  """Create a Z3 floating-point conversion expression from other term sorts
10904  to floating-point.
10905 
10906  From a bit-vector term in IEEE 754-2008 format:
10907  >>> x = FPVal(1.0, Float32())
10908  >>> x_bv = fpToIEEEBV(x)
10909  >>> simplify(fpToFP(x_bv, Float32()))
10910  1
10911 
10912  From a floating-point term with different precision:
10913  >>> x = FPVal(1.0, Float32())
10914  >>> x_db = fpToFP(RNE(), x, Float64())
10915  >>> x_db.sort()
10916  FPSort(11, 53)
10917 
10918  From a real term:
10919  >>> x_r = RealVal(1.5)
10920  >>> simplify(fpToFP(RNE(), x_r, Float32()))
10921  1.5
10922 
10923  From a signed bit-vector term:
10924  >>> x_signed = BitVecVal(-5, BitVecSort(32))
10925  >>> simplify(fpToFP(RNE(), x_signed, Float32()))
10926  -1.25*(2**2)
10927  """
10928  ctx = _get_ctx(ctx)
10929  if is_bv(a1) and is_fp_sort(a2):
10930  return FPRef(Z3_mk_fpa_to_fp_bv(ctx.ref(), a1.ast, a2.ast), ctx)
10931  elif is_fprm(a1) and is_fp(a2) and is_fp_sort(a3):
10932  return FPRef(Z3_mk_fpa_to_fp_float(ctx.ref(), a1.ast, a2.ast, a3.ast), ctx)
10933  elif is_fprm(a1) and is_real(a2) and is_fp_sort(a3):
10934  return FPRef(Z3_mk_fpa_to_fp_real(ctx.ref(), a1.ast, a2.ast, a3.ast), ctx)
10935  elif is_fprm(a1) and is_bv(a2) and is_fp_sort(a3):
10936  return FPRef(Z3_mk_fpa_to_fp_signed(ctx.ref(), a1.ast, a2.ast, a3.ast), ctx)
10937  else:
10938  raise Z3Exception("Unsupported combination of arguments for conversion to floating-point term.")
10939 
10940 
def fpToFP
Definition: z3py.py:10902
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...
def is_real(a)
Definition: z3py.py:2859
Z3_ast Z3_API Z3_mk_fpa_to_fp_float(Z3_context c, Z3_ast rm, Z3_ast t, Z3_sort s)
Conversion of a FloatingPoint term into another term of different FloatingPoint sort.
def is_fp_sort(s)
Definition: z3py.py:9859
def is_bv(a)
Definition: z3py.py:4111
def is_fprm(a)
Definition: z3py.py:10119
def is_fp(a)
Definition: z3py.py:10285
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 11032 of file z3py.py.

Referenced by fpUnsignedToFP().

11032 def fpToFPUnsigned(rm, x, s, ctx=None):
11033  """Create a Z3 floating-point conversion expression, from unsigned bit-vector to floating-point expression."""
11034  if z3_debug():
11035  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
11036  _z3_assert(is_bv(x), "Second argument must be a Z3 bit-vector expression")
11037  _z3_assert(is_fp_sort(s), "Third argument must be Z3 floating-point sort")
11038  ctx = _get_ctx(ctx)
11039  return FPRef(Z3_mk_fpa_to_fp_unsigned(ctx.ref(), rm.ast, x.ast, s.ast), ctx)
11040 
11041 
def fpToFPUnsigned
Definition: z3py.py:11032
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:70
def is_fp_sort(s)
Definition: z3py.py:9859
def is_bv(a)
Definition: z3py.py:4111
def is_fprm(a)
Definition: z3py.py:10119
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 11106 of file z3py.py.

Referenced by fpToFP().

11106 def fpToIEEEBV(x, ctx=None):
11107  """\brief Conversion of a floating-point term into a bit-vector term in IEEE 754-2008 format.
11108 
11109  The size of the resulting bit-vector is automatically determined.
11110 
11111  Note that IEEE 754-2008 allows multiple different representations of NaN. This conversion
11112  knows only one NaN and it will always produce the same bit-vector representation of
11113  that NaN.
11114 
11115  >>> x = FP('x', FPSort(8, 24))
11116  >>> y = fpToIEEEBV(x)
11117  >>> print(is_fp(x))
11118  True
11119  >>> print(is_bv(y))
11120  True
11121  >>> print(is_fp(y))
11122  False
11123  >>> print(is_bv(x))
11124  False
11125  """
11126  if z3_debug():
11127  _z3_assert(is_fp(x), "First argument must be a Z3 floating-point expression")
11128  ctx = _get_ctx(ctx)
11129  return BitVecRef(Z3_mk_fpa_to_ieee_bv(ctx.ref(), x.ast), ctx)
11130 
11131 
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:70
def fpToIEEEBV
Definition: z3py.py:11106
def is_fp(a)
Definition: z3py.py:10285
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 11086 of file z3py.py.

11086 def fpToReal(x, ctx=None):
11087  """Create a Z3 floating-point conversion expression, from floating-point expression to real.
11088 
11089  >>> x = FP('x', FPSort(8, 24))
11090  >>> y = fpToReal(x)
11091  >>> print(is_fp(x))
11092  True
11093  >>> print(is_real(y))
11094  True
11095  >>> print(is_fp(y))
11096  False
11097  >>> print(is_real(x))
11098  False
11099  """
11100  if z3_debug():
11101  _z3_assert(is_fp(x), "First argument must be a Z3 floating-point expression")
11102  ctx = _get_ctx(ctx)
11103  return ArithRef(Z3_mk_fpa_to_real(ctx.ref(), x.ast), ctx)
11104 
11105 
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 z3_debug()
Definition: z3py.py:70
def fpToReal
Definition: z3py.py:11086
def is_fp(a)
Definition: z3py.py:10285
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 11042 of file z3py.py.

11042 def fpToSBV(rm, x, s, ctx=None):
11043  """Create a Z3 floating-point conversion expression, from floating-point expression to signed bit-vector.
11044 
11045  >>> x = FP('x', FPSort(8, 24))
11046  >>> y = fpToSBV(RTZ(), x, BitVecSort(32))
11047  >>> print(is_fp(x))
11048  True
11049  >>> print(is_bv(y))
11050  True
11051  >>> print(is_fp(y))
11052  False
11053  >>> print(is_bv(x))
11054  False
11055  """
11056  if z3_debug():
11057  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
11058  _z3_assert(is_fp(x), "Second argument must be a Z3 floating-point expression")
11059  _z3_assert(is_bv_sort(s), "Third argument must be Z3 bit-vector sort")
11060  ctx = _get_ctx(ctx)
11061  return BitVecRef(Z3_mk_fpa_to_sbv(ctx.ref(), rm.ast, x.ast, s.size()), ctx)
11062 
11063 
Z3_ast Z3_API Z3_mk_fpa_to_sbv(Z3_context c, Z3_ast rm, Z3_ast t, unsigned sz)
Conversion of a floating-point term into a signed bit-vector.
def fpToSBV
Definition: z3py.py:11042
def z3_debug()
Definition: z3py.py:70
def is_bv_sort(s)
Definition: z3py.py:3638
def is_fprm(a)
Definition: z3py.py:10119
def is_fp(a)
Definition: z3py.py:10285
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 11064 of file z3py.py.

11064 def fpToUBV(rm, x, s, ctx=None):
11065  """Create a Z3 floating-point conversion expression, from floating-point expression to unsigned bit-vector.
11066 
11067  >>> x = FP('x', FPSort(8, 24))
11068  >>> y = fpToUBV(RTZ(), x, BitVecSort(32))
11069  >>> print(is_fp(x))
11070  True
11071  >>> print(is_bv(y))
11072  True
11073  >>> print(is_fp(y))
11074  False
11075  >>> print(is_bv(x))
11076  False
11077  """
11078  if z3_debug():
11079  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression")
11080  _z3_assert(is_fp(x), "Second argument must be a Z3 floating-point expression")
11081  _z3_assert(is_bv_sort(s), "Third argument must be Z3 bit-vector sort")
11082  ctx = _get_ctx(ctx)
11083  return BitVecRef(Z3_mk_fpa_to_ubv(ctx.ref(), rm.ast, x.ast, s.size()), ctx)
11084 
11085 
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 z3_debug()
Definition: z3py.py:70
def is_bv_sort(s)
Definition: z3py.py:3638
def fpToUBV
Definition: z3py.py:11064
def is_fprm(a)
Definition: z3py.py:10119
def is_fp(a)
Definition: z3py.py:10285
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 11014 of file z3py.py.

11014 def fpUnsignedToFP(rm, v, sort, ctx=None):
11015  """Create a Z3 floating-point conversion expression that represents the
11016  conversion from an unsigned bit-vector term (encoding an integer) to a floating-point term.
11017 
11018  >>> x_signed = BitVecVal(-5, BitVecSort(32))
11019  >>> x_fp = fpUnsignedToFP(RNE(), x_signed, Float32())
11020  >>> x_fp
11021  fpToFPUnsigned(RNE(), 4294967291)
11022  >>> simplify(x_fp)
11023  1*(2**32)
11024  """
11025  _z3_assert(is_fprm(rm), "First argument must be a Z3 floating-point rounding mode expression.")
11026  _z3_assert(is_bv(v), "Second argument must be a Z3 bit-vector expression")
11027  _z3_assert(is_fp_sort(sort), "Third argument must be a Z3 floating-point sort.")
11028  ctx = _get_ctx(ctx)
11029  return FPRef(Z3_mk_fpa_to_fp_unsigned(ctx.ref(), rm.ast, v.ast, sort.ast), ctx)
11030 
11031 
def fpUnsignedToFP
Definition: z3py.py:11014
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(s)
Definition: z3py.py:9859
def is_bv(a)
Definition: z3py.py:4111
def is_fprm(a)
Definition: z3py.py:10119
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 10439 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().

10439 def FPVal(sig, exp=None, fps=None, ctx=None):
10440  """Return a floating-point value of value `val` and sort `fps`.
10441  If `ctx=None`, then the global context is used.
10442 
10443  >>> v = FPVal(20.0, FPSort(8, 24))
10444  >>> v
10445  1.25*(2**4)
10446  >>> print("0x%.8x" % v.exponent_as_long(False))
10447  0x00000004
10448  >>> v = FPVal(2.25, FPSort(8, 24))
10449  >>> v
10450  1.125*(2**1)
10451  >>> v = FPVal(-2.25, FPSort(8, 24))
10452  >>> v
10453  -1.125*(2**1)
10454  >>> FPVal(-0.0, FPSort(8, 24))
10455  -0.0
10456  >>> FPVal(0.0, FPSort(8, 24))
10457  +0.0
10458  >>> FPVal(+0.0, FPSort(8, 24))
10459  +0.0
10460  """
10461  ctx = _get_ctx(ctx)
10462  if is_fp_sort(exp):
10463  fps = exp
10464  exp = None
10465  elif fps is None:
10466  fps = _dflt_fps(ctx)
10467  _z3_assert(is_fp_sort(fps), "sort mismatch")
10468  if exp is None:
10469  exp = 0
10470  val = _to_float_str(sig)
10471  if val == "NaN" or val == "nan":
10472  return fpNaN(fps)
10473  elif val == "-0.0":
10474  return fpMinusZero(fps)
10475  elif val == "0.0" or val == "+0.0":
10476  return fpPlusZero(fps)
10477  elif val == "+oo" or val == "+inf" or val == "+Inf":
10478  return fpPlusInfinity(fps)
10479  elif val == "-oo" or val == "-inf" or val == "-Inf":
10480  return fpMinusInfinity(fps)
10481  else:
10482  return FPNumRef(Z3_mk_numeral(ctx.ref(), val, fps.ast), ctx)
10483 
10484 
def fpMinusInfinity(s)
Definition: z3py.py:10407
def FPVal
Definition: z3py.py:10439
def fpMinusZero(s)
Definition: z3py.py:10426
def fpPlusZero(s)
Definition: z3py.py:10420
def fpPlusInfinity(s)
Definition: z3py.py:10390
def fpNaN(s)
Definition: z3py.py:10373
def is_fp_sort(s)
Definition: z3py.py:9859
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 10432 of file z3py.py.

10432 def fpZero(s, negative):
10433  """Create a Z3 floating-point +0.0 or -0.0 term."""
10434  _z3_assert(isinstance(s, FPSortRef), "sort mismatch")
10435  _z3_assert(isinstance(negative, bool), "expected Boolean flag")
10436  return FPNumRef(Z3_mk_fpa_zero(s.ctx_ref(), s.ast, negative), s.ctx)
10437 
10438 
def fpZero(s, negative)
Definition: z3py.py:10432
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 1904 of file z3py.py.

1904 def FreshBool(prefix="b", ctx=None):
1905  """Return a fresh Boolean constant in the given context using the given prefix.
1906 
1907  If `ctx=None`, then the global context is used.
1908 
1909  >>> b1 = FreshBool()
1910  >>> b2 = FreshBool()
1911  >>> eq(b1, b2)
1912  False
1913  """
1914  ctx = _get_ctx(ctx)
1915  return BoolRef(Z3_mk_fresh_const(ctx.ref(), prefix, BoolSort(ctx).ast), ctx)
1916 
1917 
def BoolSort
Definition: z3py.py:1824
def FreshBool
Definition: z3py.py:1904
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 1567 of file z3py.py.

1567 def FreshConst(sort, prefix="c"):
1568  """Create a fresh constant of a specified sort"""
1569  if z3_debug():
1570  _z3_assert(is_sort(sort), f"Z3 sort expected, got {type(sort)}")
1571  ctx = _get_ctx(sort.ctx)
1572  return _to_expr_ref(Z3_mk_fresh_const(ctx.ref(), prefix, sort.ast), ctx)
1573 
1574 
def FreshConst
Definition: z3py.py:1567
def z3_debug()
Definition: z3py.py:70
def is_sort
Definition: z3py.py:682
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.FreshFunction (   sig)
Create a new fresh Z3 uninterpreted function with the given sorts.

Definition at line 943 of file z3py.py.

943 def FreshFunction(*sig):
944  """Create a new fresh Z3 uninterpreted function with the given sorts.
945  """
946  sig = _get_args(sig)
947  if z3_debug():
948  _z3_assert(len(sig) > 0, "At least two arguments expected")
949  arity = len(sig) - 1
950  rng = sig[arity]
951  if z3_debug():
952  _z3_assert(is_sort(rng), "Z3 sort expected")
953  dom = (z3.Sort * arity)()
954  for i in range(arity):
955  if z3_debug():
956  _z3_assert(is_sort(sig[i]), "Z3 sort expected")
957  dom[i] = sig[i].ast
958  ctx = rng.ctx
959  return FuncDeclRef(Z3_mk_fresh_func_decl(ctx.ref(), "f", arity, dom, rng.ast), ctx)
960 
961 
Z3_func_decl Z3_API Z3_mk_fresh_func_decl(Z3_context c, Z3_string prefix, unsigned domain_size, Z3_sort const domain[], Z3_sort range)
Declare a fresh constant or function.
Function Declarations.
Definition: z3py.py:775
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:4343
def z3_debug()
Definition: z3py.py:70
def is_sort
Definition: z3py.py:682
def FreshFunction(sig)
Definition: z3py.py:943
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 3447 of file z3py.py.

3447 def FreshInt(prefix="x", ctx=None):
3448  """Return a fresh integer constant in the given context using the given prefix.
3449 
3450  >>> x = FreshInt()
3451  >>> y = FreshInt()
3452  >>> eq(x, y)
3453  False
3454  >>> x.sort()
3455  Int
3456  """
3457  ctx = _get_ctx(ctx)
3458  return ArithRef(Z3_mk_fresh_const(ctx.ref(), prefix, IntSort(ctx).ast), ctx)
3459 
3460 
def IntSort
Definition: z3py.py:3298
def FreshInt
Definition: z3py.py:3447
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 3504 of file z3py.py.

3504 def FreshReal(prefix="b", ctx=None):
3505  """Return a fresh real constant in the given context using the given prefix.
3506 
3507  >>> x = FreshReal()
3508  >>> y = FreshReal()
3509  >>> eq(x, y)
3510  False
3511  >>> x.sort()
3512  Real
3513  """
3514  ctx = _get_ctx(ctx)
3515  return ArithRef(Z3_mk_fresh_const(ctx.ref(), prefix, RealSort(ctx).ast), ctx)
3516 
3517 
def RealSort
Definition: z3py.py:3315
def FreshReal
Definition: z3py.py:3504
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 11409 of file z3py.py.

11409 def Full(s):
11410  """Create the regular expression that accepts the universal language
11411  >>> e = Full(ReSort(SeqSort(IntSort())))
11412  >>> print(e)
11413  Full(ReSort(Seq(Int)))
11414  >>> e1 = Full(ReSort(StringSort()))
11415  >>> print(e1)
11416  Full(ReSort(String))
11417  """
11418  if isinstance(s, ReSortRef):
11419  return ReRef(Z3_mk_re_full(s.ctx_ref(), s.ast), s.ctx)
11420  raise Z3Exception("Non-sequence, non-regular expression sort passed to Full")
11421 
11422 
11423 
def Full(s)
Definition: z3py.py:11409
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 5114 of file z3py.py.

5114 def FullSet(s):
5115  """Create the full set
5116  >>> FullSet(IntSort())
5117  K(Int, True)
5118  """
5119  ctx = s.ctx
5120  return ArrayRef(Z3_mk_full_set(ctx.ref(), s.ast), ctx)
5121 
5122 
Z3_ast Z3_API Z3_mk_full_set(Z3_context c, Z3_sort domain)
Create the full set.
def FullSet(s)
Definition: z3py.py:5114
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 920 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().

920 def Function(name, *sig):
921  """Create a new Z3 uninterpreted function with the given sorts.
922 
923  >>> f = Function('f', IntSort(), IntSort())
924  >>> f(f(0))
925  f(f(0))
926  """
927  sig = _get_args(sig)
928  if z3_debug():
929  _z3_assert(len(sig) > 0, "At least two arguments expected")
930  arity = len(sig) - 1
931  rng = sig[arity]
932  if z3_debug():
933  _z3_assert(is_sort(rng), "Z3 sort expected")
934  dom = (Sort * arity)()
935  for i in range(arity):
936  if z3_debug():
937  _z3_assert(is_sort(sig[i]), "Z3 sort expected")
938  dom[i] = sig[i].ast
939  ctx = rng.ctx
940  return FuncDeclRef(Z3_mk_func_decl(ctx.ref(), to_symbol(name, ctx), arity, dom, rng.ast), ctx)
941 
942 
Function Declarations.
Definition: z3py.py:775
def Function(name, sig)
Definition: z3py.py:920
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:4343
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 z3_debug()
Definition: z3py.py:70
def is_sort
Definition: z3py.py:682
def to_symbol
Definition: z3py.py:132
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 6961 of file z3py.py.

6962  """Return the function declaration f associated with a Z3 expression of the form (_ as-array f)."""
6963  if z3_debug():
6964  _z3_assert(is_as_array(n), "as-array Z3 expression expected.")
6965  return FuncDeclRef(Z3_get_as_array_func_decl(n.ctx.ref(), n.as_ast()), n.ctx)
6966 
Function Declarations.
Definition: z3py.py:775
Z3_func_decl Z3_API Z3_get_as_array_func_decl(Z3_context c, Z3_ast a)
Return the function declaration f associated with a (_ as_array f) node.
def get_as_array_func(n)
Definition: z3py.py:6961
def z3_debug()
Definition: z3py.py:70
def is_as_array(n)
Definition: z3py.py:6956
def z3py.get_ctx (   ctx,
  Context 
)

Definition at line 294 of file z3py.py.

294 def get_ctx(ctx) -> Context:
295  return _get_ctx(ctx)
296 
297 
def get_ctx(ctx)
Definition: z3py.py:294
def z3py.get_default_fp_sort (   ctx = None)

Definition at line 9726 of file z3py.py.

9726 def get_default_fp_sort(ctx=None):
9727  return FPSort(_dflt_fpsort_ebits, _dflt_fpsort_sbits, ctx)
9728 
9729 
def get_default_fp_sort
Definition: z3py.py:9726
def FPSort
Definition: z3py.py:10314
def z3py.get_default_rounding_mode (   ctx = None)
Retrieves the global default rounding mode.

Definition at line 9693 of file z3py.py.

9694  """Retrieves the global default rounding mode."""
9695  global _dflt_rounding_mode
9696  if _dflt_rounding_mode == Z3_OP_FPA_RM_TOWARD_ZERO:
9697  return RTZ(ctx)
9698  elif _dflt_rounding_mode == Z3_OP_FPA_RM_TOWARD_NEGATIVE:
9699  return RTN(ctx)
9700  elif _dflt_rounding_mode == Z3_OP_FPA_RM_TOWARD_POSITIVE:
9701  return RTP(ctx)
9702  elif _dflt_rounding_mode == Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN:
9703  return RNE(ctx)
9704  elif _dflt_rounding_mode == Z3_OP_FPA_RM_NEAREST_TIES_TO_AWAY:
9705  return RNA(ctx)
9706 
9707 
def RNE
Definition: z3py.py:10074
def RNA
Definition: z3py.py:10084
def get_default_rounding_mode
Definition: z3py.py:9693
def RTP
Definition: z3py.py:10094
def RTZ
Definition: z3py.py:10114
def RTN
Definition: z3py.py:10104
def z3py.get_full_version ( )

Definition at line 109 of file z3py.py.

110  return Z3_get_full_version()
111 
112 
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:109
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 4866 of file z3py.py.

4867  """Return the function declaration associated with a Z3 map array expression.
4868 
4869  >>> f = Function('f', IntSort(), IntSort())
4870  >>> b = Array('b', IntSort(), IntSort())
4871  >>> a = Map(f, b)
4872  >>> eq(f, get_map_func(a))
4873  True
4874  >>> get_map_func(a)
4875  f
4876  >>> get_map_func(a)(0)
4877  f(0)
4878  """
4879  if z3_debug():
4880  _z3_assert(is_map(a), "Z3 array map expression expected.")
4881  return FuncDeclRef(
4883  a.ctx_ref(),
4884  Z3_get_decl_ast_parameter(a.ctx_ref(), a.decl().ast, 0),
4885  ),
4886  ctx=a.ctx,
4887  )
4888 
4889 
Function Declarations.
Definition: z3py.py:775
Z3_func_decl Z3_API Z3_to_func_decl(Z3_context c, Z3_ast a)
Convert an AST into a FUNC_DECL_AST. This is just type casting.
def is_map(a)
Definition: z3py.py:4841
def get_map_func(a)
Definition: z3py.py:4866
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:70
def z3py.get_param (   name)
Return the value of a Z3 global (or module) parameter

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

Definition at line 334 of file z3py.py.

334 def get_param(name):
335  """Return the value of a Z3 global (or module) parameter
336 
337  >>> get_param('nlsat.reorder')
338  'true'
339  """
340  ptr = (ctypes.c_char_p * 1)()
341  if Z3_global_param_get(str(name), ptr):
342  r = z3core._to_pystr(ptr[0])
343  return r
344  raise Z3Exception("failed to retrieve value for '%s'" % name)
345 
bool Z3_API Z3_global_param_get(Z3_string param_id, Z3_string_ptr param_value)
Get a global (or module) parameter.
def get_param(name)
Definition: z3py.py:334
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 1438 of file z3py.py.

1439  """Return the de-Bruijn index of the Z3 bounded variable `a`.
1440 
1441  >>> x = Int('x')
1442  >>> y = Int('y')
1443  >>> is_var(x)
1444  False
1445  >>> is_const(x)
1446  True
1447  >>> f = Function('f', IntSort(), IntSort(), IntSort())
1448  >>> # Z3 replaces x and y with bound variables when ForAll is executed.
1449  >>> q = ForAll([x, y], f(x, y) == x + y)
1450  >>> q.body()
1451  f(Var(1), Var(0)) == Var(1) + Var(0)
1452  >>> b = q.body()
1453  >>> b.arg(0)
1454  f(Var(1), Var(0))
1455  >>> v1 = b.arg(0).arg(0)
1456  >>> v2 = b.arg(0).arg(1)
1457  >>> v1
1458  Var(1)
1459  >>> v2
1460  Var(0)
1461  >>> get_var_index(v1)
1462  1
1463  >>> get_var_index(v2)
1464  0
1465  """
1466  if z3_debug():
1467  _z3_assert(is_var(a), "Z3 bound variable expected")
1468  return int(Z3_get_index_value(a.ctx.ref(), a.as_ast()))
1469 
1470 
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:70
def get_var_index(a)
Definition: z3py.py:1438
def is_var(a)
Definition: z3py.py:1413
def z3py.get_version ( )

Definition at line 100 of file z3py.py.

101  major = ctypes.c_uint(0)
102  minor = ctypes.c_uint(0)
103  build = ctypes.c_uint(0)
104  rev = ctypes.c_uint(0)
105  Z3_get_version(major, minor, build, rev)
106  return (major.value, minor.value, build.value, rev.value)
107 
108 
def get_version()
Definition: z3py.py:100
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 91 of file z3py.py.

92  major = ctypes.c_uint(0)
93  minor = ctypes.c_uint(0)
94  build = ctypes.c_uint(0)
95  rev = ctypes.c_uint(0)
96  Z3_get_version(major, minor, build, rev)
97  return "%s.%s.%s" % (major.value, minor.value, build.value)
98 
99 
def get_version_string()
Definition: z3py.py:91
void Z3_API Z3_get_version(unsigned *major, unsigned *minor, unsigned *build_number, unsigned *revision_number)
Return Z3 version number information.
def z3py.help_simplify ( )
Return a string describing all options available for Z3 `simplify` procedure.

Definition at line 9199 of file z3py.py.

9200  """Return a string describing all options available for Z3 `simplify` procedure."""
9201  print(Z3_simplify_get_help(main_ctx().ref()))
9202 
9203 
def main_ctx()
Definition: z3py.py:266
def help_simplify()
Definition: z3py.py:9199
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 1484 of file z3py.py.

Referenced by ArithRef.__abs__(), BoolRef.__add__(), BoolRef.__mul__(), Abs(), BV2Int(), and Lambda().

1484 def If(a, b, c, ctx=None):
1485  """Create a Z3 if-then-else expression.
1486 
1487  >>> x = Int('x')
1488  >>> y = Int('y')
1489  >>> max = If(x > y, x, y)
1490  >>> max
1491  If(x > y, x, y)
1492  >>> simplify(max)
1493  If(x <= y, y, x)
1494  """
1495  if isinstance(a, Probe) or isinstance(b, Tactic) or isinstance(c, Tactic):
1496  return Cond(a, b, c, ctx)
1497  else:
1498  ctx = _get_ctx(_ctx_from_ast_arg_list([a, b, c], ctx))
1499  s = BoolSort(ctx)
1500  a = s.cast(a)
1501  b, c = _coerce_exprs(b, c, ctx)
1502  if z3_debug():
1503  _z3_assert(a.ctx == b.ctx, "Context mismatch")
1504  return _to_expr_ref(Z3_mk_ite(ctx.ref(), a.as_ast(), b.as_ast(), c.as_ast()), ctx)
1505 
1506 
def BoolSort
Definition: z3py.py:1824
def If
Definition: z3py.py:1484
def Cond
Definition: z3py.py:9157
def z3_debug()
Definition: z3py.py:70
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)

Definition at line 1918 of file z3py.py.

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

1918 def Implies(a, b, ctx=None):
1919  """Create a Z3 implies expression.
1920 
1921  >>> p, q = Bools('p q')
1922  >>> Implies(p, q)
1923  Implies(p, q)
1924  """
1925  ctx = _get_ctx(_ctx_from_ast_arg_list([a, b], ctx))
1926  s = BoolSort(ctx)
1927  a = s.cast(a)
1928  b = s.cast(b)
1929  return BoolRef(Z3_mk_implies(ctx.ref(), a.as_ast(), b.as_ast()), ctx)
1930 
1931 
def BoolSort
Definition: z3py.py:1824
def Implies
Definition: z3py.py:1918
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,
  offset = None 
)
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 11493 of file z3py.py.

11493 def IndexOf(s, substr, offset=None):
11494  """Retrieve the index of substring within a string starting at a specified offset.
11495  >>> simplify(IndexOf("abcabc", "bc", 0))
11496  1
11497  >>> simplify(IndexOf("abcabc", "bc", 2))
11498  4
11499  """
11500  if offset is None:
11501  offset = IntVal(0)
11502  ctx = None
11503  if is_expr(offset):
11504  ctx = offset.ctx
11505  ctx = _get_ctx2(s, substr, ctx)
11506  s = _coerce_seq(s, ctx)
11507  substr = _coerce_seq(substr, ctx)
11508  if _is_int(offset):
11509  offset = IntVal(offset, ctx)
11510  return ArithRef(Z3_mk_seq_index(s.ctx_ref(), s.as_ast(), substr.as_ast(), offset.as_ast()), s.ctx)
11511 
11512 
Z3_ast Z3_API Z3_mk_seq_index(Z3_context c, Z3_ast s, Z3_ast substr, Z3_ast offset)
Return index of the first occurrence of substr in s starting from offset offset. If s does not contai...
def is_expr(a)
Definition: z3py.py:1345
def IndexOf
Definition: z3py.py:11493
def IntVal
Definition: z3py.py:3344
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 11632 of file z3py.py.

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

11632 def InRe(s, re):
11633  """Create regular expression membership test
11634  >>> re = Union(Re("a"),Re("b"))
11635  >>> print (simplify(InRe("a", re)))
11636  True
11637  >>> print (simplify(InRe("b", re)))
11638  True
11639  >>> print (simplify(InRe("c", re)))
11640  False
11641  """
11642  s = _coerce_seq(s, re.ctx)
11643  return BoolRef(Z3_mk_seq_in_re(s.ctx_ref(), s.as_ast(), re.as_ast()), s.ctx)
11644 
11645 
def InRe(s, re)
Definition: z3py.py:11632
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 3408 of file z3py.py.

Referenced by ArithRef.__abs__(), 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(), Goal.simplify(), ArithRef.sort(), Solver.statistics(), Store(), ToReal(), Goal.translate(), AstVector.translate(), Update(), QuantifierRef.var_name(), QuantifierRef.var_sort(), and QuantifierRef.weight().

3408 def Int(name, ctx=None):
3409  """Return an integer constant named `name`. If `ctx=None`, then the global context is used.
3410 
3411  >>> x = Int('x')
3412  >>> is_int(x)
3413  True
3414  >>> is_int(x + 1)
3415  True
3416  """
3417  ctx = _get_ctx(ctx)
3418  return ArithRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), IntSort(ctx).ast), ctx)
3419 
3420 
def IntSort
Definition: z3py.py:3298
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:3408
def to_symbol
Definition: z3py.py:132
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 4163 of file z3py.py.

4163 def Int2BV(a, num_bits):
4164  """Return the z3 expression Int2BV(a, num_bits).
4165  It is a bit-vector of width num_bits and represents the
4166  modulo of a by 2^num_bits
4167  """
4168  ctx = a.ctx
4169  return BitVecRef(Z3_mk_int2bv(ctx.ref(), num_bits, a.as_ast()), ctx)
4170 
4171 
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 Int2BV(a, num_bits)
Definition: z3py.py:4163
def z3py.Intersect (   args)
Create intersection of regular expressions.
>>> re = Intersect(Re("a"), Re("b"), Re("c"))

Definition at line 11666 of file z3py.py.

11666 def Intersect(*args):
11667  """Create intersection of regular expressions.
11668  >>> re = Intersect(Re("a"), Re("b"), Re("c"))
11669  """
11670  args = _get_args(args)
11671  sz = len(args)
11672  if z3_debug():
11673  _z3_assert(sz > 0, "At least one argument expected.")
11674  _z3_assert(all([is_re(a) for a in args]), "All arguments must be regular expressions.")
11675  if sz == 1:
11676  return args[0]
11677  ctx = args[0].ctx
11678  v = (Ast * sz)()
11679  for i in range(sz):
11680  v[i] = args[i].as_ast()
11681  return ReRef(Z3_mk_re_intersect(ctx.ref(), sz, v), ctx)
11682 
11683 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:4343
def Intersect(args)
Definition: z3py.py:11666
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(s)
Definition: z3py.py:11628
def z3_debug()
Definition: z3py.py:70
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 3421 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().

3421 def Ints(names, ctx=None):
3422  """Return a tuple of Integer constants.
3423 
3424  >>> x, y, z = Ints('x y z')
3425  >>> Sum(x, y, z)
3426  x + y + z
3427  """
3428  ctx = _get_ctx(ctx)
3429  if isinstance(names, str):
3430  names = names.split(" ")
3431  return [Int(name, ctx) for name in names]
3432 
3433 
def Ints
Definition: z3py.py:3421
def Int
Definition: z3py.py:3408
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 3298 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(), DatatypeSort(), 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(), 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(), 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(), DatatypeRef.update_field(), FuncEntry.value(), QuantifierRef.var_name(), QuantifierRef.var_sort(), and QuantifierRef.weight().

3298 def IntSort(ctx=None):
3299  """Return the integer sort in the given context. If `ctx=None`, then the global context is used.
3300 
3301  >>> IntSort()
3302  Int
3303  >>> x = Const('x', IntSort())
3304  >>> is_int(x)
3305  True
3306  >>> x.sort() == IntSort()
3307  True
3308  >>> x.sort() == BoolSort()
3309  False
3310  """
3311  ctx = _get_ctx(ctx)
3312  return ArithSortRef(Z3_mk_int_sort(ctx.ref()), ctx)
3313 
3314 
def IntSort
Definition: z3py.py:3298
Z3_sort Z3_API Z3_mk_int_sort(Z3_context c)
Create the integer type.
Arithmetic.
Definition: z3py.py:2431
def z3py.IntToStr (   s)
Convert integer expression to string

Definition at line 11574 of file z3py.py.

Referenced by StrToInt().

11574 def IntToStr(s):
11575  """Convert integer expression to string"""
11576  if not is_expr(s):
11577  s = _py2expr(s)
11578  return SeqRef(Z3_mk_int_to_str(s.ctx_ref(), s.as_ast()), s.ctx)
11579 
11580 
def IntToStr(s)
Definition: z3py.py:11574
def is_expr(a)
Definition: z3py.py:1345
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 3344 of file z3py.py.

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

3344 def IntVal(val, ctx=None):
3345  """Return a Z3 integer value. If `ctx=None`, then the global context is used.
3346 
3347  >>> IntVal(1)
3348  1
3349  >>> IntVal("100")
3350  100
3351  """
3352  ctx = _get_ctx(ctx)
3353  return IntNumRef(Z3_mk_numeral(ctx.ref(), _to_int_str(val), IntSort(ctx).ast), ctx)
3354 
3355 
def IntSort
Definition: z3py.py:3298
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:3344
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 3434 of file z3py.py.

3434 def IntVector(prefix, sz, ctx=None):
3435  """Return a list of integer constants of size `sz`.
3436 
3437  >>> X = IntVector('x', 3)
3438  >>> X
3439  [x__0, x__1, x__2]
3440  >>> Sum(X)
3441  x__0 + x__1 + x__2
3442  """
3443  ctx = _get_ctx(ctx)
3444  return [Int("%s__%s" % (prefix, i), ctx) for i in range(sz)]
3445 
3446 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:4343
def Int
Definition: z3py.py:3408
def IntVector
Definition: z3py.py:3434
def z3py.is_add (   a)

Definition at line 2946 of file z3py.py.

2946 def is_add(a : Any) -> bool:
2947  """Return `True` if `a` is an expression of the form b + c.
2948 
2949  >>> x, y = Ints('x y')
2950  >>> is_add(x + y)
2951  True
2952  >>> is_add(x - y)
2953  False
2954  """
2955  return is_app_of(a, Z3_OP_ADD)
2956 
2957 
def is_add
Definition: z3py.py:2946
def is_app_of(a, k)
Definition: z3py.py:1471
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 2932 of file z3py.py.

2933  """Return `True` if `a` is an algebraic value of sort Real.
2934 
2935  >>> is_algebraic_value(RealVal("3/5"))
2936  False
2937  >>> n = simplify(Sqrt(2))
2938  >>> n
2939  1.4142135623?
2940  >>> is_algebraic_value(n)
2941  True
2942  """
2943  return is_arith(a) and a.is_real() and _is_algebraic(a.ctx, a.as_ast())
2944 
2945 
def is_arith(a)
Definition: z3py.py:2819
def is_algebraic_value(a)
Definition: z3py.py:2932
def z3py.is_and (   a)

Definition at line 1754 of file z3py.py.

1754 def is_and(a : Any) -> bool:
1755  """Return `True` if `a` is a Z3 and expression.
1756 
1757  >>> p, q = Bools('p q')
1758  >>> is_and(And(p, q))
1759  True
1760  >>> is_and(Or(p, q))
1761  False
1762  """
1763  return is_app_of(a, Z3_OP_AND)
1764 
1765 
def is_and
Definition: z3py.py:1754
def is_app_of(a, k)
Definition: z3py.py:1471
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 1368 of file z3py.py.

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

1368 def is_app(a):
1369  """Return `True` if `a` is a Z3 function application.
1370 
1371  Note that, constants are function applications with 0 arguments.
1372 
1373  >>> a = Int('a')
1374  >>> is_app(a)
1375  True
1376  >>> is_app(a + 1)
1377  True
1378  >>> is_app(IntSort())
1379  False
1380  >>> is_app(1)
1381  False
1382  >>> is_app(IntVal(1))
1383  True
1384  >>> x = Int('x')
1385  >>> is_app(ForAll(x, x >= 0))
1386  False
1387  """
1388  if not isinstance(a, ExprRef):
1389  return False
1390  k = _ast_kind(a.ctx, a)
1391  return k == Z3_NUMERAL_AST or k == Z3_APP_AST
1392 
1393 
def is_app(a)
Definition: z3py.py:1368
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 1471 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().

1471 def is_app_of(a, k):
1472  """Return `True` if `a` is an application of the given kind `k`.
1473 
1474  >>> x = Int('x')
1475  >>> n = x + 1
1476  >>> is_app_of(n, Z3_OP_ADD)
1477  True
1478  >>> is_app_of(n, Z3_OP_MUL)
1479  False
1480  """
1481  return is_app(a) and a.kind() == k
1482 
1483 
def is_app(a)
Definition: z3py.py:1368
def is_app_of(a, k)
Definition: z3py.py:1471
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 2819 of file z3py.py.

Referenced by is_algebraic_value().

2819 def is_arith(a):
2820  """Return `True` if `a` is an arithmetical expression.
2821 
2822  >>> x = Int('x')
2823  >>> is_arith(x)
2824  True
2825  >>> is_arith(x + 1)
2826  True
2827  >>> is_arith(1)
2828  False
2829  >>> is_arith(IntVal(1))
2830  True
2831  >>> y = Real('y')
2832  >>> is_arith(y)
2833  True
2834  >>> is_arith(y + 1)
2835  True
2836  """
2837  return isinstance(a, ArithRef)
2838 
2839 
def is_arith(a)
Definition: z3py.py:2819
def z3py.is_arith_sort (   s)

Definition at line 2507 of file z3py.py.

2507 def is_arith_sort(s : Any) -> bool:
2508  """Return `True` if s is an arithmetical sort (type).
2509 
2510  >>> is_arith_sort(IntSort())
2511  True
2512  >>> is_arith_sort(RealSort())
2513  True
2514  >>> is_arith_sort(BoolSort())
2515  False
2516  >>> n = Int('x') + 1
2517  >>> is_arith_sort(n.sort())
2518  True
2519  """
2520  return isinstance(s, ArithSortRef)
2521 
2522 
def is_arith_sort
Definition: z3py.py:2507
def z3py.is_array (   a)

Definition at line 4801 of file z3py.py.

Referenced by Ext().

4801 def is_array(a : Any) -> bool:
4802  """Return `True` if `a` is a Z3 array expression.
4803 
4804  >>> a = Array('a', IntSort(), IntSort())
4805  >>> is_array(a)
4806  True
4807  >>> is_array(Store(a, 0, 1))
4808  True
4809  >>> is_array(a[0])
4810  False
4811  """
4812  return isinstance(a, ArrayRef)
4813 
4814 
def is_array
Definition: z3py.py:4801
def z3py.is_array_sort (   a)

Definition at line 4797 of file z3py.py.

Referenced by Default(), and Ext().

4798  return Z3_get_sort_kind(a.ctx.ref(), Z3_get_sort(a.ctx.ref(), a.ast)) == Z3_ARRAY_SORT
4799 
4800 
def is_array_sort(a)
Definition: z3py.py:4797
Z3_sort_kind Z3_API Z3_get_sort_kind(Z3_context c, Z3_sort t)
Return the sort kind (e.g., array, tuple, int, bool, etc).
Z3_sort Z3_API Z3_get_sort(Z3_context c, Z3_ast a)
Return the sort of an AST node.
def z3py.is_as_array (   n)
Return true if n is a Z3 expression of the form (_ as-array f).

Definition at line 6956 of file z3py.py.

Referenced by get_as_array_func().

6957  """Return true if n is a Z3 expression of the form (_ as-array f)."""
6958  return isinstance(n, ExprRef) and Z3_is_as_array(n.ctx.ref(), n.as_ast())
6959 
6960 
def is_as_array(n)
Definition: z3py.py:6956
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)

Definition at line 482 of file z3py.py.

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

482 def is_ast(a : Any) -> bool:
483  """Return `True` if `a` is an AST node.
484 
485  >>> is_ast(10)
486  False
487  >>> is_ast(IntVal(10))
488  True
489  >>> is_ast(Int('x'))
490  True
491  >>> is_ast(BoolSort())
492  True
493  >>> is_ast(Function('f', IntSort(), IntSort()))
494  True
495  >>> is_ast("x")
496  False
497  >>> is_ast(Solver())
498  False
499  """
500  return isinstance(a, AstRef)
501 
502 
def is_ast
Definition: z3py.py:482
def z3py.is_bool (   a)

Definition at line 1704 of file z3py.py.

Referenced by BoolSort(), and prove().

1704 def is_bool(a : Any) -> bool:
1705  """Return `True` if `a` is a Z3 Boolean expression.
1706 
1707  >>> p = Bool('p')
1708  >>> is_bool(p)
1709  True
1710  >>> q = Bool('q')
1711  >>> is_bool(And(p, q))
1712  True
1713  >>> x = Real('x')
1714  >>> is_bool(x)
1715  False
1716  >>> is_bool(x == 0)
1717  True
1718  """
1719  return isinstance(a, BoolRef)
1720 
1721 
def is_bool
Definition: z3py.py:1704
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 4111 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().

4111 def is_bv(a):
4112  """Return `True` if `a` is a Z3 bit-vector expression.
4113 
4114  >>> b = BitVec('b', 32)
4115  >>> is_bv(b)
4116  True
4117  >>> is_bv(b + 10)
4118  True
4119  >>> is_bv(Int('x'))
4120  False
4121  """
4122  return isinstance(a, BitVecRef)
4123 
4124 
def is_bv(a)
Definition: z3py.py:4111
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 3638 of file z3py.py.

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

3638 def is_bv_sort(s):
3639  """Return True if `s` is a Z3 bit-vector sort.
3640 
3641  >>> is_bv_sort(BitVecSort(32))
3642  True
3643  >>> is_bv_sort(IntSort())
3644  False
3645  """
3646  return isinstance(s, BitVecSortRef)
3647 
3648 
def is_bv_sort(s)
Definition: z3py.py:3638
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 4125 of file z3py.py.

4126  """Return `True` if `a` is a Z3 bit-vector numeral value.
4127 
4128  >>> b = BitVec('b', 32)
4129  >>> is_bv_value(b)
4130  False
4131  >>> b = BitVecVal(10, 32)
4132  >>> b
4133  10
4134  >>> is_bv_value(b)
4135  True
4136  """
4137  return is_bv(a) and _is_numeral(a.ctx, a.as_ast())
4138 
4139 
def is_bv_value(a)
Definition: z3py.py:4125
def is_bv(a)
Definition: z3py.py:4111
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 1394 of file z3py.py.

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

1394 def is_const(a):
1395  """Return `True` if `a` is Z3 constant/variable expression.
1396 
1397  >>> a = Int('a')
1398  >>> is_const(a)
1399  True
1400  >>> is_const(a + 1)
1401  False
1402  >>> is_const(1)
1403  False
1404  >>> is_const(IntVal(1))
1405  True
1406  >>> x = Int('x')
1407  >>> is_const(ForAll(x, x >= 0))
1408  False
1409  """
1410  return is_app(a) and a.num_args() == 0
1411 
1412 
def is_app(a)
Definition: z3py.py:1368
def is_const(a)
Definition: z3py.py:1394
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 4815 of file z3py.py.

4816  """Return `True` if `a` is a Z3 constant array.
4817 
4818  >>> a = K(IntSort(), 10)
4819  >>> is_const_array(a)
4820  True
4821  >>> a = Array('a', IntSort(), IntSort())
4822  >>> is_const_array(a)
4823  False
4824  """
4825  return is_app_of(a, Z3_OP_CONST_ARRAY)
4826 
4827 
def is_const_array(a)
Definition: z3py.py:4815
def is_app_of(a, k)
Definition: z3py.py:1471
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 4857 of file z3py.py.

4857 def is_default(a):
4858  """Return `True` if `a` is a Z3 default array expression.
4859  >>> d = Default(K(IntSort(), 10))
4860  >>> is_default(d)
4861  True
4862  """
4863  return is_app_of(a, Z3_OP_ARRAY_DEFAULT)
4864 
4865 
def is_default(a)
Definition: z3py.py:4857
def is_app_of(a, k)
Definition: z3py.py:1471
def z3py.is_distinct (   a)

Definition at line 1812 of file z3py.py.

1812 def is_distinct(a : Any) -> bool:
1813  """Return `True` if `a` is a Z3 distinct expression.
1814 
1815  >>> x, y, z = Ints('x y z')
1816  >>> is_distinct(x == y)
1817  False
1818  >>> is_distinct(Distinct(x, y, z))
1819  True
1820  """
1821  return is_app_of(a, Z3_OP_DISTINCT)
1822 
1823 
def is_distinct
Definition: z3py.py:1812
def is_app_of(a, k)
Definition: z3py.py:1471
def z3py.is_div (   a)

Definition at line 2982 of file z3py.py.

2982 def is_div(a : Any) -> bool:
2983  """Return `True` if `a` is an expression of the form b / c.
2984 
2985  >>> x, y = Reals('x y')
2986  >>> is_div(x / y)
2987  True
2988  >>> is_div(x + y)
2989  False
2990  >>> x, y = Ints('x y')
2991  >>> is_div(x / y)
2992  False
2993  >>> is_idiv(x / y)
2994  True
2995  """
2996  return is_app_of(a, Z3_OP_DIV)
2997 
2998 
def is_div
Definition: z3py.py:2982
def is_app_of(a, k)
Definition: z3py.py:1471
def z3py.is_eq (   a)

Definition at line 1802 of file z3py.py.

Referenced by AstRef.__bool__().

1802 def is_eq(a : Any) -> bool:
1803  """Return `True` if `a` is a Z3 equality expression.
1804 
1805  >>> x, y = Ints('x y')
1806  >>> is_eq(x == y)
1807  True
1808  """
1809  return is_app_of(a, Z3_OP_EQ)
1810 
1811 
def is_eq
Definition: z3py.py:1802
def is_app_of(a, k)
Definition: z3py.py:1471
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 1345 of file z3py.py.

Referenced by SortRef.cast(), BoolSortRef.cast(), Cbrt(), CharFromBv(), Concat(), deserialize(), Diff(), IndexOf(), IntToStr(), is_var(), simplify(), substitute(), substitute_funs(), substitute_vars(), and ExprRef.update().

1345 def is_expr(a):
1346  """Return `True` if `a` is a Z3 expression.
1347 
1348  >>> a = Int('a')
1349  >>> is_expr(a)
1350  True
1351  >>> is_expr(a + 1)
1352  True
1353  >>> is_expr(IntSort())
1354  False
1355  >>> is_expr(1)
1356  False
1357  >>> is_expr(IntVal(1))
1358  True
1359  >>> x = Int('x')
1360  >>> is_expr(ForAll(x, x >= 0))
1361  True
1362  >>> is_expr(FPVal(1.0))
1363  True
1364  """
1365  return isinstance(a, ExprRef)
1366 
1367 
def is_expr(a)
Definition: z3py.py:1345
def z3py.is_false (   a)

Definition at line 1740 of file z3py.py.

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

1740 def is_false(a : Any) -> bool:
1741  """Return `True` if `a` is the Z3 false expression.
1742 
1743  >>> p = Bool('p')
1744  >>> is_false(p)
1745  False
1746  >>> is_false(False)
1747  False
1748  >>> is_false(BoolVal(False))
1749  True
1750  """
1751  return is_app_of(a, Z3_OP_FALSE)
1752 
1753 
def is_false
Definition: z3py.py:1740
def is_app_of(a, k)
Definition: z3py.py:1471
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 8075 of file z3py.py.

Referenced by is_finite_domain_value().

8076  """Return `True` if `a` is a Z3 finite-domain expression.
8077 
8078  >>> s = FiniteDomainSort('S', 100)
8079  >>> b = Const('b', s)
8080  >>> is_finite_domain(b)
8081  True
8082  >>> is_finite_domain(Int('x'))
8083  False
8084  """
8085  return isinstance(a, FiniteDomainRef)
8086 
8087 
def is_finite_domain(a)
Definition: z3py.py:8075
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 8052 of file z3py.py.

Referenced by FiniteDomainVal().

8053  """Return True if `s` is a Z3 finite-domain sort.
8054 
8055  >>> is_finite_domain_sort(FiniteDomainSort('S', 100))
8056  True
8057  >>> is_finite_domain_sort(IntSort())
8058  False
8059  """
8060  return isinstance(s, FiniteDomainSortRef)
8061 
8062 
def is_finite_domain_sort(s)
Definition: z3py.py:8052
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 8129 of file z3py.py.

8130  """Return `True` if `a` is a Z3 finite-domain value.
8131 
8132  >>> s = FiniteDomainSort('S', 100)
8133  >>> b = Const('b', s)
8134  >>> is_finite_domain_value(b)
8135  False
8136  >>> b = FiniteDomainVal(10, s)
8137  >>> b
8138  10
8139  >>> is_finite_domain_value(b)
8140  True
8141  """
8142  return is_finite_domain(a) and _is_numeral(a.ctx, a.as_ast())
8143 
8144 
def is_finite_domain_value(a)
Definition: z3py.py:8129
def is_finite_domain(a)
Definition: z3py.py:8075
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 10285 of file z3py.py.

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

10285 def is_fp(a):
10286  """Return `True` if `a` is a Z3 floating-point expression.
10287 
10288  >>> b = FP('b', FPSort(8, 24))
10289  >>> is_fp(b)
10290  True
10291  >>> is_fp(b + 1.0)
10292  True
10293  >>> is_fp(Int('x'))
10294  False
10295  """
10296  return isinstance(a, FPRef)
10297 
10298 
def is_fp(a)
Definition: z3py.py:10285
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 9859 of file z3py.py.

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

9859 def is_fp_sort(s):
9860  """Return True if `s` is a Z3 floating-point sort.
9861 
9862  >>> is_fp_sort(FPSort(8, 24))
9863  True
9864  >>> is_fp_sort(IntSort())
9865  False
9866  """
9867  return isinstance(s, FPSortRef)
9868 
9869 
def is_fp_sort(s)
Definition: z3py.py:9859
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 10299 of file z3py.py.

10300  """Return `True` if `a` is a Z3 floating-point numeral value.
10301 
10302  >>> b = FP('b', FPSort(8, 24))
10303  >>> is_fp_value(b)
10304  False
10305  >>> b = FPVal(1.0, FPSort(8, 24))
10306  >>> b
10307  1
10308  >>> is_fp_value(b)
10309  True
10310  """
10311  return is_fp(a) and _is_numeral(a.ctx, a.ast)
10312 
10313 
def is_fp_value(a)
Definition: z3py.py:10299
def is_fp(a)
Definition: z3py.py:10285
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 10119 of file z3py.py.

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

10119 def is_fprm(a):
10120  """Return `True` if `a` is a Z3 floating-point rounding mode expression.
10121 
10122  >>> rm = RNE()
10123  >>> is_fprm(rm)
10124  True
10125  >>> rm = 1.0
10126  >>> is_fprm(rm)
10127  False
10128  """
10129  return isinstance(a, FPRMRef)
10130 
10131 
def is_fprm(a)
Definition: z3py.py:10119
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 9870 of file z3py.py.

9871  """Return True if `s` is a Z3 floating-point rounding mode sort.
9872 
9873  >>> is_fprm_sort(FPSort(8, 24))
9874  False
9875  >>> is_fprm_sort(RNE().sort())
9876  True
9877  """
9878  return isinstance(s, FPRMSortRef)
9879 
9880 # FP Expressions
9881 
9882 
def is_fprm_sort(s)
Definition: z3py.py:9870
def z3py.is_fprm_value (   a)
Return `True` if `a` is a Z3 floating-point rounding mode numeral value.

Definition at line 10132 of file z3py.py.

10133  """Return `True` if `a` is a Z3 floating-point rounding mode numeral value."""
10134  return is_fprm(a) and _is_numeral(a.ctx, a.ast)
10135 
10136 # FP Numerals
10137 
10138 
def is_fprm_value(a)
Definition: z3py.py:10132
def is_fprm(a)
Definition: z3py.py:10119
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 907 of file z3py.py.

Referenced by prove(), and substitute_funs().

908  """Return `True` if `a` is a Z3 function declaration.
909 
910  >>> f = Function('f', IntSort(), IntSort())
911  >>> is_func_decl(f)
912  True
913  >>> x = Real('x')
914  >>> is_func_decl(x)
915  False
916  """
917  return isinstance(a, FuncDeclRef)
918 
919 
def is_func_decl(a)
Definition: z3py.py:907
def z3py.is_ge (   a)

Definition at line 3047 of file z3py.py.

3047 def is_ge(a : Any) -> bool:
3048  """Return `True` if `a` is an expression of the form b >= c.
3049 
3050  >>> x, y = Ints('x y')
3051  >>> is_ge(x >= y)
3052  True
3053  >>> is_ge(x == y)
3054  False
3055  """
3056  return is_app_of(a, Z3_OP_GE)
3057 
3058 
def is_ge
Definition: z3py.py:3047
def is_app_of(a, k)
Definition: z3py.py:1471
def z3py.is_gt (   a)

Definition at line 3059 of file z3py.py.

3059 def is_gt(a : Any) -> bool:
3060  """Return `True` if `a` is an expression of the form b > c.
3061 
3062  >>> x, y = Ints('x y')
3063  >>> is_gt(x > y)
3064  True
3065  >>> is_gt(x == y)
3066  False
3067  """
3068  return is_app_of(a, Z3_OP_GT)
3069 
3070 
def is_gt
Definition: z3py.py:3059
def is_app_of(a, k)
Definition: z3py.py:1471
def z3py.is_idiv (   a)

Definition at line 2999 of file z3py.py.

Referenced by is_div().

2999 def is_idiv(a : Any) -> bool:
3000  """Return `True` if `a` is an expression of the form b div c.
3001 
3002  >>> x, y = Ints('x y')
3003  >>> is_idiv(x / y)
3004  True
3005  >>> is_idiv(x + y)
3006  False
3007  """
3008  return is_app_of(a, Z3_OP_IDIV)
3009 
3010 
def is_idiv
Definition: z3py.py:2999
def is_app_of(a, k)
Definition: z3py.py:1471
def z3py.is_implies (   a)

Definition at line 1778 of file z3py.py.

1778 def is_implies(a : Any) -> bool:
1779  """Return `True` if `a` is a Z3 implication expression.
1780 
1781  >>> p, q = Bools('p q')
1782  >>> is_implies(Implies(p, q))
1783  True
1784  >>> is_implies(And(p, q))
1785  False
1786  """
1787  return is_app_of(a, Z3_OP_IMPLIES)
1788 
1789 
def is_implies
Definition: z3py.py:1778
def is_app_of(a, k)
Definition: z3py.py:1471
def z3py.is_int (   a,
  bool 
)
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 2840 of file z3py.py.

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

2840 def is_int(a) -> bool:
2841  """Return `True` if `a` is an integer expression.
2842 
2843  >>> x = Int('x')
2844  >>> is_int(x + 1)
2845  True
2846  >>> is_int(1)
2847  False
2848  >>> is_int(IntVal(1))
2849  True
2850  >>> y = Real('y')
2851  >>> is_int(y)
2852  False
2853  >>> is_int(y + 1)
2854  False
2855  """
2856  return is_arith(a) and a.is_int()
2857 
2858 
def is_arith(a)
Definition: z3py.py:2819
def is_int(a)
Definition: z3py.py:2840
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 2886 of file z3py.py.

2887  """Return `True` if `a` is an integer value of sort Int.
2888 
2889  >>> is_int_value(IntVal(1))
2890  True
2891  >>> is_int_value(1)
2892  False
2893  >>> is_int_value(Int('x'))
2894  False
2895  >>> n = Int('x') + 1
2896  >>> n
2897  x + 1
2898  >>> n.arg(1)
2899  1
2900  >>> is_int_value(n.arg(1))
2901  True
2902  >>> is_int_value(RealVal("1/3"))
2903  False
2904  >>> is_int_value(RealVal(1))
2905  False
2906  """
2907  return is_arith(a) and a.is_int() and _is_numeral(a.ctx, a.as_ast())
2908 
2909 
def is_int_value(a)
Definition: z3py.py:2886
def is_arith(a)
Definition: z3py.py:2819
def z3py.is_is_int (   a)

Definition at line 3071 of file z3py.py.

3071 def is_is_int(a : Any) -> bool:
3072  """Return `True` if `a` is an expression of the form IsInt(b).
3073 
3074  >>> x = Real('x')
3075  >>> is_is_int(IsInt(x))
3076  True
3077  >>> is_is_int(x)
3078  False
3079  """
3080  return is_app_of(a, Z3_OP_IS_INT)
3081 
3082 
def is_is_int
Definition: z3py.py:3071
def is_app_of(a, k)
Definition: z3py.py:1471
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 4828 of file z3py.py.

4828 def is_K(a):
4829  """Return `True` if `a` is a Z3 constant array.
4830 
4831  >>> a = K(IntSort(), 10)
4832  >>> is_K(a)
4833  True
4834  >>> a = Array('a', IntSort(), IntSort())
4835  >>> is_K(a)
4836  False
4837  """
4838  return is_app_of(a, Z3_OP_CONST_ARRAY)
4839 
4840 
def is_K(a)
Definition: z3py.py:4828
def is_app_of(a, k)
Definition: z3py.py:1471
def z3py.is_le (   a)

Definition at line 3023 of file z3py.py.

3023 def is_le(a : Any) -> bool:
3024  """Return `True` if `a` is an expression of the form b <= c.
3025 
3026  >>> x, y = Ints('x y')
3027  >>> is_le(x <= y)
3028  True
3029  >>> is_le(x < y)
3030  False
3031  """
3032  return is_app_of(a, Z3_OP_LE)
3033 
3034 
def is_le
Definition: z3py.py:3023
def is_app_of(a, k)
Definition: z3py.py:1471
def z3py.is_lt (   a)

Definition at line 3035 of file z3py.py.

3035 def is_lt(a : Any) -> bool:
3036  """Return `True` if `a` is an expression of the form b < c.
3037 
3038  >>> x, y = Ints('x y')
3039  >>> is_lt(x < y)
3040  True
3041  >>> is_lt(x == y)
3042  False
3043  """
3044  return is_app_of(a, Z3_OP_LT)
3045 
3046 
def is_lt
Definition: z3py.py:3035
def is_app_of(a, k)
Definition: z3py.py:1471
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 4841 of file z3py.py.

Referenced by get_map_func().

4841 def is_map(a):
4842  """Return `True` if `a` is a Z3 map array expression.
4843 
4844  >>> f = Function('f', IntSort(), IntSort())
4845  >>> b = Array('b', IntSort(), IntSort())
4846  >>> a = Map(f, b)
4847  >>> a
4848  Map(f, b)
4849  >>> is_map(a)
4850  True
4851  >>> is_map(b)
4852  False
4853  """
4854  return is_app_of(a, Z3_OP_ARRAY_MAP)
4855 
4856 
def is_map(a)
Definition: z3py.py:4841
def is_app_of(a, k)
Definition: z3py.py:1471
def z3py.is_mod (   a)

Definition at line 3011 of file z3py.py.

3011 def is_mod(a : Any) -> bool:
3012  """Return `True` if `a` is an expression of the form b % c.
3013 
3014  >>> x, y = Ints('x y')
3015  >>> is_mod(x % y)
3016  True
3017  >>> is_mod(x + y)
3018  False
3019  """
3020  return is_app_of(a, Z3_OP_MOD)
3021 
3022 
def is_mod
Definition: z3py.py:3011
def is_app_of(a, k)
Definition: z3py.py:1471
def z3py.is_mul (   a)

Definition at line 2958 of file z3py.py.

2958 def is_mul(a : Any) -> bool:
2959  """Return `True` if `a` is an expression of the form b * c.
2960 
2961  >>> x, y = Ints('x y')
2962  >>> is_mul(x * y)
2963  True
2964  >>> is_mul(x - y)
2965  False
2966  """
2967  return is_app_of(a, Z3_OP_MUL)
2968 
2969 
def is_mul
Definition: z3py.py:2958
def is_app_of(a, k)
Definition: z3py.py:1471
def z3py.is_not (   a)

Definition at line 1790 of file z3py.py.

1790 def is_not(a : Any) -> bool:
1791  """Return `True` if `a` is a Z3 not expression.
1792 
1793  >>> p = Bool('p')
1794  >>> is_not(p)
1795  False
1796  >>> is_not(Not(p))
1797  True
1798  """
1799  return is_app_of(a, Z3_OP_NOT)
1800 
1801 
def is_not
Definition: z3py.py:1790
def is_app_of(a, k)
Definition: z3py.py:1471
def z3py.is_or (   a)

Definition at line 1766 of file z3py.py.

1766 def is_or(a : Any) -> bool:
1767  """Return `True` if `a` is a Z3 or expression.
1768 
1769  >>> p, q = Bools('p q')
1770  >>> is_or(Or(p, q))
1771  True
1772  >>> is_or(And(p, q))
1773  False
1774  """
1775  return is_app_of(a, Z3_OP_OR)
1776 
1777 
def is_app_of(a, k)
Definition: z3py.py:1471
def is_or
Definition: z3py.py:1766
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 2066 of file z3py.py.

Referenced by MultiPattern().

2066 def is_pattern(a):
2067  """Return `True` if `a` is a Z3 pattern (hint for quantifier instantiation.
2068 
2069  >>> f = Function('f', IntSort(), IntSort())
2070  >>> x = Int('x')
2071  >>> q = ForAll(x, f(x) == 0, patterns = [ f(x) ])
2072  >>> q
2073  ForAll(x, f(x) == 0)
2074  >>> q.num_patterns()
2075  1
2076  >>> is_pattern(q.pattern(0))
2077  True
2078  >>> q.pattern(0)
2079  f(Var(0))
2080  """
2081  return isinstance(a, PatternRef)
2082 
2083 
def is_pattern(a)
Definition: z3py.py:2066
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 9040 of file z3py.py.

Referenced by eq().

9040 def is_probe(p):
9041  """Return `True` if `p` is a Z3 probe.
9042 
9043  >>> is_probe(Int('x'))
9044  False
9045  >>> is_probe(Probe('memory'))
9046  True
9047  """
9048  return isinstance(p, Probe)
9049 
9050 
def is_probe(p)
Definition: z3py.py:9040
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 2316 of file z3py.py.

Referenced by Exists().

2317  """Return `True` if `a` is a Z3 quantifier.
2318 
2319  >>> f = Function('f', IntSort(), IntSort())
2320  >>> x = Int('x')
2321  >>> q = ForAll(x, f(x) == 0)
2322  >>> is_quantifier(q)
2323  True
2324  >>> is_quantifier(f(x))
2325  False
2326  """
2327  return isinstance(a, QuantifierRef)
2328 
2329 
def is_quantifier(a)
Definition: z3py.py:2316
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 2910 of file z3py.py.

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

2911  """Return `True` if `a` is rational value of sort Real.
2912 
2913  >>> is_rational_value(RealVal(1))
2914  True
2915  >>> is_rational_value(RealVal("3/5"))
2916  True
2917  >>> is_rational_value(IntVal(1))
2918  False
2919  >>> is_rational_value(1)
2920  False
2921  >>> n = Real('x') + 1
2922  >>> n.arg(1)
2923  1
2924  >>> is_rational_value(n.arg(1))
2925  True
2926  >>> is_rational_value(Real('x'))
2927  False
2928  """
2929  return is_arith(a) and a.is_real() and _is_numeral(a.ctx, a.as_ast())
2930 
2931 
def is_arith(a)
Definition: z3py.py:2819
def is_rational_value(a)
Definition: z3py.py:2910
def z3py.is_re (   s)

Definition at line 11628 of file z3py.py.

Referenced by Concat(), and Intersect().

11628 def is_re(s):
11629  return isinstance(s, ReRef)
11630 
11631 
def is_re(s)
Definition: z3py.py:11628
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 2859 of file z3py.py.

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

2859 def is_real(a):
2860  """Return `True` if `a` is a real expression.
2861 
2862  >>> x = Int('x')
2863  >>> is_real(x + 1)
2864  False
2865  >>> y = Real('y')
2866  >>> is_real(y)
2867  True
2868  >>> is_real(y + 1)
2869  True
2870  >>> is_real(1)
2871  False
2872  >>> is_real(RealVal(1))
2873  True
2874  """
2875  return is_arith(a) and a.is_real()
2876 
2877 
def is_real(a)
Definition: z3py.py:2859
def is_arith(a)
Definition: z3py.py:2819
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 5069 of file z3py.py.

5069 def is_select(a):
5070  """Return `True` if `a` is a Z3 array select application.
5071 
5072  >>> a = Array('a', IntSort(), IntSort())
5073  >>> is_select(a)
5074  False
5075  >>> i = Int('i')
5076  >>> is_select(a[i])
5077  True
5078  """
5079  return is_app_of(a, Z3_OP_SELECT)
5080 
5081 
def is_select(a)
Definition: z3py.py:5069
def is_app_of(a, k)
Definition: z3py.py:1471
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 11310 of file z3py.py.

Referenced by Concat(), and Extract().

11310 def is_seq(a):
11311  """Return `True` if `a` is a Z3 sequence expression.
11312  >>> print (is_seq(Unit(IntVal(0))))
11313  True
11314  >>> print (is_seq(StringVal("abc")))
11315  True
11316  """
11317  return isinstance(a, SeqRef)
11318 
11319 
def is_seq(a)
Definition: z3py.py:11310
def z3py.is_sort (   s)

Definition at line 682 of file z3py.py.

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

682 def is_sort(s : Any) -> bool:
683  """Return `True` if `s` is a Z3 sort.
684 
685  >>> is_sort(IntSort())
686  True
687  >>> is_sort(Int('x'))
688  False
689  >>> is_expr(Int('x'))
690  True
691  """
692  return isinstance(s, SortRef)
693 
694 
def is_sort
Definition: z3py.py:682
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 5082 of file z3py.py.

5082 def is_store(a):
5083  """Return `True` if `a` is a Z3 array store application.
5084 
5085  >>> a = Array('a', IntSort(), IntSort())
5086  >>> is_store(a)
5087  False
5088  >>> is_store(Store(a, 0, 1))
5089  True
5090  """
5091  return is_app_of(a, Z3_OP_STORE)
5092 
def is_store(a)
Definition: z3py.py:5082
def is_app_of(a, k)
Definition: z3py.py:1471
def z3py.is_string (   a)

Definition at line 11320 of file z3py.py.

11320 def is_string(a: Any) -> bool:
11321  """Return `True` if `a` is a Z3 string expression.
11322  >>> print (is_string(StringVal("ab")))
11323  True
11324  """
11325  return isinstance(a, SeqRef) and a.is_string()
11326 
11327 
def is_string
Definition: z3py.py:11320
def z3py.is_string_value (   a)

Definition at line 11328 of file z3py.py.

11328 def is_string_value(a: Any) -> bool:
11329  """return 'True' if 'a' is a Z3 string constant expression.
11330  >>> print (is_string_value(StringVal("a")))
11331  True
11332  >>> print (is_string_value(StringVal("a") + StringVal("b")))
11333  False
11334  """
11335  return isinstance(a, SeqRef) and a.is_string_value()
11336 
def is_string_value
Definition: z3py.py:11328
def z3py.is_sub (   a)

Definition at line 2970 of file z3py.py.

2970 def is_sub(a : Any) -> bool:
2971  """Return `True` if `a` is an expression of the form b - c.
2972 
2973  >>> x, y = Ints('x y')
2974  >>> is_sub(x - y)
2975  True
2976  >>> is_sub(x + y)
2977  False
2978  """
2979  return is_app_of(a, Z3_OP_SUB)
2980 
2981 
def is_sub
Definition: z3py.py:2970
def is_app_of(a, k)
Definition: z3py.py:1471
def z3py.is_to_int (   a)

Definition at line 3098 of file z3py.py.

3098 def is_to_int(a : Any) -> bool:
3099  """Return `True` if `a` is an expression of the form ToInt(b).
3100 
3101  >>> x = Real('x')
3102  >>> n = ToInt(x)
3103  >>> n
3104  ToInt(x)
3105  >>> is_to_int(n)
3106  True
3107  >>> is_to_int(x)
3108  False
3109  """
3110  return is_app_of(a, Z3_OP_TO_INT)
3111 
3112 
def is_to_int
Definition: z3py.py:3098
def is_app_of(a, k)
Definition: z3py.py:1471
def z3py.is_to_real (   a)

Definition at line 3083 of file z3py.py.

3083 def is_to_real(a : Any) -> bool:
3084  """Return `True` if `a` is an expression of the form ToReal(b).
3085 
3086  >>> x = Int('x')
3087  >>> n = ToReal(x)
3088  >>> n
3089  ToReal(x)
3090  >>> is_to_real(n)
3091  True
3092  >>> is_to_real(x)
3093  False
3094  """
3095  return is_app_of(a, Z3_OP_TO_REAL)
3096 
3097 
def is_app_of(a, k)
Definition: z3py.py:1471
def is_to_real
Definition: z3py.py:3083
def z3py.is_true (   a)

Definition at line 1722 of file z3py.py.

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

1722 def is_true(a : Any) -> bool:
1723  """Return `True` if `a` is the Z3 true expression.
1724 
1725  >>> p = Bool('p')
1726  >>> is_true(p)
1727  False
1728  >>> is_true(simplify(p == p))
1729  True
1730  >>> x = Real('x')
1731  >>> is_true(x == 0)
1732  False
1733  >>> # True is a Python Boolean expression
1734  >>> is_true(True)
1735  False
1736  """
1737  return is_app_of(a, Z3_OP_TRUE)
1738 
1739 
def is_true
Definition: z3py.py:1722
def is_app_of(a, k)
Definition: z3py.py:1471
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 1413 of file z3py.py.

Referenced by get_var_index().

1413 def is_var(a):
1414  """Return `True` if `a` is variable.
1415 
1416  Z3 uses de-Bruijn indices for representing bound variables in
1417  quantifiers.
1418 
1419  >>> x = Int('x')
1420  >>> is_var(x)
1421  False
1422  >>> is_const(x)
1423  True
1424  >>> f = Function('f', IntSort(), IntSort())
1425  >>> # Z3 replaces x with bound variables when ForAll is executed.
1426  >>> q = ForAll(x, f(x) == x)
1427  >>> b = q.body()
1428  >>> b
1429  f(Var(0)) == Var(0)
1430  >>> b.arg(1)
1431  Var(0)
1432  >>> is_var(b.arg(1))
1433  True
1434  """
1435  return is_expr(a) and _ast_kind(a.ctx, a) == Z3_VAR_AST
1436 
1437 
def is_expr(a)
Definition: z3py.py:1345
def is_var(a)
Definition: z3py.py:1413
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 3556 of file z3py.py.

Referenced by is_is_int().

3556 def IsInt(a):
3557  """ Return the Z3 predicate IsInt(a).
3558 
3559  >>> x = Real('x')
3560  >>> IsInt(x + "1/2")
3561  IsInt(x + 1/2)
3562  >>> solve(IsInt(x + "1/2"), x > 0, x < 1)
3563  [x = 1/2]
3564  >>> solve(IsInt(x + "1/2"), x > 0, x < 1, x != "1/2")
3565  no solution
3566  """
3567  if z3_debug():
3568  _z3_assert(a.is_real(), "Z3 real expression expected.")
3569  ctx = a.ctx
3570  return BoolRef(Z3_mk_is_int(ctx.ref(), a.as_ast()), ctx)
3571 
3572 
def IsInt(a)
Definition: z3py.py:3556
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:70
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 5192 of file z3py.py.

5192 def IsMember(e, s):
5193  """ Check if e is a member of set s
5194  >>> a = Const('a', SetSort(IntSort()))
5195  >>> IsMember(1, a)
5196  a[1]
5197  """
5198  ctx = _ctx_from_ast_arg_list([s, e])
5199  e = _py2expr(e, ctx)
5200  return BoolRef(Z3_mk_set_member(ctx.ref(), e.as_ast(), s.as_ast()), ctx)
5201 
5202 
Z3_ast Z3_API Z3_mk_set_member(Z3_context c, Z3_ast elem, Z3_ast set)
Check for set membership.
def IsMember(e, s)
Definition: z3py.py:5192
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 5203 of file z3py.py.

5203 def IsSubset(a, b):
5204  """ Check if a is a subset of b
5205  >>> a = Const('a', SetSort(IntSort()))
5206  >>> b = Const('b', SetSort(IntSort()))
5207  >>> IsSubset(a, b)
5208  subset(a, b)
5209  """
5210  ctx = _ctx_from_ast_arg_list([a, b])
5211  return BoolRef(Z3_mk_set_subset(ctx.ref(), a.as_ast(), b.as_ast()), ctx)
5212 
5213 
def IsSubset(a, b)
Definition: z3py.py:5203
Z3_ast Z3_API Z3_mk_set_subset(Z3_context c, Z3_ast arg1, Z3_ast arg2)
Check for subsetness of sets.
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 5036 of file z3py.py.

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

5036 def K(dom, v):
5037  """Return a Z3 constant array expression.
5038 
5039  >>> a = K(IntSort(), 10)
5040  >>> a
5041  K(Int, 10)
5042  >>> a.sort()
5043  Array(Int, Int)
5044  >>> i = Int('i')
5045  >>> a[i]
5046  K(Int, 10)[i]
5047  >>> simplify(a[i])
5048  10
5049  """
5050  if z3_debug():
5051  _z3_assert(is_sort(dom), "Z3 sort expected")
5052  ctx = dom.ctx
5053  if not is_expr(v):
5054  v = _py2expr(v, ctx)
5055  return ArrayRef(Z3_mk_const_array(ctx.ref(), dom.ast, v.as_ast()), ctx)
5056 
5057 
Z3_ast Z3_API Z3_mk_const_array(Z3_context c, Z3_sort domain, Z3_ast v)
Create the constant array.
def z3_debug()
Definition: z3py.py:70
def K(dom, v)
Definition: z3py.py:5036
def is_sort
Definition: z3py.py:682
def is_expr(a)
Definition: z3py.py:1345
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 2404 of file z3py.py.

Referenced by QuantifierRef.is_lambda().

2404 def Lambda(vs, body):
2405  """Create a Z3 lambda expression.
2406 
2407  >>> f = Function('f', IntSort(), IntSort(), IntSort())
2408  >>> mem0 = Array('mem0', IntSort(), IntSort())
2409  >>> lo, hi, e, i = Ints('lo hi e i')
2410  >>> mem1 = Lambda([i], If(And(lo <= i, i <= hi), e, mem0[i]))
2411  >>> mem1
2412  Lambda(i, If(And(lo <= i, i <= hi), e, mem0[i]))
2413  """
2414  ctx = body.ctx
2415  if is_app(vs):
2416  vs = [vs]
2417  num_vars = len(vs)
2418  _vs = (Ast * num_vars)()
2419  for i in range(num_vars):
2420  # TODO: Check if is constant
2421  _vs[i] = vs[i].as_ast()
2422  return QuantifierRef(Z3_mk_lambda_const(ctx.ref(), num_vars, _vs, body.as_ast()), ctx)
2423 
Quantifiers.
Definition: z3py.py:2121
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:4343
def is_app(a)
Definition: z3py.py:1368
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 Lambda(vs, body)
Definition: z3py.py:2404
def z3py.LastIndexOf (   s,
  substr 
)
Retrieve the last index of substring within a string

Definition at line 11513 of file z3py.py.

11513 def LastIndexOf(s, substr):
11514  """Retrieve the last index of substring within a string"""
11515  ctx = None
11516  ctx = _get_ctx2(s, substr, ctx)
11517  s = _coerce_seq(s, ctx)
11518  substr = _coerce_seq(substr, ctx)
11519  return ArithRef(Z3_mk_seq_last_index(s.ctx_ref(), s.as_ast(), substr.as_ast()), s.ctx)
11520 
11521 
def LastIndexOf(s, substr)
Definition: z3py.py:11513
Z3_ast Z3_API Z3_mk_seq_last_index(Z3_context c, Z3_ast s, Z3_ast substr)
Return index of the last occurrence of substr in s. If s does not contain substr, then the value is -...
def z3py.Length (   s)
Obtain the length of a sequence 's'
>>> l = Length(StringVal("abc"))
>>> simplify(l)
3

Definition at line 11522 of file z3py.py.

11522 def Length(s):
11523  """Obtain the length of a sequence 's'
11524  >>> l = Length(StringVal("abc"))
11525  >>> simplify(l)
11526  3
11527  """
11528  s = _coerce_seq(s)
11529  return ArithRef(Z3_mk_seq_length(s.ctx_ref(), s.as_ast()), s.ctx)
11530 
Z3_ast Z3_API Z3_mk_seq_length(Z3_context c, Z3_ast s)
Return the length of the sequence s.
def Length(s)
Definition: z3py.py:11522
def z3py.LinearOrder (   a,
  index 
)

Definition at line 11784 of file z3py.py.

11784 def LinearOrder(a, index):
11785  return FuncDeclRef(Z3_mk_linear_order(a.ctx_ref(), a.ast, index), a.ctx)
11786 
11787 
Function Declarations.
Definition: z3py.py:775
def LinearOrder(a, index)
Definition: z3py.py:11784
Z3_func_decl Z3_API Z3_mk_linear_order(Z3_context c, Z3_sort a, unsigned id)
create a linear ordering relation over signature a. The relation is identified by the index 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 11734 of file z3py.py.

11734 def Loop(re, lo, hi=0):
11735  """Create the regular expression accepting between a lower and upper bound repetitions
11736  >>> re = Loop(Re("a"), 1, 3)
11737  >>> print(simplify(InRe("aa", re)))
11738  True
11739  >>> print(simplify(InRe("aaaa", re)))
11740  False
11741  >>> print(simplify(InRe("", re)))
11742  False
11743  """
11744  if z3_debug():
11745  _z3_assert(is_expr(re), "expression expected")
11746  return ReRef(Z3_mk_re_loop(re.ctx_ref(), re.as_ast(), lo, hi), re.ctx)
11747 
11748 
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:11734
def z3_debug()
Definition: z3py.py:70
def is_expr(a)
Definition: z3py.py:1345
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 4489 of file z3py.py.

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

4489 def LShR(a, b):
4490  """Create the Z3 expression logical right shift.
4491 
4492  Use the operator >> for the arithmetical right shift.
4493 
4494  >>> x, y = BitVecs('x y', 32)
4495  >>> LShR(x, y)
4496  LShR(x, y)
4497  >>> (x >> y).sexpr()
4498  '(bvashr x y)'
4499  >>> LShR(x, y).sexpr()
4500  '(bvlshr x y)'
4501  >>> BitVecVal(4, 3)
4502  4
4503  >>> BitVecVal(4, 3).as_signed_long()
4504  -4
4505  >>> simplify(BitVecVal(4, 3) >> 1).as_signed_long()
4506  -2
4507  >>> simplify(BitVecVal(4, 3) >> 1)
4508  6
4509  >>> simplify(LShR(BitVecVal(4, 3), 1))
4510  2
4511  >>> simplify(BitVecVal(2, 3) >> 1)
4512  1
4513  >>> simplify(LShR(BitVecVal(2, 3), 1))
4514  1
4515  """
4516  _check_bv_args(a, b)
4517  a, b = _coerce_exprs(a, b)
4518  return BitVecRef(Z3_mk_bvlshr(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4519 
4520 
Z3_ast Z3_API Z3_mk_bvlshr(Z3_context c, Z3_ast t1, Z3_ast t2)
Logical shift right.
def LShR(a, b)
Definition: z3py.py:4489
def z3py.main_ctx (   Context)
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 266 of file z3py.py.

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

266 def main_ctx() -> Context:
267  """Return a reference to the global Z3 context.
268 
269  >>> x = Real('x')
270  >>> x.ctx == main_ctx()
271  True
272  >>> c = Context()
273  >>> c == main_ctx()
274  False
275  >>> x2 = Real('x', c)
276  >>> x2.ctx == c
277  True
278  >>> eq(x, x2)
279  False
280  """
281  global _main_ctx
282  if _main_ctx is None:
283  _main_ctx = Context()
284  return _main_ctx
285 
286 
def main_ctx()
Definition: z3py.py:266
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 5013 of file z3py.py.

Referenced by get_map_func(), and is_map().

5013 def Map(f, *args):
5014  """Return a Z3 map array expression.
5015 
5016  >>> f = Function('f', IntSort(), IntSort(), IntSort())
5017  >>> a1 = Array('a1', IntSort(), IntSort())
5018  >>> a2 = Array('a2', IntSort(), IntSort())
5019  >>> b = Map(f, a1, a2)
5020  >>> b
5021  Map(f, a1, a2)
5022  >>> prove(b[0] == f(a1[0], a2[0]))
5023  proved
5024  """
5025  args = _get_args(args)
5026  if z3_debug():
5027  _z3_assert(len(args) > 0, "At least one Z3 array expression expected")
5028  _z3_assert(is_func_decl(f), "First argument must be a Z3 function declaration")
5029  _z3_assert(all([is_array(a) for a in args]), "Z3 array expected expected")
5030  _z3_assert(len(args) == f.arity(), "Number of arguments mismatch")
5031  _args, sz = _to_ast_array(args)
5032  ctx = f.ctx
5033  return ArrayRef(Z3_mk_map(ctx.ref(), f.ast, sz, _args), ctx)
5034 
5035 
def z3_debug()
Definition: z3py.py:70
def is_array
Definition: z3py.py:4801
def Map(f, args)
Definition: z3py.py:5013
Z3_ast Z3_API Z3_mk_map(Z3_context c, Z3_func_decl f, unsigned n, Z3_ast const *args)
Map f on the argument arrays.
def is_func_decl(a)
Definition: z3py.py:907
def z3py.mk_not (   a)

Definition at line 1967 of file z3py.py.

1967 def mk_not(a):
1968  if is_not(a):
1969  return a.arg(0)
1970  else:
1971  return Not(a)
1972 
1973 
def Not
Definition: z3py.py:1948
def mk_not(a)
Definition: z3py.py:1967
def is_not
Definition: z3py.py:1790
def z3py.Model (   ctx = None,
  eval = {} 
)

Definition at line 6948 of file z3py.py.

Referenced by Optimize.set_on_model().

6948 def Model(ctx=None, eval = {}):
6949  ctx = _get_ctx(ctx)
6950  mdl = ModelRef(Z3_mk_model(ctx.ref()), ctx)
6951  for k, v in eval.items():
6952  mdl.update_value(k, v)
6953  return mdl
6954 
6955 
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:6948
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 2084 of file z3py.py.

2084 def MultiPattern(*args):
2085  """Create a Z3 multi-pattern using the given expressions `*args`
2086 
2087  >>> f = Function('f', IntSort(), IntSort())
2088  >>> g = Function('g', IntSort(), IntSort())
2089  >>> x = Int('x')
2090  >>> q = ForAll(x, f(x) != g(x), patterns = [ MultiPattern(f(x), g(x)) ])
2091  >>> q
2092  ForAll(x, f(x) != g(x))
2093  >>> q.num_patterns()
2094  1
2095  >>> is_pattern(q.pattern(0))
2096  True
2097  >>> q.pattern(0)
2098  MultiPattern(f(Var(0)), g(Var(0)))
2099  """
2100  if z3_debug():
2101  _z3_assert(len(args) > 0, "At least one argument expected")
2102  _z3_assert(all([is_expr(a) for a in args]), "Z3 expressions expected")
2103  ctx = args[0].ctx
2104  args, sz = _to_ast_array(args)
2105  return PatternRef(Z3_mk_pattern(ctx.ref(), sz, args), ctx)
2106 
2107 
Patterns.
Definition: z3py.py:2054
def z3_debug()
Definition: z3py.py:70
Z3_pattern Z3_API Z3_mk_pattern(Z3_context c, unsigned num_patterns, Z3_ast const terms[])
Create a pattern for quantifier instantiation.
def MultiPattern(args)
Definition: z3py.py:2084
def is_expr(a)
Definition: z3py.py:1345
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 1948 of file z3py.py.

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

1948 def Not(a, ctx=None):
1949  """Create a Z3 not expression or probe.
1950 
1951  >>> p = Bool('p')
1952  >>> Not(Not(p))
1953  Not(Not(p))
1954  >>> simplify(Not(Not(p)))
1955  p
1956  """
1957  ctx = _get_ctx(_ctx_from_ast_arg_list([a], ctx))
1958  if is_probe(a):
1959  # Not is also used to build probes
1960  return Probe(Z3_probe_not(ctx.ref(), a.probe), ctx)
1961  else:
1962  s = BoolSort(ctx)
1963  a = s.cast(a)
1964  return BoolRef(Z3_mk_not(ctx.ref(), a.as_ast()), ctx)
1965 
1966 
def Not
Definition: z3py.py:1948
def BoolSort
Definition: z3py.py:1824
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 is_probe(p)
Definition: z3py.py:9040
def z3py.on_clause_eh (   ctx,
  p,
  n,
  dep,
  clause 
)

Definition at line 11824 of file z3py.py.

Referenced by on_clause.on_clause().

11824 def on_clause_eh(ctx, p, n, dep, clause):
11825  onc = _my_hacky_class
11826  p = _to_expr_ref(to_Ast(p), onc.ctx)
11827  clause = AstVector(to_AstVectorObj(clause), onc.ctx)
11828  deps = [dep[i] for i in range(n)]
11829  onc.on_clause(p, deps, clause)
11830 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:4343
def on_clause_eh(ctx, p, n, dep, clause)
Definition: z3py.py:11824
def to_AstVectorObj(ptr)
Definition: z3py.py:11813
def to_Ast(ptr)
Definition: z3py.py:11803
def z3py.open_log (   fname)
Log interaction to a file. This function must be invoked immediately after init(). 

Definition at line 122 of file z3py.py.

122 def open_log(fname):
123  """Log interaction to a file. This function must be invoked immediately after init(). """
124  Z3_open_log(fname)
125 
126 
def open_log(fname)
Definition: z3py.py:122
bool Z3_API Z3_open_log(Z3_string filename)
Log interaction to a file.
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 11699 of file z3py.py.

11699 def Option(re):
11700  """Create the regular expression that optionally accepts the argument.
11701  >>> re = Option(Re("a"))
11702  >>> print(simplify(InRe("a", re)))
11703  True
11704  >>> print(simplify(InRe("", re)))
11705  True
11706  >>> print(simplify(InRe("aa", re)))
11707  False
11708  """
11709  if z3_debug():
11710  _z3_assert(is_expr(re), "expression expected")
11711  return ReRef(Z3_mk_re_option(re.ctx_ref(), re.as_ast()), re.ctx)
11712 
11713 
Z3_ast Z3_API Z3_mk_re_option(Z3_context c, Z3_ast re)
Create the regular language [re].
def z3_debug()
Definition: z3py.py:70
def is_expr(a)
Definition: z3py.py:1345
def Option(re)
Definition: z3py.py:11699
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 2015 of file z3py.py.

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

2015 def Or(*args):
2016  """Create a Z3 or-expression or or-probe.
2017 
2018  >>> p, q, r = Bools('p q r')
2019  >>> Or(p, q, r)
2020  Or(p, q, r)
2021  >>> P = BoolVector('p', 5)
2022  >>> Or(P)
2023  Or(p__0, p__1, p__2, p__3, p__4)
2024  """
2025  last_arg = None
2026  if len(args) > 0:
2027  last_arg = args[len(args) - 1]
2028  if isinstance(last_arg, Context):
2029  ctx = args[len(args) - 1]
2030  args = args[:len(args) - 1]
2031  elif len(args) == 1 and isinstance(args[0], AstVector):
2032  ctx = args[0].ctx
2033  args = [a for a in args[0]]
2034  else:
2035  ctx = None
2036  args = _get_args(args)
2037  ctx = _get_ctx(_ctx_from_ast_arg_list(args, ctx))
2038  if z3_debug():
2039  _z3_assert(ctx is not None, "At least one of the arguments must be a Z3 expression or probe")
2040  if _has_probe(args):
2041  return _probe_or(args, ctx)
2042  else:
2043  args = _coerce_expr_list(args, ctx)
2044  _args, sz = _to_ast_array(args)
2045  return BoolRef(Z3_mk_or(ctx.ref(), sz, _args), ctx)
2046 
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 Or(args)
Definition: z3py.py:2015
def z3_debug()
Definition: z3py.py:70
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 8733 of file z3py.py.

8733 def OrElse(*ts, **ks):
8734  """Return a tactic that applies the tactics in `*ts` until one of them succeeds (it doesn't fail).
8735 
8736  >>> x = Int('x')
8737  >>> t = OrElse(Tactic('split-clause'), Tactic('skip'))
8738  >>> # Tactic split-clause fails if there is no clause in the given goal.
8739  >>> t(x == 0)
8740  [[x == 0]]
8741  >>> t(Or(x == 0, x == 1))
8742  [[x == 0], [x == 1]]
8743  """
8744  if z3_debug():
8745  _z3_assert(len(ts) >= 2, "At least two arguments expected")
8746  ctx = ks.get("ctx", None)
8747  num = len(ts)
8748  r = ts[0]
8749  for i in range(num - 1):
8750  r = _or_else(r, ts[i + 1], ctx)
8751  return r
8752 
8753 
def OrElse(ts, ks)
Definition: z3py.py:8733
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:4343
def z3_debug()
Definition: z3py.py:70
def z3py.ParAndThen (   t1,
  t2,
  ctx = None 
)
Alias for ParThen(t1, t2, ctx).

Definition at line 8789 of file z3py.py.

8789 def ParAndThen(t1, t2, ctx=None):
8790  """Alias for ParThen(t1, t2, ctx)."""
8791  return ParThen(t1, t2, ctx)
8792 
8793 
def ParThen
Definition: z3py.py:8773
def ParAndThen
Definition: z3py.py:8789
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 8754 of file z3py.py.

8754 def ParOr(*ts, **ks):
8755  """Return a tactic that applies the tactics in `*ts` in parallel until one of them succeeds (it doesn't fail).
8756 
8757  >>> x = Int('x')
8758  >>> t = ParOr(Tactic('simplify'), Tactic('fail'))
8759  >>> t(x + 1 == 2)
8760  [[x == 1]]
8761  """
8762  if z3_debug():
8763  _z3_assert(len(ts) >= 2, "At least two arguments expected")
8764  ctx = _get_ctx(ks.get("ctx", None))
8765  ts = [_to_tactic(t, ctx) for t in ts]
8766  sz = len(ts)
8767  _args = (TacticObj * sz)()
8768  for i in range(sz):
8769  _args[i] = ts[i].tactic
8770  return Tactic(Z3_tactic_par_or(ctx.ref(), sz, _args), ctx)
8771 
8772 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:4343
def z3_debug()
Definition: z3py.py:70
Z3_tactic Z3_API Z3_tactic_par_or(Z3_context c, unsigned num, Z3_tactic const ts[])
Return a tactic that applies the given tactics in parallel.
def ParOr(ts, ks)
Definition: z3py.py:8754
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 9669 of file z3py.py.

9669 def parse_smt2_file(f, sorts={}, decls={}, ctx=None):
9670  """Parse a file in SMT 2.0 format using the given sorts and decls.
9671 
9672  This function is similar to parse_smt2_string().
9673  """
9674  ctx = _get_ctx(ctx)
9675  ssz, snames, ssorts = _dict2sarray(sorts, ctx)
9676  dsz, dnames, ddecls = _dict2darray(decls, ctx)
9677  return AstVector(Z3_parse_smtlib2_file(ctx.ref(), f, ssz, snames, ssorts, dsz, dnames, ddecls), ctx)
9678 
9679 
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:9669
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 9648 of file z3py.py.

Referenced by parse_smt2_file().

9648 def parse_smt2_string(s, sorts={}, decls={}, ctx=None):
9649  """Parse a string in SMT 2.0 format using the given sorts and decls.
9650 
9651  The arguments sorts and decls are Python dictionaries used to initialize
9652  the symbol table used for the SMT 2.0 parser.
9653 
9654  >>> parse_smt2_string('(declare-const x Int) (assert (> x 0)) (assert (< x 10))')
9655  [x > 0, x < 10]
9656  >>> x, y = Ints('x y')
9657  >>> f = Function('f', IntSort(), IntSort())
9658  >>> parse_smt2_string('(assert (> (+ foo (g bar)) 0))', decls={ 'foo' : x, 'bar' : y, 'g' : f})
9659  [x + f(y) > 0]
9660  >>> parse_smt2_string('(declare-const a U) (assert (> a 0))', sorts={ 'U' : IntSort() })
9661  [a > 0]
9662  """
9663  ctx = _get_ctx(ctx)
9664  ssz, snames, ssorts = _dict2sarray(sorts, ctx)
9665  dsz, dnames, ddecls = _dict2darray(decls, ctx)
9666  return AstVector(Z3_parse_smtlib2_string(ctx.ref(), s, ssz, snames, ssorts, dsz, dnames, ddecls), ctx)
9667 
9668 
def parse_smt2_string
Definition: z3py.py:9648
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 8773 of file z3py.py.

Referenced by ParAndThen().

8773 def ParThen(t1, t2, ctx=None):
8774  """Return a tactic that applies t1 and then t2 to every subgoal produced by t1.
8775  The subgoals are processed in parallel.
8776 
8777  >>> x, y = Ints('x y')
8778  >>> t = ParThen(Tactic('split-clause'), Tactic('propagate-values'))
8779  >>> t(And(Or(x == 1, x == 2), y == x + 1))
8780  [[x == 1, y == 2], [x == 2, y == 3]]
8781  """
8782  t1 = _to_tactic(t1, ctx)
8783  t2 = _to_tactic(t2, ctx)
8784  if z3_debug():
8785  _z3_assert(t1.ctx == t2.ctx, "Context mismatch")
8786  return Tactic(Z3_tactic_par_and_then(t1.ctx.ref(), t1.tactic, t2.tactic), t1.ctx)
8787 
8788 
def ParThen
Definition: z3py.py:8773
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:70
def z3py.PartialOrder (   a,
  index 
)

Definition at line 11780 of file z3py.py.

11780 def PartialOrder(a, index):
11781  return FuncDeclRef(Z3_mk_partial_order(a.ctx_ref(), a.ast, index), a.ctx)
11782 
11783 
Function Declarations.
Definition: z3py.py:775
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 PartialOrder(a, index)
Definition: z3py.py:11780
def z3py.PbEq (   args,
  k,
  ctx = None 
)
Create a Pseudo-Boolean equality k constraint.

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

Definition at line 9425 of file z3py.py.

9425 def PbEq(args, k, ctx=None):
9426  """Create a Pseudo-Boolean equality k constraint.
9427 
9428  >>> a, b, c = Bools('a b c')
9429  >>> f = PbEq(((a,1),(b,3),(c,2)), 3)
9430  """
9431  _z3_check_cint_overflow(k, "k")
9432  ctx, sz, _args, _coeffs, args = _pb_args_coeffs(args)
9433  return BoolRef(Z3_mk_pbeq(ctx.ref(), sz, _args, _coeffs, k), ctx)
9434 
9435 
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:9425
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 9414 of file z3py.py.

9414 def PbGe(args, k):
9415  """Create a Pseudo-Boolean inequality k constraint.
9416 
9417  >>> a, b, c = Bools('a b c')
9418  >>> f = PbGe(((a,1),(b,3),(c,2)), 3)
9419  """
9420  _z3_check_cint_overflow(k, "k")
9421  ctx, sz, _args, _coeffs, args = _pb_args_coeffs(args)
9422  return BoolRef(Z3_mk_pbge(ctx.ref(), sz, _args, _coeffs, k), ctx)
9423 
9424 
def PbGe(args, k)
Definition: z3py.py:9414
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 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 9403 of file z3py.py.

9403 def PbLe(args, k):
9404  """Create a Pseudo-Boolean inequality k constraint.
9405 
9406  >>> a, b, c = Bools('a b c')
9407  >>> f = PbLe(((a,1),(b,3),(c,2)), 3)
9408  """
9409  _z3_check_cint_overflow(k, "k")
9410  ctx, sz, _args, _coeffs, args = _pb_args_coeffs(args)
9411  return BoolRef(Z3_mk_pble(ctx.ref(), sz, _args, _coeffs, k), ctx)
9412 
9413 
def PbLe(args, k)
Definition: z3py.py:9403
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 11792 of file z3py.py.

11792 def PiecewiseLinearOrder(a, index):
11793  return FuncDeclRef(Z3_mk_piecewise_linear_order(a.ctx_ref(), a.ast, index), a.ctx)
11794 
11795 
Function Declarations.
Definition: z3py.py:775
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(a, index)
Definition: z3py.py:11792
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 11684 of file z3py.py.

11684 def Plus(re):
11685  """Create the regular expression accepting one or more repetitions of argument.
11686  >>> re = Plus(Re("a"))
11687  >>> print(simplify(InRe("aa", re)))
11688  True
11689  >>> print(simplify(InRe("ab", re)))
11690  False
11691  >>> print(simplify(InRe("", re)))
11692  False
11693  """
11694  if z3_debug():
11695  _z3_assert(is_expr(re), "expression expected")
11696  return ReRef(Z3_mk_re_plus(re.ctx_ref(), re.as_ast()), re.ctx)
11697 
11698 
def Plus(re)
Definition: z3py.py:11684
Z3_ast Z3_API Z3_mk_re_plus(Z3_context c, Z3_ast re)
Create the regular language re+.
def z3_debug()
Definition: z3py.py:70
def is_expr(a)
Definition: z3py.py:1345
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 11429 of file z3py.py.

11429 def PrefixOf(a, b):
11430  """Check if 'a' is a prefix of 'b'
11431  >>> s1 = PrefixOf("ab", "abc")
11432  >>> simplify(s1)
11433  True
11434  >>> s2 = PrefixOf("bc", "abc")
11435  >>> simplify(s2)
11436  False
11437  """
11438  ctx = _get_ctx2(a, b)
11439  a = _coerce_seq(a, ctx)
11440  b = _coerce_seq(b, ctx)
11441  return BoolRef(Z3_mk_seq_prefix(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
11442 
11443 
Z3_ast Z3_API Z3_mk_seq_prefix(Z3_context c, Z3_ast prefix, Z3_ast s)
Check if prefix is a prefix of s.
def PrefixOf(a, b)
Definition: z3py.py:11429
def z3py.probe_description (   name,
  ctx = None 
)
Return a short description for the probe named `name`.

>>> d = probe_description('memory')

Definition at line 9069 of file z3py.py.

Referenced by describe_probes().

9069 def probe_description(name, ctx=None):
9070  """Return a short description for the probe named `name`.
9071 
9072  >>> d = probe_description('memory')
9073  """
9074  ctx = _get_ctx(ctx)
9075  return Z3_probe_get_descr(ctx.ref(), name)
9076 
9077 
def probe_description
Definition: z3py.py:9069
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 9058 of file z3py.py.

Referenced by describe_probes().

9058 def probes(ctx=None):
9059  """Return a list of all available probes in Z3.
9060 
9061  >>> l = probes()
9062  >>> l.count('memory') == 1
9063  True
9064  """
9065  ctx = _get_ctx(ctx)
9066  return [Z3_get_probe_name(ctx.ref(), i) for i in range(Z3_get_num_probes(ctx.ref()))]
9067 
9068 
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:4343
def probes
Definition: z3py.py:9058
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 9310 of file z3py.py.

Referenced by BitVecs().

9310 def Product(*args):
9311  """Create the product of the Z3 expressions.
9312 
9313  >>> a, b, c = Ints('a b c')
9314  >>> Product(a, b, c)
9315  a*b*c
9316  >>> Product([a, b, c])
9317  a*b*c
9318  >>> A = IntVector('a', 5)
9319  >>> Product(A)
9320  a__0*a__1*a__2*a__3*a__4
9321  """
9322  args = _get_args(args)
9323  if len(args) == 0:
9324  return 1
9325  ctx = _ctx_from_ast_arg_list(args)
9326  if ctx is None:
9327  return _reduce(lambda a, b: a * b, args, 1)
9328  args = _coerce_expr_list(args, ctx)
9329  if is_bv(args[0]):
9330  return _reduce(lambda a, b: a * b, args, 1)
9331  else:
9332  _args, sz = _to_ast_array(args)
9333  return ArithRef(Z3_mk_mul(ctx.ref(), sz, _args), ctx)
9334 
Z3_ast Z3_API Z3_mk_mul(Z3_context c, unsigned num_args, Z3_ast const args[])
Create an AST node representing args[0] * ... * args[num_args-1].
def Product(args)
Definition: z3py.py:9310
def is_bv(a)
Definition: z3py.py:4111
def z3py.PropagateFunction (   name,
  sig 
)
Create a function that gets tracked by user propagator.
   Every term headed by this function symbol is tracked.
   If a term is fixed and the fixed callback is registered a
   callback is invoked that the term headed by this function is fixed.

Definition at line 11989 of file z3py.py.

11989 def PropagateFunction(name, *sig):
11990  """Create a function that gets tracked by user propagator.
11991  Every term headed by this function symbol is tracked.
11992  If a term is fixed and the fixed callback is registered a
11993  callback is invoked that the term headed by this function is fixed.
11994  """
11995  sig = _get_args(sig)
11996  if z3_debug():
11997  _z3_assert(len(sig) > 0, "At least two arguments expected")
11998  arity = len(sig) - 1
11999  rng = sig[arity]
12000  if z3_debug():
12001  _z3_assert(is_sort(rng), "Z3 sort expected")
12002  dom = (Sort * arity)()
12003  for i in range(arity):
12004  if z3_debug():
12005  _z3_assert(is_sort(sig[i]), "Z3 sort expected")
12006  dom[i] = sig[i].ast
12007  ctx = rng.ctx
12008  return FuncDeclRef(Z3_solver_propagate_declare(ctx.ref(), to_symbol(name, ctx), arity, dom, rng.ast), ctx)
12009 
12010 
12011 
Function Declarations.
Definition: z3py.py:775
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:4343
def PropagateFunction(name, sig)
Definition: z3py.py:11989
def z3_debug()
Definition: z3py.py:70
def is_sort
Definition: z3py.py:682
def to_symbol
Definition: z3py.py:132
Z3_func_decl Z3_API Z3_solver_propagate_declare(Z3_context c, Z3_symbol name, unsigned n, Z3_sort *domain, Z3_sort range)
def z3py.prove (   claim,
  show = False,
  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 9497 of file z3py.py.

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

9497 def prove(claim, show=False, **keywords):
9498  """Try to prove the given claim.
9499 
9500  This is a simple function for creating demonstrations. It tries to prove
9501  `claim` by showing the negation is unsatisfiable.
9502 
9503  >>> p, q = Bools('p q')
9504  >>> prove(Not(And(p, q)) == Or(Not(p), Not(q)))
9505  proved
9506  """
9507  if z3_debug():
9508  _z3_assert(is_bool(claim), "Z3 Boolean expression expected")
9509  s = Solver()
9510  s.set(**keywords)
9511  s.add(Not(claim))
9512  if show:
9513  print(s)
9514  r = s.check()
9515  if r == unsat:
9516  print("proved")
9517  elif r == unknown:
9518  print("failed to prove")
9519  print(s.model())
9520  else:
9521  print("counterexample")
9522  print(s.model())
9523 
9524 
def Not
Definition: z3py.py:1948
def prove(claim, show=False, keywords)
Definition: z3py.py:9497
def is_bool
Definition: z3py.py:1704
def z3_debug()
Definition: z3py.py:70
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 3395 of file z3py.py.

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

3395 def Q(a, b, ctx=None):
3396  """Return a Z3 rational a/b.
3397 
3398  If `ctx=None`, then the global context is used.
3399 
3400  >>> Q(3,5)
3401  3/5
3402  >>> Q(3,5).sort()
3403  Real
3404  """
3405  return simplify(RatVal(a, b, ctx=ctx))
3406 
3407 
def simplify(a, arguments, keywords)
Utils.
Definition: z3py.py:9174
def Q
Definition: z3py.py:3395
def RatVal
Definition: z3py.py:3375
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 11749 of file z3py.py.

11749 def Range(lo, hi, ctx=None):
11750  """Create the range regular expression over two sequences of length 1
11751  >>> range = Range("a","z")
11752  >>> print(simplify(InRe("b", range)))
11753  True
11754  >>> print(simplify(InRe("bb", range)))
11755  False
11756  """
11757  lo = _coerce_seq(lo, ctx)
11758  hi = _coerce_seq(hi, ctx)
11759  if z3_debug():
11760  _z3_assert(is_expr(lo), "expression expected")
11761  _z3_assert(is_expr(hi), "expression expected")
11762  return ReRef(Z3_mk_re_range(lo.ctx_ref(), lo.ast, hi.ast), lo.ctx)
11763 
def Range
Definition: z3py.py:11749
def z3_debug()
Definition: z3py.py:70
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 is_expr(a)
Definition: z3py.py:1345
def z3py.RatVal (   a,
  b,
  ctx = None 
)
Return a Z3 rational a/b.

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

Note: Division by zero (b == 0) is allowed in Z3 symbolic expressions.
Z3 can reason about such expressions symbolically.

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

Definition at line 3375 of file z3py.py.

Referenced by Q().

3375 def RatVal(a, b, ctx=None):
3376  """Return a Z3 rational a/b.
3377 
3378  If `ctx=None`, then the global context is used.
3379 
3380  Note: Division by zero (b == 0) is allowed in Z3 symbolic expressions.
3381  Z3 can reason about such expressions symbolically.
3382 
3383  >>> RatVal(3,5)
3384  3/5
3385  >>> RatVal(3,5).sort()
3386  Real
3387  """
3388  if z3_debug():
3389  _z3_assert(_is_int(a) or isinstance(a, str), "First argument cannot be converted into an integer")
3390  _z3_assert(_is_int(b) or isinstance(b, str), "Second argument cannot be converted into an integer")
3391  # Division by 0 is intentionally allowed - Z3 handles it symbolically
3392  return simplify(RealVal(a, ctx) / RealVal(b, ctx))
3393 
3394 
def simplify(a, arguments, keywords)
Utils.
Definition: z3py.py:9174
def z3_debug()
Definition: z3py.py:70
def RealVal
Definition: z3py.py:3356
def RatVal
Definition: z3py.py:3375
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 11593 of file z3py.py.

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

11593 def Re(s, ctx=None):
11594  """The regular expression that accepts sequence 's'
11595  >>> s1 = Re("ab")
11596  >>> s2 = Re(StringVal("ab"))
11597  >>> s3 = Re(Unit(BoolVal(True)))
11598  """
11599  s = _coerce_seq(s, ctx)
11600  return ReRef(Z3_mk_seq_to_re(s.ctx_ref(), s.as_ast()), s.ctx)
11601 
11602 
11603 # Regular expressions
11604 
def Re
Definition: z3py.py:11593
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 3461 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().

3461 def Real(name, ctx=None):
3462  """Return a real constant named `name`. If `ctx=None`, then the global context is used.
3463 
3464  >>> x = Real('x')
3465  >>> is_real(x)
3466  True
3467  >>> is_real(x + 1)
3468  True
3469  """
3470  ctx = _get_ctx(ctx)
3471  return ArithRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), RealSort(ctx).ast), ctx)
3472 
3473 
def RealSort
Definition: z3py.py:3315
def Real
Definition: z3py.py:3461
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:132
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 3474 of file z3py.py.

Referenced by is_div().

3474 def Reals(names, ctx=None):
3475  """Return a tuple of real constants.
3476 
3477  >>> x, y, z = Reals('x y z')
3478  >>> Sum(x, y, z)
3479  x + y + z
3480  >>> Sum(x, y, z).sort()
3481  Real
3482  """
3483  ctx = _get_ctx(ctx)
3484  if isinstance(names, str):
3485  names = names.split(" ")
3486  return [Real(name, ctx) for name in names]
3487 
3488 
def Real
Definition: z3py.py:3461
def Reals
Definition: z3py.py:3474
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 3315 of file z3py.py.

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

3315 def RealSort(ctx=None):
3316  """Return the real sort in the given context. If `ctx=None`, then the global context is used.
3317 
3318  >>> RealSort()
3319  Real
3320  >>> x = Const('x', RealSort())
3321  >>> is_real(x)
3322  True
3323  >>> is_int(x)
3324  False
3325  >>> x.sort() == RealSort()
3326  True
3327  """
3328  ctx = _get_ctx(ctx)
3329  return ArithSortRef(Z3_mk_real_sort(ctx.ref()), ctx)
3330 
3331 
def RealSort
Definition: z3py.py:3315
Arithmetic.
Definition: z3py.py:2431
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 3356 of file z3py.py.

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

3356 def RealVal(val, ctx=None):
3357  """Return a Z3 real value.
3358 
3359  `val` may be a Python int, long, float or string representing a number in decimal or rational notation.
3360  If `ctx=None`, then the global context is used.
3361 
3362  >>> RealVal(1)
3363  1
3364  >>> RealVal(1).sort()
3365  Real
3366  >>> RealVal("3/5")
3367  3/5
3368  >>> RealVal("1.5")
3369  3/2
3370  """
3371  ctx = _get_ctx(ctx)
3372  return RatNumRef(Z3_mk_numeral(ctx.ref(), str(val), RealSort(ctx).ast), ctx)
3373 
3374 
def RealSort
Definition: z3py.py:3315
def RealVal
Definition: z3py.py:3356
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)

Definition at line 1590 of file z3py.py.

Referenced by RealVarVector().

1590 def RealVar(idx: int, ctx=None) -> ExprRef:
1591  """
1592  Create a real free variable. Free variables are used to create quantified formulas.
1593  They are also used to create polynomials.
1594 
1595  >>> RealVar(0)
1596  Var(0)
1597  """
1598  return Var(idx, RealSort(ctx))
1599 
def RealSort
Definition: z3py.py:3315
def RealVar
Definition: z3py.py:1590
def Var
Definition: z3py.py:1575
def z3py.RealVarVector (   n)

Definition at line 1600 of file z3py.py.

1600 def RealVarVector(n: int, ctx= None):
1601  """
1602  Create a list of Real free variables.
1603  The variables have ids: 0, 1, ..., n-1
1604 
1605  >>> x0, x1, x2, x3 = RealVarVector(4)
1606  >>> x2
1607  Var(2)
1608  """
1609  return [RealVar(i, ctx) for i in range(n)]
1610 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:4343
def RealVarVector
Definition: z3py.py:1600
def RealVar
Definition: z3py.py:1590
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 3489 of file z3py.py.

3489 def RealVector(prefix, sz, ctx=None):
3490  """Return a list of real constants of size `sz`.
3491 
3492  >>> X = RealVector('x', 3)
3493  >>> X
3494  [x__0, x__1, x__2]
3495  >>> Sum(X)
3496  x__0 + x__1 + x__2
3497  >>> Sum(X).sort()
3498  Real
3499  """
3500  ctx = _get_ctx(ctx)
3501  return [Real("%s__%s" % (prefix, i), ctx) for i in range(sz)]
3502 
3503 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:4343
def Real
Definition: z3py.py:3461
def RealVector
Definition: z3py.py:3489
def z3py.RecAddDefinition (   f,
  args,
  body 
)
Set the body of a recursive function.
   Recursive definitions can be simplified if they are applied to ground
   arguments.
>>> 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))
120
>>> s = Solver(ctx=ctx)
>>> s.add(fac(n) < 3)
>>> s.check()
sat
>>> s.model().eval(fac(5))
120

Definition at line 984 of file z3py.py.

984 def RecAddDefinition(f, args, body):
985  """Set the body of a recursive function.
986  Recursive definitions can be simplified if they are applied to ground
987  arguments.
988  >>> ctx = Context()
989  >>> fac = RecFunction('fac', IntSort(ctx), IntSort(ctx))
990  >>> n = Int('n', ctx)
991  >>> RecAddDefinition(fac, n, If(n == 0, 1, n*fac(n-1)))
992  >>> simplify(fac(5))
993  120
994  >>> s = Solver(ctx=ctx)
995  >>> s.add(fac(n) < 3)
996  >>> s.check()
997  sat
998  >>> s.model().eval(fac(5))
999  120
1000  """
1001  if is_app(args):
1002  args = [args]
1003  ctx = body.ctx
1004  args = _get_args(args)
1005  n = len(args)
1006  _args = (Ast * n)()
1007  for i in range(n):
1008  _args[i] = args[i].ast
1009  Z3_add_rec_def(ctx.ref(), f.ast, n, _args, body.ast)
1010 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:4343
def is_app(a)
Definition: z3py.py:1368
def RecAddDefinition(f, args, body)
Definition: z3py.py:984
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 z3py.RecFunction (   name,
  sig 
)
Create a new Z3 recursive with the given sorts.

Definition at line 966 of file z3py.py.

966 def RecFunction(name, *sig):
967  """Create a new Z3 recursive with the given sorts."""
968  sig = _get_args(sig)
969  if z3_debug():
970  _z3_assert(len(sig) > 0, "At least two arguments expected")
971  arity = len(sig) - 1
972  rng = sig[arity]
973  if z3_debug():
974  _z3_assert(is_sort(rng), "Z3 sort expected")
975  dom = (Sort * arity)()
976  for i in range(arity):
977  if z3_debug():
978  _z3_assert(is_sort(sig[i]), "Z3 sort expected")
979  dom[i] = sig[i].ast
980  ctx = rng.ctx
981  return FuncDeclRef(Z3_mk_rec_func_decl(ctx.ref(), to_symbol(name, ctx), arity, dom, rng.ast), ctx)
982 
983 
Function Declarations.
Definition: z3py.py:775
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:4343
def RecFunction(name, sig)
Definition: z3py.py:966
def z3_debug()
Definition: z3py.py:70
def is_sort
Definition: z3py.py:682
def to_symbol
Definition: z3py.py:132
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 8822 of file z3py.py.

8822 def Repeat(t, max=4294967295, ctx=None):
8823  """Return a tactic that keeps applying `t` until the goal is not modified anymore
8824  or the maximum number of iterations `max` is reached.
8825 
8826  >>> x, y = Ints('x y')
8827  >>> c = And(Or(x == 0, x == 1), Or(y == 0, y == 1), x > y)
8828  >>> t = Repeat(OrElse(Tactic('split-clause'), Tactic('skip')))
8829  >>> r = t(c)
8830  >>> for subgoal in r: print(subgoal)
8831  [x == 0, y == 0, x > y]
8832  [x == 0, y == 1, x > y]
8833  [x == 1, y == 0, x > y]
8834  [x == 1, y == 1, x > y]
8835  >>> t = Then(t, Tactic('propagate-values'))
8836  >>> t(c)
8837  [[x == 1, y == 0]]
8838  """
8839  t = _to_tactic(t, ctx)
8840  return Tactic(Z3_tactic_repeat(t.ctx.ref(), t.tactic, max), t.ctx)
8841 
8842 
def Repeat
Definition: z3py.py:8822
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 4611 of file z3py.py.

4611 def RepeatBitVec(n, a):
4612  """Return an expression representing `n` copies of `a`.
4613 
4614  >>> x = BitVec('x', 8)
4615  >>> n = RepeatBitVec(4, x)
4616  >>> n
4617  RepeatBitVec(4, x)
4618  >>> n.size()
4619  32
4620  >>> v0 = BitVecVal(10, 4)
4621  >>> print("%.x" % v0.as_long())
4622  a
4623  >>> v = simplify(RepeatBitVec(4, v0))
4624  >>> v.size()
4625  16
4626  >>> print("%.x" % v.as_long())
4627  aaaa
4628  """
4629  if z3_debug():
4630  _z3_assert(_is_int(n), "First argument must be an integer")
4631  _z3_assert(is_bv(a), "Second argument must be a Z3 bit-vector expression")
4632  return BitVecRef(Z3_mk_repeat(a.ctx_ref(), n, a.as_ast()), a.ctx)
4633 
4634 
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:70
def is_bv(a)
Definition: z3py.py:4111
def RepeatBitVec(n, a)
Definition: z3py.py:4611
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 11478 of file z3py.py.

11478 def Replace(s, src, dst):
11479  """Replace the first occurrence of 'src' by 'dst' in 's'
11480  >>> r = Replace("aaa", "a", "b")
11481  >>> simplify(r)
11482  "baa"
11483  """
11484  ctx = _get_ctx2(dst, s)
11485  if ctx is None and is_expr(src):
11486  ctx = src.ctx
11487  src = _coerce_seq(src, ctx)
11488  dst = _coerce_seq(dst, ctx)
11489  s = _coerce_seq(s, ctx)
11490  return SeqRef(Z3_mk_seq_replace(src.ctx_ref(), s.as_ast(), src.as_ast(), dst.as_ast()), s.ctx)
11491 
11492 
Z3_ast Z3_API Z3_mk_seq_replace(Z3_context c, Z3_ast s, Z3_ast src, Z3_ast dst)
Replace the first occurrence of src with dst in s.
def Replace(s, src, dst)
Definition: z3py.py:11478
def is_expr(a)
Definition: z3py.py:1345
def z3py.reset_params (   None)
Reset all global (or module) parameters.

Definition at line 322 of file z3py.py.

322 def reset_params() -> None:
323  """Reset all global (or module) parameters.
324  """
326 
327 
def reset_params()
Definition: z3py.py:322
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 11612 of file z3py.py.

Referenced by Empty(), and Full().

11612 def ReSort(s):
11613  if is_ast(s):
11614  return ReSortRef(Z3_mk_re_sort(s.ctx.ref(), s.ast), s.ctx)
11615  if s is None or isinstance(s, Context):
11616  ctx = _get_ctx(s)
11617  return ReSortRef(Z3_mk_re_sort(ctx.ref(), Z3_mk_string_sort(ctx.ref())), s.ctx)
11618  raise Z3Exception("Regular expression sort constructor expects either a string or a context or no argument")
11619 
11620 
def is_ast
Definition: z3py.py:482
def ReSort(s)
Definition: z3py.py:11612
Z3_sort Z3_API Z3_mk_string_sort(Z3_context c)
Create a sort for unicode strings.
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 10084 of file z3py.py.

Referenced by get_default_rounding_mode().

10084 def RNA(ctx=None):
10085  ctx = _get_ctx(ctx)
10086  return FPRMRef(Z3_mk_fpa_round_nearest_ties_to_away(ctx.ref()), ctx)
10087 
10088 
def RNA
Definition: z3py.py:10084
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 10074 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().

10074 def RNE(ctx=None):
10075  ctx = _get_ctx(ctx)
10076  return FPRMRef(Z3_mk_fpa_round_nearest_ties_to_even(ctx.ref()), ctx)
10077 
10078 
def RNE
Definition: z3py.py:10074
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 4521 of file z3py.py.

4521 def RotateLeft(a, b):
4522  """Return an expression representing `a` rotated to the left `b` times.
4523 
4524  >>> a, b = BitVecs('a b', 16)
4525  >>> RotateLeft(a, b)
4526  RotateLeft(a, b)
4527  >>> simplify(RotateLeft(a, 0))
4528  a
4529  >>> simplify(RotateLeft(a, 16))
4530  a
4531  """
4532  _check_bv_args(a, b)
4533  a, b = _coerce_exprs(a, b)
4534  return BitVecRef(Z3_mk_ext_rotate_left(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4535 
4536 
def RotateLeft(a, b)
Definition: z3py.py:4521
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 4537 of file z3py.py.

4537 def RotateRight(a, b):
4538  """Return an expression representing `a` rotated to the right `b` times.
4539 
4540  >>> a, b = BitVecs('a b', 16)
4541  >>> RotateRight(a, b)
4542  RotateRight(a, b)
4543  >>> simplify(RotateRight(a, 0))
4544  a
4545  >>> simplify(RotateRight(a, 16))
4546  a
4547  """
4548  _check_bv_args(a, b)
4549  a, b = _coerce_exprs(a, b)
4550  return BitVecRef(Z3_mk_ext_rotate_right(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4551 
4552 
Z3_ast Z3_API Z3_mk_ext_rotate_right(Z3_context c, Z3_ast t1, Z3_ast t2)
Rotate bits of t1 to the right t2 times.
def RotateRight(a, b)
Definition: z3py.py:4537
def z3py.RoundNearestTiesToAway (   ctx = None)

Definition at line 10079 of file z3py.py.

10080  ctx = _get_ctx(ctx)
10081  return FPRMRef(Z3_mk_fpa_round_nearest_ties_to_away(ctx.ref()), ctx)
10082 
10083 
def RoundNearestTiesToAway
Definition: z3py.py:10079
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 10069 of file z3py.py.

10070  ctx = _get_ctx(ctx)
10071  return FPRMRef(Z3_mk_fpa_round_nearest_ties_to_even(ctx.ref()), ctx)
10072 
10073 
def RoundNearestTiesToEven
Definition: z3py.py:10069
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 10099 of file z3py.py.

10099 def RoundTowardNegative(ctx=None):
10100  ctx = _get_ctx(ctx)
10101  return FPRMRef(Z3_mk_fpa_round_toward_negative(ctx.ref()), ctx)
10102 
10103 
def RoundTowardNegative
Definition: z3py.py:10099
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 10089 of file z3py.py.

10089 def RoundTowardPositive(ctx=None):
10090  ctx = _get_ctx(ctx)
10091  return FPRMRef(Z3_mk_fpa_round_toward_positive(ctx.ref()), ctx)
10092 
10093 
def RoundTowardPositive
Definition: z3py.py:10089
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 10109 of file z3py.py.

10109 def RoundTowardZero(ctx=None):
10110  ctx = _get_ctx(ctx)
10111  return FPRMRef(Z3_mk_fpa_round_toward_zero(ctx.ref()), ctx)
10112 
10113 
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:10109
def z3py.RTN (   ctx = None)

Definition at line 10104 of file z3py.py.

Referenced by get_default_rounding_mode().

10104 def RTN(ctx=None):
10105  ctx = _get_ctx(ctx)
10106  return FPRMRef(Z3_mk_fpa_round_toward_negative(ctx.ref()), ctx)
10107 
10108 
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:10104
def z3py.RTP (   ctx = None)

Definition at line 10094 of file z3py.py.

Referenced by get_default_rounding_mode().

10094 def RTP(ctx=None):
10095  ctx = _get_ctx(ctx)
10096  return FPRMRef(Z3_mk_fpa_round_toward_positive(ctx.ref()), ctx)
10097 
10098 
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:10094
def z3py.RTZ (   ctx = None)

Definition at line 10114 of file z3py.py.

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

10114 def RTZ(ctx=None):
10115  ctx = _get_ctx(ctx)
10116  return FPRMRef(Z3_mk_fpa_round_toward_zero(ctx.ref()), ctx)
10117 
10118 
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:10114
def z3py.Select (   a,
  args 
)
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 4997 of file z3py.py.

4997 def Select(a, *args):
4998  """Return a Z3 select array expression.
4999 
5000  >>> a = Array('a', IntSort(), IntSort())
5001  >>> i = Int('i')
5002  >>> Select(a, i)
5003  a[i]
5004  >>> eq(Select(a, i), a[i])
5005  True
5006  """
5007  args = _get_args(args)
5008  if z3_debug():
5009  _z3_assert(is_array_sort(a), "First argument must be a Z3 array expression")
5010  return a[args]
5011 
5012 
def is_array_sort(a)
Definition: z3py.py:4797
def Select(a, args)
Definition: z3py.py:4997
def z3_debug()
Definition: z3py.py:70
def z3py.SeqFoldLeft (   f,
  a,
  s 
)

Definition at line 11545 of file z3py.py.

11545 def SeqFoldLeft(f, a, s):
11546  ctx = _get_ctx2(f, s)
11547  s = _coerce_seq(s, ctx)
11548  a = _py2expr(a)
11549  return _to_expr_ref(Z3_mk_seq_foldl(s.ctx_ref(), f.as_ast(), a.as_ast(), s.as_ast()), ctx)
11550 
Z3_ast Z3_API Z3_mk_seq_foldl(Z3_context c, Z3_ast f, Z3_ast a, Z3_ast s)
Create a fold of the function f over the sequence s with accumulator a.
def SeqFoldLeft(f, a, s)
Definition: z3py.py:11545
def z3py.SeqFoldLeftI (   f,
  i,
  a,
  s 
)

Definition at line 11551 of file z3py.py.

11551 def SeqFoldLeftI(f, i, a, s):
11552  ctx = _get_ctx2(f, s)
11553  s = _coerce_seq(s, ctx)
11554  a = _py2expr(a)
11555  i = _py2expr(i)
11556  return _to_expr_ref(Z3_mk_seq_foldli(s.ctx_ref(), f.as_ast(), i.as_ast(), a.as_ast(), s.as_ast()), ctx)
11557 
Z3_ast Z3_API Z3_mk_seq_foldli(Z3_context c, Z3_ast f, Z3_ast i, Z3_ast a, Z3_ast s)
Create a fold with index tracking of the function f over the sequence s with accumulator a starting a...
def SeqFoldLeftI(f, i, a, s)
Definition: z3py.py:11551
def z3py.SeqMap (   f,
  s 
)
Map function 'f' over sequence 's'

Definition at line 11531 of file z3py.py.

11531 def SeqMap(f, s):
11532  """Map function 'f' over sequence 's'"""
11533  ctx = _get_ctx2(f, s)
11534  s = _coerce_seq(s, ctx)
11535  return _to_expr_ref(Z3_mk_seq_map(s.ctx_ref(), f.as_ast(), s.as_ast()), ctx)
11536 
def SeqMap(f, s)
Definition: z3py.py:11531
Z3_ast Z3_API Z3_mk_seq_map(Z3_context c, Z3_ast f, Z3_ast s)
Create a map of the function f over the sequence s.
def z3py.SeqMapI (   f,
  i,
  s 
)
Map function 'f' over sequence 's' at index 'i'

Definition at line 11537 of file z3py.py.

11537 def SeqMapI(f, i, s):
11538  """Map function 'f' over sequence 's' at index 'i'"""
11539  ctx = _get_ctx2(f, s)
11540  s = _coerce_seq(s, ctx)
11541  if not is_expr(i):
11542  i = _py2expr(i)
11543  return _to_expr_ref(Z3_mk_seq_mapi(s.ctx_ref(), f.as_ast(), i.as_ast(), s.as_ast()), ctx)
11544 
Z3_ast Z3_API Z3_mk_seq_mapi(Z3_context c, Z3_ast f, Z3_ast i, Z3_ast s)
Create a map of the function f over the sequence s starting at index i.
def SeqMapI(f, i, s)
Definition: z3py.py:11537
def is_expr(a)
Definition: z3py.py:1345
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 11178 of file z3py.py.

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

11178 def SeqSort(s):
11179  """Create a sequence sort over elements provided in the argument
11180  >>> s = SeqSort(IntSort())
11181  >>> s == Unit(IntVal(1)).sort()
11182  True
11183  """
11184  return SeqSortRef(Z3_mk_seq_sort(s.ctx_ref(), s.ast), s.ctx)
11185 
11186 
def SeqSort(s)
Definition: z3py.py:11178
Strings, Sequences and Regular expressions.
Definition: z3py.py:11138
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 9730 of file z3py.py.

9730 def set_default_fp_sort(ebits, sbits, ctx=None):
9731  global _dflt_fpsort_ebits
9732  global _dflt_fpsort_sbits
9733  _dflt_fpsort_ebits = ebits
9734  _dflt_fpsort_sbits = sbits
9735 
9736 
def set_default_fp_sort
Definition: z3py.py:9730
def z3py.set_default_rounding_mode (   rm,
  ctx = None 
)

Definition at line 9717 of file z3py.py.

9717 def set_default_rounding_mode(rm, ctx=None):
9718  global _dflt_rounding_mode
9719  if is_fprm_value(rm):
9720  _dflt_rounding_mode = rm.kind()
9721  else:
9722  _z3_assert(_dflt_rounding_mode in _ROUNDING_MODES, "illegal rounding mode")
9723  _dflt_rounding_mode = rm
9724 
9725 
def is_fprm_value(a)
Definition: z3py.py:10132
def set_default_rounding_mode
Definition: z3py.py:9717
def z3py.set_option (   args,
  kws 
)
Alias for 'set_param' for backward compatibility.

Definition at line 328 of file z3py.py.

328 def set_option(*args, **kws):
329  """Alias for 'set_param' for backward compatibility.
330  """
331  return set_param(*args, **kws)
332 
333 
def set_option(args, kws)
Definition: z3py.py:328
def set_param(args, kws)
Definition: z3py.py:298
def z3py.set_param (   args,
  kws 
)
Set Z3 global (or module) parameters.

>>> set_param(precision=10)

Definition at line 298 of file z3py.py.

Referenced by set_option().

298 def set_param(*args, **kws):
299  """Set Z3 global (or module) parameters.
300 
301  >>> set_param(precision=10)
302  """
303  if z3_debug():
304  _z3_assert(len(args) % 2 == 0, "Argument list must have an even number of elements.")
305  new_kws = {}
306  for k in kws:
307  v = kws[k]
308  if not set_pp_option(k, v):
309  new_kws[k] = v
310  for key in new_kws:
311  value = new_kws[key]
312  Z3_global_param_set(str(key).upper(), _to_param_value(value))
313  prev = None
314  for a in args:
315  if prev is None:
316  prev = a
317  else:
318  Z3_global_param_set(str(prev), _to_param_value(a))
319  prev = None
320 
321 
void Z3_API Z3_global_param_set(Z3_string param_id, Z3_string param_value)
Set a global (or module) parameter. This setting is shared by all Z3 contexts.
def set_param(args, kws)
Definition: z3py.py:298
def z3_debug()
Definition: z3py.py:70
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 5149 of file z3py.py.

5149 def SetAdd(s, e):
5150  """ Add element e to set s
5151  >>> a = Const('a', SetSort(IntSort()))
5152  >>> SetAdd(a, 1)
5153  Store(a, 1, True)
5154  """
5155  ctx = _ctx_from_ast_arg_list([s, e])
5156  e = _py2expr(e, ctx)
5157  return ArrayRef(Z3_mk_set_add(ctx.ref(), s.as_ast(), e.as_ast()), ctx)
5158 
5159 
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(s, e)
Definition: z3py.py:5149
def z3py.SetComplement (   s)
The complement of set s
>>> a = Const('a', SetSort(IntSort()))
>>> SetComplement(a)
complement(a)

Definition at line 5171 of file z3py.py.

5172  """ The complement of set s
5173  >>> a = Const('a', SetSort(IntSort()))
5174  >>> SetComplement(a)
5175  complement(a)
5176  """
5177  ctx = s.ctx
5178  return ArrayRef(Z3_mk_set_complement(ctx.ref(), s.as_ast()), ctx)
5179 
5180 
Z3_ast Z3_API Z3_mk_set_complement(Z3_context c, Z3_ast arg)
Take the complement of a set.
def SetComplement(s)
Definition: z3py.py:5171
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 5160 of file z3py.py.

5160 def SetDel(s, e):
5161  """ Remove element e to set s
5162  >>> a = Const('a', SetSort(IntSort()))
5163  >>> SetDel(a, 1)
5164  Store(a, 1, False)
5165  """
5166  ctx = _ctx_from_ast_arg_list([s, e])
5167  e = _py2expr(e, ctx)
5168  return ArrayRef(Z3_mk_set_del(ctx.ref(), s.as_ast(), e.as_ast()), ctx)
5169 
5170 
Z3_ast Z3_API Z3_mk_set_del(Z3_context c, Z3_ast set, Z3_ast elem)
Remove an element to a set.
def SetDel(s, e)
Definition: z3py.py:5160
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 5181 of file z3py.py.

5181 def SetDifference(a, b):
5182  """ The set difference of a and b
5183  >>> a = Const('a', SetSort(IntSort()))
5184  >>> b = Const('b', SetSort(IntSort()))
5185  >>> SetDifference(a, b)
5186  setminus(a, b)
5187  """
5188  ctx = _ctx_from_ast_arg_list([a, b])
5189  return ArrayRef(Z3_mk_set_difference(ctx.ref(), a.as_ast(), b.as_ast()), ctx)
5190 
5191 
def SetDifference(a, b)
Definition: z3py.py:5181
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 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 5136 of file z3py.py.

5136 def SetIntersect(*args):
5137  """ Take the union of sets
5138  >>> a = Const('a', SetSort(IntSort()))
5139  >>> b = Const('b', SetSort(IntSort()))
5140  >>> SetIntersect(a, b)
5141  intersection(a, b)
5142  """
5143  args = _get_args(args)
5144  ctx = _ctx_from_ast_arg_list(args)
5145  _args, sz = _to_ast_array(args)
5146  return ArrayRef(Z3_mk_set_intersect(ctx.ref(), sz, _args), ctx)
5147 
5148 
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(args)
Definition: z3py.py:5136
def z3py.SetSort (   s)

Sets.

Create a set sort over element sort s

Definition at line 5100 of file z3py.py.

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

5100 def SetSort(s):
5101  """ Create a set sort over element sort s"""
5102  return ArraySort(s, BoolSort())
5103 
5104 
def BoolSort
Definition: z3py.py:1824
def ArraySort(sig)
Definition: z3py.py:4890
def SetSort(s)
Sets.
Definition: z3py.py:5100
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 5123 of file z3py.py.

5123 def SetUnion(*args):
5124  """ Take the union of sets
5125  >>> a = Const('a', SetSort(IntSort()))
5126  >>> b = Const('b', SetSort(IntSort()))
5127  >>> SetUnion(a, b)
5128  union(a, b)
5129  """
5130  args = _get_args(args)
5131  ctx = _ctx_from_ast_arg_list(args)
5132  _args, sz = _to_ast_array(args)
5133  return ArrayRef(Z3_mk_set_union(ctx.ref(), sz, _args), ctx)
5134 
5135 
def SetUnion(args)
Definition: z3py.py:5123
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 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 4553 of file z3py.py.

4553 def SignExt(n, a):
4554  """Return a bit-vector expression with `n` extra sign-bits.
4555 
4556  >>> x = BitVec('x', 16)
4557  >>> n = SignExt(8, x)
4558  >>> n.size()
4559  24
4560  >>> n
4561  SignExt(8, x)
4562  >>> n.sort()
4563  BitVec(24)
4564  >>> v0 = BitVecVal(2, 2)
4565  >>> v0
4566  2
4567  >>> v0.size()
4568  2
4569  >>> v = simplify(SignExt(6, v0))
4570  >>> v
4571  254
4572  >>> v.size()
4573  8
4574  >>> print("%.x" % v.as_long())
4575  fe
4576  """
4577  if z3_debug():
4578  _z3_assert(_is_int(n), "First argument must be an integer")
4579  _z3_assert(is_bv(a), "Second argument must be a Z3 bit-vector expression")
4580  return BitVecRef(Z3_mk_sign_ext(a.ctx_ref(), n, a.as_ast()), a.ctx)
4581 
4582 
def SignExt(n, a)
Definition: z3py.py:4553
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:70
def is_bv(a)
Definition: z3py.py:4111
def z3py.SimpleSolver (   ctx = None,
  logFile = 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 7747 of file z3py.py.

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

7747 def SimpleSolver(ctx=None, logFile=None):
7748  """Return a simple general purpose solver with limited amount of preprocessing.
7749 
7750  >>> s = SimpleSolver()
7751  >>> x = Int('x')
7752  >>> s.add(x > 0)
7753  >>> s.check()
7754  sat
7755  """
7756  ctx = _get_ctx(ctx)
7757  return Solver(Z3_mk_simple_solver(ctx.ref()), ctx, logFile)
7758 
Z3_solver Z3_API Z3_mk_simple_solver(Z3_context c)
Create a new incremental solver.
def SimpleSolver
Definition: z3py.py:7747
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 9174 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(), 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(), SubSeq(), SubString(), SuffixOf(), Union(), Xor(), and ZeroExt().

9174 def simplify(a, *arguments, **keywords):
9175  """Simplify the expression `a` using the given options.
9176 
9177  This function has many options. Use `help_simplify` to obtain the complete list.
9178 
9179  >>> x = Int('x')
9180  >>> y = Int('y')
9181  >>> simplify(x + 1 + y + x + 1)
9182  2 + 2*x + y
9183  >>> simplify((x + 1)*(y + 1), som=True)
9184  1 + x + y + x*y
9185  >>> simplify(Distinct(x, y, 1), blast_distinct=True)
9186  And(Not(x == y), Not(x == 1), Not(y == 1))
9187  >>> simplify(And(x == 0, y == 1), elim_and=True)
9188  Not(Or(Not(x == 0), Not(y == 1)))
9189  """
9190  if z3_debug():
9191  _z3_assert(is_expr(a), "Z3 expression expected")
9192  if len(arguments) > 0 or len(keywords) > 0:
9193  p = args2params(arguments, keywords, a.ctx)
9194  return _to_expr_ref(Z3_simplify_ex(a.ctx_ref(), a.as_ast(), p.params), a.ctx)
9195  else:
9196  return _to_expr_ref(Z3_simplify(a.ctx_ref(), a.as_ast()), a.ctx)
9197 
9198 
def simplify(a, arguments, keywords)
Utils.
Definition: z3py.py:9174
Z3_ast Z3_API Z3_simplify_ex(Z3_context c, Z3_ast a, Z3_params p)
Interface to simplifier.
def args2params
Definition: z3py.py:5695
Z3_ast Z3_API Z3_simplify(Z3_context c, Z3_ast a)
Interface to simplifier.
def z3_debug()
Definition: z3py.py:70
def is_expr(a)
Definition: z3py.py:1345
def z3py.simplify_param_descrs ( )
Return the set of parameter descriptions for Z3 `simplify` procedure.

Definition at line 9204 of file z3py.py.

9205  """Return the set of parameter descriptions for Z3 `simplify` procedure."""
9207 
9208 
def main_ctx()
Definition: z3py.py:266
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:9204
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 9436 of file z3py.py.

Referenced by BV2Int(), and IsInt().

9436 def solve(*args, **keywords):
9437  """Solve the constraints `*args`.
9438 
9439  This is a simple function for creating demonstrations. It creates a solver,
9440  configure it using the options in `keywords`, adds the constraints
9441  in `args`, and invokes check.
9442 
9443  >>> a = Int('a')
9444  >>> solve(a > 0, a < 2)
9445  [a = 1]
9446  """
9447  show = keywords.pop("show", False)
9448  s = Solver()
9449  s.set(**keywords)
9450  s.add(*args)
9451  if show:
9452  print(s)
9453  r = s.check()
9454  if r == unsat:
9455  print("no solution")
9456  elif r == unknown:
9457  print("failed to solve")
9458  try:
9459  print(s.model())
9460  except Z3Exception:
9461  return
9462  else:
9463  print(s.model())
9464 
9465 
def solve(args, keywords)
Definition: z3py.py:9436
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 9466 of file z3py.py.

9466 def solve_using(s, *args, **keywords):
9467  """Solve the constraints `*args` using solver `s`.
9468 
9469  This is a simple function for creating demonstrations. It is similar to `solve`,
9470  but it uses the given solver `s`.
9471  It configures solver `s` using the options in `keywords`, adds the constraints
9472  in `args`, and invokes check.
9473  """
9474  show = keywords.pop("show", False)
9475  if z3_debug():
9476  _z3_assert(isinstance(s, Solver), "Solver object expected")
9477  s.set(**keywords)
9478  s.add(*args)
9479  if show:
9480  print("Problem:")
9481  print(s)
9482  r = s.check()
9483  if r == unsat:
9484  print("no solution")
9485  elif r == unknown:
9486  print("failed to solve")
9487  try:
9488  print(s.model())
9489  except Z3Exception:
9490  return
9491  else:
9492  if show:
9493  print("Solution:")
9494  print(s.model())
9495 
9496 
def solve_using(s, args, keywords)
Definition: z3py.py:9466
def z3_debug()
Definition: z3py.py:70
def z3py.SolverFor (   logic,
  ctx = None,
  logFile = 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 7726 of file z3py.py.

7726 def SolverFor(logic, ctx=None, logFile=None):
7727  """Create a solver customized for the given logic.
7728 
7729  The parameter `logic` is a string. It should be contains
7730  the name of a SMT-LIB logic.
7731  See http://www.smtlib.org/ for the name of all available logics.
7732 
7733  >>> s = SolverFor("QF_LIA")
7734  >>> x = Int('x')
7735  >>> s.add(x > 0)
7736  >>> s.add(x < 2)
7737  >>> s.check()
7738  sat
7739  >>> s.model()
7740  [x = 1]
7741  """
7742  ctx = _get_ctx(ctx)
7743  logic = to_symbol(logic)
7744  return Solver(Z3_mk_solver_for_logic(ctx.ref(), logic), ctx, logFile)
7745 
7746 
def SolverFor
Definition: z3py.py:7726
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:132
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 3573 of file z3py.py.

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

3573 def Sqrt(a, ctx=None):
3574  """ Return a Z3 expression which represents the square root of a.
3575 
3576  >>> x = Real('x')
3577  >>> Sqrt(x)
3578  x**(1/2)
3579  """
3580  if not is_expr(a):
3581  ctx = _get_ctx(ctx)
3582  a = RealVal(a, ctx)
3583  return a ** "1/2"
3584 
3585 
def RealVal
Definition: z3py.py:3356
def is_expr(a)
Definition: z3py.py:1345
def Sqrt
Definition: z3py.py:3573
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 4468 of file z3py.py.

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

4468 def SRem(a, b):
4469  """Create the Z3 expression signed remainder.
4470 
4471  Use the operator % for signed modulus, and URem() for unsigned remainder.
4472 
4473  >>> x = BitVec('x', 32)
4474  >>> y = BitVec('y', 32)
4475  >>> SRem(x, y)
4476  SRem(x, y)
4477  >>> SRem(x, y).sort()
4478  BitVec(32)
4479  >>> (x % y).sexpr()
4480  '(bvsmod x y)'
4481  >>> SRem(x, y).sexpr()
4482  '(bvsrem x y)'
4483  """
4484  _check_bv_args(a, b)
4485  a, b = _coerce_exprs(a, b)
4486  return BitVecRef(Z3_mk_bvsrem(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4487 
4488 
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(a, b)
Definition: z3py.py:4468
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 11719 of file z3py.py.

11719 def Star(re):
11720  """Create the regular expression accepting zero or more repetitions of argument.
11721  >>> re = Star(Re("a"))
11722  >>> print(simplify(InRe("aa", re)))
11723  True
11724  >>> print(simplify(InRe("ab", re)))
11725  False
11726  >>> print(simplify(InRe("", re)))
11727  True
11728  """
11729  if z3_debug():
11730  _z3_assert(is_expr(re), "expression expected")
11731  return ReRef(Z3_mk_re_star(re.ctx_ref(), re.as_ast()), re.ctx)
11732 
11733 
def Star(re)
Definition: z3py.py:11719
Z3_ast Z3_API Z3_mk_re_star(Z3_context c, Z3_ast re)
Create the regular language re*.
def z3_debug()
Definition: z3py.py:70
def is_expr(a)
Definition: z3py.py:1345
def z3py.Store (   a,
  args 
)
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 4980 of file z3py.py.

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

4980 def Store(a, *args):
4981  """Return a Z3 store array expression.
4982 
4983  >>> a = Array('a', IntSort(), IntSort())
4984  >>> i, v = Ints('i v')
4985  >>> s = Store(a, i, v)
4986  >>> s.sort()
4987  Array(Int, Int)
4988  >>> prove(s[i] == v)
4989  proved
4990  >>> j = Int('j')
4991  >>> prove(Implies(i != j, s[j] == a[j]))
4992  proved
4993  """
4994  return Update(a, args)
4995 
4996 
def Update(a, args)
Definition: z3py.py:4937
def Store(a, args)
Definition: z3py.py:4980
def z3py.StrFromCode (   c)
Convert code to a string

Definition at line 11587 of file z3py.py.

11588  """Convert code to a string"""
11589  if not is_expr(c):
11590  c = _py2expr(c)
11591  return SeqRef(Z3_mk_string_from_code(c.ctx_ref(), c.as_ast()), c.ctx)
11592 
Z3_ast Z3_API Z3_mk_string_from_code(Z3_context c, Z3_ast a)
Code to string conversion.
def StrFromCode(c)
Definition: z3py.py:11587
def is_expr(a)
Definition: z3py.py:1345
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 11344 of file z3py.py.

11344 def String(name, ctx=None):
11345  """Return a string constant named `name`. If `ctx=None`, then the global context is used.
11346 
11347  >>> x = String('x')
11348  """
11349  ctx = _get_ctx(ctx)
11350  return SeqRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), StringSort(ctx).ast), ctx)
11351 
11352 
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:11344
def to_symbol
Definition: z3py.py:132
def StringSort
Definition: z3py.py:11159
def z3py.Strings (   names,
  ctx = None 
)
Return a tuple of String constants. 

Definition at line 11353 of file z3py.py.

Referenced by Contains().

11353 def Strings(names, ctx=None):
11354  """Return a tuple of String constants. """
11355  ctx = _get_ctx(ctx)
11356  if isinstance(names, str):
11357  names = names.split(" ")
11358  return [String(name, ctx) for name in names]
11359 
11360 
def String
Definition: z3py.py:11344
def Strings
Definition: z3py.py:11353
def z3py.StringSort (   ctx = None)
Create a string sort
>>> s = StringSort()
>>> print(s)
String

Definition at line 11159 of file z3py.py.

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

11159 def StringSort(ctx=None):
11160  """Create a string sort
11161  >>> s = StringSort()
11162  >>> print(s)
11163  String
11164  """
11165  ctx = _get_ctx(ctx)
11166  return SeqSortRef(Z3_mk_string_sort(ctx.ref()), ctx)
11167 
Z3_sort Z3_API Z3_mk_string_sort(Z3_context c)
Create a sort for unicode strings.
Strings, Sequences and Regular expressions.
Definition: z3py.py:11138
def StringSort
Definition: z3py.py:11159
def z3py.StringVal (   s,
  ctx = None 
)
create a string expression

Definition at line 11337 of file z3py.py.

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

11337 def StringVal(s, ctx=None):
11338  """create a string expression"""
11339  s = "".join(str(ch) if 32 <= ord(ch) and ord(ch) < 127 else "\\u{%x}" % (ord(ch)) for ch in s)
11340  ctx = _get_ctx(ctx)
11341  return SeqRef(Z3_mk_string(ctx.ref(), s), ctx)
11342 
11343 
def StringVal
Definition: z3py.py:11337
Z3_ast Z3_API Z3_mk_string(Z3_context c, Z3_string s)
Create a string constant out of the string that is passed in The string may contain escape encoding f...
def z3py.StrToCode (   s)
Convert a unit length string to integer code

Definition at line 11581 of file z3py.py.

11581 def StrToCode(s):
11582  """Convert a unit length string to integer code"""
11583  if not is_expr(s):
11584  s = _py2expr(s)
11585  return ArithRef(Z3_mk_string_to_code(s.ctx_ref(), s.as_ast()), s.ctx)
11586 
Z3_ast Z3_API Z3_mk_string_to_code(Z3_context c, Z3_ast a)
String to code conversion.
def is_expr(a)
Definition: z3py.py:1345
def StrToCode(s)
Definition: z3py.py:11581
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 11558 of file z3py.py.

11558 def StrToInt(s):
11559  """Convert string expression to integer
11560  >>> a = StrToInt("1")
11561  >>> simplify(1 == a)
11562  True
11563  >>> b = StrToInt("2")
11564  >>> simplify(1 == b)
11565  False
11566  >>> c = StrToInt(IntToStr(2))
11567  >>> simplify(1 == c)
11568  False
11569  """
11570  s = _coerce_seq(s)
11571  return ArithRef(Z3_mk_str_to_int(s.ctx_ref(), s.as_ast()), s.ctx)
11572 
11573 
Z3_ast Z3_API Z3_mk_str_to_int(Z3_context c, Z3_ast s)
Convert string to integer.
def StrToInt(s)
Definition: z3py.py:11558
def z3py.SubSeq (   s,
  offset,
  length 
)
Extract substring or subsequence starting at offset.

This is a convenience function that redirects to Extract(s, offset, length).

>>> s = StringVal("hello world")
>>> SubSeq(s, 0, 5)  # Extract "hello"  
str.substr("hello world", 0, 5)
>>> simplify(SubSeq(StringVal("testing"), 2, 4))
"stin"

Definition at line 11375 of file z3py.py.

11375 def SubSeq(s, offset, length):
11376  """Extract substring or subsequence starting at offset.
11377 
11378  This is a convenience function that redirects to Extract(s, offset, length).
11379 
11380  >>> s = StringVal("hello world")
11381  >>> SubSeq(s, 0, 5) # Extract "hello"
11382  str.substr("hello world", 0, 5)
11383  >>> simplify(SubSeq(StringVal("testing"), 2, 4))
11384  "stin"
11385  """
11386  return Extract(s, offset, length)
11387 
11388 
def SubSeq(s, offset, length)
Definition: z3py.py:11375
def Extract(high, low, a)
Definition: z3py.py:4295
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 9209 of file z3py.py.

9209 def substitute(t, *m):
9210  """Apply substitution m on t, m is a list of pairs of the form (from, to).
9211  Every occurrence in t of from is replaced with to.
9212 
9213  >>> x = Int('x')
9214  >>> y = Int('y')
9215  >>> substitute(x + 1, (x, y + 1))
9216  y + 1 + 1
9217  >>> f = Function('f', IntSort(), IntSort())
9218  >>> substitute(f(x) + f(y), (f(x), IntVal(1)), (f(y), IntVal(1)))
9219  1 + 1
9220  """
9221  if isinstance(m, tuple):
9222  m1 = _get_args(m)
9223  if isinstance(m1, list) and all(isinstance(p, tuple) for p in m1):
9224  m = m1
9225  if z3_debug():
9226  _z3_assert(is_expr(t), "Z3 expression expected")
9227  _z3_assert(
9228  all([isinstance(p, tuple) and is_expr(p[0]) and is_expr(p[1]) for p in m]),
9229  "Z3 invalid substitution, expression pairs expected.")
9230  _z3_assert(
9231  all([p[0].sort().eq(p[1].sort()) for p in m]),
9232  'Z3 invalid substitution, mismatching "from" and "to" sorts.')
9233  num = len(m)
9234  _from = (Ast * num)()
9235  _to = (Ast * num)()
9236  for i in range(num):
9237  _from[i] = m[i][0].as_ast()
9238  _to[i] = m[i][1].as_ast()
9239  return _to_expr_ref(Z3_substitute(t.ctx.ref(), t.as_ast(), num, _from, _to), t.ctx)
9240 
9241 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:4343
Z3_ast Z3_API Z3_substitute(Z3_context c, Z3_ast a, unsigned num_exprs, Z3_ast const from[], Z3_ast const to[])
Substitute every occurrence of from[i] in a with to[i], for i smaller than num_exprs. The result is the new AST. The arrays from and to must have size num_exprs. For every i smaller than num_exprs, we must have that sort of from[i] must be equal to sort of to[i].
def substitute(t, m)
Definition: z3py.py:9209
def z3_debug()
Definition: z3py.py:70
def is_expr(a)
Definition: z3py.py:1345
def eq
Definition: z3py.py:503
def z3py.substitute_funs (   t,
  m 
)
Apply substitution m on t, m is a list of pairs of a function and expression (from, to)
Every occurrence in to of the function from is replaced with the expression to.
The expression to can have free variables, that refer to the arguments of from.
For examples, see 

Definition at line 9262 of file z3py.py.

9262 def substitute_funs(t, *m):
9263  """Apply substitution m on t, m is a list of pairs of a function and expression (from, to)
9264  Every occurrence in to of the function from is replaced with the expression to.
9265  The expression to can have free variables, that refer to the arguments of from.
9266  For examples, see
9267  """
9268  if isinstance(m, tuple):
9269  m1 = _get_args(m)
9270  if isinstance(m1, list) and all(isinstance(p, tuple) for p in m1):
9271  m = m1
9272  if z3_debug():
9273  _z3_assert(is_expr(t), "Z3 expression expected")
9274  _z3_assert(all([isinstance(p, tuple) and is_func_decl(p[0]) and is_expr(p[1]) for p in m]), "Z3 invalid substitution, function pairs expected.")
9275  num = len(m)
9276  _from = (FuncDecl * num)()
9277  _to = (Ast * num)()
9278  for i in range(num):
9279  _from[i] = m[i][0].as_func_decl()
9280  _to[i] = m[i][1].as_ast()
9281  return _to_expr_ref(Z3_substitute_funs(t.ctx.ref(), t.as_ast(), num, _from, _to), t.ctx)
9282 
9283 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:4343
def z3_debug()
Definition: z3py.py:70
def is_expr(a)
Definition: z3py.py:1345
def substitute_funs(t, m)
Definition: z3py.py:9262
def is_func_decl(a)
Definition: z3py.py:907
Z3_ast Z3_API Z3_substitute_funs(Z3_context c, Z3_ast a, unsigned num_funs, Z3_func_decl const from[], Z3_ast const to[])
Substitute functions in from with new expressions in to.
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 9242 of file z3py.py.

9242 def substitute_vars(t, *m):
9243  """Substitute the free variables in t with the expression in m.
9244 
9245  >>> v0 = Var(0, IntSort())
9246  >>> v1 = Var(1, IntSort())
9247  >>> x = Int('x')
9248  >>> f = Function('f', IntSort(), IntSort(), IntSort())
9249  >>> # replace v0 with x+1 and v1 with x
9250  >>> substitute_vars(f(v0, v1), x + 1, x)
9251  f(x + 1, x)
9252  """
9253  if z3_debug():
9254  _z3_assert(is_expr(t), "Z3 expression expected")
9255  _z3_assert(all([is_expr(n) for n in m]), "Z3 invalid substitution, list of expressions expected.")
9256  num = len(m)
9257  _to = (Ast * num)()
9258  for i in range(num):
9259  _to[i] = m[i].as_ast()
9260  return _to_expr_ref(Z3_substitute_vars(t.ctx.ref(), t.as_ast(), num, _to), t.ctx)
9261 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:4343
def substitute_vars(t, m)
Definition: z3py.py:9242
Z3_ast Z3_API Z3_substitute_vars(Z3_context c, Z3_ast a, unsigned num_exprs, Z3_ast const to[])
Substitute the variables in a with the expressions in to. For every i smaller than num_exprs...
def z3_debug()
Definition: z3py.py:70
def is_expr(a)
Definition: z3py.py:1345
def z3py.SubString (   s,
  offset,
  length 
)
Extract substring or subsequence starting at offset.

This is a convenience function that redirects to Extract(s, offset, length).

>>> s = StringVal("hello world") 
>>> SubString(s, 6, 5)  # Extract "world"
str.substr("hello world", 6, 5)
>>> simplify(SubString(StringVal("hello"), 1, 3))
"ell"

Definition at line 11361 of file z3py.py.

11361 def SubString(s, offset, length):
11362  """Extract substring or subsequence starting at offset.
11363 
11364  This is a convenience function that redirects to Extract(s, offset, length).
11365 
11366  >>> s = StringVal("hello world")
11367  >>> SubString(s, 6, 5) # Extract "world"
11368  str.substr("hello world", 6, 5)
11369  >>> simplify(SubString(StringVal("hello"), 1, 3))
11370  "ell"
11371  """
11372  return Extract(s, offset, length)
11373 
11374 
def SubString(s, offset, length)
Definition: z3py.py:11361
def Extract(high, low, a)
Definition: z3py.py:4295
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 11444 of file z3py.py.

11444 def SuffixOf(a, b):
11445  """Check if 'a' is a suffix of 'b'
11446  >>> s1 = SuffixOf("ab", "abc")
11447  >>> simplify(s1)
11448  False
11449  >>> s2 = SuffixOf("bc", "abc")
11450  >>> simplify(s2)
11451  True
11452  """
11453  ctx = _get_ctx2(a, b)
11454  a = _coerce_seq(a, ctx)
11455  b = _coerce_seq(b, ctx)
11456  return BoolRef(Z3_mk_seq_suffix(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
11457 
11458 
Z3_ast Z3_API Z3_mk_seq_suffix(Z3_context c, Z3_ast suffix, Z3_ast s)
Check if suffix is a suffix of s.
def SuffixOf(a, b)
Definition: z3py.py:11444
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 9284 of file z3py.py.

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

9284 def Sum(*args):
9285  """Create the sum of the Z3 expressions.
9286 
9287  >>> a, b, c = Ints('a b c')
9288  >>> Sum(a, b, c)
9289  a + b + c
9290  >>> Sum([a, b, c])
9291  a + b + c
9292  >>> A = IntVector('a', 5)
9293  >>> Sum(A)
9294  a__0 + a__1 + a__2 + a__3 + a__4
9295  """
9296  args = _get_args(args)
9297  if len(args) == 0:
9298  return 0
9299  ctx = _ctx_from_ast_arg_list(args)
9300  if ctx is None:
9301  return _reduce(lambda a, b: a + b, args, 0)
9302  args = _coerce_expr_list(args, ctx)
9303  if is_bv(args[0]):
9304  return _reduce(lambda a, b: a + b, args, 0)
9305  else:
9306  _args, sz = _to_ast_array(args)
9307  return ArithRef(Z3_mk_add(ctx.ref(), sz, _args), ctx)
9308 
9309 
def Sum(args)
Definition: z3py.py:9284
Z3_ast Z3_API Z3_mk_add(Z3_context c, unsigned num_args, Z3_ast const args[])
Create an AST node representing args[0] + ... + args[num_args-1].
def is_bv(a)
Definition: z3py.py:4111
def z3py.tactic_description (   name,
  ctx = None 
)
Return a short description for the tactic named `name`.

>>> d = tactic_description('simplify')

Definition at line 8863 of file z3py.py.

Referenced by describe_tactics().

8863 def tactic_description(name, ctx=None):
8864  """Return a short description for the tactic named `name`.
8865 
8866  >>> d = tactic_description('simplify')
8867  """
8868  ctx = _get_ctx(ctx)
8869  return Z3_tactic_get_descr(ctx.ref(), name)
8870 
8871 
def tactic_description
Definition: z3py.py:8863
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 8852 of file z3py.py.

Referenced by describe_tactics().

8852 def tactics(ctx=None):
8853  """Return a list of all available tactics in Z3.
8854 
8855  >>> l = tactics()
8856  >>> l.count('simplify') == 1
8857  True
8858  """
8859  ctx = _get_ctx(ctx)
8860  return [Z3_get_tactic_name(ctx.ref(), i) for i in range(Z3_get_num_tactics(ctx.ref()))]
8861 
8862 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:4343
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:8852
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 8720 of file z3py.py.

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

8720 def Then(*ts, **ks):
8721  """Return a tactic that applies the tactics in `*ts` in sequence. Shorthand for AndThen(*ts, **ks).
8722 
8723  >>> x, y = Ints('x y')
8724  >>> t = Then(Tactic('simplify'), Tactic('solve-eqs'))
8725  >>> t(And(x == 0, y > x + 1))
8726  [[Not(y <= 1)]]
8727  >>> t(And(x == 0, y > x + 1)).as_expr()
8728  Not(y <= 1)
8729  """
8730  return AndThen(*ts, **ks)
8731 
8732 
def Then(ts, ks)
Definition: z3py.py:8720
def AndThen(ts, ks)
Definition: z3py.py:8700
def z3py.to_Ast (   ptr)

Definition at line 11803 of file z3py.py.

Referenced by on_clause_eh().

11803 def to_Ast(ptr,):
11804  ast = Ast(ptr)
11805  super(ctypes.c_void_p, ast).__init__(ptr)
11806  return ast
11807 
def to_Ast(ptr)
Definition: z3py.py:11803
def z3py.to_AstVectorObj (   ptr)

Definition at line 11813 of file z3py.py.

Referenced by on_clause_eh().

11814  v = AstVectorObj(ptr)
11815  super(ctypes.c_void_p, v).__init__(ptr)
11816  return v
11817 
11818 # NB. my-hacky-class only works for a single instance of OnClause
11819 # it should be replaced with a proper correlation between OnClause
11820 # and object references that can be passed over the FFI.
11821 # for UserPropagator we use a global dictionary, which isn't great code.
11822 
def to_AstVectorObj(ptr)
Definition: z3py.py:11813
def z3py.to_ContextObj (   ptr)

Definition at line 11808 of file z3py.py.

11808 def to_ContextObj(ptr,):
11809  ctx = ContextObj(ptr)
11810  super(ctypes.c_void_p, ctx).__init__(ptr)
11811  return ctx
11812 
def to_ContextObj(ptr)
Definition: z3py.py:11808
def z3py.to_symbol (   s,
  ctx = None 
)
Convert an integer or string into a Z3 symbol.

Definition at line 132 of file z3py.py.

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

132 def to_symbol(s, ctx = None):
133  """Convert an integer or string into a Z3 symbol."""
134  if _is_int(s):
135  return Z3_mk_int_symbol(_get_ctx(ctx).ref(), s)
136  else:
137  return Z3_mk_string_symbol(_get_ctx(ctx).ref(), s)
138 
139 
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:132
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 3538 of file z3py.py.

Referenced by is_to_int().

3538 def ToInt(a):
3539  """ Return the Z3 expression ToInt(a).
3540 
3541  >>> x = Real('x')
3542  >>> x.sort()
3543  Real
3544  >>> n = ToInt(x)
3545  >>> n
3546  ToInt(x)
3547  >>> n.sort()
3548  Int
3549  """
3550  if z3_debug():
3551  _z3_assert(a.is_real(), "Z3 real expression expected.")
3552  ctx = a.ctx
3553  return ArithRef(Z3_mk_real2int(ctx.ref(), a.as_ast()), ctx)
3554 
3555 
Z3_ast Z3_API Z3_mk_real2int(Z3_context c, Z3_ast t1)
Coerce a real to an integer.
def z3_debug()
Definition: z3py.py:70
def ToInt(a)
Definition: z3py.py:3538
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 3518 of file z3py.py.

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

3518 def ToReal(a):
3519  """ Return the Z3 expression ToReal(a).
3520 
3521  >>> x = Int('x')
3522  >>> x.sort()
3523  Int
3524  >>> n = ToReal(x)
3525  >>> n
3526  ToReal(x)
3527  >>> n.sort()
3528  Real
3529  """
3530  ctx = a.ctx
3531  if isinstance(a, BoolRef):
3532  return If(a, RealVal(1, ctx), RealVal(0, ctx))
3533  if z3_debug():
3534  _z3_assert(a.is_int(), "Z3 integer expression expected.")
3535  return ArithRef(Z3_mk_int2real(ctx.ref(), a.as_ast()), ctx)
3536 
3537 
def If
Definition: z3py.py:1484
Z3_ast Z3_API Z3_mk_int2real(Z3_context c, Z3_ast t1)
Coerce an integer to a real.
def ToReal(a)
Definition: z3py.py:3518
def z3_debug()
Definition: z3py.py:70
def RealVal
Definition: z3py.py:3356
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 11796 of file z3py.py.

11797  """Given a binary relation R, such that the two arguments have the same sort
11798  create the transitive closure relation R+.
11799  The transitive closure R+ is a new relation.
11800  """
11801  return FuncDeclRef(Z3_mk_transitive_closure(f.ctx_ref(), f.ast), f.ctx)
11802 
def TransitiveClosure(f)
Definition: z3py.py:11796
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:775
def z3py.TreeOrder (   a,
  index 
)

Definition at line 11788 of file z3py.py.

11788 def TreeOrder(a, index):
11789  return FuncDeclRef(Z3_mk_tree_order(a.ctx_ref(), a.ast, index), a.ctx)
11790 
11791 
Function Declarations.
Definition: z3py.py:775
def TreeOrder(a, index)
Definition: z3py.py:11788
Z3_func_decl Z3_API Z3_mk_tree_order(Z3_context c, Z3_sort a, unsigned id)
create a tree ordering relation 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 8843 of file z3py.py.

8843 def TryFor(t, ms, ctx=None):
8844  """Return a tactic that applies `t` to a given goal for `ms` milliseconds.
8845 
8846  If `t` does not terminate in `ms` milliseconds, then it fails.
8847  """
8848  t = _to_tactic(t, ctx)
8849  return Tactic(Z3_tactic_try_for(t.ctx.ref(), t.tactic, ms), t.ctx)
8850 
8851 
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:8843
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 5592 of file z3py.py.

5592 def TupleSort(name, sorts, ctx=None):
5593  """Create a named tuple sort base on a set of underlying sorts
5594  Example:
5595  >>> pair, mk_pair, (first, second) = TupleSort("pair", [IntSort(), StringSort()])
5596  """
5597  tuple = Datatype(name, ctx)
5598  projects = [("project%d" % i, sorts[i]) for i in range(len(sorts))]
5599  tuple.declare(name, *projects)
5600  tuple = tuple.create()
5601  return tuple, tuple.constructor(0), [tuple.accessor(0, i) for i in range(len(sorts))]
5602 
5603 
def TupleSort
Definition: z3py.py:5592
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:4343
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 4426 of file z3py.py.

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

4426 def UDiv(a, b):
4427  """Create the Z3 expression (unsigned) division `self / other`.
4428 
4429  Use the operator / for signed division.
4430 
4431  >>> x = BitVec('x', 32)
4432  >>> y = BitVec('y', 32)
4433  >>> UDiv(x, y)
4434  UDiv(x, y)
4435  >>> UDiv(x, y).sort()
4436  BitVec(32)
4437  >>> (x / y).sexpr()
4438  '(bvsdiv x y)'
4439  >>> UDiv(x, y).sexpr()
4440  '(bvudiv x y)'
4441  """
4442  _check_bv_args(a, b)
4443  a, b = _coerce_exprs(a, b)
4444  return BitVecRef(Z3_mk_bvudiv(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4445 
4446 
Z3_ast Z3_API Z3_mk_bvudiv(Z3_context c, Z3_ast t1, Z3_ast t2)
Unsigned division.
def UDiv(a, b)
Definition: z3py.py:4426
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 4390 of file z3py.py.

Referenced by BitVecRef.__ge__().

4390 def UGE(a, b):
4391  """Create the Z3 expression (unsigned) `other >= self`.
4392 
4393  Use the operator >= for signed greater than or equal to.
4394 
4395  >>> x, y = BitVecs('x y', 32)
4396  >>> UGE(x, y)
4397  UGE(x, y)
4398  >>> (x >= y).sexpr()
4399  '(bvsge x y)'
4400  >>> UGE(x, y).sexpr()
4401  '(bvuge x y)'
4402  """
4403  _check_bv_args(a, b)
4404  a, b = _coerce_exprs(a, b)
4405  return BoolRef(Z3_mk_bvuge(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4406 
4407 
Z3_ast Z3_API Z3_mk_bvuge(Z3_context c, Z3_ast t1, Z3_ast t2)
Unsigned greater than or equal to.
def UGE(a, b)
Definition: z3py.py:4390
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 4408 of file z3py.py.

Referenced by BitVecRef.__gt__().

4408 def UGT(a, b):
4409  """Create the Z3 expression (unsigned) `other > self`.
4410 
4411  Use the operator > for signed greater than.
4412 
4413  >>> x, y = BitVecs('x y', 32)
4414  >>> UGT(x, y)
4415  UGT(x, y)
4416  >>> (x > y).sexpr()
4417  '(bvsgt x y)'
4418  >>> UGT(x, y).sexpr()
4419  '(bvugt x y)'
4420  """
4421  _check_bv_args(a, b)
4422  a, b = _coerce_exprs(a, b)
4423  return BoolRef(Z3_mk_bvugt(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4424 
4425 
Z3_ast Z3_API Z3_mk_bvugt(Z3_context c, Z3_ast t1, Z3_ast t2)
Unsigned greater than.
def UGT(a, b)
Definition: z3py.py:4408
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 4354 of file z3py.py.

Referenced by BitVecRef.__le__().

4354 def ULE(a, b):
4355  """Create the Z3 expression (unsigned) `other <= self`.
4356 
4357  Use the operator <= for signed less than or equal to.
4358 
4359  >>> x, y = BitVecs('x y', 32)
4360  >>> ULE(x, y)
4361  ULE(x, y)
4362  >>> (x <= y).sexpr()
4363  '(bvsle x y)'
4364  >>> ULE(x, y).sexpr()
4365  '(bvule x y)'
4366  """
4367  _check_bv_args(a, b)
4368  a, b = _coerce_exprs(a, b)
4369  return BoolRef(Z3_mk_bvule(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4370 
4371 
Z3_ast Z3_API Z3_mk_bvule(Z3_context c, Z3_ast t1, Z3_ast t2)
Unsigned less than or equal to.
def ULE(a, b)
Definition: z3py.py:4354
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 4372 of file z3py.py.

Referenced by BitVecRef.__lt__().

4372 def ULT(a, b):
4373  """Create the Z3 expression (unsigned) `other < self`.
4374 
4375  Use the operator < for signed less than.
4376 
4377  >>> x, y = BitVecs('x y', 32)
4378  >>> ULT(x, y)
4379  ULT(x, y)
4380  >>> (x < y).sexpr()
4381  '(bvslt x y)'
4382  >>> ULT(x, y).sexpr()
4383  '(bvult x y)'
4384  """
4385  _check_bv_args(a, b)
4386  a, b = _coerce_exprs(a, b)
4387  return BoolRef(Z3_mk_bvult(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4388 
4389 
def ULT(a, b)
Definition: z3py.py:4372
Z3_ast Z3_API Z3_mk_bvult(Z3_context c, Z3_ast t1, Z3_ast t2)
Unsigned less than.
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 11646 of file z3py.py.

Referenced by InRe().

11646 def Union(*args):
11647  """Create union of regular expressions.
11648  >>> re = Union(Re("a"), Re("b"), Re("c"))
11649  >>> print (simplify(InRe("d", re)))
11650  False
11651  """
11652  args = _get_args(args)
11653  sz = len(args)
11654  if z3_debug():
11655  _z3_assert(sz > 0, "At least one argument expected.")
11656  _z3_assert(all([is_re(a) for a in args]), "All arguments must be regular expressions.")
11657  if sz == 1:
11658  return args[0]
11659  ctx = args[0].ctx
11660  v = (Ast * sz)()
11661  for i in range(sz):
11662  v[i] = args[i].as_ast()
11663  return ReRef(Z3_mk_re_union(ctx.ref(), sz, v), ctx)
11664 
11665 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:4343
def Union(args)
Definition: z3py.py:11646
def is_re(s)
Definition: z3py.py:11628
def z3_debug()
Definition: z3py.py:70
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 11424 of file z3py.py.

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

11424 def Unit(a):
11425  """Create a singleton sequence"""
11426  return SeqRef(Z3_mk_seq_unit(a.ctx_ref(), a.as_ast()), a.ctx)
11427 
11428 
def Unit(a)
Definition: z3py.py:11424
Z3_ast Z3_API Z3_mk_seq_unit(Z3_context c, Z3_ast a)
Create a unit sequence of a.
def z3py.Update (   a,
  args 
)
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 4937 of file z3py.py.

Referenced by Store().

4937 def Update(a, *args):
4938  """Return a Z3 store array expression.
4939 
4940  >>> a = Array('a', IntSort(), IntSort())
4941  >>> i, v = Ints('i v')
4942  >>> s = Update(a, i, v)
4943  >>> s.sort()
4944  Array(Int, Int)
4945  >>> prove(s[i] == v)
4946  proved
4947  >>> j = Int('j')
4948  >>> prove(Implies(i != j, s[j] == a[j]))
4949  proved
4950  """
4951  if z3_debug():
4952  _z3_assert(is_array_sort(a), "First argument must be a Z3 array expression")
4953  args = _get_args(args)
4954  ctx = a.ctx
4955  if len(args) <= 1:
4956  raise Z3Exception("array update requires index and value arguments")
4957  if len(args) == 2:
4958  i = args[0]
4959  v = args[1]
4960  i = a.sort().domain().cast(i)
4961  v = a.sort().range().cast(v)
4962  return _to_expr_ref(Z3_mk_store(ctx.ref(), a.as_ast(), i.as_ast(), v.as_ast()), ctx)
4963  v = a.sort().range().cast(args[-1])
4964  idxs = [a.sort().domain_n(i).cast(args[i]) for i in range(len(args)-1)]
4965  _args, sz = _to_ast_array(idxs)
4966  return _to_expr_ref(Z3_mk_store_n(ctx.ref(), a.as_ast(), sz, _args, v.as_ast()), ctx)
4967 
4968 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:4343
Z3_ast Z3_API Z3_mk_store(Z3_context c, Z3_ast a, Z3_ast i, Z3_ast v)
Array update.
def Update(a, args)
Definition: z3py.py:4937
def is_array_sort(a)
Definition: z3py.py:4797
Z3_ast Z3_API Z3_mk_store_n(Z3_context c, Z3_ast a, unsigned n, Z3_ast const *idxs, Z3_ast v)
n-ary Array update.
def z3_debug()
Definition: z3py.py:70
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 4447 of file z3py.py.

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

4447 def URem(a, b):
4448  """Create the Z3 expression (unsigned) remainder `self % other`.
4449 
4450  Use the operator % for signed modulus, and SRem() for signed remainder.
4451 
4452  >>> x = BitVec('x', 32)
4453  >>> y = BitVec('y', 32)
4454  >>> URem(x, y)
4455  URem(x, y)
4456  >>> URem(x, y).sort()
4457  BitVec(32)
4458  >>> (x % y).sexpr()
4459  '(bvsmod x y)'
4460  >>> URem(x, y).sexpr()
4461  '(bvurem x y)'
4462  """
4463  _check_bv_args(a, b)
4464  a, b = _coerce_exprs(a, b)
4465  return BitVecRef(Z3_mk_bvurem(a.ctx_ref(), a.as_ast(), b.as_ast()), a.ctx)
4466 
4467 
def URem(a, b)
Definition: z3py.py:4447
Z3_ast Z3_API Z3_mk_bvurem(Z3_context c, Z3_ast t1, Z3_ast t2)
Unsigned remainder.
def z3py.user_prop_binding (   ctx,
  cb,
  q_ref,
  inst_ref 
)

Definition at line 11966 of file z3py.py.

11966 def user_prop_binding(ctx, cb, q_ref, inst_ref):
11967  prop = _prop_closures.get(ctx)
11968  old_cb = prop.cb
11969  prop.cb = cb
11970  q = _to_expr_ref(to_Ast(q_ref), prop.ctx())
11971  inst = _to_expr_ref(to_Ast(inst_ref), prop.ctx())
11972  r = prop.binding(q, inst)
11973  prop.cb = old_cb
11974  return r
11975 
11976 
def user_prop_binding(ctx, cb, q_ref, inst_ref)
Definition: z3py.py:11966
def to_Ast(ptr)
Definition: z3py.py:11803
def z3py.user_prop_created (   ctx,
  cb,
  id 
)

Definition at line 11924 of file z3py.py.

11924 def user_prop_created(ctx, cb, id):
11925  prop = _prop_closures.get(ctx)
11926  old_cb = prop.cb
11927  prop.cb = cb
11928  id = _to_expr_ref(to_Ast(id), prop.ctx())
11929  prop.created(id)
11930  prop.cb = old_cb
11931 
11932 
def user_prop_created(ctx, cb, id)
Definition: z3py.py:11924
def to_Ast(ptr)
Definition: z3py.py:11803
def z3py.user_prop_decide (   ctx,
  cb,
  t_ref,
  idx,
  phase 
)

Definition at line 11958 of file z3py.py.

11958 def user_prop_decide(ctx, cb, t_ref, idx, phase):
11959  prop = _prop_closures.get(ctx)
11960  old_cb = prop.cb
11961  prop.cb = cb
11962  t = _to_expr_ref(to_Ast(t_ref), prop.ctx())
11963  prop.decide(t, idx, phase)
11964  prop.cb = old_cb
11965 
def user_prop_decide(ctx, cb, t_ref, idx, phase)
Definition: z3py.py:11958
def to_Ast(ptr)
Definition: z3py.py:11803
def z3py.user_prop_diseq (   ctx,
  cb,
  x,
  y 
)

Definition at line 11949 of file z3py.py.

11949 def user_prop_diseq(ctx, cb, x, y):
11950  prop = _prop_closures.get(ctx)
11951  old_cb = prop.cb
11952  prop.cb = cb
11953  x = _to_expr_ref(to_Ast(x), prop.ctx())
11954  y = _to_expr_ref(to_Ast(y), prop.ctx())
11955  prop.diseq(x, y)
11956  prop.cb = old_cb
11957 
def user_prop_diseq(ctx, cb, x, y)
Definition: z3py.py:11949
def to_Ast(ptr)
Definition: z3py.py:11803
def z3py.user_prop_eq (   ctx,
  cb,
  x,
  y 
)

Definition at line 11940 of file z3py.py.

11940 def user_prop_eq(ctx, cb, x, y):
11941  prop = _prop_closures.get(ctx)
11942  old_cb = prop.cb
11943  prop.cb = cb
11944  x = _to_expr_ref(to_Ast(x), prop.ctx())
11945  y = _to_expr_ref(to_Ast(y), prop.ctx())
11946  prop.eq(x, y)
11947  prop.cb = old_cb
11948 
def user_prop_eq(ctx, cb, x, y)
Definition: z3py.py:11940
def to_Ast(ptr)
Definition: z3py.py:11803
def z3py.user_prop_final (   ctx,
  cb 
)

Definition at line 11933 of file z3py.py.

11933 def user_prop_final(ctx, cb):
11934  prop = _prop_closures.get(ctx)
11935  old_cb = prop.cb
11936  prop.cb = cb
11937  prop.final()
11938  prop.cb = old_cb
11939 
def user_prop_final(ctx, cb)
Definition: z3py.py:11933
def z3py.user_prop_fixed (   ctx,
  cb,
  id,
  value 
)

Definition at line 11915 of file z3py.py.

11915 def user_prop_fixed(ctx, cb, id, value):
11916  prop = _prop_closures.get(ctx)
11917  old_cb = prop.cb
11918  prop.cb = cb
11919  id = _to_expr_ref(to_Ast(id), prop.ctx())
11920  value = _to_expr_ref(to_Ast(value), prop.ctx())
11921  prop.fixed(id, value)
11922  prop.cb = old_cb
11923 
def to_Ast(ptr)
Definition: z3py.py:11803
def user_prop_fixed(ctx, cb, id, value)
Definition: z3py.py:11915
def z3py.user_prop_fresh (   ctx,
  _new_ctx 
)

Definition at line 11901 of file z3py.py.

11901 def user_prop_fresh(ctx, _new_ctx):
11902  _prop_closures.set_threaded()
11903  prop = _prop_closures.get(ctx)
11904  nctx = Context()
11905  Z3_del_context(nctx.ctx)
11906  new_ctx = to_ContextObj(_new_ctx)
11907  nctx.ctx = new_ctx
11908  nctx.eh = Z3_set_error_handler(new_ctx, z3_error_handler)
11909  nctx.owner = False
11910  new_prop = prop.fresh(nctx)
11911  _prop_closures.set(new_prop.id, new_prop)
11912  return new_prop.id
11913 
11914 
void Z3_API Z3_del_context(Z3_context c)
Delete the given logical context.
void Z3_API Z3_set_error_handler(Z3_context c, Z3_error_handler h)
Register a Z3 error handler.
def user_prop_fresh(ctx, _new_ctx)
Definition: z3py.py:11901
def to_ContextObj(ptr)
Definition: z3py.py:11808
def z3py.user_prop_pop (   ctx,
  cb,
  num_scopes 
)

Definition at line 11895 of file z3py.py.

11895 def user_prop_pop(ctx, cb, num_scopes):
11896  prop = _prop_closures.get(ctx)
11897  prop.cb = cb
11898  prop.pop(num_scopes)
11899 
11900 
def user_prop_pop(ctx, cb, num_scopes)
Definition: z3py.py:11895
def z3py.user_prop_push (   ctx,
  cb 
)

Definition at line 11889 of file z3py.py.

11889 def user_prop_push(ctx, cb):
11890  prop = _prop_closures.get(ctx)
11891  prop.cb = cb
11892  prop.push()
11893 
11894 
def user_prop_push(ctx, cb)
Definition: z3py.py:11889
def z3py.Var (   idx)

Definition at line 1575 of file z3py.py.

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

1575 def Var(idx : int, s : SortRef) -> ExprRef:
1576  """Create a Z3 free variable. Free variables are used to create quantified formulas.
1577  A free variable with index n is bound when it occurs within the scope of n+1 quantified
1578  declarations.
1579 
1580  >>> Var(0, IntSort())
1581  Var(0)
1582  >>> eq(Var(0, IntSort()), Var(0, BoolSort()))
1583  False
1584  """
1585  if z3_debug():
1586  _z3_assert(is_sort(s), "Z3 sort expected")
1587  return _to_expr_ref(Z3_mk_bound(s.ctx_ref(), idx, s.ast), s.ctx)
1588 
1589 
Z3_ast Z3_API Z3_mk_bound(Z3_context c, unsigned index, Z3_sort ty)
Create a variable.
def z3_debug()
Definition: z3py.py:70
def Var
Definition: z3py.py:1575
def is_sort
Definition: z3py.py:682
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 9137 of file z3py.py.

9137 def When(p, t, ctx=None):
9138  """Return a tactic that applies tactic `t` only if probe `p` evaluates to true.
9139  Otherwise, it returns the input goal unmodified.
9140 
9141  >>> t = When(Probe('size') > 2, Tactic('simplify'))
9142  >>> x, y = Ints('x y')
9143  >>> g = Goal()
9144  >>> g.add(x > 0)
9145  >>> g.add(y > 0)
9146  >>> t(g)
9147  [[x > 0, y > 0]]
9148  >>> g.add(x == y + 1)
9149  >>> t(g)
9150  [[Not(x <= 0), Not(y <= 0), x == 1 + y]]
9151  """
9152  p = _to_probe(p, ctx)
9153  t = _to_tactic(t, ctx)
9154  return Tactic(Z3_tactic_when(t.ctx.ref(), p.probe, t.tactic), t.ctx)
9155 
9156 
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:9137
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 8794 of file z3py.py.

Referenced by Goal.prec().

8794 def With(t, *args, **keys):
8795  """Return a tactic that applies tactic `t` using the given configuration options.
8796 
8797  >>> x, y = Ints('x y')
8798  >>> t = With(Tactic('simplify'), som=True)
8799  >>> t((x + 1)*(y + 2) == 0)
8800  [[2*x + y + x*y == -2]]
8801  """
8802  ctx = keys.pop("ctx", None)
8803  t = _to_tactic(t, ctx)
8804  p = args2params(args, keys, t.ctx)
8805  return Tactic(Z3_tactic_using_params(t.ctx.ref(), t.tactic, p.params), t.ctx)
8806 
8807 
def args2params
Definition: z3py.py:5695
Z3_tactic Z3_API Z3_tactic_using_params(Z3_context c, Z3_tactic t, Z3_params p)
Return a tactic that applies t using the given set of parameters.
def With(t, args, keys)
Definition: z3py.py:8794
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 8808 of file z3py.py.

8808 def WithParams(t, p):
8809  """Return a tactic that applies tactic `t` using the given configuration options.
8810 
8811  >>> x, y = Ints('x y')
8812  >>> p = ParamsRef()
8813  >>> p.set("som", True)
8814  >>> t = WithParams(Tactic('simplify'), p)
8815  >>> t((x + 1)*(y + 2) == 0)
8816  [[2*x + y + x*y == -2]]
8817  """
8818  t = _to_tactic(t, None)
8819  return Tactic(Z3_tactic_using_params(t.ctx.ref(), t.tactic, p.params), t.ctx)
8820 
8821 
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(t, p)
Definition: z3py.py:8808
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 1932 of file z3py.py.

Referenced by BoolRef.__xor__().

1932 def Xor(a, b, ctx=None):
1933  """Create a Z3 Xor expression.
1934 
1935  >>> p, q = Bools('p q')
1936  >>> Xor(p, q)
1937  Xor(p, q)
1938  >>> simplify(Xor(p, q))
1939  Not(p == q)
1940  """
1941  ctx = _get_ctx(_ctx_from_ast_arg_list([a, b], ctx))
1942  s = BoolSort(ctx)
1943  a = s.cast(a)
1944  b = s.cast(b)
1945  return BoolRef(Z3_mk_xor(ctx.ref(), a.as_ast(), b.as_ast()), ctx)
1946 
1947 
def BoolSort
Definition: z3py.py:1824
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:1932
def z3py.z3_debug ( )
def z3py.z3_error_handler (   c,
  e 
)

Definition at line 184 of file z3py.py.

185  # Do nothing error handler, just avoid exit(0)
186  # The wrappers in z3core.py will raise a Z3Exception if an error is detected
187  return
188 
189 
def z3_error_handler(c, e)
Definition: z3py.py:184
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 4583 of file z3py.py.

4583 def ZeroExt(n, a):
4584  """Return a bit-vector expression with `n` extra zero-bits.
4585 
4586  >>> x = BitVec('x', 16)
4587  >>> n = ZeroExt(8, x)
4588  >>> n.size()
4589  24
4590  >>> n
4591  ZeroExt(8, x)
4592  >>> n.sort()
4593  BitVec(24)
4594  >>> v0 = BitVecVal(2, 2)
4595  >>> v0
4596  2
4597  >>> v0.size()
4598  2
4599  >>> v = simplify(ZeroExt(6, v0))
4600  >>> v
4601  2
4602  >>> v.size()
4603  8
4604  """
4605  if z3_debug():
4606  _z3_assert(_is_int(n), "First argument must be an integer")
4607  _z3_assert(is_bv(a), "Second argument must be a Z3 bit-vector expression")
4608  return BitVecRef(Z3_mk_zero_ext(a.ctx_ref(), n, a.as_ast()), a.ctx)
4609 
4610 
def ZeroExt(n, a)
Definition: z3py.py:4583
def z3_debug()
Definition: z3py.py:70
def is_bv(a)
Definition: z3py.py:4111
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 9689 of file z3py.py.

int _dflt_fpsort_sbits = 53

Definition at line 9690 of file z3py.py.

_dflt_rounding_mode = Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN

Floating-Point Arithmetic.

Definition at line 9688 of file z3py.py.

_main_ctx = None

Definition at line 263 of file z3py.py.

_my_hacky_class = None

Definition at line 11823 of file z3py.py.

tuple _on_clause_eh = Z3_on_clause_eh(on_clause_eh)

Definition at line 11831 of file z3py.py.

tuple _on_model_eh = on_model_eh_type(_global_on_model)

Definition at line 8191 of file z3py.py.

dictionary _on_models = {}

Definition at line 8183 of file z3py.py.

_prop_closures = None

Definition at line 11880 of file z3py.py.

tuple _ROUNDING_MODES
Initial value:
1 = frozenset({
2  Z3_OP_FPA_RM_TOWARD_ZERO,
3  Z3_OP_FPA_RM_TOWARD_NEGATIVE,
4  Z3_OP_FPA_RM_TOWARD_POSITIVE,
5  Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN,
6  Z3_OP_FPA_RM_NEAREST_TIES_TO_AWAY
7 })

Definition at line 9708 of file z3py.py.

tuple _user_prop_binding = Z3_on_binding_eh(user_prop_binding)

Definition at line 11986 of file z3py.py.

tuple _user_prop_created = Z3_created_eh(user_prop_created)

Definition at line 11981 of file z3py.py.

tuple _user_prop_decide = Z3_decide_eh(user_prop_decide)

Definition at line 11985 of file z3py.py.

tuple _user_prop_diseq = Z3_eq_eh(user_prop_diseq)

Definition at line 11984 of file z3py.py.

tuple _user_prop_eq = Z3_eq_eh(user_prop_eq)

Definition at line 11983 of file z3py.py.

tuple _user_prop_final = Z3_final_eh(user_prop_final)

Definition at line 11982 of file z3py.py.

tuple _user_prop_fixed = Z3_fixed_eh(user_prop_fixed)

Definition at line 11980 of file z3py.py.

tuple _user_prop_fresh = Z3_fresh_eh(user_prop_fresh)

Definition at line 11979 of file z3py.py.

tuple _user_prop_pop = Z3_pop_eh(user_prop_pop)

Definition at line 11978 of file z3py.py.

tuple _user_prop_push = Z3_push_eh(user_prop_push)

Definition at line 11977 of file z3py.py.

tuple sat = CheckSatResult(Z3_L_TRUE)

Definition at line 7154 of file z3py.py.

tuple unknown = CheckSatResult(Z3_L_UNDEF)

Definition at line 7156 of file z3py.py.

tuple unsat = CheckSatResult(Z3_L_FALSE)

Definition at line 7155 of file z3py.py.

Z3_DEBUG = __debug__

Definition at line 67 of file z3py.py.