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

1955  def __add__(self, other):
1956  """Create the Z3 expression `self + other`.
1957 
1958  >>> x = Int('x')
1959  >>> y = Int('y')
1960  >>> x + y
1961  x + y
1962  >>> (x + y).sort()
1963  Int
1964  """
1965  a, b = _coerce_exprs(self, other)
1966  return ArithRef(_mk_bin(Z3_mk_add, a, b), self.ctx)
1967 
def __add__(self, other)
Definition: z3py.py:1955
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 2052 of file z3py.py.

2052  def __div__(self, other):
2053  """Create the Z3 expression `other/self`.
2054 
2055  >>> x = Int('x')
2056  >>> y = Int('y')
2057  >>> x/y
2058  x/y
2059  >>> (x/y).sort()
2060  Int
2061  >>> (x/y).sexpr()
2062  '(div x y)'
2063  >>> x = Real('x')
2064  >>> y = Real('y')
2065  >>> x/y
2066  x/y
2067  >>> (x/y).sort()
2068  Real
2069  >>> (x/y).sexpr()
2070  '(/ x y)'
2071  """
2072  a, b = _coerce_exprs(self, other)
2073  return ArithRef(Z3_mk_div(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
2074 
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:2052
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 2186 of file z3py.py.

2186  def __ge__(self, other):
2187  """Create the Z3 expression `other >= self`.
2188 
2189  >>> x, y = Ints('x y')
2190  >>> x >= y
2191  x >= y
2192  >>> y = Real('y')
2193  >>> x >= y
2194  ToReal(x) >= y
2195  """
2196  a, b = _coerce_exprs(self, other)
2197  return BoolRef(Z3_mk_ge(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
2198 
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:2186
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 2173 of file z3py.py.

2173  def __gt__(self, other):
2174  """Create the Z3 expression `other > self`.
2175 
2176  >>> x, y = Ints('x y')
2177  >>> x > y
2178  x > y
2179  >>> y = Real('y')
2180  >>> x > y
2181  ToReal(x) > y
2182  """
2183  a, b = _coerce_exprs(self, other)
2184  return BoolRef(Z3_mk_gt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
2185 
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:2173
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 2147 of file z3py.py.

2147  def __le__(self, other):
2148  """Create the Z3 expression `other <= self`.
2149 
2150  >>> x, y = Ints('x y')
2151  >>> x <= y
2152  x <= y
2153  >>> y = Real('y')
2154  >>> x <= y
2155  ToReal(x) <= y
2156  """
2157  a, b = _coerce_exprs(self, other)
2158  return BoolRef(Z3_mk_le(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
2159 
def __le__(self, other)
Definition: z3py.py:2147
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 2160 of file z3py.py.

2160  def __lt__(self, other):
2161  """Create the Z3 expression `other < self`.
2162 
2163  >>> x, y = Ints('x y')
2164  >>> x < y
2165  x < y
2166  >>> y = Real('y')
2167  >>> x < y
2168  ToReal(x) < y
2169  """
2170  a, b = _coerce_exprs(self, other)
2171  return BoolRef(Z3_mk_lt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
2172 
def __lt__(self, other)
Definition: z3py.py:2160
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 2100 of file z3py.py.

2100  def __mod__(self, other):
2101  """Create the Z3 expression `other%self`.
2102 
2103  >>> x = Int('x')
2104  >>> y = Int('y')
2105  >>> x % y
2106  x%y
2107  >>> simplify(IntVal(10) % IntVal(3))
2108  1
2109  """
2110  a, b = _coerce_exprs(self, other)
2111  if __debug__:
2112  _z3_assert(a.is_int(), "Z3 integer expression expected")
2113  return ArithRef(Z3_mk_mod(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
2114 
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:2100
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 1978 of file z3py.py.

1978  def __mul__(self, other):
1979  """Create the Z3 expression `self * other`.
1980 
1981  >>> x = Real('x')
1982  >>> y = Real('y')
1983  >>> x * y
1984  x*y
1985  >>> (x * y).sort()
1986  Real
1987  """
1988  a, b = _coerce_exprs(self, other)
1989  return ArithRef(_mk_bin(Z3_mk_mul, a, b), self.ctx)
1990 
def __mul__(self, other)
Definition: z3py.py:1978
def __neg__ (   self)
Return an expression representing `-self`.

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

Definition at line 2127 of file z3py.py.

2127  def __neg__(self):
2128  """Return an expression representing `-self`.
2129 
2130  >>> x = Int('x')
2131  >>> -x
2132  -x
2133  >>> simplify(-(-x))
2134  x
2135  """
2136  return ArithRef(Z3_mk_unary_minus(self.ctx_ref(), self.as_ast()), self.ctx)
2137 
def as_ast(self)
Definition: z3py.py:296
def __neg__(self)
Definition: z3py.py:2127
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 2138 of file z3py.py.

2138  def __pos__(self):
2139  """Return `self`.
2140 
2141  >>> x = Int('x')
2142  >>> +x
2143  x
2144  """
2145  return self
2146 
def __pos__(self)
Definition: z3py.py:2138
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 2024 of file z3py.py.

2024  def __pow__(self, other):
2025  """Create the Z3 expression `self**other` (** is the power operator).
2026 
2027  >>> x = Real('x')
2028  >>> x**3
2029  x**3
2030  >>> (x**3).sort()
2031  Real
2032  >>> simplify(IntVal(2)**8)
2033  256
2034  """
2035  a, b = _coerce_exprs(self, other)
2036  return ArithRef(Z3_mk_power(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
2037 
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:2024
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 1968 of file z3py.py.

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

2079  def __rdiv__(self, other):
2080  """Create the Z3 expression `other/self`.
2081 
2082  >>> x = Int('x')
2083  >>> 10/x
2084  10/x
2085  >>> (10/x).sexpr()
2086  '(div 10 x)'
2087  >>> x = Real('x')
2088  >>> 10/x
2089  10/x
2090  >>> (10/x).sexpr()
2091  '(/ 10.0 x)'
2092  """
2093  a, b = _coerce_exprs(self, other)
2094  return ArithRef(Z3_mk_div(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
2095 
def __rdiv__(self, other)
Definition: z3py.py:2079
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 2115 of file z3py.py.

2115  def __rmod__(self, other):
2116  """Create the Z3 expression `other%self`.
2117 
2118  >>> x = Int('x')
2119  >>> 10 % x
2120  10%x
2121  """
2122  a, b = _coerce_exprs(self, other)
2123  if __debug__:
2124  _z3_assert(a.is_int(), "Z3 integer expression expected")
2125  return ArithRef(Z3_mk_mod(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
2126 
def __rmod__(self, other)
Definition: z3py.py:2115
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 1991 of file z3py.py.

1991  def __rmul__(self, other):
1992  """Create the Z3 expression `other * self`.
1993 
1994  >>> x = Real('x')
1995  >>> 10 * x
1996  10*x
1997  """
1998  a, b = _coerce_exprs(self, other)
1999  return ArithRef(_mk_bin(Z3_mk_mul, b, a), self.ctx)
2000 
def __rmul__(self, other)
Definition: z3py.py:1991
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 2038 of file z3py.py.

2038  def __rpow__(self, other):
2039  """Create the Z3 expression `other**self` (** is the power operator).
2040 
2041  >>> x = Real('x')
2042  >>> 2**x
2043  2**x
2044  >>> (2**x).sort()
2045  Real
2046  >>> simplify(2**IntVal(8))
2047  256
2048  """
2049  a, b = _coerce_exprs(self, other)
2050  return ArithRef(Z3_mk_power(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
2051 
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:2038
def __rsub__ (   self,
  other 
)
Create the Z3 expression `other - self`.

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

Definition at line 2014 of file z3py.py.

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

Definition at line 2096 of file z3py.py.

2096  def __rtruediv__(self, other):
2097  """Create the Z3 expression `other/self`."""
2098  return self.__rdiv__(other)
2099 
def __rdiv__(self, other)
Definition: z3py.py:2079
def __rtruediv__(self, other)
Definition: z3py.py:2096
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 2001 of file z3py.py.

2001  def __sub__(self, other):
2002  """Create the Z3 expression `self - other`.
2003 
2004  >>> x = Int('x')
2005  >>> y = Int('y')
2006  >>> x - y
2007  x - y
2008  >>> (x - y).sort()
2009  Int
2010  """
2011  a, b = _coerce_exprs(self, other)
2012  return ArithRef(_mk_bin(Z3_mk_sub, a, b), self.ctx)
2013 
def __sub__(self, other)
Definition: z3py.py:2001
def __truediv__ (   self,
  other 
)
Create the Z3 expression `other/self`.

Definition at line 2075 of file z3py.py.

2075  def __truediv__(self, other):
2076  """Create the Z3 expression `other/self`."""
2077  return self.__div__(other)
2078 
def __truediv__(self, other)
Definition: z3py.py:2075
def __div__(self, other)
Definition: z3py.py:2052
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 1930 of file z3py.py.

1930  def is_int(self):
1931  """Return `True` if `self` is an integer expression.
1932 
1933  >>> x = Int('x')
1934  >>> x.is_int()
1935  True
1936  >>> (x + 1).is_int()
1937  True
1938  >>> y = Real('y')
1939  >>> (x + y).is_int()
1940  False
1941  """
1942  return self.sort().is_int()
1943 
def is_int(self)
Definition: z3py.py:1930
def sort(self)
Definition: z3py.py:748
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 1944 of file z3py.py.

1944  def is_real(self):
1945  """Return `True` if `self` is an real expression.
1946 
1947  >>> x = Real('x')
1948  >>> x.is_real()
1949  True
1950  >>> (x + 1).is_real()
1951  True
1952  """
1953  return self.sort().is_real()
1954 
def is_real(self)
Definition: z3py.py:1944
def sort(self)
Definition: z3py.py:748
def sort (   self)
Return the sort (type) of the arithmetical expression `self`.

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

Definition at line 1920 of file z3py.py.

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

1920  def sort(self):
1921  """Return the sort (type) of the arithmetical expression `self`.
1922 
1923  >>> Int('x').sort()
1924  Int
1925  >>> (Real('x') + 1).sort()
1926  Real
1927  """
1928  return ArithSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
1929 
def as_ast(self)
Definition: z3py.py:296
Arithmetic.
Definition: z3py.py:1835
def sort(self)
Definition: z3py.py:1920
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