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)
 
 kind (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
 
 ast
 
- 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 2035 of file z3py.py.

Member Function Documentation

◆ __getitem__()

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

Definition at line 2092 of file z3py.py.

2092 def __getitem__(self, arg):
2093 """Return the Z3 expression `self[arg]`.
2094 """
2095 if z3_debug():
2096 _z3_assert(self.is_lambda(), "quantifier should be a lambda expression")
2097 return _array_select(self, arg)
2098

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

2163 def body(self):
2164 """Return the expression being quantified.
2165
2166 >>> f = Function('f', IntSort(), IntSort())
2167 >>> x = Int('x')
2168 >>> q = ForAll(x, f(x) == 0)
2169 >>> q.body()
2170 f(Var(0)) == 0
2171 """
2172 return _to_expr_ref(Z3_get_quantifier_body(self.ctx_ref(), self.ast), self.ctx)
2173
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 2218 of file z3py.py.

2218 def children(self):
2219 """Return a list containing a single element self.body()
2220
2221 >>> f = Function('f', IntSort(), IntSort())
2222 >>> x = Int('x')
2223 >>> q = ForAll(x, f(x) == 0)
2224 >>> q.children()
2225 [f(Var(0)) == 0]
2226 """
2227 return [self.body()]
2228
2229

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

2041 def get_id(self):
2042 return Z3_get_ast_id(self.ctx_ref(), self.as_ast())
2043
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 2064 of file z3py.py.

2064 def is_exists(self):
2065 """Return `True` if `self` is an existential quantifier.
2066
2067 >>> f = Function('f', IntSort(), IntSort())
2068 >>> x = Int('x')
2069 >>> q = ForAll(x, f(x) == 0)
2070 >>> q.is_exists()
2071 False
2072 >>> q = Exists(x, f(x) != 0)
2073 >>> q.is_exists()
2074 True
2075 """
2076 return Z3_is_quantifier_exists(self.ctx_ref(), self.ast)
2077
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 2050 of file z3py.py.

2050 def is_forall(self):
2051 """Return `True` if `self` is a universal quantifier.
2052
2053 >>> f = Function('f', IntSort(), IntSort())
2054 >>> x = Int('x')
2055 >>> q = ForAll(x, f(x) == 0)
2056 >>> q.is_forall()
2057 True
2058 >>> q = Exists(x, f(x) != 0)
2059 >>> q.is_forall()
2060 False
2061 """
2062 return Z3_is_quantifier_forall(self.ctx_ref(), self.ast)
2063
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 2078 of file z3py.py.

2078 def is_lambda(self):
2079 """Return `True` if `self` is a lambda expression.
2080
2081 >>> f = Function('f', IntSort(), IntSort())
2082 >>> x = Int('x')
2083 >>> q = Lambda(x, f(x))
2084 >>> q.is_lambda()
2085 True
2086 >>> q = Exists(x, f(x) != 0)
2087 >>> q.is_lambda()
2088 False
2089 """
2090 return Z3_is_lambda(self.ctx_ref(), self.ast)
2091
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 2157 of file z3py.py.

2157 def no_pattern(self, idx):
2158 """Return a no-pattern."""
2159 if z3_debug():
2160 _z3_assert(idx < self.num_no_patterns(), "Invalid no-pattern idx")
2161 return _to_expr_ref(Z3_get_quantifier_no_pattern_ast(self.ctx_ref(), self.ast, idx), self.ctx)
2162
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 2153 of file z3py.py.

2153 def num_no_patterns(self):
2154 """Return the number of no-patterns."""
2155 return Z3_get_quantifier_num_no_patterns(self.ctx_ref(), self.ast)
2156
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 2123 of file z3py.py.

2123 def num_patterns(self):
2124 """Return the number of patterns (i.e., quantifier instantiation hints) in `self`.
2125
2126 >>> f = Function('f', IntSort(), IntSort())
2127 >>> g = Function('g', IntSort(), IntSort())
2128 >>> x = Int('x')
2129 >>> q = ForAll(x, f(x) != g(x), patterns = [ f(x), g(x) ])
2130 >>> q.num_patterns()
2131 2
2132 """
2133 return int(Z3_get_quantifier_num_patterns(self.ctx_ref(), self.ast))
2134
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 2174 of file z3py.py.

2174 def num_vars(self):
2175 """Return the number of variables bounded by this quantifier.
2176
2177 >>> f = Function('f', IntSort(), IntSort(), IntSort())
2178 >>> x = Int('x')
2179 >>> y = Int('y')
2180 >>> q = ForAll([x, y], f(x, y) >= x)
2181 >>> q.num_vars()
2182 2
2183 """
2184 return int(Z3_get_quantifier_num_bound(self.ctx_ref(), self.ast))
2185
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 2135 of file z3py.py.

2135 def pattern(self, idx):
2136 """Return a pattern (i.e., quantifier instantiation hints) in `self`.
2137
2138 >>> f = Function('f', IntSort(), IntSort())
2139 >>> g = Function('g', IntSort(), IntSort())
2140 >>> x = Int('x')
2141 >>> q = ForAll(x, f(x) != g(x), patterns = [ f(x), g(x) ])
2142 >>> q.num_patterns()
2143 2
2144 >>> q.pattern(0)
2145 f(Var(0))
2146 >>> q.pattern(1)
2147 g(Var(0))
2148 """
2149 if z3_debug():
2150 _z3_assert(idx < self.num_patterns(), "Invalid pattern idx")
2151 return PatternRef(Z3_get_quantifier_pattern_ast(self.ctx_ref(), self.ast, idx), self.ctx)
2152
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 2118 of file z3py.py.

2118 def qid(self):
2119 """Return the quantifier id of `self`.
2120 """
2121 return _symbol2py(self.ctx, Z3_get_quantifier_id(self.ctx_ref(), self.ast))
2122
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 2113 of file z3py.py.

2113 def skolem_id(self):
2114 """Return the skolem id of `self`.
2115 """
2116 return _symbol2py(self.ctx, Z3_get_quantifier_skolem_id(self.ctx_ref(), self.ast))
2117
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 2044 of file z3py.py.

2044 def sort(self):
2045 """Return the Boolean sort or sort of Lambda."""
2046 if self.is_lambda():
2047 return _sort(self.ctx, self.as_ast())
2048 return BoolSort(self.ctx)
2049

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

2186 def var_name(self, idx):
2187 """Return a string representing a name used when displaying the quantifier.
2188
2189 >>> f = Function('f', IntSort(), IntSort(), IntSort())
2190 >>> x = Int('x')
2191 >>> y = Int('y')
2192 >>> q = ForAll([x, y], f(x, y) >= x)
2193 >>> q.var_name(0)
2194 'x'
2195 >>> q.var_name(1)
2196 'y'
2197 """
2198 if z3_debug():
2199 _z3_assert(idx < self.num_vars(), "Invalid variable idx")
2200 return _symbol2py(self.ctx, Z3_get_quantifier_bound_name(self.ctx_ref(), self.ast, idx))
2201
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 2202 of file z3py.py.

2202 def var_sort(self, idx):
2203 """Return the sort of a bound variable.
2204
2205 >>> f = Function('f', IntSort(), RealSort(), IntSort())
2206 >>> x = Int('x')
2207 >>> y = Real('y')
2208 >>> q = ForAll([x, y], f(x, y) >= x)
2209 >>> q.var_sort(0)
2210 Int
2211 >>> q.var_sort(1)
2212 Real
2213 """
2214 if z3_debug():
2215 _z3_assert(idx < self.num_vars(), "Invalid variable idx")
2216 return _to_sort_ref(Z3_get_quantifier_bound_sort(self.ctx_ref(), self.ast, idx), self.ctx)
2217
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 2099 of file z3py.py.

2099 def weight(self):
2100 """Return the weight annotation of `self`.
2101
2102 >>> f = Function('f', IntSort(), IntSort())
2103 >>> x = Int('x')
2104 >>> q = ForAll(x, f(x) == 0)
2105 >>> q.weight()
2106 1
2107 >>> q = ForAll(x, f(x) == 0, weight=10)
2108 >>> q.weight()
2109 10
2110 """
2111 return int(Z3_get_quantifier_weight(self.ctx_ref(), self.ast))
2112
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 2047 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(), ModelRef.project(), ModelRef.project_with_witness(), 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().