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 is_exists (self)
 
def is_lambda (self)
 
def __getitem__ (self, arg)
 
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 __rmul__ (self, other)
 
def __mul__ (self, other)
 
- Public Member Functions inherited from ExprRef
def sort_kind (self)
 
def __eq__ (self, other)
 
def __hash__ (self)
 
def __ne__ (self, other)
 
def params (self)
 
def decl (self)
 
def num_args (self)
 
def arg (self, idx)
 
- Public Member Functions inherited from AstRef
def __init__ (self, ast, ctx=None)
 
def __del__ (self)
 
def __deepcopy__ (self, memo={})
 
def __str__ (self)
 
def __repr__ (self)
 
def __nonzero__ (self)
 
def __bool__ (self)
 
def sexpr (self)
 
def ctx_ref (self)
 
def eq (self, other)
 
def translate (self, target)
 
def __copy__ (self)
 
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 1832 of file z3py.py.

Member Function Documentation

◆ __getitem__()

def __getitem__ (   self,
  arg 
)
Return the Z3 expression `self[arg]`.

Definition at line 1889 of file z3py.py.

1889  def __getitem__(self, arg):
1890  """Return the Z3 expression `self[arg]`.
1891  """
1892  if z3_debug():
1893  _z3_assert(self.is_lambda(), "quantifier should be a lambda expression")
1894  arg = self.sort().domain().cast(arg)
1895  return _to_expr_ref(Z3_mk_select(self.ctx_ref(), self.as_ast(), arg.as_ast()), self.ctx)
1896 
1897 

◆ as_ast()

def as_ast (   self)
Return a pointer to the corresponding C Z3_ast object.

Reimplemented from ExprRef.

Definition at line 1835 of file z3py.py.

1835  def as_ast(self):
1836  return self.ast
1837 

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

1952  def body(self):
1953  """Return the expression being quantified.
1954 
1955  >>> f = Function('f', IntSort(), IntSort())
1956  >>> x = Int('x')
1957  >>> q = ForAll(x, f(x) == 0)
1958  >>> q.body()
1959  f(Var(0)) == 0
1960  """
1961  return _to_expr_ref(Z3_get_quantifier_body(self.ctx_ref(), self.ast), self.ctx)
1962 

Referenced by QuantifierRef.children().

◆ 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]

Reimplemented from ExprRef.

Definition at line 2007 of file z3py.py.

2007  def children(self):
2008  """Return a list containing a single element self.body()
2009 
2010  >>> f = Function('f', IntSort(), IntSort())
2011  >>> x = Int('x')
2012  >>> q = ForAll(x, f(x) == 0)
2013  >>> q.children()
2014  [f(Var(0)) == 0]
2015  """
2016  return [ self.body() ]
2017 

◆ get_id()

def get_id (   self)
Return unique identifier for object. It can be used for hash-tables and maps.

Reimplemented from ExprRef.

Definition at line 1838 of file z3py.py.

1838  def get_id(self):
1839  return Z3_get_ast_id(self.ctx_ref(), self.as_ast())
1840 

◆ is_exists()

def is_exists (   self)
Return `True` if `self` is an existential quantifier.

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

Definition at line 1861 of file z3py.py.

1861  def is_exists(self):
1862  """Return `True` if `self` is an existential quantifier.
1863 
1864  >>> f = Function('f', IntSort(), IntSort())
1865  >>> x = Int('x')
1866  >>> q = ForAll(x, f(x) == 0)
1867  >>> q.is_exists()
1868  False
1869  >>> q = Exists(x, f(x) != 0)
1870  >>> q.is_exists()
1871  True
1872  """
1873  return Z3_is_quantifier_exists(self.ctx_ref(), self.ast)
1874 

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

1847  def is_forall(self):
1848  """Return `True` if `self` is a universal quantifier.
1849 
1850  >>> f = Function('f', IntSort(), IntSort())
1851  >>> x = Int('x')
1852  >>> q = ForAll(x, f(x) == 0)
1853  >>> q.is_forall()
1854  True
1855  >>> q = Exists(x, f(x) != 0)
1856  >>> q.is_forall()
1857  False
1858  """
1859  return Z3_is_quantifier_forall(self.ctx_ref(), self.ast)
1860 

◆ is_lambda()

