UCF

School of computer Science

COT 4020: Programming Languages

Spring 2007

Homework 3 (Prolog)

Due Wednesday 2007-04-11 by 11:59pm

Instructions

Exercise #1

Suppose we are given a knowledge base with the following facts:


translation(un,one).
translation(deux,two).
translation(trois,three).
translation(quatre,four).
translation(cinq,five).
translation(six,six).
translation(sept,seven).
translation(huit,eight).
translation(neuf,nine).
translation(dix, ten).



Write a predicate listE2F(English,French) which translates a list of English number words to the corresponding list of French number words. For example:
       
        listE2F(X,[un,neuf,deux]).

    should give:

        X = [one,nine,two].


    Your program should also work in the other direction. For example, if you give it the query

        listE2F([one,seven,six,two],X).

     it should return:

        X = [un,sept,six,deux].

Hint: to answer this question, first ask yourself `How do I translate the empty list of number words?'. That's the base case. For non-empty lists, first translate the head of the list, then use recursion to translate the tail.

Exercise #2 - Family Tree

Define predicates for “simple” family information.

All binary predicates of form predicate(A,B) in this exercise can be read as A is predicate of B, unless otherwise noted.
For this exercise you will be given a knowledge base containing info for three predicates:  parent/2, female/1, and male/1.

You need to define the following predicates that will work for any family knowledge base:
    • father/2
    • sister/2
    • niece/2
    • cousin/2                  
    • grandparent/2                 

Example knowledge base

parent(alice,betty).
parent(alice,bob).
parent(alice,ricky).
parent(rebecca,alice).
parent(castro,betty).
parent(castro,bob).
parent(castro,ricky).
parent(dana,castro).
parent(dana,vince).
parent(vince,erma).
male(ricky).
male(vince).
male(bob).
male(castro).
female(alice).
female(betty).
female(dana).
female(erma).
female(rebecca).

Note! If you are going to test with your own KB (which is recommended!), be sure to define the gender of each person. Also, be sure that no one is their own brother or sister.

Rubric

Out of 100 points:
Exercise #1 (25 points)
Exercise #2 (15 points each)

Note: These are very short problems, and there is not much room for partial credit. It is in your best interests to fully test your predicates before submission.

Submission guidelines

UPDATE (2007-04-02) Please do not include knowledge base predicates in your submissions.
In case of confusion I am available for clarifications. I will update the website in case of mass confusion and hysteria.
Include everything in one file named hw3-`first initial + lastname`.pl ... e.g., I would submit a file called hw3-cmillward.pl
Submit as an attachment via email to cmillward@cs.ucf.edu
Late submissions will not be accepted.
Plagiary and cheating will at the very least receive zeros.
Code that fails to compile will have heavy penalties.