Created
September 24, 2025 05:17
-
-
Save YuMingLiao/6908cd8a82f4456bd16a968dd65c353f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import Data.Nat | |
| data Parity : Nat -> Type where | |
| Even : Parity (n + n) | |
| Odd : Parity (S (n + n)) | |
| helpEven : (j : Nat) -> Parity (S j + S j) -> Parity (S (S (plus j j))) | |
| helpEven j p = rewrite plusSuccRightSucc j j in p | |
| helpOdd : (j : Nat) -> Parity (S (S (j + S j))) -> Parity (S (S (S (j + j)))) | |
| helpOdd j p = rewrite plusSuccRightSucc j j in p | |
| parity : (n:Nat) -> Parity n | |
| parity Z = Even {n=Z} | |
| parity (S Z) = Odd {n=Z} | |
| parity (S (S k)) with (parity k) | |
| parity (S (S (j + j))) | Even = helpEven j (Even {n = S j}) | |
| parity (S (S (S (j + j)))) | Odd = helpOdd j (Odd {n = S j}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment