Z3
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Member Functions | Data Fields
ArithSortRef Class Reference

Arithmetic. More...

+ Inheritance diagram for ArithSortRef:

Public Member Functions

def is_real
 
def is_int
 
def subsort
 
def cast
 
- Public Member Functions inherited from SortRef
def as_ast
 
def get_id
 
def kind
 
def subsort
 
def cast
 
def name
 
def __eq__
 
def __ne__
 
- 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

 ctx
 
- Data Fields inherited from AstRef
 ast
 
 ctx
 

Detailed Description

Arithmetic.

Real and Integer sorts.

Definition at line 1835 of file z3py.py.

Member Function Documentation

def cast (   self,
  val 
)
Try to cast `val` as an Integer or Real.

>>> IntSort().cast(10)
10
>>> is_int(IntSort().cast(10))
True
>>> is_int(10)
False
>>> RealSort().cast(10)
10
>>> is_real(RealSort().cast(10))
True

Definition at line 1870 of file z3py.py.

1871  def cast(self, val):
1872  """Try to cast `val` as an Integer or Real.
1873 
1874  >>> IntSort().cast(10)
1875  10
1876  >>> is_int(IntSort().cast(10))
1877  True
1878  >>> is_int(10)
1879  False
1880  >>> RealSort().cast(10)
1881  10
1882  >>> is_real(RealSort().cast(10))
1883  True
1884  """
1885  if is_expr(val):
1886  if __debug__:
1887  _z3_assert(self.ctx == val.ctx, "Context mismatch")
1888  val_s = val.sort()
1889  if self.eq(val_s):
1890  return val
1891  if val_s.is_int() and self.is_real():
1892  return ToReal(val)
1893  if __debug__:
1894  _z3_assert(False, "Z3 Integer/Real expression expected" )
1895  else:
1896  if self.is_int():
1897  return IntVal(val, self.ctx)
1898  if self.is_real():
1899  return RealVal(val, self.ctx)
1900  if __debug__:
1901  _z3_assert(False, "int, long, float, string (numeral), or Z3 Integer/Real expression expected")
def ToReal
Definition: z3py.py:2817
def eq
Definition: z3py.py:309
def is_expr
Definition: z3py.py:950
def RealVal
Definition: z3py.py:2672
def IntVal
Definition: z3py.py:2661
def is_int (   self)
Return `True` if `self` is of the sort Integer.

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

Definition at line 1852 of file z3py.py.

Referenced by ArithSortRef.cast().

1853  def is_int(self):
1854  """Return `True` if `self` is of the sort Integer.
1855 
1856  >>> x = Int('x')
1857  >>> x.is_int()
1858  True
1859  >>> (x + 1).is_int()
1860  True
1861  >>> x = Real('x')
1862  >>> x.is_int()
1863  False
1864  """
1865  return self.kind() == Z3_INT_SORT
def kind
Definition: z3py.py:459
def is_real (   self)
Return `True` if `self` is of the sort Real.

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

Definition at line 1838 of file z3py.py.

Referenced by ArithSortRef.cast().

1839  def is_real(self):
1840  """Return `True` if `self` is of the sort Real.
1841 
1842  >>> x = Real('x')
1843  >>> x.is_real()
1844  True
1845  >>> (x + 1).is_real()
1846  True
1847  >>> x = Int('x')
1848  >>> x.is_real()
1849  False
1850  """
1851  return self.kind() == Z3_REAL_SORT
def kind
Definition: z3py.py:459
def subsort (   self,
  other 
)
Return `True` if `self` is a subsort of `other`.

Definition at line 1866 of file z3py.py.

1867  def subsort(self, other):
1868  """Return `True` if `self` is a subsort of `other`."""
1869  return self.is_int() and is_arith_sort(other) and other.is_real()
def is_arith_sort
Definition: z3py.py:1902

Field Documentation

ctx

Definition at line 1886 of file z3py.py.

Referenced by Probe.__eq__(), Probe.__ge__(), ApplyResult.__getitem__(), Probe.__gt__(), Probe.__le__(), Probe.__lt__(), Probe.__ne__(), Fixedpoint.add_rule(), Tactic.apply(), ApplyResult.as_expr(), Fixedpoint.assert_exprs(), ApplyResult.convert_model(), Fixedpoint.get_answer(), Fixedpoint.get_assertions(), Fixedpoint.get_cover_delta(), Fixedpoint.get_rules(), Fixedpoint.param_descrs(), Tactic.param_descrs(), Fixedpoint.parse_file(), Fixedpoint.parse_string(), Fixedpoint.set(), Tactic.solver(), Fixedpoint.statistics(), Solver.to_smt2(), and Fixedpoint.update_rule().