Parsing Symbolic Logic Formulas

Demonstrate object-oriented programing using a simple class hierarchy in Java.

The class library in the us.rader.tt.formula package supports parsing formulas of the monadic predicate calculus in an ASCII-keyboard friendly syntax and automatically outputting the LaTeX representation of the "proper" formula in Kalish-Montague syntax [3] along with its truth table.

For example,

(P -> (Q | R))


will produce the following LaTex formula:

\left( P \rightarrow \left( Q \vee R \right) \right)


which renders as:

The point of this example, however, is less about the substance of parsing and processing formulas of the monadic predicate calculus but, rather, how such formulas can be represented in Java as trees of object that exploit the core features of object-oriented programming: polymorphism, inheritance, encapsulation etc.

See us.rader.tt.formula.Expression and the classes which descend from it for details.