def is_lambda (   self)
Return `True` if `self` is a lambda expression.

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

Definition at line 1875 of file z3py.py.

1875  def is_lambda(self):
1876  """Return `True` if `self` is a lambda expression.
1877 
1878  >>> f = Function('f', IntSort(), IntSort())
1879  >>> x = Int('x')
1880  >>> q = Lambda(x, f(x))
1881  >>> q.is_lambda()
1882  True
1883  >>> q = Exists(x, f(x) != 0)
1884  >>> q.is_lambda()
1885  False
1886  """
1887  return Z3_is_lambda(self.ctx_ref(), self.ast)
1888 

Referenced by QuantifierRef.__getitem__(), and QuantifierRef.sort().

◆ no_pattern()

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

Definition at line 1946 of file z3py.py.

1946  def no_pattern(self, idx):
1947  """Return a no-pattern."""
1948  if z3_debug():
1949  _z3_assert(idx < self.num_no_patterns(), "Invalid no-pattern idx")
1950  return _to_expr_ref(Z3_get_quantifier_no_pattern_ast(self.ctx_ref(), self.ast, idx), self.ctx)
1951 

◆ num_no_patterns()

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

Definition at line 1942 of file z3py.py.

1942  def num_no_patterns(self):
1943  """Return the number of no-patterns."""
1944  return Z3_get_quantifier_num_no_patterns(self.ctx_ref(), self.ast)
1945 

Referenced by QuantifierRef.no_pattern().

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

1912  def num_patterns(self):
1913  """Return the number of patterns (i.e., quantifier instantiation hints) in `self`.
1914 
1915  >>> f = Function('f', IntSort(), IntSort())
1916  >>> g = Function('g', IntSort(), IntSort())
1917  >>> x = Int('x')
1918  >>> q = ForAll(x, f(x) != g(x), patterns = [ f(x), g(x) ])
1919  >>> q.num_patterns()
1920  2
1921  """
1922  return int(Z3_get_quantifier_num_patterns(self.ctx_ref(), self.ast))
1923 

Referenced by QuantifierRef.pattern().

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

1963  def num_vars(self):
1964  """Return the number of variables bounded by this quantifier.
1965 
1966  >>> f = Function('f', IntSort(), IntSort(), IntSort())
1967  >>> x = Int('x')
1968  >>> y = Int('y')
1969  >>> q = ForAll([x, y], f(x, y) >= x)
1970  >>> q.num_vars()
1971  2
1972  """
1973  return int(Z3_get_quantifier_num_bound(self.ctx_ref(), self.ast))
1974 

Referenced by QuantifierRef.var_name(), and QuantifierRef.var_sort().

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

1924  def pattern(self, idx):
1925  """Return a pattern (i.e., quantifier instantiation hints) in `self`.
1926 
1927  >>> f = Function('f', IntSort(), IntSort())
1928  >>> g = Function('g', IntSort(), IntSort())
1929  >>> x = Int('x')
1930  >>> q = ForAll(x, f(x) != g(x), patterns = [ f(x), g(x) ])
1931  >>> q.num_patterns()
1932  2
1933  >>> q.pattern(0)
1934  f(Var(0))
1935  >>> q.pattern(1)
1936  g(Var(0))
1937  """
1938  if z3_debug():
1939  _z3_assert(idx < self.num_patterns(), "Invalid pattern idx")
1940  return PatternRef(Z3_get_quantifier_pattern_ast(self.ctx_ref(), self.ast, idx), self.ctx)
1941 

◆ sort()

def sort (   self)
Return the Boolean sort or sort of Lambda.

Reimplemented from BoolRef.

Definition at line 1841 of file z3py.py.

1841  def sort(self):
1842  """Return the Boolean sort or sort of Lambda."""
1843  if self.is_lambda():
1844  return _sort(self.ctx, self.as_ast())
1845  return BoolSort(self.ctx)
1846 

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

1975  def var_name(self, idx):
1976  """Return a string representing a name used when displaying the quantifier.
1977 
1978  >>> f = Function('f', IntSort(), IntSort(), IntSort())
1979  >>> x = Int('x')
1980  >>> y = Int('y')
1981  >>> q = ForAll([x, y], f(x, y) >= x)
1982  >>> q.var_name(0)
1983  'x'
1984  >>> q.var_name(1)
1985  'y'
1986  """
1987  if z3_debug():
1988  _z3_assert(idx < self.num_vars(), "Invalid variable idx")
1989  return _symbol2py(self.ctx, Z3_get_quantifier_bound_name(self.ctx_ref(), self.ast, idx))
1990 

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

