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:
- prefix notation, knowledge-based files: prefix_kb1.txt, prefix_kb2.txt, and prefix_kb3.txt.
- prefix notation, statements whose entailment we want to determine:
prefix_statement1.txt,
prefix_statement2.txt, and prefix_statement3.txt.
- infix notation, knowledge-based files: kb1.txt, kb2.txt, and kb3.txt.
- infix notation, statements whose entailment we want to determine:
statement1.txt,
statement2.txt, and statement3.txt.
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)
- The CNF of the knowledge base.
- The CNF of the negation of the statement.
- The set of all new statements generated by the resolution
algorithm (one line for each statement).
- The number of all new statements generated by the resolution algorithm.
- 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:
- Where the code runs (i.e., on gamma or on omega).
- What programming language is used.
- How to run the code (including compilation instructions, if compilation
is needed and no appropriate binaries are included).
- What parts of the assignment were implemented
- (if task 4 was implemented) What methods were used to improve
efficiency, and what was the number of generated sentences in specific
test cases (including test cases made by you) with the original
implementation and with the improvements incorporated as part of task
4.
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
- Start immediately. No extensions will be given.
- How to submit homeworks using gzip and tar:
1. Log into omega or gamma.
2. Create a homework directory CSE4308HWNo. (replace the No. by the
homework number being submitted.)
3. Now use the following command to create a zip file.
1. tar -cvf CSE4308HWNo.tar CSE4308HWNo.
2. gzip CSE4308HWNo.tar.
-To list all the files in the archive CSE4308HWNo.tar you can use tar
-tvf CSE4308HWNo.tar.
-To list all the files in the gzip CSE4308HWNo.gz you can use gzip -l
CSE4308HWNo.tar.gz.
-To extract all the files in the archive CSE4308HWNo.tar you can use
tar -xvf CSE4308HWNo.tar.
-To dcompress CSE4308HWNo.tar.gz you can use gzip -d
CSE4308HWNo.tar.gz.