This commit is contained in:
Michael Zhang 2021-10-06 13:37:19 -05:00
parent 8b1fbba12a
commit 87fafc7a15
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B
2 changed files with 18 additions and 18 deletions

View file

@ -94,16 +94,16 @@ postulate
open import Debug.Trace open import Debug.Trace
postulate postulate
makeProofEven : (n m : ) m * 2 n suc m ≤′ n makeProofEven : (n m : ) m * 2 n suc m ≤′ suc n
makeProofOdd : (n m : ) suc (m * 2) n suc m ≤′ n makeProofOdd : (n m : ) suc (m * 2) n suc m ≤′ suc n
to' : (n : ) Terminating n Bin to' : (n : ) Terminating n Bin
to' zero _ = O to' zero _ = O
to' n (box mWit) with parity? n to' (suc n) (box mWit) with parity? n
-- this means n is odd -- this means n is odd
... | m , isOdd p = (to' m (mWit (makeProofOdd n m p))) I ... | m , isOdd p = (to' m (mWit (makeProofOdd n m p))) II
-- this means n is even -- this means n is even
... | m , isEven p = (to' m (mWit (makeProofEven n m p))) II ... | m , isEven p = (to' m (mWit (makeProofEven n m p))) I
to : (n : ) Bin to : (n : ) Bin
to n = to' n (term n) to n = to' n (term n)

View file

@ -12,19 +12,19 @@ data Bin : Set where
_I : Bin Bin _I : Bin Bin
_II : Bin Bin _II : Bin Bin
data Bool : Set where data even : Set
true : Bool data odd : Set
false : Bool
T : Bool Set data even where
T true = zero : even zero
T false = suc : {n : } odd n even (suc n)
T→≡ : (b : Bool) T b b true data odd where
T→≡ true tt = refl suc : {n : } even n odd (suc n)
T→≡ false ()
data parity : Set Set where to : Bin
zero : parity zero to zero = O
oddSuc : {n : } parity n parity (evenSuc n) to n with odd n
evenSuc : {n : } parity n parity (oddSuc n) ... | x = O I
to n with even n
... | x = O II