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 skolem_id (self)
 
def qid (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 __add__ (self, other)
 
def __radd__ (self, other)
 
def __rmul__ (self, other)
 
def __mul__ (self, other)
 
def __and__ (self, other)
 
def __or__ (self, other)
 
def __xor__ (self, other)
 
def __invert__ (self)
 
def py_value (self)
 
- 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 kind (self)
 
def num_args (self)
 
def arg (self, idx)
 
def children (self)
 
def update (self, args)
 
def from_string (self, s)
 
def serialize (self)
 
- Public Member Functions inherited from AstRef
def __init__
 
def __del__ (self)
 
def __deepcopy__
 
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)
 
def py_value (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 2121 of file z3py.py.

Member Function Documentation

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

Definition at line 2178 of file z3py.py.

2178  def __getitem__(self, arg):
2179  """Return the Z3 expression `self[arg]`.
2180  """
2181  if z3_debug():
2182  _z3_assert(self.is_lambda(), "quantifier should be a lambda expression")
2183  return _array_select(self, arg)
2184 
def is_lambda(self)
Definition: z3py.py:2164
def __getitem__(self, arg)
Definition: z3py.py:2178
def z3_debug()
Definition: z3py.py:70
def as_ast (   self)

Definition at line 2124 of file z3py.py.

2124  def as_ast(self):
2125  return self.ast
2126 
def as_ast(self)
Definition: z3py.py:2124
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 2249 of file z3py.py.

Referenced by QuantifierRef.children().

2249  def body(self):
2250  """Return the expression being quantified.
2251 
2252  >>> f = Function('f', IntSort(), IntSort())
2253  >>> x = Int('x')
2254  >>> q = ForAll(x, f(x) == 0)
2255  >>> q.body()
2256  f(Var(0)) == 0
2257  """
2258  return _to_expr_ref(Z3_get_quantifier_body(self.ctx_ref(), self.ast), self.ctx)
2259 
def ctx_ref(self)
Definition: z3py.py:427
Z3_ast Z3_API Z3_get_quantifier_body(Z3_context c, Z3_ast a)
Return body of quantifier.
def body(self)
Definition: z3py.py:2249
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]

Definition at line 2304 of file z3py.py.

2304  def children(self):
2305  """Return a list containing a single element self.body()
2306 
2307  >>> f = Function('f', IntSort(), IntSort())
2308  >>> x = Int('x')
2309  >>> q = ForAll(x, f(x) == 0)
2310  >>> q.children()
2311  [f(Var(0)) == 0]
2312  """
2313  return [self.body()]
2314 
2315 
def children(self)
Definition: z3py.py:2304
def body(self)
Definition: z3py.py:2249
def get_id (   self)

Definition at line 2127 of file z3py.py.

2127  def get_id(self):
2128  return Z3_get_ast_id(self.ctx_ref(), self.as_ast())
2129 
def get_id(self)
Definition: z3py.py:2127
def as_ast(self)
Definition: z3py.py:419
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. Thus, two ast nodes created by the same context and having the same children and same function symbols have the same identifiers. Ast nodes created in the same context, but having different children or different functions have different identifiers. Variables and quantifiers are also assigned different identifiers according to their structure.
def ctx_ref(self)
Definition: z3py.py:427
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 2150 of file z3py.py.

2150  def is_exists(self):
2151  """Return `True` if `self` is an existential quantifier.
2152 
2153  >>> f = Function('f', IntSort(), IntSort())
2154  >>> x = Int('x')
2155  >>> q = ForAll(x, f(x) == 0)
2156  >>> q.is_exists()
2157  False
2158  >>> q = Exists(x, f(x) != 0)
2159  >>> q.is_exists()
2160  True
2161  """
2162  return Z3_is_quantifier_exists(self.ctx_ref(), self.ast)
2163 
bool Z3_API Z3_is_quantifier_exists(Z3_context c, Z3_ast a)
Determine if ast is an existential quantifier.
def is_exists(self)
Definition: z3py.py:2150
def ctx_ref(self)
Definition: z3py.py:427
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 2136 of file z3py.py.

