So, I'm trying to understand how Datalog works, and one of the differences between it and Prolog is that it has stratification restrictions associated with negation and recursion. To quote Wikipedia:
If the predicate P is positively derived from the predicate Q (i.e., P is the head of the rule, and Q occurs positively in the body of the same rule), then the stratification number P must be greater than or equal to the stratification number Q
If the predicate P is derived from the negative predicate Q (i.e., P is the head of the rule, and Q occurs negatively in the body of the same rule), then the number of stratification P must be greater than the number of stratification Q,
So, moving on to this, the following two predicates do not lead to a stratification error, since they can simply be assigned the same stratification number. Thus, these predicates are good, despite the circular definition.
- A (x): - B (x)
- B (x): - A (x)
But compare this to what happens if we have a definition that has some kind of negation (Where ~ is negation)
- A (x): - ~ B (x)
- B (x): - ~ A (x)
. A (x, y) B (x, y), B (x, y) A (x, y). , , , , . ? . , -. , ?