CS 251 Assignment 1: Prolog I (Due September 29, 2008)

  1. Write a Prolog program that determines which students from a database of Prolog facts are classmates of each other.
Each student should be represented by one fact that captures all the information from the following records:
John joined the CS Department at UVM in 2000 and graduated in 2003. 
Mary joined the CS Department at UVM in 1994 and graduated in 2001. 
Peter joined the Business Department at UVM in 1999 and graduated in 2002.
If any two students were present at the same university in the same department for any period of time, they are considered classmates.

For example, your program should answer "yes" to the following query:

?- class_mates(john, mary).
Yes
And no to the following query:
?- class_mates(john, peter).
No
You should also be able to provide a rule called attended_during(S,Year), which indicates that a student S attended UVM during a particular Year. For example:
?- attended_during(S,2002).
Yes
S=john
S=peter
  1. Suppose L is a list of integer lists, write a set of clauses with head predicate double/2, which doubles the value of each element in L and place all doubled values into a single list X.
For example,
?- double([[1,3],[9,5],[7],[6,8,4]], X).
Yes
X=[2,6,18,10,14,12,16,8]

Questions provided by Nagi Basha.