Skip to content

Top down query has incorrect/differing behavior #13

@ntbertram

Description

@ntbertram

Hi,

Thanks for this helpful library!
I seem to have found an instance where querying a top down database gives an incorrect answer.

Here's the program:

foo(a1, a3).
foo(a2, a3).
fooAlso(X, Y) :- foo(X, Y).
bar(a1, a2).
baz(a3, X) :- fooAlso(X, a3), fooAlso(Y, a3), bar(X, Y).
result(a3, X) :- fooAlso(X, a3), ~baz(a3, X).

Querying result(a3, X) returns [result(a3, a2); result(a3, a1)], however, result(a3, a1) should not be in query output. On the other hand, if you query instead result(a3, a1), the output is empty, which is the expected behavior.

Interestingly, if you replace fooAlso(Y, a3) with foo(Y, a3) in the baz clause, querying result(a3, X) returns the desired output [result(a3,a2)].

Here's a zip file of a dune project containing this example, if that's helpful.
bug.zip

Can you confirm this is a bug? Or maybe I'm not using this library properly?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions