annotate agda/halt.agda @ 175:bf50676c77af

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 14 Mar 2021 19:18:51 +0900
parents 0e87089e5de4
children 728cd6f7bf56
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
141
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 module halt where
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 open import Level renaming ( zero to Zero ; suc to Suc )
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 open import Data.Nat
142
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
5 open import Data.Maybe
141
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 open import Data.List hiding ([_])
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 open import Data.Nat.Properties
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 open import Relation.Nullary
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 open import Data.Empty
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 open import Data.Unit
142
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
11 open import Relation.Binary.Core hiding (_⇔_)
141
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 open import Relation.Binary.Definitions
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 open import Relation.Binary.PropositionalEquality
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 open import logic
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 record Bijection {n m : Level} (R : Set n) (S : Set m) : Set (n Level.⊔ m) where
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 field
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 fun← : S → R
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 fun→ : R → S
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 fiso← : (x : R) → fun← ( fun→ x ) ≡ x
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 fiso→ : (x : S ) → fun→ ( fun← x ) ≡ x
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23
164
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
24 injection : {n m : Level} (R : Set n) (S : Set m) (f : R → S ) → Set (n Level.⊔ m)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
25 injection R S f = (x y : R) → f x ≡ f y → x ≡ y
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
26
141
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 open Bijection
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
28
164
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
29 b→injection0 : {n m : Level} (R : Set n) (S : Set m) → (b : Bijection R S) → injection R S (fun→ b)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
30 b→injection0 R S b x y eq = begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
31 x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
32 ≡⟨ sym ( fiso← b x ) ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
33 fun← b ( fun→ b x )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
34 ≡⟨ cong (λ k → fun← b k ) eq ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
35 fun← b ( fun→ b y )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
36 ≡⟨ fiso← b y ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
37 y
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
38 ∎ where open ≡-Reasoning
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
39
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
40 b→injection1 : {n m : Level} (R : Set n) (S : Set m) → (b : Bijection R S) → injection S R (fun← b)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
41 b→injection1 R S b x y eq = trans ( sym ( fiso→ b x ) ) (trans ( cong (λ k → fun→ b k ) eq ) ( fiso→ b y ))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
42
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
43 -- ¬ A = A → ⊥
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
44
174
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
45 diag : {S : Set } (b : Bijection ( S → Bool ) S) → S → Bool
164
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
46 diag b n = not (fun← b n n)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
47
174
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
48 diagonal : { S : Set } → ¬ Bijection ( S → Bool ) S
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
49 diagonal {S} b = diagn1 (fun→ b (diag b) ) refl where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
50 diagn1 : (n : S ) → ¬ (fun→ b (diag b) ≡ n )
164
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
51 diagn1 n dn = ¬t=f (diag b n ) ( begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
52 not (diag b n)
141
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 ≡⟨⟩
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 not (not fun← b n n)
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 ≡⟨ cong (λ k → not (k n) ) (sym (fiso← b _)) ⟩
164
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
56 not (fun← b (fun→ b (diag b)) n)
141
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 ≡⟨ cong (λ k → not (fun← b k n) ) dn ⟩
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 not (fun← b n n)
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 ≡⟨⟩
164
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
60 diag b n
141
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 ∎ ) where open ≡-Reasoning
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
62
164
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
63 b1 : (b : Bijection ( ℕ → Bool ) ℕ) → ℕ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
64 b1 b = fun→ b (diag b)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
65
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
66 b-iso : (b : Bijection ( ℕ → Bool ) ℕ) → fun← b (b1 b) ≡ (diag b)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
67 b-iso b = fiso← b _
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
68
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
69 postulate
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
70 utm : List Bool → List Bool → Maybe Bool
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
71
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
72 record TM : Set where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
73 field
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
74 tm : List Bool → Maybe Bool
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
75 encode : List Bool
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
76 is-tm : utm encode ≡ tm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
77
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
78 open TM
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
79
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
80 Halt1 : TM → List Bool → Bool -- ℕ → ( ℕ → Bool )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
81 Halt1 = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
82
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
83 record Halt1-is-tm : Set where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
84 field
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
85 htm : TM
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
86 htm-is-Halt1 : (t : TM ) → (x : List Bool) → (Halt1 t x ≡ true) ⇔ ((tm htm (encode t ++ x)) ≡ just true)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
87
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
88 Halt2 : (tm : TM ) → List Bool -- ( ℕ → Bool ) → ℕ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
89 Halt2 tm = encode tm
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
90
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
91 not-halt : {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
92 not-halt = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
93
141
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
94 to1 : {n : Level} {R : Set n} → Bijection ℕ R → Bijection ℕ (⊤ ∨ R )
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 to1 {n} {R} b = record {
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 fun← = to11
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
97 ; fun→ = to12
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
98 ; fiso← = to13
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 ; fiso→ = to14
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
100 } where
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
101 to11 : ⊤ ∨ R → ℕ
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
102 to11 (case1 tt) = 0
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
103 to11 (case2 x) = suc ( fun← b x )
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
104 to12 : ℕ → ⊤ ∨ R
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
105 to12 zero = case1 tt
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
106 to12 (suc n) = case2 ( fun→ b n)
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
107 to13 : (x : ℕ) → to11 (to12 x) ≡ x
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
108 to13 zero = refl
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
109 to13 (suc x) = cong suc (fiso← b x)
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
110 to14 : (x : ⊤ ∨ R) → to12 (to11 x) ≡ x
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
111 to14 (case1 x) = refl
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
112 to14 (case2 x) = cong case2 (fiso→ b x)
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
113
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
114 open _∧_
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
115
172
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 164
diff changeset
116 open import nat
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 164
diff changeset
117
173
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 172
diff changeset
118 open ≡-Reasoning
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 172
diff changeset
119
172
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 164
diff changeset
120 -- [] 0
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 164
diff changeset
121 -- 0 → 1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 164
diff changeset
122 -- 1 → 2
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 164
diff changeset
123 -- 01 → 3
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 164
diff changeset
124 -- 11 → 4
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 164
diff changeset
125 -- ...
141
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
126 --
172
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 164
diff changeset
127 {-# TERMINATING #-}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 164
diff changeset
128 LBℕ : Bijection ℕ ( List Bool )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 164
diff changeset
129 LBℕ = record {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 164
diff changeset
130 fun← = λ x → lton x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 164
diff changeset
131 ; fun→ = λ n → ntol n
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 164
diff changeset
132 ; fiso← = lbiso0
173
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 172
diff changeset
133 ; fiso→ = lbisor
172
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 164
diff changeset
134 } where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 164
diff changeset
135 lton1 : List Bool → ℕ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 164
diff changeset
136 lton1 [] = 0
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 164
diff changeset
137 lton1 (true ∷ t) = suc (lton1 t + lton1 t)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 164
diff changeset
138 lton1 (false ∷ t) = lton1 t + lton1 t
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 164
diff changeset
139 lton : List Bool → ℕ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 164
diff changeset
140 lton [] = 0
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 164
diff changeset
141 lton x = suc (lton1 x)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 164
diff changeset
142 ntol1 : ℕ → List Bool
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 164
diff changeset
143 ntol1 0 = []
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 164
diff changeset
144 ntol1 (suc x) with div2 (suc x)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 164
diff changeset
145 ... | ⟪ x1 , true ⟫ = true ∷ ntol1 x1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 164
diff changeset
146 ... | ⟪ x1 , false ⟫ = false ∷ ntol1 x1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 164
diff changeset
147 ntol : ℕ → List Bool
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 164
diff changeset
148 ntol 0 = []
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 164
diff changeset
149 ntol 1 = false ∷ []
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 164
diff changeset
150 ntol (suc n) = ntol1 n
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 164
diff changeset
151 xx : (x : ℕ ) → List Bool ∧ ℕ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 164
diff changeset
152 xx x = ⟪ (ntol x) , lton ((ntol x)) ⟫
175
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 174
diff changeset
153 ---- div2-eq : (x : ℕ ) → div2-rev ( div2 x ) ≡ x
172
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 164
diff changeset
154 lbiso1 : (x : ℕ) → suc (lton1 (ntol1 x)) ≡ suc x
173
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 172
diff changeset
155 lbiso1 zero = refl
175
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 174
diff changeset
156 lbiso1 (suc x) with div2 (suc x) | inspect div2 (suc x)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 174
diff changeset
157 ... | ⟪ x1 , true ⟫ | record { eq = eq1 } = begin
173
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 172
diff changeset
158 suc (suc (lton1 (ntol1 x1) + lton1 (ntol1 x1))) ≡⟨ {!!} ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 172
diff changeset
159 suc (lton1 (ntol1 x1)) + suc (lton1 (ntol1 x1)) ≡⟨ cong ( λ k → k + k ) (lbiso1 x1) ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 172
diff changeset
160 suc x1 + suc x1 ≡⟨ {!!} ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 172
diff changeset
161 suc (suc (x1 + x1)) ≡⟨ {!!} ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 172
diff changeset
162 suc (suc x) ∎
175
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 174
diff changeset
163 ... | ⟪ x1 , false ⟫ | record { eq = eq1 } = {!!}
172
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 164
diff changeset
164 lbiso0 : (x : ℕ) → lton (ntol x) ≡ x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 164
diff changeset
165 lbiso0 zero = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 164
diff changeset
166 lbiso0 (suc zero) = refl
173
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 172
diff changeset
167 lbiso0 (suc (suc x)) = subst (λ k → k ≡ suc (suc x)) (hh x) ( lbiso1 (suc x)) where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 172
diff changeset
168 hh : (x : ℕ ) → suc (lton1 (ntol1 (suc x))) ≡ lton (ntol (suc (suc x)))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 172
diff changeset
169 hh x with div2 (suc x)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 172
diff changeset
170 ... | ⟪ proj3 , true ⟫ = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 172
diff changeset
171 ... | ⟪ proj3 , false ⟫ = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 172
diff changeset
172 lbisor : (x : List Bool) → ntol (lton x) ≡ x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 172
diff changeset
173 lbisor [] = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 172
diff changeset
174 lbisor (false ∷ []) = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 172
diff changeset
175 lbisor (true ∷ []) = refl
174
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
176 lbisor (false ∷ true ∷ t) = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
177 lbisor (false ∷ false ∷ t) = {!!}
173
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 172
diff changeset
178 lbisor (true ∷ x ∷ t) = {!!}
141
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
179
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
180
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
181 open import Axiom.Extensionality.Propositional
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
182 postulate f-extensionality : { n : Level} → Axiom.Extensionality.Propositional.Extensionality n n
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
183 open import Relation.Binary.HeterogeneousEquality as HE using (_≅_;refl ) renaming ( sym to ≅-sym ; trans to ≅-trans ; cong to ≅-cong )
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
184
142
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
185 record Halt : Set where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
186 field
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
187 htm : TM
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
188 is-halt : (t : TM ) → (x : List Bool ) → (tm htm (encode t ++ x) ≡ just true) ⇔ ((tm t x ≡ just true) ∨ (tm t x ≡ just false))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
189 nhtm : TM
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
190 nhtm-is-negation : (t : TM ) → (x : List Bool ) → (tm htm (encode t ++ x) ≡ just true) ⇔ (tm nhtm (encode t ++ x) ≡ nothing )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
191
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
192 open Halt
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
193
141
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
194 tm-cong : {x y : TM} → tm x ≡ tm y → encode x ≡ encode y → is-tm x ≅ is-tm y → x ≡ y
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
195 tm-cong refl refl refl = refl
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
196
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
197 tm-bij : Bijection TM (List Bool)
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
198 tm-bij = record {
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
199 fun← = λ x → record { tm = utm x ; encode = x ; is-tm = refl }
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
200 ; fun→ = λ tm → encode tm
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
201 ; fiso← = tmb1
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
202 ; fiso→ = λ x → refl
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
203 } where
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
204 tmb1 : (x : TM ) → record { tm = utm (encode x) ; encode = encode x ; is-tm = refl } ≡ x
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
205 tmb1 x with is-tm x | inspect is-tm x
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
206 ... | refl | record { eq = refl } = tm-cong (is-tm x) refl refl
b3f05cd08d24 clean up
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
207
174
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
208 TNℕ : Halt → Bijection (TM → Bool) TM
164
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
209 TNℕ = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
210
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
211 -- Halt1 (Halt2 x) ≡ x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
212 -- Halt2 (Halt2 y) ≡ y
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 142
diff changeset
213
142
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
214 halting : ¬ Halt
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
215 halting h with tm (htm h) (encode (nhtm h) ++ encode (nhtm h))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
216 ... | just true = ¬t=f {!!} {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
217 ... | nothing = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 141
diff changeset
218 ... | just false = {!!}