woman(queen_elizabeth_II).
mother(queen_elizabeth_II, prince_charles).
mother(queen_elizabeth_II, princess_anne).
mother(queen_elizabeth_II, prince_andrew).
mother(queen_elizabeth_II, prince_edward).
man(duke_philip).
father(duke_philip, prince_charles).
father(duke_philip, princess_anne).
father(duke_philip, prince_andrew).
father(duke_philip, prince_edward).
man(prince_charles).
father(prince_charles, prince_william).
father(prince_charles, prince_henry).
woman( princess_anne).
man( prince_andrew).
man( prince_edward).
woman(princess_diana).
mother(princess_diana, prince_william).
mother(princess_diana, prince_henry).
man(prince_william).
man(prince_henry).
parent( Father, Child) :- father( Father, Child).
parent( Mother, Child) :- mother( Mother, Child).
parents( Father, Mother, Child) :-
father( Father, Child), mother( Mother, Child).
child( Child, Parent) :- parent( Parent, Child).
son( S, P) :- child( S, P), man( S).
daughter( D, P) :- child( D, P), woman( D).
grandfather( GP, Grandchild) :-
parent( P, Grandchild), father( GP, P).
grandmother( GM, Grandchild) :-
parent( P, Grandchild), mother( GM, P).
grandchild( Grandchild, G) :-
parent( P, Grandchild), parent( G, P).
brother( Brother, Sibling) :-
parents( Father, Mother, Brother),
parents( Father, Mother, Sibling),
man( Brother), Brother \= Sibling.
sister( Sister, Sibling) :-
parents( Father, Mother, Sister),
parents( Father, Mother, Sibling),
woman( Sister), Sister \= Sibling.
uncle( U, N) :- parent( P, N), brother( U, P).
aunt( A, N) :- parent( P, N), sister( A, P).
Back to example 1.1
wish_to_live_in_peace( X) :- people( X).
people( X) :- man( X).
people( X) :- woman( X).
people( X) :- child( X).
man( 'I').
Back to example 1.2
furniture( wardrobe, 1).
furniture( bookshelf, 1).
furniture( bed, 1).
furniture( desk, 1).
furniture( chair, 1).
furniture( X) :- furniture( X, N).
number( X, N) :- furniture( X, N).
number( door, 1).
number( window, 2).
at( wall_1, wardrobe).
at( wall_1, door).
at( wall_2, bookshelf).
at( wall_2, bed).
at( wall_3, bed).
at( wall_3, window_1).
at( wall_3, desk).
at( wall_4, desk).
at( wall_4, window_2).
at( wall_4, wardrobe).
at( window_1, bed).
at( window_2, desk).
in( corner_1, wardrobe).
in( corner_3, bed).
in( corner_4, desk).
place( X, P) :- at( P, X).
place( X, P) :- in( P, X).
place( chair, at_desk).
left( door, bookshelf).
left( bookshelf, bed).
left( bed, desk).
left( desk, wardrobe).
left( wardrobe, door).
right( X, Y) :- left( Y, X).
Back to example 1.3