Last active
July 10, 2022 02:24
-
-
Save ion1/058ee03fd82a7b453933 to your computer and use it in GitHub Desktop.
Exercise: prove Peirce’s law <=> law of excluded middle 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
-- Exercise: prove Peirce’s law <=> law of excluded middle in Haskell | |
{-# LANGUAGE Rank2Types #-} | |
import Data.Void | |
type Not a = a -> Void | |
type Peirce = forall a b. ((a -> b) -> a) -> a | |
type LEM = forall a. Either (Not a) a | |
callCC_lem :: Peirce -> LEM | |
callCC_lem callCC = _ | |
lem_callCC :: LEM -> Peirce | |
lem_callCC lem = _ | |
-- Bonus exercise: prove Peirce’s law <=> double negation elimination | |
type DNE = forall a. Not (Not a) -> a | |
callCC_dne :: Peirce -> DNE | |
callCC_dne callCC = _ | |
dne_callCC :: DNE -> Peirce | |
dne_callCC dne = _ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment