annotate src/HyperReal.agda @ 7:a9fc3ece852a

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 03 Jul 2021 14:27:01 +0900
parents b7c2a67befdf
children e423b498f3fe
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 module HyperReal where
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 open import Data.Nat
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 open import Data.Nat.Properties
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 open import Data.Empty
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 open import Relation.Nullary using (¬_; Dec; yes; no)
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 open import Level renaming ( suc to succ ; zero to Zero )
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 open import Relation.Binary.PropositionalEquality hiding ( [_] )
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 open import Relation.Binary.Definitions
3
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
10 open import Function.Bijection
4
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 3
diff changeset
11 open import Relation.Binary.Structures
1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
12 open import nat
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
13 open import logic
0
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14
1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
15 HyperNat : Set
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
16 HyperNat = ℕ → ℕ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
17
5
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
18 record IsoN : Set where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
19 field
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
20 m→ m← : ℕ → ℕ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
21 id→← : (i : ℕ) → m→ (m← i ) ≡ i
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
22 id←→ : (i : ℕ) → m← (m→ i ) ≡ i
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
23
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
24 open IsoN
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
25
2
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
26 record NxN : Set where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
27 field
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
28 nxn→n : ℕ ∧ ℕ → ℕ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
29 n→nxn : ℕ → ℕ ∧ ℕ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
30 nn-id : (i j : ℕ) → n→nxn (nxn→n ⟪ i , j ⟫ ) ≡ ⟪ i , j ⟫
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
31 n-id : (i : ℕ) → nxn→n (n→nxn i ) ≡ i
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
32
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
33 open _∧_
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
34
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
35 nxn : NxN
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
36 nxn = record {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
37 nxn→n = λ p → nxn→n (proj1 p) (proj2 p)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
38 ; n→nxn = n→nxn
6
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
39 ; nn-id = nn-id
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
40 ; n-id = n-id
2
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
41 } where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
42 nxn→n : ℕ → ℕ → ℕ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
43 nxn→n zero zero = zero
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
44 nxn→n zero (suc j) = j + suc (nxn→n zero j)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
45 nxn→n (suc i) zero = suc i + suc (nxn→n i zero)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
46 nxn→n (suc i) (suc j) = suc i + suc j + suc (nxn→n i (suc j))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
47 n→nxn : ℕ → ℕ ∧ ℕ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
48 n→nxn zero = ⟪ 0 , 0 ⟫
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
49 n→nxn (suc i) with n→nxn i
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
50 ... | ⟪ x , zero ⟫ = ⟪ zero , suc x ⟫
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
51 ... | ⟪ x , suc y ⟫ = ⟪ suc x , y ⟫
6
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
52 nid1 : (i : ℕ) → 0 < proj2 ( n→nxn i) → n→nxn (suc i) ≡ ⟪ suc (proj1 ( n→nxn i )) , pred ( proj2 ( n→nxn i )) ⟫
7
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
53 nid1 (suc i) 0<p2 with n→nxn (suc i)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
54 ... | ⟪ x , zero ⟫ = ⊥-elim ( nat-≤> 0<p2 a<sa )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
55 ... | ⟪ x , suc y ⟫ = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
56 nid4 : {i j : ℕ} → i + 1 + j ≡ i + suc j
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
57 nid4 {zero} {j} = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
58 nid4 {suc i} {j} = cong suc (nid4 {i} {j} )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
59 nid5 : {i j k : ℕ} → i + suc (suc j) + suc k ≡ i + suc j + suc (suc k )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
60 nid5 {zero} {j} {k} = begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
61 suc (suc j) + suc k ≡⟨ +-assoc 1 (suc j) _ ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
62 1 + (suc j + suc k) ≡⟨ +-comm 1 _ ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
63 (suc j + suc k) + 1 ≡⟨ +-assoc (suc j) (suc k) _ ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
64 suc j + (suc k + 1) ≡⟨ cong (λ k → suc j + k ) (+-comm (suc k) 1) ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
65 suc j + suc (suc k) ∎ where open ≡-Reasoning
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
66 nid5 {suc i} {j} {k} = cong suc (nid5 {i} {j} {k} )
6
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
67 nid2 : (i j : ℕ) → suc (nxn→n i (suc j)) ≡ nxn→n (suc i) j
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
68 nid2 zero zero = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
69 nid2 zero (suc j) = refl
7
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
70 nid2 (suc i) zero = begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
71 suc (nxn→n (suc i) 1) ≡⟨ refl ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
72 suc (suc (i + 1 + suc (nxn→n i 1))) ≡⟨ cong (λ k → suc (suc k)) nid4 ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
73 suc (suc (i + suc (suc (nxn→n i 1)))) ≡⟨ cong (λ k → suc (suc (i + suc (suc k)))) (nid3 i) ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
74 suc (suc (i + suc (suc (i + suc (nxn→n i 0))))) ≡⟨ refl ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
75 nxn→n (suc (suc i)) zero ∎ where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
76 open ≡-Reasoning
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
77 nid3 : (i : ℕ) → nxn→n i 1 ≡ i + suc (nxn→n i 0)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
78 nid3 zero = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
79 nid3 (suc i) = begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
80 suc (i + 1 + suc (nxn→n i 1)) ≡⟨ cong suc nid4 ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
81 suc (i + suc (suc (nxn→n i 1))) ≡⟨ cong (λ k → suc (i + suc (suc k))) (nid3 i) ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
82 suc (i + suc (suc (i + suc (nxn→n i 0))))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
83
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
84 nid2 (suc i) (suc j) = begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
85 suc (nxn→n (suc i) (suc (suc j))) ≡⟨ refl ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
86 suc (suc (i + suc (suc j) + suc (nxn→n i (suc (suc j))))) ≡⟨ cong (λ k → suc (suc (i + suc (suc j) + k))) (nid2 i (suc j)) ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
87 suc (suc (i + suc (suc j) + suc (i + suc j + suc (nxn→n i (suc j))))) ≡⟨ cong ( λ k → suc (suc k)) nid5 ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
88 suc (suc (i + suc j + suc (suc (i + suc j + suc (nxn→n i (suc j)))))) ≡⟨ refl ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
89 nxn→n (suc (suc i)) (suc j) ∎ where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
90 open ≡-Reasoning
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
91 nid6 : {i : ℕ } → 0 < i → suc (pred i) ≡ i
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
92 nid6 {suc i} 0<i = refl
6
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
93 n-id : (i : ℕ) → nxn→n (proj1 (n→nxn i)) (proj2 (n→nxn i)) ≡ i
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
94 n-id 0 = refl
7
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
95 n-id (suc i) with proj2 (n→nxn (suc i)) | inspect proj2 (n→nxn (suc i))
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
96 ... | zero | record { eq = eq } = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
97 ... | suc x | record { eq = eq } with proj2 (n→nxn i) | inspect proj2 (n→nxn i)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
98 ... | zero | record { eq = eqy } = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
99 ... | suc y | record { eq = eqy } = begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
100 nxn→n (proj1 (n→nxn (suc i))) (suc x) ≡⟨ cong (λ k → nxn→n (proj1 k) (suc x)) (nid1 i nid7 ) ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
101 nxn→n (suc (proj1 (n→nxn i))) (suc x) ≡⟨ sym (nid2 (proj1 (n→nxn i)) (suc x) ) ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
102 suc (nxn→n (proj1 (n→nxn i)) (suc (suc x))) ≡⟨ cong (λ k → suc (nxn→n (proj1 (n→nxn i)) (suc k))) (sym eq) ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
103 suc (nxn→n (proj1 (n→nxn i)) (suc (proj2 (n→nxn (suc i))))) ≡⟨ cong (λ k → suc (nxn→n (proj1 (n→nxn i)) k)) ( begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
104 suc (proj2 (n→nxn (suc i))) ≡⟨ cong suc (cong proj2 (nid1 i nid7)) ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
105 suc (pred (proj2 (n→nxn i))) ≡⟨ nid6 nid7 ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
106 proj2 (n→nxn i) ∎ )⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
107 suc (nxn→n (proj1 (n→nxn i)) (proj2 (n→nxn i))) ≡⟨ cong suc (n-id i) ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
108 suc i ∎ where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
109 open ≡-Reasoning
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
110 nid7 : 0 < proj2 (n→nxn i)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
111 nid7 = subst (λ k → 0 < k ) (sym eqy) (s≤s z≤n)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
112 nid8 : suc (proj2 (n→nxn (suc i))) ≡ proj2 (n→nxn i)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
113 nid8 = begin
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
114 suc (proj2 (n→nxn (suc i))) ≡⟨ cong suc (cong proj2 (nid1 i nid7 )) ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
115 suc (pred (proj2 (n→nxn i))) ≡⟨ nid6 nid7 ⟩
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
116 proj2 (n→nxn i) ∎
6
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
117 f : (i : ℕ) → Set
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
118 f i = n→nxn (suc i) ≡ ⟪ suc (proj1 ( n→nxn i )) , pred ( proj2 ( n→nxn i )) ⟫
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
119 g : (i j : ℕ) → Set
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
120 g i j = suc (nxn→n i (suc j)) ≡ nxn→n (suc i) j
2
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
121 nn-id : (i j : ℕ) → n→nxn (nxn→n i j) ≡ ⟪ i , j ⟫
6
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
122 nn-id = {!!}
2
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
123
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
124 open NxN
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
125
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
126 n1 : ℕ → ℕ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
127 n1 n = proj1 (n→nxn nxn n)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
128
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
129 n2 : ℕ → ℕ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
130 n2 n = proj2 (n→nxn nxn n)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
131
1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
132 _n*_ : (i j : HyperNat ) → HyperNat
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
133
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
134 _n+_ : (i j : HyperNat ) → HyperNat
2
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
135 i n+ j = λ k → i (n1 k) + j (n2 k)
1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
136
2
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
137 i n* j = λ k → i (n1 k) * j (n2 k)
1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
138
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
139 hzero : HyperNat
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
140 hzero _ = 0
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
141
5
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
142 record _n=_ (i j : HyperNat ) : Set where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
143 field
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
144 =-map : IsoN
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
145 =-m : ℕ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
146 is-n= : (k : ℕ ) → k > =-m → i k ≡ j (m→ =-map k)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
147
3
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
148 --
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
149 --
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
150 record _n≤_ (i j : HyperNat ) : Set where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
151 field
5
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
152 ≤-map : IsoN
3
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
153 ≤-m : ℕ
5
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
154 is-n≤ : (k : ℕ ) → k > ≤-m → i k ≤ j (m→ ≤-map k)
2
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
155
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
156 postulate
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
157 _cmpn_ : ( i j : HyperNat ) → Dec ( i n≤ j )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
158
5
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
159 HNTotalOrder : IsTotalPreorder _n=_ _n≤_
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
160 HNTotalOrder = record {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
161 isPreorder = record {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
162 isEquivalence = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
163 ; reflexive = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
164 ; trans = {!!} }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
165 ; total = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
166 }
4
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 3
diff changeset
167
2
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
168
1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
169 data HyperZ : Set where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
170 hz : HyperNat → HyperNat → HyperZ
0
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
171
1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
172 _z*_ : (i j : HyperZ ) → HyperZ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
173
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
174 _z+_ : (i j : HyperZ ) → HyperZ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
175 hz i i₁ z+ hz j j₁ = hz ( i n+ j ) (i₁ n+ j₁ )
0
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
176
1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
177 -- ( i - i₁ ) * ( j - j₁ ) = i * j + i₁ * j₁ - i * j₁ - i₁ * j
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
178 hz i i₁ z* hz j j₁ = hz (λ k → i k * j k + i₁ k * j₁ k ) (λ k → i k * j₁ k - i₁ k * j k )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
179
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
180 HNzero : HyperNat → Set
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
181 HNzero i = ( k : ℕ ) → i k ≡ 0
0
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
182
5
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
183 _z=_ : (i j : HyperZ ) → Set
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
184 _z=_ = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
185
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
186 _z≤_ : (i j : HyperZ ) → Set
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
187 _z≤_ = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
188
2
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
189 ≤→= : {i j : ℕ} → i ≤ j → j ≤ i → i ≡ j
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
190 ≤→= {0} {0} z≤n z≤n = refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
191 ≤→= {suc i} {suc j} (s≤s i<j) (s≤s j<i) = cong suc ( ≤→= {i} {j} i<j j<i )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
192
4
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 3
diff changeset
193
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 3
diff changeset
194
1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
195 HNzero? : ( i : HyperNat ) → Dec (HNzero i)
2
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
196 HNzero? i with i cmpn hzero | hzero cmpn i
3
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
197 ... | no s | t = no (λ n → s {!!}) -- (k₁ : ℕ) → i k₁ ≡ 0 → i k ≤ 0
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
198 ... | s | no t = no (λ n → t {!!})
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 2
diff changeset
199 ... | yes s | yes t = yes (λ k → {!!} )
2
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
200
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
201 record HNzeroK ( x : HyperNat ) : Set where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
202 field
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
203 nonzero : ℕ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
204 isNonzero : ¬ ( x nonzero ≡ 0 )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
205
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
206 postulate
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
207 HNnzerok : (x : HyperNat ) → ¬ ( HNzero x ) → HNzeroK x
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
208
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
209 import Axiom.Extensionality.Propositional
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
210 postulate f-extensionality : { n m : Level} → Axiom.Extensionality.Propositional.Extensionality n m
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
211
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
212 m*n=0⇒m=0∨n=0 : {i j : ℕ} → i * j ≡ 0 → (i ≡ 0) ∨ ( j ≡ 0 )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
213 m*n=0⇒m=0∨n=0 {zero} {j} refl = case1 refl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
214 m*n=0⇒m=0∨n=0 {suc i} {zero} eq = case2 refl
0
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
215
1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
216 HNnzero* : {x y : HyperNat } → ¬ ( HNzero x ) → ¬ ( HNzero y ) → ¬ ( HNzero (x n* y) )
2
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
217 HNnzero* {x} {y} nzx nzy nzx*y with HNnzerok x nzx | HNnzerok y nzy
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
218 ... | s | t = {!!} where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
219 hnz0 : ( k : ℕ ) → x k * y k ≡ 0 → (x k ≡ 0) ∨ (y k ≡ 0)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
220 hnz0 k x*y = m*n=0⇒m=0∨n=0 x*y
0
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
221
1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
222
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
223 HZzero : HyperZ → Set
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
224 HZzero (hz i j ) = ( k : ℕ ) → i k ≡ j k
0
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
225
1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
226 HZzero? : ( i : HyperZ ) → Dec (HZzero i)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
227 HZzero? = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
228
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
229 data HyperR : Set where
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
230 hr : HyperZ → (k : HyperNat ) → ¬ HNzero k → HyperR
0
8c492c69514c HyperReal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
231
1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
232 HZnzero* : {x y : HyperZ } → ¬ ( HZzero x ) → ¬ ( HZzero y ) → ¬ ( HZzero (x z* y) )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
233 HZnzero* {x} {y} nzx nzy nzx*y with HZzero? x | HZzero? y
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
234 ... | yes t | s = ⊥-elim ( nzx t )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
235 ... | t | yes s = ⊥-elim ( nzy s )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
236 ... | no t | no s = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
237
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
238 HRzero : HyperR → Set
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
239 HRzero (hr i j nz ) = HZzero i
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
240
5
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
241 _h=_ : (i j : HyperR ) → Set
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
242 _h=_ = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
243
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
244 _h≤_ : (i j : HyperR ) → Set
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
245 _h≤_ = {!!}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
246
1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
247 _h*_ : (i j : HyperR) → HyperR
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
248
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
249 _h+_ : (i j : HyperR) → HyperR
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
250 hr x k nz h+ hr y k₁ nz₁ = hr ( (x z* (hz k hzero)) z+ (y z* (hz k₁ hzero)) ) (k n* k₁) (HNnzero* nz nz₁)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
251
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
252 hr x k nz h* hr y k₁ nz₁ = hr ( x z* y ) ( k n* k₁ ) (HNnzero* nz nz₁)