Z3
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | Data Fields
AstMap Class Reference

Public Member Functions

def __init__
 
def __deepcopy__
 
def __del__
 
def __len__
 
def __contains__
 
def __getitem__
 
def __setitem__
 
def __repr__
 
def erase
 
def reset
 
def keys
 

Data Fields

 map
 
 ctx
 

Detailed Description

A mapping from ASTs to ASTs.

Definition at line 5588 of file z3py.py.

Constructor & Destructor Documentation

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

Definition at line 5591 of file z3py.py.

5592  def __init__(self, m=None, ctx=None):
5593  self.map = None
5594  if m is None:
5595  self.ctx = _get_ctx(ctx)
5596  self.map = Z3_mk_ast_map(self.ctx.ref())
5597  else:
5598  self.map = m
5599  assert ctx is not None
5600  self.ctx = ctx
5601  Z3_ast_map_inc_ref(self.ctx.ref(), self.map)
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 Z3_API Z3_mk_ast_map(Z3_context c)
Return an empty mapping from AST to AST.
def __init__
Definition: z3py.py:5591
def __del__ (   self)

Definition at line 5605 of file z3py.py.

5606  def __del__(self):
5607  if self.map is not None and self.ctx.ref() is not None:
5608  Z3_ast_map_dec_ref(self.ctx.ref(), self.map)
def __del__
Definition: z3py.py:5605
void Z3_API Z3_ast_map_dec_ref(Z3_context c, Z3_ast_map m)
Decrement the reference counter of the given AST map.

Member Function Documentation

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

5623  def __contains__(self, key):
5624  """Return `True` if the map contains key `key`.
5625 
5626  >>> M = AstMap()
5627  >>> x = Int('x')
5628  >>> M[x] = x + 1
5629  >>> x in M
5630  True
5631  >>> x+1 in M
5632  False
5633  """
5634  return Z3_ast_map_contains(self.ctx.ref(), self.map, key.as_ast())
def __contains__
Definition: z3py.py:5622
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.
def __deepcopy__ (   self,
  memo = {} 
)

Definition at line 5602 of file z3py.py.

5603  def __deepcopy__(self, memo={}):
5604  return AstMap(self.map, self.ctx)
def __deepcopy__
Definition: z3py.py:5602
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 5635 of file z3py.py.

5636  def __getitem__(self, key):
5637  """Retrieve the value associated with key `key`.
5638 
5639  >>> M = AstMap()
5640  >>> x = Int('x')
5641  >>> M[x] = x + 1
5642  >>> M[x]
5643  x + 1
5644  """
5645  return _to_ast_ref(Z3_ast_map_find(self.ctx.ref(), self.map, key.as_ast()), self.ctx)
def __getitem__
Definition: z3py.py:5635
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.
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 5609 of file z3py.py.

5610  def __len__(self):
5611  """Return the size of the map.
5612 
5613  >>> M = AstMap()
5614  >>> len(M)
5615  0
5616  >>> x = Int('x')
5617  >>> M[x] = IntVal(1)
5618  >>> len(M)
5619  1
5620  """
5621  return int(Z3_ast_map_size(self.ctx.ref(), self.map))
def __len__
Definition: z3py.py:5609
unsigned Z3_API Z3_ast_map_size(Z3_context c, Z3_ast_map m)
Return the size of the given map.
def __repr__ (   self)

Definition at line 5662 of file z3py.py.

5663  def __repr__(self):
5664  return Z3_ast_map_to_string(self.ctx.ref(), self.map)
def __repr__
Definition: z3py.py:5662
Z3_string Z3_API Z3_ast_map_to_string(Z3_context c, Z3_ast_map m)
Convert the given map into a string.
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 5646 of file z3py.py.

5647  def __setitem__(self, k, v):
5648  """Add/Update key `k` with value `v`.
5649 
5650  >>> M = AstMap()
5651  >>> x = Int('x')
5652  >>> M[x] = x + 1
5653  >>> len(M)
5654  1
5655  >>> M[x]
5656  x + 1
5657  >>> M[x] = IntVal(1)
5658  >>> M[x]
5659  1
5660  """
5661  Z3_ast_map_insert(self.ctx.ref(), self.map, k.as_ast(), v.as_ast())
def __setitem__
Definition: z3py.py:5646
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.
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 5665 of file z3py.py.

5666  def erase(self, k):
5667  """Remove the entry associated with key `k`.
5668 
5669  >>> M = AstMap()
5670  >>> x = Int('x')
5671  >>> M[x] = x + 1
5672  >>> len(M)
5673  1
5674  >>> M.erase(x)
5675  >>> len(M)
5676  0
5677  """
5678  Z3_ast_map_erase(self.ctx.ref(), self.map, k.as_ast())
void Z3_API Z3_ast_map_erase(Z3_context c, Z3_ast_map m, Z3_ast k)
Erase a key from the map.
def erase
Definition: z3py.py:5665
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 5694 of file z3py.py.

5695  def keys(self):
5696  """Return an AstVector containing all keys in the map.
5697 
5698  >>> M = AstMap()
5699  >>> x = Int('x')
5700  >>> M[x] = x + 1
5701  >>> M[x+x] = IntVal(1)
5702  >>> M.keys()
5703  [x, x + x]
5704  """
5705  return AstVector(Z3_ast_map_keys(self.ctx.ref(), self.map), self.ctx)
Z3_ast_vector Z3_API Z3_ast_map_keys(Z3_context c, Z3_ast_map m)
Return the keys stored in the given map.
def keys
Definition: z3py.py:5694
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 5679 of file z3py.py.

5680  def reset(self):
5681  """Remove all entries from the map.
5682 
5683  >>> M = AstMap()
5684  >>> x = Int('x')
5685  >>> M[x] = x + 1
5686  >>> M[x+x] = IntVal(1)
5687  >>> len(M)
5688  2
5689  >>> M.reset()
5690  >>> len(M)
5691  0
5692  """
5693  Z3_ast_map_reset(self.ctx.ref(), self.map)
def reset
Definition: z3py.py:5679
void Z3_API Z3_ast_map_reset(Z3_context c, Z3_ast_map m)
Remove all keys from the given map.

Field Documentation

ctx

Definition at line 5594 of file z3py.py.

Referenced by AstMap.__deepcopy__(), Fixedpoint.__deepcopy__(), Optimize.__deepcopy__(), ApplyResult.__deepcopy__(), Tactic.__deepcopy__(), Probe.__deepcopy__(), Probe.__eq__(), Probe.__ge__(), AstMap.__getitem__(), 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(), 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(), AstMap.keys(), 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().

map

Definition at line 5592 of file z3py.py.

Referenced by AstMap.__contains__(), AstMap.__deepcopy__(), AstMap.__del__(), AstMap.__getitem__(), AstMap.__len__(), AstMap.__repr__(), AstMap.__setitem__(), AstMap.erase(), AstMap.keys(), and AstMap.reset().