Z3
 
Loading...
Searching...
No Matches
QuantifierRef Class Reference

Quantifiers. More...

+ Inheritance diagram for QuantifierRef:

Public Member Functions

 as_ast (self)
 
 get_id (self)
 
 sort (self)
 
 is_forall (self)
 
 is_exists (self)
 
 is_lambda (self)
 
 __getitem__ (self, arg)
 
 weight (self)
 
 skolem_id (self)
 
 qid (self)
 
 num_patterns (self)
 
 pattern (self, idx)
 
 num_no_patterns (self)
 
 no_pattern (self, idx)
 
 body (self)
 
 num_vars (self)
 
 var_name (self, idx)
 
 var_sort (self, idx)
 
 children (self)
 
- Public Member Functions inherited from BoolRef
 __add__ (self, other)
 
 __radd__ (self, other)
 
 __rmul__ (self, other)
 
 __mul__ (self, other)
 
 __and__ (self, other)
 
 __or__ (self, other)
 
 __xor__ (self, other)
 
 __invert__ (self)
 
- Public Member Functions inherited from ExprRef
 sort_kind (self)
 
 __eq__ (self, other)
 
 __hash__ (self)
 
 __ne__ (self, other)
 
 params (self)
 
 decl (self)
 
 num_args (self)
 
 arg (self, idx)
 
 from_string (self, s)
 
 serialize (self)
 
- Public Member Functions inherited from AstRef
 __init__ (self, ast, ctx=None)
 
 __del__ (self)
 
 __deepcopy__ (self, memo={})
 
 __str__ (self)
 
 __repr__ (self)
 
 __nonzero__ (self)
 
 __bool__ (self)
 
 sexpr (self)
 
 ctx_ref (self)
 
 eq (self, other)
 
 translate (self, target)
 
 __copy__ (self)
 
 hash (self)
 
- Public Member Functions inherited from Z3PPObject
 use_pp (self)
 

Data Fields

 ctx
 
 ast
 
- Data Fields inherited from BoolRef
 ctx
 
- Data Fields inherited from ExprRef
 ctx
 
- Data Fields inherited from AstRef
 ast = ast
 
 ctx = _get_ctx(ctx)
 

Additional Inherited Members

- Protected Member Functions inherited from Z3PPObject
 _repr_html_ (self)
 

Detailed Description

Quantifiers.

Universally and Existentially quantified formulas.

Definition at line 2028 of file z3py.py.

Member Function Documentation

◆ __getitem__()

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

Definition at line 2085 of file z3py.py.

2085 def __getitem__(self, arg):
2086 """Return the Z3 expression `self[arg]`.
2087 """
2088 if z3_debug():
2089 _z3_assert(self.is_lambda(), "quantifier should be a lambda expression")
2090 return _array_select(self, arg)
2091

◆ as_ast()

◆ body()

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

2156 def body(self):
2157 """Return the expression being quantified.
2158
2159 >>> f = Function('f', IntSort(), IntSort())
2160 >>> x = Int('x')
2161 >>> q = ForAll(x, f(x) == 0)
2162 >>> q.body()
2163 f(Var(0)) == 0
2164 """
2165 return _to_expr_ref(Z3_get_quantifier_body(self.ctx_ref(), self.ast), self.ctx)
2166
Z3_ast Z3_API Z3_get_quantifier_body(Z3_context c, Z3_ast a)
Return body of quantifier.

Referenced by QuantifierRef.children().

◆ children()

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

2211 def children(self):
2212 """Return a list containing a single element self.body()
2213
2214 >>> f = Function('f', IntSort(), IntSort())
2215 >>> x = Int('x')
2216 >>> q = ForAll(x, f(x) == 0)
2217 >>> q.children()
2218 [f(Var(0)) == 0]
2219 """
2220 return [self.body()]
2221
2222

◆ get_id()

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

Reimplemented from ExprRef.

Definition at line 2034 of file z3py.py.

2034 def get_id(self):
2035 return Z3_get_ast_id(self.ctx_ref(), self.as_ast())
2036
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()

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

