Z3
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions
SortRef Class Reference
+ Inheritance diagram for SortRef:

Public Member Functions

def as_ast
 
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 ctx_ref
 
def eq
 
def translate
 
def hash
 
- Public Member Functions inherited from Z3PPObject
def use_pp
 

Additional Inherited Members

- Data Fields inherited from AstRef
 ast
 
 ctx
 

Detailed Description

A Sort is essentially a type. Every Z3 expression has a sort. A sort is an AST node.

Definition at line 420 of file z3py.py.

Member Function Documentation

def __eq__ (   self,
  other 
)
Return `True` if `self` and `other` are the same Z3 sort.

>>> p = Bool('p')
>>> p.sort() == BoolSort()
True
>>> p.sort() == IntSort()
False

Definition at line 474 of file z3py.py.

Referenced by Probe.__ne__().

475  def __eq__(self, other):
476  """Return `True` if `self` and `other` are the same Z3 sort.
477 
478  >>> p = Bool('p')
479  >>> p.sort() == BoolSort()
480  True
481  >>> p.sort() == IntSort()
482  False
483  """
484  if other == None:
485  return False
486  return Z3_is_eq_sort(self.ctx_ref(), self.ast, other.ast)
def __ne__ (   self,
  other 
)
Return `True` if `self` and `other` are not the same Z3 sort.

>>> p = Bool('p')
>>> p.sort() != BoolSort()
False
>>> p.sort() != IntSort()
True

Definition at line 487 of file z3py.py.

488  def __ne__(self, other):
489  """Return `True` if `self` and `other` are not the same Z3 sort.
490 
491  >>> p = Bool('p')
492  >>> p.sort() != BoolSort()
493  False
494  >>> p.sort() != IntSort()
495  True
496  """
497  return not Z3_is_eq_sort(self.ctx_ref(), self.ast, other.ast)
def as_ast (   self)

Definition at line 422 of file z3py.py.

423  def as_ast(self):
424  return Z3_sort_to_ast(self.ctx_ref(), self.ast)
def cast (   self,
  val 
)
Try to cast `val` as an element of sort `self`. 

This method is used in Z3Py to convert Python objects such as integers,
floats, longs and strings into Z3 expressions.

>>> x = Int('x')
>>> RealSort().cast(x)
ToReal(x)

Definition at line 449 of file z3py.py.

450  def cast(self, val):
451  """Try to cast `val` as an element of sort `self`.
452 
453  This method is used in Z3Py to convert Python objects such as integers,
454  floats, longs and strings into Z3 expressions.
455 
456  >>> x = Int('x')
457  >>> RealSort().cast(x)
458  ToReal(x)
459  """
460  if __debug__:
461  _z3_assert(is_expr(val), "Z3 expression expected")
462  _z3_assert(self.eq(val.sort()), "Sort mismatch")
463  return val
def kind (   self)
Return the Z3 internal kind of a sort. This method can be used to test if `self` is one of the Z3 builtin sorts.

>>> b = BoolSort()
>>> b.kind() == Z3_BOOL_SORT
True
>>> b.kind() == Z3_INT_SORT
False
>>> A = ArraySort(IntSort(), IntSort())
>>> A.kind() == Z3_ARRAY_SORT
True
>>> A.kind() == Z3_INT_SORT
False

Definition at line 425 of file z3py.py.

426  def kind(self):
427  """Return the Z3 internal kind of a sort. This method can be used to test if `self` is one of the Z3 builtin sorts.
428 
429  >>> b = BoolSort()
430  >>> b.kind() == Z3_BOOL_SORT
431  True
432  >>> b.kind() == Z3_INT_SORT
433  False
434  >>> A = ArraySort(IntSort(), IntSort())
435  >>> A.kind() == Z3_ARRAY_SORT
436  True
437  >>> A.kind() == Z3_INT_SORT
438  False
439  """
440  return _sort_kind(self.ctx, self.ast)
def name (   self)
Return the name (string) of sort `self`.

>>> BoolSort().name()
'Bool'
>>> ArraySort(IntSort(), IntSort()).name()
'Array'

Definition at line 464 of file z3py.py.

465  def name(self):
466  """Return the name (string) of sort `self`.
467 
468  >>> BoolSort().name()
469  'Bool'
470  >>> ArraySort(IntSort(), IntSort()).name()
471  'Array'
472  """
473  return _symbol2py(self.ctx, Z3_get_sort_name(self.ctx_ref(), self.ast))
def subsort (   self,
  other 
)
Return `True` if `self` is a subsort of `other`. 

>>> IntSort().subsort(RealSort())
True

Definition at line 441 of file z3py.py.

442  def subsort(self, other):
443  """Return `True` if `self` is a subsort of `other`.
444 
445  >>> IntSort().subsort(RealSort())
446  True
447  """
448  return False