Mercurial > hg > Members > kono > Proof > ZF-in-agda
comparison OPair.agda @ 272:985a1af11bce
separate ordered pair and Boolean Algebra
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 31 Dec 2019 11:22:52 +0900 |
parents | |
children | d9d3654baee1 |
comparison
equal
deleted
inserted
replaced
271:2169d948159b | 272:985a1af11bce |
---|---|
1 open import Level | |
2 open import Ordinals | |
3 module OPair {n : Level } (O : Ordinals {n}) where | |
4 | |
5 open import zf | |
6 open import logic | |
7 import OD | |
8 | |
9 open import Relation.Nullary | |
10 open import Relation.Binary | |
11 open import Data.Empty | |
12 open import Relation.Binary | |
13 open import Relation.Binary.Core | |
14 open import Relation.Binary.PropositionalEquality | |
15 open import Data.Nat renaming ( zero to Zero ; suc to Suc ; ℕ to Nat ; _⊔_ to _n⊔_ ) | |
16 | |
17 open inOrdinal O | |
18 open OD O | |
19 open OD.OD | |
20 | |
21 open _∧_ | |
22 open _∨_ | |
23 open Bool | |
24 | |
25 open _==_ | |
26 | |
27 <_,_> : (x y : OD) → OD | |
28 < x , y > = (x , x ) , (x , y ) | |
29 | |
30 exg-pair : { x y : OD } → (x , y ) == ( y , x ) | |
31 exg-pair {x} {y} = record { eq→ = left ; eq← = right } where | |
32 left : {z : Ordinal} → def (x , y) z → def (y , x) z | |
33 left (case1 t) = case2 t | |
34 left (case2 t) = case1 t | |
35 right : {z : Ordinal} → def (y , x) z → def (x , y) z | |
36 right (case1 t) = case2 t | |
37 right (case2 t) = case1 t | |
38 | |
39 ord≡→≡ : { x y : OD } → od→ord x ≡ od→ord y → x ≡ y | |
40 ord≡→≡ eq = subst₂ (λ j k → j ≡ k ) oiso oiso ( cong ( λ k → ord→od k ) eq ) | |
41 | |
42 od≡→≡ : { x y : Ordinal } → ord→od x ≡ ord→od y → x ≡ y | |
43 od≡→≡ eq = subst₂ (λ j k → j ≡ k ) diso diso ( cong ( λ k → od→ord k ) eq ) | |
44 | |
45 eq-prod : { x x' y y' : OD } → x ≡ x' → y ≡ y' → < x , y > ≡ < x' , y' > | |
46 eq-prod refl refl = refl | |
47 | |
48 prod-eq : { x x' y y' : OD } → < x , y > == < x' , y' > → (x ≡ x' ) ∧ ( y ≡ y' ) | |
49 prod-eq {x} {x'} {y} {y'} eq = record { proj1 = lemmax ; proj2 = lemmay } where | |
50 lemma0 : {x y z : OD } → ( x , x ) == ( z , y ) → x ≡ y | |
51 lemma0 {x} {y} eq with trio< (od→ord x) (od→ord y) | |
52 lemma0 {x} {y} eq | tri< a ¬b ¬c with eq← eq {od→ord y} (case2 refl) | |
53 lemma0 {x} {y} eq | tri< a ¬b ¬c | case1 s = ⊥-elim ( o<¬≡ (sym s) a ) | |
54 lemma0 {x} {y} eq | tri< a ¬b ¬c | case2 s = ⊥-elim ( o<¬≡ (sym s) a ) | |
55 lemma0 {x} {y} eq | tri≈ ¬a b ¬c = ord≡→≡ b | |
56 lemma0 {x} {y} eq | tri> ¬a ¬b c with eq← eq {od→ord y} (case2 refl) | |
57 lemma0 {x} {y} eq | tri> ¬a ¬b c | case1 s = ⊥-elim ( o<¬≡ s c ) | |
58 lemma0 {x} {y} eq | tri> ¬a ¬b c | case2 s = ⊥-elim ( o<¬≡ s c ) | |
59 lemma2 : {x y z : OD } → ( x , x ) == ( z , y ) → z ≡ y | |
60 lemma2 {x} {y} {z} eq = trans (sym (lemma0 lemma3 )) ( lemma0 eq ) where | |
61 lemma3 : ( x , x ) == ( y , z ) | |
62 lemma3 = ==-trans eq exg-pair | |
63 lemma1 : {x y : OD } → ( x , x ) == ( y , y ) → x ≡ y | |
64 lemma1 {x} {y} eq with eq← eq {od→ord y} (case2 refl) | |
65 lemma1 {x} {y} eq | case1 s = ord≡→≡ (sym s) | |
66 lemma1 {x} {y} eq | case2 s = ord≡→≡ (sym s) | |
67 lemma4 : {x y z : OD } → ( x , y ) == ( x , z ) → y ≡ z | |
68 lemma4 {x} {y} {z} eq with eq← eq {od→ord z} (case2 refl) | |
69 lemma4 {x} {y} {z} eq | case1 s with ord≡→≡ s -- x ≡ z | |
70 ... | refl with lemma2 (==-sym eq ) | |
71 ... | refl = refl | |
72 lemma4 {x} {y} {z} eq | case2 s = ord≡→≡ (sym s) -- y ≡ z | |
73 lemmax : x ≡ x' | |
74 lemmax with eq→ eq {od→ord (x , x)} (case1 refl) | |
75 lemmax | case1 s = lemma1 (ord→== s ) -- (x,x)≡(x',x') | |
76 lemmax | case2 s with lemma2 (ord→== s ) -- (x,x)≡(x',y') with x'≡y' | |
77 ... | refl = lemma1 (ord→== s ) | |
78 lemmay : y ≡ y' | |
79 lemmay with lemmax | |
80 ... | refl with lemma4 eq -- with (x,y)≡(x,y') | |
81 ... | eq1 = lemma4 (ord→== (cong (λ k → od→ord k ) eq1 )) | |
82 | |
83 data ord-pair : (p : Ordinal) → Set n where | |
84 pair : (x y : Ordinal ) → ord-pair ( od→ord ( < ord→od x , ord→od y > ) ) | |
85 | |
86 ZFProduct : OD | |
87 ZFProduct = record { def = λ x → ord-pair x } | |
88 | |
89 -- open import Relation.Binary.HeterogeneousEquality as HE using (_≅_ ) | |
90 -- eq-pair : { x x' y y' : Ordinal } → x ≡ x' → y ≡ y' → pair x y ≅ pair x' y' | |
91 -- eq-pair refl refl = HE.refl | |
92 | |
93 pi1 : { p : Ordinal } → ord-pair p → Ordinal | |
94 pi1 ( pair x y) = x | |
95 | |
96 π1 : { p : OD } → ZFProduct ∋ p → OD | |
97 π1 lt = ord→od (pi1 lt ) | |
98 | |
99 pi2 : { p : Ordinal } → ord-pair p → Ordinal | |
100 pi2 ( pair x y ) = y | |
101 | |
102 π2 : { p : OD } → ZFProduct ∋ p → OD | |
103 π2 lt = ord→od (pi2 lt ) | |
104 | |
105 op-cons : { ox oy : Ordinal } → ZFProduct ∋ < ord→od ox , ord→od oy > | |
106 op-cons {ox} {oy} = pair ox oy | |
107 | |
108 p-cons : ( x y : OD ) → ZFProduct ∋ < x , y > | |
109 p-cons x y = def-subst {_} {_} {ZFProduct} {od→ord (< x , y >)} (pair (od→ord x) ( od→ord y )) refl ( | |
110 let open ≡-Reasoning in begin | |
111 od→ord < ord→od (od→ord x) , ord→od (od→ord y) > | |
112 ≡⟨ cong₂ (λ j k → od→ord < j , k >) oiso oiso ⟩ | |
113 od→ord < x , y > | |
114 ∎ ) | |
115 | |
116 op-iso : { op : Ordinal } → (q : ord-pair op ) → od→ord < ord→od (pi1 q) , ord→od (pi2 q) > ≡ op | |
117 op-iso (pair ox oy) = refl | |
118 | |
119 p-iso : { x : OD } → (p : ZFProduct ∋ x ) → < π1 p , π2 p > ≡ x | |
120 p-iso {x} p = ord≡→≡ (op-iso p) | |
121 | |
122 p-pi1 : { x y : OD } → (p : ZFProduct ∋ < x , y > ) → π1 p ≡ x | |
123 p-pi1 {x} {y} p = proj1 ( prod-eq ( ord→== (op-iso p) )) | |
124 | |
125 p-pi2 : { x y : OD } → (p : ZFProduct ∋ < x , y > ) → π2 p ≡ y | |
126 p-pi2 {x} {y} p = proj2 ( prod-eq ( ord→== (op-iso p))) | |
127 |