Skip to content

Add VC Constraint Simplification - #264

Merged
rcosta358 merged 4 commits into
mainfrom
vc-constraint-elimination
Aug 14, 2026
Merged

Add VC Constraint Simplification#264
rcosta358 merged 4 commits into
mainfrom
vc-constraint-elimination

Conversation

@rcosta358

@rcosta358 rcosta358 commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Description

This PR adds VC simplification for redundant antecedent constraints in a VCImplication chain. For any two antecedents, excluding the conclusion, if one constraint implies another, the weaker constraint is redundant.
The weaker antecedent node is removed when its binder is not used by the remaining VC.

Examples

x:int. x > 1 =>
∀#fresh:boolean. x > 0 =>
∀#ret:int. #ret == x

is simplified tox:int. x > 1 =>
∀#ret:int. #ret == x
x:int. x >= 0 =>
∀#fresh_1:boolean. !(x < 1) =>
∀#fresh_2:boolean. !(x < 2) =>
∀#fresh_3:boolean. !(x < 3) =>
x == 4

is simplified (in two passes) tox:int. x >= 0 =>
∀#fresh_3:boolean. !(x < 3) =>
x == 4

Related Issue

None.

Type of change

  • Bug fix
  • New feature
  • Documentation update
  • Code refactoring

Checklist

  • Added/updated tests
  • ./mvnw -pl liquidjava-verifier test passes locally
  • Updated docs/README if behavior or API changed

@rcosta358 rcosta358 self-assigned this Jun 22, 2026
@rcosta358 rcosta358 added enhancement New feature or request simplification Related to the simplification of expressions labels Jun 22, 2026
@CatarinaGamboa

Copy link
Copy Markdown
Collaborator

Why substitute by "true"? I don't think this is a good idea cause true is usually "we don't know anything about this", so I would say either remove it completely or leave the "x > 0".
This might also bring a question of how we should present the path variables (freshed from ifs) cause this only makes sense because we know that that is true right? But how we write it seems it is just another variable

@rcosta358

Copy link
Copy Markdown
Collaborator Author

We substitute by true and then it is removed in the next pass by the binder simplification.
I see this as "this information is not needed" rather than "we don't know anything about this".

Removing it right away is possible, but it would basically repeat the same logic from the VCBinderSimplification. That's why I decided to leave that to that pass.

@CatarinaGamboa

Copy link
Copy Markdown
Collaborator

You have branch conflicts. I'm still not super sure about this simplification cause the intermediate step has a meaning right that os not really accurate. Couldnt we simply mark this for removal instead of overwriting the refinement so we still remove it next turn but don't make the substitution

@rcosta358
rcosta358 force-pushed the vc-constraint-elimination branch from 3e93fee to e8aa3d3 Compare August 13, 2026 23:17
@rcosta358

Copy link
Copy Markdown
Collaborator Author

Agreed. I changed it so we remove the binders immediately instead of replacing their refinements with true.

@CatarinaGamboa CatarinaGamboa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Discussed offline. This is great simplification, just add the example to reduce the freshes into just one

@rcosta358
rcosta358 merged commit 53867f2 into main Aug 14, 2026
1 check passed
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.

2 participants