Let's imagine a simple database of genealogy facts where mother(M, C)
and father(F, C)
denotes that M
/F
is the mother/father of child C
.
I've written a rule to find known parents of a child (zero, one or both):
parents(C, M, F) :-
(mother(M, C) -> true; true),
(father(M, C) -> true; true).
which binds M
and F
if they are known and leaves them unbound otherwise.
It works fine, which means that for a set of facts:
mother(m1, c1).
father(f1, c1).
mother(m2, c2).
a call to parents(c1, M, F)
returns:
M = m1,
F = f1.
while parents(c2, M, F)
returns:
M = m2.
but the use of the arrow operators seems a little strange to me. Am I missing something basic? Can the (X -> true ; true)
calls be avoided/simplified?
Any help appreciated.
Cheers,