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 eqrel? #2163

Closed
bertram-gil opened this issue Jan 2, 2022 · 5 comments
Closed

Incorrect result with eqrel? #2163

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

Comments

@bertram-gil
Copy link

Hi guys,
Consider the following program:

.decl two_set(x : number, y : number) eqrel
.decl union_two_set(x : number, y : number)
.decl unique2(x : number)
.decl equivalent(a: number, b: number) eqrel
.decl out(a: number)
.decl A(a:number, b:number) 
.output A 

two_set(1, 2).
two_set(3, 1).
two_set(6, 10).
unique2(1).
equivalent(1, 2).
equivalent(1, 3).

union_two_set(x, y) :- two_set(x, x), two_set(y, y).
out(x) :- equivalent(x, 1).

A(j, j) :- union_two_set(j, g), unique2(a),  equivalent(a, h).

Running the above program with Souffle gives me the following values for A:

1	1
2	2
3	3
6	6
10	10

If I add a new rule A(a, a) :- out(a), !out(a). to get the following program:

.decl two_set(x : number, y : number) eqrel
.decl union_two_set(x : number, y : number)
.decl unique2(x : number)
.decl equivalent(a: number, b: number) eqrel
.decl out(a: number)
.decl A(a:number, b:number) 
.output A 

two_set(1, 2).
two_set(3, 1).
two_set(6, 10).
unique2(1).
equivalent(1, 2).
equivalent(1, 3).

union_two_set(x, y) :- two_set(x, x), two_set(y, y).
out(x) :- equivalent(x, 1).

A(j, j) :- union_two_set(j, g), unique2(a),  equivalent(a, h).
A(a, a) :- out(a), !out(a).

Running the above program returns an empty result for A. But the result should not change.

Souffle version I am using: 235a3bc

@b-scholz
Copy link
Member

b-scholz commented Jan 3, 2022

With the latest performance changes of eqrel, we destroyed the iterators. A smaller example is the following:

.decl E(a:number, b:number) eqrel
E(1,2).
E(1,3).
 
.decl A()
A() :-
     E(1,_).
 
.decl B()
B() :-
  E(_,1).
.output  A,B

Both nullaries should contain the empty tuple. However, only the nullary B contains the empty tuple but not the nullary A.

@b-scholz
Copy link
Member

b-scholz commented Jan 3, 2022

Can you check whether the latest release has the same issue?

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

b-scholz commented Jan 3, 2022

The problem is the execution of two subsequent existence checks on an equivalence relation, i.e.,

QUERY
    IF ((ISEMPTY(+disconnected1) AND (NOT ISEMPTY(E))) AND (NUMBER(1),UNDEF) IN E)
     INSERT () INTO +disconnected1
   END QUERY

@b-scholz
Copy link
Member

b-scholz commented Jan 3, 2022

This is only an issue in the interpreter - not in the compiler - right?

@b-scholz
Copy link
Member

b-scholz commented Jan 3, 2022

After further analysis, it seems to be an interpreter issue that undefined values for equivalence relations cause problems and this needs to be fixed in the Generator.

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