Created
December 6, 2015 05:49
-
-
Save sivawashere/dabeff9fed2ac8b68cc2 to your computer and use it in GitHub Desktop.
Partially implements a natural deduction system in Haskell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE TypeOperators #-} | |
module NaturalDeduction where | |
data (⊥) -- no inhabitants | |
type (¬)p = p -> (⊥) | |
type (∧) = (,) | |
type (∨) = Either | |
type (→) = (->) | |
modusTollens :: (p → q) ∧ (¬)q → (¬)p | |
modusTollens (φ, ψ) = ψ . φ | |
true :: truth | |
true = true | |
exclMid :: p ∧ (¬)p | |
exclMid = true | |
type p ↔ q = (p → q) ∧ (q → p) | |
dblNeg :: p ↔ (¬)((¬) p) | |
dblNeg = (flip ($), true) | |
transposition :: (p → q) ↔ ((¬)q → (¬)p) | |
transposition = | |
(curry modusTollens, \c p -> -- c = contrapositive | |
undoDblNegate $ curry modusTollens c $ dblNegate p) | |
where (dblNegate, undoDblNegate) = dblNeg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment