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

Quantifiers. More...

+ Inheritance diagram for QuantifierRef:

Public Member Functions

def as_ast
 
def get_id
 
def sort
 
def is_forall
 
def weight
 
def num_patterns
 
def pattern
 
def num_no_patterns
 
def no_pattern
 
def body
 
def num_vars
 
def var_name
 
def var_sort
 
def children
 
- Public Member Functions inherited from BoolRef
def sort
 
- Public Member Functions inherited from ExprRef
def as_ast
 
def get_id
 
def sort
 
def sort_kind
 
def __eq__
 
def __ne__
 
def decl
 
def num_args
 
def arg
 
def children
 
- 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
 

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.

1605  def as_ast(self):
1606  return self.ast
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().

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

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

Definition at line 1607 of file z3py.py.

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

1615  def is_forall(self):
1616  """Return `True` if `self` is a universal quantifier.
1617 
1618  >>> f = Function('f', IntSort(), IntSort())
1619  >>> x = Int('x')
1620  >>> q = ForAll(x, f(x) == 0)
1621  >>> q.is_forall()
1622  True
1623  >>> q = Exists(x, f(x) != 0)
1624  >>> q.is_forall()
1625  False
1626  """
1627  return Z3_is_quantifier_forall(self.ctx_ref(), self.ast)
def ctx_ref
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.

1677  def no_pattern(self, idx):
1678  """Return a no-pattern."""
1679  if __debug__:
1680  _z3_assert(idx < self.num_no_patterns(), "Invalid no-pattern idx")
1681  return _to_expr_ref(Z3_get_quantifier_no_pattern_ast(self.ctx_ref(), self.ast, idx), self.ctx)
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
Definition: z3py.py:1672
def ctx_ref
Definition: z3py.py:305
def num_no_patterns (   self)
Return the number of no-patterns.

Definition at line 1672 of file z3py.py.

Referenced by QuantifierRef.no_pattern().

1673  def num_no_patterns(self):
1674  """Return the number of no-patterns."""
1675  return Z3_get_quantifier_num_no_patterns(self.ctx_ref(), self.ast)
def num_no_patterns
Definition: z3py.py:1672
def ctx_ref
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.

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

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

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

Definition at line 1610 of file z3py.py.

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

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

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

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