Z3
 
Loading...
Searching...
No Matches
Public Member Functions | Data Fields
AstMap Class Reference

Public Member Functions

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

Data Fields

 map
 
 ctx
 

Detailed Description

A mapping from ASTs to ASTs.

Definition at line 6206 of file z3py.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 6209 of file z3py.py.

6209 def __init__(self, m=None, ctx=None):
6210 self.map = None
6211 if m is None:
6212 self.ctx = _get_ctx(ctx)
6213 self.map = Z3_mk_ast_map(self.ctx.ref())
6214 else:
6215 self.map = m
6216 assert ctx is not None
6217 self.ctx = ctx
6218 Z3_ast_map_inc_ref(self.ctx.ref(), self.map)
6219
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.

◆ __del__()

__del__ (   self)

Definition at line 6223 of file z3py.py.

6223 def __del__(self):
6224 if self.map is not None and self.ctx.ref() is not None and Z3_ast_map_dec_ref is not None:
6225 Z3_ast_map_dec_ref(self.ctx.ref(), self.map)
6226
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

◆ __contains__()

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

6240 def __contains__(self, key):
6241 """Return `True` if the map contains key `key`.
6242
6243 >>> M = AstMap()
6244 >>> x = Int('x')
6245 >>> M[x] = x + 1
6246 >>> x in M
6247 True
6248 >>> x+1 in M
6249 False
6250 """
6251 return Z3_ast_map_contains(self.ctx.ref(), self.map, key.as_ast())
6252
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.

◆ __deepcopy__()

__deepcopy__ (   self,
  memo = {} 
)

Definition at line 6220 of file z3py.py.

6220 def __deepcopy__(self, memo={}):
6221 return AstMap(self.map, self.ctx)
6222

◆ __getitem__()

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

6253 def __getitem__(self, key):
6254 """Retrieve the value associated with key `key`.
6255
6256 >>> M = AstMap()
6257 >>> x = Int('x')
6258 >>> M[x] = x + 1
6259 >>> M[x]
6260 x + 1
6261 """
6262 return _to_ast_ref(Z3_ast_map_find(self.ctx.ref(), self.map, key.as_ast()), self.ctx)
6263
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.

◆ __len__()

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

6227 def __len__(self):
6228 """Return the size of the map.
6229
6230 >>> M = AstMap()
6231 >>> len(M)
6232 0
6233 >>> x = Int('x')
6234 >>> M[x] = IntVal(1)
6235 >>> len(M)
6236 1
6237 """
6238 return int(Z3_ast_map_size(self.ctx.ref(), self.map))
6239
unsigned Z3_API Z3_ast_map_size(Z3_context c, Z3_ast_map m)
Return the size of the given map.

Referenced by AstVector.__getitem__(), and AstVector.__setitem__().

◆ __repr__()

__repr__ (   self)

Definition at line 6280 of file z3py.py.

6280 def __repr__(self):
6281 return Z3_ast_map_to_string(self.ctx.ref(), self.map)
6282
Z3_string Z3_API Z3_ast_map_to_string(Z3_context c, Z3_ast_map m)
Convert the given map into a string.

◆ __setitem__()

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

6264 def __setitem__(self, k, v):
6265 """Add/Update key `k` with value `v`.
6266
6267 >>> M = AstMap()
6268 >>> x = Int('x')
6269 >>> M[x] = x + 1
6270 >>> len(M)
6271 1
6272 >>> M[x]
6273 x + 1
6274 >>> M[x] = IntVal(1)
6275 >>> M[x]
6276 1
6277 """
6278 Z3_ast_map_insert(self.ctx.ref(), self.map, k.as_ast(), v.as_ast())
6279
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.

◆ erase()

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

6283 def erase(self, k):
6284 """Remove the entry associated with key `k`.
6285
6286 >>> M = AstMap()
6287 >>> x = Int('x')
6288 >>> M[x] = x + 1
6289 >>> len(M)
6290 1
6291 >>> M.erase(x)
6292 >>> len(M)
6293 0
6294 """
6295 Z3_ast_map_erase(self.ctx.ref(), self.map, k.as_ast())
6296
void Z3_API Z3_ast_map_erase(Z3_context c, Z3_ast_map m, Z3_ast k)
Erase a key from the map.

◆ keys()

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

6312 def keys(self):
6313 """Return an AstVector containing all keys in the map.
6314
6315 >>> M = AstMap()
6316 >>> x = Int('x')
6317 >>> M[x] = x + 1
6318 >>> M[x+x] = IntVal(1)
6319 >>> M.keys()
6320 [x, x + x]
6321 """
6322 return AstVector(Z3_ast_map_keys(self.ctx.ref(), self.map), self.ctx)
6323
Z3_ast_vector Z3_API Z3_ast_map_keys(Z3_context c, Z3_ast_map m)
Return the keys stored in the given map.

◆ reset()

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

6297 def reset(self):
6298 """Remove all entries from the map.
6299
6300 >>> M = AstMap()
6301 >>> x = Int('x')
6302 >>> M[x] = x + 1
6303 >>> M[x+x] = IntVal(1)
6304 >>> len(M)
6305 2
6306 >>> M.reset()
6307 >>> len(M)
6308 0
6309 """
6310 Z3_ast_map_reset(self.ctx.ref(), self.map)
6311
void Z3_API Z3_ast_map_reset(Z3_context c, Z3_ast_map m)
Remove all keys from the given map.

