Z3
Public Member Functions
SortRef Class Reference
+ Inheritance diagram for SortRef:

Public Member Functions

def as_ast (self)
 
def get_id (self)
 
def kind (self)
 
def subsort (self, other)
 
def cast (self, val)
 
def name (self)
 
def __eq__ (self, other)
 
def __ne__ (self, other)
 
def __hash__ (self)
 
- Public Member Functions inherited from AstRef
def __init__ (self, ast, ctx=None)
 
def __del__ (self)
 
def __str__ (self)
 
def __repr__ (self)
 
def __eq__ (self, other)
 
def __hash__ (self)
 
def __nonzero__ (self)
 
def __bool__ (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

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

Definition at line 478 of file z3py.py.

Member Function Documentation

§ __eq__()

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

Referenced by Probe.__ne__().

535  def __eq__(self, other):
536  """Return `True` if `self` and `other` are the same Z3 sort.
537 
538  >>> p = Bool('p')
539  >>> p.sort() == BoolSort()
540  True
541  >>> p.sort() == IntSort()
542  False
543  """
544  if other is None:
545  return False
546  return Z3_is_eq_sort(self.ctx_ref(), self.ast, other.ast)
547 

§ __hash__()

def __hash__ (   self)
Hash code. 

Definition at line 559 of file z3py.py.

559  def __hash__(self):
560  """ Hash code. """
561  return AstRef.__hash__(self)
562 

§ __ne__()

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

548  def __ne__(self, other):
549  """Return `True` if `self` and `other` are not the same Z3 sort.
550 
551  >>> p = Bool('p')
552  >>> p.sort() != BoolSort()
553  False
554  >>> p.sort() != IntSort()
555  True
556  """
557  return not Z3_is_eq_sort(self.ctx_ref(), self.ast, other.ast)
558 

§ as_ast()

def as_ast (   self)

Definition at line 480 of file z3py.py.

480  def as_ast(self):
481  return Z3_sort_to_ast(self.ctx_ref(), self.ast)
482 

§ cast()

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

510  def cast(self, val):
511  """Try to cast `val` as an element of sort `self`.
512 
513  This method is used in Z3Py to convert Python objects such as integers,
514  floats, longs and strings into Z3 expressions.
515 
516  >>> x = Int('x')
517  >>> RealSort().cast(x)
518  ToReal(x)
519  """
520  if __debug__:
521  _z3_assert(is_expr(val), "Z3 expression expected")
522  _z3_assert(self.eq(val.sort()), "Sort mismatch")
523  return val
524 
def is_expr(a)
Definition: z3py.py:1007

§ get_id()

def get_id (   self)

Definition at line 483 of file z3py.py.

483  def get_id(self):
484  return Z3_get_ast_id(self.ctx_ref(), self.as_ast())
485 

§ kind()

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

486  def kind(self):
487  """Return the Z3 internal kind of a sort. This method can be used to test if `self` is one of the Z3 builtin sorts.
488 
489  >>> b = BoolSort()
490  >>> b.kind() == Z3_BOOL_SORT
491  True
492  >>> b.kind() == Z3_INT_SORT
493  False
494  >>> A = ArraySort(IntSort(), IntSort())
495  >>> A.kind() == Z3_ARRAY_SORT
496  True
497  >>> A.kind() == Z3_INT_SORT
498  False
499  """
500  return _sort_kind(self.ctx, self.ast)
501 

§ name()

def name (   self)
Return the name (string) of sort `self`.

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

Definition at line 525 of file z3py.py.

525  def name(self):
526  """Return the name (string) of sort `self`.
527 
528  >>> BoolSort().name()
529  'Bool'
530  >>> ArraySort(IntSort(), IntSort()).name()
531  'Array'
532  """
533  return _symbol2py(self.ctx, Z3_get_sort_name(self.ctx_ref(), self.ast))
534 

§ subsort()

def subsort (   self,
  other 
)
Return `True` if `self` is a subsort of `other`.

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

Definition at line 502 of file z3py.py.

502  def subsort(self, other):
503  """Return `True` if `self` is a subsort of `other`.
504 
505  >>> IntSort().subsort(RealSort())
506  True
507  """
508  return False
509