Created
March 19, 2014 15:09
-
-
Save nvanderw/9643739 to your computer and use it in GitHub Desktop.
Proof that numbers go even-odd-even-odd...
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 DataKinds, KindSignatures, GADTs #-} | |
data Nat = Zero | Succ Nat | |
data Even :: Nat -> * where | |
Even_base :: Even Zero | |
Even_induct :: Even k -> Even (Succ (Succ k)) | |
data Odd :: Nat -> * where | |
Odd_base :: Odd (Succ Zero) | |
Odd_induct :: Odd k -> Odd (Succ (Succ k)) | |
-- Proof that numbers go even-odd-even-odd... | |
evenOdd :: Even n -> Odd (Succ n) | |
evenOdd Even_base = Odd_base | |
evenOdd (Even_induct k) = let ih = evenOdd k -- inductive hypothesis | |
in Odd_induct ih | |
oddEven :: Odd n -> Even (Succ n) | |
oddEven Odd_base = Even_induct Even_base | |
oddEven (Odd_induct k) = let ih = oddEven k | |
in Even_induct ih |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment