Z3
Public Member Functions | Data Fields
FuncInterp Class Reference
+ Inheritance diagram for FuncInterp:

Public Member Functions

def __init__ (self, f, ctx)
 
def __deepcopy__ (self, memo={})
 
def __del__ (self)
 
def else_value (self)
 
def num_entries (self)
 
def arity (self)
 
def entry (self, idx)
 
def translate (self, other_ctx)
 
def __copy__ (self)
 
def __deepcopy__ (self, memo={})
 
def as_list (self)
 
def __repr__ (self)
 
- Public Member Functions inherited from Z3PPObject
def use_pp (self)
 

Data Fields

 f
 
 ctx
 

Detailed Description

Stores the interpretation of a function in a Z3 model.

Definition at line 5881 of file z3py.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  f,
  ctx 
)

Definition at line 5884 of file z3py.py.

5884  def __init__(self, f, ctx):
5885  self.f = f
5886  self.ctx = ctx
5887  if self.f is not None:
5888  Z3_func_interp_inc_ref(self.ctx.ref(), self.f)
5889 

◆ __del__()

def __del__ (   self)

Definition at line 5893 of file z3py.py.

5893  def __del__(self):
5894  if self.f is not None and self.ctx.ref() is not None:
5895  Z3_func_interp_dec_ref(self.ctx.ref(), self.f)
5896 

Member Function Documentation

◆ __copy__()

def __copy__ (   self)

Definition at line 5975 of file z3py.py.

5975  def __copy__(self):
5976  return self.translate(self.ctx)
5977 

◆ __deepcopy__() [1/2]

def __deepcopy__ (   self,
  memo = {} 
)

Definition at line 5890 of file z3py.py.

5890  def __deepcopy__(self, memo={}):
5891  return FuncInterp(self.f, self.ctx)
5892 

Referenced by FuncInterp.__deepcopy__().

◆ __deepcopy__() [2/2]

def __deepcopy__ (   self,
  memo = {} 
)

Definition at line 5978 of file z3py.py.

5978  def __deepcopy__(self, memo={}):
5979  return self.translate(self.ctx)
5980 

◆ __repr__()

def __repr__ (   self)

Definition at line 5998 of file z3py.py.

5998  def __repr__(self):
5999  return obj_to_string(self)
6000 

◆ arity()

def arity (   self)
Return the number of arguments for each entry in the function interpretation `self`.

>>> f = Function('f', IntSort(), IntSort())
>>> s = Solver()
>>> s.add(f(0) == 1, f(1) == 1, f(2) == 0)
>>> s.check()
sat
>>> m = s.model()
>>> m[f].arity()
1

Definition at line 5936 of file z3py.py.

5936  def arity(self):
5937  """Return the number of arguments for each entry in the function interpretation `self`.
5938 
5939  >>> f = Function('f', IntSort(), IntSort())
5940  >>> s = Solver()
5941  >>> s.add(f(0) == 1, f(1) == 1, f(2) == 0)
5942  >>> s.check()
5943  sat
5944  >>> m = s.model()
5945  >>> m[f].arity()
5946  1
5947  """
5948  return int(Z3_func_interp_get_arity(self.ctx.ref(), self.f))
5949 

◆ as_list()

def as_list (   self)
Return the function interpretation as a Python list.
>>> f = Function('f', IntSort(), IntSort())
>>> s = Solver()
>>> s.add(f(0) == 1, f(1) == 1, f(2) == 0)
>>> s.check()
sat
>>> m = s.model()
>>> m[f]
[2 -> 0, else -> 1]
>>> m[f].as_list()
[[2, 0], 1]

Definition at line 5981 of file z3py.py.

5981  def as_list(self):
5982  """Return the function interpretation as a Python list.
5983  >>> f = Function('f', IntSort(), IntSort())
5984  >>> s = Solver()
5985  >>> s.add(f(0) == 1, f(1) == 1, f(2) == 0)
5986  >>> s.check()
5987  sat
5988  >>> m = s.model()
5989  >>> m[f]
5990  [2 -> 0, else -> 1]
5991  >>> m[f].as_list()
5992  [[2, 0], 1]
5993  """
5994  r = [ self.entry(i).as_list() for i in range(self.num_entries())]
5995  r.append(self.else_value())
5996  return r
5997 

◆ else_value()

def else_value (   self)
Return the `else` value for a function interpretation.
Return None if Z3 did not specify the `else` value for
this object.

>>> f = Function('f', IntSort(), IntSort())
>>> s = Solver()
>>> s.add(f(0) == 1, f(1) == 1, f(2) == 0)
>>> s.check()
sat
>>> m = s.model()
>>> m[f]
[2 -> 0, else -> 1]
>>> m[f].else_value()
1

