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
- type Mapping = Map String Bool
- equivalent :: Expr -> Expr -> Bool
- interpret :: Expr -> Mapping -> Bool
- assignments :: Expr -> [Mapping]
- 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 :: (Expr -> String) -> Expr -> String
- variables :: 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.
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.
"R"etc.; basically anything in the character class
"(φ & ψ)"
"(φ | ψ)"
"(φ -> ψ)"
"(φ <-> ψ)"
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.