2057 def is_exists(self):
2058 """Return `True` if `self` is an existential quantifier.
2059
2060 >>> f = Function('f', IntSort(), IntSort())
2061 >>> x = Int('x')
2062 >>> q = ForAll(x, f(x) == 0)
2063 >>> q.is_exists()
2064 False
2065 >>> q = Exists(x, f(x) != 0)
2066 >>> q.is_exists()
2067 True
2068 """
2069 return Z3_is_quantifier_exists(self.ctx_ref(), self.ast)
2070
bool Z3_API Z3_is_quantifier_exists(Z3_context c, Z3_ast a)
Determine if ast is an existential quantifier.

◆ is_forall()

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

2043 def is_forall(self):
2044 """Return `True` if `self` is a universal quantifier.
2045
2046 >>> f = Function('f', IntSort(), IntSort())
2047 >>> x = Int('x')
2048 >>> q = ForAll(x, f(x) == 0)
2049 >>> q.is_forall()
2050 True
2051 >>> q = Exists(x, f(x) != 0)
2052 >>> q.is_forall()
2053 False
2054 """
2055 return Z3_is_quantifier_forall(self.ctx_ref(), self.ast)
2056
bool Z3_API Z3_is_quantifier_forall(Z3_context c, Z3_ast a)
Determine if an ast is a universal quantifier.

◆ is_lambda()

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

2071 def is_lambda(self):
2072 """Return `True` if `self` is a lambda expression.
2073
2074 >>> f = Function('f', IntSort(), IntSort())
2075 >>> x = Int('x')
2076 >>> q = Lambda(x, f(x))
2077 >>> q.is_lambda()
2078 True
2079 >>> q = Exists(x, f(x) != 0)
2080 >>> q.is_lambda()
2081 False
2082 """
2083 return Z3_is_lambda(self.ctx_ref(), self.ast)
2084
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()

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

Definition at line 2150 of file z3py.py.

2150 def no_pattern(self, idx):
2151 """Return a no-pattern."""
2152 if z3_debug():
2153 _z3_assert(idx < self.num_no_patterns(), "Invalid no-pattern idx")
2154 return _to_expr_ref(Z3_get_quantifier_no_pattern_ast(self.ctx_ref(), self.ast, idx), self.ctx)
2155
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()

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

Definition at line 2146 of file z3py.py.

2146 def num_no_patterns(self):
2147 """Return the number of no-patterns."""
2148 return Z3_get_quantifier_num_no_patterns(self.ctx_ref(), self.ast)
2149
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()

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

2116 def num_patterns(self):
2117 """Return the number of patterns (i.e., quantifier instantiation hints) in `self`.
2118
2119 >>> f = Function('f', IntSort(), IntSort())
2120 >>> g = Function('g', IntSort(), IntSort())
2121 >>> x = Int('x')
2122 >>> q = ForAll(x, f(x) != g(x), patterns = [ f(x), g(x) ])
2123 >>> q.num_patterns()
2124 2
2125 """
2126 return int(Z3_get_quantifier_num_patterns(self.ctx_ref(), self.ast))
2127
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()

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

2167 def num_vars(self):
2168 """Return the number of variables bounded by this quantifier.
2169
2170 >>> f = Function('f', IntSort(), IntSort(), IntSort())
2171 >>> x = Int('x')
2172 >>> y = Int('y')
2173 >>> q = ForAll([x, y], f(x, y) >= x)
2174 >>> q.num_vars()
2175 2
2176 """
2177 return int(Z3_get_quantifier_num_bound(self.ctx_ref(), self.ast))
2178
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()

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

2128 def pattern(self, idx):
2129 """Return a pattern (i.e., quantifier instantiation hints) in `self`.
2130
2131 >>> f = Function('f', IntSort(), IntSort())
2132 >>> g = Function('g', IntSort(), IntSort())
2133 >>> x = Int('x')
2134 >>> q = ForAll(x, f(x) != g(x), patterns = [ f(x), g(x) ])
2135 >>> q.num_patterns()
2136 2
2137 >>> q.pattern(0)
2138 f(Var(0))
2139 >>> q.pattern(1)
2140 g(Var(0))
2141 """
2142 if z3_debug():
2143 _z3_assert(idx < self.num_patterns(), "Invalid pattern idx")
2144 return PatternRef(Z3_get_quantifier_pattern_ast(self.ctx_ref(), self.ast, idx), self.ctx)
2145
Z3_pattern Z3_API Z3_get_quantifier_pattern_ast(Z3_context c, Z3_ast a, unsigned i)
Return i'th pattern.