Definition at line 5897 of file z3py.py.

5897  def else_value(self):
5898  """
5899  Return the `else` value for a function interpretation.
5900  Return None if Z3 did not specify the `else` value for
5901  this object.
5902 
5903  >>> f = Function('f', IntSort(), IntSort())
5904  >>> s = Solver()
5905  >>> s.add(f(0) == 1, f(1) == 1, f(2) == 0)
5906  >>> s.check()
5907  sat
5908  >>> m = s.model()
5909  >>> m[f]
5910  [2 -> 0, else -> 1]
5911  >>> m[f].else_value()
5912  1
5913  """
5914  r = Z3_func_interp_get_else(self.ctx.ref(), self.f)
5915  if r:
5916  return _to_expr_ref(r, self.ctx)
5917  else:
5918  return None
5919 

Referenced by FuncInterp.as_list().

◆ entry()

def entry (   self,
  idx 
)
Return an entry at position `idx < self.num_entries()` in the function interpretation `self`.

>>> f = Function('f', IntSort(), IntSort())
>>> s = Solver()
>>> s.add(f(0) == 1, f(1) == 1, f(2) == 0)
>>> s.check()
sat
>>> m = s.model()
>>> m[f]
[2 -> 0, else -> 1]
>>> m[f].num_entries()
1
>>> m[f].entry(0)
[2, 0]

Definition at line 5950 of file z3py.py.

5950  def entry(self, idx):
5951  """Return an entry at position `idx < self.num_entries()` in the function interpretation `self`.
5952 
5953  >>> f = Function('f', IntSort(), IntSort())
5954  >>> s = Solver()
5955  >>> s.add(f(0) == 1, f(1) == 1, f(2) == 0)
5956  >>> s.check()
5957  sat
5958  >>> m = s.model()
5959  >>> m[f]
5960  [2 -> 0, else -> 1]
5961  >>> m[f].num_entries()
5962  1
5963  >>> m[f].entry(0)
5964  [2, 0]
5965  """
5966  if idx >= self.num_entries():
5967  raise IndexError
5968  return FuncEntry(Z3_func_interp_get_entry(self.ctx.ref(), self.f, idx), self.ctx)
5969 

Referenced by FuncInterp.as_list().

◆ num_entries()

def num_entries (   self)
Return the number of entries/points in the function interpretation `self`.

>>> f = Function('f', IntSort(), IntSort())
>>> s = Solver()
>>> s.add(f(0) == 1, f(1) == 1, f(2) == 0)
>>> s.check()
sat
>>> m = s.model()
>>> m[f]
[2 -> 0, else -> 1]
>>> m[f].num_entries()
1

Definition at line 5920 of file z3py.py.

5920  def num_entries(self):
5921  """Return the number of entries/points in the function interpretation `self`.
5922 
5923  >>> f = Function('f', IntSort(), IntSort())
5924  >>> s = Solver()
5925  >>> s.add(f(0) == 1, f(1) == 1, f(2) == 0)
5926  >>> s.check()
5927  sat
5928  >>> m = s.model()
5929  >>> m[f]
5930  [2 -> 0, else -> 1]
5931  >>> m[f].num_entries()
5932  1
5933  """
5934  return int(Z3_func_interp_get_num_entries(self.ctx.ref(), self.f))
5935 

Referenced by FuncInterp.as_list(), and FuncInterp.entry().

◆ translate()

def translate (   self,
  other_ctx 
)
Copy model 'self' to context 'other_ctx'.

Definition at line 5970 of file z3py.py.

5970  def translate(self, other_ctx):
5971  """Copy model 'self' to context 'other_ctx'.
5972  """
5973  return ModelRef(Z3_model_translate(self.ctx.ref(), self.model, other_ctx.ref()), other_ctx)
5974 

Referenced by FuncInterp.__copy__(), ModelRef.__copy__(), Solver.__copy__(), FuncInterp.__deepcopy__(), ModelRef.__deepcopy__(), and Solver.__deepcopy__().

Field Documentation

◆ ctx

ctx

Definition at line 5886 of file z3py.py.

