techniques.FOL
Class PLConverter

java.lang.Object
  |
  +--techniques.FOL.PLConverter

public class PLConverter
extends java.lang.Object

Contains static methods to convert first-order to propositional logic.


Method Summary
static Sentence CNFconvert(Sentence s)
          Converts a Sentence into a techniques.PL.Sentence.
static Sentence convert(Sentence input, java.util.Set universe)
          Converts a Sentence to the propositional subset of first-order logic, given a finite "universe" of Objects.
static void convertFile(java.lang.String inPath, java.lang.String outPath, java.util.Set universe)
          Given an input file in the FOL language, and a universe, writes an output file in the PL language.
static void test(java.lang.String s, java.util.Set universe)
           
static void verboseTest(java.lang.String s, java.util.Set universe)
          Prints out the results of conversion on a sentence.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

convert

public static Sentence convert(Sentence input,
                               java.util.Set universe)

Converts a Sentence to the propositional subset of first-order logic, given a finite "universe" of Objects. It does not mutate either the Sentence or the Universe. We encourage you to use Strings as the Objects in your universe, though it is not strictly necessary. We will be using the "unique names" hypothesis, and thus the objects in your universe should return distinct names via their toString() method. It is these names that will be used when translating the "Equals" relation between two terms. See the note on "Equals" below for more information about this.

This converter does not handle Functions, thus the only terms in your FOL setences should be constant terms and variables. In practice, the FOL parser parses all symbols as Variables, so if you create a sentence in some way other than using the parser, you should just use Variables for your ConstantTerms --- The converter treats all free variables (i.e. variables not introduced by a Quantifier) as constant terms.

The conversion process works as follows: The parse tree of the Sentence is traversed. Nodes which represent syntactic element that are legal in propositional logic are trivially translated (Negation, Connectives, and AtomicPropositions). Thus, AtomicPropositions in first-order logic are equivalent to the Variables of propositional logic.

The nodes that need explicit translation are Quantifiers and CompoundPropositions (relations). Quantifiers over variables are translated into Conjunctions and Disjunctions by replacing the variable of quantification with constant terms from the universe.

Quantified variables are typed. In an untyped system, quantified variables range over every element in the universe. In our system, quantified variables only range over elements in the universe with the same type. To keep a simple syntax, we will use the following convention to indicate types: A variable ranges over exactly those elements in the universe which share the same, case insensitive, letter as the variable. Thus, in "all t p(t)", the "t" will only be filled in with elements beginning with "t" or "T". If none of the elements in the universe share the same initial letter with a variable, it is assumed to range over all elements in the universe. A good convention would be to use capital letters for constant terms, and lowercase letters for variables.

CompoundPropositions/Relations are translated into AtomicPropositions by gathering up the terms of the relation into the name of the AtomicProposition. Thus, you should think of the atomic proposition "P_Object1_Object2" as holding only in (first-order) universes where P(Object1, Object2) holds.

The compound proposition "Equals" has special treatment, and rather than being converted into an AtomicProposition, it is converted into either the TrueProposition or the FalseProposition. This conversion is possible because all variable terms will be eliminated by the translation of Quantifiers. Thus, we only need to translate "Equals" between two constant terms. Constant terms, (either pure constant terms or variables bound to elements in the universe) are considered equal if their names are equal.


CNFconvert

public static Sentence CNFconvert(Sentence s)
Converts a Sentence into a techniques.PL.Sentence. The input sentence must not contain non-propositional subcomponents.

convertFile

public static void convertFile(java.lang.String inPath,
                               java.lang.String outPath,
                               java.util.Set universe)
Given an input file in the FOL language, and a universe, writes an output file in the PL language.

verboseTest

public static void verboseTest(java.lang.String s,
                               java.util.Set universe)
Prints out the results of conversion on a sentence. The sentence is passed in as a String. You are encouraged to use this method to play around with the conversion process and understand what it is doing.

test

public static void test(java.lang.String s,
                        java.util.Set universe)