Z3
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | Data Fields
FuncInterp Class Reference
+ Inheritance diagram for FuncInterp:

Public Member Functions

def __init__
 
def __deepcopy__
 
def __del__
 
def else_value
 
def num_entries
 
def arity
 
def entry
 
def translate
 
def __copy__
 
def __deepcopy__
 
def as_list
 
def __repr__
 
- Public Member Functions inherited from Z3PPObject
def use_pp
 

Data Fields

 f
 
 ctx
 

Detailed Description

Stores the interpretation of a function in a Z3 model.

Definition at line 5820 of file z3py.py.

Constructor & Destructor Documentation

def __init__ (   self,
  f,
  ctx 
)

Definition at line 5823 of file z3py.py.

5824  def __init__(self, f, ctx):
5825  self.f = f
5826  self.ctx = ctx
5827  if self.f is not None:
5828  Z3_func_interp_inc_ref(self.ctx.ref(), self.f)
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.
def __init__
Definition: z3py.py:5823
def __del__ (   self)

Definition at line 5832 of file z3py.py.

5833  def __del__(self):
5834  if self.f is not None and self.ctx.ref() is not None:
5835  Z3_func_interp_dec_ref(self.ctx.ref(), self.f)
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

def __copy__ (   self)

Definition at line 5914 of file z3py.py.

5915  def __copy__(self):
5916  return self.translate(self.ctx)
def translate
Definition: z3py.py:5909
def __copy__
Definition: z3py.py:5914
def __deepcopy__ (   self,
  memo = {} 
)

Definition at line 5829 of file z3py.py.

5830  def __deepcopy__(self, memo={}):
5831  return FuncInterp(self.f, self.ctx)
def __deepcopy__
Definition: z3py.py:5829
def __deepcopy__ (   self,
  memo = {} 
)

Definition at line 5917 of file z3py.py.

5918  def __deepcopy__(self, memo={}):
5919  return self.translate(self.ctx)
def __deepcopy__
Definition: z3py.py:5829
def translate
Definition: z3py.py:5909
def __repr__ (   self)

Definition at line 5937 of file z3py.py.

5938  def __repr__(self):
5939  return obj_to_string(self)
def __repr__
Definition: z3py.py:5937
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 5875 of file z3py.py.

5876  def arity(self):
5877  """Return the number of arguments for each entry in the function interpretation `self`.
5878 
5879  >>> f = Function('f', IntSort(), IntSort())
5880  >>> s = Solver()
5881  >>> s.add(f(0) == 1, f(1) == 1, f(2) == 0)
5882  >>> s.check()
5883  sat
5884  >>> m = s.model()
5885  >>> m[f].arity()
5886  1
5887  """
5888  return int(Z3_func_interp_get_arity(self.ctx.ref(), self.f))
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.
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 5920 of file z3py.py.

5921  def as_list(self):
5922  """Return the function interpretation as a Python list.
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].as_list()
5932  [[2, 0], 1]
5933  """
5934  r = [ self.entry(i).as_list() for i in range(self.num_entries())]
5935  r.append(self.else_value())
5936  return r
expr range(expr const &lo, expr const &hi)
Definition: z3++.h:3358
def else_value
Definition: z3py.py:5836
def num_entries
Definition: z3py.py:5859
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 5836 of file z3py.py.

Referenced by FuncInterp.as_list().

5837  def else_value(self):
5838  """
5839  Return the `else` value for a function interpretation.
5840  Return None if Z3 did not specify the `else` value for
5841  this object.
5842 
5843  >>> f = Function('f', IntSort(), IntSort())
5844  >>> s = Solver()
5845  >>> s.add(f(0) == 1, f(1) == 1, f(2) == 0)
5846  >>> s.check()
5847  sat
5848  >>> m = s.model()
5849  >>> m[f]
5850  [2 -> 0, else -> 1]
5851  >>> m[f].else_value()
5852  1
5853  """
5854  r = Z3_func_interp_get_else(self.ctx.ref(), self.f)
5855  if r:
5856  return _to_expr_ref(r, self.ctx)
5857  else:
5858  return None
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.
def else_value
Definition: z3py.py:5836
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 5889 of file z3py.py.

