Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't dispatch SMT queries that can be proven False via simplification #683

Merged
merged 1 commit into from
Mar 17, 2025

Conversation

msooseth
Copy link
Collaborator

@msooseth msooseth commented Mar 13, 2025

Description

This fixes issues where we dispatched a query that was constant False after simplification.

Checklist

  • tested locally
  • added automated tests
  • updated the docs
  • updated the changelog

@msooseth msooseth marked this pull request as ready for review March 13, 2025 12:46
@msooseth msooseth force-pushed the dont-dispatch-false branch from 809704f to 72ee7dc Compare March 13, 2025 14:13
@msooseth msooseth changed the title Don't dispatch SMT queries that can be proven False via simp Don't dispatch SMT queries that can be proven False via simplification Mar 13, 2025
@msooseth msooseth requested a review from blishko March 13, 2025 14:16
Copy link
Collaborator

@blishko blishko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works, but I would suggest to spend some more time. I think the design could be improved.
What do I mean by that?
There are more places that call checkSat which might also benefit from this early check.
However, looking at them, there seems to be different strategies what they do with the propositions (and I admittedly do not understand everything that is going on there).
For example, in the function verify in SymExec, the queries are already being filtered for [PBool False] (see canBeSat).
On the other hand, function check in the same file does not seem to be doing anything in this regard.

It seems to me the code would benefit from some abstraction, for example a new function that would encompass both the transformation (assertProps) and dispatching to solver (checkSat). The check for False could be implemented inside this method. If all places that use checkSat now would be ported to use the new function, they would automatically benefit from this optimization.
However, that may require further thinking, as some of these places use cache or dispatch queries in parallel, and I don't know if the code could be easily changed there.

@msooseth
Copy link
Collaborator Author

Thanks! I actually agree with all what you said. Let me have another go at this, with a cleanup. I'll put this back into [DRAFT] and try to create such a helper function. It's a LOT of code repetition. It was a bad first attempt, sort of good for highlighting that it's messed up. I'll try doing it cleaner. Will be a bigger change but hopefully make the code a lot more readable and uniform.

@msooseth msooseth changed the title Don't dispatch SMT queries that can be proven False via simplification [DRAFT] Don't dispatch SMT queries that can be proven False via simplification -- TODO cleanup Mar 13, 2025
@msooseth msooseth force-pushed the dont-dispatch-false branch from 72ee7dc to dc0c2bf Compare March 17, 2025 14:01
@msooseth msooseth changed the title [DRAFT] Don't dispatch SMT queries that can be proven False via simplification -- TODO cleanup Don't dispatch SMT queries that can be proven False via simplification -- TODO cleanup Mar 17, 2025
@msooseth msooseth changed the title Don't dispatch SMT queries that can be proven False via simplification -- TODO cleanup Don't dispatch SMT queries that can be proven False via simplification Mar 17, 2025
Using a function specifically tailored to do this. Thanks to @blishko
for the help and idea!

Cleanup
@msooseth msooseth force-pushed the dont-dispatch-false branch from dc0c2bf to 7157051 Compare March 17, 2025 14:03
@msooseth
Copy link
Collaborator Author

@blishko I have now adjusted it to use a subfunction. You were 100% right, it's a lot cleaner. There's still one use of the plain checkSat function, the solution obtaining code. I plan on writing a solution minimization PR, as it's been asked for by multiple people. This PR is now a ton cleaner and is essentially standalone, which is how it's supposed to be, hopefully :)

Note that we now pass App into more places, which is great for the long run, too. I had to use this MonadUnliftIO thing to unlift the IO from the App and then push it back in, but I think it's actually super-clean and readable. Used only where necessary, and it's quite clean and tidy I think. The only other way is to read out the conf, then runEnv conf $ ... but I find that less clean and more prone to error.

Copy link
Collaborator

@blishko blishko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty nice!

@msooseth msooseth merged commit 6264499 into main Mar 17, 2025
9 checks passed
@msooseth msooseth deleted the dont-dispatch-false branch March 17, 2025 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants