Z3
Public Member Functions
QuantifierRef Class Reference

Quantifiers. More...

+ Inheritance diagram for QuantifierRef:

Public Member Functions

def as_ast (self)
 
def get_id (self)
 
def sort (self)
 
def is_forall (self)
 
def weight (self)
 
def num_patterns (self)
 
def pattern (self, idx)
 
def num_no_patterns (self)
 
def no_pattern (self, idx)
 
def body (self)
 
def num_vars (self)
 
def var_name (self, idx)
 
def var_sort (self, idx)
 
def children (self)
 
- Public Member Functions inherited from BoolRef
def sort (self)
 
def __rmul__ (self, other)
 
def __mul__ (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 __hash__ (self)
 
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__ (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

Quantifiers.

Universally and Existentially quantified formulas.

Definition at line 1686 of file z3py.py.

Member Function Documentation

§ as_ast()

def as_ast (   self)

Definition at line 1689 of file z3py.py.

1689  def as_ast(self):
1690  return self.ast
1691 

§ body()

def body (   self)
Return the expression being quantified.

>>> f = Function('f', IntSort(), IntSort())
>>> x = Int('x')
>>> q = ForAll(x, f(x) == 0)
>>> q.body()
f(Var(0)) == 0

Definition at line 1767 of file z3py.py.

Referenced by QuantifierRef.children().

1767  def body(self):
1768  """Return the expression being quantified.
1769 
1770  >>> f = Function('f', IntSort(), IntSort())
1771  >>> x = Int('x')
1772  >>> q = ForAll(x, f(x) == 0)
1773  >>> q.body()
1774  f(Var(0)) == 0
1775  """
1776  return _to_expr_ref(Z3_get_quantifier_body(self.ctx_ref(), self.ast), self.ctx)
1777 
Z3_ast Z3_API Z3_get_quantifier_body(Z3_context c, Z3_ast a)
Return body of quantifier.

§ children()

def children (   self)
Return a list containing a single element self.body()

>>> f = Function('f', IntSort(), IntSort())
>>> x = Int('x')
>>> q = ForAll(x, f(x) == 0)
>>> q.children()
[f(Var(0)) == 0]

Definition at line 1822 of file z3py.py.

1822  def children(self):
1823  """Return a list containing a single element self.body()
1824 
1825  >>> f = Function('f', IntSort(), IntSort())
1826  >>> x = Int('x')
1827  >>> q = ForAll(x, f(x) == 0)
1828  >>> q.children()
1829  [f(Var(0)) == 0]
1830  """
1831  return [ self.body() ]
1832 

§ get_id()

def get_id (   self)

Definition at line 1692 of file z3py.py.

1692  def get_id(self):
1693  return Z3_get_ast_id(self.ctx_ref(), self.as_ast())
1694 

§ is_forall()

def is_forall (   self)
Return `True` if `self` is a universal quantifier.

>>> f = Function('f', IntSort(), IntSort())
>>> x = Int('x')
>>> q = ForAll(x, f(x) == 0)
>>> q.is_forall()
True
>>> q = Exists(x, f(x) != 0)
>>> q.is_forall()
False

Definition at line 1699 of file z3py.py.

1699  def is_forall(self):
1700  """Return `True` if `self` is a universal quantifier.
1701 
1702  >>> f = Function('f', IntSort(), IntSort())
1703  >>> x = Int('x')
1704  >>> q = ForAll(x, f(x) == 0)
1705  >>> q.is_forall()
1706  True
1707  >>> q = Exists(x, f(x) != 0)
1708  >>> q.is_forall()
1709  False
1710  """
1711  return Z3_is_quantifier_forall(self.ctx_ref(), self.ast)
1712 
Z3_bool Z3_API Z3_is_quantifier_forall(Z3_context c, Z3_ast a)
Determine if quantifier is universal.

§ no_pattern()

def no_pattern (   self,
  idx 
)
Return a no-pattern.

Definition at line 1761 of file z3py.py.

1761  def no_pattern(self, idx):
1762  """Return a no-pattern."""
1763  if __debug__:
1764  _z3_assert(idx < self.num_no_patterns(), "Invalid no-pattern idx")
1765  return _to_expr_ref(Z3_get_quantifier_no_pattern_ast(self.ctx_ref(), self.ast, idx), self.ctx)
1766 
Z3_ast Z3_API Z3_get_quantifier_no_pattern_ast(Z3_context c, Z3_ast a, unsigned i)
Return i&#39;th no_pattern.

§ num_no_patterns()

def num_no_patterns (   self)
Return the number of no-patterns.

Definition at line 1757 of file z3py.py.

1757  def num_no_patterns(self):
1758  """Return the number of no-patterns."""
1759  return Z3_get_quantifier_num_no_patterns(self.ctx_ref(), self.ast)
1760 
unsigned Z3_API Z3_get_quantifier_num_no_patterns(Z3_context c, Z3_ast a)
Return number of no_patterns used in quantifier.

§ num_patterns()

def num_patterns (   self)
Return the number of patterns (i.e., quantifier instantiation hints) in `self`.

>>> f = Function('f', IntSort(), IntSort())
>>> g = Function('g', IntSort(), IntSort())
>>> x = Int('x')
>>> q = ForAll(x, f(x) != g(x), patterns = [ f(x), g(x) ])
>>> q.num_patterns()
2

Definition at line 1727 of file z3py.py.

1727  def num_patterns(self):
1728  """Return the number of patterns (i.e., quantifier instantiation hints) in `self`.
1729 
1730  >>> f = Function('f', IntSort(), IntSort())
1731  >>> g = Function('g', IntSort(), IntSort())
1732  >>> x = Int('x')
1733  >>> q = ForAll(x, f(x) != g(x), patterns = [ f(x), g(x) ])
1734  >>> q.num_patterns()
1735  2
1736  """
1737  return int(Z3_get_quantifier_num_patterns(self.ctx_ref(), self.ast))
1738 
unsigned Z3_API Z3_get_quantifier_num_patterns(Z3_context c, Z3_ast a)
Return number of patterns used in quantifier.

§ num_vars()

def num_vars (   self)
Return the number of variables bounded by this quantifier.

>>> f = Function('f', IntSort(), IntSort(), IntSort())
>>> x = Int('x')
>>> y = Int('y')
>>> q = ForAll([x, y], f(x, y) >= x)
>>> q.num_vars()
2

Definition at line 1778 of file z3py.py.

1778  def num_vars(self):
1779  """Return the number of variables bounded by this quantifier.
1780 
1781  >>> f = Function('f', IntSort(), IntSort(), IntSort())
1782  >>> x = Int('x')
1783  >>> y = Int('y')
1784  >>> q = ForAll([x, y], f(x, y) >= x)
1785  >>> q.num_vars()
1786  2
1787  """
1788  return int(Z3_get_quantifier_num_bound(self.ctx_ref(), self.ast))
1789 
unsigned Z3_API Z3_get_quantifier_num_bound(Z3_context c, Z3_ast a)
Return number of bound variables of quantifier.

§ pattern()

def pattern (   self,
  idx 
)
Return a pattern (i.e., quantifier instantiation hints) in `self`.

>>> f = Function('f', IntSort(), IntSort())
>>> g = Function('g', IntSort(), IntSort())
>>> x = Int('x')
>>> q = ForAll(x, f(x) != g(x), patterns = [ f(x), g(x) ])
>>> q.num_patterns()
2
>>> q.pattern(0)
f(Var(0))
>>> q.pattern(1)
g(Var(0))

Definition at line 1739 of file z3py.py.

1739  def pattern(self, idx):
1740  """Return a pattern (i.e., quantifier instantiation hints) in `self`.
1741 
1742  >>> f = Function('f', IntSort(), IntSort())
1743  >>> g = Function('g', IntSort(), IntSort())
1744  >>> x = Int('x')
1745  >>> q = ForAll(x, f(x) != g(x), patterns = [ f(x), g(x) ])
1746  >>> q.num_patterns()
1747  2
1748  >>> q.pattern(0)
1749  f(Var(0))
1750  >>> q.pattern(1)
1751  g(Var(0))
1752  """
1753  if __debug__:
1754  _z3_assert(idx < self.num_patterns(), "Invalid pattern idx")
1755  return PatternRef(Z3_get_quantifier_pattern_ast(self.ctx_ref(), self.ast, idx), self.ctx)
1756 
Z3_pattern Z3_API Z3_get_quantifier_pattern_ast(Z3_context c, Z3_ast a, unsigned i)
Return i&#39;th pattern.

§ sort()

def sort (   self)
Return the Boolean sort.

Definition at line 1695 of file z3py.py.

1695  def sort(self):
1696  """Return the Boolean sort."""
1697  return BoolSort(self.ctx)
1698 
def BoolSort(ctx=None)
Definition: z3py.py:1407

§ var_name()

def var_name (   self,
  idx 
)
Return a string representing a name used when displaying the quantifier.

>>> f = Function('f', IntSort(), IntSort(), IntSort())
>>> x = Int('x')
>>> y = Int('y')
>>> q = ForAll([x, y], f(x, y) >= x)
>>> q.var_name(0)
'x'
>>> q.var_name(1)
'y'

Definition at line 1790 of file z3py.py.

1790  def var_name(self, idx):
1791  """Return a string representing a name used when displaying the quantifier.
1792 
1793  >>> f = Function('f', IntSort(), IntSort(), IntSort())
1794  >>> x = Int('x')
1795  >>> y = Int('y')
1796  >>> q = ForAll([x, y], f(x, y) >= x)
1797  >>> q.var_name(0)
1798  'x'
1799  >>> q.var_name(1)
1800  'y'
1801  """
1802  if __debug__:
1803  _z3_assert(idx < self.num_vars(), "Invalid variable idx")
1804  return _symbol2py(self.ctx, Z3_get_quantifier_bound_name(self.ctx_ref(), self.ast, idx))
1805 
Z3_symbol Z3_API Z3_get_quantifier_bound_name(Z3_context c, Z3_ast a, unsigned i)
Return symbol of the i&#39;th bound variable.

§ var_sort()

def var_sort (   self,
  idx 
)
Return the sort of a bound variable.

>>> f = Function('f', IntSort(), RealSort(), IntSort())
>>> x = Int('x')
>>> y = Real('y')
>>> q = ForAll([x, y], f(x, y) >= x)
>>> q.var_sort(0)
Int
>>> q.var_sort(1)
Real

Definition at line 1806 of file z3py.py.

1806  def var_sort(self, idx):
1807  """Return the sort of a bound variable.
1808 
1809  >>> f = Function('f', IntSort(), RealSort(), IntSort())
1810  >>> x = Int('x')
1811  >>> y = Real('y')
1812  >>> q = ForAll([x, y], f(x, y) >= x)
1813  >>> q.var_sort(0)
1814  Int
1815  >>> q.var_sort(1)
1816  Real
1817  """
1818  if __debug__:
1819  _z3_assert(idx < self.num_vars(), "Invalid variable idx")
1820  return _to_sort_ref(Z3_get_quantifier_bound_sort(self.ctx_ref(), self.ast, idx), self.ctx)
1821 
Z3_sort Z3_API Z3_get_quantifier_bound_sort(Z3_context c, Z3_ast a, unsigned i)
Return sort of the i&#39;th bound variable.

§ weight()

def weight (   self)
Return the weight annotation of `self`.

>>> f = Function('f', IntSort(), IntSort())
>>> x = Int('x')
>>> q = ForAll(x, f(x) == 0)
>>> q.weight()
1
>>> q = ForAll(x, f(x) == 0, weight=10)
>>> q.weight()
10

Definition at line 1713 of file z3py.py.

1713  def weight(self):
1714  """Return the weight annotation of `self`.
1715 
1716  >>> f = Function('f', IntSort(), IntSort())
1717  >>> x = Int('x')
1718  >>> q = ForAll(x, f(x) == 0)
1719  >>> q.weight()
1720  1
1721  >>> q = ForAll(x, f(x) == 0, weight=10)
1722  >>> q.weight()
1723  10
1724  """
1725  return int(Z3_get_quantifier_weight(self.ctx_ref(), self.ast))
1726 
unsigned Z3_API Z3_get_quantifier_weight(Z3_context c, Z3_ast a)
Obtain weight of quantifier.