This module comprises the abstract definition of two core concepts of propositional logic:
|data PropForm a|
A typical example of a propositional formula φ in standard mathematical notation is given by
¬(rain ∧ snow) ∧ (wet ↔ (rain ∨ snow)) ∧ (rain → hot) ∧ (snow → ¬ hot)
The primitive elements hot, rain, snow and wet are the atoms of φ. In Haskell, we define propositional formulas as members of the data type (PropForm a), where the type parameter a is the chosen atom type. A suitable choice for our example would be the atom type String and φ becomes a member of PropForm String type, namely
CJ [N (CJ [A "rain", A "snow"]), EJ [A "wet", DJ [A "rain", A "snow"]], SJ [A "rain", A "hot"], SJ [A "snow", N (A "hot")]]
This Haskell version is more tedious and we introduce a third notation for nicer output by making PropForm an instance of the Display type class. A call of display φ then returns
[-[rain * snow] * [wet <-> [rain + snow]] * [rain -> hot] * [snow -> -hot]]
The following overview compares the different representations:
Haskell displayed as kind of formula -------------------------------------------------------------------- A x x (without quotes) atomic formula F false the boolean zero value T true the boolean unit value N p -p negation CJ [p1,...,pN] [p1 * ... * pN] conjunction DJ [p1,...,pN] [p1 + ... + pN] disjunction SJ [p1,...,pN] [p1 -> ... -> pN] subjunction EJ [p1,...,pN] [p1 <-> ... <-> pN] equijunction
Note, that the negation is unary, as usual, but the last four constructors are all multiary junctions, i.e. the list [p1,...,pN] may have any number N of arguments, including N=0 and N=1.
PropForm a is an instance of Eq and Ord, two formulas can be compared for linear order with < or compare and PropForm a alltogther is linearly ordered, provided that a itself is. But note, that this order is a pure formal expression order does neither reflect the atomical quasi-order structure (induced by the subatomic relation; see below) nor the semantical quasi-order structure (induced by subvalent). So this is not the order that reflects the idea of propositional logic. But we do use it however for the sorting and order of formulas to reduce ambiguities and increase the efficiency of algorithmes on certain normal forms. In DefaultPropLogic we introduce the normal forms OrdPropForm and the normalizer ordPropForm.
PropForm a is also an instance of Read and Show, so String conversion (and displaying results in the interpreter) are well defined. For example
show (CJ [A 3, N (A 7), A 4]) == "CJ [A 3,N (A 7),A 4]"
Note, that reading a formula, e.g.
read "SJ [A 3, A 4, T]"
issues a complaint due to the ambiguity of the atom type. But that can be fixed, e.g. by stating the type explicitely, as in
(read "SJ [A 3, A 4, T]") :: PropForm Integer
|Parsing propositional formulas on string atoms|
|stringToProp :: String -> PropForm String|
|... CONTINUEHERE ....|
|class Ord a => PropAlg a p | p -> a where|
PropAlg a p is a structure, made of
a is the atom type
p is the type of propositions
There the set of ......................................................................
|Produced by Haddock version 2.4.2|