Hacker News new | ask | show | jobs
by khaledh 520 days ago
I think the reason is that the right hand side can be a long and complex set of premises. It is supposed to be read as: The lhs is true iff everything on the rhs is true.

You can also think the same way about functions in typical languages: we don't write the body of the function first and then assign it to an identifier.

1 comments

Yes, but not `iff`.

  f(X) :- g(X), h(X).
  f(a).
With those two statements, `f(a)` is true, but it does not mean that `g(a)` and `h(a)` are also true. Instead, it means that we happen to know some fact, `f(a)`, and some rule for cases beyond that fact. If it also happened that `g(a)` and `h(a)` are true then we'd have two ways of arriving at the fact of `f(a)` being true.

It's a reverse of the implication arrow and is meant to be read that way:

  f(X) :- g(X), h(X).
Is read as "f(X) if g(X) and h(X)", versus "if g(X) and h(X) then f(X)".
Thanks for the correction :)