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 | 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 | params (self)
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 | __deepcopy__ (self, memo={})
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 | __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 1952 of file z3py.py.

## Member Function Documentation

## ◆ __getitem__()

def __getitem__ | ( |  | self,
|  |  | arg
| ) |  |

    Return the Z3 expression `self[arg]`.

Definition at line 2009 of file z3py.py.

2009 def __getitem__(self, arg):
2010 """Return the Z3 expression `self[arg]`.
2011 """
2012 if z3_debug():
2013 _z3_assert(self.is_lambda(), "quantifier should be a lambda expression")
2014 arg = self.sort().domain().cast(arg)
2015 return _to_expr_ref(Z3_mk_select(self.ctx_ref(), self.as_ast(), arg.as_ast()), self.ctx)
2016
z3py.z3_debug
def z3_debug()
Definition: z3py.py:64
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.

## ◆ as_ast()

def as_ast | ( |  | self | ) |

    Return a pointer to the corresponding C Z3_ast object.

Reimplemented from ExprRef.

Definition at line 1955 of file z3py.py.

1955 def as_ast(self):
1956 return self.ast
1957

Referenced by AstRef.__del__(), SeqRef.__ge__(), QuantifierRef.__getitem__(), ArrayRef.__getitem__(), SeqRef.__getitem__(), SeqRef.__gt__(), BitVecRef.__invert__(), SeqRef.__le__(), SeqRef.__lt__(), ArithRef.__neg__(), BitVecRef.__neg__(), AlgebraicNumRef.approx(), ExprRef.arg(), IntNumRef.as_binary_string(), BitVecNumRef.as_binary_string(), RatNumRef.as_decimal(), AlgebraicNumRef.as_decimal(), IntNumRef.as_string(), RatNumRef.as_string(), BitVecNumRef.as_string(), FiniteDomainRef.as_string(), FiniteDomainNumRef.as_string(), FPRef.as_string(), FPRMRef.as_string(), FPNumRef.as_string(), SeqRef.as_string(), SeqRef.at(), ExprRef.decl(), ArrayRef.default(), RatNumRef.denominator(), AstRef.eq(), FPNumRef.exponent(), FPNumRef.exponent_as_bv(), FPNumRef.exponent_as_long(), AstRef.get_id(), SortRef.get_id(), FuncDeclRef.get_id(), ExprRef.get_id(), PatternRef.get_id(), QuantifierRef.get_id(), AstRef.hash(), AlgebraicNumRef.index(), SeqRef.is_string(), SeqRef.is_string_value(), FPNumRef.isInf(), FPNumRef.isNaN(), FPNumRef.isNegative(), FPNumRef.isNormal(), FPNumRef.isPositive(), FPNumRef.isSubnormal(), FPNumRef.isZero(), ExprRef.num_args(), RatNumRef.numerator(), AlgebraicNumRef.poly(), AstRef.sexpr(), FPNumRef.sign(), FPNumRef.sign_as_bv(), FPNumRef.significand(), FPNumRef.significand_as_bv(), FPNumRef.significand_as_long(), ExprRef.sort(), BoolRef.sort(), QuantifierRef.sort(), ArithRef.sort(), BitVecRef.sort(), ArrayRef.sort(), DatatypeRef.sort(), FiniteDomainRef.sort(), FPRef.sort(), SeqRef.sort(), and AstRef.translate().

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

2071 def body(self):
2072 """Return the expression being quantified.
2073
2074 >>> f = Function('f', IntSort(), IntSort())
2075 >>> x = Int('x')
2076 >>> q = ForAll(x, f(x) == 0)
2077 >>> q.body()
2078 f(Var(0)) == 0
2079 """
2080 return _to_expr_ref(Z3_get_quantifier_body(self.ctx_ref(), self.ast), self.ctx)
2081
z3py.IntSort
def IntSort(ctx=None)
Definition: z3py.py:3100
z3py.ForAll
def ForAll(vs, body, weight=1, qid="", skid="", patterns=[], no_patterns=[])
Definition: z3py.py:2187
z3py.Function
def Function(name, *sig)
Definition: z3py.py:860
z3py.Var
def Var(idx, s)
Definition: z3py.py:1438
z3py.Int
def Int(name, ctx=None)
Definition: z3py.py:3210
Z3_get_quantifier_body
Z3_ast Z3_API Z3_get_quantifier_body(Z3_context c, Z3_ast a)
Return body of quantifier.

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

