Skip to content

Commit 2b0dc33

Browse files
committed
feat: drop finite-dimensionality assumption from PerfectPairing.restrictScalarsField (#18940)
1 parent e71723b commit 2b0dc33

File tree

7 files changed

+165
-11
lines changed

7 files changed

+165
-11
lines changed

Mathlib.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3349,6 +3349,7 @@ import Mathlib.LinearAlgebra.LinearIndependent
33493349
import Mathlib.LinearAlgebra.LinearPMap
33503350
import Mathlib.LinearAlgebra.Matrix.AbsoluteValue
33513351
import Mathlib.LinearAlgebra.Matrix.Adjugate
3352+
import Mathlib.LinearAlgebra.Matrix.BaseChange
33523353
import Mathlib.LinearAlgebra.Matrix.Basis
33533354
import Mathlib.LinearAlgebra.Matrix.BilinearForm
33543355
import Mathlib.LinearAlgebra.Matrix.Block

Mathlib/Data/Matrix/Mul.lean

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,18 @@ theorem submatrix_mulVec_equiv [Fintype n] [Fintype o] [NonUnitalNonAssocSemirin
880880
M.submatrix e₁ e₂ *ᵥ v = (M *ᵥ (v ∘ e₂.symm)) ∘ e₁ :=
881881
funext fun _ => Eq.symm (dotProduct_comp_equiv_symm _ _ _)
882882

883+
@[simp]
884+
theorem submatrix_id_mul_left [Fintype n] [Fintype o] [Mul α] [AddCommMonoid α] {p : Type*}
885+
(M : Matrix m n α) (N : Matrix o p α) (e₁ : l → m) (e₂ : n ≃ o) :
886+
M.submatrix e₁ id * N.submatrix e₂ id = M.submatrix e₁ e₂.symm * N := by
887+
ext; simp [mul_apply, ← e₂.bijective.sum_comp]
888+
889+
@[simp]
890+
theorem submatrix_id_mul_right [Fintype n] [Fintype o] [Mul α] [AddCommMonoid α] {p : Type*}
891+
(M : Matrix m n α) (N : Matrix o p α) (e₁ : l → p) (e₂ : o ≃ n) :
892+
M.submatrix id e₂ * N.submatrix id e₁ = M * N.submatrix e₂.symm e₁ := by
893+
ext; simp [mul_apply, ← e₂.bijective.sum_comp]
894+
883895
theorem submatrix_vecMul_equiv [Fintype l] [Fintype m] [NonUnitalNonAssocSemiring α]
884896
(M : Matrix m n α) (v : l → α) (e₁ : l ≃ m) (e₂ : o → n) :
885897
v ᵥ* M.submatrix e₁ e₂ = ((v ∘ e₁.symm) ᵥ* M) ∘ e₂ :=

Mathlib/LinearAlgebra/Dual.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ theorem linearCombination_dualBasis (f : ι →₀ R) (i : ι) :
418418

419419
@[deprecated (since := "2024-08-29")] alias total_dualBasis := linearCombination_dualBasis
420420

421-
theorem dualBasis_repr (l : Dual R M) (i : ι) : b.dualBasis.repr l i = l (b i) := by
421+
@[simp] theorem dualBasis_repr (l : Dual R M) (i : ι) : b.dualBasis.repr l i = l (b i) := by
422422
rw [← linearCombination_dualBasis b, Basis.linearCombination_repr b.dualBasis l]
423423

424424
theorem dualBasis_apply (i : ι) (m : M) : b.dualBasis i m = b.repr m i :=
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/-
2+
Copyright (c) 2024 Oliver Nash. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Oliver Nash
5+
-/
6+
import Mathlib.LinearAlgebra.Matrix.NonsingularInverse
7+
import Mathlib.Algebra.Field.Subfield.Defs
8+
9+
/-!
10+
# Matrices and base change
11+
12+
This file is a home for results about base change for matrices.
13+
14+
## Main results:
15+
* `Matrix.mem_subfield_of_mul_eq_one_of_mem_subfield_right`: if an invertible matrix over `L` takes
16+
values in subfield `K ⊆ L`, then so does its (right) inverse.
17+
* `Matrix.mem_subfield_of_mul_eq_one_of_mem_subfield_left`: if an invertible matrix over `L` takes
18+
values in subfield `K ⊆ L`, then so does its (left) inverse.
19+
20+
-/
21+
22+
namespace Matrix
23+
24+
open scoped Matrix
25+
26+
variable {m n L : Type*} [Fintype m] [Fintype n] [DecidableEq m] [Field L]
27+
(e : m ≃ n) (K : Subfield L) {A : Matrix m n L} {B : Matrix n m L} (hAB : A * B = 1)
28+
29+
include e hAB
30+
31+
lemma mem_subfield_of_mul_eq_one_of_mem_subfield_right
32+
(h_mem : ∀ i j, A i j ∈ K) (i : n) (j : m) :
33+
B i j ∈ K := by
34+
let A' : Matrix m m K := of fun i j ↦ ⟨A.submatrix id e i j, h_mem i (e j)⟩
35+
have hA' : A'.map K.subtype = A.submatrix id e := rfl
36+
have hA : IsUnit A' := by
37+
have h_unit : IsUnit (A.submatrix id e) :=
38+
isUnit_of_right_inverse (B := B.submatrix e id) (by simpa)
39+
have h_det : (A.submatrix id e).det = K.subtype A'.det := by
40+
simp [A', K.subtype.map_det, map, submatrix]
41+
simpa [isUnit_iff_isUnit_det, h_det] using h_unit
42+
obtain ⟨B', hB⟩ := exists_right_inverse_iff_isUnit.mpr hA
43+
suffices (B'.submatrix e.symm id).map K.subtype = B by simp [← this]
44+
replace hB : A * (B'.submatrix e.symm id).map K.subtype = 1 := by
45+
replace hB := congr_arg (fun C ↦ C.map K.subtype) hB
46+
simp_rw [map_mul] at hB
47+
rw [hA', ← e.symm_symm, ← submatrix_id_mul_left] at hB
48+
simpa using hB
49+
classical
50+
simpa [← Matrix.mul_assoc, (mul_eq_one_comm_of_equiv e).mp hAB] using congr_arg (B * ·) hB
51+
52+
lemma mem_subfield_of_mul_eq_one_of_mem_subfield_left
53+
(h_mem : ∀ i j, B i j ∈ K) (i : m) (j : n) :
54+
A i j ∈ K := by
55+
replace hAB : Bᵀ * Aᵀ = 1 := by simpa using congr_arg transpose hAB
56+
rw [← A.transpose_apply]
57+
simp_rw [← B.transpose_apply] at h_mem
58+
exact mem_subfield_of_mul_eq_one_of_mem_subfield_right e K hAB (fun i j ↦ h_mem j i) j i
59+
60+
end Matrix

Mathlib/LinearAlgebra/Matrix/Basis.lean

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,12 @@ theorem Basis.toMatrix_reindex' [DecidableEq ι] [DecidableEq ι'] (b : Basis ι
230230
Matrix.reindex_apply, Matrix.submatrix_apply, Function.comp_apply, e.apply_symm_apply,
231231
Finsupp.mapDomain_equiv_apply]
232232

233+
@[simp]
234+
lemma Basis.toMatrix_mulVec_repr (m : M) :
235+
b'.toMatrix b *ᵥ b.repr m = b'.repr m := by
236+
classical
237+
simp [← LinearMap.toMatrix_id_eq_basis_toMatrix, LinearMap.toMatrix_mulVec_repr]
238+
233239
end Fintype
234240

235241
/-- A generalization of `Basis.toMatrix_self`, in the opposite direction. -/

Mathlib/LinearAlgebra/PerfectPairing.lean

Lines changed: 84 additions & 9 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: Oliver Nash
55
-/
66
import Mathlib.LinearAlgebra.Dual
7+
import Mathlib.LinearAlgebra.Matrix.Basis
8+
import Mathlib.LinearAlgebra.Matrix.BaseChange
9+
import Mathlib.LinearAlgebra.FreeModule.Finite.Matrix
710

811
/-!
912
# Perfect pairings of modules
@@ -21,6 +24,7 @@ to connect 1 and 2.
2124
2225
* `PerfectPairing`
2326
* `PerfectPairing.flip`
27+
* `PerfectPairing.dual`
2428
* `PerfectPairing.toDualLeft`
2529
* `PerfectPairing.toDualRight`
2630
* `PerfectPairing.restrict`
@@ -161,6 +165,11 @@ include p in
161165
theorem reflexive_right : IsReflexive R N :=
162166
p.flip.reflexive_left
163167

168+
include p in
169+
theorem finrank_eq [Module.Finite R M] [Module.Free R M] :
170+
finrank R M = finrank R N :=
171+
((Module.Free.chooseBasis R M).toDualEquiv.trans p.toDualRight.symm).finrank_eq
172+
164173
private lemma restrict_aux
165174
{M' N' : Type*} [AddCommGroup M'] [Module R M'] [AddCommGroup N'] [Module R N']
166175
(i : M' →ₗ[R] M) (j : N' →ₗ[R] N)
@@ -206,6 +215,61 @@ section RestrictScalars
206215

207216
open Submodule (span)
208217

218+
/-- If a perfect pairing over a field `L` takes values in a subfield `K` along two `K`-subspaces
219+
whose `L` span is full, then these subspaces induce a `K`-structure in the sense of
220+
[*Algebra I*, Bourbaki : Chapter II, §8.1 Definition 1][bourbaki1989]. -/
221+
lemma exists_basis_basis_of_span_eq_top_of_mem_algebraMap
222+
{K L : Type*} [Field K] [Field L] [Algebra K L]
223+
[Module L M] [Module L N] [Module K M] [Module K N] [IsScalarTower K L M]
224+
(p : PerfectPairing L M N)
225+
(M' : Submodule K M) (N' : Submodule K N)
226+
(hM : span L (M' : Set M) = ⊤)
227+
(hN : span L (N' : Set N) = ⊤)
228+
(hp : ∀ᵉ (x ∈ M') (y ∈ N'), p x y ∈ (algebraMap K L).range) :
229+
∃ (n : ℕ) (b : Basis (Fin n) L M) (b' : Basis (Fin n) K M'), ∀ i, b i = b' i := by
230+
classical
231+
have : IsReflexive L M := p.reflexive_left
232+
have : IsReflexive L N := p.reflexive_right
233+
obtain ⟨v, hv₁, hv₂, hv₃⟩ := exists_linearIndependent L (M' : Set M)
234+
rw [hM] at hv₂
235+
let b : Basis _ L M := Basis.mk hv₃ <| by rw [← hv₂, Subtype.range_coe_subtype, Set.setOf_mem_eq]
236+
have : Fintype v := Set.Finite.fintype <| Module.Finite.finite_basis b
237+
set v' : v → M' := fun i ↦ ⟨i, hv₁ (Subtype.coe_prop i)⟩
238+
have hv' : LinearIndependent K v' := by
239+
replace hv₃ := hv₃.restrict_scalars (R := K) <| by
240+
simp_rw [← Algebra.algebraMap_eq_smul_one]
241+
exact NoZeroSMulDivisors.algebraMap_injective K L
242+
rw [show ((↑) : v → M) = M'.subtype ∘ v' from rfl] at hv₃
243+
exact hv₃.of_comp
244+
suffices span K (Set.range v') = ⊤ by
245+
let e := (Module.Finite.finite_basis b).equivFin
246+
let b' : Basis _ K M' := Basis.mk hv' (by rw [this])
247+
exact ⟨_, b.reindex e, b'.reindex e, fun i ↦ by simp [b, b']⟩
248+
suffices span K v = M' by
249+
apply Submodule.map_injective_of_injective M'.injective_subtype
250+
rw [Submodule.map_span, ← Set.image_univ, Set.image_image]
251+
simpa
252+
refine le_antisymm (Submodule.span_le.mpr hv₁) fun m hm ↦ ?_
253+
obtain ⟨w, hw₁, hw₂, hw₃⟩ := exists_linearIndependent L (N' : Set N)
254+
rw [hN] at hw₂
255+
let bN : Basis _ L N := Basis.mk hw₃ <| by rw [← hw₂, Subtype.range_coe_subtype, Set.setOf_mem_eq]
256+
have : Fintype w := Set.Finite.fintype <| Module.Finite.finite_basis bN
257+
have e : v ≃ w := Fintype.equivOfCardEq <| by rw [← Module.finrank_eq_card_basis b,
258+
← Module.finrank_eq_card_basis bN, p.finrank_eq]
259+
let bM := bN.dualBasis.map p.toDualLeft.symm
260+
have hbM (j : w) (x : M) (hx : x ∈ M') : bM.repr x j = p x (j : N) := by simp [bM, bN]
261+
have hj (j : w) : bM.repr m j ∈ (algebraMap K L).range := (hbM _ _ hm) ▸ hp m hm j (hw₁ j.2)
262+
replace hp (i : w) (j : v) :
263+
(bN.dualBasis.map p.toDualLeft.symm).toMatrix b i j ∈ (algebraMap K L).fieldRange := by
264+
simp only [Basis.toMatrix, Basis.map_repr, LinearEquiv.symm_symm, LinearEquiv.trans_apply,
265+
toDualLeft_apply, Basis.dualBasis_repr]
266+
exact hp (b j) (by simpa [b] using hv₁ j.2) (bN i) (by simpa [bN] using hw₁ i.2)
267+
have hA (i j) : b.toMatrix bM i j ∈ (algebraMap K L).range :=
268+
Matrix.mem_subfield_of_mul_eq_one_of_mem_subfield_left e _ (by simp) hp i j
269+
have h_span : span K v = span K (Set.range b) := by simp [b]
270+
rw [h_span, Basis.mem_span_iff_repr_mem, ← Basis.toMatrix_mulVec_repr bM b m]
271+
exact fun i ↦ Subring.sum_mem _ fun j _ ↦ Subring.mul_mem _ (hA i j) (hj j)
272+
209273
variable {S : Type*}
210274
[CommRing S] [Algebra S R] [Module S M] [Module S N] [IsScalarTower S R M] [IsScalarTower S R N]
211275
[NoZeroSMulDivisors S R] [Nontrivial R]
@@ -272,18 +336,23 @@ def restrictScalars
272336
p.flip.restrictScalarsAux_surjective j i h₂ (fun m n ↦ hp n m)⟩}
273337

274338
/-- Restriction of scalars for a perfect pairing taking values in a subfield. -/
275-
def restrictScalarsField {K : Type*} [Field K] [Algebra K R]
276-
[Module K M] [Module K N] [IsScalarTower K R M] [IsScalarTower K R N]
277-
[Module K M'] [Module K N'] [FiniteDimensional K M']
339+
def restrictScalarsField {K L : Type*} [Field K] [Field L] [Algebra K L]
340+
[Module L M] [Module L N] [Module K M] [Module K N] [IsScalarTower K L M] [IsScalarTower K L N]
341+
[Module K M'] [Module K N']
278342
(i : M' →ₗ[K] M) (j : N' →ₗ[K] N)
279343
(hi : Injective i) (hj : Injective j)
280-
(hM : span R (LinearMap.range i : Set M) = ⊤)
281-
(hN : span R (LinearMap.range j : Set N) = ⊤)
282-
(hp : ∀ m n, p (i m) (j n) ∈ (algebraMap K R).range) :
283-
PerfectPairing K M' N' :=
284-
PerfectPairing.mkOfInjective _
285-
(p.restrictScalarsAux_injective i j hi hN hp)
344+
(hM : span L (LinearMap.range i : Set M) = ⊤)
345+
(hN : span L (LinearMap.range j : Set N) = ⊤)
346+
(p : PerfectPairing L M N)
347+
(hp : ∀ m n, p (i m) (j n) ∈ (algebraMap K L).range) :
348+
PerfectPairing K M' N' := by
349+
suffices FiniteDimensional K M' from mkOfInjective _ (p.restrictScalarsAux_injective i j hi hN hp)
286350
(p.flip.restrictScalarsAux_injective j i hj hM (fun m n ↦ hp n m))
351+
obtain ⟨n, -, b', -⟩ := p.exists_basis_basis_of_span_eq_top_of_mem_algebraMap _ _ hM hN <| by
352+
rintro - ⟨m, rfl⟩ - ⟨n, rfl⟩
353+
exact hp m n
354+
have : FiniteDimensional K (LinearMap.range i) := FiniteDimensional.of_fintype_basis b'
355+
exact Finite.equiv (LinearEquiv.ofInjective i hi).symm
287356

288357
end RestrictScalars
289358

@@ -341,6 +410,12 @@ def toPerfectPairing : PerfectPairing R N M where
341410

342411
end LinearEquiv
343412

413+
/-- A perfect pairing induces a perfect pairing between dual spaces. -/
414+
def PerfectPairing.dual (p : PerfectPairing R M N) :
415+
PerfectPairing R (Dual R M) (Dual R N) :=
416+
let _i := p.reflexive_right
417+
(p.toDualRight.symm.trans (evalEquiv R N)).toPerfectPairing
418+
344419
namespace Submodule
345420

346421
open LinearEquiv

docs/references.bib

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ @Book{ bourbaki1987
607607

608608
@Book{ bourbaki1989,
609609
author = {Bourbaki, N.},
610-
title = {Algebra. {II}. {C}hapters 1–3},
610+
title = {Algebra. {I}. {C}hapters 1–3},
611611
series = {Elements of Mathematics},
612612
note = {Translated from the French},
613613
year = {1998},

0 commit comments

Comments
 (0)