I am new to prolog, and I was trying to write rules for shortest path finding, I tried many times writing rules like path(X, Y) := ...
and they never work as intented, until I find these rules
(path[X,Y]==P) <= ((path[X,Z]==P2) & nextTo(Z,Y)
& (X!=Y) & (X._not_in(P2)) & (Y._not_in(P2))
& (P==P2+[Z]))
(path[X,Y]==P) <= nextTo(X,Y) & (P==[])
and it works like a charm. The tool is pydatalog.
The rules are very similar with what I have been trying (of course there are other mistakes in my code), but I was keep using round bracket path(X, Y) := ...
. I have never seen terms followed with square brackets like (path[X,Y]==P) <= ...
before, is path[X,Y]
a relation? a function? or a term? I googled but coundn't find satisfying answers.