~/ learn/ comp-456/ cards/ Horn clauses & the Prolog interpreter
1 of 4

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.

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/faafe441-119e-4090-b2f1-5bbf8fd128ff/flashcard utf-8 LF