logic-classes-0.44: Data/Logic/Classes/Logic.hs
-- | Class Logic defines the basic boolean logic operations,
-- AND, OR, NOT, and so on. Definitions which pertain to both
-- propositional and first order logic are here.
module Data.Logic.Classes.Logic where
import Data.Logic.Classes.Negatable
-- |A type class for logical formulas. Minimal implementation:
-- @
-- (.|.), (.~.)
-- @
class (Negatable formula, Ord formula) => Logic formula where
-- | Disjunction/OR
(.|.) :: formula -> formula -> formula
-- | Derived formula combinators. These could (and should!) be
-- overridden with expressions native to the instance.
--
-- | Conjunction/AND
(.&.) :: formula -> formula -> formula
x .&. y = (.~.) ((.~.) x .|. (.~.) y)
-- | Formula combinators: Equivalence
(.<=>.) :: formula -> formula -> formula
x .<=>. y = (x .=>. y) .&. (y .=>. x)
-- | Implication
(.=>.) :: formula -> formula -> formula
x .=>. y = ((.~.) x .|. y)
-- | Reverse implication:
(.<=.) :: formula -> formula -> formula
x .<=. y = y .=>. x
-- | Exclusive or
(.<~>.) :: formula -> formula -> formula
x .<~>. y = ((.~.) x .&. y) .|. (x .&. (.~.) y)
-- | Nor
(.~|.) :: formula -> formula -> formula
x .~|. y = (.~.) (x .|. y)
-- | Nand
(.~&.) :: formula -> formula -> formula
x .~&. y = (.~.) (x .&. y)
infixl 2 .<=>. , .=>. , .<~>.
infixl 3 .&.
infixl 4 .|. -- a & b | c means a & (b | c), which in cnf would be [[a], [b, c]]