parents(william, diana, charles). parents(henry, diana, charles). parents(charles, elizabeth, philip). parents(diana, frances, edward). parent(C,M) <= parents(C,M,D). parent(C,D) <= parents(C,M,D). grandparent(C,GP) <= parent(C,P) and parent(P,GP). ?grandparent(william, Who). {\fB Grand-Parent Relation. \fP}Note that a parent is either a mother or a father. This is expressed by two rules in Prolog. A mother is a parent and it is also true that a father is a parent.
The query `? grandparent(william, Who)' asks if william has a grand-parent and if so who? William has four grand-parents and the simple Prolog interpreter described later finds them all:
grandparen(william, frances) yes grandparen(william, edward) yes grandparen(william, elizabeth) yes grandparen(william, philip) yes --- Solutions to ? grandparent(william, Who). ---