CMSC 308 Fall 2015
 10/29/2015 Logic Programming Due:  Thursday, November 5 12:30pm

### Assignment:    (15 points)

For this assignment you will be asked to write some Prolog clauses.

1)   Write the clauses for a relation called longerThan which is a relation between two lists of integers.  The relation holds for two lists if the first is longer than the second.   For instance, after loading the clauses you write, the following queries should produce the results listed.

longerThan([1,2,3], [5,6]).
Yes.
longerThan([1,2,3],[5,6,7,8]).
No.
longerThan([1,2,3],[5,6,7]).
No.

a)  Write clauses for longerThan  using a len predicate (like we did in class).
b)  Write clauses for longerThan  without calculating the length of each.

2) Write the clauses for a relation called  subset  which is a relation between two lists.  The relation holds for two lists if every item in the first list is contained in the second list.    Some sample queries:

subset([],[1,2,4,5]).
Yes.
subset([1,2],[1,2,3,4]).
Yes.
subset([1,5],[1,2,3,4]).
No.
subset([1,2],X).
X = [1,2]
subset(X,[1,3,45]).
X = [1]    note that X = [3], or X=[], or X = [45] would be valid as well.
subset([1,2], [1,3,4,5,2]).
Yes.
subset([1,2],[]).
No.

3)   Consider representing dates as a compound data object, with the month, date, and year, being the arguments.  For instance, this year’s commencement would be represented as:
date(october, 28, 1999)

Now consider the relation bday, which takes a person's name (in single quotes) and a date as arguments and is true if the date is that person’s birthdate.  eg:
bday('Ed Jones', date(april, 19, 1988)).
bday('Christine Warner', date(may, 26, 1985)).
bday('Terri Veenstra', date(march, 7, 1989)).
bday('Anne Glackin', date(november, 28, 1989)).
bday('Mike Vitale', date(august, 28, 1985)).
bday('Ed Smith', date(may, 19, 1990)).

The following should work on any database, not just the one given.

a)  Give a query (goal) which will give me the name of someone in the database with a birthday in May (or "no" if no such person exists).

b)  Create a predicate inmonth with two arguments:  the first argument is a month, and the second one is a list.  It is satisfied if everyone in the list was born in the month given.  Samples:

inmonth(november,['Anne Glackin']).
Yes.
inmonth(november, ['Anne Glackin', 'Terri Veenstra']).
No.
inmonth(november,[]).
Yes.
inmonth(may, ['Mike Vitale', 'Christine Warner']).
Yes.
inmonth(X, ['Mike Vitale', 'Christine Warner']).
X = may.
inmonth(X, ['Anne Glackin', 'Terri Veenstra']).
No.
inmonth(may, X).
?????  - this may give an empty list, or a list of people in that month, depending on how you write the database.

c)  Write  clauses for a predicate over30, which is a property of a person.    The predicate is true if the person is over 30 right now.  (The date you are doing the assignment.)  Examples with the above database:

over30(X).
X = '
Christine Warner'
over30('Mike Vitale').
Yes.
over30('Ed Smith').
No.

### Handin:

Handin method:  TBA