◆ qid()

qid ( self)
Return the quantifier id of `self`.

Definition at line 2111 of file z3py.py.

2111 def qid(self):
2112 """Return the quantifier id of `self`.
2113 """
2114 return _symbol2py(self.ctx, Z3_get_quantifier_id(self.ctx_ref(), self.ast))
2115
Z3_symbol Z3_API Z3_get_quantifier_id(Z3_context c, Z3_ast a)
Obtain id of quantifier.

◆ skolem_id()

skolem_id ( self)
Return the skolem id of `self`.

Definition at line 2106 of file z3py.py.

2106 def skolem_id(self):
2107 """Return the skolem id of `self`.
2108 """
2109 return _symbol2py(self.ctx, Z3_get_quantifier_skolem_id(self.ctx_ref(), self.ast))
2110
Z3_symbol Z3_API Z3_get_quantifier_skolem_id(Z3_context c, Z3_ast a)
Obtain skolem id of quantifier.

◆ sort()

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

Reimplemented from BoolRef.

Definition at line 2037 of file z3py.py.

2037 def sort(self):
2038 """Return the Boolean sort or sort of Lambda."""
2039 if self.is_lambda():
2040 return _sort(self.ctx, self.as_ast())
2041 return BoolSort(self.ctx)
2042

Referenced by ArrayRef.domain(), ArrayRef.domain_n(), ArithRef.is_int(), ArithRef.is_real(), ArrayRef.range(), BitVecRef.size(), and ExprRef.sort_kind().

◆ var_name()

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

2179 def var_name(self, idx):
2180 """Return a string representing a name used when displaying the quantifier.
2181
2182 >>> f = Function('f', IntSort(), IntSort(), IntSort())
2183 >>> x = Int('x')
2184 >>> y = Int('y')
2185 >>> q = ForAll([x, y], f(x, y) >= x)
2186 >>> q.var_name(0)
2187 'x'
2188 >>> q.var_name(1)
2189 'y'
2190 """
2191 if z3_debug():
2192 _z3_assert(idx < self.num_vars(), "Invalid variable idx")
2193 return _symbol2py(self.ctx, Z3_get_quantifier_bound_name(self.ctx_ref(), self.ast, idx))
2194
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()

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

2195 def var_sort(self, idx):
2196 """Return the sort of a bound variable.
2197
2198 >>> f = Function('f', IntSort(), RealSort(), IntSort())
2199 >>> x = Int('x')
2200 >>> y = Real('y')
2201 >>> q = ForAll([x, y], f(x, y) >= x)
2202 >>> q.var_sort(0)
2203 Int
2204 >>> q.var_sort(1)
2205 Real
2206 """
2207 if z3_debug():
2208 _z3_assert(idx < self.num_vars(), "Invalid variable idx")
2209 return _to_sort_ref(Z3_get_quantifier_bound_sort(self.ctx_ref(), self.ast, idx), self.ctx)
2210
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()

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

2092 def weight(self):
2093 """Return the weight annotation of `self`.
2094
2095 >>> f = Function('f', IntSort(), IntSort())
2096 >>> x = Int('x')
2097 >>> q = ForAll(x, f(x) == 0)
2098 >>> q.weight()
2099 1
2100 >>> q = ForAll(x, f(x) == 0, weight=10)
2101 >>> q.weight()
2102 10
2103 """
2104 return int(Z3_get_quantifier_weight(self.ctx_ref(), self.ast))
2105
unsigned Z3_API Z3_get_quantifier_weight(Z3_context c, Z3_ast a)
Obtain weight of quantifier.

Field Documentation

◆ ast

◆ ctx

ctx

Definition at line 2040 of file z3py.py.

