-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix ungrounded error when destructuring with don't-cares (#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 #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`.
- Loading branch information
Showing
8 changed files
with
64 additions
and
2 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
$Some(abc, xyz) some | ||
$None none |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
.type Rec = [a: symbol, b: symbol] | ||
.type Adt = Some{a:symbol, b:symbol} | None{} | ||
|
||
.decl fact_rec(t:Rec) | ||
fact_rec(["abc", "xyz"]). | ||
|
||
.decl pred_rec(t:Rec, ta:symbol) | ||
pred_rec(t, ta) :- | ||
fact_rec(t), | ||
t=[ta, _]. | ||
|
||
.decl fact_adt(t:Adt) | ||
fact_adt($Some("abc", "xyz")). | ||
fact_adt($None()). | ||
|
||
.decl pred_adt(t:Adt, ta:symbol) | ||
pred_adt(t, ta) :- | ||
fact_adt(t), | ||
t = $Some(ta, _). | ||
|
||
.decl case_adt(t:Adt, case:symbol) | ||
case_adt(t, case) :- | ||
fact_adt(t), | ||
( t = $Some(_,_), case = "some" | ||
; t = $None(), case= "none" | ||
). | ||
|
||
.output pred_rec() | ||
.output pred_adt() | ||
.output case_adt() |
Empty file.
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
$Some(abc, xyz) abc |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[abc, xyz] abc |