Referenced by Probe.__call__(), FuncInterp.__copy__(), ModelRef.__copy__(), Solver.__copy__(), FuncInterp.__deepcopy__(), ModelRef.__deepcopy__(), Statistics.__deepcopy__(), Solver.__deepcopy__(), Fixedpoint.__deepcopy__(), Optimize.__deepcopy__(), ApplyResult.__deepcopy__(), Tactic.__deepcopy__(), Probe.__deepcopy__(), FuncInterp.__del__(), ModelRef.__del__(), Statistics.__del__(), Solver.__del__(), Fixedpoint.__del__(), Optimize.__del__(), ApplyResult.__del__(), Tactic.__del__(), Probe.__del__(), Probe.__eq__(), Probe.__ge__(), ModelRef.__getitem__(), Statistics.__getitem__(), ApplyResult.__getitem__(), Probe.__gt__(), Probe.__le__(), ModelRef.__len__(), Statistics.__len__(), ApplyResult.__len__(), Probe.__lt__(), Probe.__ne__(), Statistics.__repr__(), Fixedpoint.add_cover(), Fixedpoint.add_rule(), Optimize.add_soft(), Tactic.apply(), FuncInterp.arity(), ApplyResult.as_expr(), Solver.assert_and_track(), Optimize.assert_and_track(), Solver.assert_exprs(), Fixedpoint.assert_exprs(), Optimize.assert_exprs(), Solver.assertions(), Optimize.assertions(), Solver.check(), Optimize.check(), UserPropagateBase.conflict(), Solver.consequences(), UserPropagateBase.ctx_ref(), ModelRef.decls(), Solver.dimacs(), FuncInterp.else_value(), FuncInterp.entry(), ModelRef.eval(), Solver.from_file(), Optimize.from_file(), Solver.from_string(), Optimize.from_string(), Fixedpoint.get_answer(), Fixedpoint.get_assertions(), Fixedpoint.get_cover_delta(), Fixedpoint.get_ground_sat_answer(), ModelRef.get_interp(), Statistics.get_key_value(), Fixedpoint.get_num_levels(), Fixedpoint.get_rule_names_along_trace(), Fixedpoint.get_rules(), Fixedpoint.get_rules_along_trace(), ModelRef.get_sort(), ModelRef.get_universe(), Solver.help(), Fixedpoint.help(), Optimize.help(), Tactic.help(), Solver.import_model_converter(), Statistics.keys(), Optimize.maximize(), Optimize.minimize(), Solver.model(), Optimize.model(), Solver.non_units(), FuncInterp.num_entries(), Solver.num_scopes(), ModelRef.num_sorts(), Optimize.objectives(), Solver.param_descrs(), Fixedpoint.param_descrs(), Optimize.param_descrs(), Tactic.param_descrs(), Fixedpoint.parse_file(), Fixedpoint.parse_string(), Solver.pop(), Optimize.pop(), Solver.proof(), Solver.push(), Optimize.push(), Fixedpoint.query(), Fixedpoint.query_from_lvl(), Solver.reason_unknown(), Fixedpoint.reason_unknown(), Optimize.reason_unknown(), Fixedpoint.register_relation(), Solver.reset(), Solver.set(), Fixedpoint.set(), Optimize.set(), Fixedpoint.set_predicate_representation(), ModelRef.sexpr(), Solver.sexpr(), Fixedpoint.sexpr(), Optimize.sexpr(), ApplyResult.sexpr(), Tactic.solver(), Solver.statistics(), Fixedpoint.statistics(), Optimize.statistics(), Solver.to_smt2(), Fixedpoint.to_string(), Solver.trail(), Solver.trail_levels(), FuncInterp.translate(), ModelRef.translate(), Solver.translate(), Solver.units(), Solver.unsat_core(), Optimize.unsat_core(), and Fixedpoint.update_rule().

◆ f

f
Z3_model_translate
Z3_model Z3_API Z3_model_translate(Z3_context c, Z3_model m, Z3_context dst)
translate model from context c to context dst.
z3py.UserPropagateBase.__init__
def __init__(self, s, ctx=None)
Definition: z3py.py:10582
z3::range
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3515
Z3_func_interp_get_else
Z3_ast Z3_API Z3_func_interp_get_else(Z3_context c, Z3_func_interp f)
Return the 'else' value of the given function interpretation.
z3py.UserPropagateBase.__del__
def __del__(self)
Definition: z3py.py:10607
Z3_func_interp_get_entry
Z3_func_entry Z3_API Z3_func_interp_get_entry(Z3_context c, Z3_func_interp f, unsigned i)
Return a "point" of the given function interpretation. It represents the value of f in a particular p...
Z3_func_interp_inc_ref
void Z3_API Z3_func_interp_inc_ref(Z3_context c, Z3_func_interp f)
Increment the reference counter of the given Z3_func_interp object.
Z3_func_interp_dec_ref
void Z3_API Z3_func_interp_dec_ref(Z3_context c, Z3_func_interp f)
Decrement the reference counter of the given Z3_func_interp object.
Z3_func_interp_get_arity
unsigned Z3_API Z3_func_interp_get_arity(Z3_context c, Z3_func_interp f)
Return the arity (number of arguments) of the given function interpretation.
Z3_func_interp_get_num_entries
unsigned Z3_API Z3_func_interp_get_num_entries(Z3_context c, Z3_func_interp f)
Return the number of entries in the given function interpretation.