Built foundation for activation literal management in PDR - #52
Built foundation for activation literal management in PDR#52michael-zhang-lambda wants to merge 14 commits into
Conversation
…and added proxy variables to BMC
…ssumptions; made YICES2 skip some (get-unsat-assumptions) tests
…ivation literals from scope during cleanup
… literals for compound expressions in pdr
| fn name(&self) -> &str; | ||
| fn supports_check_assuming(&self) -> bool; | ||
| /// Indicates whether `(check-sat-assuming ...)` accepts arbitrary Boolean-valued expressions | ||
| fn supports_check_assuming_exprs(&self) -> bool { |
There was a problem hiding this comment.
Please don't define this here. I would rather have each implementation of the trait provide their own explicit definition.
There was a problem hiding this comment.
Understood. I'll make the change.
ekiwi
left a comment
There was a problem hiding this comment.
There is new code that is never used. It also looks like you removed some activation literal cleanups without replacement.
| } | ||
|
|
||
| /// Execute closure with a fresh [`ActLitScope`] and clean up all used activation literals in the end | ||
| fn with_act_scope<S: SolverContext, T>( |
There was a problem hiding this comment.
In the meantime, we don't have any activation literals that we want to permanently disable yet. This will be necessary once we get activation literals for compound formulas that we would only use once for a query (e.g. compound expressions in a relative inductiveness query).
Currently, all activation literals are coupled with formulas that are used throughout the program (such as the FROM_STEP bad states, TO_STEP constraints, and various stepped cube literals). To throw these away would mean wasting more solver time to redefine them when we need them. Therefore, their activation literals are permanently asserted in the solver and are cached to be used again as needed.
I can remove this helper function in this PR if you want to keep things clean for this PR.
|
|
||
| /// Create a temporary activation literal that is coupled with `body` (i.e. `act => body`) | ||
| /// and registered into `scope` | ||
| fn imply( |
There was a problem hiding this comment.
Currently, the only activation literals that we create should persist throughout the entire PDR run. imply is only used when we want an activation literal to be active for some scope (connecting back the the reason why we have no usages for with_act_scope).
In a sense, we can say that imply is always coupled with a call to with_act_scope. Thus, it is not used in the current PDR implementation.
|
|
||
| if check_res.0 && first_iter { | ||
| // Clean up activation literals | ||
| for &act in lit_map.keys() { |
There was a problem hiding this comment.
How does this cleanup happen now?
There was a problem hiding this comment.
Since the activation literals are associated with stepped literals (instead of compound formulas), they could be used in a different context. Therefore, to prevent redefinition of activation literals, step_lit_act will cache the activation literal for the particular stepped literal.
If we were to deactivate these activation literals here, we may get a solver error in the future since the cache will still return the cached activation literal (which was already deactivated).
There was a problem hiding this comment.
Even if these literals are removed from the cube, that does not necessarily mean that the literal does not exist elsewhere. For example, let's say that some literal was truly dropped in the fix_gen_cube subroutine. However, the same literal could exist in a CTI in block_cube. Just because we stopped using the literal in one instance doesn't mean it's useless in another! In this case, it would better to reuse the same activation literal, instead of creating a new one.
|
|
||
| // Permanently disable literals that were removed | ||
| for &act in &prev_acts { | ||
| if !lit_map.contains_key(&act) { |
There was a problem hiding this comment.
How does this cleanup happen now?
There was a problem hiding this comment.
Same reasoning as before.
| fin_lits.extend(lit_map.values().copied()); | ||
|
|
||
| // Clean up activation literals | ||
| for &act in lit_map.keys() { |
There was a problem hiding this comment.
Same reasoning as before.
| }; | ||
|
|
||
| // Disable all created activation literals as cleanup | ||
| for &act in lit_map.keys() { |
There was a problem hiding this comment.
Same reasoning as before.
| smt_ctx.restart()?; | ||
|
|
||
| // Clear the stepped literal cache | ||
| state.pool.step_lit_cache.clear(); |
There was a problem hiding this comment.
Why do you clear the cache here?
There was a problem hiding this comment.
Also, since you clear the cache, should you also disable the associated activation literals?
There was a problem hiding this comment.
This is a little bit of vestigial code from earlier. This code just wants to highlight that the cache for the pool is invalid (because the solver was previously cleared). Technically, this doesn't provide that much safety for the program because we still have stale solver formulas in the PdrEncodingWrapper, frame trace, etc. because the solver was restarted.
However, since PDR will subsequently call BMC and return, this is not an issue for now. I'm removing this to keep the code clean.
This PR is essentially #50, but all activation literal usage that was not present before (including in PDR and BMC) are removed.
Thus, YICES2 will run all tests without
(check-sat-assuming)and(get-unsat-assumptions).Changes
supports_check_assuming_exprsflag to mark solvers that can accept compound expression query assumptionscreate_act_litfromBasePdrActLitScopestruct that contains activation literals active in a given scope, which can then be permanently deactivated (i.e. assertreleasemethodActLitPoolstruct which provides helper methods to create activation literal implications (i.e.ActLitScope, with an additional cache and special helper method (step_lit_act) to reuse activation literals for stepped cube literals (which are valid throughout the whole PDR run)with_act_scopehelper function to execute a closure with an activation literal scope, automatically disabling the relevant activation literals (i.e. those that are not associated with stepped cube literals)