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