Z3
 
Loading...
Searching...
No Matches
Public Member Functions | Data Fields
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)
 
 py_value (self)
 
- Public Member Functions inherited from ExprRef
 sort_kind (self)
 
 __eq__ (self, other)
 
 __hash__ (self)
 
 __ne__ (self, other)
 
 params (self)
 
 decl (self)
 
 kind (self)
 
 num_args (self)
 
 arg (self, idx)
 
 update (self, *args)
 
 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
 
 ast
 
- Data Fields inherited from AstRef
 ast
 
 ctx
 

Additional Inherited Members

- Protected Member Functions inherited from Z3PPObject
 _repr_html_ (self)
 

Detailed Description

Quantifiers.

Universally and Existentially quantified formulas.

Definition at line 2124 of file z3py.py.

Member Function Documentation

◆ __getitem__()

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

Definition at line 2181 of file z3py.py.

2181 def __getitem__(self, arg):
2182 """Return the Z3 expression `self[arg]`.
2183 """
2184 if z3_debug():
2185 _z3_assert(self.is_lambda(), "quantifier should be a lambda expression")
2186 return _array_select(self, arg)
2187

◆ as_ast()

as_ast (   self)

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

2252 def body(self):
2253 """Return the expression being quantified.
2254
2255 >>> f = Function('f', IntSort(), IntSort())
2256 >>> x = Int('x')
2257 >>> q = ForAll(x, f(x) == 0)
2258 >>> q.body()
2259 f(Var(0)) == 0
2260 """
2261 return _to_expr_ref(Z3_get_quantifier_body(self.ctx_ref(), self.ast), self.ctx)
2262
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 2307 of file z3py.py.

2307 def children(self):
2308 """Return a list containing a single element self.body()
2309
2310 >>> f = Function('f', IntSort(), IntSort())
2311 >>> x = Int('x')
2312 >>> q = ForAll(x, f(x) == 0)
2313 >>> q.children()
2314 [f(Var(0)) == 0]
2315 """
2316 return [self.body()]
2317
2318

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

2130 def get_id(self):
2131 return Z3_get_ast_id(self.ctx_ref(), self.as_ast())
2132
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 2153 of file z3py.py.

2153 def is_exists(self):
2154 """Return `True` if `self` is an existential quantifier.
2155
2156 >>> f = Function('f', IntSort(), IntSort())
2157 >>> x = Int('x')
2158 >>> q = ForAll(x, f(x) == 0)
2159 >>> q.is_exists()
2160 False
2161 >>> q = Exists(x, f(x) != 0)
2162 >>> q.is_exists()
2163 True
2164 """
2165 return Z3_is_quantifier_exists(self.ctx_ref(), self.ast)
2166
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 2139 of file z3py.py.

2139 def is_forall(self):
2140 """Return `True` if `self` is a universal quantifier.
2141
2142 >>> f = Function('f', IntSort(), IntSort())
2143 >>> x = Int('x')
2144 >>> q = ForAll(x, f(x) == 0)
2145 >>> q.is_forall()
2146 True
2147 >>> q = Exists(x, f(x) != 0)
2148 >>> q.is_forall()
2149 False
2150 """
2151 return Z3_is_quantifier_forall(self.ctx_ref(), self.ast)
2152
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 2167 of file z3py.py.

2167 def is_lambda(self):
2168 """Return `True` if `self` is a lambda expression.
2169
2170 >>> f = Function('f', IntSort(), IntSort())
2171 >>> x = Int('x')
2172 >>> q = Lambda(x, f(x))
2173 >>> q.is_lambda()
2174 True
2175 >>> q = Exists(x, f(x) != 0)
2176 >>> q.is_lambda()
2177 False
2178 """
2179 return Z3_is_lambda(self.ctx_ref(), self.ast)
2180
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 2246 of file z3py.py.

2246 def no_pattern(self, idx):
2247 """Return a no-pattern."""
2248 if z3_debug():
2249 _z3_assert(idx < self.num_no_patterns(), "Invalid no-pattern idx")
2250 return _to_expr_ref(Z3_get_quantifier_no_pattern_ast(self.ctx_ref(), self.ast, idx), self.ctx)
2251
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 2242 of file z3py.py.

