Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A formula "exists X (X = 1)" should be simplified to "#true" with the currently available simplifications, but using the simplify function this does not happen.
The problem is that the syntax tree is traversed once and the
substitute_defined_variables
simplification can only be applied when the root of the tree is reached. Therefore, the evaluate comparisons simplifications will not be applied as the root is not a comparison.Instead of using a fixpoint algorithm it is sufficient to first apply
substitute_defined_variables
to the whole syntax tree and then useapply_all
to apply all the other simplifications.Of course a fixpoint algorithm is still necessary for more complicated examples (e.g. "exists X (X = 1 or exists Y (Y = 1 and Y != 1))" should simplify to "#true" but with the proposed modification it only simplifies to "#exists X (X = 1)", to reach "#true" it would require a second application of the simplify algorithm). But maybe this could still be useful as an option that:
apply_all
,