Skip to content

Commit

Permalink
Merge pull request #2178 from XiaowenHu96/eqrel_extend_fix
Browse files Browse the repository at this point in the history
Fix issue #2176
  • Loading branch information
Bernhard Scholz authored Jan 23, 2022
2 parents ea4ebd4 + 9bc5da0 commit 544dbcd
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 11 deletions.
6 changes: 4 additions & 2 deletions src/interpreter/Relation.h
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,10 @@ class EqrelRelation : public Relation<2, Eqrel> {

void extendAndInsert(const EqrelRelation& rel) {
auto src = static_cast<EqrelIndex*>(this->main);
auto trg = static_cast<EqrelIndex*>(rel.main);
src->extendAndInsert(trg);
for (auto& trgIndex : rel.indexes) {
auto trg = static_cast<EqrelIndex*>(trgIndex.get());
src->extendAndInsert(trg);
}
}
};

Expand Down
9 changes: 9 additions & 0 deletions tests/semantic/eqrel_tests3/c__.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
0 0
0 1
0 2
1 0
1 1
1 2
2 0
2 1
2 2
18 changes: 14 additions & 4 deletions tests/semantic/eqrel_tests3/eqrel_tests3.dl
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,26 @@
// - https://opensource.org/licenses/UPL
// - <souffle root>/licenses/SOUFFLE-UPL.txt

// Check that new knowledge generated by inserting into an eqrel is not lost.
// 1. Check that new knowledge generated by inserting into an eqrel is not lost.
// 2. Issue #2176

.decl notEqrel(x:number,y:number)
.decl isEqrel(x:number, y:number) eqrel
.decl a__(a:number, b:number)
.decl b__(a:number)
.decl c__(a:number, b:number)

.output c__, isEqrel, notEqrel // Output relation

notEqrel(x, y) :- isEqrel(x, y).
isEqrel(x, y) :- notEqrel(x, y).

isEqrel(0,1).

notEqrel(1,2).

.output isEqrel, notEqrel
a__(b, b) :- notEqrel(b, b).
a__(b, b) :- isEqrel(a, b), !isEqrel(a, b). // new rule

b__(b) :- isEqrel(b, a).

c__(a, c) :- a__(e, g), a__(a, e), b__(e), b__(c).
c__(b, b) :- b__(b).
6 changes: 6 additions & 0 deletions tests/semantic/eqrel_tests3/eqrel_tests3.err
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Warning: Variable a only occurs once in file eqrel_tests3.dl at line 26
b__(b) :- isEqrel(b, a).
---------------------^---
Warning: Variable g only occurs once in file eqrel_tests3.dl at line 28
c__(a, c) :- a__(e, g), a__(a, e), b__(e), b__(c).
--------------------^------------------------------
10 changes: 5 additions & 5 deletions tests/semantic/eqrel_tests3/isEqrel.csv
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
0 0
0 1
0 2
1 0
1 1
1 0
1 2
2 0
0 1
0 0
0 2
2 1
2 0
2 2

0 comments on commit 544dbcd

Please sign in to comment.