scallop-lang / scallop-lang.github.io

Official Website of Scallop Language
https://scallop-lang.github.io/
9 stars 7 forks source link

Incorrect computation on commit: `fdd07476` #18

Closed bertram-gil closed 2 years ago

bertram-gil commented 2 years ago

Hi guys,

Consider the following Scallop program:

rel c__ = { 
    ("ms", 49),
    ("bx", 74),
}

rel e__ = { 
    (3, 28, "hk"),
    (74, 16, "ux"),
    (41, 17, "wm"),
    (77, 31, "dp"),
}

rel h__ = {
    (20, "lv", "fq"),
    (69, "qj", "mk"),
    (32, "eo", "wm"),
    (43, "qg", "fi"),
}

rel e__(b, d, c) = c__(c, d), c__(c, b)
rel h__(d, e, e) = c__(e, b), c__(e, d), ~e__(d, d, e)

query h__

When I run this program with the latest Scallop commit (fdd074767ae909d695f558c9757e1ef05a987da6), I get:

$ ./scli program.scl
h__: {(20, "lv", "fq"), (32, "eo", "wm"), (43, "qg", "fi"), (69, "qj", "mk")}

If I now add a subgoal e__(d, b, e) in the rule for relation h__ to get the following new program:

rel c__ = { 
    ("ms", 49),
    ("bx", 74),
}

rel e__ = { 
    (3, 28, "hk"),
    (74, 16, "ux"),
    (41, 17, "wm"),
    (77, 31, "dp"),
}

rel h__ = {
    (20, "lv", "fq"),
    (69, "qj", "mk"),
    (32, "eo", "wm"),
    (43, "qg", "fi"),
}

rel e__(b, d, c) = c__(c, d), c__(c, b)
rel h__(d, e, e) = c__(e, b), c__(e, d), e__(d, b, e), ~e__(d, d, e)

query h__

Now if i run this program, I get:

$ ./scli program.scl
h__: {(20, "lv", "fq"), (32, "eo", "wm"), (43, "qg", "fi"), (49, "ms", "ms"), (69, "qj", "mk"), (74, "bx", "bx")}

I get 2 extra tuples: (49, "ms", "ms") and (74, "bx", "bx"). However, adding the subgoal e__(d, b, e) in the rule for h__ should not introduce extra entries in the result for relation h__.

Please let me know if you cannot reproduce this result or if I am doing something wrong.

My machine:

   Operating System: Debian GNU/Linux 10 (buster)  
   Kernel: Linux 5.4.188.1.amd64-smp
   Architecture: x86-64
Liby99 commented 2 years ago

Fixed in commit 07b7e13f897ac9036c526cbc6406b05c6799e786