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

Quantifiers. More...

+ Inheritance diagram for QuantifierRef:

Public Member Functions

def as_ast
 
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 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 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 1504 of file z3py.py.

Member Function Documentation

def as_ast (   self)

Definition at line 1507 of file z3py.py.

1508  def as_ast(self):
1509  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 1582 of file z3py.py.

Referenced by QuantifierRef.children().

1583  def body(self):
1584  """Return the expression being quantified.
1585 
1586  >>> f = Function('f', IntSort(), IntSort())
1587  >>> x = Int('x')
1588  >>> q = ForAll(x, f(x) == 0)
1589  >>> q.body()
1590  f(Var(0)) == 0
1591  """
1592  return _to_expr_ref(Z3_get_quantifier_body(self.ctx_ref(), self.ast), self.ctx)
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 1637 of file z3py.py.

1638  def children(self):
1639  """Return a list containing a single element self.body()
1640 
1641  >>> f = Function('f', IntSort(), IntSort())
1642  >>> x = Int('x')
1643  >>> q = ForAll(x, f(x) == 0)
1644  >>> q.children()
1645  [f(Var(0)) == 0]
1646  """
1647  return [ self.body() ]
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 1514 of file z3py.py.

1515  def is_forall(self):
1516  """Return `True` if `self` is a universal quantifier.
1517 
1518  >>> f = Function('f', IntSort(), IntSort())
1519  >>> x = Int('x')
1520  >>> q = ForAll(x, f(x) == 0)
1521  >>> q.is_forall()
1522  True
1523  >>> q = Exists(x, f(x) != 0)
1524  >>> q.is_forall()
1525  False
1526  """
1527  return Z3_is_quantifier_forall(self.ctx_ref(), self.ast)
def no_pattern (   self,
  idx 
)
Return a no-pattern.

Definition at line 1576 of file z3py.py.

1577  def no_pattern(self, idx):
1578  """Return a no-pattern."""
1579  if __debug__:
1580  _z3_assert(idx < self.num_no_patterns(), "Invalid no-pattern idx")
1581  return _to_expr_ref(Z3_get_quantifier_no_pattern_ast(self.ctx_ref(), self.ast, idx), self.ctx)
def num_no_patterns (   self)
Return the number of no-patterns.

Definition at line 1572 of file z3py.py.

Referenced by QuantifierRef.no_pattern().

1573  def num_no_patterns(self):
1574  """Return the number of no-patterns."""
1575  return Z3_get_quantifier_num_no_patterns(self.ctx_ref(), self.ast)
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 1542 of file z3py.py.

1543  def num_patterns(self):
1544  """Return the number of patterns (i.e., quantifier instantiation hints) in `self`.
1545 
1546  >>> f = Function('f', IntSort(), IntSort())
1547  >>> g = Function('g', IntSort(), IntSort())
1548  >>> x = Int('x')
1549  >>> q = ForAll(x, f(x) != g(x), patterns = [ f(x), g(x) ])
1550  >>> q.num_patterns()
1551  2
1552  """
1553  return int(Z3_get_quantifier_num_patterns(self.ctx_ref(), self.ast))
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 1593 of file z3py.py.

1594  def num_vars(self):
1595  """Return the number of variables bounded by this quantifier.
1596 
1597  >>> f = Function('f', IntSort(), IntSort(), IntSort())
1598  >>> x = Int('x')
1599  >>> y = Int('y')
1600  >>> q = ForAll([x, y], f(x, y) >= x)
1601  >>> q.num_vars()
1602  2
1603  """
1604  return int(Z3_get_quantifier_num_bound(self.ctx_ref(), self.ast))
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 1554 of file z3py.py.

1555  def pattern(self, idx):
1556  """Return a pattern (i.e., quantifier instantiation hints) in `self`.
1557 
1558  >>> f = Function('f', IntSort(), IntSort())
1559  >>> g = Function('g', IntSort(), IntSort())
1560  >>> x = Int('x')
1561  >>> q = ForAll(x, f(x) != g(x), patterns = [ f(x), g(x) ])
1562  >>> q.num_patterns()
1563  2
1564  >>> q.pattern(0)
1565  f(Var(0))
1566  >>> q.pattern(1)
1567  g(Var(0))
1568  """
1569  if __debug__:
1570  _z3_assert(idx < self.num_patterns(), "Invalid pattern idx")
1571  return PatternRef(Z3_get_quantifier_pattern_ast(self.ctx_ref(), self.ast, idx), self.ctx)
def sort (   self)
Return the Boolean sort.

Definition at line 1510 of file z3py.py.

1511  def sort(self):
1512  """Return the Boolean sort."""
1513  return BoolSort(self.ctx)
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 1605 of file z3py.py.

1606  def var_name(self, idx):
1607  """Return a string representing a name used when displaying the quantifier.
1608 
1609  >>> f = Function('f', IntSort(), IntSort(), IntSort())
1610  >>> x = Int('x')
1611  >>> y = Int('y')
1612  >>> q = ForAll([x, y], f(x, y) >= x)
1613  >>> q.var_name(0)
1614  'x'
1615  >>> q.var_name(1)
1616  'y'
1617  """
1618  if __debug__:
1619  _z3_assert(idx < self.num_vars(), "Invalid variable idx")
1620  return _symbol2py(self.ctx, Z3_get_quantifier_bound_name(self.ctx_ref(), self.ast, idx))
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 1621 of file z3py.py.

1622  def var_sort(self, idx):
1623  """Return the sort of a bound variable.
1624 
1625  >>> f = Function('f', IntSort(), RealSort(), IntSort())
1626  >>> x = Int('x')
1627  >>> y = Real('y')
1628  >>> q = ForAll([x, y], f(x, y) >= x)
1629  >>> q.var_sort(0)
1630  Int
1631  >>> q.var_sort(1)
1632  Real
1633  """
1634  if __debug__:
1635  _z3_assert(idx < self.num_vars(), "Invalid variable idx")
1636  return SortRef(Z3_get_quantifier_bound_sort(self.ctx_ref(), self.ast, idx), self.ctx)
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 1528 of file z3py.py.

1529  def weight(self):
1530  """Return the weight annotation of `self`.
1531 
1532  >>> f = Function('f', IntSort(), IntSort())
1533  >>> x = Int('x')
1534  >>> q = ForAll(x, f(x) == 0)
1535  >>> q.weight()
1536  1
1537  >>> q = ForAll(x, f(x) == 0, weight=10)
1538  >>> q.weight()
1539  10
1540  """
1541  return int(Z3_get_quantifier_weight(self.ctx_ref(), self.ast))