Skip to content

Conversation

@rcosta358
Copy link
Collaborator

@rcosta358 rcosta358 commented Nov 21, 2025

This PR improves the simplification of the predicates.

  • The simplification is now applied until a fixed point is reached (no further simplifications are possible) while preserving previous simplifications
  • The variable resolver now only extracts variables used in the expression (excluding their own definitions)
  • The expression simplifier is now also able to collapse duplicate conjunctions into a single one (x && xx) as well as symmetrical ones (x == y && y == xx == y)
  • Simplify not only found but also expected predicate in refinement errors

Also added tests such as:

  • x == 1x == 1 (does not simplify)
  • x == 1 && x == 1x == 1 (collapse duplicate)
  • x == y && y == xx == y (collapse symmetrical)
  • x == 1 && y == 2x == 1 && y == 2 (does not simplify)
  • x == -y && y == a / b && a == 6 && b == 3x == -y && y == 2x == -2 (two simplifications until fixed point)

@rcosta358 rcosta358 self-assigned this Nov 21, 2025
@rcosta358 rcosta358 added the enhancement New feature or request label Nov 21, 2025
@rcosta358 rcosta358 requested a review from alcides November 21, 2025 16:15
@rcosta358
Copy link
Collaborator Author

The expression x == 1 && x == 1 should not simplify to true.

@rcosta358 rcosta358 marked this pull request as draft November 23, 2025 11:28
- Ignore unused variable equalities in VariableResolver, only extracts the variables actually used in the expression (excluding its own definitions)
- Improves ExpressionSimplifier by collapsing duplicate conjuctions (e.g. x && x => x)
@rcosta358 rcosta358 marked this pull request as ready for review November 23, 2025 14:03
Fixed by tracking previous origins in constant propagation
Variable nodes should have origin nodes so when expressions are simplified in multiple passes, previous simplifications are preserved
Copy link
Collaborator

@CatarinaGamboa CatarinaGamboa left a comment

Choose a reason for hiding this comment

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

Are we following any known algorithms for the constant propagation? We should compare with them in the writing

@rcosta358 rcosta358 merged commit 8685353 into main Dec 10, 2025
1 check passed
@rcosta358 rcosta358 deleted the simplification-fixes branch January 5, 2026 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants