### COSC-574: Automated Reasoning

Project 1
Fall 2017

First deliverable (p1a, 10%): F 9/22 @ 5 PM
Second deliverable (p1b, 10%): F 10/6 @ 5 PM
Final deliverable (p1c, 80%): Su 10/15 Su 10/22 @ 5 PM
20 points

For this project, you will implement a theorem prover for first-order logic using linear resolution.

For this and subsequent projects, you must implement your program using Java 8. Your code must be well-structured and well-organized and follow object-oriented design principles.

For this and subsequent projects, you must implement your program using the standard libraries the language provides. If you want to use external libraries or something non-standard, check with me first.

I have divided the project into three deliverables:

1. Write a program and the classes and methods necessary to read, parse, store, and output first-order well-formed formulas (wffs). Formulas must be stored internally as expression trees.

The following grammar specifies the syntax for wffs.

formula ::= '(' predicate-name argument-list ')'
| '(' 'not' formula ')'
| '(' 'or' formula formula ')'
| '(' 'and' formula formula ')'
| '(' 'cond' formula formula ')'
| '(' 'forall' variable formula ')'
| '(' 'exists' variable formula ')'

predicate-name ::= identifier

argument-list ::= argument arguments

arguments ::= argument arguments | ε

argument ::= function-or-constant-or-variable

function-or-constant-or-variable ::= function | constant | variable

function ::= '(' function-name argument-list ')'

function-name ::= identifier

identifier ::= letter letters-and-digits

constant ::= constant-letter letters-and-digits
| variable-letter letter letters-and-digits

constant-letter ::= 'a'..'t' | 'A'..'Z'

variable ::= variable-letter | variable-letter digits

variable-letter ::= 'u'..'z'

digits ::= digit digits | ε

letters-and-digits ::= letter-or-digit letters-and-digits | ε

letter-or-digit ::= letter | digit

letter ::= 'a'..'z' | 'A'..'Z'

digit ::= '0'..'9'


Examples of wffs written in this syntax are:

• Jack owns a dog
• $$\exists x \; \mbox{dog}(x)$$ & $$\mbox{owns}(\mbox{jack}, x)$$
• (exists x (and (dog x) (owns jack x)))
• All cats are animals
• $$\forall x \; \mbox{cat}(x) \rightarrow \mbox{animal}(x)$$
• (forall x (cond (cat x) (animal x)))
• No animal lover kills an animal
• $$\forall x \; \mbox{animalLover}(x) \rightarrow ( \forall y \; \mbox{animal}(y) \rightarrow \neg \mbox{kills}(x, y) )$$
• (forall x (cond (animallover x) (forall y (cond (animal y) (not (kills x y))))))

To support development, I have created files for two proofs that appear in Russell and Norvig, the proof that Curiosity did not kill the cat and the proof that Colonel West is a criminal. As you can see, comments begin with a forward slash, formulas begin with a left parenthesis, and both are confined to a single physical line. By convention, the last formula in the file is the conclusion.

In addition to the Curiosity and West proofs, you must find two additional proofs from reputable sources consisting of at least four formulas and three predicates. Naturally, I will test your program on my own set of proofs.

For the first deliverable, Main.main in Main.java should take a file name as a command-line argument. For each formula in the file, the program must parse it, store it as an expression tree, and print the string representation of the expression tree to the console.

You must implement the class Formula with the methods

public void set( String s );
public String toString();

In addition to calling Main.main, the autograder will call these two methods.

Include with your submission the two proof files and a transcript of your program's execution on the four files.

In a file named HONOR, include the following statement:

Name
NetID

In accordance with the class policies and Georgetown's Honor Code,
I certify that, with the exceptions of the class resources and those
items noted below, I have neither given nor received any assistance
on this project.

When you are ready to submit your program for grading, create a zip file named submit.zip containing your project's source files, proof files, transcript, and honor statement. Upload the zip file to Autolab using the assignment p1a.
2. Implement the routines to convert wffs to clausal form. For the second deliverable, you must produce a single executable that takes a file name as a command-line argument. For the formulas in the file, the program must read and store them, print them to the console, convert them to clausal form, store them as expression trees, and print them to the console. Include with your submission the proof files and a transcript of your program's execution on the four files.

You must implement

• public void Formula.cnf(), which converts a formula to conjunctive normal form
• public Clauses Formula.getClauses(), which converts a formula to clausal form and returns the resulting clauses
• public class Clauses, which simply extends ArrayList<Clause>
• public String Clause toString(), which returns the string representation of the clause

The prefix for Skolem constants must be sc. The prefix for Skolem functions must be sf.

When you are ready to submit your project for grading, put your source files, proof files, transcript, and honor statement in a zip file named submit.zip. Upload the zip file to Autolab using the assignment p1b.

3. Implement the routines to required to conduct resolution proofs using linear resolution.

For the final deliverable, you must produce a single executable that takes a file name as a command-line argument. The program should read the formulas in the file and conduct a proof using linear resolution. The program should print the formulas, the converted clauses, and a trace of the proof consisting of each clause Ci its resolvents from Δ and S. Finally, it should print a message indicating whether it was able to derive the conclusion from the premises.

You must also implement

• public void Clause.set( String ), which sets the Clause to the clause that the specified String represents.
• public Clauses Clauses.resolve( Clause clause ), which resolves all of the clauses in Clauses with the Clause clause and returns them.
• public static boolean LinearResolution.prove( String filename ), which returns true if the conclusion follows from the premises and returns false otherwise.

Include with your submission the proof files and a transcript of your program's execution on the four files.

When you are ready to submit your project for grading, put your source files, proof files, transcript, and honor statement in a zip file named submit.zip. Upload the zip file to Autolab using the assignment p1c.