-
|
I am implementing Datalog for a personal project right now. I have a naive inference engine working. I am starting to scale up my test sizes and came across a behavior in a test that I did not expect. I am double-checking my results for this program against Souffle and Souffle's answers have confused me further. This is broadly a question about the meaning of From what I understand, Using the following program, I get two different answers, depending on which .decl edge(x : number, y : number)
edge(1,2).
edge(2,3).
edge(3,4).
.decl path(x : number, y : number) eqrel
.decl path(x : number, y : number)
path(x,y) :- path(y,x). // Paths are undirected
path(x,y) :- edge(x,y). // A path is an edge
path(x,z) :- edge(x,y), path(y,z).
.output path(IO=stdout)When I do not have When I do have The difference between the two is the last |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
You can read more about It is an optimization in the sense that you don't have to write explicit reflexivity, symmetry and transitivity rules and it will perform better than if you had. In your exemple, Maybe you want to add a reflexivity rule and change To summarize: |
Beta Was this translation helpful? Give feedback.
You can read more about
eqrelin https://souffle-lang.github.io/relations#equivalence-relations and the paper https://souffle-lang.github.io/pdf/pact2019eqrel.pdfIt is an optimization in the sense that you don't have to write explicit reflexivity, symmetry and transitivity rules and it will perform better than if you had.
In your exemple,
pathhas a symmetry rule but no reflexivity or transitivity rule, so you cannot expect to get the same output wheneqreladd them for you.Maybe you want to add a reflexivity rule and change
path(x,z) :- edge(x,y), path(y,z).into a transitivity rule:path(x,z) :- path(x,y), path(y,z)., in that case you get the same result aseqrel.To summarize: