CSCI.4430/6430 Programming Languages Fall 2016
Programming Assignment #3

This assignment is to be done either individually or in pairs. Do not show your code to any other group and do not look at any other group's code. Do not put your code in a public directory or otherwise make it public. However, you may get help from the TAs or the instructor. You are encouraged to use the LMS Discussions page to post problems so that other students can also answer/see the answers.


Part 1: Office Riddle

In this programming assignment, you will solve the following riddle using logical programming.

The Facts

  1. There are 5 offices with five different comic book posters on the door.
  2. Each office is occupied by a student with a different major.
  3. These five students read a distinct book genre, eat a distinct type of pizza, and belong to a distinct club.
  4. No students belong to the same club, eat the same pizza type, or read the same book genre.

The Question

Who belongs to the Taekwondo club?

The Hints

Note for Prolog Programmers:

Your code should be placed in a file called riddle.pl. Your program should have a student predicate which when queried should give the major of the student who belongs to the Taekwondo club.

Sample Interactions

?- [riddle].
true.

?- student(Major).
Major = .

Notes for Oz Programmers:

You should remove any other Oz installations and use Oz 1.4.0 downloadable from http://sourceforge.net/projects/mozart-oz/files/v1/ and Emacs downloadable from http://gnu.mirror.vexxhost.com/emacs/, to enable the Oz programming interface to find the proper emacs running command such as runemacs.exe, you need to create an environment variable OZEMACS and set its value to for example F:\Programs\emacs-21.1\bin\runemacs.exe

Your final solution should have a one argument procedure called Riddle. When executing the following Oz code, your program should return the solution in the form of: The  < MAJOR >  student.

{Browse {SearchOne Riddle}}

See CTM Chapter 9 for relational programming techniques.
Your code should be placed in a file called riddle.oz


Part 2: Generate the Rules Dynamically

In this part, your program should be able to read a text file containing hints in Natural Language similar to the ones in part 1 (The Hints). Your program should then be able to generate rules dynamically by parsing the text file and solve the riddle like you did in part 1.
You should be able to query the riddle using Prolog/Mozart's shell.

Note that if you raise the query “student(Major)” before reading/parsing/asserting the hints, it should return multiple student majors.

Also, keep in mind that there is more than one way to word the same hint. For example, these two hints mean the same thing:

Make sure to include and document your grammar and to justify the choices you made in your ReadMe.

Note for Prolog Programmers: Your code should be placed in a file called riddlegenerator.pl

Your program should have a predicate called generateRiddle that will generate a riddle/rules everytime it's called based on the grammar you feed it in your program. 

The predicate's argument should represent the text file that contains hints. To assist you with this part, we have provided you with the read_line predicate, which can be found in read_line.pl. You should be able to modify it so that it reads the line from a file instead of IO.

Sample Interactions

?- [riddlegenerator].
?- generateRiddle("hints.txt").

?- student(Major).
Major = .

Notes for Oz Programmers:

You should remove any other Oz installations and use Oz 1.4.0 downloadable from http://sourceforge.net/projects/mozart-oz/files/v1/ and Emacs downloadable from http://gnu.mirror.vexxhost.com/emacs/, to enable the Oz programming interface to find the proper emacs running command such as runemacs.exe, you need to create an environment variable OZEMACS and set its value to for example F:\Programs\emacs-21.1\bin\runemacs.exe

Your final solution should have a procedure called GenerateRiddle that will generate a riddle/rules everytime it's called based on hints you feed it in your program.
Your code should be placed in a file called generateriddle.oz


Due date and submission guidelines


Due Date: Thursday, 12/01, 7:00PM

Grading: The assignment will be graded mostly on correctness, but code clarity / readability will also be a factor (make sure to comment your code!).

Submission Requirements: Please submit a ZIP file with your code, including a README file. README files must be in plain text; markdown is acceptable. Your ZIP file should be named with your LMS user name(s) and chosen language as the filename, either userid1_oz.zip (or userid1_pl.zip) or userid1_userid2_oz.zip (or userid1_userid2_pl.zip). Only submit one assignment per pair via LMS. In the README file, place the names of each group member (up to two). Your README file should also have a list of specific features / bugs in your solution.

Do not include unnecesary files. Test your archive after uploading it. Name your source files appropriately.