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

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  f,
  ctx 
)

Definition at line 5847 of file z3py.py.

5847  def __init__(self, f, ctx):
5848  self.f = f
5849  self.ctx = ctx
5850  if self.f is not None:
5851  Z3_func_interp_inc_ref(self.ctx.ref(), self.f)
5852 
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.

◆ __del__()

def __del__ (   self)

Definition at line 5856 of file z3py.py.

5856  def __del__(self):
5857  if self.f is not None and self.ctx.ref() is not None:
5858  Z3_func_interp_dec_ref(self.ctx.ref(), self.f)
5859 
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.

Member Function Documentation

◆ __copy__()

def __copy__ (   self)

Definition at line 5938 of file z3py.py.

5938  def __copy__(self):
5939  return self.translate(self.ctx)
5940 

◆ __deepcopy__() [1/2]

def __deepcopy__ (   self,
  memo = {} 
)

Definition at line 5853 of file z3py.py.

5853  def __deepcopy__(self, memo={}):
5854  return FuncInterp(self.f, self.ctx)
5855 

Referenced by FuncInterp.__deepcopy__().

◆ __deepcopy__() [2/2]

def __deepcopy__ (   self,
  memo = {} 
)

Definition at line 5941 of file z3py.py.

5941  def __deepcopy__(self, memo={}):
5942  return self.translate(self.ctx)
5943 

◆ __repr__()

def __repr__ (   self)

Definition at line 5961 of file z3py.py.

5961  def __repr__(self):
5962  return obj_to_string(self)
5963 

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

5899  def arity(self):
5900  """Return the number of arguments for each entry in the function interpretation `self`.
5901 
5902  >>> f = Function('f', IntSort(), IntSort())
5903  >>> s = Solver()
5904  >>> s.add(f(0) == 1, f(1) == 1, f(2) == 0)
5905  >>> s.check()
5906  sat
5907  >>> m = s.model()
5908  >>> m[f].arity()
5909  1
5910  """
5911  return int(Z3_func_interp_get_arity(self.ctx.ref(), self.f))
5912 
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.

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

5944  def as_list(self):
5945  """Return the function interpretation as a Python list.
5946  >>> f = Function('f', IntSort(), IntSort())
5947  >>> s = Solver()
5948  >>> s.add(f(0) == 1, f(1) == 1, f(2) == 0)
5949  >>> s.check()
5950  sat
5951  >>> m = s.model()
5952  >>> m[f]
5953  [2 -> 0, else -> 1]
5954  >>> m[f].as_list()
5955  [[2, 0], 1]
5956  """
5957  r = [ self.entry(i).as_list() for i in range(self.num_entries())]
5958  r.append(self.else_value())
5959  return r
5960 
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3370

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

5860  def else_value(self):
5861  """
5862  Return the `else` value for a function interpretation.
5863  Return None if Z3 did not specify the `else` value for
5864  this object.
5865 
5866  >>> f = Function('f', IntSort(), IntSort())
5867  >>> s = Solver()
5868  >>> s.add(f(0) == 1, f(1) == 1, f(2) == 0)
5869  >>> s.check()
5870  sat
5871  >>> m = s.model()
5872  >>> m[f]
5873  [2 -> 0, else -> 1]
5874  >>> m[f].else_value()
5875  1
5876  """
5877  r = Z3_func_interp_get_else(self.ctx.ref(), self.f)
5878  if r:
5879  return _to_expr_ref(r, self.ctx)
5880  else:
5881  return None
5882 
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.

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

5913  def entry(self, idx):
5914  """Return an entry at position `idx < self.num_entries()` in the function interpretation `self`.
5915 
5916  >>> f = Function('f', IntSort(), IntSort())
5917  >>> s = Solver()
5918  >>> s.add(f(0) == 1, f(1) == 1, f(2) == 0)
5919  >>> s.check()
5920  sat
5921  >>> m = s.model()
5922  >>> m[f]
5923  [2 -> 0, else -> 1]
5924  >>> m[f].num_entries()
5925  1
5926  >>> m[f].entry(0)
5927  [2, 0]
5928  """
5929  if idx >= self.num_entries():
5930  raise IndexError
5931  return FuncEntry(Z3_func_interp_get_entry(self.ctx.ref(), self.f, idx), self.ctx)
5932 
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...

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

5883  def num_entries(self):
5884  """Return the number of entries/points in the function interpretation `self`.
5885 
5886  >>> f = Function('f', IntSort(), IntSort())
5887  >>> s = Solver()
5888  >>> s.add(f(0) == 1, f(1) == 1, f(2) == 0)
5889  >>> s.check()
5890  sat
5891  >>> m = s.model()
5892  >>> m[f]
5893  [2 -> 0, else -> 1]
5894  >>> m[f].num_entries()
5895  1
5896  """
5897  return int(Z3_func_interp_get_num_entries(self.ctx.ref(), self.f))
5898 
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.

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

◆ translate()

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

Definition at line 5933 of file z3py.py.

5933  def translate(self, other_ctx):
5934  """Copy model 'self' to context 'other_ctx'.
5935  """
5936  return ModelRef(Z3_model_translate(self.ctx.ref(), self.model, other_ctx.ref()), other_ctx)
5937 
Z3_model Z3_API Z3_model_translate(Z3_context c, Z3_model m, Z3_context dst)
translate model from context c to context dst.

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

Field Documentation

◆ ctx

ctx

Definition at line 5849 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(), 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