Potential optimization: split the solver into two #2068
Replies: 3 comments 2 replies
-
Your hypothesis makes sense to me. In my experiments, with |
Beta Was this translation helpful? Give feedback.
-
However, afaict, the suggested solution would mean pushing non-deterministic choice among enabled transitions into both solver instances, which might again slow them down both? |
Beta Was this translation helpful? Give feedback.
-
I agree with @thpani that the idea makes sense, but I think it is hard to say at this stage what the effect in solving time will be. Just to be sure I got it right, the proposed change will lock |
Beta Was this translation helpful? Give feedback.
-
The following discussions proposes a hypothesis about a potential source of slowdown in Apalache, which relates to how the model checker is interacting with Z3. This hypothesis may be completely wrong, but it should be relatively easy to conduct experiments and see, whether it is wrong or not.
Assume that
Init
encodes a single symbolic transition andNext
encodes two symbolic transitionsA
andB
. Additionally, we are checking an invariantInv
. This is how the model checker interacts with Z3:Init
:Init
to Z3.(check)
. If UNSAT, terminate.Inv
to Z3.(check)
. If SAT, terminate.i
for1 <= i <= length
:A
:(push)
.A
to Z3.(check)
. If SAT, save thatA
is enabled. Otherwise, save thatA
is disabled.Inv'
to Z3 (if the invariants are checked before making a step).(check)
. If SAT, terminate.(pop)
.B
:(push)
.B
to Z3.(check)
. If SAT, save thatB
is enabled. Otherwise, save thatB
is disabled.Inv'
to Z3 (if the invariants are checked before making a step).(check)
. If SAT, terminate.(pop)
.A
andB
are disabled, terminate.A
to Z3, if it was enabled.B
to Z3, if it was enabled.A
orB
(modulo which ones were enabled).(push)
.Inv
to Z3.(check)
. If SAT, terminate.(pop)
.There are several observations to be made here:
Inv
orInv'
), the search terminates. Hence, the invariant checks gravitate towards UNSAT (the last call may result in SAT, which would produce an error).A
andB
may be enabled or disabled after makingi
steps, in many practical benchmarks the actions are only disabled in a prefix and then all become enabled. Still, we are checking, whether they are enabled or not, as pruning disabled transitions significantly reduces the number of constraints. (We can disable this option with--discard-disabled=false
.) Hence, these calls gravitate towards SAT.What happens in the above interaction is that the solver is constantly switching between proving and disproving satisfiability of the context. This probably forces the solver to forget all clauses it has learned in the previous steps (how would we check that it is true?). If this is true, we are not using the incremental mode efficiently. This probably also explains the visible exponential slowdown as the number of steps increases.
If this is indeed true, we could try to help the solver to keep its learned context for SAT by using two solver instances:
push
andpop
, so the solver can keep all the learned clauses.push
andpop
. Potentially, the invariants disproven at previous steps may help the solver to prove UNSAT faster.Beta Was this translation helpful? Give feedback.
All reactions