Z3
Public Member Functions | Data Fields
FuncEntry Class Reference

Public Member Functions

def __init__ (self, entry, ctx)
 
def __deepcopy__
 
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 6373 of file z3py.py.

Constructor & Destructor Documentation

def __init__ (   self,
  entry,
  ctx 
)

Definition at line 6376 of file z3py.py.

6376  def __init__(self, entry, ctx):
6377  self.entry = entry
6378  self.ctx = ctx
6379  Z3_func_entry_inc_ref(self.ctx.ref(), self.entry)
6380 
def __init__(self, entry, ctx)
Definition: z3py.py:6376
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.
ctx
Definition: z3py.py:6378
entry
Definition: z3py.py:6377
def __del__ (   self)

Definition at line 6384 of file z3py.py.

6384  def __del__(self):
6385  if self.ctx.ref() is not None and Z3_func_entry_dec_ref is not None:
6386  Z3_func_entry_dec_ref(self.ctx.ref(), self.entry)
6387 
def __del__(self)
Definition: z3py.py:6384
entry
Definition: z3py.py:6377
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

def __deepcopy__ (   self,
  memo = {} 
)

Definition at line 6381 of file z3py.py.

6381  def __deepcopy__(self, memo={}):
6382  return FuncEntry(self.entry, self.ctx)
6383 
def __deepcopy__
Definition: z3py.py:6381
Definition: z3py.py:6373
ctx
Definition: z3py.py:6378
entry
Definition: z3py.py:6377
def __repr__ (   self)

Definition at line 6478 of file z3py.py.

6478  def __repr__(self):
6479  return repr(self.as_list())
6480 
6481 
def __repr__(self)
Definition: z3py.py:6478
def as_list(self)
Definition: z3py.py:6459
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()
1
>>> e = f_i.entry(0)
>>> e
[1, 2, 20]
>>> e.num_args()
2
>>> e.arg_value(0)
1
>>> e.arg_value(1)
2
>>> try:
...   e.arg_value(2)
... except IndexError:
...   print("index error")
index error

Definition at line 6406 of file z3py.py.

6406  def arg_value(self, idx):
6407  """Return the value of argument `idx`.
6408 
6409  >>> f = Function('f', IntSort(), IntSort(), IntSort())
6410  >>> s = Solver()
6411  >>> s.add(f(0, 1) == 10, f(1, 2) == 20, f(1, 0) == 10)
6412  >>> s.check()
6413  sat
6414  >>> m = s.model()
6415  >>> f_i = m[f]
6416  >>> f_i.num_entries()
6417  1
6418  >>> e = f_i.entry(0)
6419  >>> e
6420  [1, 2, 20]
6421  >>> e.num_args()
6422  2
6423  >>> e.arg_value(0)
6424  1
6425  >>> e.arg_value(1)
6426  2
6427  >>> try:
6428  ... e.arg_value(2)
6429  ... except IndexError:
6430  ... print("index error")
6431  index error
6432  """
6433  if idx >= self.num_args():
6434  raise IndexError
6435  return _to_expr_ref(Z3_func_entry_get_arg(self.ctx.ref(), self.entry, idx), self.ctx)
6436 
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.
def num_args(self)
Definition: z3py.py:6388
ctx
Definition: z3py.py:6378
entry
Definition: z3py.py:6377
def arg_value(self, idx)
Definition: z3py.py:6406
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()
1
>>> e = f_i.entry(0)
>>> e.as_list()
[1, 2, 20]

Definition at line 6459 of file z3py.py.

Referenced by FuncEntry.__repr__().

6459  def as_list(self):
6460  """Return entry `self` as a Python list.
6461  >>> f = Function('f', IntSort(), IntSort(), IntSort())
6462  >>> s = Solver()
6463  >>> s.add(f(0, 1) == 10, f(1, 2) == 20, f(1, 0) == 10)
6464  >>> s.check()
6465  sat
6466  >>> m = s.model()
6467  >>> f_i = m[f]
6468  >>> f_i.num_entries()
6469  1
6470  >>> e = f_i.entry(0)
6471  >>> e.as_list()
6472  [1, 2, 20]
6473  """
6474  args = [self.arg_value(i) for i in range(self.num_args())]
6475  args.append(self.value())
6476  return args
6477 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:4343
def num_args(self)
Definition: z3py.py:6388
def value(self)
Definition: z3py.py:6437
def as_list(self)
Definition: z3py.py:6459
def arg_value(self, idx)
Definition: z3py.py:6406
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()
1
>>> e = f_i.entry(0)
>>> e.num_args()
2

Definition at line 6388 of file z3py.py.

Referenced by AstRef.__bool__(), FuncEntry.arg_value(), and FuncEntry.as_list().

6388  def num_args(self):
6389  """Return the number of arguments in the given entry.
6390 
6391  >>> f = Function('f', IntSort(), IntSort(), IntSort())
6392  >>> s = Solver()
6393  >>> s.add(f(0, 1) == 10, f(1, 2) == 20, f(1, 0) == 10)
6394  >>> s.check()
6395  sat
6396  >>> m = s.model()
6397  >>> f_i = m[f]
6398  >>> f_i.num_entries()
6399  1
6400  >>> e = f_i.entry(0)
6401  >>> e.num_args()
6402  2
6403  """
6404  return int(Z3_func_entry_get_num_args(self.ctx.ref(), self.entry))
6405 
def num_args(self)
Definition: z3py.py:6388
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.
entry
Definition: z3py.py:6377
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()
1
>>> e = f_i.entry(0)
>>> e
[1, 2, 20]
>>> e.num_args()
2
>>> e.value()
20

Definition at line 6437 of file z3py.py.

Referenced by FuncEntry.as_list().

6437  def value(self):
6438  """Return the value of the function at point `self`.
6439 
6440  >>> f = Function('f', IntSort(), IntSort(), IntSort())
6441  >>> s = Solver()
6442  >>> s.add(f(0, 1) == 10, f(1, 2) == 20, f(1, 0) == 10)
6443  >>> s.check()
6444  sat
6445  >>> m = s.model()
6446  >>> f_i = m[f]
6447  >>> f_i.num_entries()
6448  1
6449  >>> e = f_i.entry(0)
6450  >>> e
6451  [1, 2, 20]
6452  >>> e.num_args()
6453  2
6454  >>> e.value()
6455  20
6456  """
6457  return _to_expr_ref(Z3_func_entry_get_value(self.ctx.ref(), self.entry), self.ctx)
6458 
Z3_ast Z3_API Z3_func_entry_get_value(Z3_context c, Z3_func_entry e)
Return the value of this point.
def value(self)
Definition: z3py.py:6437
ctx
Definition: z3py.py:6378
entry
Definition: z3py.py:6377

Field Documentation

ctx
entry