3data Binary : Nat -> Type where
5 BO : Binary n -> Binary (n + n)
6 BI : Binary n -> Binary (S (n + n))
8implementation Show (Binary n) where
9 show (BO x) = show x ++ "0"
10 show (BI x) = show x ++ "1"
13data Parity : Nat -> Type where
15 Odd : Parity (S (n + n))
17parity : (n:Nat) -> Parity n
19parity (S Z) = Odd {n=Z}
20parity (S (S k)) with (parity k)
21 parity (S (S (j + j))) | Even ?= Even {n=S j}
22 parity (S (S (S (j + j)))) | Odd ?= Odd {n=S j}
24natToBin : (n:Nat) -> Binary n
26natToBin (S k) with (parity k)
27 natToBin (S (j + j)) | Even = BI (natToBin j)
28 natToBin (S (S (j + j))) | Odd ?= BO (natToBin (S j))
32intToNat x = if (x>0) then (S (intToNat (x-1))) else Z
35main = do putStr "Enter a number: "
37 printLn (natToBin (fromInteger (cast x)))
39---------- Proofs ----------
41Main.natToBin_lemma_1 = proof
43 rewrite plusSuccRightSucc j j
44 rewrite sym (plusSuccRightSucc j j)
50 rewrite sym (plusSuccRightSucc j j)
54parity_lemma_2 = proof {
57 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