Field Documentation

◆ ctx

ctx

Definition at line 6212 of file z3py.py.

Referenced by ArithRef.__add__(), BitVecRef.__add__(), BitVecRef.__and__(), FuncDeclRef.__call__(), AstMap.__contains__(), AstRef.__copy__(), Goal.__copy__(), AstVector.__copy__(), FuncInterp.__copy__(), ModelRef.__copy__(), AstRef.__deepcopy__(), Datatype.__deepcopy__(), ParamsRef.__deepcopy__(), ParamDescrsRef.__deepcopy__(), Goal.__deepcopy__(), AstVector.__deepcopy__(), AstMap.__deepcopy__(), FuncEntry.__deepcopy__(), FuncInterp.__deepcopy__(), ModelRef.__deepcopy__(), Statistics.__deepcopy__(), Context.__del__(), AstRef.__del__(), ScopedConstructor.__del__(), ScopedConstructorList.__del__(), ParamsRef.__del__(), ParamDescrsRef.__del__(), Goal.__del__(), AstVector.__del__(), AstMap.__del__(), FuncEntry.__del__(), FuncInterp.__del__(), ModelRef.__del__(), Statistics.__del__(), Solver.__del__(), ArithRef.__div__(), BitVecRef.__div__(), ExprRef.__eq__(), ArithRef.__ge__(), BitVecRef.__ge__(), AstVector.__getitem__(), ModelRef.__getitem__(), Statistics.__getitem__(), AstMap.__getitem__(), ArithRef.__gt__(), BitVecRef.__gt__(), BitVecRef.__invert__(), ArithRef.__le__(), BitVecRef.__le__(), AstVector.__len__(), AstMap.__len__(), ModelRef.__len__(), Statistics.__len__(), BitVecRef.__lshift__(), ArithRef.__lt__(), BitVecRef.__lt__(), ArithRef.__mod__(), BitVecRef.__mod__(), BoolRef.__mul__(), ArithRef.__mul__(), BitVecRef.__mul__(), ExprRef.__ne__(), ArithRef.__neg__(), BitVecRef.__neg__(), BitVecRef.__or__(), ArithRef.__pow__(), ArithRef.__radd__(), BitVecRef.__radd__(), BitVecRef.__rand__(), ArithRef.__rdiv__(), BitVecRef.__rdiv__(), ParamsRef.__repr__(), ParamDescrsRef.__repr__(), AstMap.__repr__(), Statistics.__repr__(), BitVecRef.__rlshift__(), ArithRef.__rmod__(), BitVecRef.__rmod__(), ArithRef.__rmul__(), BitVecRef.__rmul__(), BitVecRef.__ror__(), ArithRef.__rpow__(), BitVecRef.__rrshift__(), BitVecRef.__rshift__(), ArithRef.__rsub__(), BitVecRef.__rsub__(), BitVecRef.__rxor__(), AstVector.__setitem__(), AstMap.__setitem__(), ArithRef.__sub__(), BitVecRef.__sub__(), BitVecRef.__xor__(), DatatypeSortRef.accessor(), ExprRef.arg(), FuncEntry.arg_value(), FuncInterp.arity(), Goal.as_expr(), Solver.assert_and_track(), Goal.assert_exprs(), Solver.assert_exprs(), QuantifierRef.body(), Solver.check(), Goal.convert_model(), AstRef.ctx_ref(), ExprRef.decl(), ModelRef.decls(), ArrayRef.default(), RatNumRef.denominator(), Goal.depth(), Goal.dimacs(), FuncDeclRef.domain(), ArraySortRef.domain_n(), FuncInterp.else_value(), FuncInterp.entry(), AstMap.erase(), ModelRef.eval(), Goal.get(), ParamDescrsRef.get_documentation(), ModelRef.get_interp(), Statistics.get_key_value(), ParamDescrsRef.get_kind(), ParamDescrsRef.get_name(), ModelRef.get_sort(), ModelRef.get_universe(), Goal.inconsistent(), AstMap.keys(), Statistics.keys(), Solver.model(), SortRef.name(), QuantifierRef.no_pattern(), FuncEntry.num_args(), FuncInterp.num_entries(), Solver.num_scopes(), ModelRef.num_sorts(), FuncDeclRef.params(), QuantifierRef.pattern(), AlgebraicNumRef.poly(), Solver.pop(), Goal.prec(), ModelRef.project(), ModelRef.project_with_witness(), Solver.push(), AstVector.push(), QuantifierRef.qid(), FuncDeclRef.range(), ArraySortRef.range(), DatatypeSortRef.recognizer(), Context.ref(), AstMap.reset(), Solver.reset(), AstVector.resize(), Solver.set(), ParamsRef.set(), Goal.sexpr(), AstVector.sexpr(), ModelRef.sexpr(), ParamDescrsRef.size(), Goal.size(), QuantifierRef.skolem_id(), AstVector.translate(), AstRef.translate(), Goal.translate(), ModelRef.translate(), ExprRef.update(), ParamsRef.validate(), FuncEntry.value(), QuantifierRef.var_name(), and QuantifierRef.var_sort().

◆ map

map