2126 def children(self):
2127 """Return a list containing a single element self.body()
2128
2129 >>> f = Function('f', IntSort(), IntSort())
2130 >>> x = Int('x')
2131 >>> q = ForAll(x, f(x) == 0)
2132 >>> q.children()
2133 [f(Var(0)) == 0]
2134 """
2135 return [self.body()]
2136
2137

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

1958 def get_id(self):
1959 return Z3_get_ast_id(self.ctx_ref(), self.as_ast())
1960
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....

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

1981 def is_exists(self):
1982 """Return `True` if `self` is an existential quantifier.
1983
1984 >>> f = Function('f', IntSort(), IntSort())
1985 >>> x = Int('x')
1986 >>> q = ForAll(x, f(x) == 0)
1987 >>> q.is_exists()
1988 False
1989 >>> q = Exists(x, f(x) != 0)
1990 >>> q.is_exists()
1991 True
1992 """
1993 return Z3_is_quantifier_exists(self.ctx_ref(), self.ast)
1994
z3py.Exists
def Exists(vs, body, weight=1, qid="", skid="", patterns=[], no_patterns=[])
Definition: z3py.py:2205
Z3_is_quantifier_exists
bool Z3_API Z3_is_quantifier_exists(Z3_context c, Z3_ast a)
Determine if ast is an existential quantifier.

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

1967 def is_forall(self):
1968 """Return `True` if `self` is a universal quantifier.
1969
1970 >>> f = Function('f', IntSort(), IntSort())
1971 >>> x = Int('x')
1972 >>> q = ForAll(x, f(x) == 0)
1973 >>> q.is_forall()
1974 True
1975 >>> q = Exists(x, f(x) != 0)
1976 >>> q.is_forall()
1977 False
1978 """
1979 return Z3_is_quantifier_forall(self.ctx_ref(), self.ast)
1980
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.

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

1995 def is_lambda(self):
1996 """Return `True` if `self` is a lambda expression.
1997
1998 >>> f = Function('f', IntSort(), IntSort())
1999 >>> x = Int('x')
2000 >>> q = Lambda(x, f(x))
2001 >>> q.is_lambda()
2002 True
2003 >>> q = Exists(x, f(x) != 0)
2004 >>> q.is_lambda()
2005 False
2006 """
2007 return Z3_is_lambda(self.ctx_ref(), self.ast)
2008
z3py.Lambda
def Lambda(vs, body)
Definition: z3py.py:2226
Z3_is_lambda
bool Z3_API Z3_is_lambda(Z3_context c, Z3_ast a)
Determine if ast is a lambda expression.

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

## ◆ no_pattern()

def no_pattern | ( |  | self,
|  |  | idx
| ) |  |

    Return a no-pattern.

Definition at line 2065 of file z3py.py.

2065 def no_pattern(self, idx):
2066 """Return a no-pattern."""
2067 if z3_debug():
2068 _z3_assert(idx < self.num_no_patterns(), "Invalid no-pattern idx")
2069 return _to_expr_ref(Z3_get_quantifier_no_pattern_ast(self.ctx_ref(), self.ast, idx), self.ctx)
2070
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.

## ◆ num_no_patterns()

def num_no_patterns | ( |  | self | ) |

    Return the number of no-patterns.

Definition at line 2061 of file z3py.py.

2061 def num_no_patterns(self):
2062 """Return the number of no-patterns."""
2063 return Z3_get_quantifier_num_no_patterns(self.ctx_ref(), self.ast)
2064
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.

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

2031 def num_patterns(self):
2032 """Return the number of patterns (i.e., quantifier instantiation hints) in `self`.
2033
2034 >>> f = Function('f', IntSort(), IntSort())
2035 >>> g = Function('g', IntSort(), IntSort())
2036 >>> x = Int('x')
2037 >>> q = ForAll(x, f(x) != g(x), patterns = [ f(x), g(x) ])
2038 >>> q.num_patterns()
2039 2
2040 """
2041 return int(Z3_get_quantifier_num_patterns(self.ctx_ref(), self.ast))
2042
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.

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

