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

## Constructor & Destructor Documentation

## ◆ __init__()

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

Definition at line 5948 of file z3py.py.

5948 def __init__(self, m=None, ctx=None):
5949 self.map = None
5950 if m is None:
5951 self.ctx = _get_ctx(ctx)
5952 self.map = Z3_mk_ast_map(self.ctx.ref())
5953 else:
5954 self.map = m
5955 assert ctx is not None
5956 self.ctx = ctx
5957 Z3_ast_map_inc_ref(self.ctx.ref(), self.map)
5958
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_mk_ast_map
Z3_ast_map Z3_API Z3_mk_ast_map(Z3_context c)
Return an empty mapping from AST to AST.

## ◆ __del__()

def __del__ | ( |  | self | ) |

Definition at line 5962 of file z3py.py.

5962 def __del__(self):
5963 if self.map is not None and self.ctx.ref() is not None:
5964 Z3_ast_map_dec_ref(self.ctx.ref(), self.map)
5965
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.

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

5979 def __contains__(self, key):
5980 """Return `True` if the map contains key `key`.
5981
5982 >>> M = AstMap()
5983 >>> x = Int('x')
5984 >>> M[x] = x + 1
5985 >>> x in M
5986 True
5987 >>> x+1 in M
5988 False
5989 """
5990 return Z3_ast_map_contains(self.ctx.ref(), self.map, key.as_ast())
5991
z3py.Int
def Int(name, ctx=None)
Definition: z3py.py:3210
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.

## ◆ __deepcopy__()

def __deepcopy__ | ( |  | self,
|  |  | memo = `{}`
| ) |  |

Definition at line 5959 of file z3py.py.

5959 def __deepcopy__(self, memo={}):
5960 return AstMap(self.map, self.ctx)
5961

## ◆ __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 5992 of file z3py.py.

5992 def __getitem__(self, key):
5993 """Retrieve the value associated with key `key`.
5994
5995 >>> M = AstMap()
5996 >>> x = Int('x')
5997 >>> M[x] = x + 1
5998 >>> M[x]
5999 x + 1
6000 """
6001 return _to_ast_ref(Z3_ast_map_find(self.ctx.ref(), self.map, key.as_ast()), self.ctx)
6002
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.

## ◆ __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 5966 of file z3py.py.

5966 def __len__(self):
5967 """Return the size of the map.
5968
5969 >>> M = AstMap()
5970 >>> len(M)
5971 0
5972 >>> x = Int('x')
5973 >>> M[x] = IntVal(1)
5974 >>> len(M)
5975 1
5976 """
5977 return int(Z3_ast_map_size(self.ctx.ref(), self.map))
5978
z3py.IntVal
def IntVal(val, ctx=None)
Definition: z3py.py:3150
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.

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

## ◆ __repr__()

def __repr__ | ( |  | self | ) |

Definition at line 6019 of file z3py.py.

6019 def __repr__(self):
6020 return Z3_ast_map_to_string(self.ctx.ref(), self.map)
6021
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.

## ◆ __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 6003 of file z3py.py.

6003 def __setitem__(self, k, v):
6004 """Add/Update key `k` with value `v`.
6005
6006 >>> M = AstMap()
6007 >>> x = Int('x')
6008 >>> M[x] = x + 1
6009 >>> len(M)
6010 1
6011 >>> M[x]
6012 x + 1
6013 >>> M[x] = IntVal(1)
6014 >>> M[x]
6015 1
6016 """
6017 Z3_ast_map_insert(self.ctx.ref(), self.map, k.as_ast(), v.as_ast())
6018
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.

## ◆ 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 6022 of file z3py.py.

6022 def erase(self, k):
6023 """Remove the entry associated with key `k`.
6024
6025 >>> M = AstMap()
6026 >>> x = Int('x')
6027 >>> M[x] = x + 1
6028 >>> len(M)
6029 1
6030 >>> M.erase(x)
6031 >>> len(M)
6032 0
6033 """
6034 Z3_ast_map_erase(self.ctx.ref(), self.map, k.as_ast())
6035
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.

## ◆ 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 6051 of file z3py.py.

6051 def keys(self):
6052 """Return an AstVector containing all keys in the map.
6053
6054 >>> M = AstMap()
6055 >>> x = Int('x')
6056 >>> M[x] = x + 1
6057 >>> M[x+x] = IntVal(1)
6058 >>> M.keys()
6059 [x, x + x]
6060 """
6061 return AstVector(Z3_ast_map_keys(self.ctx.ref(), self.map), self.ctx)
6062
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.

## ◆ 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 6036 of file z3py.py.

