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

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  f,
  ctx 
)

Definition at line 5843 of file z3py.py.

5843  def __init__(self, f, ctx):
5844  self.f = f
5845  self.ctx = ctx
5846  if self.f is not None:
5847  Z3_func_interp_inc_ref(self.ctx.ref(), self.f)
5848 

◆ __del__()

def __del__ (   self)

Definition at line 5852 of file z3py.py.

5852  def __del__(self):
5853  if self.f is not None and self.ctx.ref() is not None:
5854  Z3_func_interp_dec_ref(self.ctx.ref(), self.f)
5855 

Member Function Documentation

◆ __copy__()

def __copy__ (   self)

Definition at line 5934 of file z3py.py.

5934  def __copy__(self):
5935  return self.translate(self.ctx)
5936 

◆ __deepcopy__() [1/2]

def __deepcopy__ (   self,
  memo = {} 
)

Definition at line 5849 of file z3py.py.

5849  def __deepcopy__(self, memo={}):
5850  return FuncInterp(self.f, self.ctx)
5851 

Referenced by FuncInterp.__deepcopy__().

◆ __deepcopy__() [2/2]

def __deepcopy__ (   self,
  memo = {} 
)

Definition at line 5937 of file z3py.py.

5937  def __deepcopy__(self, memo={}):
5938  return self.translate(self.ctx)
5939 

◆ __repr__()

def __repr__ (   self)

Definition at line 5957 of file z3py.py.

5957  def __repr__(self):
5958  return obj_to_string(self)
5959 

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

5895  def arity(self):
5896  """Return the number of arguments for each entry in the function interpretation `self`.
5897 
5898  >>> f = Function('f', IntSort(), IntSort())
5899  >>> s = Solver()
5900  >>> s.add(f(0) == 1, f(1) == 1, f(2) == 0)
5901  >>> s.check()
5902  sat
5903  >>> m = s.model()
5904  >>> m[f].arity()
5905  1
5906  """
5907  return int(Z3_func_interp_get_arity(self.ctx.ref(), self.f))
5908 

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

5940  def as_list(self):
5941  """Return the function interpretation as a Python list.
5942  >>> f = Function('f', IntSort(), IntSort())
5943  >>> s = Solver()
5944  >>> s.add(f(0) == 1, f(1) == 1, f(2) == 0)
5945  >>> s.check()
5946  sat
5947  >>> m = s.model()
5948  >>> m[f]
5949  [2 -> 0, else -> 1]
5950  >>> m[f].as_list()
5951  [[2, 0], 1]
5952  """
5953  r = [ self.entry(i).as_list() for i in range(self.num_entries())]
5954  r.append(self.else_value())
5955  return r
5956 

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

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

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

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

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

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

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

◆ translate()

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

Definition at line 5929 of file z3py.py.

5929  def translate(self, other_ctx):
5930  """Copy model 'self' to context 'other_ctx'.
5931  """
5932  return ModelRef(Z3_model_translate(self.ctx.ref(), self.model, other_ctx.ref()), other_ctx)
5933 

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

Field Documentation

◆ ctx

ctx

Definition at line 5845 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
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:3431
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.