Copyright © 2023 Jiri Kriz,

1    Basics


1.1    Family Relations

1.1.1    Facts

Describe a real family as a list of facts of the following form:

father( f, c) /* f is father of child c */
mother( m, c) /* m is mother of child c */
man( m) /* m is man */
woman( w) /* w is woman */

1.1.2    Predicates

Define the following predicates:

parent( P, C) /* P is father or mother of C */
parents( F, M, C)  /* F is father, M is mother of C */
child( C, P) /* C is child of P */
son( S, P) /* S is son of P */
daughter( D, P) /* D is daughter of P */
grandfather( GP, GC) /* GV is grandfather of GC */
grandmother( GM, E /* GM is grandmother of E */
grandchild( GC, G) /* GC is grandchild of G */
brother( B, SB) /* B is brother of sibling SB */
sister( S, SB) /* S is sister of sibling SB */
uncle( U, N) /* U is uncle of N */
aunt( A, N) /* A is aunt of N */
woman( w) /* w is woman */

1.1.3    More Family Relations

Define further family relations (e.g. niece, cousin, spouse (!), ...) und test them.


The goal X \= Y with the predefined operator \= succeeds, if and only if X and Y are not equal (more precisely: if they do not unify).

Solution 1.1

1.2    A Simple Thought (Basic Inference)

People wish to live in piece. Men, women and children are people. I am a man (a woman). Therefore I wish to live in peace.

Use Prolog to prove this statement!

Solution 1.2

1.3    A Small World (Knowledge Representation)

A student's room

Fig. 1.1: A Student's Room

Represent this student's room such that the following queries are possible:

  1. Which furniture is in the room?
  2. How many doors, windows, tables, ... are in the room?
  3. Where is the table, the chair, ... ?
  4. What is to the left (right) of the table, ... (with respect to the center of the room)?
  5. What is at the wall 2, at the window 1, ... ?
  6. What is in the corner 1, ... ?


Start with the reprentation of the queries and adapt the reprentation of the room correspondigly. Aim at a concise program with few facts and many rules.

Solution 1.3