Potential optimization: split the solver into two #2068
Replies: 3 comments 2 replies
|
Your hypothesis makes sense to me. In my experiments, with |
|
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? |
|
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 |
Uh oh!
There was an error while loading. Please reload this page.
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
Initencodes a single symbolic transition andNextencodes two symbolic transitionsAandB. Additionally, we are checking an invariantInv. This is how the model checker interacts with Z3:Init:Initto Z3.(check). If UNSAT, terminate.Invto Z3.(check). If SAT, terminate.ifor1 <= i <= length:A:(push).Ato Z3.(check). If SAT, save thatAis enabled. Otherwise, save thatAis disabled.Inv'to Z3 (if the invariants are checked before making a step).(check). If SAT, terminate.(pop).B:(push).Bto Z3.(check). If SAT, save thatBis enabled. Otherwise, save thatBis disabled.Inv'to Z3 (if the invariants are checked before making a step).(check). If SAT, terminate.(pop).AandBare disabled, terminate.Ato Z3, if it was enabled.Bto Z3, if it was enabled.AorB(modulo which ones were enabled).(push).Invto Z3.(check). If SAT, terminate.(pop).There are several observations to be made here:
InvorInv'), the search terminates. Hence, the invariant checks gravitate towards UNSAT (the last call may result in SAT, which would produce an error).AandBmay be enabled or disabled after makingisteps, 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:
pushandpop, so the solver can keep all the learned clauses.pushandpop. Potentially, the invariants disproven at previous steps may help the solver to prove UNSAT faster.All reactions