2082 def num_vars(self):
2083 """Return the number of variables bounded by this quantifier.
2084
2085 >>> f = Function('f', IntSort(), IntSort(), IntSort())
2086 >>> x = Int('x')
2087 >>> y = Int('y')
2088 >>> q = ForAll([x, y], f(x, y) >= x)
2089 >>> q.num_vars()
2090 2
2091 """
2092 return int(Z3_get_quantifier_num_bound(self.ctx_ref(), self.ast))
2093
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.

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

2043 def pattern(self, idx):
2044 """Return a pattern (i.e., quantifier instantiation hints) in `self`.
2045
2046 >>> f = Function('f', IntSort(), IntSort())
2047 >>> g = Function('g', IntSort(), IntSort())
2048 >>> x = Int('x')
2049 >>> q = ForAll(x, f(x) != g(x), patterns = [ f(x), g(x) ])
2050 >>> q.num_patterns()
2051 2
2052 >>> q.pattern(0)
2053 f(Var(0))
2054 >>> q.pattern(1)
2055 g(Var(0))
2056 """
2057 if z3_debug():
2058 _z3_assert(idx < self.num_patterns(), "Invalid pattern idx")
2059 return PatternRef(Z3_get_quantifier_pattern_ast(self.ctx_ref(), self.ast, idx), self.ctx)
2060
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.

## ◆ sort()

def sort | ( |  | self | ) |

    Return the Boolean sort or sort of Lambda.

Reimplemented from BoolRef.

Definition at line 1961 of file z3py.py.

1961 def sort(self):
1962 """Return the Boolean sort or sort of Lambda."""
1963 if self.is_lambda():
1964 return _sort(self.ctx, self.as_ast())
1965 return BoolSort(self.ctx)
1966
z3py.BoolSort
def BoolSort(ctx=None)
Definition: z3py.py:1655

Referenced by QuantifierRef.__getitem__(), FPNumRef.as_string(), ArrayRef.domain(), FPRef.ebits(), ArithRef.is_int(), ArithRef.is_real(), ArrayRef.range(), FPRef.sbits(), BitVecRef.size(), and ExprRef.sort_kind().

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

2094 def var_name(self, idx):
2095 """Return a string representing a name used when displaying the quantifier.
2096
2097 >>> f = Function('f', IntSort(), IntSort(), IntSort())
2098 >>> x = Int('x')
2099 >>> y = Int('y')
2100 >>> q = ForAll([x, y], f(x, y) >= x)
2101 >>> q.var_name(0)
2102 'x'
2103 >>> q.var_name(1)
2104 'y'
2105 """
2106 if z3_debug():
2107 _z3_assert(idx < self.num_vars(), "Invalid variable idx")
2108 return _symbol2py(self.ctx, Z3_get_quantifier_bound_name(self.ctx_ref(), self.ast, idx))
2109
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.

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

2110 def var_sort(self, idx):
2111 """Return the sort of a bound variable.
2112
2113 >>> f = Function('f', IntSort(), RealSort(), IntSort())
2114 >>> x = Int('x')
2115 >>> y = Real('y')
2116 >>> q = ForAll([x, y], f(x, y) >= x)
2117 >>> q.var_sort(0)
2118 Int
2119 >>> q.var_sort(1)
2120 Real
2121 """
2122 if z3_debug():
2123 _z3_assert(idx < self.num_vars(), "Invalid variable idx")
2124 return _to_sort_ref(Z3_get_quantifier_bound_sort(self.ctx_ref(), self.ast, idx), self.ctx)
2125
z3py.RealSort
def RealSort(ctx=None)
Definition: z3py.py:3117
z3py.Real
def Real(name, ctx=None)
Definition: z3py.py:3263
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.

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

2017 def weight(self):
2018 """Return the weight annotation of `self`.
2019
2020 >>> f = Function('f', IntSort(), IntSort())
2021 >>> x = Int('x')
2022 >>> q = ForAll(x, f(x) == 0)
2023 >>> q.weight()
2024 1
2025 >>> q = ForAll(x, f(x) == 0, weight=10)
2026 >>> q.weight()
2027 10
2028 """
2029 return int(Z3_get_quantifier_weight(self.ctx_ref(), self.ast))
2030
Z3_get_quantifier_weight
unsigned Z3_API Z3_get_quantifier_weight(Z3_context c, Z3_ast a)
Obtain weight of quantifier.