Z3
Public Member Functions | Data Fields
FuncEntry Class Reference

Public Member Functions

def __init__ (self, entry, ctx)
 
def __deepcopy__ (self, memo={})
 
def __del__ (self)
 
def num_args (self)
 
def arg_value (self, idx)
 
def value (self)
 
def as_list (self)
 
def __repr__ (self)
 

Data Fields

 entry
 
 ctx
 

Detailed Description

Store the value of the interpretation of a function in a particular point.

Definition at line 5395 of file z3py.py.

Constructor & Destructor Documentation

§ __init__()

def __init__ (   self,
  entry,
  ctx 
)

Definition at line 5398 of file z3py.py.

5398  def __init__(self, entry, ctx):
5399  self.entry = entry
5400  self.ctx = ctx
5401  Z3_func_entry_inc_ref(self.ctx.ref(), self.entry)
5402 
void Z3_API Z3_func_entry_inc_ref(Z3_context c, Z3_func_entry e)
Increment the reference counter of the given Z3_func_entry object.

§ __del__()

def __del__ (   self)

Definition at line 5406 of file z3py.py.

5406  def __del__(self):
5407  if self.ctx.ref() is not None:
5408  Z3_func_entry_dec_ref(self.ctx.ref(), self.entry)
5409 
void Z3_API Z3_func_entry_dec_ref(Z3_context c, Z3_func_entry e)
Decrement the reference counter of the given Z3_func_entry object.

Member Function Documentation

§ __deepcopy__()

def __deepcopy__ (   self,
  memo = {} 
)

Definition at line 5403 of file z3py.py.

5403  def __deepcopy__(self, memo={}):
5404  return FuncEntry(self.entry, self.ctx)
5405 

§ __repr__()

def __repr__ (   self)

Definition at line 5500 of file z3py.py.

5500  def __repr__(self):
5501  return repr(self.as_list())
5502 

§ arg_value()

def arg_value (   self,
  idx 
)
Return the value of argument `idx`.

>>> f = Function('f', IntSort(), IntSort(), IntSort())
>>> s = Solver()
>>> s.add(f(0, 1) == 10, f(1, 2) == 20, f(1, 0) == 10)
>>> s.check()
sat
>>> m = s.model()
>>> f_i = m[f]
>>> f_i.num_entries()
3
>>> e = f_i.entry(0)
>>> e
[0, 1, 10]
>>> e.num_args()
2
>>> e.arg_value(0)
0
>>> e.arg_value(1)
1
>>> try:
...   e.arg_value(2)
... except IndexError:
...   print("index error")
index error

Definition at line 5428 of file z3py.py.

5428  def arg_value(self, idx):
5429  """Return the value of argument `idx`.
5430 
5431  >>> f = Function('f', IntSort(), IntSort(), IntSort())
5432  >>> s = Solver()
5433  >>> s.add(f(0, 1) == 10, f(1, 2) == 20, f(1, 0) == 10)
5434  >>> s.check()
5435  sat
5436  >>> m = s.model()
5437  >>> f_i = m[f]
5438  >>> f_i.num_entries()
5439  3
5440  >>> e = f_i.entry(0)
5441  >>> e
5442  [0, 1, 10]
5443  >>> e.num_args()
5444  2
5445  >>> e.arg_value(0)
5446  0
5447  >>> e.arg_value(1)
5448  1
5449  >>> try:
5450  ... e.arg_value(2)
5451  ... except IndexError:
5452  ... print("index error")
5453  index error
5454  """
5455  if idx >= self.num_args():
5456  raise IndexError
5457  return _to_expr_ref(Z3_func_entry_get_arg(self.ctx.ref(), self.entry, idx), self.ctx)
5458 
Z3_ast Z3_API Z3_func_entry_get_arg(Z3_context c, Z3_func_entry e, unsigned i)
Return an argument of a Z3_func_entry object.

§ as_list()

def as_list (   self)
Return entry `self` as a Python list.
>>> f = Function('f', IntSort(), IntSort(), IntSort())
>>> s = Solver()
>>> s.add(f(0, 1) == 10, f(1, 2) == 20, f(1, 0) == 10)
>>> s.check()
sat
>>> m = s.model()
>>> f_i = m[f]
>>> f_i.num_entries()
3
>>> e = f_i.entry(0)
>>> e.as_list()
[0, 1, 10]

Definition at line 5481 of file z3py.py.

5481  def as_list(self):
5482  """Return entry `self` as a Python list.
5483  >>> f = Function('f', IntSort(), IntSort(), IntSort())
5484  >>> s = Solver()
5485  >>> s.add(f(0, 1) == 10, f(1, 2) == 20, f(1, 0) == 10)
5486  >>> s.check()
5487  sat
5488  >>> m = s.model()
5489  >>> f_i = m[f]
5490  >>> f_i.num_entries()
5491  3
5492  >>> e = f_i.entry(0)
5493  >>> e.as_list()
5494  [0, 1, 10]
5495  """
5496  args = [ self.arg_value(i) for i in range(self.num_args())]
5497  args.append(self.value())
5498  return args
5499 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:2868

§ num_args()

def num_args (   self)
Return the number of arguments in the given entry.

