Z3
Public Member Functions | Data Fields
AstMap Class Reference

Public Member Functions

def __init__ (self, m=None, ctx=None)
 
def __deepcopy__ (self, memo={})
 
def __del__ (self)
 
def __len__ (self)
 
def __contains__ (self, key)
 
def __getitem__ (self, key)
 
def __setitem__ (self, k, v)
 
def __repr__ (self)
 
def erase (self, k)
 
def reset (self)
 
def keys (self)
 

Data Fields

 map
 
 ctx
 

Detailed Description

A mapping from ASTs to ASTs.

Definition at line 5631 of file z3py.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  m = None,
  ctx = None 
)

Definition at line 5634 of file z3py.py.

5634  def __init__(self, m=None, ctx=None):
5635  self.map = None
5636  if m is None:
5637  self.ctx = _get_ctx(ctx)
5638  self.map = Z3_mk_ast_map(self.ctx.ref())
5639  else:
5640  self.map = m
5641  assert ctx is not None
5642  self.ctx = ctx
5643  Z3_ast_map_inc_ref(self.ctx.ref(), self.map)
5644 

◆ __del__()

def __del__ (   self)

Definition at line 5648 of file z3py.py.

5648  def __del__(self):
5649  if self.map is not None and self.ctx.ref() is not None:
5650  Z3_ast_map_dec_ref(self.ctx.ref(), self.map)
5651 

Member Function Documentation

◆ __contains__()

def __contains__ (   self,
  key 
)
Return `True` if the map contains key `key`.

>>> M = AstMap()
>>> x = Int('x')
>>> M[x] = x + 1
>>> x in M
True
>>> x+1 in M
False

Definition at line 5665 of file z3py.py.

5665  def __contains__(self, key):
5666  """Return `True` if the map contains key `key`.
5667 
5668  >>> M = AstMap()
5669  >>> x = Int('x')
5670  >>> M[x] = x + 1
5671  >>> x in M
5672  True
5673  >>> x+1 in M
5674  False
5675  """
5676  return Z3_ast_map_contains(self.ctx.ref(), self.map, key.as_ast())
5677 

◆ __deepcopy__()

def __deepcopy__ (   self,
  memo = {} 
)

Definition at line 5645 of file z3py.py.

5645  def __deepcopy__(self, memo={}):
5646  return AstMap(self.map, self.ctx)
5647 

◆ __getitem__()

def __getitem__ (   self,
  key 
)
Retrieve the value associated with key `key`.

>>> M = AstMap()
>>> x = Int('x')
>>> M[x] = x + 1
>>> M[x]
x + 1

Definition at line 5678 of file z3py.py.

5678  def __getitem__(self, key):
5679  """Retrieve the value associated with key `key`.
5680 
5681  >>> M = AstMap()
5682  >>> x = Int('x')
5683  >>> M[x] = x + 1
5684  >>> M[x]
5685  x + 1
5686  """
5687  return _to_ast_ref(Z3_ast_map_find(self.ctx.ref(), self.map, key.as_ast()), self.ctx)
5688 

◆ __len__()

def __len__ (   self)
Return the size of the map.

>>> M = AstMap()
>>> len(M)
0
>>> x = Int('x')
>>> M[x] = IntVal(1)
>>> len(M)
1

Definition at line 5652 of file z3py.py.

5652  def __len__(self):
5653  """Return the size of the map.
5654 
5655  >>> M = AstMap()
5656  >>> len(M)
5657  0
5658  >>> x = Int('x')
5659  >>> M[x] = IntVal(1)
5660  >>> len(M)
5661  1
5662  """
5663  return int(Z3_ast_map_size(self.ctx.ref(), self.map))
5664 

◆ __repr__()

def __repr__ (   self)

Definition at line 5705 of file z3py.py.

5705  def __repr__(self):
5706  return Z3_ast_map_to_string(self.ctx.ref(), self.map)
5707 

◆ __setitem__()

def __setitem__ (   self,
  k,
  v 
)
Add/Update key `k` with value `v`.

>>> M = AstMap()
>>> x = Int('x')
>>> M[x] = x + 1
>>> len(M)
1
>>> M[x]
x + 1
>>> M[x] = IntVal(1)
>>> M[x]
1

Definition at line 5689 of file z3py.py.

5689  def __setitem__(self, k, v):
5690  """Add/Update key `k` with value `v`.
5691 
5692  >>> M = AstMap()
5693  >>> x = Int('x')
5694  >>> M[x] = x + 1
5695  >>> len(M)
5696  1
5697  >>> M[x]
5698  x + 1
5699  >>> M[x] = IntVal(1)
5700  >>> M[x]
5701  1
5702  """
5703  Z3_ast_map_insert(self.ctx.ref(), self.map, k.as_ast(), v.as_ast())
5704 

◆ erase()

def erase (   self,
  k 
)
Remove the entry associated with key `k`.

>>> M = AstMap()
>>> x = Int('x')
>>> M[x] = x + 1
>>> len(M)
1
>>> M.erase(x)
>>> len(M)
0

Definition at line 5708 of file z3py.py.

5708  def erase(self, k):
5709  """Remove the entry associated with key `k`.
5710 
5711  >>> M = AstMap()
5712  >>> x = Int('x')
5713  >>> M[x] = x + 1
5714  >>> len(M)
5715  1
5716  >>> M.erase(x)
5717  >>> len(M)
5718  0
5719  """
5720  Z3_ast_map_erase(self.ctx.ref(), self.map, k.as_ast())
5721 

