The Data.Logic.Propositional module provides a set of functions for parsing, manipulating and generating truth tables for expressions in classical propositional logic.
The core of the API is the
Expr data type, which has constructors for all
the usual expression forms: variables, standing for atomic propositions;
negation, the only unary connective; and the binary connectives of
conjunction, disjunction, material implication and logical equivalence.
- data Expr
- newtype Var = Var Char
- type Mapping = Map Var Bool
- equivalent :: Expr -> Expr -> Bool
- interpret :: Expr -> Mapping -> Bool
- assignments :: Expr -> [Mapping]
- values :: Expr -> [Bool]
- variables :: Expr -> [Var]
- isContingent :: Expr -> Bool
- isContradiction :: Expr -> Bool
- isTautology :: Expr -> Bool
- parseExpr :: SourceName -> String -> Either ParseError Expr
- show :: Show a => a -> String
- showAscii :: Expr -> String
- truthTable :: Expr -> String
- truthTableP :: Printer -> Expr -> String
|Conjunction Expr Expr|
|Disjunction Expr Expr|
|Conditional Expr Expr|
|Biconditional Expr Expr|
Determines whether two expressions are extensionally equivalent (that is, have the same values under all interpretations).
In order to interpret an expression, a mapping from variables to truth
values needs to be provided. Truth values are compositional; that's to say,
the value of a composite expression (any expression which is not atomic)
depends on the truth values of its component parts. For example, the Haskell
expression below would evaluate to
interpret (Conjunction (Variable "A") (Variable "B")) (fromList [("A", True), ("B", False)])
Generates the possible assignments of variables in an expression.
Lists the values of an expression under all interpretations (that is, all assignments of values to variables).
Determines whether an expression is contingent (that is, true in at least one interpretation and false in at least one interpretation).
parseExpr function accepts the name of a source, and a string to be
parsed, and attempts to parse the string as a logical expression of the
following forms, where
ψ are metalinguistic variables
standing for any valid expression.
"b"etc.; basically anything in the character class
"(φ & ψ)"
"(φ | ψ)"
"(φ -> ψ)"
"(φ <-> ψ)"
Top-level expressions where the primary connective is a binary one do not
need to be parenthesised. For example,
"p -> (q & r)" is a valid
"(p -> (q & r))" is also fine.
Represents expressions using only ASCII characters (the
pretty-prints expressions using logical symbols only present in extended
truthTable function produces a truth table for the given expression.