scallop-lang / scallop-lang.github.io

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

Question about `@demand("bf")` #19

Open bertram-gil opened 2 years ago

bertram-gil commented 2 years ago

Hi, Consider the following program:

rel path(a, c) = edge(a, c) \/ path(a, b) /\ edge(b, c)
rel a__(a) = path(a, b), not path(a, b)
rel f__(c, e) = path(c, b), d__(c, e), a__(f)
query f__

The above program runs without any problems. But if I add @demand("bf") before path then i get:

@demand("bf")
rel path(a, c) = edge(a, c) \/ path(a, b) /\ edge(b, c)
rel a__(a) = path(a, b), not path(a, b)
rel f__(c, e) = path(c, b), d__(c, e), a__(f)
query f__
[Error] Cannot stratify program: negative cycle detected between predicate `a__` and `path`

But there is no negative path between a__ and path. Am I doing something wrong? Is this not a valid program if we enable magic transformation?

Liby99 commented 2 years ago

So on a syntax level there is a negative cycle, but I agree that Scallop could be smarter to detect that the demand on a__ should not be propagated into the demand for path. Let me debug this issue a little more and get back to you.