Repository navigation
Conversation
…and add some tests for them, as simplifiers can't be used with unsat-cores or assumption solving currently
daniel-raffler
left a comment
There was a problem hiding this comment.
There are a few TODOs about the unsat-core issue left in the code. Should we open a
Z3 issue for this?
Other than that, it looks fine to me
| @Option( | ||
| secure = true, | ||
| description = | ||
| "List of Z3 simplifiers that are applied, in the given order, as incremental" |
There was a problem hiding this comment.
What is the "incremental" referring to here? Do we need to set a specific solver mode for simplifieres to work?
| + " pre-processing to the assertions of each ProverEnvironment created by this" | ||
| + " context. This option has no effect on OptimizationProverEnvironments." | ||
| + " Unsat-core generation and solving with assumptions are not supported together" | ||
| + " with simplifiers due to issues." |
There was a problem hiding this comment.
Should we open a new Z3 issue for this?
There was a problem hiding this comment.
Name one of the 3 things ;D
Short answer: yes we need a issue for the unsat-core issue. The assumption solving issue is solved by updating Z3 (which i will do this week). I don't know whether optimization works or not, but i will only look into it if someone wants me to.
| + " with simplifiers due to issues." | ||
| + " Example: \"simplify, propagate-values, solve-eqs\". Available simplifiers" | ||
| + " can be found in the Z3 documentation online:" | ||
| + " https://microsoft.github.io/z3guide/docs/strategies/simplifiers/") |
There was a problem hiding this comment.
I couldn't find a list of simplifiers on the website. It just say that they can be listed by running (help-simplifier)
There was a problem hiding this comment.
Good point; either we support some API to get options and their values, or we need to add it here. I'll try adding it here and report back!
There was a problem hiding this comment.
I added all available simplifiers to the options text + what they do + a test that they do not go out of date.
| // TODO: unsat-cores with simplifiers fail with an exceptions. | ||
| // Tested in Z3 4.17.0-1009b13 and up to 5.4.1 |
There was a problem hiding this comment.
What's the exception here? Did you make sure it's not an issue on our side? IIRC we use the same API call for both unsat-core and unsat-assumptions, so I'm a little surprised only one of them isn't working
There was a problem hiding this comment.
They actually don't fail with exceptions, but with wrong results. I updated the TODO. I even know why and will report in the issue. This is not caused by us.
| // TODO: do we allow tactic options currently? | ||
| @SuppressWarnings("unused") | ||
| String getTacticOptions() { | ||
| long tactic = Native.mkTactic(creator.getEnv(), "simplify"); | ||
| Native.simplifierIncRef(creator.getEnv(), tactic); | ||
| String options = Native.tacticGetHelp(creator.getEnv(), tactic); | ||
| Native.simplifierDecRef(creator.getEnv(), tactic); | ||
| return options; | ||
| } | ||
|
|
||
| String getSimplifierOptions() { | ||
| long simplifier = Native.mkSimplifier(creator.getEnv(), "propagate-values"); | ||
| Native.simplifierIncRef(creator.getEnv(), simplifier); | ||
| String options = Native.simplifierGetHelp(creator.getEnv(), simplifier); | ||
| Native.simplifierDecRef(creator.getEnv(), simplifier); | ||
| return options; | ||
| } |
There was a problem hiding this comment.
There are a few unused functions down here. Can they be removed now, or do we still need them?
… not go out of date
This PR extends our Z3 wrapper with simplifiers. They are applied to all
ProverEnvironments created from a context with aConfigurationthat specified a list of simplifiers via a newly added option. I have not added simplifier support to optimization proving for now.Several tests were added as well. They showcase general workings, failures when configuring, and keep track of restrictions. Simplifiers can not be used with UNSAT-cores (neither in our version nor the current main branch of Z3), and also not with assumption solving, but this seems to be fixed in the current release.
(Simplifiers are a list instead of a set, as they may be applied multiple times and are applied in the order of the list.)