Referenced by ArithRef.__add__(), BitVecRef.__add__(), BitVecRef.__and__(), FuncDeclRef.__call__(), AstMap.__contains__(), AstRef.__copy__(), AstVector.__copy__(), FuncInterp.__copy__(), Goal.__copy__(), ModelRef.__copy__(), AstMap.__deepcopy__(), AstRef.__deepcopy__(), AstVector.__deepcopy__(), Datatype.__deepcopy__(), FuncEntry.__deepcopy__(), FuncInterp.__deepcopy__(), Goal.__deepcopy__(), ModelRef.__deepcopy__(), ParamDescrsRef.__deepcopy__(), ParamsRef.__deepcopy__(), Statistics.__deepcopy__(), AstMap.__del__(), AstRef.__del__(), AstVector.__del__(), Context.__del__(), FuncEntry.__del__(), FuncInterp.__del__(), Goal.__del__(), ModelRef.__del__(), ParamDescrsRef.__del__(), ParamsRef.__del__(), ScopedConstructor.__del__(), ScopedConstructorList.__del__(), Solver.__del__(), Statistics.__del__(), ArithRef.__div__(), BitVecRef.__div__(), ExprRef.__eq__(), ArithRef.__ge__(), BitVecRef.__ge__(), AstMap.__getitem__(), AstVector.__getitem__(), ModelRef.__getitem__(), Statistics.__getitem__(), ArithRef.__gt__(), BitVecRef.__gt__(), BitVecRef.__invert__(), ArithRef.__le__(), BitVecRef.__le__(), AstMap.__len__(), AstVector.__len__(), ModelRef.__len__(), Statistics.__len__(), BitVecRef.__lshift__(), ArithRef.__lt__(), BitVecRef.__lt__(), ArithRef.__mod__(), BitVecRef.__mod__(), ArithRef.__mul__(), BitVecRef.__mul__(), BoolRef.__mul__(), ExprRef.__ne__(), ArithRef.__neg__(), BitVecRef.__neg__(), BitVecRef.__or__(), ArithRef.__pow__(), ArithRef.__radd__(), BitVecRef.__radd__(), BitVecRef.__rand__(), ArithRef.__rdiv__(), BitVecRef.__rdiv__(), AstMap.__repr__(), ParamDescrsRef.__repr__(), ParamsRef.__repr__(), Statistics.__repr__(), BitVecRef.__rlshift__(), ArithRef.__rmod__(), BitVecRef.__rmod__(), ArithRef.__rmul__(), BitVecRef.__rmul__(), BitVecRef.__ror__(), ArithRef.__rpow__(), BitVecRef.__rrshift__(), BitVecRef.__rshift__(), ArithRef.__rsub__(), BitVecRef.__rsub__(), BitVecRef.__rxor__(), AstMap.__setitem__(), AstVector.__setitem__(), ArithRef.__sub__(), BitVecRef.__sub__(), BitVecRef.__xor__(), DatatypeSortRef.accessor(), ExprRef.arg(), FuncEntry.arg_value(), FuncInterp.arity(), Goal.as_expr(), Solver.assert_and_track(), Goal.assert_exprs(), Solver.assert_exprs(), QuantifierRef.body(), Solver.check(), Goal.convert_model(), AstRef.ctx_ref(), ExprRef.decl(), ModelRef.decls(), ArrayRef.default(), RatNumRef.denominator(), Goal.depth(), Goal.dimacs(), FuncDeclRef.domain(), ArraySortRef.domain_n(), FuncInterp.else_value(), FuncInterp.entry(), AstMap.erase(), ModelRef.eval(), Goal.get(), ParamDescrsRef.get_documentation(), ModelRef.get_interp(), Statistics.get_key_value(), ParamDescrsRef.get_kind(), ParamDescrsRef.get_name(), ModelRef.get_sort(), ModelRef.get_universe(), Goal.inconsistent(), AstMap.keys(), Statistics.keys(), Solver.model(), SortRef.name(), QuantifierRef.no_pattern(), FuncEntry.num_args(), FuncInterp.num_entries(), Solver.num_scopes(), ModelRef.num_sorts(), FuncDeclRef.params(), QuantifierRef.pattern(), AlgebraicNumRef.poly(), Solver.pop(), Goal.prec(), AstVector.push(), Solver.push(), QuantifierRef.qid(), ArraySortRef.range(), FuncDeclRef.range(), DatatypeSortRef.recognizer(), Context.ref(), AstMap.reset(), Solver.reset(), AstVector.resize(), ParamsRef.set(), Solver.set(), AstVector.sexpr(), Goal.sexpr(), ModelRef.sexpr(), Goal.size(), ParamDescrsRef.size(), QuantifierRef.skolem_id(), AstRef.translate(), AstVector.translate(), Goal.translate(), ModelRef.translate(), ParamsRef.validate(), FuncEntry.value(), QuantifierRef.var_name(), and QuantifierRef.var_sort().