2242 def num_no_patterns(self):
2243 """Return the number of no-patterns."""
2244 return Z3_get_quantifier_num_no_patterns(self.ctx_ref(), self.ast)
2245
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 2212 of file z3py.py.

2212 def num_patterns(self):
2213 """Return the number of patterns (i.e., quantifier instantiation hints) in `self`.
2214
2215 >>> f = Function('f', IntSort(), IntSort())
2216 >>> g = Function('g', IntSort(), IntSort())
2217 >>> x = Int('x')
2218 >>> q = ForAll(x, f(x) != g(x), patterns = [ f(x), g(x) ])
2219 >>> q.num_patterns()
2220 2
2221 """
2222 return int(Z3_get_quantifier_num_patterns(self.ctx_ref(), self.ast))
2223
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 2263 of file z3py.py.

2263 def num_vars(self):
2264 """Return the number of variables bounded by this quantifier.
2265
2266 >>> f = Function('f', IntSort(), IntSort(), IntSort())
2267 >>> x = Int('x')
2268 >>> y = Int('y')
2269 >>> q = ForAll([x, y], f(x, y) >= x)
2270 >>> q.num_vars()
2271 2
2272 """
2273 return int(Z3_get_quantifier_num_bound(self.ctx_ref(), self.ast))
2274
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 2224 of file z3py.py.

2224 def pattern(self, idx):
2225 """Return a pattern (i.e., quantifier instantiation hints) in `self`.
2226
2227 >>> f = Function('f', IntSort(), IntSort())
2228 >>> g = Function('g', IntSort(), IntSort())
2229 >>> x = Int('x')
2230 >>> q = ForAll(x, f(x) != g(x), patterns = [ f(x), g(x) ])
2231 >>> q.num_patterns()
2232 2
2233 >>> q.pattern(0)
2234 f(Var(0))
2235 >>> q.pattern(1)
2236 g(Var(0))
2237 """
2238 if z3_debug():
2239 _z3_assert(idx < self.num_patterns(), "Invalid pattern idx")
2240 return PatternRef(Z3_get_quantifier_pattern_ast(self.ctx_ref(), self.ast, idx), self.ctx)
2241
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 2207 of file z3py.py.

2207 def qid(self):
2208 """Return the quantifier id of `self`.
2209 """
2210 return _symbol2py(self.ctx, Z3_get_quantifier_id(self.ctx_ref(), self.ast))
2211
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 2202 of file z3py.py.

2202 def skolem_id(self):
2203 """Return the skolem id of `self`.
2204 """
2205 return _symbol2py(self.ctx, Z3_get_quantifier_skolem_id(self.ctx_ref(), self.ast))
2206
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 2133 of file z3py.py.

2133 def sort(self):
2134 """Return the Boolean sort or sort of Lambda."""
2135 if self.is_lambda():
2136 return _sort(self.ctx, self.as_ast())
2137 return BoolSort(self.ctx)
2138

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

2275 def var_name(self, idx):
2276 """Return a string representing a name used when displaying the quantifier.
2277
2278 >>> f = Function('f', IntSort(), IntSort(), IntSort())
2279 >>> x = Int('x')
2280 >>> y = Int('y')
2281 >>> q = ForAll([x, y], f(x, y) >= x)
2282 >>> q.var_name(0)
2283 'x'
2284 >>> q.var_name(1)
2285 'y'
2286 """
2287 if z3_debug():
2288 _z3_assert(idx < self.num_vars(), "Invalid variable idx")
2289 return _symbol2py(self.ctx, Z3_get_quantifier_bound_name(self.ctx_ref(), self.ast, idx))
2290
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 2291 of file z3py.py.

2291 def var_sort(self, idx):
2292 """Return the sort of a bound variable.
2293
2294 >>> f = Function('f', IntSort(), RealSort(), IntSort())
2295 >>> x = Int('x')
2296 >>> y = Real('y')
2297 >>> q = ForAll([x, y], f(x, y) >= x)
2298 >>> q.var_sort(0)
2299 Int
2300 >>> q.var_sort(1)
2301 Real
2302 """
2303 if z3_debug():
2304 _z3_assert(idx < self.num_vars(), "Invalid variable idx")
2305 return _to_sort_ref(Z3_get_quantifier_bound_sort(self.ctx_ref(), self.ast, idx), self.ctx)
2306
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 2188 of file z3py.py.

2188 def weight(self):
2189 """Return the weight annotation of `self`.
2190
2191 >>> f = Function('f', IntSort(), IntSort())
2192 >>> x = Int('x')
2193 >>> q = ForAll(x, f(x) == 0)
2194 >>> q.weight()
2195 1
2196 >>> q = ForAll(x, f(x) == 0, weight=10)
2197 >>> q.weight()
2198 10
2199 """
2200 return int(Z3_get_quantifier_weight(self.ctx_ref(), self.ast))
2201
unsigned Z3_API Z3_get_quantifier_weight(Z3_context c, Z3_ast a)
Obtain weight of quantifier.

Field Documentation

◆ ast

ast

◆ ctx

ctx

Definition at line 2136 of file z3py.py.

Referenced by ArithRef.__add__(), BitVecRef.__add__(), BitVecRef.__and__(), FuncDeclRef.__call__(), AstMap.__contains__(), AstRef.__copy__(), Goal.__copy__(), AstVector.__copy__(), FuncInterp.__copy__(), ModelRef.__copy__(), AstRef.__deepcopy__(), Datatype.__deepcopy__(), ParamsRef.__deepcopy__(), ParamDescrsRef.__deepcopy__(), Goal.__deepcopy__(), AstVector.__deepcopy__(), AstMap.__deepcopy__(), FuncEntry.__deepcopy__(), FuncInterp.__deepcopy__(), ModelRef.__deepcopy__(), Statistics.__deepcopy__(), Context.__del__(), AstRef.__del__(), ScopedConstructor.__del__(), ScopedConstructorList.__del__(), ParamsRef.__del__(), ParamDescrsRef.__del__(), Goal.__del__(), AstVector.__del__(), AstMap.__del__(), FuncEntry.__del__(), FuncInterp.__del__(), ModelRef.__del__(), Statistics.__del__(), Solver.__del__(), ArithRef.__div__(), BitVecRef.__div__(), ExprRef.__eq__(), ArithRef.__ge__(), BitVecRef.__ge__(), AstVector.__getitem__(), ModelRef.__getitem__(), Statistics.__getitem__(), AstMap.__getitem__(), ArithRef.__gt__(), BitVecRef.__gt__(), BitVecRef.__invert__(), ArithRef.__le__(), BitVecRef.__le__(), AstVector.__len__(), AstMap.__len__(), ModelRef.__len__(), Statistics.__len__(), BitVecRef.__lshift__(), ArithRef.__lt__(), BitVecRef.__lt__(), ArithRef.__mod__(), BitVecRef.__mod__(), BoolRef.__mul__(), ArithRef.__mul__(), BitVecRef.__mul__(), ExprRef.__ne__(), ArithRef.__neg__(), BitVecRef.__neg__(), BitVecRef.__or__(), ArithRef.__pow__(), ArithRef.__radd__(), BitVecRef.__radd__(), BitVecRef.__rand__(), ArithRef.__rdiv__(), BitVecRef.__rdiv__(), ParamsRef.__repr__(), ParamDescrsRef.__repr__(), AstMap.__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__(), AstVector.__setitem__(), AstMap.__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(), ModelRef.project(), ModelRef.project_with_witness(), Solver.push(), AstVector.push(), QuantifierRef.qid(), FuncDeclRef.range(), ArraySortRef.range(), DatatypeSortRef.recognizer(), Context.ref(), AstMap.reset(), Solver.reset(), AstVector.resize(), Solver.set(), ParamsRef.set(), Goal.sexpr(), AstVector.sexpr(), ModelRef.sexpr(), ParamDescrsRef.size(), Goal.size(), QuantifierRef.skolem_id(), AstVector.translate(), AstRef.translate(), Goal.translate(), ModelRef.translate(), ExprRef.update(), ParamsRef.validate(), FuncEntry.value(), QuantifierRef.var_name(), and QuantifierRef.var_sort().