Skip to content

Expression Oversimplification#179

Merged
rcosta358 merged 3 commits intomainfrom
expression-oversimplification
Mar 28, 2026
Merged

Expression Oversimplification#179
rcosta358 merged 3 commits intomainfrom
expression-oversimplification

Conversation

@rcosta358
Copy link
Copy Markdown
Collaborator

@rcosta358 rcosta358 commented Mar 17, 2026

Closes #163 and #164. Expressions were simplified to the fullest (e.g., true), which was not helpful to see in the error message, especially in the terminal version which does not allow for expansion.

To fix this, two changes were made:

  • Added a condition to stop and use the unsimplified expression If an expression is simplified to a boolean literal
  • Added unwrapDerivedLiterals that is called after the simplification is performed, to traverse the derivation tree and replace boolean literals with the expressions that produced them, but only when at least one operand in the derivation is non-boolean (otherwise the boolean literal is okay)

Examples

Before & After

x > 5 && x == 1010 > 5true
x > 5 && x == 1010 > 5

Before & After

x == y > 0 && y == 1x == 1 > 0x == true
x == y > 0 && y == 1x == 1 > 0

Before & After

...1 == 1 && 2 == 2true && truetrue
...1 == 1 && 2 == 2

@rcosta358 rcosta358 self-assigned this Mar 17, 2026
@rcosta358 rcosta358 added enhancement New feature or request simplification Related to the simplification of expressions labels Mar 17, 2026
@rcosta358 rcosta358 mentioned this pull request Mar 17, 2026
@rcosta358 rcosta358 marked this pull request as draft March 18, 2026 00:24
@rcosta358 rcosta358 marked this pull request as draft March 18, 2026 00:24
@rcosta358 rcosta358 marked this pull request as ready for review March 18, 2026 15:27
@rcosta358 rcosta358 linked an issue Mar 19, 2026 that may be closed by this pull request
Copy link
Copy Markdown
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.

lgtm

@rcosta358 rcosta358 merged commit 6963a61 into main Mar 28, 2026
1 check passed
@rcosta358 rcosta358 deleted the expression-oversimplification branch March 30, 2026 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request simplification Related to the simplification of expressions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Careful removing variables from simplification Don't oversimplify to true

2 participants