-
Notifications
You must be signed in to change notification settings - Fork 208
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
fix ungrounded error when destructuring with don't-cares #2483
Merged
Conversation
This file contains 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
Name unnamed variables that appear in record and branch inits before the resolution of aliases. fix 2482 After the `ResolveAliasesTransformer`, all occurences of `t` are replaced with `[ta,_]`, and the groundedness constraint system cannot give a bounded value to `[ta,_]` in the head (`var([ta,_])->0` in the `Solution`). ``` Clause: pred([ta,_],ta) :- fact([ta,_]). Problem: { var([ta,_]) ⇒ var(ta), var([ta,_]) ⇒ var(_), var(ta) ∧ var(_) ⇒ var([ta,_]), var([ta,_]) is true, var([ta,_]) ⇒ var(ta), var([ta,_]) ⇒ var(_), var(ta) ∧ var(_) ⇒ var([ta,_]) } Solution: {var(_)->1,var(_)->0,var([ta,_])->1,var([ta,_])->0,var(ta)->1} ``` When you provide an explicit variable for the second part of the record, the constraint system can be solved because the second member of the record has is bound by the variable (`var(_fix)->1` and `var([ta,_fix])->1`): ``` Clause: pred([ta,_fix],ta) :- fact([ta,_fix]). Problem: { var([ta,_fix]) ⇒ var(ta), var([ta,_fix]) ⇒ var(_fix), var(ta) ∧ var(_fix) ⇒ var([ta,_fix]), var([ta,_fix]) is true, var([ta,_fix]) ⇒ var(ta), var([ta,_fix]) ⇒ var(_fix), var(ta) ∧ var(_fix) ⇒ var([ta,_fix]) } Solution: {var([ta,_fix])->1,var([ta,_fix])->1,var(ta)->1,var(_fix)->1} ``` To fix this, we need to transform `_` into unique variables before the `ResolveAliasesTransformer`.
This change allows some form of match/case:
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2483 +/- ##
==========================================
+ Coverage 77.80% 77.83% +0.03%
==========================================
Files 492 492
Lines 33189 33205 +16
==========================================
+ Hits 25822 25846 +24
+ Misses 7367 7359 -8
|
julienhenry
approved these changes
Apr 4, 2024
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.
Thank you, this is useful.
quentin
added a commit
to quentin/souffle
that referenced
this pull request
Jun 3, 2024
…g#2483) fix ungrounded error when destructuring with don't-cares Name unnamed variables that appear in record and branch inits before the resolution of aliases. fix souffle-lang#2482 After the `ResolveAliasesTransformer`, all occurences of `t` are replaced with `[ta,_]`, and the groundedness constraint system cannot give a bounded value to `[ta,_]` in the head (`var([ta,_])->0` in the `Solution`). ``` Clause: pred([ta,_],ta) :- fact([ta,_]). Problem: { var([ta,_]) ⇒ var(ta), var([ta,_]) ⇒ var(_), var(ta) ∧ var(_) ⇒ var([ta,_]), var([ta,_]) is true, var([ta,_]) ⇒ var(ta), var([ta,_]) ⇒ var(_), var(ta) ∧ var(_) ⇒ var([ta,_]) } Solution: {var(_)->1,var(_)->0,var([ta,_])->1,var([ta,_])->0,var(ta)->1} ``` When you provide an explicit variable for the second part of the record, the constraint system can be solved because the second member of the record has is bound by the variable (`var(_fix)->1` and `var([ta,_fix])->1`): ``` Clause: pred([ta,_fix],ta) :- fact([ta,_fix]). Problem: { var([ta,_fix]) ⇒ var(ta), var([ta,_fix]) ⇒ var(_fix), var(ta) ∧ var(_fix) ⇒ var([ta,_fix]), var([ta,_fix]) is true, var([ta,_fix]) ⇒ var(ta), var([ta,_fix]) ⇒ var(_fix), var(ta) ∧ var(_fix) ⇒ var([ta,_fix]) } Solution: {var([ta,_fix])->1,var([ta,_fix])->1,var(ta)->1,var(_fix)->1} ``` To fix this, we need to transform `_` into unique variables before the `ResolveAliasesTransformer`.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Name unnamed variables that appear in record and branch inits before the resolution of aliases.
fix #2482
After the
ResolveAliasesTransformer
, all occurences oft
are replaced with[ta,_]
, and the groundedness constraint system cannot give a bounded value to[ta,_]
in the head (var([ta,_])->0
in theSolution
).When you provide an explicit variable for the second part of the record, the constraint system can be solved because the second member of the record has is bound by the variable (
var(_fix)->1
andvar([ta,_fix])->1
):To fix this, we need to transform
_
into unique variables before theResolveAliasesTransformer
.