◆ keys()

def keys (   self)
Return an AstVector containing all keys in the map.

>>> M = AstMap()
>>> x = Int('x')
>>> M[x]   = x + 1
>>> M[x+x] = IntVal(1)
>>> M.keys()
[x, x + x]

Definition at line 5737 of file z3py.py.

5737  def keys(self):
5738  """Return an AstVector containing all keys in the map.
5739 
5740  >>> M = AstMap()
5741  >>> x = Int('x')
5742  >>> M[x] = x + 1
5743  >>> M[x+x] = IntVal(1)
5744  >>> M.keys()
5745  [x, x + x]
5746  """
5747  return AstVector(Z3_ast_map_keys(self.ctx.ref(), self.map), self.ctx)
5748 

◆ reset()

def reset (   self)
Remove all entries from the map.

>>> M = AstMap()
>>> x = Int('x')
>>> M[x]   = x + 1
>>> M[x+x] = IntVal(1)
>>> len(M)
2
>>> M.reset()
>>> len(M)
0

Definition at line 5722 of file z3py.py.

5722  def reset(self):
5723  """Remove all entries from the map.
5724 
5725  >>> M = AstMap()
5726  >>> x = Int('x')
5727  >>> M[x] = x + 1
5728  >>> M[x+x] = IntVal(1)
5729  >>> len(M)
5730  2
5731  >>> M.reset()
5732  >>> len(M)
5733  0
5734  """
5735  Z3_ast_map_reset(self.ctx.ref(), self.map)
5736 

Field Documentation

◆ ctx

ctx

Definition at line 5637 of file z3py.py.

Referenced by Probe.__call__(), AstMap.__contains__(), FuncInterp.__copy__(), ModelRef.__copy__(), Solver.__copy__(), AstMap.__deepcopy__(), FuncEntry.__deepcopy__(), FuncInterp.__deepcopy__(), ModelRef.__deepcopy__(), Statistics.__deepcopy__(), Solver.__deepcopy__(), Fixedpoint.__deepcopy__(), Optimize.__deepcopy__(), ApplyResult.__deepcopy__(), Tactic.__deepcopy__(), Probe.__deepcopy__(), AstMap.__del__(), FuncEntry.__del__(), FuncInterp.__del__(), ModelRef.__del__(), Statistics.__del__(), Solver.__del__(), Fixedpoint.__del__(), Optimize.__del__(), ApplyResult.__del__(), Tactic.__del__(), Probe.__del__(), Probe.__eq__(), Probe.__ge__(), AstMap.__getitem__(), ModelRef.__getitem__(), Statistics.__getitem__(), ApplyResult.__getitem__(), Probe.__gt__(), Probe.__le__(), AstMap.__len__(), ModelRef.__len__(), Statistics.__len__(), ApplyResult.__len__(), Probe.__lt__(), Probe.__ne__(), AstMap.__repr__(), Statistics.__repr__(), AstMap.__setitem__(), Fixedpoint.add_cover(), Fixedpoint.add_rule(), Optimize.add_soft(), Tactic.apply(), FuncEntry.arg_value(), 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(), AstMap.erase(), 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(), AstMap.keys(), Statistics.keys(), Optimize.maximize(), Optimize.minimize(), Solver.model(), Optimize.model(), Solver.non_units(), FuncEntry.num_args(), 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(), AstMap.reset(), 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(), Fixedpoint.update_rule(), and FuncEntry.value().

◆ map

map
Z3_ast_map_keys
Z3_ast_vector Z3_API Z3_ast_map_keys(Z3_context c, Z3_ast_map m)
Return the keys stored in the given map.
Z3_ast_map_size
unsigned Z3_API Z3_ast_map_size(Z3_context c, Z3_ast_map m)
Return the size of the given map.
Z3_ast_map_dec_ref
void Z3_API Z3_ast_map_dec_ref(Z3_context c, Z3_ast_map m)
Decrement the reference counter of the given AST map.
Z3_ast_map_insert
void Z3_API Z3_ast_map_insert(Z3_context c, Z3_ast_map m, Z3_ast k, Z3_ast v)
Store/Replace a new key, value pair in the given map.
Z3_ast_map_inc_ref
void Z3_API Z3_ast_map_inc_ref(Z3_context c, Z3_ast_map m)
Increment the reference counter of the given AST map.
Z3_ast_map_reset
void Z3_API Z3_ast_map_reset(Z3_context c, Z3_ast_map m)
Remove all keys from the given map.
Z3_ast_map_contains
bool Z3_API Z3_ast_map_contains(Z3_context c, Z3_ast_map m, Z3_ast k)
Return true if the map m contains the AST key k.
Z3_ast_map_find
Z3_ast Z3_API Z3_ast_map_find(Z3_context c, Z3_ast_map m, Z3_ast k)
Return the value associated with the key k.
Z3_ast_map_erase
void Z3_API Z3_ast_map_erase(Z3_context c, Z3_ast_map m, Z3_ast k)
Erase a key from the map.
Z3_ast_map_to_string
Z3_string Z3_API Z3_ast_map_to_string(Z3_context c, Z3_ast_map m)
Convert the given map into a string.
Z3_mk_ast_map
Z3_ast_map Z3_API Z3_mk_ast_map(Z3_context c)
Return an empty mapping from AST to AST.