Label each clause: fact, rule, or goal
Label each clause: fact, rule, or goal
Answer
parent(tom, bob). grandparent(X, Z) :- parent(X, Y), parent(Y, Z). ?- grandparent(tom, ann).
Line 1 is a FACT (head, no body — one positive literal). Line 2 is a RULE (one positive head `grandparent/2`, a body of subgoals). Line 3 is a GOAL / query (headless — the negated goal of resolution). The interpreter unifies `grandparent(tom, ann)` with the rule head, then solves the two `parent` subgoals left-to-right with backtracking.