Z3
Public Member Functions | Data Fields
AstMap Class Reference

Public Member Functions

def __init__
 
def __deepcopy__
 
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 6248 of file z3py.py.

Constructor & Destructor Documentation

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

Definition at line 6251 of file z3py.py.

6251  def __init__(self, m=None, ctx=None):
6252  self.map = None
6253  if m is None:
6254  self.ctx = _get_ctx(ctx)
6255  self.map = Z3_mk_ast_map(self.ctx.ref())
6256  else:
6257  self.map = m
6258  assert ctx is not None
6259  self.ctx = ctx
6260  Z3_ast_map_inc_ref(self.ctx.ref(), self.map)
6261 
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:6251
def __del__ (   self)

Definition at line 6265 of file z3py.py.

6265  def __del__(self):
6266  if self.map is not None and self.ctx.ref() is not None and Z3_ast_map_dec_ref is not None:
6267  Z3_ast_map_dec_ref(self.ctx.ref(), self.map)
6268 
def __del__(self)
Definition: z3py.py:6265
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 6282 of file z3py.py.

6282  def __contains__(self, key):
6283  """Return `True` if the map contains key `key`.
6284 
6285  >>> M = AstMap()
6286  >>> x = Int('x')
6287  >>> M[x] = x + 1
6288  >>> x in M
6289  True
6290  >>> x+1 in M
6291  False
6292  """
6293  return Z3_ast_map_contains(self.ctx.ref(), self.map, key.as_ast())
6294 
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 __contains__(self, key)
Definition: z3py.py:6282
def __deepcopy__ (   self,
  memo = {} 
)

Definition at line 6262 of file z3py.py.

6262  def __deepcopy__(self, memo={}):
6263  return AstMap(self.map, self.ctx)
6264 
def __deepcopy__
Definition: z3py.py:6262
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 6295 of file z3py.py.

6295  def __getitem__(self, key):
6296  """Retrieve the value associated with key `key`.
6297 
6298  >>> M = AstMap()
6299  >>> x = Int('x')
6300  >>> M[x] = x + 1
6301  >>> M[x]
6302  x + 1
6303  """
6304  return _to_ast_ref(Z3_ast_map_find(self.ctx.ref(), self.map, key.as_ast()), self.ctx)
6305 
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 __getitem__(self, key)
Definition: z3py.py:6295
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 6269 of file z3py.py.

6269  def __len__(self):
6270  """Return the size of the map.
6271 
6272  >>> M = AstMap()
6273  >>> len(M)
6274  0
6275  >>> x = Int('x')
6276  >>> M[x] = IntVal(1)
6277  >>> len(M)
6278  1
6279  """
6280  return int(Z3_ast_map_size(self.ctx.ref(), self.map))
6281 
def __len__(self)
Definition: z3py.py:6269
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 6322 of file z3py.py.

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

6306  def __setitem__(self, k, v):
6307  """Add/Update key `k` with value `v`.
6308 
6309  >>> M = AstMap()
6310  >>> x = Int('x')
6311  >>> M[x] = x + 1
6312  >>> len(M)
6313  1
6314  >>> M[x]
6315  x + 1
6316  >>> M[x] = IntVal(1)
6317  >>> M[x]
6318  1
6319  """
6320  Z3_ast_map_insert(self.ctx.ref(), self.map, k.as_ast(), v.as_ast())
6321 
def __setitem__(self, k, v)
Definition: z3py.py:6306
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 6325 of file z3py.py.

6325  def erase(self, k):
6326  """Remove the entry associated with key `k`.
6327 
6328  >>> M = AstMap()
6329  >>> x = Int('x')
6330  >>> M[x] = x + 1
6331  >>> len(M)
6332  1
6333  >>> M.erase(x)
6334  >>> len(M)
6335  0
6336  """
6337  Z3_ast_map_erase(self.ctx.ref(), self.map, k.as_ast())
6338 
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(self, k)
Definition: z3py.py:6325
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 6354 of file z3py.py.

6354  def keys(self):
6355  """Return an AstVector containing all keys in the map.
6356 
6357  >>> M = AstMap()
6358  >>> x = Int('x')
6359  >>> M[x] = x + 1
6360  >>> M[x+x] = IntVal(1)
6361  >>> M.keys()
6362  [x, x + x]
6363  """
6364  return AstVector(Z3_ast_map_keys(self.ctx.ref(), self.map), self.ctx)
6365 
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(self)
Definition: z3py.py:6354
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 6339 of file z3py.py.

6339  def reset(self):
6340  """Remove all entries from the map.
6341 
6342  >>> M = AstMap()
6343  >>> x = Int('x')
6344  >>> M[x] = x + 1
6345  >>> M[x+x] = IntVal(1)
6346  >>> len(M)
6347  2
6348  >>> M.reset()
6349  >>> len(M)
6350  0
6351  """
6352  Z3_ast_map_reset(self.ctx.ref(), self.map)
6353 
def reset(self)
Definition: z3py.py:6339
void Z3_API Z3_ast_map_reset(Z3_context c, Z3_ast_map m)
Remove all keys from the given map.

Field Documentation

ctx
map