Override default methods in BasicProverEnvironment for all delegates#685
Override default methods in BasicProverEnvironment for all delegates#685daniel-raffler wants to merge 16 commits into
default methods in BasicProverEnvironment for all delegates#685Conversation
… so that calls are always passed through
…a, don't add the result to the list of tracked formulas
baierd
left a comment
There was a problem hiding this comment.
Looks good besides the open points! Nice work!
Please open multiple smaller PRs next time instead of one giant one ;D
Did you test whether we handle push(BooleanFormula) correctly in all cases? (I saw that you added it to the trace test. Good!) The used delegate calls addConstraint(BooleanFormula) due to the default implementation, but is that addConstraint() call then tracked by the delegate layers?
Do we even need to add push(BooleanFormula) to the delegates? The default impl. uses two methods that are already part of the layers, and it is never overridden.
We should test most of our additional layers (logging/debugging etc.) from time to time! Would you be so kind and open issues (per delegate) to do this? Running CPAchecker with distinct analyses for each should be fine for now to get a sense of whether they work or collect problems.
| @Override | ||
| public @Nullable T push(BooleanFormula f) throws InterruptedException { | ||
| stats.push.getAndIncrement(); | ||
| stats.pop.getAndIncrement(); |
There was a problem hiding this comment.
I think this line should not be here.
There was a problem hiding this comment.
Nice catch! I've replaced it with
@Override
public @Nullable T push(BooleanFormula f) throws InterruptedException {
stats.push.getAndIncrement();
stats.constraint.getAndIncrement();
return delegate.push(f);
}which is what the default method would have produced
Should I get rid of the stats.constraint.getAndIncrement() entirely?
|
|
||
| @Override | ||
| public ImmutableMap<String, String> getStatistics() { | ||
| return ImmutableMap.of(); |
There was a problem hiding this comment.
Hmm.. I wasn't quite sure what to put there. In StatisticsSolverContext the getStatistics method includes the data that we're collecting. However, this won't work for StatisticsBasicProverEnvironment as we're not tracking statistics for each prover individually
I've now simply added a call to the delegate
There was a problem hiding this comment.
We can always just return the solvers statistics if it provides some.
But i agree that this is actually a interesting question. I'll take a closer look.
|
|
||
| @Override | ||
| public <T extends Formula> @Nullable T eval(T pFormula) { | ||
| throw new UnsupportedOperationException(UNSUPPORTED_OPERATION); |
There was a problem hiding this comment.
Why can't we synchronize evaluators with contexts?
I know that the old code also did not allow this, but why?
There was a problem hiding this comment.
I think it's just because FormulaManager.translate expects a boolean formula. We could allow eval for boolean formulas, but throwing an UnsupportedOperationException only for some inputs may be a bit confusing to the user
There was a problem hiding this comment.
I think the current message is confusing, as it actually says that only boolean formulas are allowed.
Would you be so kind and test boolean formulas only + add a small test for this? Essentially just try to eval a boolean and a non-boolean formula.
There was a problem hiding this comment.
I've implemented it for booleans now, see here
| logger.logDefDiscard( | ||
| logger.toVariable(this), "getModelAssignments()", delegate::getModelAssignments); | ||
| return FluentIterable.from(result) | ||
| // TODO Fix this in the Z3 model |
There was a problem hiding this comment.
Would you be so kind and open a issue for this?
There was a problem hiding this comment.
Good point.
If that's the case, we should remove the TODO. Could you double check with the commit that added the TODO whether we can be sure that it is related to the 2 fixes and remove the TODO if they are?
Thanks!
Sure, I'll try to keep the PRs smaller 😅. Most of the large changes are just copy and paste, but I can see how it's hard to review
The tracing delegate will just write There is an example of how the trace changed in one of the tests. Before adding the override we had: Now it's just:
I've open some issues here |
Hello,
this PR adds overrides for all
defaultmethods inBasicProverEnvironmentfor all of our delegates. This makes sure that the solver implementation is used when available, and that we don't fall back to the default implementation when using a delegate