6036 def reset(self):
6037 """Remove all entries from the map.
6038
6039 >>> M = AstMap()
6040 >>> x = Int('x')
6041 >>> M[x] = x + 1
6042 >>> M[x+x] = IntVal(1)
6043 >>> len(M)
6044 2
6045 >>> M.reset()
6046 >>> len(M)
6047 0
6048 """
6049 Z3_ast_map_reset(self.ctx.ref(), self.map)
6050
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.

## Field Documentation

## ◆ ctx

ctx

Definition at line 5951 of file z3py.py.

Referenced by ArithRef.__add__(), BitVecRef.__add__(), FPRef.__add__(), BitVecRef.__and__(), FuncDeclRef.__call__(), Probe.__call__(), AstMap.__contains__(), AstRef.__copy__(), Goal.__copy__(), AstVector.__copy__(), FuncInterp.__copy__(), ModelRef.__copy__(), Solver.__copy__(), AstRef.__deepcopy__(), Datatype.__deepcopy__(), ParamsRef.__deepcopy__(), ParamDescrsRef.__deepcopy__(), Goal.__deepcopy__(), AstVector.__deepcopy__(), AstMap.__deepcopy__(), FuncEntry.__deepcopy__(), FuncInterp.__deepcopy__(), ModelRef.__deepcopy__(), Statistics.__deepcopy__(), Solver.__deepcopy__(), Fixedpoint.__deepcopy__(), Optimize.__deepcopy__(), ApplyResult.__deepcopy__(), Tactic.__deepcopy__(), Probe.__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__(), Fixedpoint.__del__(), Optimize.__del__(), ApplyResult.__del__(), Tactic.__del__(), Probe.__del__(), ArithRef.__div__(), BitVecRef.__div__(), FPRef.__div__(), ExprRef.__eq__(), Probe.__eq__(), ArithRef.__ge__(), BitVecRef.__ge__(), Probe.__ge__(), FPRef.__ge__(), SeqRef.__ge__(), QuantifierRef.__getitem__(), ArrayRef.__getitem__(), AstVector.__getitem__(), SeqRef.__getitem__(), ModelRef.__getitem__(), Statistics.__getitem__(), ApplyResult.__getitem__(), AstMap.__getitem__(), ArithRef.__gt__(), BitVecRef.__gt__(), Probe.__gt__(), FPRef.__gt__(), SeqRef.__gt__(), BitVecRef.__invert__(), ArithRef.__le__(), BitVecRef.__le__(), Probe.__le__(), FPRef.__le__(), SeqRef.__le__(), AstVector.__len__(), AstMap.__len__(), ModelRef.__len__(), Statistics.__len__(), ApplyResult.__len__(), BitVecRef.__lshift__(), ArithRef.__lt__(), BitVecRef.__lt__(), Probe.__lt__(), FPRef.__lt__(), SeqRef.__lt__(), ArithRef.__mod__(), BitVecRef.__mod__(), ArithRef.__mul__(), BitVecRef.__mul__(), FPRef.__mul__(), ExprRef.__ne__(), Probe.__ne__(), ArithRef.__neg__(), BitVecRef.__neg__(), BitVecRef.__or__(), ArithRef.__pow__(), ArithRef.__radd__(), BitVecRef.__radd__(), FPRef.__radd__(), BitVecRef.__rand__(), ArithRef.__rdiv__(), BitVecRef.__rdiv__(), FPRef.__rdiv__(), ParamsRef.__repr__(), ParamDescrsRef.__repr__(), AstMap.__repr__(), Statistics.__repr__(), BitVecRef.__rlshift__(), ArithRef.__rmod__(), BitVecRef.__rmod__(), ArithRef.__rmul__(), BitVecRef.__rmul__(), FPRef.__rmul__(), BitVecRef.__ror__(), ArithRef.__rpow__(), BitVecRef.__rrshift__(), BitVecRef.__rshift__(), ArithRef.__rsub__(), BitVecRef.__rsub__(), FPRef.__rsub__(), BitVecRef.__rxor__(), AstVector.__setitem__(), AstMap.__setitem__(), ArithRef.__sub__(), BitVecRef.__sub__(), FPRef.__sub__(), BitVecRef.__xor__(), DatatypeSortRef.accessor(), Fixedpoint.add_cover(), Fixedpoint.add_rule(), Optimize.add_soft(), Tactic.apply(), AlgebraicNumRef.approx(), ExprRef.arg(), FuncEntry.arg_value(), FuncInterp.arity(), Goal.as_expr(), ApplyResult.as_expr(), FPNumRef.as_string(), Solver.assert_and_track(), Optimize.assert_and_track(), Goal.assert_exprs(), Solver.assert_exprs(), Fixedpoint.assert_exprs(), Optimize.assert_exprs(), Solver.assertions(), Optimize.assertions(), SeqRef.at(), SeqSortRef.basis(), ReSortRef.basis(), QuantifierRef.body(), BoolSortRef.cast(), Solver.check(), Optimize.check(), UserPropagateBase.conflict(), Solver.consequences(), DatatypeSortRef.constructor(), Goal.convert_model(), AstRef.ctx_ref(), UserPropagateBase.ctx_ref(), ExprRef.decl(), ModelRef.decls(), ArrayRef.default(), RatNumRef.denominator(), Goal.depth(), Goal.dimacs(), Solver.dimacs(), ArraySortRef.domain(), FuncDeclRef.domain(), FuncInterp.else_value(), FuncInterp.entry(), AstMap.erase(), ModelRef.eval(), FPNumRef.exponent(), FPNumRef.exponent_as_bv(), FPNumRef.exponent_as_long(), Solver.from_file(), Optimize.from_file(), Solver.from_string(), Optimize.from_string(), Goal.get(), Fixedpoint.get_answer(), Fixedpoint.get_assertions(), Fixedpoint.get_cover_delta(), ParamDescrsRef.get_documentation(), Fixedpoint.get_ground_sat_answer(), ModelRef.get_interp(), Statistics.get_key_value(), ParamDescrsRef.get_kind(), ParamDescrsRef.get_name(), 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(), Goal.inconsistent(), FPNumRef.isInf(), FPNumRef.isNaN(), FPNumRef.isNegative(), FPNumRef.isNormal(), FPNumRef.isPositive(), FPNumRef.isSubnormal(), FPNumRef.isZero(), AstMap.keys(), Statistics.keys(), SortRef.kind(), Optimize.maximize(), Optimize.minimize(), Solver.model(), Optimize.model(), SortRef.name(), FuncDeclRef.name(), QuantifierRef.no_pattern(), Solver.non_units(), FuncEntry.num_args(), FuncInterp.num_entries(), Solver.num_scopes(), ModelRef.num_sorts(), RatNumRef.numerator(), Optimize.objectives(), Solver.param_descrs(), Fixedpoint.param_descrs(), Optimize.param_descrs(), Tactic.param_descrs(), FuncDeclRef.params(), Fixedpoint.parse_file(), Fixedpoint.parse_string(), QuantifierRef.pattern(), AlgebraicNumRef.poly(), Optimize.pop(), Solver.pop(), Goal.prec(), Solver.proof(), Solver.push(), Optimize.push(), AstVector.push(), Fixedpoint.query(), Fixedpoint.query_from_lvl(), FuncDeclRef.range(), ArraySortRef.range(), Solver.reason_unknown(), Fixedpoint.reason_unknown(), Optimize.reason_unknown(), DatatypeSortRef.recognizer(), Context.ref(), Fixedpoint.register_relation(), AstMap.reset(), Solver.reset(), AstVector.resize(), Solver.set(), Fixedpoint.set(), Optimize.set(), ParamsRef.set(), Optimize.set_on_model(), Fixedpoint.set_predicate_representation(), Goal.sexpr(), AstVector.sexpr(), ModelRef.sexpr(), Solver.sexpr(), Fixedpoint.sexpr(), Optimize.sexpr(), ApplyResult.sexpr(), FPNumRef.sign(), FPNumRef.sign_as_bv(), FPNumRef.significand(), FPNumRef.significand_as_bv(), FPNumRef.significand_as_long(), ParamDescrsRef.size(), Goal.size(), Tactic.solver(), ExprRef.sort(), BoolRef.sort(), QuantifierRef.sort(), ArithRef.sort(), BitVecRef.sort(), ArrayRef.sort(), DatatypeRef.sort(), FiniteDomainRef.sort(), FPRef.sort(), SeqRef.sort(), Solver.statistics(), Fixedpoint.statistics(), Optimize.statistics(), Solver.to_smt2(), Fixedpoint.to_string(), Solver.trail(), Solver.trail_levels(), AstVector.translate(), FuncInterp.translate(), AstRef.translate(), Goal.translate(), ModelRef.translate(), Solver.translate(), Solver.units(), Solver.unsat_core(), Optimize.unsat_core(), Fixedpoint.update_rule(), ParamsRef.validate(), FuncEntry.value(), QuantifierRef.var_name(), and QuantifierRef.var_sort().

## ◆ map

map

Definition at line 5949 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().