1991  def var_sort(self, idx):
1992  """Return the sort of a bound variable.
1993 
1994  >>> f = Function('f', IntSort(), RealSort(), IntSort())
1995  >>> x = Int('x')
1996  >>> y = Real('y')
1997  >>> q = ForAll([x, y], f(x, y) >= x)
1998  >>> q.var_sort(0)
1999  Int
2000  >>> q.var_sort(1)
2001  Real
2002  """
2003  if z3_debug():
2004  _z3_assert(idx < self.num_vars(), "Invalid variable idx")
2005  return _to_sort_ref(Z3_get_quantifier_bound_sort(self.ctx_ref(), self.ast, idx), self.ctx)
2006 

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

1898  def weight(self):
1899  """Return the weight annotation of `self`.
1900 
1901  >>> f = Function('f', IntSort(), IntSort())
1902  >>> x = Int('x')
1903  >>> q = ForAll(x, f(x) == 0)
1904  >>> q.weight()
1905  1
1906  >>> q = ForAll(x, f(x) == 0, weight=10)
1907  >>> q.weight()
1908  10
1909  """
1910  return int(Z3_get_quantifier_weight(self.ctx_ref(), self.ast))
1911 
Z3_mk_select
Z3_ast Z3_API Z3_mk_select(Z3_context c, Z3_ast a, Z3_ast i)
Array read. The argument a is the array and i is the index of the array that gets read.
Z3_get_quantifier_pattern_ast
Z3_pattern Z3_API Z3_get_quantifier_pattern_ast(Z3_context c, Z3_ast a, unsigned i)
Return i'th pattern.
Z3_get_quantifier_num_no_patterns
unsigned Z3_API Z3_get_quantifier_num_no_patterns(Z3_context c, Z3_ast a)
Return number of no_patterns used in quantifier.
Z3_get_quantifier_num_patterns
unsigned Z3_API Z3_get_quantifier_num_patterns(Z3_context c, Z3_ast a)
Return number of patterns used in quantifier.
Z3_is_quantifier_forall
bool Z3_API Z3_is_quantifier_forall(Z3_context c, Z3_ast a)
Determine if an ast is a universal quantifier.
Z3_get_quantifier_weight
unsigned Z3_API Z3_get_quantifier_weight(Z3_context c, Z3_ast a)
Obtain weight of quantifier.
Z3_is_quantifier_exists
bool Z3_API Z3_is_quantifier_exists(Z3_context c, Z3_ast a)
Determine if ast is an existential quantifier.
Z3_get_ast_id
unsigned Z3_API Z3_get_ast_id(Z3_context c, Z3_ast t)
Return a unique identifier for t. The identifier is unique up to structural equality....
Z3_get_quantifier_bound_sort
Z3_sort Z3_API Z3_get_quantifier_bound_sort(Z3_context c, Z3_ast a, unsigned i)
Return sort of the i'th bound variable.
z3py.z3_debug
def z3_debug()
Definition: z3py.py:56
Z3_get_quantifier_no_pattern_ast
Z3_ast Z3_API Z3_get_quantifier_no_pattern_ast(Z3_context c, Z3_ast a, unsigned i)
Return i'th no_pattern.
Z3_is_lambda
bool Z3_API Z3_is_lambda(Z3_context c, Z3_ast a)
Determine if ast is a lambda expression.
Z3_get_quantifier_bound_name
Z3_symbol Z3_API Z3_get_quantifier_bound_name(Z3_context c, Z3_ast a, unsigned i)
Return symbol of the i'th bound variable.
Z3_get_quantifier_num_bound
unsigned Z3_API Z3_get_quantifier_num_bound(Z3_context c, Z3_ast a)
Return number of bound variables of quantifier.
Z3_get_quantifier_body
Z3_ast Z3_API Z3_get_quantifier_body(Z3_context c, Z3_ast a)
Return body of quantifier.
z3py.BoolSort
def BoolSort(ctx=None)
Definition: z3py.py:1553