CSE 4308/5360 - Assignments
Assignment 5 (Programming 3)

Due date: Monday, November 05, 2007, 11:59pm.

Summary

The main task in this programming assignment is to implement the resolution inference algorithm for propositional logic. You will implement a program that will take in as input two filenames: a filename where the knowledge base is stored, and a filename where some logical statement is stored. The program will create the conjunctive normal form for the combination of knowledge base and negated statement, and then the program will run the resolution algorithm to determine if the knowledge base entails the statement (i.e., if adding the negation of the statement to the knowledge base leads to a contradiction).

For CSE 5360 (or extra credit for CSE 4308), you should also implement a program that decides if the knowledge base is unsatisfiable, satisfiable, and/or valid, by generating and checking every row of the truth table (no other inference methods are accepted for this part).

Text File Format

The knowledge base will be stored as a file. This file will contain one or more lines, and each line will contain a logical statement. The knowledge base should be considered to be a CONJUNCTION of all those statements. The following syntax rules should be obeyed: The statement whose entailment we want to determine will also be stored as a text file. Files are stored in two different formats: prefix format (for which it is easier to write parsing code) and infix format (for which parsing code is harder to write). If your code works correctly with one format you get full credit. If your code works correctly with both formats you get extra credit. Example files can be found at these links:

Required Tasks

Task 1: 50 points

Assuming that you are using C++, and your executable is called "program", this is what the command line should look like for calling the program:
program [kb_filename] [statement_filename]
For example:
program kb1.txt statement3.txt
Your code does not have to work on both prefix and infix formats. Just choose one of the two formats (prefix is probably easier). Make sure you specify in your submission which format you chose. The program should print (in nicely formatted text that is easy to read)
  1. The CNF of the knowledge base.
  2. The CNF of the negation of the statement.
  3. The set of all new statements generated by the resolution algorithm (one line for each statement).
  4. The number of all new statements generated by the resolution algorithm.
  5. The final answer: STATEMENT ENTAILED if the knowledge base entails the sentence, STATEMENT NOT ENTAILED otherwise.

Task 2: 10 points (required for CSE 5360 only, extra credit for CSE4308)

For the CSE 5360 portion of the assignment, the program should be invoked as follows:
program [kb_filename]
For example:
program kb1.txt
The program should print out "UNSATISFIABLE" if the knowledge base is unsatisfiable, "VALID" if the knowledge base is valid, and "SATISFIABLE" otherwise.

Extra Credit Tasks

Task 3: 5 points

Modify the implementation of task 1 so that it checks for three cases (as opposed to the two cases in task 1), and gives the following output: STATEMENT ENTAILED if the knowledge base entails the sentence, NEGATION ENTAILED if the knowledge base entails the negation of the sentence, NEITHER STATEMENT NOR NEGATION ENTAILED otherwise.

Task 4: 10 points

Implement, clearly describe, and evaluate methods/tricks/heuristics that make the program run faster and generate fewer sentences in the course of the resolution algorithm, WITHOUT COMPROMISING EITHER THE SOUNDNESS OR THE COMPLETENESS OF THE ALGORITHM. Points will be awarded depending on the resulting efficiency, for a maximum of 10 points.

Task 5: 15 points

Make your code work with both infix and prefix formats. Your code would have to determine which format is being used, without the user specifying it from the command line.

Submissions

All submissions are via e-mail. E-mail your submission to BOTH the instructor and the TA.

Implementations in LISP, C, C++, and Java will be accepted. If you would like to use another language, please first check with the instructor via e-mail.

Submit a zipped directory (no other forms of compression accepted) via e-mail, with subject "CSE 4308/5360, assignment 5". THE ATTACHMENT SHOULD NOT EXCEED 800KB in size (e-mail the instructor if the 800KB limit is a concern). The directory should contain source code, and optionally, binaries that are appropriate for gamma or omega. The directory should also contain a file called readme.txt, which should specify precisely:

Insufficient or unclear instructions will be penalized by up to 20 points. Code that does not run on at least one of the gamma and omega machines gets zero points.

Some hints