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

Public Member Functions

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

Constructor & Destructor Documentation

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

Definition at line 4939 of file z3py.py.

4940  def __init__(self, m=None, ctx=None):
4941  self.map = None
4942  if m == None:
4943  self.ctx = _get_ctx(ctx)
4944  self.map = Z3_mk_ast_map(self.ctx.ref())
4945  else:
4946  self.map = m
4947  assert ctx != None
4948  self.ctx = ctx
4949  Z3_ast_map_inc_ref(self.ctx.ref(), self.map)
Z3_ast_map Z3_API Z3_mk_ast_map(__in Z3_context c)
Return an empty mapping from AST to AST.
def __init__
Definition: z3py.py:4939
void Z3_API Z3_ast_map_inc_ref(__in Z3_context c, __in Z3_ast_map m)
Increment the reference counter of the given AST map.
def __del__ (   self)

Definition at line 4950 of file z3py.py.

4951  def __del__(self):
4952  if self.map != None:
4953  Z3_ast_map_dec_ref(self.ctx.ref(), self.map)
def __del__
Definition: z3py.py:4950
void Z3_API Z3_ast_map_dec_ref(__in Z3_context c, __in 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 4967 of file z3py.py.

4968  def __contains__(self, key):
4969  """Return `True` if the map contains key `key`.
4970 
4971  >>> M = AstMap()
4972  >>> x = Int('x')
4973  >>> M[x] = x + 1
4974  >>> x in M
4975  True
4976  >>> x+1 in M
4977  False
4978  """
4979  return Z3_ast_map_contains(self.ctx.ref(), self.map, key.as_ast())
def __contains__
Definition: z3py.py:4967
Z3_bool Z3_API Z3_ast_map_contains(__in Z3_context c, __in Z3_ast_map m, __in Z3_ast k)
Return true if the map m contains the AST key k.
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 4980 of file z3py.py.

4981  def __getitem__(self, key):
4982  """Retrieve the value associated with key `key`.
4983 
4984  >>> M = AstMap()
4985  >>> x = Int('x')
4986  >>> M[x] = x + 1
4987  >>> M[x]
4988  x + 1
4989  """
4990  return _to_ast_ref(Z3_ast_map_find(self.ctx.ref(), self.map, key.as_ast()), self.ctx)
def __getitem__
Definition: z3py.py:4980
Z3_ast Z3_API Z3_ast_map_find(__in Z3_context c, __in Z3_ast_map m, __in 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 4954 of file z3py.py.

4955  def __len__(self):
4956  """Return the size of the map.
4957 
4958  >>> M = AstMap()
4959  >>> len(M)
4960  0
4961  >>> x = Int('x')
4962  >>> M[x] = IntVal(1)
4963  >>> len(M)
4964  1
4965  """
4966  return int(Z3_ast_map_size(self.ctx.ref(), self.map))
unsigned Z3_API Z3_ast_map_size(__in Z3_context c, __in Z3_ast_map m)
Return the size of the given map.
def __len__
Definition: z3py.py:4954
def __repr__ (   self)

Definition at line 5007 of file z3py.py.

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

4992  def __setitem__(self, k, v):
4993  """Add/Update key `k` with value `v`.
4994 
4995  >>> M = AstMap()
4996  >>> x = Int('x')
4997  >>> M[x] = x + 1
4998  >>> len(M)
4999  1
5000  >>> M[x]
5001  x + 1
5002  >>> M[x] = IntVal(1)
5003  >>> M[x]
5004  1
5005  """
5006  Z3_ast_map_insert(self.ctx.ref(), self.map, k.as_ast(), v.as_ast())
def __setitem__
Definition: z3py.py:4991
void Z3_API Z3_ast_map_insert(__in Z3_context c, __in Z3_ast_map m, __in Z3_ast k, __in 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 5010 of file z3py.py.

5011  def erase(self, k):
5012  """Remove the entry associated with key `k`.
5013 
5014  >>> M = AstMap()
5015  >>> x = Int('x')
5016  >>> M[x] = x + 1
5017  >>> len(M)
5018  1
5019  >>> M.erase(x)
5020  >>> len(M)
5021  0
5022  """
5023  Z3_ast_map_erase(self.ctx.ref(), self.map, k.as_ast())
void Z3_API Z3_ast_map_erase(__in Z3_context c, __in Z3_ast_map m, __in Z3_ast k)
Erase a key from the map.
def erase
Definition: z3py.py:5010
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 5039 of file z3py.py.

5040  def keys(self):
5041  """Return an AstVector containing all keys in the map.
5042 
5043  >>> M = AstMap()
5044  >>> x = Int('x')
5045  >>> M[x] = x + 1
5046  >>> M[x+x] = IntVal(1)
5047  >>> M.keys()
5048  [x, x + x]
5049  """
5050  return AstVector(Z3_ast_map_keys(self.ctx.ref(), self.map), self.ctx)
Z3_ast_vector Z3_API Z3_ast_map_keys(__in Z3_context c, __in Z3_ast_map m)
Return the keys stored in the given map.
def keys
Definition: z3py.py:5039
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 5024 of file z3py.py.

5025  def reset(self):
5026  """Remove all entries from the map.
5027 
5028  >>> M = AstMap()
5029  >>> x = Int('x')
5030  >>> M[x] = x + 1
5031  >>> M[x+x] = IntVal(1)
5032  >>> len(M)
5033  2
5034  >>> M.reset()
5035  >>> len(M)
5036  0
5037  """
5038  Z3_ast_map_reset(self.ctx.ref(), self.map)
def reset
Definition: z3py.py:5024
void Z3_API Z3_ast_map_reset(__in Z3_context c, __in Z3_ast_map m)
Remove all keys from the given map.

Field Documentation

ctx

Definition at line 4942 of file z3py.py.

Referenced by Probe.__eq__(), Probe.__ge__(), AstMap.__getitem__(), ApplyResult.__getitem__(), Probe.__gt__(), Probe.__le__(), Probe.__lt__(), Probe.__ne__(), Fixedpoint.add_rule(), Tactic.apply(), ApplyResult.as_expr(), Fixedpoint.assert_exprs(), ApplyResult.convert_model(), Fixedpoint.get_answer(), Fixedpoint.get_assertions(), Fixedpoint.get_cover_delta(), Fixedpoint.get_rules(), AstMap.keys(), Fixedpoint.param_descrs(), Tactic.param_descrs(), Fixedpoint.parse_file(), Fixedpoint.parse_string(), Fixedpoint.set(), Tactic.solver(), Fixedpoint.statistics(), Solver.to_smt2(), and Fixedpoint.update_rule().

map

Definition at line 4940 of file z3py.py.

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