How will prolog interpret this expression?
a(R) :- b(R,S), b(S,R).
Does this mean that a(R) will only return true if both b(R,S) and b(S,R) are true?
How will prolog interpret this expression?
a(R) :- b(R,S), b(S,R).
Does this mean that a(R) will only return true if both b(R,S) and b(S,R) are true?
a(R)will only return true if bothb(R,S)andb(S,R)are true?
Yes. The comma is a logical and. The rule:
a(R) :- b(R,S), b(S,R)
can thus be explained as:
"a(R) holds given there exists an S such that b(R, S) holds, and b(S, R) holds".
If for example you have a dataset like:
b(a, c).
b(a, d).
b(c, a).
b(b, c).
Then it will succeed for a(a), since b(a, c) holds and b(c, a). But it will not succeed for a(b), since b(b, c) holds, but not b(c, b).