datalog

Björn Ebbinghaus 2021-03-23T13:46:11.007600Z

I have the following (working) predicate: It is true, if ?user and ?proposal don't have a common ?opinion or if they do, the ::value of said ?opinion is 0.

[(undecided? ?user ?proposal)
 (or-join [?user ?proposal]
   (not
     [?user ::user/opinions ?opinion]
     [?proposal ::proposal/opinions ?opinion])
   (and
     [?user ::user/opinions ?opinion]
     [?proposal ::proposal/opinions ?opinion]
     [?opinion ::value 0]))]
I suspect that I can improve it. I don't think I should have the clause [?user ::user/opinions ?opinion] twice, but I can't figure it out. Can anyone can tell me if my suspicion is right and how I can improve the predicate?