Require variable declarations in DDlog?
In DDlog, as in Datalog, variable declarations are often implicit. Sometimes this can lead to pitfalls. For example, it has happened to me a couple of times that I deleted a body clause with one mention of a variable, leaving a reference in a second body clause and one in the head. I expected that I'd get a compiler error if there were other references, but of course I did not. (Now, of course, I'm more careful to look for this, but it was a easy newbie mistake.)
Maybe this is a better way to phrase it: a bare mention of a variable can be a declaration or a reference to a variable, with potentially different semantics. And it's kind of weird that, for example, this is valid:
X(a) :- Y(a), Y(a + 1).
but this is not:
X(a) :- Y(a + 1), Y(a).
The reason would be more obvious if variables had to be declared on first use, e.g.:
X(a) :- Y(var a), Y(a + 1).
or
X(a) :- Y(var a + 1), Y(a).
although I don't know whether it would be reasonable to accept the latter.