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

Negation of conjunction does not work #20

Open
cd2bcg16 opened this issue Jul 29, 2016 · 4 comments
Open

Negation of conjunction does not work #20

cd2bcg16 opened this issue Jul 29, 2016 · 4 comments

Comments

@cd2bcg16
Copy link

cd2bcg16 commented Jul 29, 2016

In 0.17.0 the negation of conjunction does not work. Query

(A==1) & (B==2) & ~((A==1) & (A==1))

should have no solution, however, pyDatalog finds solution [(1,2)].

I have tested negation of an equivalent non-compound term

(A==1) & (B==2) & ~((A==1))

and that indeed results in an empty set.

I have tested this in older releases and I got correct behaviour up to 0.14.6, but not since 0.15.0. I have just upgraded from 0.13 to 0.17 and found this issue.

@cd2bcg16 cd2bcg16 changed the title Negation of conjuction does not work Negation of conjunction does not work Jul 29, 2016
@bernhardwinkel
Copy link

I can confirm. Negations of conjunctions seem to always yield true. Any news concerning this issue?

@pcarbonn
Copy link
Owner

A workaround is to create a predicate for the clause to be negated :

One(A) <= (A==1) & (A==1)
(A==1) & (B==2) & ~(One(A))

yields the correct empty result.

@cd2bcg16
Copy link
Author

cd2bcg16 commented Sep 26, 2016

I agree Pierre, the workaround is obvious -- not using negated conjunction.
I have patched my pyDatalog and it seems to work. Can you please review and incorporate to the code stream?

--- a/pyDatalog/pyEngine.py
+++ b/pyDatalog/pyEngine.py
@@ -586,8 +586,6 @@ def insert(pred):
     return pred

 def remove(pred):
-    if pred.id in Logic.tl.logic.Pred_registry:
-        del Logic.tl.logic.Pred_registry[pred.id]
     if pred.id in Logic.tl.logic.Db:
         del Logic.tl.logic.Db[pred.id]
     return pred

@pcarbonn
Copy link
Owner

If I applied your patch correctly, it fixes this issue, but the regression tests fail (test.py fails in the reset function, line 6). Predicates cannot be correctly reset anymore.

Could you double-check ?

One approach would be to find out which commit introduced the regression, between 0.14.6, and 0.15.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants