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

Member Function Documentation

◆ __getitem__()

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

Definition at line 2206 of file z3py.py.

2206 def __getitem__(self, arg):
2207 """Return the Z3 expression `self[arg]`.
2208 """
2209 if z3_debug():
2210 _z3_assert(self.is_lambda(), "quantifier should be a lambda expression")
2211 return _array_select(self, arg)
2212

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

2277 def body(self):
2278 """Return the expression being quantified.
2279
2280 >>> f = Function('f', IntSort(), IntSort())
2281 >>> x = Int('x')
2282 >>> q = ForAll(x, f(x) == 0)
2283 >>> q.body()
2284 f(Var(0)) == 0
2285 """
2286 return _to_expr_ref(Z3_get_quantifier_body(self.ctx_ref(), self.ast), self.ctx)
2287
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 2332 of file z3py.py.

2332 def children(self):
2333 """Return a list containing a single element self.body()
2334
2335 >>> f = Function('f', IntSort(), IntSort())
2336 >>> x = Int('x')
2337 >>> q = ForAll(x, f(x) == 0)
2338 >>> q.children()
2339 [f(Var(0)) == 0]
2340 """
2341 return [self.body()]
2342
2343

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

2155 def get_id(self):
2156 return Z3_get_ast_id(self.ctx_ref(), self.as_ast())
2157
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 2178 of file z3py.py.

2178 def is_exists(self):
2179 """Return `True` if `self` is an existential quantifier.
2180
2181 >>> f = Function('f', IntSort(), IntSort())
2182 >>> x = Int('x')
2183 >>> q = ForAll(x, f(x) == 0)
2184 >>> q.is_exists()
2185 False
2186 >>> q = Exists(x, f(x) != 0)
2187 >>> q.is_exists()
2188 True
2189 """
2190 return Z3_is_quantifier_exists(self.ctx_ref(), self.ast)
2191
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 2164 of file z3py.py.

2164 def is_forall(self):
2165 """Return `True` if `self` is a universal quantifier.
2166
2167 >>> f = Function('f', IntSort(), IntSort())
2168 >>> x = Int('x')
2169 >>> q = ForAll(x, f(x) == 0)
2170 >>> q.is_forall()
2171 True
2172 >>> q = Exists(x, f(x) != 0)
2173 >>> q.is_forall()
2174 False
2175 """
2176 return Z3_is_quantifier_forall(self.ctx_ref(), self.ast)
2177
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 2192 of file z3py.py.

2192 def is_lambda(self):
2193 """Return `True` if `self` is a lambda expression.
2194
2195 >>> f = Function('f', IntSort(), IntSort())
2196 >>> x = Int('x')
2197 >>> q = Lambda(x, f(x))
2198 >>> q.is_lambda()
2199 True
2200 >>> q = Exists(x, f(x) != 0)
2201 >>> q.is_lambda()
2202 False
2203 """
2204 return Z3_is_lambda(self.ctx_ref(), self.ast)
2205
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 2271 of file z3py.py.

2271 def no_pattern(self, idx):
2272 """Return a no-pattern."""
2273 if z3_debug():
2274 _z3_assert(idx < self.num_no_patterns(), "Invalid no-pattern idx")
2275 return _to_expr_ref(Z3_get_quantifier_no_pattern_ast(self.ctx_ref(), self.ast, idx), self.ctx)
2276
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 2267 of file z3py.py.

2267 def num_no_patterns(self):
2268 """Return the number of no-patterns."""
2269 return Z3_get_quantifier_num_no_patterns(self.ctx_ref(), self.ast)
2270
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 2237 of file z3py.py.

2237 def num_patterns(self):
2238 """Return the number of patterns (i.e., quantifier instantiation hints) in `self`.
2239
2240 >>> f = Function('f', IntSort(), IntSort())
2241 >>> g = Function('g', IntSort(), IntSort())
2242 >>> x = Int('x')
2243 >>> q = ForAll(x, f(x) != g(x), patterns = [ f(x), g(x) ])
2244 >>> q.num_patterns()
2245 2
2246 """
2247 return int(Z3_get_quantifier_num_patterns(self.ctx_ref(), self.ast))
2248
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 2288 of file z3py.py.

