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

Member Function Documentation

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

Definition at line 2116 of file z3py.py.

2116  def __getitem__(self, arg):
2117  """Return the Z3 expression `self[arg]`.
2118  """
2119  if z3_debug():
2120  _z3_assert(self.is_lambda(), "quantifier should be a lambda expression")
2121  return _array_select(self, arg)
2122 
def is_lambda(self)
Definition: z3py.py:2102
def __getitem__(self, arg)
Definition: z3py.py:2116
def z3_debug()
Definition: z3py.py:70
def as_ast (   self)

Definition at line 2062 of file z3py.py.

2062  def as_ast(self):
2063  return self.ast
2064 
def as_ast(self)
Definition: z3py.py:2062
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 2187 of file z3py.py.

Referenced by QuantifierRef.children().

2187  def body(self):
2188  """Return the expression being quantified.
2189 
2190  >>> f = Function('f', IntSort(), IntSort())
2191  >>> x = Int('x')
2192  >>> q = ForAll(x, f(x) == 0)
2193  >>> q.body()
2194  f(Var(0)) == 0
2195  """
2196  return _to_expr_ref(Z3_get_quantifier_body(self.ctx_ref(), self.ast), self.ctx)
2197 
def ctx_ref(self)
Definition: z3py.py:410
Z3_ast Z3_API Z3_get_quantifier_body(Z3_context c, Z3_ast a)
Return body of quantifier.
def body(self)
Definition: z3py.py:2187
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 2242 of file z3py.py.

2242  def children(self):
2243  """Return a list containing a single element self.body()
2244 
2245  >>> f = Function('f', IntSort(), IntSort())
2246  >>> x = Int('x')
2247  >>> q = ForAll(x, f(x) == 0)
2248  >>> q.children()
2249  [f(Var(0)) == 0]
2250  """
2251  return [self.body()]
2252 
2253 
def children(self)
Definition: z3py.py:2242
def body(self)
Definition: z3py.py:2187
def get_id (   self)

Definition at line 2065 of file z3py.py.

2065  def get_id(self):
2066  return Z3_get_ast_id(self.ctx_ref(), self.as_ast())
2067 
def get_id(self)
Definition: z3py.py:2065
def as_ast(self)
Definition: z3py.py:402
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:410
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 2088 of file z3py.py.

2088  def is_exists(self):
2089  """Return `True` if `self` is an existential quantifier.
2090 
2091  >>> f = Function('f', IntSort(), IntSort())
2092  >>> x = Int('x')
2093  >>> q = ForAll(x, f(x) == 0)
2094  >>> q.is_exists()
2095  False
2096  >>> q = Exists(x, f(x) != 0)
2097  >>> q.is_exists()
2098  True
2099  """
2100  return Z3_is_quantifier_exists(self.ctx_ref(), self.ast)
2101 
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:2088
def ctx_ref(self)
Definition: z3py.py:410
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 2074 of file z3py.py.

2074  def is_forall(self):
2075  """Return `True` if `self` is a universal quantifier.
2076 
2077  >>> f = Function('f', IntSort(), IntSort())
2078  >>> x = Int('x')
2079  >>> q = ForAll(x, f(x) == 0)
2080  >>> q.is_forall()
2081  True
2082  >>> q = Exists(x, f(x) != 0)
2083  >>> q.is_forall()
2084  False
2085  """
2086  return Z3_is_quantifier_forall(self.ctx_ref(), self.ast)
2087 
def is_forall(self)
Definition: z3py.py:2074
def ctx_ref(self)
Definition: z3py.py:410
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 2102 of file z3py.py.

Referenced by QuantifierRef.__getitem__().

2102  def is_lambda(self):
2103  """Return `True` if `self` is a lambda expression.
2104 
2105  >>> f = Function('f', IntSort(), IntSort())
2106  >>> x = Int('x')
2107  >>> q = Lambda(x, f(x))
2108  >>> q.is_lambda()
2109  True
2110  >>> q = Exists(x, f(x) != 0)
2111  >>> q.is_lambda()
2112  False
2113  """
2114  return Z3_is_lambda(self.ctx_ref(), self.ast)
2115 
def is_lambda(self)
Definition: z3py.py:2102
def ctx_ref(self)
Definition: z3py.py:410
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 2181 of file z3py.py.

2181  def no_pattern(self, idx):
2182  """Return a no-pattern."""
2183  if z3_debug():
2184  _z3_assert(idx < self.num_no_patterns(), "Invalid no-pattern idx")
2185  return _to_expr_ref(Z3_get_quantifier_no_pattern_ast(self.ctx_ref(), self.ast, idx), self.ctx)
2186 
def num_no_patterns(self)
Definition: z3py.py:2177
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:410
def no_pattern(self, idx)
Definition: z3py.py:2181
def num_no_patterns (   self)
Return the number of no-patterns.

Definition at line 2177 of file z3py.py.

Referenced by QuantifierRef.no_pattern().

2177  def num_no_patterns(self):
2178  """Return the number of no-patterns."""
2179  return Z3_get_quantifier_num_no_patterns(self.ctx_ref(), self.ast)
2180 
def num_no_patterns(self)
Definition: z3py.py:2177
def ctx_ref(self)
Definition: z3py.py:410
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 2147 of file z3py.py.

2147  def num_patterns(self):
2148  """Return the number of patterns (i.e., quantifier instantiation hints) in `self`.
2149 
2150  >>> f = Function('f', IntSort(), IntSort())
2151  >>> g = Function('g', IntSort(), IntSort())
2152  >>> x = Int('x')
2153  >>> q = ForAll(x, f(x) != g(x), patterns = [ f(x), g(x) ])
2154  >>> q.num_patterns()
2155  2
2156  """
2157  return int(Z3_get_quantifier_num_patterns(self.ctx_ref(), self.ast))
2158 
def num_patterns(self)
Definition: z3py.py:2147
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:410
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 2198 of file z3py.py.

