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

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  f,
  ctx 
)

Definition at line 5866 of file z3py.py.

5866  def __init__(self, f, ctx):
5867  self.f = f
5868  self.ctx = ctx
5869  if self.f is not None:
5870  Z3_func_interp_inc_ref(self.ctx.ref(), self.f)
5871 

◆ __del__()

def __del__ (   self)

Definition at line 5875 of file z3py.py.

5875  def __del__(self):
5876  if self.f is not None and self.ctx.ref() is not None:
5877  Z3_func_interp_dec_ref(self.ctx.ref(), self.f)
5878 

Member Function Documentation

◆ __copy__()

def __copy__ (   self)

Definition at line 5957 of file z3py.py.

5957  def __copy__(self):
5958  return self.translate(self.ctx)
5959 

◆ __deepcopy__() [1/2]

def __deepcopy__ (   self,
  memo = {} 
)

Definition at line 5872 of file z3py.py.

5872  def __deepcopy__(self, memo={}):
5873  return FuncInterp(self.f, self.ctx)
5874 

Referenced by FuncInterp.__deepcopy__().

◆ __deepcopy__() [2/2]

def __deepcopy__ (   self,
  memo = {} 
)

Definition at line 5960 of file z3py.py.

5960  def __deepcopy__(self, memo={}):
5961  return self.translate(self.ctx)
5962 

◆ __repr__()

def __repr__ (   self)

Definition at line 5980 of file z3py.py.

5980  def __repr__(self):
5981  return obj_to_string(self)
5982 

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

5918  def arity(self):
5919  """Return the number of arguments for each entry in the function interpretation `self`.
5920 
5921  >>> f = Function('f', IntSort(), IntSort())
5922  >>> s = Solver()
5923  >>> s.add(f(0) == 1, f(1) == 1, f(2) == 0)
5924  >>> s.check()
5925  sat
5926  >>> m = s.model()
5927  >>> m[f].arity()
5928  1
5929  """
5930  return int(Z3_func_interp_get_arity(self.ctx.ref(), self.f))
5931 

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

5963  def as_list(self):
5964  """Return the function interpretation as a Python list.
5965  >>> f = Function('f', IntSort(), IntSort())
5966  >>> s = Solver()
5967  >>> s.add(f(0) == 1, f(1) == 1, f(2) == 0)
5968  >>> s.check()
5969  sat
5970  >>> m = s.model()
5971  >>> m[f]
5972  [2 -> 0, else -> 1]
5973  >>> m[f].as_list()
5974  [[2, 0], 1]
5975  """
5976  r = [ self.entry(i).as_list() for i in range(self.num_entries())]
5977  r.append(self.else_value())
5978  return r
5979 

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

5879  def else_value(self):
5880  """
5881  Return the `else` value for a function interpretation.
5882  Return None if Z3 did not specify the `else` value for
5883  this object.
5884 
5885  >>> f = Function('f', IntSort(), IntSort())
5886  >>> s = Solver()
5887  >>> s.add(f(0) == 1, f(1) == 1, f(2) == 0)
5888  >>> s.check()
5889  sat
5890  >>> m = s.model()
5891  >>> m[f]
5892  [2 -> 0, else -> 1]
5893  >>> m[f].else_value()
5894  1
5895  """
5896  r = Z3_func_interp_get_else(self.ctx.ref(), self.f)
5897  if r:
5898  return _to_expr_ref(r, self.ctx)
5899  else:
5900  return None
5901 

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

5932  def entry(self, idx):
5933  """Return an entry at position `idx < self.num_entries()` in the function interpretation `self`.
5934 
5935  >>> f = Function('f', IntSort(), IntSort())
5936  >>> s = Solver()
5937  >>> s.add(f(0) == 1, f(1) == 1, f(2) == 0)
5938  >>> s.check()
5939  sat
5940  >>> m = s.model()
5941  >>> m[f]
5942  [2 -> 0, else -> 1]
5943  >>> m[f].num_entries()
5944  1
5945  >>> m[f].entry(0)
5946  [2, 0]
5947  """
5948  if idx >= self.num_entries():
5949  raise IndexError
5950  return FuncEntry(Z3_func_interp_get_entry(self.ctx.ref(), self.f, idx), self.ctx)
5951 

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

5902  def num_entries(self):
5903  """Return the number of entries/points in the function interpretation `self`.
5904 
5905  >>> f = Function('f', IntSort(), IntSort())
5906  >>> s = Solver()
5907  >>> s.add(f(0) == 1, f(1) == 1, f(2) == 0)
5908  >>> s.check()
5909  sat
5910  >>> m = s.model()
5911  >>> m[f]
5912  [2 -> 0, else -> 1]
5913  >>> m[f].num_entries()
5914  1
5915  """
5916  return int(Z3_func_interp_get_num_entries(self.ctx.ref(), self.f))
5917 

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

◆ translate()

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

Definition at line 5952 of file z3py.py.

5952  def translate(self, other_ctx):
5953  """Copy model 'self' to context 'other_ctx'.
5954  """
5955  return ModelRef(Z3_model_translate(self.ctx.ref(), self.model, other_ctx.ref()), other_ctx)
5956 

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

Field Documentation

◆ ctx

ctx

Definition at line 5868 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(), Solver.consequences(), 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(), Optimize.pop(), Solver.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.
z3::range
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3488
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.
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.