Skip to content

Simplify Conjunctions#182

Open
rcosta358 wants to merge 1 commit intomainfrom
simplify-conjunctions
Open

Simplify Conjunctions#182
rcosta358 wants to merge 1 commit intomainfrom
simplify-conjunctions

Conversation

@rcosta358
Copy link
Collaborator

This PR adds a small simplification to avoid duplicate conjunctions in predicates, which made error messages redundant and harder to read.

To fix this, before creating a conjunction with two predicates, it recursively checks whether the second operand is already present in the first operand conjunctions. If so, the first one is returned.

Example

Before

#b_2 == #b_1 + 100 && #b_1 == b && b > 0 && b > 0 

After

#b_2 == #b_1 + 100 && #b_1 == b && b > 0

After with #181

#b_2 == b + 100 && b > 0

@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
}

private static boolean containsConjunct(Predicate c1, Predicate c2) {
if (c1.toString().equals(c2.toString()))
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Used string comparison instead of equals() to handle inconsistent GroupExpression wrapping.

}

@Override
public boolean equals(Object obj) {
Copy link
Collaborator Author

@rcosta358 rcosta358 Mar 17, 2026

Choose a reason for hiding this comment

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

Added missing equals() for predicates anyway.

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.

1 participant