2288 def num_vars(self):
2289 """Return the number of variables bounded by this quantifier.
2290
2291 >>> f = Function('f', IntSort(), IntSort(), IntSort())
2292 >>> x = Int('x')
2293 >>> y = Int('y')
2294 >>> q = ForAll([x, y], f(x, y) >= x)
2295 >>> q.num_vars()
2296 2
2297 """
2298 return int(Z3_get_quantifier_num_bound(self.ctx_ref(), self.ast))
2299
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 2249 of file z3py.py.

2249 def pattern(self, idx):
2250 """Return a pattern (i.e., quantifier instantiation hints) in `self`.
2251
2252 >>> f = Function('f', IntSort(), IntSort())
2253 >>> g = Function('g', IntSort(), IntSort())
2254 >>> x = Int('x')
2255 >>> q = ForAll(x, f(x) != g(x), patterns = [ f(x), g(x) ])
2256 >>> q.num_patterns()
2257 2
2258 >>> q.pattern(0)
2259 f(Var(0))
2260 >>> q.pattern(1)
2261 g(Var(0))
2262 """
2263 if z3_debug():
2264 _z3_assert(idx < self.num_patterns(), "Invalid pattern idx")
2265 return PatternRef(Z3_get_quantifier_pattern_ast(self.ctx_ref(), self.ast, idx), self.ctx)
2266
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 2232 of file z3py.py.

2232 def qid(self):
2233 """Return the quantifier id of `self`.
2234 """
2235 return _symbol2py(self.ctx, Z3_get_quantifier_id(self.ctx_ref(), self.ast))
2236
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 2227 of file z3py.py.

2227 def skolem_id(self):
2228 """Return the skolem id of `self`.
2229 """
2230 return _symbol2py(self.ctx, Z3_get_quantifier_skolem_id(self.ctx_ref(), self.ast))
2231
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 2158 of file z3py.py.

2158 def sort(self):
2159 """Return the Boolean sort or sort of Lambda."""
2160 if self.is_lambda():
2161 return _sort(self.ctx, self.as_ast())
2162 return BoolSort(self.ctx)
2163

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

2300 def var_name(self, idx):
2301 """Return a string representing a name used when displaying the quantifier.
2302
2303 >>> f = Function('f', IntSort(), IntSort(), IntSort())
2304 >>> x = Int('x')
2305 >>> y = Int('y')
2306 >>> q = ForAll([x, y], f(x, y) >= x)
2307 >>> q.var_name(0)
2308 'x'
2309 >>> q.var_name(1)
2310 'y'
2311 """
2312 if z3_debug():
2313 _z3_assert(idx < self.num_vars(), "Invalid variable idx")
2314 return _symbol2py(self.ctx, Z3_get_quantifier_bound_name(self.ctx_ref(), self.ast, idx))
2315
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 2316 of file z3py.py.

2316 def var_sort(self, idx):
2317 """Return the sort of a bound variable.
2318
2319 >>> f = Function('f', IntSort(), RealSort(), IntSort())
2320 >>> x = Int('x')
2321 >>> y = Real('y')
2322 >>> q = ForAll([x, y], f(x, y) >= x)
2323 >>> q.var_sort(0)
2324 Int
2325 >>> q.var_sort(1)
2326 Real
2327 """
2328 if z3_debug():
2329 _z3_assert(idx < self.num_vars(), "Invalid variable idx")
2330 return _to_sort_ref(Z3_get_quantifier_bound_sort(self.ctx_ref(), self.ast, idx), self.ctx)
2331
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 2213 of file z3py.py.

2213 def weight(self):
2214 """Return the weight annotation of `self`.
2215
2216 >>> f = Function('f', IntSort(), IntSort())
2217 >>> x = Int('x')
2218 >>> q = ForAll(x, f(x) == 0)
2219 >>> q.weight()
2220 1
2221 >>> q = ForAll(x, f(x) == 0, weight=10)
2222 >>> q.weight()
2223 10
2224 """
2225 return int(Z3_get_quantifier_weight(self.ctx_ref(), self.ast))
2226
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 2161 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(), FiniteSetSortRef.cast(), 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(), DatatypeRef.update_field(), ParamsRef.validate(), FuncEntry.value(), QuantifierRef.var_name(), and QuantifierRef.var_sort().