Z3
Public Member Functions
ArithRef Class Reference
+ Inheritance diagram for ArithRef:

Public Member Functions

def sort (self)
 
def is_int (self)
 
def is_real (self)
 
def __add__ (self, other)
 
def __radd__ (self, other)
 
def __mul__ (self, other)
 
def __rmul__ (self, other)
 
def __sub__ (self, other)
 
def __rsub__ (self, other)
 
def __pow__ (self, other)
 
def __rpow__ (self, other)
 
def __div__ (self, other)
 
def __truediv__ (self, other)
 
def __rdiv__ (self, other)
 
def __rtruediv__ (self, other)
 
def __mod__ (self, other)
 
def __rmod__ (self, other)
 
def __neg__ (self)
 
def __pos__ (self)
 
def __le__ (self, other)
 
def __lt__ (self, other)
 
def __gt__ (self, other)
 
def __ge__ (self, other)
 
- Public Member Functions inherited from ExprRef
def as_ast (self)
 
def get_id (self)
 
def sort (self)
 
def sort_kind (self)
 
def __eq__ (self, other)
 
def __ne__ (self, other)
 
def decl (self)
 
def num_args (self)
 
def arg (self, idx)
 
def children (self)
 
- Public Member Functions inherited from AstRef
def __init__ (self, ast, ctx=None)
 
def __del__ (self)
 
def __str__ (self)
 
def __repr__ (self)
 
def sexpr (self)
 
def as_ast (self)
 
def get_id (self)
 
def ctx_ref (self)
 
def eq (self, other)
 
def translate (self, target)
 
def hash (self)
 
- Public Member Functions inherited from Z3PPObject
def use_pp (self)
 

Additional Inherited Members

- Data Fields inherited from AstRef
 ast
 
 ctx
 

Detailed Description

Integer and Real expressions.

Definition at line 1942 of file z3py.py.

Member Function Documentation

def __add__ (   self,
  other 
)
Create the Z3 expression `self + other`.

>>> x = Int('x')
>>> y = Int('y')
>>> x + y
x + y
>>> (x + y).sort()
Int

Definition at line 1980 of file z3py.py.

1980  def __add__(self, other):
1981  """Create the Z3 expression `self + other`.
1982 
1983  >>> x = Int('x')
1984  >>> y = Int('y')
1985  >>> x + y
1986  x + y
1987  >>> (x + y).sort()
1988  Int
1989  """
1990  a, b = _coerce_exprs(self, other)
1991  return ArithRef(_mk_bin(Z3_mk_add, a, b), self.ctx)
1992 
def __add__(self, other)
Definition: z3py.py:1980
def __div__ (   self,
  other 
)
Create the Z3 expression `other/self`.

>>> x = Int('x')
>>> y = Int('y')
>>> x/y
x/y
>>> (x/y).sort()
Int
>>> (x/y).sexpr()
'(div x y)'
>>> x = Real('x')
>>> y = Real('y')
>>> x/y
x/y
>>> (x/y).sort()
Real
>>> (x/y).sexpr()
'(/ x y)'

Definition at line 2077 of file z3py.py.

