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

Commit 8489972

Browse files
urkudjcommelin
andcommitted
feat(data/complex/module): ![1, I] is a basis of C over R (#4713)
Co-authored-by: Johan Commelin <johan@commelin.net>
1 parent cf551ee commit 8489972

File tree

2 files changed

+66
-9
lines changed

2 files changed

+66
-9
lines changed

src/data/complex/module.lean

Lines changed: 58 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Alexander Bentkamp, Sébastien Gouëzel
55
-/
66
import data.complex.basic
7-
import algebra.algebra.basic
7+
import data.matrix.notation
8+
import field_theory.tower
9+
import linear_algebra.finite_dimensional
810

911
/-!
1012
# Complex number as a vector space over `ℝ`
1113
1214
This file contains three instances:
1315
* `ℂ` is an `ℝ` algebra;
1416
* any complex vector space is a real vector space;
17+
* any finite dimensional complex vector space is a finite dimesional real vector space;
1518
* the space of `ℝ`-linear maps from a real vector space to a complex vector space is a complex
1619
vector space.
1720
@@ -30,41 +33,88 @@ namespace complex
3033

3134
instance algebra_over_reals : algebra ℝ ℂ := (complex.of_real).to_algebra
3235

36+
@[simp] lemma coe_algebra_map : ⇑(algebra_map ℝ ℂ) = complex.of_real := rfl
37+
38+
@[simp] lemma re_smul (a : ℝ) (z : ℂ) : re (a • z) = a * re z := by simp [algebra.smul_def]
39+
40+
@[simp] lemma im_smul (a : ℝ) (z : ℂ) : im (a • z) = a * im z := by simp [algebra.smul_def]
41+
42+
open submodule finite_dimensional
43+
44+
lemma is_basis_one_I : is_basis ℝ ![1, I] :=
45+
begin
46+
refine ⟨linear_independent_fin2.2 ⟨I_ne_zero, λ a, mt (congr_arg re) $ by simp⟩,
47+
eq_top_iff'.2 $ λ z, _⟩,
48+
suffices : ∃ a b, z = a • I + b • 1,
49+
by simpa [mem_span_insert, mem_span_singleton, -set.singleton_one],
50+
use [z.im, z.re],
51+
simp [algebra.smul_def, add_comm]
52+
end
53+
54+
instance : finite_dimensional ℝ ℂ := of_fintype_basis is_basis_one_I
55+
56+
@[simp] lemma findim_real_complex : finite_dimensional.findim ℝ ℂ = 2 :=
57+
by rw [findim_eq_card_basis is_basis_one_I, fintype.card_fin]
58+
59+
@[simp] lemma dim_real_complex : vector_space.dim ℝ ℂ = 2 :=
60+
by simp [← findim_eq_dim, findim_real_complex]
61+
62+
lemma {u} dim_real_complex' : cardinal.lift.{0 u} (vector_space.dim ℝ ℂ) = 2 :=
63+
by simp [← findim_eq_dim, findim_real_complex, bit0]
64+
3365
end complex
3466

3567
/- Register as an instance (with low priority) the fact that a complex vector space is also a real
3668
vector space. -/
69+
@[priority 900]
3770
instance module.complex_to_real (E : Type*) [add_comm_group E] [module ℂ E] : module ℝ E :=
3871
semimodule.restrict_scalars' ℝ ℂ E
39-
attribute [instance, priority 900] module.complex_to_real
72+
73+
instance module.real_complex_tower (E : Type*) [add_comm_group E] [module ℂ E] :
74+
is_scalar_tower ℝ ℂ E :=
75+
semimodule.restrict_scalars.is_scalar_tower ℝ
4076

4177
instance (E : Type*) [add_comm_group E] [module ℝ E]
4278
(F : Type*) [add_comm_group F] [module ℂ F] : module ℂ (E →ₗ[ℝ] F) :=
4379
linear_map.module_extend_scalars _ _ _ _
4480

81+
@[priority 100]
82+
instance finite_dimensional.complex_to_real (E : Type*) [add_comm_group E] [module ℂ E]
83+
[finite_dimensional ℂ E] : finite_dimensional ℝ E :=
84+
finite_dimensional.trans ℝ ℂ E
85+
86+
lemma dim_real_of_complex (E : Type*) [add_comm_group E] [module ℂ E] :
87+
vector_space.dim ℝ E = 2 * vector_space.dim ℂ E :=
88+
cardinal.lift_inj.1 $
89+
by { rw [← dim_mul_dim' ℝ ℂ E, complex.dim_real_complex], simp [bit0] }
90+
91+
lemma findim_real_of_complex (E : Type*) [add_comm_group E] [module ℂ E] :
92+
finite_dimensional.findim ℝ E = 2 * finite_dimensional.findim ℂ E :=
93+
by rw [← finite_dimensional.findim_mul_findim ℝ ℂ E, complex.findim_real_complex]
94+
4595
namespace complex
4696

4797
/-- Linear map version of the real part function, from `ℂ` to `ℝ`. -/
4898
def linear_map.re : ℂ →ₗ[ℝ] ℝ :=
4999
{ to_fun := λx, x.re,
50-
map_add' := by simp,
51-
map_smul' := λc x, by { change ((c : ℂ) * x).re = c * x.re, simp } }
100+
map_add' := add_re,
101+
map_smul' := re_smul }
52102

53103
@[simp] lemma linear_map.coe_re : ⇑linear_map.re = re := rfl
54104

55105
/-- Linear map version of the imaginary part function, from `ℂ` to `ℝ`. -/
56106
def linear_map.im : ℂ →ₗ[ℝ] ℝ :=
57107
{ to_fun := λx, x.im,
58-
map_add' := by simp,
59-
map_smul' := λc x, by { change ((c : ℂ) * x).im = c * x.im, simp } }
108+
map_add' := add_im,
109+
map_smul' := im_smul }
60110

61111
@[simp] lemma linear_map.coe_im : ⇑linear_map.im = im := rfl
62112

63113
/-- Linear map version of the canonical embedding of `ℝ` in `ℂ`. -/
64114
def linear_map.of_real : ℝ →ₗ[ℝ] ℂ :=
65115
{ to_fun := coe,
66-
map_add' := by simp,
67-
map_smul' := λc x, by { simp, refl } }
116+
map_add' := of_real_add,
117+
map_smul' := λc x, by simp [algebra.smul_def] }
68118

69119
@[simp] lemma linear_map.coe_of_real : ⇑linear_map.of_real = coe := rfl
70120

src/data/matrix/notation.lean

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,14 @@ by { ext, simp [vec_tail] }
115115

116116
@[simp] lemma cons_head_tail (u : fin m.succ → α) :
117117
vec_cons (vec_head u) (vec_tail u) = u :=
118-
by { ext i, refine fin.cases _ _ i; simp [vec_head, vec_tail] }
118+
fin.cons_self_tail _
119+
120+
@[simp] lemma range_cons (x : α) (u : fin n → α) :
121+
set.range (vec_cons x u) = {x} ∪ set.range u :=
122+
set.ext $ λ y, by simp [fin.exists_fin_succ, eq_comm]
123+
124+
@[simp] lemma range_empty (u : fin 0 → α) : set.range u = ∅ :=
125+
set.range_eq_empty.2 $ λ ⟨k⟩, k.elim0
119126

120127
/-- `![a, b, ...] 1` is equal to `b`.
121128

0 commit comments

Comments
 (0)