3data Binary : Nat -> Set where
5 | bO : Binary n -> Binary (n + n)
6 | bI : Binary n -> Binary (S (n + n));
8instance Show (Binary n) where {
9 show (bO x) = show x ++ "0";
10 show (bI x) = show x ++ "1";
14data Parity : Nat -> Set where
16 | odd : Parity (S (n + n));
18parity : (n:Nat) -> Parity n;
20parity (S O) = odd {n=O};
21parity (S (S k)) with parity k {
22 parity (S (S (j + j))) | even ?= even {n=S j};
23 parity (S (S (S (j + j)))) | odd ?= odd {n=S j};
26natToBin : (n:Nat) -> Binary n;
28natToBin (S k) with parity k {
29 natToBin (S (j + j)) | even = bI (natToBin j);
30 natToBin (S (S (j + j))) | odd ?= bO (natToBin (S j));
35intToNat x = if (x>0) then (S (intToNat (x-1))) else O;
38main = do { putStr "Enter a number: ";
40 let n = prim__strToInt x;
41 let b = natToBin (fromInteger n);
44---------- Proofs ----------
46natToBin_lemma_1 = proof {
53parity_lemma_2 = proof {
60parity_lemma_1 = proof {
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