2198  def num_vars(self):
2199  """Return the number of variables bounded by this quantifier.
2200 
2201  >>> f = Function('f', IntSort(), IntSort(), IntSort())
2202  >>> x = Int('x')
2203  >>> y = Int('y')
2204  >>> q = ForAll([x, y], f(x, y) >= x)
2205  >>> q.num_vars()
2206  2
2207  """
2208  return int(Z3_get_quantifier_num_bound(self.ctx_ref(), self.ast))
2209 
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:410
def num_vars(self)
Definition: z3py.py:2198
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 2159 of file z3py.py.

2159  def pattern(self, idx):
2160  """Return a pattern (i.e., quantifier instantiation hints) in `self`.
2161 
2162  >>> f = Function('f', IntSort(), IntSort())
2163  >>> g = Function('g', IntSort(), IntSort())
2164  >>> x = Int('x')
2165  >>> q = ForAll(x, f(x) != g(x), patterns = [ f(x), g(x) ])
2166  >>> q.num_patterns()
2167  2
2168  >>> q.pattern(0)
2169  f(Var(0))
2170  >>> q.pattern(1)
2171  g(Var(0))
2172  """
2173  if z3_debug():
2174  _z3_assert(idx < self.num_patterns(), "Invalid pattern idx")
2175  return PatternRef(Z3_get_quantifier_pattern_ast(self.ctx_ref(), self.ast, idx), self.ctx)
2176 
Patterns.
Definition: z3py.py:1992
def num_patterns(self)
Definition: z3py.py:2147
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:2159
def z3_debug()
Definition: z3py.py:70
def ctx_ref(self)
Definition: z3py.py:410
def qid (   self)
Return the quantifier id of `self`.

Definition at line 2142 of file z3py.py.

2142  def qid(self):
2143  """Return the quantifier id of `self`.
2144  """
2145  return _symbol2py(self.ctx, Z3_get_quantifier_id(self.ctx_ref(), self.ast))
2146 
def qid(self)
Definition: z3py.py:2142
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:410
def skolem_id (   self)
Return the skolem id of `self`.

Definition at line 2137 of file z3py.py.

2137  def skolem_id(self):
2138  """Return the skolem id of `self`.
2139  """
2140  return _symbol2py(self.ctx, Z3_get_quantifier_skolem_id(self.ctx_ref(), self.ast))
2141 
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:2137
def ctx_ref(self)
Definition: z3py.py:410
def sort (   self)
Return the Boolean sort or sort of Lambda.

Definition at line 2068 of file z3py.py.

2068  def sort(self):
2069  """Return the Boolean sort or sort of Lambda."""
2070  if self.is_lambda():
2071  return _sort(self.ctx, self.as_ast())
2072  return BoolSort(self.ctx)
2073 
def BoolSort
Definition: z3py.py:1762
def as_ast(self)
Definition: z3py.py:402
def sort(self)
Definition: z3py.py:2068
def is_lambda(self)
Definition: z3py.py:2102
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 2210 of file z3py.py.

2210  def var_name(self, idx):
2211  """Return a string representing a name used when displaying the quantifier.
2212 
2213  >>> f = Function('f', IntSort(), IntSort(), IntSort())
2214  >>> x = Int('x')
2215  >>> y = Int('y')
2216  >>> q = ForAll([x, y], f(x, y) >= x)
2217  >>> q.var_name(0)
2218  'x'
2219  >>> q.var_name(1)
2220  'y'
2221  """
2222  if z3_debug():
2223  _z3_assert(idx < self.num_vars(), "Invalid variable idx")
2224  return _symbol2py(self.ctx, Z3_get_quantifier_bound_name(self.ctx_ref(), self.ast, idx))
2225 
def var_name(self, idx)
Definition: z3py.py:2210
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:410
def num_vars(self)
Definition: z3py.py:2198
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 2226 of file z3py.py.

2226  def var_sort(self, idx):
2227  """Return the sort of a bound variable.
2228 
2229  >>> f = Function('f', IntSort(), RealSort(), IntSort())
2230  >>> x = Int('x')
2231  >>> y = Real('y')
2232  >>> q = ForAll([x, y], f(x, y) >= x)
2233  >>> q.var_sort(0)
2234  Int
2235  >>> q.var_sort(1)
2236  Real
2237  """
2238  if z3_debug():
2239  _z3_assert(idx < self.num_vars(), "Invalid variable idx")
2240  return _to_sort_ref(Z3_get_quantifier_bound_sort(self.ctx_ref(), self.ast, idx), self.ctx)
2241 
def var_sort(self, idx)
Definition: z3py.py:2226
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:410
def num_vars(self)
Definition: z3py.py:2198
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 2123 of file z3py.py.

2123  def weight(self):
2124  """Return the weight annotation of `self`.
2125 
2126  >>> f = Function('f', IntSort(), IntSort())
2127  >>> x = Int('x')
2128  >>> q = ForAll(x, f(x) == 0)
2129  >>> q.weight()
2130  1
2131  >>> q = ForAll(x, f(x) == 0, weight=10)
2132  >>> q.weight()
2133  10
2134  """
2135  return int(Z3_get_quantifier_weight(self.ctx_ref(), self.ast))
2136 
unsigned Z3_API Z3_get_quantifier_weight(Z3_context c, Z3_ast a)
Obtain weight of quantifier.
def ctx_ref(self)
Definition: z3py.py:410
def weight(self)
Definition: z3py.py:2123