2136  def is_forall(self):
2137  """Return `True` if `self` is a universal quantifier.
2138 
2139  >>> f = Function('f', IntSort(), IntSort())
2140  >>> x = Int('x')
2141  >>> q = ForAll(x, f(x) == 0)
2142  >>> q.is_forall()
2143  True
2144  >>> q = Exists(x, f(x) != 0)
2145  >>> q.is_forall()
2146  False
2147  """
2148  return Z3_is_quantifier_forall(self.ctx_ref(), self.ast)
2149 
def is_forall(self)
Definition: z3py.py:2136
def ctx_ref(self)
Definition: z3py.py:427
bool Z3_API Z3_is_quantifier_forall(Z3_context c, Z3_ast a)
Determine if an ast is a universal quantifier.
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 2164 of file z3py.py.

Referenced by QuantifierRef.__getitem__().

2164  def is_lambda(self):
2165  """Return `True` if `self` is a lambda expression.
2166 
2167  >>> f = Function('f', IntSort(), IntSort())
2168  >>> x = Int('x')
2169  >>> q = Lambda(x, f(x))
2170  >>> q.is_lambda()
2171  True
2172  >>> q = Exists(x, f(x) != 0)
2173  >>> q.is_lambda()
2174  False
2175  """
2176  return Z3_is_lambda(self.ctx_ref(), self.ast)
2177 
def is_lambda(self)
Definition: z3py.py:2164
def ctx_ref(self)
Definition: z3py.py:427
bool Z3_API Z3_is_lambda(Z3_context c, Z3_ast a)
Determine if ast is a lambda expression.
def no_pattern (   self,
  idx 
)
Return a no-pattern.

Definition at line 2243 of file z3py.py.

2243  def no_pattern(self, idx):
2244  """Return a no-pattern."""
2245  if z3_debug():
2246  _z3_assert(idx < self.num_no_patterns(), "Invalid no-pattern idx")
2247  return _to_expr_ref(Z3_get_quantifier_no_pattern_ast(self.ctx_ref(), self.ast, idx), self.ctx)
2248 
def num_no_patterns(self)
Definition: z3py.py:2239
Z3_ast Z3_API Z3_get_quantifier_no_pattern_ast(Z3_context c, Z3_ast a, unsigned i)
Return i'th no_pattern.
def z3_debug()
Definition: z3py.py:70
def ctx_ref(self)
Definition: z3py.py:427
def no_pattern(self, idx)
Definition: z3py.py:2243
def num_no_patterns (   self)
Return the number of no-patterns.

Definition at line 2239 of file z3py.py.

Referenced by QuantifierRef.no_pattern().

2239  def num_no_patterns(self):
2240  """Return the number of no-patterns."""
2241  return Z3_get_quantifier_num_no_patterns(self.ctx_ref(), self.ast)
2242 
def num_no_patterns(self)
Definition: z3py.py:2239
def ctx_ref(self)
Definition: z3py.py:427
unsigned Z3_API Z3_get_quantifier_num_no_patterns(Z3_context c, Z3_ast a)
Return number of no_patterns used in quantifier.
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 2209 of file z3py.py.

2209  def num_patterns(self):
2210  """Return the number of patterns (i.e., quantifier instantiation hints) in `self`.
2211 
2212  >>> f = Function('f', IntSort(), IntSort())
2213  >>> g = Function('g', IntSort(), IntSort())
2214  >>> x = Int('x')
2215  >>> q = ForAll(x, f(x) != g(x), patterns = [ f(x), g(x) ])
2216  >>> q.num_patterns()
2217  2
2218  """
2219  return int(Z3_get_quantifier_num_patterns(self.ctx_ref(), self.ast))
2220 
def num_patterns(self)
Definition: z3py.py:2209
unsigned Z3_API Z3_get_quantifier_num_patterns(Z3_context c, Z3_ast a)
Return number of patterns used in quantifier.
def ctx_ref(self)
Definition: z3py.py:427
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 2260 of file z3py.py.

