﻿ Z3: ArithRef Class Reference
 Z3
ArithRef Class Reference
Inheritance diagram for ArithRef:

## Public Member Functions

def sort

def is_int

def is_real

def __mul__

def __rmul__

def __sub__

def __rsub__

def __pow__

def __rpow__

def __div__

def __truediv__

def __rdiv__

def __rtruediv__

def __mod__

def __rmod__

def __neg__

def __pos__

def __le__

def __lt__

def __gt__

def __ge__

Public Member Functions inherited from ExprRef
def as_ast

def get_id

def sort

def sort_kind

def __eq__

def __ne__

def decl

def num_args

def arg

def children

Public Member Functions inherited from AstRef
def __init__

def __del__

def __str__

def __repr__

def sexpr

def as_ast

def get_id

def ctx_ref

def eq

def translate

def hash

Public Member Functions inherited from Z3PPObject
def use_pp

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.

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

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

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

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

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

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

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

1979  def __mul__(self, other):
1980  """Create the Z3 expression `self * other`.
1981
1982  >>> x = Real('x')
1983  >>> y = Real('y')
1984  >>> x * y
1985  x*y
1986  >>> (x * y).sort()
1987  Real
1988  """
1989  a, b = _coerce_exprs(self, other)
1990  return ArithRef(_mk_bin(Z3_mk_mul, a, b), self.ctx)
def __mul__
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.

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

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

Definition at line 2138 of file z3py.py.

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

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

1970  """Create the Z3 expression `other + self`.
1971
1972  >>> x = Int('x')
1973  >>> 10 + x
1974  10 + x
1975  """
1976  a, b = _coerce_exprs(self, other)
1977  return ArithRef(_mk_bin(Z3_mk_add, b, a), self.ctx)
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.

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

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

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

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

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

Definition at line 2096 of file z3py.py.

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

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

Definition at line 2075 of file z3py.py.

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

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

1945  def is_real(self):
1946  """Return `True` if `self` is an real expression.
1947
1948  >>> x = Real('x')
1949  >>> x.is_real()
1950  True
1951  >>> (x + 1).is_real()
1952  True
1953  """
1954  return self.sort().is_real()
def sort
Definition: z3py.py:748
def is_real
Definition: z3py.py:1944
 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.

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