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

Constructor & Destructor Documentation

§ __init__()

def __init__ (   self,
  entry,
  ctx 
)

Definition at line 5355 of file z3py.py.

5355  def __init__(self, entry, ctx):
5356  self.entry = entry
5357  self.ctx = ctx
5358  Z3_func_entry_inc_ref(self.ctx.ref(), self.entry)
5359 
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 5363 of file z3py.py.

5363  def __del__(self):
5364  if self.ctx.ref() is not None:
5365  Z3_func_entry_dec_ref(self.ctx.ref(), self.entry)
5366 
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 5360 of file z3py.py.

5360  def __deepcopy__(self, memo={}):
5361  return FuncEntry(self.entry, self.ctx)
5362 

§ __repr__()

def __repr__ (   self)

Definition at line 5457 of file z3py.py.

5457  def __repr__(self):
5458  return repr(self.as_list())
5459 

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

5385  def arg_value(self, idx):
5386  """Return the value of argument `idx`.
5387 
5388  >>> f = Function('f', IntSort(), IntSort(), IntSort())
5389  >>> s = Solver()
5390  >>> s.add(f(0, 1) == 10, f(1, 2) == 20, f(1, 0) == 10)
5391  >>> s.check()
5392  sat
5393  >>> m = s.model()
5394  >>> f_i = m[f]
5395  >>> f_i.num_entries()
5396  3
5397  >>> e = f_i.entry(0)
5398  >>> e
5399  [0, 1, 10]
5400  >>> e.num_args()
5401  2
5402  >>> e.arg_value(0)
5403  0
5404  >>> e.arg_value(1)
5405  1
5406  >>> try:
5407  ... e.arg_value(2)
5408  ... except IndexError:
5409  ... print("index error")
5410  index error
5411  """
5412  if idx >= self.num_args():
5413  raise IndexError
5414  return _to_expr_ref(Z3_func_entry_get_arg(self.ctx.ref(), self.entry, idx), self.ctx)
5415 
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 5438 of file z3py.py.

5438  def as_list(self):
5439  """Return entry `self` as a Python list.
5440  >>> f = Function('f', IntSort(), IntSort(), IntSort())
5441  >>> s = Solver()
5442  >>> s.add(f(0, 1) == 10, f(1, 2) == 20, f(1, 0) == 10)
5443  >>> s.check()
5444  sat
5445  >>> m = s.model()
5446  >>> f_i = m[f]
5447  >>> f_i.num_entries()
5448  3
5449  >>> e = f_i.entry(0)
5450  >>> e.as_list()
5451  [0, 1, 10]
5452  """
5453  args = [ self.arg_value(i) for i in range(self.num_args())]
5454  args.append(self.value())
5455  return args
5456 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:2813

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

Referenced by AstRef.__bool__().

5367  def num_args(self):
5368  """Return the number of arguments in the given entry.
5369 
5370  >>> f = Function('f', IntSort(), IntSort(), IntSort())
5371  >>> s = Solver()
5372  >>> s.add(f(0, 1) == 10, f(1, 2) == 20, f(1, 0) == 10)
5373  >>> s.check()
5374  sat
5375  >>> m = s.model()
5376  >>> f_i = m[f]
5377  >>> f_i.num_entries()
5378  3
5379  >>> e = f_i.entry(0)
5380  >>> e.num_args()
5381  2
5382  """
5383  return int(Z3_func_entry_get_num_args(self.ctx.ref(), self.entry))
5384 
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 5416 of file z3py.py.

5416  def value(self):
5417  """Return the value of the function at point `self`.
5418 
5419  >>> f = Function('f', IntSort(), IntSort(), IntSort())
5420  >>> s = Solver()
5421  >>> s.add(f(0, 1) == 10, f(1, 2) == 20, f(1, 0) == 10)
5422  >>> s.check()
5423  sat
5424  >>> m = s.model()
5425  >>> f_i = m[f]
5426  >>> f_i.num_entries()
5427  3
5428  >>> e = f_i.entry(0)
5429  >>> e
5430  [0, 1, 10]
5431  >>> e.num_args()
5432  2
5433  >>> e.value()
5434  10
5435  """
5436  return _to_expr_ref(Z3_func_entry_get_value(self.ctx.ref(), self.entry), self.ctx)
5437 
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 5357 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 5356 of file z3py.py.