-
Notifications
You must be signed in to change notification settings - Fork 35
Add VC Substitution Simplification #249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rcosta358
wants to merge
22
commits into
main
Choose a base branch
from
vc-substitution
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
4091d36
Add SimplifiedExpression
rcosta358 cfa1be1
Change SimplifiedExpression to SimplifiedPredicate
rcosta358 abc5a02
Requested Changes
rcosta358 3c358a9
Formatting
rcosta358 8229c60
Minor Changes
rcosta358 a61f0f7
Add VC Substitution
rcosta358 176f337
Add Comments
rcosta358 03f1d88
SimplifiedPredicate Follow-Up
rcosta358 3fc150d
Add `simplifyOnce`
rcosta358 da87af9
Add Property Based Test using JUnit Quickcheck
rcosta358 39be6f6
Minor Changes
rcosta358 8adba68
Code Refactoring
rcosta358 d55680d
Add Comment
rcosta358 6e4e1cd
Code Refactoring
rcosta358 39e54c4
Add Fixed Point Iteration
rcosta358 92f3d12
Requested Changes
rcosta358 c42edc8
Rename
rcosta358 9c54833
Replace `SimplifiedPredicate` with `SimplifiedVCImplication`
rcosta358 e486e28
Fix
rcosta358 a487ea9
Refactoring
rcosta358 bd77390
Minor Change
rcosta358 07e0fa7
Add Tests
rcosta358 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
liquidjava-verifier/src/main/java/liquidjava/processor/SimplifiedVCImplication.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| package liquidjava.processor; | ||
|
|
||
| import java.util.Objects; | ||
|
|
||
| import liquidjava.rj_language.Predicate; | ||
|
|
||
| /** | ||
| * Represents a VC implication node whose refinement was simplified from another quantified VC shape. | ||
| */ | ||
| public class SimplifiedVCImplication extends VCImplication { | ||
|
|
||
| private final VCImplication origin; | ||
|
|
||
| public SimplifiedVCImplication(VCImplication implication, Predicate refinement, VCImplication origin) { | ||
| super(implication, refinement); | ||
| this.origin = origin.clone(); | ||
| } | ||
|
|
||
| @Override | ||
| public VCImplication getOrigin() { | ||
| return origin; | ||
| } | ||
|
|
||
| @Override | ||
| public VCImplication copyWithRefinement(Predicate refinement) { | ||
| return new SimplifiedVCImplication(this, refinement, origin); | ||
| } | ||
|
|
||
| @Override | ||
| public SimplifiedVCImplication clone() { | ||
| SimplifiedVCImplication vc = new SimplifiedVCImplication(this, this.refinement.clone(), origin); | ||
| if (this.next != null) | ||
| vc.next = this.next.clone(); | ||
| return vc; | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hash(super.hashCode(), origin); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object obj) { | ||
| if (this == obj) | ||
| return true; | ||
| if (!(obj instanceof SimplifiedVCImplication)) | ||
| return false; | ||
| if (!super.equals(obj)) | ||
| return false; | ||
| SimplifiedVCImplication other = (SimplifiedVCImplication) obj; | ||
| return origin.equals(other.origin); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 0 additions & 108 deletions
108
liquidjava-verifier/src/main/java/liquidjava/rj_language/SimplifiedPredicate.java
This file was deleted.
Oops, something went wrong.
42 changes: 42 additions & 0 deletions
42
liquidjava-verifier/src/main/java/liquidjava/rj_language/opt/VCSimplification.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| package liquidjava.rj_language.opt; | ||
|
|
||
| import liquidjava.processor.VCImplication; | ||
|
|
||
| /** | ||
| * Simplifies VCImplication chains by applying various simplification steps | ||
| */ | ||
| public class VCSimplification { | ||
|
|
||
| /** | ||
| * Applies all available simplification steps to a VC chain | ||
| */ | ||
| public static VCImplication simplifyToFixedPoint(VCImplication implication) { | ||
| if (implication == null) | ||
| return null; | ||
|
|
||
| // keep applying simplification steps until a fixed point is reached | ||
| VCImplication current = implication.clone(); | ||
| while (true) { | ||
| VCImplication simplified = simplifyOnce(current); | ||
| if (current.equals(simplified)) // fixed point reached | ||
| return simplified; | ||
| current = simplified; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Applies one simplification step to a VC chain | ||
| */ | ||
| public static VCImplication simplifyOnce(VCImplication implication) { | ||
| if (implication == null) | ||
| return null; | ||
|
|
||
| // first try to apply substitution, then folding | ||
| VCImplication substituted = VCSubstitution.apply(implication); | ||
| if (!implication.equals(substituted)) | ||
| return substituted; | ||
|
|
||
| // TODO: add more simplification steps here (e.g., folding) | ||
| return substituted; | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so dont all have binders? i think every VCImplication had a name and type, the question might be if they appear inside the refinement, but i didnt think this would be a possibility
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not all of them. We have this constructor
VCImplication(Predicate ref)which does not set thenameandtype. For example in∀x:int. x == 1 => x > 0the first vc has a binder but the second doesnt.