souffle icon indicating copy to clipboard operation
souffle copied to clipboard

Wrong result caused by "eqrel"

Open DerZc opened this issue 2 years ago • 4 comments

Hi,

I meet a problem that eqrel may cause empty result. Consider the following program:

.decl uvbh(A:unsigned)
.decl bctu(A:symbol)
.decl ygro(A:symbol)
.decl zzki(A:unsigned, B:unsigned) magic eqrel
.decl cxrz(A:unsigned, B:unsigned, C:unsigned, D:unsigned, E:unsigned, F:unsigned, G:unsigned) btree

uvbh(10).
uvbh(1).
uvbh(1).
bctu("g").
bctu("m").
bctu("d").
bctu("8").
bctu("m").
bctu("q").
bctu("v").
bctu("i").

ygro(A) :- bctu(A), uvbh(B).
zzki(B*11, B) :- ygro(A), uvbh(B).
cxrz(A, A, A, A, A, A, A) :- zzki(A, A).

.output zzki
.output cxrz

I run it with souffle -w sample.dl. The result of zzki is:

1       1
1       11
11      1
11      11
10      10
10      110
110     10
110     110

But the result of cxrz is empty. It shouldn't be empty. I use the last release version of Souffle.

DerZc avatar Oct 19 '22 15:10 DerZc

Hi,

I find a more simple test case:

.decl hvnh(A:float, B:number)
.decl mgds(A:symbol, B:unsigned)
.decl ehiz(A:unsigned, B:unsigned) magic eqrel
.decl bxax(A:symbol, B:symbol, C:unsigned) no_inline btree

hvnh(3.21, -2).
hvnh(1.26, -1).
hvnh(-5.433, 0).
mgds("b", 8).
mgds("j", 2).
mgds("S", 3).
mgds("p", 4).
mgds("z", 1).


ehiz(min(D,D)+4, D) :- hvnh(A, B), mgds(C, D).
bxax(A, A, B) :- ehiz(B, C), mgds(A, B).

.output ehiz
.output bxax

The output of ehiz is:

1       1
1       5
5       1
5       5
2       2
2       6
6       2
6       6
3       3
3       7
7       3
7       7
4       4
4       8
4       12
8       4
8       8
8       12
12      4
12      8
12      12

But the output of bxax is:

b       b       8

which is same with without eqrel

DerZc avatar Oct 20 '22 15:10 DerZc

Hi,

I reduce this program to a simplest one:

.decl a(b:symbol, c:unsigned)
.decl d(b:unsigned, c:unsigned) magic eqrel 
.decl bxax(b:symbol, c:symbol, e:unsigned) 

a("b", 8).
a("", 4).

d(f+4, f) :- a(e, f).
bxax(b, b, c) :- d(c, e), a(b, c).

.output bxax

The output of bxax is:

b       b       8

If remove the magic, the result of bxax will become:

b       b       8
""       ""       4

I think it is because magic and reqel are used together. And inline and reqel used together also can trigger this bug.

DerZc avatar Oct 21 '22 12:10 DerZc

May be same problem as described in #2302 ?

quentin avatar Oct 22 '22 09:10 quentin

May be same problem as described in #2302 ?

I tried #2302 and feel that maybe they are not the same issue.

In this issus, I print the d, although it has the correct result, but I tried with more facts and found that the result of bxax same with that of removing eqrel. I though maybe this means eqrel not work under magic and inline transformation.

But I add some meaningless rule for d, this will not modify the result of bxax. This is the difference.

DerZc avatar Oct 22 '22 09:10 DerZc