2260  def num_vars(self):
2261  """Return the number of variables bounded by this quantifier.
2262 
2263  >>> f = Function('f', IntSort(), IntSort(), IntSort())
2264  >>> x = Int('x')
2265  >>> y = Int('y')
2266  >>> q = ForAll([x, y], f(x, y) >= x)
2267  >>> q.num_vars()
2268  2
2269  """
2270  return int(Z3_get_quantifier_num_bound(self.ctx_ref(), self.ast))
2271 
unsigned Z3_API Z3_get_quantifier_num_bound(Z3_context c, Z3_ast a)
Return number of bound variables of quantifier.
def ctx_ref(self)
Definition: z3py.py:427
def num_vars(self)
Definition: z3py.py:2260
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 2221 of file z3py.py.

2221  def pattern(self, idx):
2222  """Return a pattern (i.e., quantifier instantiation hints) in `self`.
2223 
2224  >>> f = Function('f', IntSort(), IntSort())
2225  >>> g = Function('g', IntSort(), IntSort())
2226  >>> x = Int('x')
2227  >>> q = ForAll(x, f(x) != g(x), patterns = [ f(x), g(x) ])
2228  >>> q.num_patterns()
2229  2
2230  >>> q.pattern(0)
2231  f(Var(0))
2232  >>> q.pattern(1)
2233  g(Var(0))
2234  """
2235  if z3_debug():
2236  _z3_assert(idx < self.num_patterns(), "Invalid pattern idx")
2237  return PatternRef(Z3_get_quantifier_pattern_ast(self.ctx_ref(), self.ast, idx), self.ctx)
2238 
Patterns.
Definition: z3py.py:2054
def num_patterns(self)
Definition: z3py.py:2209
Z3_pattern Z3_API Z3_get_quantifier_pattern_ast(Z3_context c, Z3_ast a, unsigned i)
Return i'th pattern.
def pattern(self, idx)
Definition: z3py.py:2221
def z3_debug()
Definition: z3py.py:70
def ctx_ref(self)
Definition: z3py.py:427
def qid (   self)
Return the quantifier id of `self`.

Definition at line 2204 of file z3py.py.

2204  def qid(self):
2205  """Return the quantifier id of `self`.
2206  """
2207  return _symbol2py(self.ctx, Z3_get_quantifier_id(self.ctx_ref(), self.ast))
2208 
def qid(self)
Definition: z3py.py:2204
Z3_symbol Z3_API Z3_get_quantifier_id(Z3_context c, Z3_ast a)
Obtain id of quantifier.
def ctx_ref(self)
Definition: z3py.py:427
def skolem_id (   self)
Return the skolem id of `self`.

Definition at line 2199 of file z3py.py.

2199  def skolem_id(self):
2200  """Return the skolem id of `self`.
2201  """
2202  return _symbol2py(self.ctx, Z3_get_quantifier_skolem_id(self.ctx_ref(), self.ast))
2203 
Z3_symbol Z3_API Z3_get_quantifier_skolem_id(Z3_context c, Z3_ast a)
Obtain skolem id of quantifier.
def skolem_id(self)
Definition: z3py.py:2199
def ctx_ref(self)
Definition: z3py.py:427
def sort (   self)
Return the Boolean sort or sort of Lambda.

Definition at line 2130 of file z3py.py.

2130  def sort(self):
2131  """Return the Boolean sort or sort of Lambda."""
2132  if self.is_lambda():
2133  return _sort(self.ctx, self.as_ast())
2134  return BoolSort(self.ctx)
2135 
def BoolSort
Definition: z3py.py:1824
def as_ast(self)
Definition: z3py.py:419
def sort(self)
Definition: z3py.py:2130
def is_lambda(self)
Definition: z3py.py:2164
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 2272 of file z3py.py.

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

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

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