>>> f = Function('f', IntSort(), IntSort(), IntSort())
>>> s = Solver()
>>> s.add(f(0, 1) == 10, f(1, 2) == 20, f(1, 0) == 10)
>>> s.check()
sat
>>> m = s.model()
>>> f_i = m[f]
>>> f_i.num_entries()
3
>>> e = f_i.entry(0)
>>> e.num_args()
2

Definition at line 5410 of file z3py.py.

Referenced by AstRef.__bool__().

5410  def num_args(self):
5411  """Return the number of arguments in the given entry.
5412 
5413  >>> f = Function('f', IntSort(), IntSort(), IntSort())
5414  >>> s = Solver()
5415  >>> s.add(f(0, 1) == 10, f(1, 2) == 20, f(1, 0) == 10)
5416  >>> s.check()
5417  sat
5418  >>> m = s.model()
5419  >>> f_i = m[f]
5420  >>> f_i.num_entries()
5421  3
5422  >>> e = f_i.entry(0)
5423  >>> e.num_args()
5424  2
5425  """
5426  return int(Z3_func_entry_get_num_args(self.ctx.ref(), self.entry))
5427 
unsigned Z3_API Z3_func_entry_get_num_args(Z3_context c, Z3_func_entry e)
Return the number of arguments in a Z3_func_entry object.

§ value()

def value (   self)
Return the value of the function at point `self`.

>>> f = Function('f', IntSort(), IntSort(), IntSort())
>>> s = Solver()
>>> s.add(f(0, 1) == 10, f(1, 2) == 20, f(1, 0) == 10)
>>> s.check()
sat
>>> m = s.model()
>>> f_i = m[f]
>>> f_i.num_entries()
3
>>> e = f_i.entry(0)
>>> e
[0, 1, 10]
>>> e.num_args()
2
>>> e.value()
10

Definition at line 5459 of file z3py.py.

5459  def value(self):
5460  """Return the value of the function at point `self`.
5461 
5462  >>> f = Function('f', IntSort(), IntSort(), IntSort())
5463  >>> s = Solver()
5464  >>> s.add(f(0, 1) == 10, f(1, 2) == 20, f(1, 0) == 10)
5465  >>> s.check()
5466  sat
5467  >>> m = s.model()
5468  >>> f_i = m[f]
5469  >>> f_i.num_entries()
5470  3
5471  >>> e = f_i.entry(0)
5472  >>> e
5473  [0, 1, 10]
5474  >>> e.num_args()
5475  2
5476  >>> e.value()
5477  10
5478  """
5479  return _to_expr_ref(Z3_func_entry_get_value(self.ctx.ref(), self.entry), self.ctx)
5480 
Z3_ast Z3_API Z3_func_entry_get_value(Z3_context c, Z3_func_entry e)
Return the value of this point.

Field Documentation

§ ctx

ctx

Definition at line 5400 of file z3py.py.

Referenced by Probe.__call__(), Fixedpoint.__deepcopy__(), Optimize.__deepcopy__(), ApplyResult.__deepcopy__(), Tactic.__deepcopy__(), Probe.__deepcopy__(), Fixedpoint.__del__(), Optimize.__del__(), ApplyResult.__del__(), Tactic.__del__(), Probe.__del__(), Probe.__eq__(), Probe.__ge__(), ApplyResult.__getitem__(), Probe.__gt__(), Probe.__le__(), ApplyResult.__len__(), Probe.__lt__(), Probe.__ne__(), Fixedpoint.add_cover(), Fixedpoint.add_rule(), Optimize.add_soft(), Tactic.apply(), ApplyResult.as_expr(), Fixedpoint.assert_exprs(), Optimize.assert_exprs(), Optimize.assertions(), Optimize.check(), ApplyResult.convert_model(), Optimize.from_file(), Optimize.from_string(), Fixedpoint.get_answer(), Fixedpoint.get_assertions(), Fixedpoint.get_cover_delta(), Fixedpoint.get_ground_sat_answer(), Fixedpoint.get_num_levels(), Fixedpoint.get_rule_names_along_trace(), Fixedpoint.get_rules(), Fixedpoint.get_rules_along_trace(), Fixedpoint.help(), Optimize.help(), Tactic.help(), Optimize.maximize(), Optimize.minimize(), Optimize.model(), Optimize.objectives(), Fixedpoint.param_descrs(), Optimize.param_descrs(), Tactic.param_descrs(), Fixedpoint.parse_file(), Fixedpoint.parse_string(), Fixedpoint.pop(), Optimize.pop(), Fixedpoint.push(), Optimize.push(), Fixedpoint.query(), Fixedpoint.query_from_lvl(), Fixedpoint.reason_unknown(), Optimize.reason_unknown(), Fixedpoint.register_relation(), Fixedpoint.set(), Optimize.set(), Fixedpoint.set_predicate_representation(), Fixedpoint.sexpr(), Optimize.sexpr(), ApplyResult.sexpr(), Tactic.solver(), Fixedpoint.statistics(), Optimize.statistics(), Solver.to_smt2(), Fixedpoint.to_string(), and Fixedpoint.update_rule().

§ entry

entry

Definition at line 5399 of file z3py.py.