2077  def __div__(self, other):
2078  """Create the Z3 expression `other/self`.
2079 
2080  >>> x = Int('x')
2081  >>> y = Int('y')
2082  >>> x/y
2083  x/y
2084  >>> (x/y).sort()
2085  Int
2086  >>> (x/y).sexpr()
2087  '(div x y)'
2088  >>> x = Real('x')
2089  >>> y = Real('y')
2090  >>> x/y
2091  x/y
2092  >>> (x/y).sort()
2093  Real
2094  >>> (x/y).sexpr()
2095  '(/ x y)'
2096  """
2097  a, b = _coerce_exprs(self, other)
2098  return ArithRef(Z3_mk_div(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
2099 
Z3_ast Z3_API Z3_mk_div(Z3_context c, Z3_ast arg1, Z3_ast arg2)
Create an AST node representing arg1 div arg2.The arguments must either both have int type or both ha...
def ctx_ref(self)
Definition: z3py.py:304
def __div__(self, other)
Definition: z3py.py:2077
def __ge__ (   self,
  other 
)
Create the Z3 expression `other >= self`.

>>> x, y = Ints('x y')
>>> x >= y
x >= y
>>> y = Real('y')
>>> x >= y
ToReal(x) >= y

Definition at line 2211 of file z3py.py.

2211  def __ge__(self, other):
2212  """Create the Z3 expression `other >= self`.
2213 
2214  >>> x, y = Ints('x y')
2215  >>> x >= y
2216  x >= y
2217  >>> y = Real('y')
2218  >>> x >= y
2219  ToReal(x) >= y
2220  """
2221  a, b = _coerce_exprs(self, other)
2222  return BoolRef(Z3_mk_ge(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
2223 
Z3_ast Z3_API Z3_mk_ge(Z3_context c, Z3_ast t1, Z3_ast t2)
Create greater than or equal to.
def __ge__(self, other)
Definition: z3py.py:2211
def ctx_ref(self)
Definition: z3py.py:304
def __gt__ (   self,
  other 
)
Create the Z3 expression `other > self`.

>>> x, y = Ints('x y')
>>> x > y
x > y
>>> y = Real('y')
>>> x > y
ToReal(x) > y

Definition at line 2198 of file z3py.py.

2198  def __gt__(self, other):
2199  """Create the Z3 expression `other > self`.
2200 
2201  >>> x, y = Ints('x y')
2202  >>> x > y
2203  x > y
2204  >>> y = Real('y')
2205  >>> x > y
2206  ToReal(x) > y
2207  """
2208  a, b = _coerce_exprs(self, other)
2209  return BoolRef(Z3_mk_gt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
2210 
def __gt__(self, other)
Definition: z3py.py:2198
Z3_ast Z3_API Z3_mk_gt(Z3_context c, Z3_ast t1, Z3_ast t2)
Create greater than.
def ctx_ref(self)
Definition: z3py.py:304
def __le__ (   self,
  other 
)
Create the Z3 expression `other <= self`.

>>> x, y = Ints('x y')
>>> x <= y
x <= y
>>> y = Real('y')
>>> x <= y
ToReal(x) <= y

Definition at line 2172 of file z3py.py.

2172  def __le__(self, other):
2173  """Create the Z3 expression `other <= self`.
2174 
2175  >>> x, y = Ints('x y')
2176  >>> x <= y
2177  x <= y
2178  >>> y = Real('y')
2179  >>> x <= y
2180  ToReal(x) <= y
2181  """
2182  a, b = _coerce_exprs(self, other)
2183  return BoolRef(Z3_mk_le(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
2184 
Z3_ast Z3_API Z3_mk_le(Z3_context c, Z3_ast t1, Z3_ast t2)
Create less than or equal to.
def __le__(self, other)
Definition: z3py.py:2172
def ctx_ref(self)
Definition: z3py.py:304
def __lt__ (   self,
  other 
)
Create the Z3 expression `other < self`.

>>> x, y = Ints('x y')
>>> x < y
x < y
>>> y = Real('y')
>>> x < y
ToReal(x) < y

Definition at line 2185 of file z3py.py.

2185  def __lt__(self, other):
2186  """Create the Z3 expression `other < self`.
2187 
2188  >>> x, y = Ints('x y')
2189  >>> x < y
2190  x < y
2191  >>> y = Real('y')
2192  >>> x < y
2193  ToReal(x) < y
2194  """
2195  a, b = _coerce_exprs(self, other)
2196  return BoolRef(Z3_mk_lt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
2197 
def __lt__(self, other)
Definition: z3py.py:2185
Z3_ast Z3_API Z3_mk_lt(Z3_context c, Z3_ast t1, Z3_ast t2)
Create less than.
def ctx_ref(self)
Definition: z3py.py:304
def __mod__ (   self,
  other 
)
Create the Z3 expression `other%self`.

>>> x = Int('x')
>>> y = Int('y')
>>> x % y
x%y
>>> simplify(IntVal(10) % IntVal(3))
1

Definition at line 2125 of file z3py.py.

2125  def __mod__(self, other):
2126  """Create the Z3 expression `other%self`.
2127 
2128  >>> x = Int('x')
2129  >>> y = Int('y')
2130  >>> x % y
2131  x%y
2132  >>> simplify(IntVal(10) % IntVal(3))
2133  1
2134  """
2135  a, b = _coerce_exprs(self, other)
2136  if __debug__:
2137  _z3_assert(a.is_int(), "Z3 integer expression expected")
2138  return ArithRef(Z3_mk_mod(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
2139 
Z3_ast Z3_API Z3_mk_mod(Z3_context c, Z3_ast arg1, Z3_ast arg2)
Create an AST node representing arg1 mod arg2.The arguments must have int type.
def __mod__(self, other)
Definition: z3py.py:2125
def ctx_ref(self)
Definition: z3py.py:304
def __mul__ (   self,
  other 
)
Create the Z3 expression `self * other`.

>>> x = Real('x')
>>> y = Real('y')
>>> x * y
x*y
>>> (x * y).sort()
Real

Definition at line 2003 of file z3py.py.

2003  def __mul__(self, other):
2004  """Create the Z3 expression `self * other`.
2005 
2006  >>> x = Real('x')
2007  >>> y = Real('y')
2008  >>> x * y
2009  x*y
2010  >>> (x * y).sort()
2011  Real
2012  """
2013  a, b = _coerce_exprs(self, other)
2014  return ArithRef(_mk_bin(Z3_mk_mul, a, b), self.ctx)
2015 
def __mul__(self, other)
Definition: z3py.py:2003
def __neg__ (   self)
Return an expression representing `-self`.

>>> x = Int('x')
>>> -x
-x
>>> simplify(-(-x))
x

Definition at line 2152 of file z3py.py.

2152  def __neg__(self):
2153  """Return an expression representing `-self`.
2154 
2155  >>> x = Int('x')
2156  >>> -x
2157  -x
2158  >>> simplify(-(-x))
2159  x
2160  """
2161  return ArithRef(Z3_mk_unary_minus(self.ctx_ref(), self.as_ast()), self.ctx)
2162 
Z3_ast Z3_API Z3_mk_unary_minus(Z3_context c, Z3_ast arg)
Create an AST node representing -arg.The arguments must have int or real type.
def as_ast(self)
Definition: z3py.py:296
def __neg__(self)
Definition: z3py.py:2152
def ctx_ref(self)
Definition: z3py.py:304
def __pos__ (   self)
Return `self`.

>>> x = Int('x')
>>> +x
x

Definition at line 2163 of file z3py.py.

2163  def __pos__(self):
2164  """Return `self`.
2165 
2166  >>> x = Int('x')
2167  >>> +x
2168  x
2169  """
2170  return self
2171 
def __pos__(self)
Definition: z3py.py:2163
def __pow__ (   self,
  other 
)
Create the Z3 expression `self**other` (** is the power operator).

>>> x = Real('x')
>>> x**3
x**3
>>> (x**3).sort()
Real
>>> simplify(IntVal(2)**8)
256

Definition at line 2049 of file z3py.py.

2049  def __pow__(self, other):
2050  """Create the Z3 expression `self**other` (** is the power operator).
2051 
2052  >>> x = Real('x')
2053  >>> x**3
2054  x**3
2055  >>> (x**3).sort()
2056  Real
2057  >>> simplify(IntVal(2)**8)
2058  256
2059  """
2060  a, b = _coerce_exprs(self, other)
2061  return ArithRef(Z3_mk_power(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
2062 
def __pow__(self, other)
Definition: z3py.py:2049
Z3_ast Z3_API Z3_mk_power(Z3_context c, Z3_ast arg1, Z3_ast arg2)
Create an AST node representing arg1^arg2.
def ctx_ref(self)
Definition: z3py.py:304
def __radd__ (   self,
  other 
)
Create the Z3 expression `other + self`.

>>> x = Int('x')
>>> 10 + x
10 + x

Definition at line 1993 of file z3py.py.

1993  def __radd__(self, other):
1994  """Create the Z3 expression `other + self`.
1995 
1996  >>> x = Int('x')
1997  >>> 10 + x
1998  10 + x
1999  """
2000  a, b = _coerce_exprs(self, other)
2001  return ArithRef(_mk_bin(Z3_mk_add, b, a), self.ctx)
2002 
def __radd__(self, other)
Definition: z3py.py:1993
def __rdiv__ (   self,
  other 
)
Create the Z3 expression `other/self`.

>>> x = Int('x')
>>> 10/x
10/x
>>> (10/x).sexpr()
'(div 10 x)'
>>> x = Real('x')
>>> 10/x
10/x
>>> (10/x).sexpr()
'(/ 10.0 x)'

Definition at line 2104 of file z3py.py.

2104  def __rdiv__(self, other):
2105  """Create the Z3 expression `other/self`.
2106 
2107  >>> x = Int('x')
2108  >>> 10/x
2109  10/x
2110  >>> (10/x).sexpr()
2111  '(div 10 x)'
2112  >>> x = Real('x')
2113  >>> 10/x
2114  10/x
2115  >>> (10/x).sexpr()
2116  '(/ 10.0 x)'
2117  """
2118  a, b = _coerce_exprs(self, other)
2119  return ArithRef(Z3_mk_div(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
2120 
def __rdiv__(self, other)
Definition: z3py.py:2104
Z3_ast Z3_API Z3_mk_div(Z3_context c, Z3_ast arg1, Z3_ast arg2)
Create an AST node representing arg1 div arg2.The arguments must either both have int type or both ha...
def ctx_ref(self)
Definition: z3py.py:304
def __rmod__ (   self,
  other 
)
Create the Z3 expression `other%self`.

>>> x = Int('x')
>>> 10 % x
10%x

Definition at line 2140 of file z3py.py.

2140  def __rmod__(self, other):
2141  """Create the Z3 expression `other%self`.
2142 
2143  >>> x = Int('x')
2144  >>> 10 % x
2145  10%x
2146  """
2147  a, b = _coerce_exprs(self, other)
2148  if __debug__:
2149  _z3_assert(a.is_int(), "Z3 integer expression expected")
2150  return ArithRef(Z3_mk_mod(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
2151 
Z3_ast Z3_API Z3_mk_mod(Z3_context c, Z3_ast arg1, Z3_ast arg2)
Create an AST node representing arg1 mod arg2.The arguments must have int type.
def __rmod__(self, other)
Definition: z3py.py:2140
def ctx_ref(self)
Definition: z3py.py:304
def __rmul__ (   self,
  other 
)
Create the Z3 expression `other * self`.

>>> x = Real('x')
>>> 10 * x
10*x

Definition at line 2016 of file z3py.py.

2016  def __rmul__(self, other):
2017  """Create the Z3 expression `other * self`.
2018 
2019  >>> x = Real('x')
2020  >>> 10 * x
2021  10*x
2022  """
2023  a, b = _coerce_exprs(self, other)
2024  return ArithRef(_mk_bin(Z3_mk_mul, b, a), self.ctx)
2025 
def __rmul__(self, other)
Definition: z3py.py:2016
def __rpow__ (   self,
  other 
)
Create the Z3 expression `other**self` (** is the power operator).

>>> x = Real('x')
>>> 2**x
2**x
>>> (2**x).sort()
Real
>>> simplify(2**IntVal(8))
256

Definition at line 2063 of file z3py.py.

2063  def __rpow__(self, other):
2064  """Create the Z3 expression `other**self` (** is the power operator).
2065 
2066  >>> x = Real('x')
2067  >>> 2**x
2068  2**x
2069  >>> (2**x).sort()
2070  Real
2071  >>> simplify(2**IntVal(8))
2072  256
2073  """
2074  a, b = _coerce_exprs(self, other)
2075  return ArithRef(Z3_mk_power(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
2076 
Z3_ast Z3_API Z3_mk_power(Z3_context c, Z3_ast arg1, Z3_ast arg2)
Create an AST node representing arg1^arg2.
def ctx_ref(self)
Definition: z3py.py:304
def __rpow__(self, other)
Definition: z3py.py:2063
def __rsub__ (   self,
  other 
)
Create the Z3 expression `other - self`.

>>> x = Int('x')
>>> 10 - x
10 - x

Definition at line 2039 of file z3py.py.

2039  def __rsub__(self, other):
2040  """Create the Z3 expression `other - self`.
2041 
2042  >>> x = Int('x')
2043  >>> 10 - x
2044  10 - x
2045  """
2046  a, b = _coerce_exprs(self, other)
2047  return ArithRef(_mk_bin(Z3_mk_sub, b, a), self.ctx)
2048 
def __rsub__(self, other)
Definition: z3py.py:2039
def __rtruediv__ (   self,
  other 
)
Create the Z3 expression `other/self`.

Definition at line 2121 of file z3py.py.

2121  def __rtruediv__(self, other):
2122  """Create the Z3 expression `other/self`."""
2123  return self.__rdiv__(other)
2124 
def __rdiv__(self, other)
Definition: z3py.py:2104
def __rtruediv__(self, other)
Definition: z3py.py:2121
def __sub__ (   self,
  other 
)
Create the Z3 expression `self - other`.

>>> x = Int('x')
>>> y = Int('y')
>>> x - y
x - y
>>> (x - y).sort()
Int

Definition at line 2026 of file z3py.py.

2026  def __sub__(self, other):
2027  """Create the Z3 expression `self - other`.
2028 
2029  >>> x = Int('x')
2030  >>> y = Int('y')
2031  >>> x - y
2032  x - y
2033  >>> (x - y).sort()
2034  Int
2035  """
2036  a, b = _coerce_exprs(self, other)
2037  return ArithRef(_mk_bin(Z3_mk_sub, a, b), self.ctx)
2038 
def __sub__(self, other)
Definition: z3py.py:2026
def __truediv__ (   self,
  other 
)
Create the Z3 expression `other/self`.

Definition at line 2100 of file z3py.py.

2100  def __truediv__(self, other):
2101  """Create the Z3 expression `other/self`."""
2102  return self.__div__(other)
2103 
def __truediv__(self, other)
Definition: z3py.py:2100
def __div__(self, other)
Definition: z3py.py:2077
def is_int (   self)
Return `True` if `self` is an integer expression.

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

Definition at line 1955 of file z3py.py.

1955  def is_int(self):
1956  """Return `True` if `self` is an integer expression.
1957 
1958  >>> x = Int('x')
1959  >>> x.is_int()
1960  True
1961  >>> (x + 1).is_int()
1962  True
1963  >>> y = Real('y')
1964  >>> (x + y).is_int()
1965  False
1966  """
1967  return self.sort().is_int()
1968 
def is_int(self)
Definition: z3py.py:1955
def sort(self)
Definition: z3py.py:752
def is_real (   self)
Return `True` if `self` is an real expression.

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

Definition at line 1969 of file z3py.py.

1969  def is_real(self):
1970  """Return `True` if `self` is an real expression.
1971 
1972  >>> x = Real('x')
1973  >>> x.is_real()
1974  True
1975  >>> (x + 1).is_real()
1976  True
1977  """
1978  return self.sort().is_real()
1979 
def is_real(self)
Definition: z3py.py:1969
def sort(self)
Definition: z3py.py:752
def sort (   self)
Return the sort (type) of the arithmetical expression `self`.

>>> Int('x').sort()
Int
>>> (Real('x') + 1).sort()
Real

Definition at line 1945 of file z3py.py.

Referenced by ArithRef.__add__(), ArithRef.__div__(), ArithRef.__mul__(), ArithRef.__pow__(), ArithRef.__rpow__(), and ArithRef.__sub__().

1945  def sort(self):
1946  """Return the sort (type) of the arithmetical expression `self`.
1947 
1948  >>> Int('x').sort()
1949  Int
1950  >>> (Real('x') + 1).sort()
1951  Real
1952  """
1953  return ArithSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
1954 
def as_ast(self)
Definition: z3py.py:296
Arithmetic.
Definition: z3py.py:1856
def sort(self)
Definition: z3py.py:1945
def ctx_ref(self)
Definition: z3py.py:304
Z3_sort Z3_API Z3_get_sort(Z3_context c, Z3_ast a)
Return the sort of an AST node.