3data Parity : Nat -> Type where
4 even : {n : Nat} -> Parity (n + n)
5 odd : {n : Nat} -> Parity (S (n + n))
7parity : (n:Nat) -> Parity n
9parity (S Z) = odd {n=Z}
10parity (S (S k)) with (parity k)
11 parity (S (S (j + j))) | (even {n = j}) ?= even {n=S j}
12 parity (S (S (S (j + j)))) | (odd {n = j}) ?= odd {n=S j}
14natToBin : Nat -> List Bool
16natToBin k with (parity k)
17 natToBin (j + j) | even {n = j} = False :: natToBin j
18 natToBin (S (j + j)) | odd {n = j} = True :: natToBin j
21main = do print (natToBin 42)
23---------- Proofs ----------
25Main.parity_lemma_2 = proof {
28 rewrite sym (plusSuccRightSucc j j);
32Main.parity_lemma_1 = proof {
35 rewrite sym (plusSuccRightSucc j j);
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list