@@ -69,8 +69,9 @@ prove...], so here it is:
6969
7070``` agda
7171Int-is-initial : is-initial (Rings ℓ) Liftℤ
72- Int-is-initial R = contr z→r λ x → ext (lemma x) where
73- module R = Kit R
72+ Int-is-initial = hom-contr→is-initial λ R → contr (z→r R) λ h → ext (lemma R h) where
73+ module _ (R : Ring ℓ) where
74+ module R = Kit R
7475```
7576
7677Note that we treat 1 with care: we could have this map 1 to ` 1r + 0r ` ,
@@ -79,10 +80,10 @@ embedding. This will result in a bit more work right now, but is work
7980worth doing.
8081
8182``` agda
82- e : Nat → ⌞ R ⌟
83- e zero = R.0r
84- e (suc zero) = R.1r
85- e (suc (suc x)) = R.1r R.+ e (suc x)
83+ e : Nat → ⌞ R ⌟
84+ e zero = R.0r
85+ e (suc zero) = R.1r
86+ e (suc (suc x)) = R.1r R.+ e (suc x)
8687```
8788
8889Zero gets sent to zero, and "adding one" gets sent to adding one. Is
@@ -92,32 +93,32 @@ naturals to sums in $R$, and products of naturals to products in $R$.
9293We'll need this later.
9394
9495``` agda
95- e-suc : ∀ n → e (suc n) ≡ R.1r R.+ e n
96- e-add : ∀ m n → e (m Nat.+ n) ≡ e m R.+ e n
97- e-mul : ∀ m n → e (m Nat.* n) ≡ e m R.* e n
96+ e-suc : ∀ n → e (suc n) ≡ R.1r R.+ e n
97+ e-add : ∀ m n → e (m Nat.+ n) ≡ e m R.+ e n
98+ e-mul : ∀ m n → e (m Nat.* n) ≡ e m R.* e n
9899```
99100
100101<!--
101102```agda
102- e-suc zero = sym R.+-idr
103- e-suc (suc n) = refl
104-
105- e-add zero n = sym R.+-idl
106- e-add (suc m) n =
107- e (suc m Nat.+ n) ≡⟨ e-suc (m Nat.+ n) ⟩
108- R.1r R.+ e (m Nat.+ n) ≡⟨ ap (R.1r R.+_) (e-add m n) ⟩
109- R.1r R.+ (e m R.+ e n) ≡⟨ R.+-associative ⟩
110- (R.1r R.+ e m) R.+ e n ≡˘⟨ ap (R._+ e n) (e-suc m) ⟩
111- e (suc m) R.+ e n ∎
112-
113- e-mul zero n = sym R.*-zerol
114- e-mul (suc m) n =
115- e (suc m Nat.* n) ≡⟨ e-add n (m Nat.* n) ⟩
116- e n R.+ e (m Nat.* n) ≡⟨ ap (e n R.+_) (e-mul m n) ⟩
117- e n R.+ e m R.* e n ≡˘⟨ ap (R._+ (e m R.* e n)) R.*-idl ⟩
118- R.1r R.* e n R.+ e m R.* e n ≡˘⟨ R.*-distribr ⟩
119- (R.1r R.+ e m) R.* e n ≡˘⟨ ap (R._* e n) (e-suc m) ⟩
120- (e (suc m) R.* e n) ∎
103+ e-suc zero = sym R.+-idr
104+ e-suc (suc n) = refl
105+
106+ e-add zero n = sym R.+-idl
107+ e-add (suc m) n =
108+ e (suc m Nat.+ n) ≡⟨ e-suc (m Nat.+ n) ⟩
109+ R.1r R.+ e (m Nat.+ n) ≡⟨ ap (R.1r R.+_) (e-add m n) ⟩
110+ R.1r R.+ (e m R.+ e n) ≡⟨ R.+-associative ⟩
111+ (R.1r R.+ e m) R.+ e n ≡˘⟨ ap (R._+ e n) (e-suc m) ⟩
112+ e (suc m) R.+ e n ∎
113+
114+ e-mul zero n = sym R.*-zerol
115+ e-mul (suc m) n =
116+ e (suc m Nat.* n) ≡⟨ e-add n (m Nat.* n) ⟩
117+ e n R.+ e (m Nat.* n) ≡⟨ ap (e n R.+_) (e-mul m n) ⟩
118+ e n R.+ e m R.* e n ≡˘⟨ ap (R._+ (e m R.* e n)) R.*-idl ⟩
119+ R.1r R.* e n R.+ e m R.* e n ≡˘⟨ R.*-distribr ⟩
120+ (R.1r R.+ e m) R.* e n ≡˘⟨ ap (R._* e n) (e-suc m) ⟩
121+ (e (suc m) R.* e n) ∎
121122```
122123-->
123124
@@ -129,13 +130,13 @@ integers, i.e. we need $e(m) - e(n) = e(1 + m) - e(1 + n)$. This is
129130annoying to show, but not _ too_ annoying:
130131
131132``` agda
132- e-tr : ∀ m n → e m R.- e n ≡ e (suc m) R.- e (suc n)
133- e-tr m n = sym $
134- (e (suc m) R.- e (suc n)) ≡⟨ ap₂ R._-_ (e-suc m) (e-suc n) ⟩
135- (R.1r R.+ e m) R.- (R.1r R.+ e n) ≡⟨ ap₂ R._+_ refl (R.a.inv-comm ∙ R.+-commutes) ∙ R.+-associative ⟩
136- R.1r R.+ e m R.+ (R.- R.1r) R.+ (R.- e n) ≡⟨ ap₂ R._+_ (R.pullr R.+-commutes ∙ R.pulll refl) refl ⟩
137- R.1r R.+ (R.- R.1r) R.+ e m R.+ (R.- e n) ≡⟨ ap₂ R._+_ (R.eliml R.+-invr) refl ⟩
138- e m R.- e n ∎
133+ e-tr : ∀ m n → e m R.- e n ≡ e (suc m) R.- e (suc n)
134+ e-tr m n = sym $
135+ (e (suc m) R.- e (suc n)) ≡⟨ ap₂ R._-_ (e-suc m) (e-suc n) ⟩
136+ (R.1r R.+ e m) R.- (R.1r R.+ e n) ≡⟨ ap₂ R._+_ refl (R.a.inv-comm ∙ R.+-commutes) ∙ R.+-associative ⟩
137+ R.1r R.+ e m R.+ (R.- R.1r) R.+ (R.- e n) ≡⟨ ap₂ R._+_ (R.pullr R.+-commutes ∙ R.pulll refl) refl ⟩
138+ R.1r R.+ (R.- R.1r) R.+ e m R.+ (R.- e n) ≡⟨ ap₂ R._+_ (R.eliml R.+-invr) refl ⟩
139+ e m R.- e n ∎
139140```
140141
141142We can now build the embedding $\ZZ \mono R$. It remains to show that
@@ -144,58 +145,58 @@ algebra, so I won't comment on it too much: it can be worked out on
144145paper, following the ring laws.
145146
146147``` agda
147- ℤ↪R : Int → ⌞ R ⌟
148- ℤ↪R (pos x) = e x
149- ℤ↪R (negsuc x) = R.- (e (suc x))
150-
151- open is-ring-hom
152-
153- z-nat-diff : ∀ x y → ℤ↪R (x ℕ- y) ≡ e x R.- e y
154- z-nat-diff x zero = R.intror R.inv-unit
155- z-nat-diff zero (suc y) = R.introl refl
156- z-nat-diff (suc x) (suc y) = z-nat-diff x y ∙ e-tr x y
157-
158- z-add : ∀ x y → ℤ↪R (x +ℤ y) ≡ ℤ↪R x R.+ ℤ↪R y
159- z-add (pos x) (pos y) = e-add x y
160- z-add (pos x) (negsuc y) = z-nat-diff x (suc y)
161- z-add (negsuc x) (pos y) = z-nat-diff y (suc x) ∙ R.+-commutes
162- z-add (negsuc x) (negsuc y) =
163- R.- (e 1 R.+ e (suc x Nat.+ y)) ≡⟨ ap R.-_ (ap₂ R._+_ refl (e-add (suc x) y) ∙ R.extendl R.+-commutes) ⟩
164- R.- (e (suc x) R.+ (e 1 R.+ e y)) ≡⟨ R.a.inv-comm ⟩
165- (R.- (e 1 R.+ e y)) R.+ (R.- e (suc x)) ≡⟨ R.+-commutes ⟩
166- (R.- e (suc x)) R.+ (R.- (e 1 R.+ e y)) ≡⟨ ap₂ R._+_ refl (ap R.-_ (sym (e-add 1 y))) ⟩
167- (R.- e (suc x)) R.+ (R.- e (1 Nat.+ y)) ∎
168-
169- z-mul : ∀ x y → ℤ↪R (x *ℤ y) ≡ ℤ↪R x R.* ℤ↪R y
170- z-mul (pos x) (pos y) =
171- ℤ↪R (assign pos (x Nat.* y)) ≡⟨ ap ℤ↪R (assign-pos (x Nat.* y)) ⟩
172- e (x Nat.* y) ≡⟨ e-mul x y ⟩
173- (e x R.* e y) ∎
174- z-mul (posz) (negsuc y) = sym R.*-zerol
175- z-mul (possuc x) (negsuc y) =
176- R.- e (suc x Nat.* suc y) ≡⟨ ap R.-_ (e-mul (suc x) (suc y)) ⟩
177- R.- (e (suc x) R.* e (suc y)) ≡˘⟨ R.*-negater ⟩
178- e (suc x) R.* (R.- e (suc y)) ∎
179- z-mul (negsuc x) (posz) =
180- ℤ↪R (assign neg (x Nat.* 0)) ≡⟨ ap ℤ↪R (ap (assign neg) (Nat.*-zeror x)) ⟩
181- ℤ↪R 0 ≡⟨ sym R.*-zeror ⟩
182- ℤ↪R (negsuc x) R.* R.0r ∎
183- z-mul (negsuc x) (possuc y) =
184- R.- e (suc x Nat.* suc y) ≡⟨ ap R.-_ (e-mul (suc x) (suc y)) ⟩
185- R.- (e (suc x) R.* e (suc y)) ≡⟨ sym R.*-negatel ⟩
186- (R.- e (suc x)) R.* e (suc y) ∎
187- z-mul (negsuc x) (negsuc y) =
188- e (suc x Nat.* suc y) ≡⟨ e-mul (suc x) (suc y) ⟩
189- e (suc x) R.* e (suc y) ≡˘⟨ R.inv-inv ⟩
190- R.- (R.- (e (suc x) R.* e (suc y))) ≡˘⟨ ap R.-_ R.*-negater ⟩
191- R.- (e (suc x) R.* ℤ↪R (negsuc y)) ≡˘⟨ R.*-negatel ⟩
192- ℤ↪R (negsuc x) R.* ℤ↪R (negsuc y) ∎
193-
194- z→r : Rings.Hom Liftℤ R
195- z→r .fst (lift x) = ℤ↪R x
196- z→r .snd .pres-id = refl
197- z→r .snd .pres-+ (lift x) (lift y) = z-add x y
198- z→r .snd .pres-* (lift x) (lift y) = z-mul x y
148+ ℤ↪R : Int → ⌞ R ⌟
149+ ℤ↪R (pos x) = e x
150+ ℤ↪R (negsuc x) = R.- (e (suc x))
151+
152+ open is-ring-hom
153+
154+ z-nat-diff : ∀ x y → ℤ↪R (x ℕ- y) ≡ e x R.- e y
155+ z-nat-diff x zero = R.intror R.inv-unit
156+ z-nat-diff zero (suc y) = R.introl refl
157+ z-nat-diff (suc x) (suc y) = z-nat-diff x y ∙ e-tr x y
158+
159+ z-add : ∀ x y → ℤ↪R (x +ℤ y) ≡ ℤ↪R x R.+ ℤ↪R y
160+ z-add (pos x) (pos y) = e-add x y
161+ z-add (pos x) (negsuc y) = z-nat-diff x (suc y)
162+ z-add (negsuc x) (pos y) = z-nat-diff y (suc x) ∙ R.+-commutes
163+ z-add (negsuc x) (negsuc y) =
164+ R.- (e 1 R.+ e (suc x Nat.+ y)) ≡⟨ ap R.-_ (ap₂ R._+_ refl (e-add (suc x) y) ∙ R.extendl R.+-commutes) ⟩
165+ R.- (e (suc x) R.+ (e 1 R.+ e y)) ≡⟨ R.a.inv-comm ⟩
166+ (R.- (e 1 R.+ e y)) R.+ (R.- e (suc x)) ≡⟨ R.+-commutes ⟩
167+ (R.- e (suc x)) R.+ (R.- (e 1 R.+ e y)) ≡⟨ ap₂ R._+_ refl (ap R.-_ (sym (e-add 1 y))) ⟩
168+ (R.- e (suc x)) R.+ (R.- e (1 Nat.+ y)) ∎
169+
170+ z-mul : ∀ x y → ℤ↪R (x *ℤ y) ≡ ℤ↪R x R.* ℤ↪R y
171+ z-mul (pos x) (pos y) =
172+ ℤ↪R (assign pos (x Nat.* y)) ≡⟨ ap ℤ↪R (assign-pos (x Nat.* y)) ⟩
173+ e (x Nat.* y) ≡⟨ e-mul x y ⟩
174+ (e x R.* e y) ∎
175+ z-mul (posz) (negsuc y) = sym R.*-zerol
176+ z-mul (possuc x) (negsuc y) =
177+ R.- e (suc x Nat.* suc y) ≡⟨ ap R.-_ (e-mul (suc x) (suc y)) ⟩
178+ R.- (e (suc x) R.* e (suc y)) ≡˘⟨ R.*-negater ⟩
179+ e (suc x) R.* (R.- e (suc y)) ∎
180+ z-mul (negsuc x) (posz) =
181+ ℤ↪R (assign neg (x Nat.* 0)) ≡⟨ ap ℤ↪R (ap (assign neg) (Nat.*-zeror x)) ⟩
182+ ℤ↪R 0 ≡⟨ sym R.*-zeror ⟩
183+ ℤ↪R (negsuc x) R.* R.0r ∎
184+ z-mul (negsuc x) (possuc y) =
185+ R.- e (suc x Nat.* suc y) ≡⟨ ap R.-_ (e-mul (suc x) (suc y)) ⟩
186+ R.- (e (suc x) R.* e (suc y)) ≡⟨ sym R.*-negatel ⟩
187+ (R.- e (suc x)) R.* e (suc y) ∎
188+ z-mul (negsuc x) (negsuc y) =
189+ e (suc x Nat.* suc y) ≡⟨ e-mul (suc x) (suc y) ⟩
190+ e (suc x) R.* e (suc y) ≡˘⟨ R.inv-inv ⟩
191+ R.- (R.- (e (suc x) R.* e (suc y))) ≡˘⟨ ap R.-_ R.*-negater ⟩
192+ R.- (e (suc x) R.* ℤ↪R (negsuc y)) ≡˘⟨ R.*-negatel ⟩
193+ ℤ↪R (negsuc x) R.* ℤ↪R (negsuc y) ∎
194+
195+ z→r : Rings.Hom Liftℤ R
196+ z→r .fst (lift x) = ℤ↪R x
197+ z→r .snd .pres-id = refl
198+ z→r .snd .pres-+ (lift x) (lift y) = z-add x y
199+ z→r .snd .pres-* (lift x) (lift y) = z-mul x y
199200```
200201
201202The last thing we must show is that this is the _ unique_ ring
@@ -215,14 +216,14 @@ and that last expression is pretty exactly what our canonical map
215216evaluates to on $n$. So we're done!
216217
217218```agda
218- module _ (f : Rings.Hom Liftℤ R) where
219- private module f = is-ring-hom (f .snd)
219+ module _ (f : Rings.Hom Liftℤ R) where
220+ private module f = is-ring-hom (f .snd)
220221
221- f-pos : ∀ x → e x ≡ f · lift (pos x)
222- f-pos zero = sym f.pres-0
223- f-pos (suc x) = e-suc x ∙ sym (f.pres-+ (lift 1) (lift (pos x)) ∙ ap₂ R._+_ f.pres-id (sym (f-pos x)))
222+ f-pos : ∀ x → e x ≡ f · lift (pos x)
223+ f-pos zero = sym f.pres-0
224+ f-pos (suc x) = e-suc x ∙ sym (f.pres-+ (lift 1) (lift (pos x)) ∙ ap₂ R._+_ f.pres-id (sym (f-pos x)))
224225
225- lemma : ∀ i → z→r · lift i ≡ f · lift i
226- lemma (pos x) = f-pos x
227- lemma (negsuc x) = sym (f.pres-neg {lift (possuc x)} ∙ ap R.-_ (sym (f-pos (suc x))))
226+ lemma : ∀ i → z→r · lift i ≡ f · lift i
227+ lemma (pos x) = f-pos x
228+ lemma (negsuc x) = sym (f.pres-neg {lift (possuc x)} ∙ ap R.-_ (sym (f-pos (suc x))))
228229```
0 commit comments