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)
 
- 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 __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__
 
def __del__ (self)
 
def __str__ (self)
 
def __repr__ (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 1601 of file z3py.py.

Member Function Documentation

def as_ast (   self)

Definition at line 1604 of file z3py.py.

1604  def as_ast(self):
1605  return self.ast
1606 
def as_ast(self)
Definition: z3py.py:1604
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 1682 of file z3py.py.

Referenced by QuantifierRef.children().

1682  def body(self):
1683  """Return the expression being quantified.
1684 
1685  >>> f = Function('f', IntSort(), IntSort())
1686  >>> x = Int('x')
1687  >>> q = ForAll(x, f(x) == 0)
1688  >>> q.body()
1689  f(Var(0)) == 0
1690  """
1691  return _to_expr_ref(Z3_get_quantifier_body(self.ctx_ref(), self.ast), self.ctx)
1692 
Z3_ast Z3_API Z3_get_quantifier_body(__in Z3_context c, __in Z3_ast a)
Return body of quantifier.
def ctx_ref(self)
Definition: z3py.py:305
def body(self)
Definition: z3py.py:1682
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 1737 of file z3py.py.

1737  def children(self):
1738  """Return a list containing a single element self.body()
1739 
1740  >>> f = Function('f', IntSort(), IntSort())
1741  >>> x = Int('x')
1742  >>> q = ForAll(x, f(x) == 0)
1743  >>> q.children()
1744  [f(Var(0)) == 0]
1745  """
1746  return [ self.body() ]
1747 
def children(self)
Definition: z3py.py:1737
def body(self)
Definition: z3py.py:1682
def get_id (   self)

Definition at line 1607 of file z3py.py.

1607  def get_id(self):
1608  return Z3_get_ast_id(self.ctx_ref(), self.as_ast())
1609 
def get_id(self)
Definition: z3py.py:1607
def as_ast(self)
Definition: z3py.py:296
unsigned Z3_API Z3_get_ast_id(__in Z3_context c, Z3_ast t)
Return a unique identifier for t.
def ctx_ref(self)
Definition: z3py.py:305
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 1614 of file z3py.py.

1614  def is_forall(self):
1615  """Return `True` if `self` is a universal quantifier.
1616 
1617  >>> f = Function('f', IntSort(), IntSort())
1618  >>> x = Int('x')
1619  >>> q = ForAll(x, f(x) == 0)
1620  >>> q.is_forall()
1621  True
1622  >>> q = Exists(x, f(x) != 0)
1623  >>> q.is_forall()
1624  False
1625  """
1626  return Z3_is_quantifier_forall(self.ctx_ref(), self.ast)
1627 
def is_forall(self)
Definition: z3py.py:1614
def ctx_ref(self)
Definition: z3py.py:305
Z3_bool Z3_API Z3_is_quantifier_forall(__in Z3_context c, __in Z3_ast a)
Determine if quantifier is universal.
def no_pattern (   self,
  idx 
)
Return a no-pattern.

Definition at line 1676 of file z3py.py.

1676  def no_pattern(self, idx):
1677  """Return a no-pattern."""
1678  if __debug__:
1679  _z3_assert(idx < self.num_no_patterns(), "Invalid no-pattern idx")
1680  return _to_expr_ref(Z3_get_quantifier_no_pattern_ast(self.ctx_ref(), self.ast, idx), self.ctx)
1681 
Z3_ast Z3_API Z3_get_quantifier_no_pattern_ast(__in Z3_context c, __in Z3_ast a, unsigned i)
Return i'th no_pattern.
def num_no_patterns(self)
Definition: z3py.py:1672
def ctx_ref(self)
Definition: z3py.py:305
def no_pattern(self, idx)
Definition: z3py.py:1676
def num_no_patterns (   self)
Return the number of no-patterns.

Definition at line 1672 of file z3py.py.

Referenced by QuantifierRef.no_pattern().

1672  def num_no_patterns(self):
1673  """Return the number of no-patterns."""
1674  return Z3_get_quantifier_num_no_patterns(self.ctx_ref(), self.ast)
1675 
def num_no_patterns(self)
Definition: z3py.py:1672
def ctx_ref(self)
Definition: z3py.py:305
unsigned Z3_API Z3_get_quantifier_num_no_patterns(__in Z3_context c, __in Z3_ast a)
Return number of no_patterns used in quantifier.
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 1642 of file z3py.py.

1642  def num_patterns(self):
1643  """Return the number of patterns (i.e., quantifier instantiation hints) in `self`.
1644 
1645  >>> f = Function('f', IntSort(), IntSort())
1646  >>> g = Function('g', IntSort(), IntSort())
1647  >>> x = Int('x')
1648  >>> q = ForAll(x, f(x) != g(x), patterns = [ f(x), g(x) ])
1649  >>> q.num_patterns()
1650  2
1651  """
1652  return int(Z3_get_quantifier_num_patterns(self.ctx_ref(), self.ast))
1653 
unsigned Z3_API Z3_get_quantifier_num_patterns(__in Z3_context c, __in Z3_ast a)
Return number of patterns used in quantifier.
def num_patterns(self)
Definition: z3py.py:1642
def ctx_ref(self)
Definition: z3py.py:305
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 1693 of file z3py.py.

1693  def num_vars(self):
1694  """Return the number of variables bounded by this quantifier.
1695 
1696  >>> f = Function('f', IntSort(), IntSort(), IntSort())
1697  >>> x = Int('x')
1698  >>> y = Int('y')
1699  >>> q = ForAll([x, y], f(x, y) >= x)
1700  >>> q.num_vars()
1701  2
1702  """
1703  return int(Z3_get_quantifier_num_bound(self.ctx_ref(), self.ast))
1704 
def ctx_ref(self)
Definition: z3py.py:305
def num_vars(self)
Definition: z3py.py:1693
unsigned Z3_API Z3_get_quantifier_num_bound(__in Z3_context c, __in Z3_ast a)
Return number of bound variables of quantifier.
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 1654 of file z3py.py.

1654  def pattern(self, idx):
1655  """Return a pattern (i.e., quantifier instantiation hints) in `self`.
1656 
1657  >>> f = Function('f', IntSort(), IntSort())
1658  >>> g = Function('g', IntSort(), IntSort())
1659  >>> x = Int('x')
1660  >>> q = ForAll(x, f(x) != g(x), patterns = [ f(x), g(x) ])
1661  >>> q.num_patterns()
1662  2
1663  >>> q.pattern(0)
1664  f(Var(0))
1665  >>> q.pattern(1)
1666  g(Var(0))
1667  """
1668  if __debug__:
1669  _z3_assert(idx < self.num_patterns(), "Invalid pattern idx")
1670  return PatternRef(Z3_get_quantifier_pattern_ast(self.ctx_ref(), self.ast, idx), self.ctx)
1671 
Patterns.
Definition: z3py.py:1534
def num_patterns(self)
Definition: z3py.py:1642
Z3_pattern Z3_API Z3_get_quantifier_pattern_ast(__in Z3_context c, __in Z3_ast a, unsigned i)
Return i'th pattern.
def pattern(self, idx)
Definition: z3py.py:1654
def ctx_ref(self)
Definition: z3py.py:305
def sort (   self)
Return the Boolean sort.

Definition at line 1610 of file z3py.py.

1610  def sort(self):
1611  """Return the Boolean sort."""
1612  return BoolSort(self.ctx)
1613 
def BoolSort
Definition: z3py.py:1325
def sort(self)
Definition: z3py.py:1610
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 1705 of file z3py.py.

1705  def var_name(self, idx):
1706  """Return a string representing a name used when displaying the quantifier.
1707 
1708  >>> f = Function('f', IntSort(), IntSort(), IntSort())
1709  >>> x = Int('x')
1710  >>> y = Int('y')
1711  >>> q = ForAll([x, y], f(x, y) >= x)
1712  >>> q.var_name(0)
1713  'x'
1714  >>> q.var_name(1)
1715  'y'
1716  """
1717  if __debug__:
1718  _z3_assert(idx < self.num_vars(), "Invalid variable idx")
1719  return _symbol2py(self.ctx, Z3_get_quantifier_bound_name(self.ctx_ref(), self.ast, idx))
1720 
def var_name(self, idx)
Definition: z3py.py:1705
Z3_symbol Z3_API Z3_get_quantifier_bound_name(__in Z3_context c, __in Z3_ast a, unsigned i)
Return symbol of the i'th bound variable.
def ctx_ref(self)
Definition: z3py.py:305
def num_vars(self)
Definition: z3py.py:1693
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 1721 of file z3py.py.

1721  def var_sort(self, idx):
1722  """Return the sort of a bound variable.
1723 
1724  >>> f = Function('f', IntSort(), RealSort(), IntSort())
1725  >>> x = Int('x')
1726  >>> y = Real('y')
1727  >>> q = ForAll([x, y], f(x, y) >= x)
1728  >>> q.var_sort(0)
1729  Int
1730  >>> q.var_sort(1)
1731  Real
1732  """
1733  if __debug__:
1734  _z3_assert(idx < self.num_vars(), "Invalid variable idx")
1735  return SortRef(Z3_get_quantifier_bound_sort(self.ctx_ref(), self.ast, idx), self.ctx)
1736 
def var_sort(self, idx)
Definition: z3py.py:1721
def ctx_ref(self)
Definition: z3py.py:305
Z3_sort Z3_API Z3_get_quantifier_bound_sort(__in Z3_context c, __in Z3_ast a, unsigned i)
Return sort of the i'th bound variable.
def num_vars(self)
Definition: z3py.py:1693
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 1628 of file z3py.py.

1628  def weight(self):
1629  """Return the weight annotation of `self`.
1630 
1631  >>> f = Function('f', IntSort(), IntSort())
1632  >>> x = Int('x')
1633  >>> q = ForAll(x, f(x) == 0)
1634  >>> q.weight()
1635  1
1636  >>> q = ForAll(x, f(x) == 0, weight=10)
1637  >>> q.weight()
1638  10
1639  """
1640  return int(Z3_get_quantifier_weight(self.ctx_ref(), self.ast))
1641 
unsigned Z3_API Z3_get_quantifier_weight(__in Z3_context c, __in Z3_ast a)
Obtain weight of quantifier.
def ctx_ref(self)
Definition: z3py.py:305
def weight(self)
Definition: z3py.py:1628