Skip to content
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

Incorrect result with magic transform and eqrel #2190

Closed
bertram-gil opened this issue Feb 15, 2022 · 2 comments
Closed

Incorrect result with magic transform and eqrel #2190

bertram-gil opened this issue Feb 15, 2022 · 2 comments
Labels
bug - identified Bugs with an identified cause

Comments

@bertram-gil
Copy link

Hi guys,

Consider the following program:

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

notEqrel(x, y) :- isEqrel(x, y).
isEqrel(x, y) :- notEqrel(x, y).
isEqrel(0,1).
notEqrel(1,2).

.output a__
.output b__ // Output node

a__(a) :- notEqrel(a, a).
b__(c) :- !a__(b), a__(c), a__(b).
b__(a) :- a__(a).

Running the above program gives me the following for the relation b__:

$ souffle_59260/src/souffle -w --magic-transform=* prog.dl && cat b__.csv 
0
1
2

Now, adding notEqrel(a, b), notEqrel(c, a) in the rule for a__, should have no effect on a__ and also not on b__.
But if I now run the following new program, I get:

$ souffle_59260/src/souffle -w --magic-transform=* prog.dl && cat b__.csv 
1
2

FYI, running both programs without --magic-transform=* returns:

0
1
2

I am using the latest commit: 592605c

@bertram-gil
Copy link
Author

Hi guys, is this a confirmed bug or am i doing something wrong?

@b-scholz b-scholz added the bug - identified Bugs with an identified cause label Mar 7, 2022
@b-scholz
Copy link
Member

b-scholz commented Mar 7, 2022

When a magic-set transformation is applied to eqrel relations, they need to be expanded to their explicit form, i.e.,

.decl notEqrel(x:number,y:number)
.decl isEqrel(x:number, y:number) 

isEqrel(x,x) :- isEqrel(x,_).
isEqrel(x,y) :- isEqrel(y,x).
isEqrel(x,z) :- isEqrel(x,y), isEqrel(y,z).

.decl a__(a:number)
.decl b__(a:number)

notEqrel(x, y) :- isEqrel(x, y).
isEqrel(x, y) :- notEqrel(x, y).
isEqrel(0,1).
notEqrel(1,2).

.output a__
.output b__ // Output node

a__(a) :- notEqrel(a, a),notEqrel(a, b), notEqrel(c, a).
b__(c) :- !a__(b), a__(c), a__(b).
b__(a) :- a__(a).

Alternatively, the specialization of the magic-set transformation needs to stop for eqrel relations.

davidwzhao added a commit that referenced this issue Mar 30, 2022
@b-scholz b-scholz mentioned this issue Apr 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug - identified Bugs with an identified cause
Projects
None yet
Development

No branches or pull requests

2 participants