Inheritance diagram for Solver:Public Member Functions | |
| def | __init__ |
| def | __del__ |
| def | set |
| def | push |
| def | pop |
| def | reset |
| def | assert_exprs |
| def | add |
| def | append |
| def | insert |
| def | assert_and_track |
| def | check |
| def | model |
| def | unsat_core |
| def | proof |
| def | assertions |
| def | statistics |
| def | reason_unknown |
| def | help |
| def | param_descrs |
| def | __repr__ |
| def | sexpr |
Public Member Functions inherited from Z3PPObject | |
| def | use_pp |
Data Fields | |
| ctx | |
| solver | |
Solver API provides methods for implementing the main SMT 2.0 commands: push, pop, check, get-model, etc.
| def __del__ | ( | self | ) |
| def __repr__ | ( | self | ) |
| def add | ( | self, | |
| args | |||
| ) |
| def append | ( | self, | |
| args | |||
| ) |
| def assert_and_track | ( | self, | |
| a, | |||
| p | |||
| ) |
Assert constraint `a` and track it in the unsat core using the Boolean constant `p`.
If `p` is a string, it will be automatically converted into a Boolean constant.
>>> x = Int('x')
>>> p3 = Bool('p3')
>>> s = Solver()
>>> s.set(unsat_core=True)
>>> s.assert_and_track(x > 0, 'p1')
>>> s.assert_and_track(x != 1, 'p2')
>>> s.assert_and_track(x < 0, p3)
>>> print s.check()
unsat
>>> print s.unsat_core()
[p3, p1]
Definition at line 5763 of file z3py.py.
| def assert_exprs | ( | self, | |
| args | |||
| ) |
Assert constraints into the solver.
>>> x = Int('x')
>>> s = Solver()
>>> s.assert_exprs(x > 0, x < 2)
>>> s
[x > 0, x < 2]
Definition at line 5711 of file z3py.py.
Referenced by Solver.add(), and Solver.append().
| def assertions | ( | self | ) |
| def check | ( | self, | |
| assumptions | |||
| ) |
Check whether the assertions in the given solver plus the optional assumptions are consistent or not.
>>> x = Int('x')
>>> s = Solver()
>>> s.check()
sat
>>> s.add(x > 0, x < 2)
>>> s.check()
sat
>>> s.model()
[x = 1]
>>> s.add(x < 1)
>>> s.check()
unsat
>>> s.reset()
>>> s.add(2**x == 4)
>>> s.check()
unknown
Definition at line 5786 of file z3py.py.
Referenced by Solver.model(), Solver.proof(), Solver.reason_unknown(), Solver.statistics(), and Solver.unsat_core().
| def help | ( | self | ) |
Display a string describing all available options.
Definition at line 5914 of file z3py.py.
Referenced by Solver.set().
| def insert | ( | self, | |
| args | |||
| ) |
| def model | ( | self | ) |
| def param_descrs | ( | self | ) |
| def pop | ( | self, | |
num = 1 |
|||
| ) |
| def proof | ( | self | ) |
| def push | ( | self | ) |
Create a backtracking point.
>>> x = Int('x')
>>> s = Solver()
>>> s.add(x > 0)
>>> s
[x > 0]
>>> s.push()
>>> s.add(x < 1)
>>> s
[x > 0, x < 1]
>>> s.check()
unsat
>>> s.pop()
>>> s.check()
sat
>>> s
[x > 0]
Definition at line 5653 of file z3py.py.
Referenced by Solver.reset().
| def reason_unknown | ( | self | ) |
| def reset | ( | self | ) |
| def set | ( | self, | |
| args, | |||
| keys | |||
| ) |
Set a configuration option. The method `help()` return a string containing all available options.
>>> s = Solver()
>>> # The option MBQI can be set using three different approaches.
>>> s.set(mbqi=True)
>>> s.set('MBQI', True)
>>> s.set(':mbqi', True)
| def sexpr | ( | self | ) |
Return a formatted string (in Lisp-like format) with all added constraints. We say the string is in s-expression format.
>>> x = Int('x')
>>> s = Solver()
>>> s.add(x > 0)
>>> s.add(x < 2)
>>> r = s.sexpr()
| def statistics | ( | self | ) |
| def unsat_core | ( | self | ) |
Return a subset (as an AST vector) of the assumptions provided to the last check().
These are the assumptions Z3 used in the unsatisfiability proof.
Assumptions are available in Z3. They are used to extract unsatisfiable cores.
They may be also used to "retract" assumptions. Note that, assumptions are not really
"soft constraints", but they can be used to implement them.
>>> p1, p2, p3 = Bools('p1 p2 p3')
>>> x, y = Ints('x y')
>>> s = Solver()
>>> s.add(Implies(p1, x > 0))
>>> s.add(Implies(p2, y > x))
>>> s.add(Implies(p2, y < 1))
>>> s.add(Implies(p3, y > -3))
>>> s.check(p1, p2, p3)
unsat
>>> core = s.unsat_core()
>>> len(core)
2
>>> p1 in core
True
>>> p2 in core
True
>>> p3 in core
False
>>> # "Retracting" p2
>>> s.check(p1, p3)
sat
Definition at line 5833 of file z3py.py.
| ctx |
Definition at line 5629 of file z3py.py.
Referenced by Probe.__eq__(), Probe.__ge__(), ApplyResult.__getitem__(), Probe.__gt__(), Probe.__le__(), Probe.__lt__(), Probe.__ne__(), Tactic.apply(), ApplyResult.as_expr(), Solver.assert_and_track(), Solver.assert_exprs(), Solver.assertions(), ApplyResult.convert_model(), Fixedpoint.get_assertions(), Fixedpoint.get_cover_delta(), Fixedpoint.get_rules(), Solver.model(), Solver.param_descrs(), Tactic.param_descrs(), Fixedpoint.parse_file(), Fixedpoint.parse_string(), Solver.proof(), Solver.set(), Tactic.solver(), Solver.statistics(), Fixedpoint.statistics(), and Solver.unsat_core().
| solver |
Definition at line 5630 of file z3py.py.
Referenced by Solver.__del__(), Solver.assert_and_track(), Solver.assert_exprs(), Solver.assertions(), Solver.check(), Solver.help(), Solver.model(), Solver.param_descrs(), Solver.pop(), Solver.proof(), Solver.push(), Solver.reason_unknown(), Solver.reset(), Solver.set(), Solver.sexpr(), Solver.statistics(), and Solver.unsat_core().
1.8.2