An ApplyResult object contains the subgoals produced by a tactic when applied to a goal. It also contains model and proof converters.
Definition at line 6318 of file z3py.py.
def __getitem__ |
( |
|
self, |
|
|
|
idx |
|
) |
| |
Return one of the subgoals stored in ApplyResult object `self`.
>>> a, b = Ints('a b')
>>> g = Goal()
>>> g.add(Or(a == 0, a == 1), Or(b == 0, b == 1), a > b)
>>> t = Tactic('split-clause')
>>> r = t(g)
>>> r[0]
[a == 0, Or(b == 0, b == 1), a > b]
>>> r[1]
[a == 1, Or(b == 0, b == 1), a > b]
Definition at line 6348 of file z3py.py.
6349 """Return one of the subgoals stored in ApplyResult object `self`.
6351 >>> a, b = Ints('a b')
6353 >>> g.add(Or(a == 0, a == 1), Or(b == 0, b == 1), a > b)
6354 >>> t = Tactic('split-clause')
6357 [a == 0, Or(b == 0, b == 1), a > b]
6359 [a == 1, Or(b == 0, b == 1), a > b]
6361 if idx >= len(self):
def __getitem__(self, idx)
Z3_goal Z3_API Z3_apply_result_get_subgoal(__in Z3_context c, __in Z3_apply_result r, __in unsigned i)
Return one of the subgoals in the Z3_apply_result object returned by Z3_tactic_apply.
Return the number of subgoals in `self`.
>>> a, b = Ints('a b')
>>> g = Goal()
>>> g.add(Or(a == 0, a == 1), Or(b == 0, b == 1), a > b)
>>> t = Tactic('split-clause')
>>> r = t(g)
>>> len(r)
2
>>> t = Then(Tactic('split-clause'), Tactic('split-clause'))
>>> len(t(g))
4
>>> t = Then(Tactic('split-clause'), Tactic('split-clause'), Tactic('propagate-values'))
>>> len(t(g))
1
Definition at line 6329 of file z3py.py.
6330 """Return the number of subgoals in `self`.
6332 >>> a, b = Ints('a b')
6334 >>> g.add(Or(a == 0, a == 1), Or(b == 0, b == 1), a > b)
6335 >>> t = Tactic('split-clause')
6339 >>> t = Then(Tactic('split-clause'), Tactic('split-clause'))
6342 >>> t = Then(Tactic('split-clause'), Tactic('split-clause'), Tactic('propagate-values'))
unsigned Z3_API Z3_apply_result_get_num_subgoals(__in Z3_context c, __in Z3_apply_result r)
Return the number of subgoals in the Z3_apply_result object returned by Z3_tactic_apply.
Return a Z3 expression consisting of all subgoals.
>>> x = Int('x')
>>> g = Goal()
>>> g.add(x > 1)
>>> g.add(Or(x == 2, x == 3))
>>> r = Tactic('simplify')(g)
>>> r
[[Not(x <= 1), Or(x == 2, x == 3)]]
>>> r.as_expr()
And(Not(x <= 1), Or(x == 2, x == 3))
>>> r = Tactic('split-clause')(g)
>>> r
[[x > 1, x == 2], [x > 1, x == 3]]
>>> r.as_expr()
Or(And(x > 1, x == 2), And(x > 1, x == 3))
Definition at line 6403 of file z3py.py.
6404 """Return a Z3 expression consisting of all subgoals.
6409 >>> g.add(Or(x == 2, x == 3))
6410 >>> r = Tactic('simplify')(g)
6412 [[Not(x <= 1), Or(x == 2, x == 3)]]
6414 And(Not(x <= 1), Or(x == 2, x == 3))
6415 >>> r = Tactic('split-clause')(g)
6417 [[x > 1, x == 2], [x > 1, x == 3]]
6419 Or(And(x > 1, x == 2), And(x > 1, x == 3))
6427 return Or([ self[i].
as_expr()
for i
in range(len(self)) ])
def convert_model |
( |
|
self, |
|
|
|
model, |
|
|
|
idx = 0 |
|
) |
| |
Convert a model for a subgoal into a model for the original goal.
>>> a, b = Ints('a b')
>>> g = Goal()
>>> g.add(Or(a == 0, a == 1), Or(b == 0, b == 1), a > b)
>>> t = Then(Tactic('split-clause'), Tactic('solve-eqs'))
>>> r = t(g)
>>> r[0]
[Or(b == 0, b == 1), Not(0 <= b)]
>>> r[1]
[Or(b == 0, b == 1), Not(1 <= b)]
>>> # Remark: the subgoal r[0] is unsatisfiable
>>> # Creating a solver for solving the second subgoal
>>> s = Solver()
>>> s.add(r[1])
>>> s.check()
sat
>>> s.model()
[b = 0]
>>> # Model s.model() does not assign a value to `a`
>>> # It is a model for subgoal `r[1]`, but not for goal `g`
>>> # The method convert_model creates a model for `g` from a model for `r[1]`.
>>> r.convert_model(s.model(), 1)
[b = 0, a = 1]
Definition at line 6372 of file z3py.py.
6373 """Convert a model for a subgoal into a model for the original goal.
6375 >>> a, b = Ints('a b')
6377 >>> g.add(Or(a == 0, a == 1), Or(b == 0, b == 1), a > b)
6378 >>> t = Then(Tactic('split-clause'), Tactic('solve-eqs'))
6381 [Or(b == 0, b == 1), Not(0 <= b)]
6383 [Or(b == 0, b == 1), Not(1 <= b)]
6384 >>> # Remark: the subgoal r[0] is unsatisfiable
6385 >>> # Creating a solver for solving the second subgoal
6392 >>> # Model s.model() does not assign a value to `a`
6393 >>> # It is a model for subgoal `r[1]`, but not for goal `g`
6394 >>> # The method convert_model creates a model for `g` from a model for `r[1]`.
6395 >>> r.convert_model(s.model(), 1)
6399 _z3_assert(idx < len(self),
"index out of bounds")
6400 _z3_assert(isinstance(model, ModelRef),
"Z3 Model expected")
Z3_model Z3_API Z3_apply_result_convert_model(__in Z3_context c, __in Z3_apply_result r, __in unsigned i, __in Z3_model m)
Convert a model for the subgoal Z3_apply_result_get_subgoal(c, r, i) into a model for the original go...