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

Commit 32b9b21

Browse files
committed
refactor(linear_algebra/pi): add linear_map.single to match add_monoid_hom.single (#6315)
This changes the definition of `std_basis` to be exactly `linear_map.single`, but proves equality with the old definition. In future, it might make sense to remove `std_basis` entirely.
1 parent d483bc2 commit 32b9b21

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

src/linear_algebra/pi.lean

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ It contains theorems relating these to each other, as well as to `linear_map.ker
1515
## Main definitions
1616
1717
- pi types in the codomain:
18-
- `linear_map.proj`
1918
- `linear_map.pi`
19+
- `linear_map.single`
20+
- pi types in the domain:
21+
- `linear_map.proj`
2022
- `linear_map.diag`
2123
2224
-/
@@ -70,6 +72,17 @@ begin
7072
exact (mem_bot _).2 (funext $ assume i, h i)
7173
end
7274

75+
/-- The `linear_map` version of `add_monoid_hom.single` and `pi.single`. -/
76+
@[simps]
77+
def single [decidable_eq ι] (i : ι) : φ i →ₗ[R] (Πi, φ i) :=
78+
{ to_fun := pi.single i,
79+
map_smul' := λ r x, begin
80+
ext i', by_cases h : i' = i,
81+
{ subst h, simp only [pi.single_eq_same, pi.smul_apply], },
82+
{ simp only [h, pi.single_eq_of_ne, ne.def, not_false_iff, pi.smul_apply, smul_zero], },
83+
end,
84+
.. add_monoid_hom.single φ i}
85+
7386
section
7487
variables (R φ)
7588

src/linear_algebra/std_basis.lean

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ variables (R : Type*) {ι : Type*} [semiring R] (φ : ι → Type*)
3939
[Π i, add_comm_monoid (φ i)] [Π i, semimodule R (φ i)] [decidable_eq ι]
4040

4141
/-- The standard basis of the product of `φ`. -/
42-
def std_basis (i : ι) : φ i →ₗ[R] (Πi, φ i) := pi (diag i)
42+
def std_basis : Π (i : ι), φ i →ₗ[R] (Πi, φ i) := single
4343

4444
lemma std_basis_apply (i : ι) (b : φ i) : std_basis R φ i b = update 0 i b :=
45-
by ext j; rw [std_basis, pi_apply, diag, update_apply]; refl
45+
rfl
4646

4747
lemma coe_std_basis (i : ι) : ⇑(std_basis R φ i) = pi.single i :=
4848
funext $ std_basis_apply R φ i
@@ -53,6 +53,13 @@ by rw [std_basis_apply, update_same]
5353
lemma std_basis_ne (i j : ι) (h : j ≠ i) (b : φ i) : std_basis R φ i b j = 0 :=
5454
by rw [std_basis_apply, update_noteq h]; refl
5555

56+
lemma std_basis_eq_pi_diag (i : ι) : std_basis R φ i = pi (diag i) :=
57+
begin
58+
ext x j,
59+
convert (update_apply 0 x i j _).symm,
60+
refl,
61+
end
62+
5663
section ext
5764

5865
variables {R φ} {M : Type*} [fintype ι] [add_comm_monoid M] [semimodule R M]
@@ -84,7 +91,7 @@ ker_eq_bot_of_injective $ assume f g hfg,
8491
by simpa only [std_basis_same]
8592

8693
lemma proj_comp_std_basis (i j : ι) : (proj i).comp (std_basis R φ j) = diag j i :=
87-
by rw [std_basis, proj_pi]
94+
by rw [std_basis_eq_pi_diag, proj_pi]
8895

8996
lemma proj_std_basis_same (i : ι) : (proj i).comp (std_basis R φ i) = id :=
9097
by ext b; simp

src/ring_theory/power_series/basic.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,11 @@ by rw [coeff, monomial, linear_map.proj_apply, linear_map.std_basis_apply, funct
121121

122122
@[simp] lemma coeff_monomial_same (n : σ →₀ ℕ) (a : R) :
123123
coeff R n (monomial R n a) = a :=
124-
linear_map.std_basis_same _ _ _ _
124+
linear_map.std_basis_same R _ n a
125125

126126
lemma coeff_monomial_ne {m n : σ →₀ ℕ} (h : m ≠ n) (a : R) :
127127
coeff R m (monomial R n a) = 0 :=
128-
linear_map.std_basis_ne _ _ _ _ h a
128+
linear_map.std_basis_ne R _ _ _ h a
129129

130130
lemma eq_of_coeff_monomial_ne_zero {m n : σ →₀ ℕ} {a : R} (h : coeff R m (monomial R n a) ≠ 0) :
131131
m = n :=

0 commit comments

Comments
 (0)