Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 24f7dbd

Browse files
committed
feat(analysis/quaternion): add complete_space, module.free, and module.finite instances (#18347)
The main trick here is showing that the quaternions are in isometric equivalence with 4D euclidean space.
1 parent a758986 commit 24f7dbd

File tree

2 files changed

+109
-7
lines changed

2 files changed

+109
-7
lines changed

src/algebra/quaternion.lean

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Yury Kudryashov
55
-/
66
import algebra.algebra.equiv
7+
import linear_algebra.finrank
8+
import linear_algebra.free_module.basic
9+
import linear_algebra.free_module.finite.basic
710
import set_theory.cardinal.ordinal
811
import tactic.ring_exp
912

@@ -65,6 +68,17 @@ def equiv_prod {R : Type*} (c₁ c₂ : R) : ℍ[R, c₁, c₂] ≃ R × R × R
6568
left_inv := λ ⟨a₁, a₂, a₃, a₄⟩, rfl,
6669
right_inv := λ ⟨a₁, a₂, a₃, a₄⟩, rfl }
6770

71+
/-- The equivalence between a quaternion algebra over `R` and `fin 4 → R`. -/
72+
@[simps symm_apply]
73+
def equiv_tuple {R : Type*} (c₁ c₂ : R) : ℍ[R, c₁, c₂] ≃ (fin 4 → R) :=
74+
{ to_fun := λ a, ![a.1, a.2, a.3, a.4],
75+
inv_fun := λ a, ⟨a 0, a 1, a 2, a 3⟩,
76+
left_inv := λ ⟨a₁, a₂, a₃, a₄⟩, rfl,
77+
right_inv := λ f, by ext ⟨_, _|_|_|_|_|⟨⟩⟩; refl }
78+
79+
@[simp] lemma equiv_tuple_apply {R : Type*} (c₁ c₂ : R) (x : ℍ[R, c₁, c₂]) :
80+
equiv_tuple c₁ c₂ x = ![x.re, x.im_i, x.im_j, x.im_k] := rfl
81+
6882
@[simp] lemma mk.eta {R : Type*} {c₁ c₂} : ∀ a : ℍ[R, c₁, c₂], mk a.1 a.2 a.3 a.4 = a
6983
| ⟨a₁, a₂, a₃, a₄⟩ := rfl
7084

@@ -191,7 +205,7 @@ instance : algebra R ℍ[R, c₁, c₂] :=
191205
lemma algebra_map_eq (r : R) : algebra_map R ℍ[R,c₁,c₂] r = ⟨r, 0, 0, 0⟩ := rfl
192206

193207
section
194-
variables (R c₁ c₂)
208+
variables (c₁ c₂)
195209

196210
/-- `quaternion_algebra.re` as a `linear_map`-/
197211
@[simps] def re_lm : ℍ[R, c₁, c₂] →ₗ[R] R :=
@@ -209,6 +223,37 @@ variables (R c₁ c₂)
209223
@[simps] def im_k_lm : ℍ[R, c₁, c₂] →ₗ[R] R :=
210224
{ to_fun := im_k, map_add' := λ x y, rfl, map_smul' := λ r x, rfl }
211225

226+
/-- `quaternion_algebra.equiv_tuple` as a linear equivalence. -/
227+
def linear_equiv_tuple : ℍ[R,c₁,c₂] ≃ₗ[R] (fin 4 → R) :=
228+
linear_equiv.symm -- proofs are not `rfl` in the forward direction
229+
{ to_fun := (equiv_tuple c₁ c₂).symm,
230+
inv_fun := equiv_tuple c₁ c₂,
231+
map_add' := λ v₁ v₂, rfl,
232+
map_smul' := λ v₁ v₂, rfl,
233+
.. (equiv_tuple c₁ c₂).symm }
234+
235+
@[simp] lemma coe_linear_equiv_tuple : ⇑(linear_equiv_tuple c₁ c₂) = equiv_tuple c₁ c₂ := rfl
236+
@[simp] lemma coe_linear_equiv_tuple_symm :
237+
⇑(linear_equiv_tuple c₁ c₂).symm = (equiv_tuple c₁ c₂).symm := rfl
238+
239+
/-- `ℍ[R, c₁, c₂]` has a basis over `R` given by `1`, `i`, `j`, and `k`. -/
240+
noncomputable def basis_one_i_j_k : basis (fin 4) R ℍ[R, c₁, c₂] :=
241+
basis.of_equiv_fun $ linear_equiv_tuple c₁ c₂
242+
243+
@[simp] lemma coe_basis_one_i_j_k_repr (q : ℍ[R, c₁, c₂]) :
244+
⇑((basis_one_i_j_k c₁ c₂).repr q) = ![q.re, q.im_i, q.im_j, q.im_k] := rfl
245+
246+
instance : module.finite R ℍ[R, c₁, c₂] := module.finite.of_basis (basis_one_i_j_k c₁ c₂)
247+
instance : module.free R ℍ[R, c₁, c₂] := module.free.of_basis (basis_one_i_j_k c₁ c₂)
248+
249+
lemma dim_eq_four [strong_rank_condition R] : module.rank R ℍ[R, c₁, c₂] = 4 :=
250+
by { rw [dim_eq_card_basis (basis_one_i_j_k c₁ c₂), fintype.card_fin], norm_num }
251+
252+
lemma finrank_eq_four [strong_rank_condition R] : finite_dimensional.finrank R ℍ[R, c₁, c₂] = 4 :=
253+
have cardinal.to_nat 4 = 4,
254+
by rw [←cardinal.to_nat_cast 4, nat.cast_bit0, nat.cast_bit0, nat.cast_one],
255+
by rw [finite_dimensional.finrank, dim_eq_four, this]
256+
212257
end
213258

214259
@[norm_cast, simp] lemma coe_sub : ((x - y : R) : ℍ[R, c₁, c₂]) = x - y :=
@@ -344,10 +389,19 @@ def quaternion (R : Type*) [has_one R] [has_neg R] := quaternion_algebra R (-1)
344389

345390
localized "notation (name := quaternion) `ℍ[` R `]` := quaternion R" in quaternion
346391

347-
/-- The equivalence between the quaternions over R and R × R × R × R. -/
392+
/-- The equivalence between the quaternions over `R` and `R × R × R × R`. -/
393+
@[simps]
348394
def quaternion.equiv_prod (R : Type*) [has_one R] [has_neg R] : ℍ[R] ≃ R × R × R × R :=
349395
quaternion_algebra.equiv_prod _ _
350396

397+
/-- The equivalence between the quaternions over `R` and `fin 4 → R`. -/
398+
@[simps symm_apply]
399+
def quaternion.equiv_tuple (R : Type*) [has_one R] [has_neg R] : ℍ[R] ≃ (fin 4 → R) :=
400+
quaternion_algebra.equiv_tuple _ _
401+
402+
@[simp] lemma quaternion.equiv_tuple_apply (R : Type*) [has_one R] [has_neg R] (x : ℍ[R]) :
403+
quaternion.equiv_tuple R x = ![x.re, x.im_i, x.im_j, x.im_k] := rfl
404+
351405
namespace quaternion
352406

353407
variables {R : Type*} [comm_ring R] (r x y z : R) (a b c : ℍ[R])
@@ -445,6 +499,15 @@ lemma mul_coe_eq_smul : a * r = r • a := quaternion_algebra.mul_coe_eq_smul r
445499

446500
lemma smul_coe : x • (y : ℍ[R]) = ↑(x * y) := quaternion_algebra.smul_coe x y
447501

502+
instance : module.finite R ℍ[R] := quaternion_algebra.module.finite _ _
503+
instance : module.free R ℍ[R] := quaternion_algebra.module.free _ _
504+
505+
lemma dim_eq_four [strong_rank_condition R] : module.rank R ℍ[R] = 4 :=
506+
quaternion_algebra.dim_eq_four _ _
507+
508+
lemma finrank_eq_four [strong_rank_condition R] : finite_dimensional.finrank R ℍ[R] = 4 :=
509+
quaternion_algebra.finrank_eq_four _ _
510+
448511
/-- Quaternion conjugate. -/
449512
def conj : ℍ[R] ≃ₗ[R] ℍ[R] := quaternion_algebra.conj
450513

src/analysis/quaternion.lean

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
/-
22
Copyright (c) 2020 Yury Kudryashov. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
4-
Authors: Yury Kudryashov
4+
Authors: Yury Kudryashov, Eric Wieser
55
-/
66
import algebra.quaternion
77
import analysis.inner_product_space.basic
8+
import analysis.inner_product_space.pi_L2
89

910
/-!
1011
# Quaternions as a normed algebra
@@ -15,6 +16,8 @@ In this file we define the following structures on the space `ℍ := ℍ[ℝ]` o
1516
* normed ring;
1617
* normed space over `ℝ`.
1718
19+
We show that the norm on `ℍ[ℝ]` agrees with the euclidean norm of its components.
20+
1821
## Notation
1922
2023
The following notation is available with `open_locale quaternion`:
@@ -29,8 +32,6 @@ quaternion, normed ring, normed space, normed algebra
2932
localized "notation (name := quaternion.real) `ℍ` := quaternion ℝ" in quaternion
3033
open_locale real_inner_product_space
3134

32-
noncomputable theory
33-
3435
namespace quaternion
3536

3637
instance : has_inner ℝ ℍ := ⟨λ a b, (a * b.conj).re⟩
@@ -39,7 +40,7 @@ lemma inner_self (a : ℍ) : ⟪a, a⟫ = norm_sq a := rfl
3940

4041
lemma inner_def (a b : ℍ) : ⟪a, b⟫ = (a * b.conj).re := rfl
4142

42-
instance : inner_product_space ℝ ℍ :=
43+
noncomputable instance : inner_product_space ℝ ℍ :=
4344
inner_product_space.of_core
4445
{ inner := has_inner.inner,
4546
conj_sym := λ x y, by simp [inner_def, mul_comm],
@@ -65,7 +66,7 @@ noncomputable instance : normed_division_ring ℍ :=
6566
norm_mul' := λ a b, by { simp only [norm_eq_sqrt_real_inner, inner_self, norm_sq.map_mul],
6667
exact real.sqrt_mul norm_sq_nonneg _ } }
6768

68-
noncomputable instance : normed_algebra ℝ ℍ :=
69+
instance : normed_algebra ℝ ℍ :=
6970
{ norm_smul_le := λ a x, (norm_smul a x).le,
7071
to_algebra := quaternion.algebra }
7172

@@ -95,4 +96,42 @@ def of_complex : ℂ →ₐ[ℝ] ℍ :=
9596

9697
@[simp] lemma coe_of_complex : ⇑of_complex = coe := rfl
9798

99+
/-- The norm of the components as a euclidean vector equals the norm of the quaternion. -/
100+
lemma norm_pi_Lp_equiv_symm_equiv_tuple (x : ℍ) :
101+
‖(pi_Lp.equiv 2 (λ _ : fin 4, _)).symm (equiv_tuple ℝ x)‖ = ‖x‖ :=
102+
begin
103+
rw [norm_eq_sqrt_real_inner, norm_eq_sqrt_real_inner, inner_self, norm_sq_def', pi_Lp.inner_apply,
104+
fin.sum_univ_four],
105+
simp_rw [is_R_or_C.inner_apply, star_ring_end_apply, star_trivial, ←sq],
106+
refl,
107+
end
108+
109+
/-- `quaternion_algebra.linear_equiv_tuple` as a `linear_isometry_equiv`. -/
110+
@[simps apply symm_apply]
111+
noncomputable def linear_isometry_equiv_tuple : ℍ ≃ₗᵢ[ℝ] euclidean_space ℝ (fin 4) :=
112+
{ to_fun := λ a, (pi_Lp.equiv _ (λ _ : fin 4, _)).symm ![a.1, a.2, a.3, a.4],
113+
inv_fun := λ a, ⟨a 0, a 1, a 2, a 3⟩,
114+
norm_map' := norm_pi_Lp_equiv_symm_equiv_tuple,
115+
..(quaternion_algebra.linear_equiv_tuple (-1 : ℝ) (-1 : ℝ)).trans
116+
(pi_Lp.linear_equiv 2 ℝ (λ _ : fin 4, ℝ)).symm }
117+
118+
@[continuity] lemma continuous_re : continuous (λ q : ℍ, q.re) :=
119+
(continuous_apply 0).comp linear_isometry_equiv_tuple.continuous
120+
121+
@[continuity] lemma continuous_im_i : continuous (λ q : ℍ, q.im_i) :=
122+
(continuous_apply 1).comp linear_isometry_equiv_tuple.continuous
123+
124+
@[continuity] lemma continuous_im_j : continuous (λ q : ℍ, q.im_j) :=
125+
(continuous_apply 2).comp linear_isometry_equiv_tuple.continuous
126+
127+
@[continuity] lemma continuous_im_k : continuous (λ q : ℍ, q.im_k) :=
128+
(continuous_apply 3).comp linear_isometry_equiv_tuple.continuous
129+
130+
instance : complete_space ℍ :=
131+
begin
132+
have : uniform_embedding linear_isometry_equiv_tuple.to_linear_equiv.to_equiv.symm :=
133+
linear_isometry_equiv_tuple.to_continuous_linear_equiv.symm.uniform_embedding,
134+
exact (complete_space_congr this).1 (by apply_instance)
135+
end
136+
98137
end quaternion

0 commit comments

Comments
 (0)