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__
 
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 1928 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 1966 of file z3py.py.

1966  def __add__(self, other):
1967  """Create the Z3 expression `self + other`.
1968 
1969  >>> x = Int('x')
1970  >>> y = Int('y')
1971  >>> x + y
1972  x + y
1973  >>> (x + y).sort()
1974  Int
1975  """
1976  a, b = _coerce_exprs(self, other)
1977  return ArithRef(_mk_bin(Z3_mk_add, a, b), self.ctx)
1978 
def __add__(self, other)
Definition: z3py.py:1966
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 2063 of file z3py.py.

2063  def __div__(self, other):
2064  """Create the Z3 expression `other/self`.
2065 
2066  >>> x = Int('x')
2067  >>> y = Int('y')
2068  >>> x/y
2069  x/y
2070  >>> (x/y).sort()
2071  Int
2072  >>> (x/y).sexpr()
2073  '(div x y)'
2074  >>> x = Real('x')
2075  >>> y = Real('y')
2076  >>> x/y
2077  x/y
2078  >>> (x/y).sort()
2079  Real
2080  >>> (x/y).sexpr()
2081  '(/ x y)'
2082  """
2083  a, b = _coerce_exprs(self, other)
2084  return ArithRef(Z3_mk_div(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
2085 
Z3_ast Z3_API Z3_mk_div(__in Z3_context c, __in Z3_ast arg1, __in 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:305
def __div__(self, other)
Definition: z3py.py:2063
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 2197 of file z3py.py.

2197  def __ge__(self, other):
2198  """Create the Z3 expression `other >= self`.
2199 
2200  >>> x, y = Ints('x y')
2201  >>> x >= y
2202  x >= y
2203  >>> y = Real('y')
2204  >>> x >= y
2205  ToReal(x) >= y
2206  """
2207  a, b = _coerce_exprs(self, other)
2208  return BoolRef(Z3_mk_ge(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
2209 
Z3_ast Z3_API Z3_mk_ge(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Create greater than or equal to.
def __ge__(self, other)
Definition: z3py.py:2197
def ctx_ref(self)
Definition: z3py.py:305
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 2184 of file z3py.py.

2184  def __gt__(self, other):
2185  """Create the Z3 expression `other > self`.
2186 
2187  >>> x, y = Ints('x y')
2188  >>> x > y
2189  x > y
2190  >>> y = Real('y')
2191  >>> x > y
2192  ToReal(x) > y
2193  """
2194  a, b = _coerce_exprs(self, other)
2195  return BoolRef(Z3_mk_gt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
2196 
Z3_ast Z3_API Z3_mk_gt(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Create greater than.
def __gt__(self, other)
Definition: z3py.py:2184
def ctx_ref(self)
Definition: z3py.py:305
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 2158 of file z3py.py.

2158  def __le__(self, other):
2159  """Create the Z3 expression `other <= self`.
2160 
2161  >>> x, y = Ints('x y')
2162  >>> x <= y
2163  x <= y
2164  >>> y = Real('y')
2165  >>> x <= y
2166  ToReal(x) <= y
2167  """
2168  a, b = _coerce_exprs(self, other)
2169  return BoolRef(Z3_mk_le(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
2170 
def __le__(self, other)
Definition: z3py.py:2158
def ctx_ref(self)
Definition: z3py.py:305
Z3_ast Z3_API Z3_mk_le(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Create less than or equal to.
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 2171 of file z3py.py.

2171  def __lt__(self, other):
2172  """Create the Z3 expression `other < self`.
2173 
2174  >>> x, y = Ints('x y')
2175  >>> x < y
2176  x < y
2177  >>> y = Real('y')
2178  >>> x < y
2179  ToReal(x) < y
2180  """
2181  a, b = _coerce_exprs(self, other)
2182  return BoolRef(Z3_mk_lt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
2183 
def __lt__(self, other)
Definition: z3py.py:2171
Z3_ast Z3_API Z3_mk_lt(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Create less than.
def ctx_ref(self)
Definition: z3py.py:305
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 2111 of file z3py.py.

2111  def __mod__(self, other):
2112  """Create the Z3 expression `other%self`.
2113 
2114  >>> x = Int('x')
2115  >>> y = Int('y')
2116  >>> x % y
2117  x%y
2118  >>> simplify(IntVal(10) % IntVal(3))
2119  1
2120  """
2121  a, b = _coerce_exprs(self, other)
2122  if __debug__:
2123  _z3_assert(a.is_int(), "Z3 integer expression expected")
2124  return ArithRef(Z3_mk_mod(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
2125 
Z3_ast Z3_API Z3_mk_mod(__in Z3_context c, __in Z3_ast arg1, __in Z3_ast arg2)
Create an AST node representing arg1 mod arg2.The arguments must have int type.
def __mod__(self, other)
Definition: z3py.py:2111
def ctx_ref(self)
Definition: z3py.py:305
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 1989 of file z3py.py.

1989  def __mul__(self, other):
1990  """Create the Z3 expression `self * other`.
1991 
1992  >>> x = Real('x')
1993  >>> y = Real('y')
1994  >>> x * y
1995  x*y
1996  >>> (x * y).sort()
1997  Real
1998  """
1999  a, b = _coerce_exprs(self, other)
2000  return ArithRef(_mk_bin(Z3_mk_mul, a, b), self.ctx)
2001 
def __mul__(self, other)
Definition: z3py.py:1989
def __neg__ (   self)
Return an expression representing `-self`.

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

Definition at line 2138 of file z3py.py.

2138  def __neg__(self):
2139  """Return an expression representing `-self`.
2140 
2141  >>> x = Int('x')
2142  >>> -x
2143  -x
2144  >>> simplify(-(-x))
2145  x
2146  """
2147  return ArithRef(Z3_mk_unary_minus(self.ctx_ref(), self.as_ast()), self.ctx)
2148 
def as_ast(self)
Definition: z3py.py:296
def __neg__(self)
Definition: z3py.py:2138
Z3_ast Z3_API Z3_mk_unary_minus(__in Z3_context c, __in Z3_ast arg)
Create an AST node representing -arg.The arguments must have int or real type.
def ctx_ref(self)
Definition: z3py.py:305
def __pos__ (   self)
Return `self`.

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

Definition at line 2149 of file z3py.py.

2149  def __pos__(self):
2150  """Return `self`.
2151 
2152  >>> x = Int('x')
2153  >>> +x
2154  x
2155  """
2156  return self
2157 
def __pos__(self)
Definition: z3py.py:2149
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 2035 of file z3py.py.

2035  def __pow__(self, other):
2036  """Create the Z3 expression `self**other` (** is the power operator).
2037 
2038  >>> x = Real('x')
2039  >>> x**3
2040  x**3
2041  >>> (x**3).sort()
2042  Real
2043  >>> simplify(IntVal(2)**8)
2044  256
2045  """
2046  a, b = _coerce_exprs(self, other)
2047  return ArithRef(Z3_mk_power(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
2048 
Z3_ast Z3_API Z3_mk_power(__in Z3_context c, __in Z3_ast arg1, __in Z3_ast arg2)
Create an AST node representing arg1^arg2.
def __pow__(self, other)
Definition: z3py.py:2035
def ctx_ref(self)
Definition: z3py.py:305
def __radd__ (   self,
  other 
)
Create the Z3 expression `other + self`.

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

Definition at line 1979 of file z3py.py.

1979  def __radd__(self, other):
1980  """Create the Z3 expression `other + self`.
1981 
1982  >>> x = Int('x')
1983  >>> 10 + x
1984  10 + x
1985  """
1986  a, b = _coerce_exprs(self, other)
1987  return ArithRef(_mk_bin(Z3_mk_add, b, a), self.ctx)
1988 
def __radd__(self, other)
Definition: z3py.py:1979
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 2090 of file z3py.py.

2090  def __rdiv__(self, other):
2091  """Create the Z3 expression `other/self`.
2092 
2093  >>> x = Int('x')
2094  >>> 10/x
2095  10/x
2096  >>> (10/x).sexpr()
2097  '(div 10 x)'
2098  >>> x = Real('x')
2099  >>> 10/x
2100  10/x
2101  >>> (10/x).sexpr()
2102  '(/ 10.0 x)'
2103  """
2104  a, b = _coerce_exprs(self, other)
2105  return ArithRef(Z3_mk_div(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
2106 
def __rdiv__(self, other)
Definition: z3py.py:2090
Z3_ast Z3_API Z3_mk_div(__in Z3_context c, __in Z3_ast arg1, __in 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:305
def __rmod__ (   self,
  other 
)
Create the Z3 expression `other%self`.

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

Definition at line 2126 of file z3py.py.

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

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

Definition at line 2002 of file z3py.py.

2002  def __rmul__(self, other):
2003  """Create the Z3 expression `other * self`.
2004 
2005  >>> x = Real('x')
2006  >>> 10 * x
2007  10*x
2008  """
2009  a, b = _coerce_exprs(self, other)
2010  return ArithRef(_mk_bin(Z3_mk_mul, b, a), self.ctx)
2011 
def __rmul__(self, other)
Definition: z3py.py:2002
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 2049 of file z3py.py.

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

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

Definition at line 2025 of file z3py.py.

2025  def __rsub__(self, other):
2026  """Create the Z3 expression `other - self`.
2027 
2028  >>> x = Int('x')
2029  >>> 10 - x
2030  10 - x
2031  """
2032  a, b = _coerce_exprs(self, other)
2033  return ArithRef(_mk_bin(Z3_mk_sub, b, a), self.ctx)
2034 
def __rsub__(self, other)
Definition: z3py.py:2025
def __rtruediv__ (   self,
  other 
)
Create the Z3 expression `other/self`.

Definition at line 2107 of file z3py.py.

2107  def __rtruediv__(self, other):
2108  """Create the Z3 expression `other/self`."""
2109  return self.__rdiv__(other)
2110 
def __rdiv__(self, other)
Definition: z3py.py:2090
def __rtruediv__(self, other)
Definition: z3py.py:2107
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 2012 of file z3py.py.

2012  def __sub__(self, other):
2013  """Create the Z3 expression `self - other`.
2014 
2015  >>> x = Int('x')
2016  >>> y = Int('y')
2017  >>> x - y
2018  x - y
2019  >>> (x - y).sort()
2020  Int
2021  """
2022  a, b = _coerce_exprs(self, other)
2023  return ArithRef(_mk_bin(Z3_mk_sub, a, b), self.ctx)
2024 
def __sub__(self, other)
Definition: z3py.py:2012
def __truediv__ (   self,
  other 
)
Create the Z3 expression `other/self`.

Definition at line 2086 of file z3py.py.

2086  def __truediv__(self, other):
2087  """Create the Z3 expression `other/self`."""
2088  return self.__div__(other)
2089 
def __truediv__(self, other)
Definition: z3py.py:2086
def __div__(self, other)
Definition: z3py.py:2063
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 1941 of file z3py.py.

1941  def is_int(self):
1942  """Return `True` if `self` is an integer expression.
1943 
1944  >>> x = Int('x')
1945  >>> x.is_int()
1946  True
1947  >>> (x + 1).is_int()
1948  True
1949  >>> y = Real('y')
1950  >>> (x + y).is_int()
1951  False
1952  """
1953  return self.sort().is_int()
1954 
def is_int(self)
Definition: z3py.py:1941
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 1955 of file z3py.py.

1955  def is_real(self):
1956  """Return `True` if `self` is an real expression.
1957 
1958  >>> x = Real('x')
1959  >>> x.is_real()
1960  True
1961  >>> (x + 1).is_real()
1962  True
1963  """
1964  return self.sort().is_real()
1965 
def is_real(self)
Definition: z3py.py:1955
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 1931 of file z3py.py.

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

1931  def sort(self):
1932  """Return the sort (type) of the arithmetical expression `self`.
1933 
1934  >>> Int('x').sort()
1935  Int
1936  >>> (Real('x') + 1).sort()
1937  Real
1938  """
1939  return ArithSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
1940 
def as_ast(self)
Definition: z3py.py:296
Arithmetic.
Definition: z3py.py:1846
def sort(self)
Definition: z3py.py:1931
Z3_sort Z3_API Z3_get_sort(__in Z3_context c, __in Z3_ast a)
Return the sort of an AST node.
def ctx_ref(self)
Definition: z3py.py:305