HW 1
HW 1
1. Suppose someone has already written Prolog clauses that define the fol-
lowing family relationships:
f a t h e r (X, Y) /∗ X i s t h e f a t h e r o f Y ∗/
mother (X, Y) /∗ X i s t h e mother o f Y ∗/
male (X) /∗ X i s male ∗/
f e m a l e (X) /∗ X i s f e m a l e ∗/
p a r e n t (X, Y) /∗ X i s a p a r e n t o f Y ∗/
d i f f (X, Y) /∗ X and Y a r e d i f f e r e n t ∗/
Write a Prolog program that describes a family tree you know (e.g. your
own). Define rules for family relations. Ask questions about your family.
2. Here’s an anecdote attributed to Mark Twain:
“After long years as a bachelor I was tired of being alone and married a
widow with a grown daughter. My father fell in love with the daughter
and took her as his wife. This made me my own son-in-law and my
stepdaughter became my mother. After a year my wife gave birth to a
son. Now, my son was my father’s brother-in-law and at the same time
my uncle, since he was my stepmother’s brother. But my father’s wife also
gave birth to a son. So this was my brother and also my grandson, since
he was the son of my daughter. This meant I’d married my grandmother,
since she was the mother of my mother. As my wife’s husband, I was
also her grandson. And since the husband of a grandmother is always a
grandfather, I am my own grandfather.”
Use Prolog to verify its claim is possible.