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

Commit 9cda1ff

Browse files
committed
fix(data/complex/module): kill a non-defeq diamond (#6760)
`restrict_scalars.semimodule ℝ ℂ ℂ = complex.semimodule` is currently not definitionally true. The PR tweaks the smul definition to make sure that this becomes true. This solves a diamond that appears naturally in https://leanprover.zulipchat.com/#narrow/stream/116395-maths/topic/.60inner_product_space.20.E2.84.9D.20%28euclidean_space.20.F0.9D.95.9C.20n%29.60.3F/near/230780186
1 parent 9893a26 commit 9cda1ff

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/data/complex/module.lean

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,35 +41,37 @@ section
4141

4242
variables [has_scalar R ℝ]
4343

44+
/- The useless `0` multiplication in `smul` is to make sure that
45+
`restrict_scalars.semimodule ℝ ℂ ℂ = complex.semimodule` definitionally. -/
4446
instance : has_scalar R ℂ :=
45-
{ smul := λ r x, ⟨r • x.re, r • x.im⟩ }
47+
{ smul := λ r x, ⟨r • x.re - 0 * x.im, r • x.im + 0 * x.re⟩ }
4648

47-
lemma smul_re (r : R) (z : ℂ) : (r • z).re = r • z.re := rfl
48-
lemma smul_im (r : R) (z : ℂ) : (r • z).im = r • z.im := rfl
49+
lemma smul_re (r : R) (z : ℂ) : (r • z).re = r • z.re := by simp [(•)]
50+
lemma smul_im (r : R) (z : ℂ) : (r • z).im = r • z.im := by simp [(•)]
4951

5052
@[simp] lemma smul_coe {x : ℝ} {z : ℂ} : x • z = x * z :=
5153
by ext; simp [smul_re, smul_im]
5254

5355
end
5456

5557
instance [has_scalar R ℝ] [has_scalar S ℝ] [smul_comm_class R S ℝ] : smul_comm_class R S ℂ :=
56-
{ smul_comm := λ r s x, ext (smul_comm _ _ _) (smul_comm _ _ _) }
58+
{ smul_comm := λ r s x, by ext; simp [smul_re, smul_im, smul_comm] }
5759

5860
instance [has_scalar R S] [has_scalar R ℝ] [has_scalar S ℝ] [is_scalar_tower R S ℝ] :
5961
is_scalar_tower R S ℂ :=
60-
{ smul_assoc := λ r s x, ext (smul_assoc _ _ _) (smul_assoc _ _ _) }
62+
{ smul_assoc := λ r s x, by ext; simp [smul_re, smul_im, smul_assoc] }
6163

6264
instance [monoid R] [mul_action R ℝ] : mul_action R ℂ :=
63-
{ one_smul := λ x, ext (one_smul _ _) (one_smul _ _),
64-
mul_smul := λ r s x, ext (mul_smul _ _ _) (mul_smul _ _ _) }
65+
{ one_smul := λ x, by ext; simp [smul_re, smul_im, one_smul],
66+
mul_smul := λ r s x, by ext; simp [smul_re, smul_im, mul_smul] }
6567

6668
instance [semiring R] [distrib_mul_action R ℝ] : distrib_mul_action R ℂ :=
67-
{ smul_add := λ r x y, ext (smul_add _ _ _) (smul_add _ _ _),
68-
smul_zero := λ r, ext (smul_zero _) (smul_zero _) }
69+
{ smul_add := λ r x y, by ext; simp [smul_re, smul_im, smul_add],
70+
smul_zero := λ r, by ext; simp [smul_re, smul_im, smul_zero] }
6971

7072
instance [semiring R] [semimodule R ℝ] : semimodule R ℂ :=
71-
{ add_smul := λ r s x, ext (add_smul _ _ _) (add_smul _ _ _),
72-
zero_smul := λ r, ext (zero_smul _ _) (zero_smul _ _) }
73+
{ add_smul := λ r s x, by ext; simp [smul_re, smul_im, add_smul],
74+
zero_smul := λ r, by ext; simp [smul_re, smul_im, zero_smul] }
7375

7476
instance [comm_semiring R] [algebra R ℝ] : algebra R ℂ :=
7577
{ smul := (•),

0 commit comments

Comments
 (0)