Referenced by FuncInterp.as_list().

5890  def entry(self, idx):
5891  """Return an entry at position `idx < self.num_entries()` in the function interpretation `self`.
5892 
5893  >>> f = Function('f', IntSort(), IntSort())
5894  >>> s = Solver()
5895  >>> s.add(f(0) == 1, f(1) == 1, f(2) == 0)
5896  >>> s.check()
5897  sat
5898  >>> m = s.model()
5899  >>> m[f]
5900  [2 -> 0, else -> 1]
5901  >>> m[f].num_entries()
5902  1
5903  >>> m[f].entry(0)
5904  [2, 0]
5905  """
5906  if idx >= self.num_entries():
5907  raise IndexError
5908  return FuncEntry(Z3_func_interp_get_entry(self.ctx.ref(), self.f, idx), self.ctx)
Definition: z3py.py:5712
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...
def num_entries
Definition: z3py.py:5859
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 5859 of file z3py.py.

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

5860  def num_entries(self):
5861  """Return the number of entries/points in the function interpretation `self`.
5862 
5863  >>> f = Function('f', IntSort(), IntSort())
5864  >>> s = Solver()
5865  >>> s.add(f(0) == 1, f(1) == 1, f(2) == 0)
5866  >>> s.check()
5867  sat
5868  >>> m = s.model()
5869  >>> m[f]
5870  [2 -> 0, else -> 1]
5871  >>> m[f].num_entries()
5872  1
5873  """
5874  return int(Z3_func_interp_get_num_entries(self.ctx.ref(), self.f))
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.
def num_entries
Definition: z3py.py:5859
def translate (   self,
  other_ctx 
)
Copy model 'self' to context 'other_ctx'.

Definition at line 5909 of file z3py.py.

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

5910  def translate(self, other_ctx):
5911  """Copy model 'self' to context 'other_ctx'.
5912  """
5913  return ModelRef(Z3_model_translate(self.ctx.ref(), self.model, other_ctx.ref()), other_ctx)
def translate
Definition: z3py.py:5909
Z3_model Z3_API Z3_model_translate(Z3_context c, Z3_model m, Z3_context dst)
translate model from context c to context dst.

Field Documentation

ctx

Definition at line 5825 of file z3py.py.

Referenced by FuncInterp.__copy__(), FuncInterp.__deepcopy__(), Fixedpoint.__deepcopy__(), Optimize.__deepcopy__(), ApplyResult.__deepcopy__(), Tactic.__deepcopy__(), Probe.__deepcopy__(), Probe.__eq__(), Probe.__ge__(), ApplyResult.__getitem__(), Probe.__gt__(), Probe.__le__(), Probe.__lt__(), Probe.__ne__(), Fixedpoint.add_rule(), Optimize.add_soft(), Tactic.apply(), ApplyResult.as_expr(), Optimize.assert_and_track(), Fixedpoint.assert_exprs(), Optimize.assert_exprs(), Optimize.assertions(), FuncInterp.else_value(), FuncInterp.entry(), Fixedpoint.get_answer(), Fixedpoint.get_assertions(), Fixedpoint.get_cover_delta(), Fixedpoint.get_ground_sat_answer(), Fixedpoint.get_rule_names_along_trace(), Fixedpoint.get_rules(), Fixedpoint.get_rules_along_trace(), Optimize.model(), Optimize.objectives(), 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(), Optimize.unsat_core(), and Fixedpoint.update_rule().

f

Definition at line 5824 of file z3py.py.

Referenced by FuncInterp.__deepcopy__(), FuncInterp.__del__(), FuncInterp.arity(), FuncInterp.as_list(), FuncInterp.else_value(), FuncInterp.entry(), and FuncInterp.num_entries().