Open thpani opened 2 years ago
This is not a simple refactoring though; right now Z3SolverContext.sat()
doesn’t know what it’s checking. We’d need some outside dependency (probably the transition executor?) to track what assumptions to pass.
Seems to be an interesting idea. After having a quick look about it, I wonder if this would allow us to use specialized solvers, as described here.
This is not a simple refactoring though; right now Z3SolverContext.sat() doesn’t know what it’s checking. We’d need some outside dependency (probably the transition executor?) to track what assumptions to pass.
I do not think this is actually hard to implement. You could extend sat
with an optional list of predicates:
Then you could keep track of the predicates in a set of TransitionExecutorImpl
similar to:
When you find that a transition is enabled, add its predicate to the set.
I think it is worth time-capping this effort with 3 days. This may have a significant impact on the performance. Worth experimenting!
I'd be interested in working on this after the retreat!
I've gotten a preliminary version of this to work.
However, it is failing integration tests Bug1136
, TestSets
, and TestBagsExt
.
The fault is related to constant propagation into an exponentation operator reported here: https://github.com/Z3Prover/z3/issues/6499
Even if some integration tests are failing, we can do a few preliminary experiments to see, whether we get performance improvements, as we expected.
Capturing the current status; there are two potential encodings to explore:
Thus, the plan going forward is to experimentally evaluate option (1), then make further decisions on (2).
As the current evaluation of (1) in #2369 is a bit inconclusive, @konnov suggested to benchmark in offline mode instead.
That should give us a full assumption-based encoding for further benchmarking, without the implementation friction of figuring out how to handle caches.
Findings from the preliminary benchmarks (#2424):
As discussed synchronously, I will shelve this issue for now.
Seems expedient to revisit when we have more time to investigate, and the latest when Z3's incremental preprocessing is improved.
We currently encode transitions in SMT like this:
The double
pop
operation in the end will also pop the enabledness frame (and thus – afaict – any lemmas learned during that check). (Links on how popping affects learned lemmas: [1] [2])It seems that we could leverage assumptions to retain the lemmas learned during the enabledness check: Z3 allows passing assumptions to
(check-sat)
that can selectively enable parts of the formula. The problem above would then turn intoThat should retain the lemmas learned during the enabledness check in the solver.
Maybe we could even write out the whole BMC problem at once, and only selectively call
check-sat
on parts of the formula; this could help with repeated invariant checks.Subtasks (details https://github.com/informalsystems/apalache/issues/2137#issuecomment-1403599317):