Z3
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Data Fields
FuncEntry Class Reference

Public Member Functions

def __init__
 
def __del__
 
def num_args
 
def arg_value
 
def value
 
def as_list
 
def __repr__
 

Data Fields

 entry
 
 ctx
 

Detailed Description

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

Definition at line 5117 of file z3py.py.

Constructor & Destructor Documentation

def __init__ (   self,
  entry,
  ctx 
)

Definition at line 5120 of file z3py.py.

5121  def __init__(self, entry, ctx):
5122  self.entry = entry
5123  self.ctx = ctx
5124  Z3_func_entry_inc_ref(self.ctx.ref(), self.entry)
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:5122
entry
Definition: z3py.py:5121
def __init__
Definition: z3py.py:5120
def __del__ (   self)

Definition at line 5125 of file z3py.py.

5126  def __del__(self):
5127  Z3_func_entry_dec_ref(self.ctx.ref(), self.entry)
def __del__
Definition: z3py.py:5125
entry
Definition: z3py.py:5121
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 __repr__ (   self)

Definition at line 5218 of file z3py.py.

5219  def __repr__(self):
return repr(self.as_list())
def as_list
Definition: z3py.py:5199
def __repr__
Definition: z3py.py:5218
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 5146 of file z3py.py.

5147  def arg_value(self, idx):
5148  """Return the value of argument `idx`.
5149 
5150  >>> f = Function('f', IntSort(), IntSort(), IntSort())
5151  >>> s = Solver()
5152  >>> s.add(f(0, 1) == 10, f(1, 2) == 20, f(1, 0) == 10)
5153  >>> s.check()
5154  sat
5155  >>> m = s.model()
5156  >>> f_i = m[f]
5157  >>> f_i.num_entries()
5158  3
5159  >>> e = f_i.entry(0)
5160  >>> e
5161  [0, 1, 10]
5162  >>> e.num_args()
5163  2
5164  >>> e.arg_value(0)
5165  0
5166  >>> e.arg_value(1)
5167  1
5168  >>> try:
5169  ... e.arg_value(2)
5170  ... except IndexError:
5171  ... print("index error")
5172  index error
5173  """
5174  if idx >= self.num_args():
5175  raise IndexError
5176  return _to_expr_ref(Z3_func_entry_get_arg(self.ctx.ref(), self.entry, idx), self.ctx)
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 arg_value
Definition: z3py.py:5146
ctx
Definition: z3py.py:5122
entry
Definition: z3py.py:5121
def num_args
Definition: z3py.py:5128
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 5199 of file z3py.py.

Referenced by FuncEntry.__repr__().

5200  def as_list(self):
5201  """Return entry `self` as a Python list.
5202  >>> f = Function('f', IntSort(), IntSort(), IntSort())
5203  >>> s = Solver()
5204  >>> s.add(f(0, 1) == 10, f(1, 2) == 20, f(1, 0) == 10)
5205  >>> s.check()
5206  sat
5207  >>> m = s.model()
5208  >>> f_i = m[f]
5209  >>> f_i.num_entries()
5210  3
5211  >>> e = f_i.entry(0)
5212  >>> e.as_list()
5213  [0, 1, 10]
5214  """
5215  args = [ self.arg_value(i) for i in range(self.num_args())]
5216  args.append(self.value())
5217  return args
def as_list
Definition: z3py.py:5199
def value
Definition: z3py.py:5177
def arg_value
Definition: z3py.py:5146
def num_args
Definition: z3py.py:5128
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 5128 of file z3py.py.

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

5129  def num_args(self):
5130  """Return the number of arguments in the given entry.
5131 
5132  >>> f = Function('f', IntSort(), IntSort(), IntSort())
5133  >>> s = Solver()
5134  >>> s.add(f(0, 1) == 10, f(1, 2) == 20, f(1, 0) == 10)
5135  >>> s.check()
5136  sat
5137  >>> m = s.model()
5138  >>> f_i = m[f]
5139  >>> f_i.num_entries()
5140  3
5141  >>> e = f_i.entry(0)
5142  >>> e.num_args()
5143  2
5144  """
5145  return int(Z3_func_entry_get_num_args(self.ctx.ref(), self.entry))
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:5121
def num_args
Definition: z3py.py:5128
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 5177 of file z3py.py.

Referenced by FuncEntry.as_list().

5178  def value(self):
5179  """Return the value of the function at point `self`.
5180 
5181  >>> f = Function('f', IntSort(), IntSort(), IntSort())
5182  >>> s = Solver()
5183  >>> s.add(f(0, 1) == 10, f(1, 2) == 20, f(1, 0) == 10)
5184  >>> s.check()
5185  sat
5186  >>> m = s.model()
5187  >>> f_i = m[f]
5188  >>> f_i.num_entries()
5189  3
5190  >>> e = f_i.entry(0)
5191  >>> e
5192  [0, 1, 10]
5193  >>> e.num_args()
5194  2
5195  >>> e.value()
5196  10
5197  """
5198  return _to_expr_ref(Z3_func_entry_get_value(self.ctx.ref(), self.entry), self.ctx)
def value
Definition: z3py.py:5177
Z3_ast Z3_API Z3_func_entry_get_value(Z3_context c, Z3_func_entry e)
Return the value of this point.
ctx
Definition: z3py.py:5122
entry
Definition: z3py.py:5121

Field Documentation

ctx

Definition at line 5122 of file z3py.py.

Referenced by Probe.__eq__(), Probe.__ge__(), ApplyResult.__getitem__(), Probe.__gt__(), Probe.__le__(), Probe.__lt__(), Probe.__ne__(), Fixedpoint.add_rule(), Optimize.add_soft(), Tactic.apply(), FuncEntry.arg_value(), ApplyResult.as_expr(), Fixedpoint.assert_exprs(), ApplyResult.convert_model(), Fixedpoint.get_answer(), Fixedpoint.get_assertions(), Fixedpoint.get_cover_delta(), Fixedpoint.get_rules(), Optimize.model(), Fixedpoint.param_descrs(), Optimize.param_descrs(), Tactic.param_descrs(), Fixedpoint.parse_file(), Fixedpoint.parse_string(), Fixedpoint.query(), Fixedpoint.set(), Optimize.set(), Tactic.solver(), Fixedpoint.statistics(), Optimize.statistics(), Solver.to_smt2(), Fixedpoint.update_rule(), and FuncEntry.value().

entry

Definition at line 5121 of file z3py.py.

Referenced by FuncEntry.__del__(), FuncEntry.arg_value(), FuncEntry.num_args(), and FuncEntry.value().