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

Constructor & Destructor Documentation

def __init__ (   self,
  entry,
  ctx 
)

Definition at line 6075 of file z3py.py.

6075  def __init__(self, entry, ctx):
6076  self.entry = entry
6077  self.ctx = ctx
6078  Z3_func_entry_inc_ref(self.ctx.ref(), self.entry)
6079 
def __init__(self, entry, ctx)
Definition: z3py.py:6075
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:6077
entry
Definition: z3py.py:6076
def __del__ (   self)

Definition at line 6083 of file z3py.py.

6083  def __del__(self):
6084  if self.ctx.ref() is not None:
6085  Z3_func_entry_dec_ref(self.ctx.ref(), self.entry)
6086 
def __del__(self)
Definition: z3py.py:6083
entry
Definition: z3py.py:6076
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 6080 of file z3py.py.

6080  def __deepcopy__(self, memo={}):
6081  return FuncEntry(self.entry, self.ctx)
6082 
def __deepcopy__
Definition: z3py.py:6080
Definition: z3py.py:6072
ctx
Definition: z3py.py:6077
entry
Definition: z3py.py:6076
def __repr__ (   self)

Definition at line 6177 of file z3py.py.

6177  def __repr__(self):
6178  return repr(self.as_list())
6179 
6180 
def __repr__(self)
Definition: z3py.py:6177
def as_list(self)
Definition: z3py.py:6158
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 6105 of file z3py.py.

6105  def arg_value(self, idx):
6106  """Return the value of argument `idx`.
6107 
6108  >>> f = Function('f', IntSort(), IntSort(), IntSort())
6109  >>> s = Solver()
6110  >>> s.add(f(0, 1) == 10, f(1, 2) == 20, f(1, 0) == 10)
6111  >>> s.check()
6112  sat
6113  >>> m = s.model()
6114  >>> f_i = m[f]
6115  >>> f_i.num_entries()
6116  1
6117  >>> e = f_i.entry(0)
6118  >>> e
6119  [1, 2, 20]
6120  >>> e.num_args()
6121  2
6122  >>> e.arg_value(0)
6123  1
6124  >>> e.arg_value(1)
6125  2
6126  >>> try:
6127  ... e.arg_value(2)
6128  ... except IndexError:
6129  ... print("index error")
6130  index error
6131  """
6132  if idx >= self.num_args():
6133  raise IndexError
6134  return _to_expr_ref(Z3_func_entry_get_arg(self.ctx.ref(), self.entry, idx), self.ctx)
6135 
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:6087
ctx
Definition: z3py.py:6077
entry
Definition: z3py.py:6076
def arg_value(self, idx)
Definition: z3py.py:6105
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 6158 of file z3py.py.

Referenced by FuncEntry.__repr__().

6158  def as_list(self):
6159  """Return entry `self` as a Python list.
6160  >>> f = Function('f', IntSort(), IntSort(), IntSort())
6161  >>> s = Solver()
6162  >>> s.add(f(0, 1) == 10, f(1, 2) == 20, f(1, 0) == 10)
6163  >>> s.check()
6164  sat
6165  >>> m = s.model()
6166  >>> f_i = m[f]
6167  >>> f_i.num_entries()
6168  1
6169  >>> e = f_i.entry(0)
6170  >>> e.as_list()
6171  [1, 2, 20]
6172  """
6173  args = [self.arg_value(i) for i in range(self.num_args())]
6174  args.append(self.value())
6175  return args
6176 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3794
def num_args(self)
Definition: z3py.py:6087
def value(self)
Definition: z3py.py:6136
def as_list(self)
Definition: z3py.py:6158
def arg_value(self, idx)
Definition: z3py.py:6105
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 6087 of file z3py.py.

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

6087  def num_args(self):
6088  """Return the number of arguments in the given entry.
6089 
6090  >>> f = Function('f', IntSort(), IntSort(), IntSort())
6091  >>> s = Solver()
6092  >>> s.add(f(0, 1) == 10, f(1, 2) == 20, f(1, 0) == 10)
6093  >>> s.check()
6094  sat
6095  >>> m = s.model()
6096  >>> f_i = m[f]
6097  >>> f_i.num_entries()
6098  1
6099  >>> e = f_i.entry(0)
6100  >>> e.num_args()
6101  2
6102  """
6103  return int(Z3_func_entry_get_num_args(self.ctx.ref(), self.entry))
6104 
def num_args(self)
Definition: z3py.py:6087
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:6076
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 6136 of file z3py.py.

Referenced by FuncEntry.as_list().

6136  def value(self):
6137  """Return the value of the function at point `self`.
6138 
6139  >>> f = Function('f', IntSort(), IntSort(), IntSort())
6140  >>> s = Solver()
6141  >>> s.add(f(0, 1) == 10, f(1, 2) == 20, f(1, 0) == 10)
6142  >>> s.check()
6143  sat
6144  >>> m = s.model()
6145  >>> f_i = m[f]
6146  >>> f_i.num_entries()
6147  1
6148  >>> e = f_i.entry(0)
6149  >>> e
6150  [1, 2, 20]
6151  >>> e.num_args()
6152  2
6153  >>> e.value()
6154  20
6155  """
6156  return _to_expr_ref(Z3_func_entry_get_value(self.ctx.ref(), self.entry), self.ctx)
6157 
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:6136
ctx
Definition: z3py.py:6077
entry
Definition: z3py.py:6076

Field Documentation

ctx
entry