Mercurial > hg > Members > kono > Proof > ZF-in-agda
annotate ordinal.agda @ 222:59771eb07df0
TransFinite induction fixed
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 09 Aug 2019 16:54:30 +0900 |
parents | 95a26d1698f4 |
children | afc864169325 |
rev | line source |
---|---|
34 | 1 {-# OPTIONS --allow-unsolved-metas #-} |
16 | 2 open import Level |
29
fce60b99dc55
posturate OD is isomorphic to Ordinal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
28
diff
changeset
|
3 module ordinal where |
3 | 4 |
14
e11e95d5ddee
separete constructible set
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
11
diff
changeset
|
5 open import zf |
3 | 6 |
23 | 7 open import Data.Nat renaming ( zero to Zero ; suc to Suc ; ℕ to Nat ; _⊔_ to _n⊔_ ) |
75 | 8 open import Data.Empty |
14
e11e95d5ddee
separete constructible set
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
11
diff
changeset
|
9 open import Relation.Binary.PropositionalEquality |
213
22d435172d1a
separate logic and nat
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
204
diff
changeset
|
10 open import logic |
22d435172d1a
separate logic and nat
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
204
diff
changeset
|
11 open import nat |
3 | 12 |
24 | 13 data OrdinalD {n : Level} : (lv : Nat) → Set n where |
14 Φ : (lv : Nat) → OrdinalD lv | |
15 OSuc : (lv : Nat) → OrdinalD {n} lv → OrdinalD lv | |
3 | 16 |
24 | 17 record Ordinal {n : Level} : Set n where |
202
ed88384b5102
ε-induction like loop again
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
184
diff
changeset
|
18 constructor ordinal |
16 | 19 field |
20 lv : Nat | |
24 | 21 ord : OrdinalD {n} lv |
16 | 22 |
24 | 23 data _d<_ {n : Level} : {lx ly : Nat} → OrdinalD {n} lx → OrdinalD {n} ly → Set n where |
24 Φ< : {lx : Nat} → {x : OrdinalD {n} lx} → Φ lx d< OSuc lx x | |
25 s< : {lx : Nat} → {x y : OrdinalD {n} lx} → x d< y → OSuc lx x d< OSuc lx y | |
17 | 26 |
27 open Ordinal | |
28 | |
27 | 29 _o<_ : {n : Level} ( x y : Ordinal ) → Set n |
17 | 30 _o<_ x y = (lv x < lv y ) ∨ ( ord x d< ord y ) |
3 | 31 |
218 | 32 o<-dom : {n : Level} { x y : Ordinal {n}} → x o< y → Ordinal |
33 o<-dom {n} {x} _ = x | |
34 | |
35 o<-cod : {n : Level} { x y : Ordinal {n}} → x o< y → Ordinal | |
36 o<-cod {n} {_} {y} _ = y | |
37 | |
75 | 38 s<refl : {n : Level } {lx : Nat } { x : OrdinalD {n} lx } → x d< OSuc lx x |
39 s<refl {n} {lv} {Φ lv} = Φ< | |
40 s<refl {n} {lv} {OSuc lv x} = s< s<refl | |
41 | |
42 trio<> : {n : Level} → {lx : Nat} {x : OrdinalD {n} lx } { y : OrdinalD lx } → y d< x → x d< y → ⊥ | |
43 trio<> {n} {lx} {.(OSuc lx _)} {.(OSuc lx _)} (s< s) (s< t) = trio<> s t | |
44 trio<> {n} {lx} {.(OSuc lx _)} {.(Φ lx)} Φ< () | |
45 | |
46 d<→lv : {n : Level} {x y : Ordinal {n}} → ord x d< ord y → lv x ≡ lv y | |
47 d<→lv Φ< = refl | |
48 d<→lv (s< lt) = refl | |
49 | |
43
0d9b9db14361
equalitu and internal parametorisity
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
41
diff
changeset
|
50 o<-subst : {n : Level } {Z X z x : Ordinal {n}} → Z o< X → Z ≡ z → X ≡ x → z o< x |
0d9b9db14361
equalitu and internal parametorisity
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
41
diff
changeset
|
51 o<-subst df refl refl = df |
0d9b9db14361
equalitu and internal parametorisity
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
41
diff
changeset
|
52 |
14
e11e95d5ddee
separete constructible set
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
11
diff
changeset
|
53 open import Data.Nat.Properties |
30
3b0fdb95618e
problem on Ordinal ( OSuc ℵ )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
29
diff
changeset
|
54 open import Data.Unit using ( ⊤ ) |
6 | 55 open import Relation.Nullary |
56 | |
57 open import Relation.Binary | |
58 open import Relation.Binary.Core | |
59 | |
24 | 60 o∅ : {n : Level} → Ordinal {n} |
61 o∅ = record { lv = Zero ; ord = Φ Zero } | |
21 | 62 |
39 | 63 open import Relation.Binary.HeterogeneousEquality using (_≅_;refl) |
64 | |
65 ordinal-cong : {n : Level} {x y : Ordinal {n}} → | |
66 lv x ≡ lv y → ord x ≅ ord y → x ≡ y | |
67 ordinal-cong refl refl = refl | |
21 | 68 |
46 | 69 ordinal-lv : {n : Level} {x y : Ordinal {n}} → x ≡ y → lv x ≡ lv y |
70 ordinal-lv refl = refl | |
71 | |
72 ordinal-d : {n : Level} {x y : Ordinal {n}} → x ≡ y → ord x ≅ ord y | |
73 ordinal-d refl = refl | |
74 | |
24 | 75 ≡→¬d< : {n : Level} → {lv : Nat} → {x : OrdinalD {n} lv } → x d< x → ⊥ |
76 ≡→¬d< {n} {lx} {OSuc lx y} (s< t) = ≡→¬d< t | |
14
e11e95d5ddee
separete constructible set
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
11
diff
changeset
|
77 |
24 | 78 trio<≡ : {n : Level} → {lx : Nat} {x : OrdinalD {n} lx } { y : OrdinalD lx } → x ≡ y → x d< y → ⊥ |
17 | 79 trio<≡ refl = ≡→¬d< |
14
e11e95d5ddee
separete constructible set
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
11
diff
changeset
|
80 |
24 | 81 trio>≡ : {n : Level} → {lx : Nat} {x : OrdinalD {n} lx } { y : OrdinalD lx } → x ≡ y → y d< x → ⊥ |
17 | 82 trio>≡ refl = ≡→¬d< |
9
5ed16e2d8eb7
try to fix axiom of replacement
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
8
diff
changeset
|
83 |
24 | 84 triO : {n : Level} → {lx ly : Nat} → OrdinalD {n} lx → OrdinalD {n} ly → Tri (lx < ly) ( lx ≡ ly ) ( lx > ly ) |
85 triO {n} {lx} {ly} x y = <-cmp lx ly | |
14
e11e95d5ddee
separete constructible set
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
11
diff
changeset
|
86 |
24 | 87 triOrdd : {n : Level} → {lx : Nat} → Trichotomous _≡_ ( _d<_ {n} {lx} {lx} ) |
88 triOrdd {_} {lv} (Φ lv) (Φ lv) = tri≈ ≡→¬d< refl ≡→¬d< | |
89 triOrdd {_} {lv} (Φ lv) (OSuc lv y) = tri< Φ< (λ ()) ( λ lt → trio<> lt Φ< ) | |
90 triOrdd {_} {lv} (OSuc lv x) (Φ lv) = tri> (λ lt → trio<> lt Φ<) (λ ()) Φ< | |
91 triOrdd {_} {lv} (OSuc lv x) (OSuc lv y) with triOrdd x y | |
92 triOrdd {_} {lv} (OSuc lv x) (OSuc lv y) | tri< a ¬b ¬c = tri< (s< a) (λ tx=ty → trio<≡ tx=ty (s< a) ) ( λ lt → trio<> lt (s< a) ) | |
93 triOrdd {_} {lv} (OSuc lv x) (OSuc lv x) | tri≈ ¬a refl ¬c = tri≈ ≡→¬d< refl ≡→¬d< | |
94 triOrdd {_} {lv} (OSuc lv x) (OSuc lv y) | tri> ¬a ¬b c = tri> ( λ lt → trio<> lt (s< c) ) (λ tx=ty → trio>≡ tx=ty (s< c) ) (s< c) | |
9
5ed16e2d8eb7
try to fix axiom of replacement
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
8
diff
changeset
|
95 |
74
819da8c08f05
ordinal atomical successor?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
73
diff
changeset
|
96 osuc : {n : Level} ( x : Ordinal {n} ) → Ordinal {n} |
75 | 97 osuc record { lv = lx ; ord = ox } = record { lv = lx ; ord = OSuc lx ox } |
74
819da8c08f05
ordinal atomical successor?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
73
diff
changeset
|
98 |
819da8c08f05
ordinal atomical successor?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
73
diff
changeset
|
99 <-osuc : {n : Level} { x : Ordinal {n} } → x o< osuc x |
75 | 100 <-osuc {n} {record { lv = lx ; ord = Φ .lx }} = case2 Φ< |
101 <-osuc {n} {record { lv = lx ; ord = OSuc .lx ox }} = case2 ( s< s<refl ) | |
74
819da8c08f05
ordinal atomical successor?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
73
diff
changeset
|
102 |
819da8c08f05
ordinal atomical successor?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
73
diff
changeset
|
103 osuc-lveq : {n : Level} { x : Ordinal {n} } → lv x ≡ lv ( osuc x ) |
75 | 104 osuc-lveq {n} = refl |
74
819da8c08f05
ordinal atomical successor?
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
73
diff
changeset
|
105 |
113 | 106 osucc : {n : Level} {ox oy : Ordinal {n}} → oy o< ox → osuc oy o< osuc ox |
107 osucc {n} {ox} {oy} (case1 x) = case1 x | |
108 osucc {n} {ox} {oy} (case2 x) with d<→lv x | |
109 ... | refl = case2 (s< x) | |
110 | |
147 | 111 case12-⊥ : {n : Level} {x y : Ordinal {suc n}} → lv x < lv y → ord x d< ord y → ⊥ |
112 case12-⊥ {x} {y} lt1 lt2 with d<→lv lt2 | |
113 ... | refl = nat-≡< refl lt1 | |
114 | |
115 case21-⊥ : {n : Level} {x y : Ordinal {suc n}} → lv x < lv y → ord y d< ord x → ⊥ | |
116 case21-⊥ {x} {y} lt1 lt2 with d<→lv lt2 | |
117 ... | refl = nat-≡< refl lt1 | |
118 | |
203
8edd2a13a7f3
fixing transfinte induction...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
202
diff
changeset
|
119 o<¬≡ : {n : Level } { ox oy : Ordinal {suc n}} → ox ≡ oy → ox o< oy → ⊥ |
111 | 120 o<¬≡ {_} {ox} {ox} refl (case1 lt) = =→¬< lt |
121 o<¬≡ {_} {ox} {ox} refl (case2 (s< lt)) = trio<≡ refl lt | |
94 | 122 |
123 ¬x<0 : {n : Level} → { x : Ordinal {suc n} } → ¬ ( x o< o∅ {suc n} ) | |
124 ¬x<0 {n} {x} (case1 ()) | |
125 ¬x<0 {n} {x} (case2 ()) | |
126 | |
81 | 127 o<> : {n : Level} → {x y : Ordinal {n} } → y o< x → x o< y → ⊥ |
128 o<> {n} {x} {y} (case1 x₁) (case1 x₂) = nat-<> x₁ x₂ | |
129 o<> {n} {x} {y} (case1 x₁) (case2 x₂) = nat-≡< (sym (d<→lv x₂)) x₁ | |
130 o<> {n} {x} {y} (case2 x₁) (case1 x₂) = nat-≡< (sym (d<→lv x₁)) x₂ | |
131 o<> {n} {record { lv = lv₁ ; ord = .(OSuc lv₁ _) }} {record { lv = .lv₁ ; ord = .(Φ lv₁) }} (case2 Φ<) (case2 ()) | |
132 o<> {n} {record { lv = lv₁ ; ord = .(OSuc lv₁ _) }} {record { lv = .lv₁ ; ord = .(OSuc lv₁ _) }} (case2 (s< y<x)) (case2 (s< x<y)) = | |
133 o<> (case2 y<x) (case2 x<y) | |
16 | 134 |
24 | 135 orddtrans : {n : Level} {lx : Nat} {x y z : OrdinalD {n} lx } → x d< y → y d< z → x d< z |
136 orddtrans {_} {lx} {.(Φ lx)} {.(OSuc lx _)} {.(OSuc lx _)} Φ< (s< y<z) = Φ< | |
137 orddtrans {_} {lx} {.(OSuc lx _)} {.(OSuc lx _)} {.(OSuc lx _)} (s< x<y) (s< y<z) = s< ( orddtrans x<y y<z ) | |
9
5ed16e2d8eb7
try to fix axiom of replacement
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
8
diff
changeset
|
138 |
75 | 139 osuc-≡< : {n : Level} { a x : Ordinal {n} } → x o< osuc a → (x ≡ a ) ∨ (x o< a) |
140 osuc-≡< {n} {a} {x} (case1 lt) = case2 (case1 lt) | |
141 osuc-≡< {n} {record { lv = lv₁ ; ord = Φ .lv₁ }} {record { lv = .lv₁ ; ord = .(Φ lv₁) }} (case2 Φ<) = case1 refl | |
142 osuc-≡< {n} {record { lv = lv₁ ; ord = OSuc .lv₁ ord₁ }} {record { lv = .lv₁ ; ord = .(Φ lv₁) }} (case2 Φ<) = case2 (case2 Φ<) | |
143 osuc-≡< {n} {record { lv = lv₁ ; ord = Φ .lv₁ }} {record { lv = .lv₁ ; ord = .(OSuc lv₁ _) }} (case2 (s< ())) | |
144 osuc-≡< {n} {record { lv = la ; ord = OSuc la oa }} {record { lv = la ; ord = (OSuc la ox) }} (case2 (s< lt)) with | |
145 osuc-≡< {n} {record { lv = la ; ord = oa }} {record { lv = la ; ord = ox }} (case2 lt ) | |
146 ... | case1 refl = case1 refl | |
147 ... | case2 (case2 x) = case2 (case2( s< x) ) | |
148 ... | case2 (case1 x) = ⊥-elim (¬a≤a x) where | |
149 | |
150 osuc-< : {n : Level} { x y : Ordinal {n} } → y o< osuc x → x o< y → ⊥ | |
151 osuc-< {n} {x} {y} y<ox x<y with osuc-≡< y<ox | |
152 osuc-< {n} {x} {x} y<ox (case1 x₁) | case1 refl = ⊥-elim (¬a≤a x₁) | |
153 osuc-< {n} {x} {x} (case1 x₂) (case2 x₁) | case1 refl = ⊥-elim (¬a≤a x₂) | |
154 osuc-< {n} {x} {x} (case2 x₂) (case2 x₁) | case1 refl = ≡→¬d< x₁ | |
81 | 155 osuc-< {n} {x} {y} y<ox (case1 x₂) | case2 (case1 x₁) = nat-<> x₂ x₁ |
156 osuc-< {n} {x} {y} y<ox (case1 x₂) | case2 (case2 x₁) = nat-≡< (sym (d<→lv x₁)) x₂ | |
157 osuc-< {n} {x} {y} y<ox (case2 x<y) | case2 y<x = o<> (case2 x<y) y<x | |
75 | 158 |
24 | 159 maxαd : {n : Level} → { lx : Nat } → OrdinalD {n} lx → OrdinalD lx → OrdinalD lx |
17 | 160 maxαd x y with triOrdd x y |
161 maxαd x y | tri< a ¬b ¬c = y | |
162 maxαd x y | tri≈ ¬a b ¬c = x | |
163 maxαd x y | tri> ¬a ¬b c = x | |
6 | 164 |
127 | 165 minαd : {n : Level} → { lx : Nat } → OrdinalD {n} lx → OrdinalD lx → OrdinalD lx |
166 minαd x y with triOrdd x y | |
167 minαd x y | tri< a ¬b ¬c = x | |
168 minαd x y | tri≈ ¬a b ¬c = y | |
169 minαd x y | tri> ¬a ¬b c = x | |
170 | |
24 | 171 _o≤_ : {n : Level} → Ordinal → Ordinal → Set (suc n) |
23 | 172 a o≤ b = (a ≡ b) ∨ ( a o< b ) |
173 | |
27 | 174 ordtrans : {n : Level} {x y z : Ordinal {n} } → x o< y → y o< z → x o< z |
175 ordtrans {n} {x} {y} {z} (case1 x₁) (case1 x₂) = case1 ( <-trans x₁ x₂ ) | |
81 | 176 ordtrans {n} {x} {y} {z} (case1 x₁) (case2 x₂) with d<→lv x₂ |
27 | 177 ... | refl = case1 x₁ |
81 | 178 ordtrans {n} {x} {y} {z} (case2 x₁) (case1 x₂) with d<→lv x₁ |
27 | 179 ... | refl = case1 x₂ |
180 ordtrans {n} {x} {y} {z} (case2 x₁) (case2 x₂) with d<→lv x₁ | d<→lv x₂ | |
181 ... | refl | refl = case2 ( orddtrans x₁ x₂ ) | |
182 | |
24 | 183 trio< : {n : Level } → Trichotomous {suc n} _≡_ _o<_ |
23 | 184 trio< a b with <-cmp (lv a) (lv b) |
24 | 185 trio< a b | tri< a₁ ¬b ¬c = tri< (case1 a₁) (λ refl → ¬b (cong ( λ x → lv x ) refl ) ) lemma1 where |
186 lemma1 : ¬ (Suc (lv b) ≤ lv a) ∨ (ord b d< ord a) | |
187 lemma1 (case1 x) = ¬c x | |
81 | 188 lemma1 (case2 x) = ⊥-elim (nat-≡< (sym ( d<→lv x )) a₁ ) |
24 | 189 trio< a b | tri> ¬a ¬b c = tri> lemma1 (λ refl → ¬b (cong ( λ x → lv x ) refl ) ) (case1 c) where |
190 lemma1 : ¬ (Suc (lv a) ≤ lv b) ∨ (ord a d< ord b) | |
191 lemma1 (case1 x) = ¬a x | |
81 | 192 lemma1 (case2 x) = ⊥-elim (nat-≡< (sym ( d<→lv x )) c ) |
23 | 193 trio< a b | tri≈ ¬a refl ¬c with triOrdd ( ord a ) ( ord b ) |
24 | 194 trio< record { lv = .(lv b) ; ord = x } b | tri≈ ¬a refl ¬c | tri< a ¬b ¬c₁ = tri< (case2 a) (λ refl → ¬b (lemma1 refl )) lemma2 where |
195 lemma1 : (record { lv = _ ; ord = x }) ≡ b → x ≡ ord b | |
196 lemma1 refl = refl | |
197 lemma2 : ¬ (Suc (lv b) ≤ lv b) ∨ (ord b d< x) | |
198 lemma2 (case1 x) = ¬a x | |
199 lemma2 (case2 x) = trio<> x a | |
200 trio< record { lv = .(lv b) ; ord = x } b | tri≈ ¬a refl ¬c | tri> ¬a₁ ¬b c = tri> lemma2 (λ refl → ¬b (lemma1 refl )) (case2 c) where | |
201 lemma1 : (record { lv = _ ; ord = x }) ≡ b → x ≡ ord b | |
202 lemma1 refl = refl | |
203 lemma2 : ¬ (Suc (lv b) ≤ lv b) ∨ (x d< ord b) | |
204 lemma2 (case1 x) = ¬a x | |
205 lemma2 (case2 x) = trio<> x c | |
206 trio< record { lv = .(lv b) ; ord = x } b | tri≈ ¬a refl ¬c | tri≈ ¬a₁ refl ¬c₁ = tri≈ lemma1 refl lemma1 where | |
207 lemma1 : ¬ (Suc (lv b) ≤ lv b) ∨ (ord b d< ord b) | |
208 lemma1 (case1 x) = ¬a x | |
209 lemma1 (case2 x) = ≡→¬d< x | |
23 | 210 |
180 | 211 xo<ab : {n : Level} {oa ob : Ordinal {suc n}} → ( {ox : Ordinal {suc n}} → ox o< oa → ox o< ob ) → oa o< osuc ob |
212 xo<ab {n} {oa} {ob} a→b with trio< oa ob | |
213 xo<ab {n} {oa} {ob} a→b | tri< a ¬b ¬c = ordtrans a <-osuc | |
214 xo<ab {n} {oa} {ob} a→b | tri≈ ¬a refl ¬c = <-osuc | |
215 xo<ab {n} {oa} {ob} a→b | tri> ¬a ¬b c = ⊥-elim ( o<¬≡ refl (a→b c ) ) | |
216 | |
129 | 217 maxα : {n : Level} → Ordinal {suc n} → Ordinal → Ordinal |
218 maxα x y with trio< x y | |
127 | 219 maxα x y | tri< a ¬b ¬c = y |
220 maxα x y | tri> ¬a ¬b c = x | |
129 | 221 maxα x y | tri≈ ¬a refl ¬c = x |
84 | 222 |
129 | 223 minα : {n : Level} → Ordinal {suc n} → Ordinal → Ordinal |
224 minα {n} x y with trio< {n} x y | |
127 | 225 minα x y | tri< a ¬b ¬c = x |
226 minα x y | tri> ¬a ¬b c = y | |
129 | 227 minα x y | tri≈ ¬a refl ¬c = x |
228 | |
229 min1 : {n : Level} → {x y z : Ordinal {suc n} } → z o< x → z o< y → z o< minα x y | |
230 min1 {n} {x} {y} {z} z<x z<y with trio< {n} x y | |
231 min1 {n} {x} {y} {z} z<x z<y | tri< a ¬b ¬c = z<x | |
232 min1 {n} {x} {y} {z} z<x z<y | tri≈ ¬a refl ¬c = z<x | |
233 min1 {n} {x} {y} {z} z<x z<y | tri> ¬a ¬b c = z<y | |
234 | |
85
7494ae6b83c6
omax-induction does not work
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
84
diff
changeset
|
235 -- |
7494ae6b83c6
omax-induction does not work
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
84
diff
changeset
|
236 -- max ( osuc x , osuc y ) |
7494ae6b83c6
omax-induction does not work
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
84
diff
changeset
|
237 -- |
88 | 238 |
84 | 239 omax : {n : Level} ( x y : Ordinal {suc n} ) → Ordinal {suc n} |
88 | 240 omax {n} x y with trio< x y |
84 | 241 omax {n} x y | tri< a ¬b ¬c = osuc y |
242 omax {n} x y | tri> ¬a ¬b c = osuc x | |
88 | 243 omax {n} x y | tri≈ ¬a refl ¬c = osuc x |
84 | 244 |
245 omax< : {n : Level} ( x y : Ordinal {suc n} ) → x o< y → osuc y ≡ omax x y | |
88 | 246 omax< {n} x y lt with trio< x y |
84 | 247 omax< {n} x y lt | tri< a ¬b ¬c = refl |
88 | 248 omax< {n} x y lt | tri≈ ¬a b ¬c = ⊥-elim (¬a lt ) |
249 omax< {n} x y lt | tri> ¬a ¬b c = ⊥-elim (¬a lt ) | |
250 | |
251 omax≡ : {n : Level} ( x y : Ordinal {suc n} ) → x ≡ y → osuc y ≡ omax x y | |
252 omax≡ {n} x y eq with trio< x y | |
253 omax≡ {n} x y eq | tri< a ¬b ¬c = ⊥-elim (¬b eq ) | |
254 omax≡ {n} x y eq | tri≈ ¬a refl ¬c = refl | |
255 omax≡ {n} x y eq | tri> ¬a ¬b c = ⊥-elim (¬b eq ) | |
84 | 256 |
86 | 257 omax-x : {n : Level} ( x y : Ordinal {suc n} ) → x o< omax x y |
88 | 258 omax-x {n} x y with trio< x y |
259 omax-x {n} x y | tri< a ¬b ¬c = ordtrans a <-osuc | |
86 | 260 omax-x {n} x y | tri> ¬a ¬b c = <-osuc |
88 | 261 omax-x {n} x y | tri≈ ¬a refl ¬c = <-osuc |
86 | 262 |
263 omax-y : {n : Level} ( x y : Ordinal {suc n} ) → y o< omax x y | |
88 | 264 omax-y {n} x y with trio< x y |
86 | 265 omax-y {n} x y | tri< a ¬b ¬c = <-osuc |
88 | 266 omax-y {n} x y | tri> ¬a ¬b c = ordtrans c <-osuc |
267 omax-y {n} x y | tri≈ ¬a refl ¬c = <-osuc | |
86 | 268 |
88 | 269 omxx : {n : Level} ( x : Ordinal {suc n} ) → omax x x ≡ osuc x |
270 omxx {n} x with trio< x x | |
271 omxx {n} x | tri< a ¬b ¬c = ⊥-elim (¬b refl ) | |
272 omxx {n} x | tri> ¬a ¬b c = ⊥-elim (¬b refl ) | |
273 omxx {n} x | tri≈ ¬a refl ¬c = refl | |
86 | 274 |
275 omxxx : {n : Level} ( x : Ordinal {suc n} ) → omax x (omax x x ) ≡ osuc (osuc x) | |
88 | 276 omxxx {n} x = trans ( cong ( λ k → omax x k ) (omxx x )) (sym ( omax< x (osuc x) <-osuc )) |
86 | 277 |
91 | 278 open _∧_ |
279 | |
280 osuc2 : {n : Level} ( x y : Ordinal {suc n} ) → ( osuc x o< osuc (osuc y )) ⇔ (x o< osuc y) | |
281 proj1 (osuc2 {n} x y) (case1 lt) = case1 lt | |
282 proj1 (osuc2 {n} x y) (case2 (s< lt)) = case2 lt | |
283 proj2 (osuc2 {n} x y) (case1 lt) = case1 lt | |
284 proj2 (osuc2 {n} x y) (case2 lt) with d<→lv lt | |
285 ... | refl = case2 (s< lt) | |
286 | |
24 | 287 OrdTrans : {n : Level} → Transitive {suc n} _o≤_ |
16 | 288 OrdTrans (case1 refl) (case1 refl) = case1 refl |
289 OrdTrans (case1 refl) (case2 lt2) = case2 lt2 | |
290 OrdTrans (case2 lt1) (case1 refl) = case2 lt1 | |
81 | 291 OrdTrans (case2 x) (case2 y) = case2 (ordtrans x y) |
16 | 292 |
24 | 293 OrdPreorder : {n : Level} → Preorder (suc n) (suc n) (suc n) |
294 OrdPreorder {n} = record { Carrier = Ordinal | |
16 | 295 ; _≈_ = _≡_ |
23 | 296 ; _∼_ = _o≤_ |
16 | 297 ; isPreorder = record { |
298 isEquivalence = record { refl = refl ; sym = sym ; trans = trans } | |
299 ; reflexive = case1 | |
24 | 300 ; trans = OrdTrans |
16 | 301 } |
302 } | |
303 | |
203
8edd2a13a7f3
fixing transfinte induction...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
202
diff
changeset
|
304 TransFinite : {n m : Level} → { ψ : Ordinal {suc n} → Set m } |
8edd2a13a7f3
fixing transfinte induction...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
202
diff
changeset
|
305 → ( ∀ (lx : Nat ) → ( (x : Ordinal {suc n} ) → x o< ordinal lx (Φ lx) → ψ x ) → ψ ( record { lv = lx ; ord = Φ lx } ) ) |
222
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
306 → ( ∀ (lx : Nat ) → (x : OrdinalD lx ) → ( (y : Ordinal {suc n} ) → y o< ordinal lx (OSuc lx x) → ψ y ) → ψ ( record { lv = lx ; ord = OSuc lx x } ) ) |
22 | 307 → ∀ (x : Ordinal) → ψ x |
204
d4802eb159ff
Transfinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
203
diff
changeset
|
308 TransFinite {n} {m} {ψ} caseΦ caseOSuc x = proj1 (TransFinite1 (lv x) (ord x) ) where |
222
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
309 TransFinite1 : (lx : Nat) (ox : OrdinalD lx ) → ψ (ordinal lx ox) ∧ ( ( (x : Ordinal {suc n} ) → x o< ordinal lx ox → ψ x ) ) |
204
d4802eb159ff
Transfinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
203
diff
changeset
|
310 TransFinite1 Zero (Φ 0) = record { proj1 = caseΦ Zero lemma ; proj2 = lemma1 } where |
203
8edd2a13a7f3
fixing transfinte induction...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
202
diff
changeset
|
311 lemma : (x : Ordinal) → x o< ordinal Zero (Φ Zero) → ψ x |
8edd2a13a7f3
fixing transfinte induction...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
202
diff
changeset
|
312 lemma x (case1 ()) |
8edd2a13a7f3
fixing transfinte induction...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
202
diff
changeset
|
313 lemma x (case2 ()) |
204
d4802eb159ff
Transfinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
203
diff
changeset
|
314 lemma1 : (x : Ordinal) → x o< ordinal Zero (Φ Zero) → ψ x |
d4802eb159ff
Transfinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
203
diff
changeset
|
315 lemma1 x (case1 ()) |
d4802eb159ff
Transfinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
203
diff
changeset
|
316 lemma1 x (case2 ()) |
d4802eb159ff
Transfinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
203
diff
changeset
|
317 TransFinite1 (Suc lx) (Φ (Suc lx)) = record { proj1 = caseΦ (Suc lx) (λ x → lemma (lv x) (ord x)) ; proj2 = (λ x → lemma (lv x) (ord x)) } where |
d4802eb159ff
Transfinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
203
diff
changeset
|
318 lemma0 : (ly : Nat) (oy : OrdinalD ly ) → ordinal ly oy o< ordinal lx (Φ lx) → ψ (ordinal ly oy) |
d4802eb159ff
Transfinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
203
diff
changeset
|
319 lemma0 ly oy lt = proj2 ( TransFinite1 lx (Φ lx) ) (ordinal ly oy) lt |
d4802eb159ff
Transfinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
203
diff
changeset
|
320 lemma : (ly : Nat) (oy : OrdinalD ly ) → ordinal ly oy o< ordinal (Suc lx) (Φ (Suc lx)) → ψ (ordinal ly oy) |
213
22d435172d1a
separate logic and nat
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
204
diff
changeset
|
321 lemma lx1 ox1 (case1 lt) with <-∨ lt |
22d435172d1a
separate logic and nat
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
204
diff
changeset
|
322 lemma lx (Φ lx) (case1 lt) | case1 refl = proj1 ( TransFinite1 lx (Φ lx) ) |
222
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
323 lemma lx (Φ lx) (case1 lt) | case2 lt1 = lemma0 lx (Φ lx) (case1 lt1) |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
324 lemma lx (OSuc lx ox1) (case1 lt) | case1 refl = caseOSuc lx ox1 lemma2 where |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
325 lemma2 : (y : Ordinal) → (Suc (lv y) ≤ lx) ∨ (ord y d< OSuc lx ox1) → ψ y |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
326 lemma2 y lt1 with osuc-≡< lt1 |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
327 lemma2 y lt1 | case1 refl = lemma lx ox1 (case1 a<sa) |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
328 lemma2 y lt1 | case2 t = proj2 (TransFinite1 lx ox1) y t |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
329 lemma lx1 (OSuc lx1 ox1) (case1 lt) | case2 lt1 = caseOSuc lx1 ox1 lemma2 where |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
330 lemma2 : (y : Ordinal) → (Suc (lv y) ≤ lx1) ∨ (ord y d< OSuc lx1 ox1) → ψ y |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
331 lemma2 y lt2 with osuc-≡< lt2 |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
332 lemma2 y lt2 | case1 refl = lemma lx1 ox1 (ordtrans lt2 (case1 lt)) |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
333 lemma2 y lt2 | case2 (case1 lt3) = proj2 (TransFinite1 lx (Φ lx)) y (case1 (<-trans lt3 lt1 )) |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
334 lemma2 y lt2 | case2 (case2 lt3) with d<→lv lt3 |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
335 ... | refl = proj2 (TransFinite1 lx (Φ lx)) y (case1 lt1) |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
336 TransFinite1 lx (OSuc lx ox) = record { proj1 = caseOSuc lx ox lemma ; proj2 = lemma } where |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
337 lemma : (y : Ordinal) → y o< ordinal lx (OSuc lx ox) → ψ y |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
338 lemma y lt with osuc-≡< lt |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
339 lemma y lt | case1 refl = proj1 ( TransFinite1 lx ox ) |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
340 lemma y lt | case2 lt1 = proj2 ( TransFinite1 lx ox ) y lt1 |
97
f2b579106770
power set using sup on Def
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
94
diff
changeset
|
341 |
184 | 342 -- we cannot prove this in intutionistic logic |
142 | 343 -- (¬ (∀ y → ¬ ( ψ y ))) → (ψ y → p ) → p |
166 | 344 -- postulate |
345 -- TransFiniteExists : {n m l : Level} → ( ψ : Ordinal {n} → Set m ) | |
346 -- → (exists : ¬ (∀ y → ¬ ( ψ y ) )) | |
347 -- → {p : Set l} ( P : { y : Ordinal {n} } → ψ y → p ) | |
348 -- → p | |
349 -- | |
350 -- Instead we prove | |
351 -- | |
352 TransFiniteExists : {n m l : Level} → ( ψ : Ordinal {n} → Set m ) | |
165 | 353 → {p : Set l} ( P : { y : Ordinal {n} } → ψ y → ¬ p ) |
354 → (exists : ¬ (∀ y → ¬ ( ψ y ) )) | |
355 → ¬ p | |
166 | 356 TransFiniteExists {n} {m} {l} ψ {p} P = contra-position ( λ p y ψy → P {y} ψy p ) |
165 | 357 |
222
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
358 open import Ordinals |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
359 |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
360 C-Ordinal : {n : Level } → Ordinals {suc n} |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
361 C-Ordinal {n} = record { |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
362 ord = Ordinal {suc n} |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
363 ; o∅ = o∅ |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
364 ; osuc = osuc |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
365 ; _o<_ = _o<_ |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
366 ; isOrdinal = record { |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
367 Otrans = ordtrans |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
368 ; OTri = trio< |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
369 ; ¬x<0 = ¬x<0 |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
370 ; <-osuc = <-osuc |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
371 ; osuc-≡< = osuc-≡< |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
372 ; TransFinite = TransFinite1 |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
373 } |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
374 } where |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
375 ord1 : Set (suc n) |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
376 ord1 = Ordinal {suc n} |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
377 TransFinite1 : { ψ : ord1 → Set (suc (suc n)) } |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
378 → ( (x : ord1) → ( (y : ord1 ) → y o< x → ψ y ) → ψ x ) |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
379 → ∀ (x : ord1) → ψ x |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
380 TransFinite1 {ψ} lt x = TransFinite {n} {suc (suc n)} {ψ} caseΦ caseOSuc x where |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
381 caseΦ : (lx : Nat) → ((x₁ : Ordinal) → x₁ o< ordinal lx (Φ lx) → ψ x₁) → |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
382 ψ (record { lv = lx ; ord = Φ lx }) |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
383 caseΦ lx prev = lt (ordinal lx (Φ lx) ) prev |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
384 caseOSuc : (lx : Nat) (x₁ : OrdinalD lx) → ((y : Ordinal) → y o< ordinal lx (OSuc lx x₁) → ψ y) → |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
385 ψ (record { lv = lx ; ord = OSuc lx x₁ }) |
59771eb07df0
TransFinite induction fixed
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
220
diff
changeset
|
386 caseOSuc lx ox prev = lt (ordinal lx (OSuc lx ox)) prev |