Inheritance diagram for ModelRef:Public Member Functions | |
| def | __init__ (self, m, ctx) |
| def | __del__ (self) |
| def | __repr__ (self) |
| def | sexpr (self) |
| def | eval |
| def | evaluate |
| def | __len__ (self) |
| def | get_interp (self, decl) |
| def | num_sorts (self) |
| def | get_sort (self, idx) |
| def | sorts (self) |
| def | get_universe (self, s) |
| def | __getitem__ (self, idx) |
| def | decls (self) |
| def | update_value (self, x, value) |
| def | translate (self, target) |
| def | __copy__ (self) |
| def | __deepcopy__ |
Public Member Functions inherited from Z3PPObject | |
| def | use_pp (self) |
Data Fields | |
| model | |
| ctx | |
Model/Solution of a satisfiability problem (aka system of constraints).
| def __init__ | ( | self, | |
| m, | |||
| ctx | |||
| ) |
| def __del__ | ( | self | ) |
| def __getitem__ | ( | self, | |
| idx | |||
| ) |
If `idx` is an integer, then the declaration at position `idx` in the model `self` is returned.
If `idx` is a declaration, then the actual interpretation is returned.
The elements can be retrieved using position or the actual declaration.
>>> f = Function('f', IntSort(), IntSort())
>>> x = Int('x')
>>> s = Solver()
>>> s.add(x > 0, x < 2, f(x) == 0)
>>> s.check()
sat
>>> m = s.model()
>>> len(m)
2
>>> m[0]
x
>>> m[1]
f
>>> m[x]
1
>>> m[f]
[else -> 0]
>>> for d in m: print("%s -> %s" % (d, m[d]))
x -> 1
f -> [else -> 0]
Definition at line 6502 of file z3py.py.
| def __len__ | ( | self | ) |
Return the number of constant and function declarations in the model `self`.
>>> f = Function('f', IntSort(), IntSort())
>>> x = Int('x')
>>> s = Solver()
>>> s.add(x > 0, f(x) != x)
>>> s.check()
sat
>>> m = s.model()
>>> len(m)
2
Definition at line 6376 of file z3py.py.
| def decls | ( | self | ) |
Return a list with all symbols that have an interpretation in the model `self`.
>>> f = Function('f', IntSort(), IntSort())
>>> x = Int('x')
>>> s = Solver()
>>> s.add(x > 0, x < 2, f(x) == 0)
>>> s.check()
sat
>>> m = s.model()
>>> m.decls()
[x, f]
Definition at line 6547 of file z3py.py.
| def eval | ( | self, | |
| t, | |||
model_completion = False |
|||
| ) |
Evaluate the expression `t` in the model `self`.
If `model_completion` is enabled, then a default interpretation is automatically added
for symbols that do not have an interpretation in the model `self`.
>>> x = Int('x')
>>> s = Solver()
>>> s.add(x > 0, x < 2)
>>> s.check()
sat
>>> m = s.model()
>>> m.eval(x + 1)
2
>>> m.eval(x == 1)
True
>>> y = Int('y')
>>> m.eval(y + x)
1 + y
>>> m.eval(y)
y
>>> m.eval(y, model_completion=True)
0
>>> # Now, m contains an interpretation for y
>>> m.eval(y + x)
1
Definition at line 6319 of file z3py.py.
| def evaluate | ( | self, | |
| t, | |||
model_completion = False |
|||
| ) |
Alias for `eval`.
>>> x = Int('x')
>>> s = Solver()
>>> s.add(x > 0, x < 2)
>>> s.check()
sat
>>> m = s.model()
>>> m.evaluate(x + 1)
2
>>> m.evaluate(x == 1)
True
>>> y = Int('y')
>>> m.evaluate(y + x)
1 + y
>>> m.evaluate(y)
y
>>> m.evaluate(y, model_completion=True)
0
>>> # Now, m contains an interpretation for y
>>> m.evaluate(y + x)
1
Definition at line 6350 of file z3py.py.
| def get_interp | ( | self, | |
| decl | |||
| ) |
Return the interpretation for a given declaration or constant.
>>> f = Function('f', IntSort(), IntSort())
>>> x = Int('x')
>>> s = Solver()
>>> s.add(x > 0, x < 2, f(x) == 0)
>>> s.check()
sat
>>> m = s.model()
>>> m[x]
1
>>> m[f]
[else -> 0]
Definition at line 6393 of file z3py.py.
Referenced by ModelRef.__getitem__().
| def get_sort | ( | self, | |
| idx | |||
| ) |
Return the uninterpreted sort at position `idx` < self.num_sorts().
>>> A = DeclareSort('A')
>>> B = DeclareSort('B')
>>> a1, a2 = Consts('a1 a2', A)
>>> b1, b2 = Consts('b1 b2', B)
>>> s = Solver()
>>> s.add(a1 != a2, b1 != b2)
>>> s.check()
sat
>>> m = s.model()
>>> m.num_sorts()
2
>>> m.get_sort(0)
A
>>> m.get_sort(1)
B
Definition at line 6442 of file z3py.py.
| def get_universe | ( | self, | |
| s | |||
| ) |
Return the interpretation for the uninterpreted sort `s` in the model `self`.
>>> A = DeclareSort('A')
>>> a, b = Consts('a b', A)
>>> s = Solver()
>>> s.add(a != b)
>>> s.check()
sat
>>> m = s.model()
>>> m.get_universe(A)
[A!val!1, A!val!0]
Definition at line 6482 of file z3py.py.
Referenced by ModelRef.__getitem__().
| def num_sorts | ( | self | ) |
Return the number of uninterpreted sorts that contain an interpretation in the model `self`.
>>> A = DeclareSort('A')
>>> a, b = Consts('a b', A)
>>> s = Solver()
>>> s.add(a != b)
>>> s.check()
sat
>>> m = s.model()
>>> m.num_sorts()
1
Definition at line 6427 of file z3py.py.
Referenced by ModelRef.get_sort().
| def sexpr | ( | self | ) |
Return a textual representation of the s-expression representing the model.
Definition at line 6315 of file z3py.py.
Referenced by Fixedpoint.__repr__(), and Optimize.__repr__().
| def sorts | ( | self | ) |
Return all uninterpreted sorts that have an interpretation in the model `self`.
>>> A = DeclareSort('A')
>>> B = DeclareSort('B')
>>> a1, a2 = Consts('a1 a2', A)
>>> b1, b2 = Consts('b1 b2', B)
>>> s = Solver()
>>> s.add(a1 != a2, b1 != b2)
>>> s.check()
sat
>>> m = s.model()
>>> m.sorts()
[A, B]
Definition at line 6465 of file z3py.py.
| def translate | ( | self, | |
| target | |||
| ) |
Translate `self` to the context `target`. That is, return a copy of `self` in the context `target`.
Definition at line 6575 of file z3py.py.
Referenced by ModelRef.__copy__(), and ModelRef.__deepcopy__().
| def update_value | ( | self, | |
| x, | |||
| value | |||
| ) |
| ctx |
Definition at line 6305 of file z3py.py.
Referenced by ModelRef.__copy__(), ModelRef.__deepcopy__(), Fixedpoint.__deepcopy__(), Optimize.__deepcopy__(), ApplyResult.__deepcopy__(), Tactic.__deepcopy__(), Probe.__deepcopy__(), Probe.__eq__(), Probe.__ge__(), ModelRef.__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(), ModelRef.decls(), ModelRef.eval(), Fixedpoint.get_answer(), Fixedpoint.get_assertions(), Fixedpoint.get_cover_delta(), Fixedpoint.get_ground_sat_answer(), ModelRef.get_interp(), Fixedpoint.get_rule_names_along_trace(), Fixedpoint.get_rules(), Fixedpoint.get_rules_along_trace(), ModelRef.get_sort(), ModelRef.get_universe(), 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(), Optimize.set_on_model(), Tactic.solver(), Fixedpoint.statistics(), Optimize.statistics(), Solver.to_smt2(), Optimize.unsat_core(), and Fixedpoint.update_rule().
| model |
Definition at line 6304 of file z3py.py.
Referenced by ModelRef.__del__(), ModelRef.__getitem__(), ModelRef.__len__(), ModelRef.decls(), ModelRef.eval(), ModelRef.get_interp(), ModelRef.get_sort(), ModelRef.get_universe(), ModelRef.num_sorts(), ModelRef.sexpr(), FuncInterp.translate(), ModelRef.translate(), and ModelRef.update_value().
1.8.10