!TITLE Prolog In Prolog !KEY This example shows how simple it is to write a Prolog interpreter in Prolog, and illustrates the use of a variable goal. In this mini-interpreter, goals and clauses are represented as ordinary Prolog data structures (i.e. terms). Terms representing clauses are specified using the unary predicate my_clause, e.g. my_clause( (grandparent(X,Z):-parent(X,Y),parent(Y,Z)) ). A unit clause will be represented by a term such as my_clause( (parent(john,mary) :- true) ). The mini-interpreter consists of four clauses: | execute(true) :-!. | execute((P,Q)) :- !, execute(P), execute(Q). | execute(P) :- my_clause((P:-Q)), execute(Q). | execute(P) :- P. The last clause enables the mini-interpreter to cope with calls to ordinary Prolog predicates, e.g. evaluable predicates.