Mathematical Logic and Programming Languages Exercise #2

This is the second exercise. It is due before class on Monday October 6, 2014 (1:45 PM). You must submit your solution to D2L. It will not be graded, but it I will check that it is submitted and I will glance over it. Be prepared to discuss what you have done. We will spend considerable time discussing this in class on Monday. You may be called upon to elaborate your submission.

In this exercise you will implement an algorithm for simplifying propositional logic formulas represented by the Haskell datatype (Prop n). Import the file SimpleProp.hs to get these definitions.

The goal is to write a single function simplify:: Prop n -> Prop n which applies equivalences to its input to produce its output. The object is to return the smallest answer that is equivalent to the input. You are free to use any strategy you want. But it should always be the case that for all boolean assignments env: eval env x == eval env (simplify x).

I have suggested a few strategies you might try. I do not know the best way to do this, so I am interested in what students come up with.

• Write some equivalences as one level transformations, then apply them exhaustively in a top-down, bottom-up, or some other manner.

• Use some distributive or commutative laws to rearrange things so more equivalences become applicable.

• Apply subsumption rules. I.e. note that in a conjunction (/\ p1 p2 p3 p4) if (p1 -> p2) is a tautology, then one can remove p2 returning (/\ p1 p2 p4). In a similar manner in a disjunction (\/ p1 p2 p3 p4) if (p1 -> p2) is a tautology, them one can remove p1 returning (\/ p2 p3 p4).

• Use normal forms. Transform to a normal form, apply some simplifications, and then transform out of the normal form to the smallest equivalent formula.

Put all these functions into a file called Ex2.hs, test your functions using QuickCheck or SmallCheck and submit it to D2L.