Public Member Functions | |
| __init__ (self, m, ctx) | |
| __del__ (self) | |
| __repr__ (self) | |
| sexpr (self) | |
| eval (self, t, model_completion=False) | |
| evaluate (self, t, model_completion=False) | |
| __len__ (self) | |
| get_interp (self, decl) | |
| num_sorts (self) | |
| get_sort (self, idx) | |
| sorts (self) | |
| get_universe (self, s) | |
| __getitem__ (self, idx) | |
| decls (self) | |
| update_value (self, x, value) | |
| translate (self, target) | |
| project (self, vars, fml) | |
| project_with_witness (self, vars, fml) | |
| __copy__ (self) | |
| __deepcopy__ (self, memo={}) | |
| Public Member Functions inherited from Z3PPObject | |
| use_pp (self) | |
Data Fields | |
| model = m | |
| ctx = ctx | |
Additional Inherited Members | |
| Protected Member Functions inherited from Z3PPObject | |
| _repr_html_ (self) | |
Model/Solution of a satisfiability problem (aka system of constraints).
| __init__ | ( | self, | |
| m, | |||
| ctx ) |
Definition at line 6603 of file z3py.py.
| __del__ | ( | self | ) |
Definition at line 6609 of file z3py.py.
| __copy__ | ( | self | ) |
| __deepcopy__ | ( | self, | |
| memo = {} ) |
| __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 6821 of file z3py.py.
| __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 6677 of file z3py.py.
| __repr__ | ( | self | ) |
| 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 6868 of file z3py.py.
| 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 6620 of file z3py.py.
Referenced by evaluate().
| 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 6651 of file z3py.py.
| 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 6694 of file z3py.py.
Referenced by __getitem__(), and get_interp().
| 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 6761 of file z3py.py.
Referenced by sorts().
| 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 6801 of file z3py.py.
Referenced by __getitem__().
| 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 6746 of file z3py.py.
Referenced by get_sort(), and sorts().
| project | ( | self, | |
| vars, | |||
| fml ) |
Perform model-based projection on fml with respect to vars. Assume that the model satisfies fml. Then compute a projection fml_p, such that vars do not occur free in fml_p, fml_p is true in the model and fml_p => exists vars . fml
Definition at line 6917 of file z3py.py.
| project_with_witness | ( | self, | |
| vars, | |||
| fml ) |
Perform model-based projection, but also include realizer terms for the projected variables
Definition at line 6929 of file z3py.py.
| sexpr | ( | self | ) |
Return a textual representation of the s-expression representing the model.
Definition at line 6616 of file z3py.py.
| 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 6784 of file z3py.py.
| translate | ( | self, | |
| target ) |
Translate `self` to the context `target`. That is, return a copy of `self` in the context `target`.
Definition at line 6909 of file z3py.py.
Referenced by __copy__(), and __deepcopy__().
| update_value | ( | self, | |
| x, | |||
| value ) |
Update the interpretation of a constant
Definition at line 6887 of file z3py.py.
| ctx = ctx |
Definition at line 6606 of file z3py.py.
Referenced by __copy__(), __deepcopy__(), Statistics.__deepcopy__(), __del__(), Solver.__del__(), Statistics.__del__(), __getitem__(), Statistics.__getitem__(), __len__(), Statistics.__len__(), Statistics.__repr__(), Solver.assert_and_track(), Solver.assert_exprs(), Solver.check(), decls(), eval(), get_interp(), Statistics.get_key_value(), get_sort(), get_universe(), Statistics.keys(), Solver.model(), Solver.num_scopes(), num_sorts(), Solver.pop(), project(), project_with_witness(), Solver.push(), Solver.reset(), Solver.set(), sexpr(), and translate().
| model = m |
Definition at line 6605 of file z3py.py.
Referenced by __del__(), __getitem__(), __len__(), decls(), eval(), get_interp(), get_sort(), get_universe(), num_sorts(), project(), project_with_witness(), sexpr(), translate(), and update_value().