0% found this document useful (0 votes)
8 views1 page

HW 1

Uploaded by

Gezae Gebredingl
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views1 page

HW 1

Uploaded by

Gezae Gebredingl
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Homework 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 Prolog clauses to define the following relationships:


i s m o t h e r (X) /∗ X is a mother ∗/
i s f a t h e r (X) /∗ X is a f a t h e r ∗/
i s s o n (X) /∗ X ∗/
s i s t e r o f (X, Y) /∗ X is a s i s t e r o f Y ∗/
s i b l i n g s (X, Y) /∗ X is a s i b l i n g o f Y ∗/

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.

You might also like