module import Mathlib.LinearAlgebra.Matrix.GeneralLinearGroup.Card import Mathlib.RingTheory.PicardGroup public import TauCeti.LinearAlgebra.Matrix.GeneralLinearGroup.Elementary public import Lib.Weil.DualPair.Defs public import Lib.Weil.Unramified.HeckeGL import Lib.DiscreteSeries.Haar.CayleyChart /-! # Extending columns, block matrices and block embeddings For an embedding `ι : r ↪ n` of index sets, `New.inclMatrix k ι` has the standard basis vectors `e (ι j)` as columns. Such a map splits `n` into two blocks, and the file studies the corresponding block matrices. Over a field, independent columns extend to an invertible matrix. ## Main definitions and results * `Function.Embedding.extendGL`: the embedding g ↦ diag(g, 1), supplied by Tau Ceti. * `New.rangeParabolic`, `New.mem_rangeParabolic_iff`: the opposite parabolic for the two blocks, and its description in entries. * `New.index_rangeParabolic_mul_card_GL`, `New.index_stabilizer_inclMatrix`: the index of the opposite parabolic times |GL_r(R)| is the index of the group that fixes the basis vectors of the first block, and over a finite field the latter index is computed. * `New.residueDatum`: a function of adelic matrices given by their reductions at a family of places. Notions from other files: * `New.parabolic`: the subgroup of GL_n(R) of matrices that are block upper triangular for a given level function on the indices. -/ @[expose] public section noncomputable section /-! ## Extension of independent columns to an invertible matrix -/ section ExtendColumns open Matrix LinearEquiv Submodule namespace New variable {r n : Type*} [Fintype r] [Fintype n] [DecidableEq n] (ι : r ↪ n) lemma inclMatrix_mulVecLin_injective (k : Type*) [Field k] : Function.Injective (inclMatrix k ι).mulVecLin := mulVec_injective_iff.2 ((linearIndependent_cols_of_isUnit isUnit_one).comp ι ι.injective) /-- A matrix b over a field with linearly independent columns extends to an invertible matrix u: column ι(j) of u is column j of b. -/ lemma exists_GL_mul_inclMatrix {k : Type*} [Field k] {b : Matrix n r k} (h : Function.Injective b.mulVecLin) : ∃ u : GL n k, u.val * inclMatrix k ι = b := by -- Both matrices are injective as linear maps, so their ranges are isomorphic. Extend this -- isomorphism to an automorphism `g` of `n → k` and take its matrix. let e : (r → k) ≃ₗ[k] LinearMap.range (inclMatrix k ι).mulVecLin := ofInjective _ (inclMatrix_mulVecLin_injective ι k) obtain ⟨g, hg⟩ := exists_linearEquiv_restrict_eq (e.symm ≪≫ₗ ofInjective b.mulVecLin h) have h_apply (v : r → k) : g (inclMatrix k ι *ᵥ v) = b *ᵥ v := by simpa [e] using (hg (e v)).symm refine ⟨.mk'' g.toMatrix' (by simp [← coe_det]), ?_⟩ simp [ext_iff_mulVec, ← mulVec_mulVec, h_apply] end New end ExtendColumns /-! ## The embedding diag(g, 1), the opposite parabolic and residue data Here `u : r → n` is a map of index sets, mostly an embedding. -/ namespace New open Matrix Set variable {r n n' R S ι : Type*} [CommRing R] [CommRing S] lemma map_inclMatrix (f : R →+* S) (u : r → n) [DecidableEq n] : (inclMatrix R u).map f = inclMatrix S u := by rw [inclMatrix, ← submatrix_map, Matrix.map_one f f.map_zero f.map_one, inclMatrix] variable {E : Type*} [Field E] [NumberField E] {T : Matrix n n' R} [Fintype n] [DecidableEq n] /-- For an embedding u of index sets, multiplying T on the left by the transpose of `inclMatrix R u` selects the rows of T indexed by u. -/ lemma inclMatrix_transpose_mul (u : r ↪ n) : (inclMatrix R u)ᵀ * T = T.submatrix u id := by ext i j simp [inclMatrix, Matrix.mul_apply, Matrix.one_apply] @[simp] lemma inclMatrix_transpose_mul_self [DecidableEq r] (u : r ↪ n) : (inclMatrix R u)ᵀ * inclMatrix R u = 1 := by rw [inclMatrix_transpose_mul, inclMatrix, submatrix_submatrix] exact submatrix_one_embedding u variable [Fintype r] /-- The transpose of `inclMatrix R u` cancels `inclMatrix R u` on the left of a product. -/ lemma inclMatrix_transpose_mul_cancel_left [DecidableEq r] (u : r ↪ n) (A : Matrix r n' R) : (inclMatrix R u)ᵀ * (inclMatrix R u * A) = A := by rw [← Matrix.mul_assoc, inclMatrix_transpose_mul_self, Matrix.one_mul] open scoped Classical in /-- For a family of places `w i` of E, the function on finite adelic matrices x (given as vectors on index pairs) equal to f of the family of the reductions of x at the places `w i` if x is integral at all of them, and 0 otherwise. -/ def residueDatum (w : ι → FinPlace E) (f : ((i : ι) → Matrix n' n (ResField (w i))) → ℂ) (x : n' × n → 𝔸f E) : ℂ := if ∀ (i : ι) (p : n' × n), x p (w i) ∈ LocInt (w i) then f fun i ↦ (vecToMatrix x : Matrix n' n (𝔸f E)).map (residueOrZero ∘ evalAt (w i)) else 0 /-- For the embedding g ↦ diag(g, 1), the columns indexed by u of the image of g are the columns of g, extended by zero. -/ @[simp] lemma extendGL_mul_inclMatrix [DecidableEq r] (u : r ↪ n) (g : GL r R) : (u.extendGL _ g).val * inclMatrix R u = inclMatrix R u * g.val := by ext i j rcases em (i ∈ range u) with ⟨k, rfl⟩ | hi · simp [inclMatrix, Matrix.mul_apply, Matrix.one_apply] · have h_ne (k : r) : i ≠ u k := fun h ↦ hi ⟨k, h.symm⟩ rw [Matrix.mul_apply, Finset.sum_eq_single (u j)] · simp [inclMatrix, Matrix.one_apply, Matrix.mul_apply, h_ne, u.coe_extendGL_apply_of_notMem_left g hi] · intro k _ hk simp [inclMatrix, hk] · simp /-- The block of diag(g, 1) with rows and columns in the image of u is g. -/ lemma submatrix_extendGL [DecidableEq r] (u : r ↪ n) (g : GL r R) : (u.extendGL _ g).val.submatrix u u = g.val := by ext i j exact u.coe_extendGL_apply_apply g i j /-- An invertible matrix x fixes every column of T, seen as the family `T.col`, if and only if xT = T. -/ lemma mem_stabilizer_col_iff {x : GL n R} : x ∈ MulAction.stabilizer (GL n R) T.col ↔ x.val * T = T := by -- the columns of `x * T` are the images of those of `T` under `x` change (x.val * T)ᵀ = Tᵀ ↔ _ exact transpose_inj omit [Fintype n] in /-- A matrix T is the extension by zero of its rows indexed by u exactly when its other rows vanish. -/ lemma eq_inclMatrix_mul_iff [DecidableEq r] (u : r ↪ n) : T = inclMatrix R u * T.submatrix u id ↔ ∀ i ∉ range u, ∀ j : n', T i j = 0 := by -- row `i` of the product is row `i` of `T` if `i` is in the image of `u`, and zero otherwise rw [← ext_iff] refine forall_congr' fun i ↦ ?_ by_cases hi : i ∈ range u · obtain ⟨k, rfl⟩ := hi simp [inclMatrix, Matrix.mul_apply, Matrix.one_apply] · have h_ne (k : r) : i ≠ u k := fun h ↦ hi ⟨k, h.symm⟩ simp [inclMatrix, Matrix.mul_apply, hi, h_ne] attribute [local instance] Prop.linearOrder /-- An invertible matrix is block upper triangular, for the image of `u` as first block, exactly when it keeps the span of the basis vectors indexed by `u`, the columns of `inclMatrix R u`. -/ lemma mem_parabolic_iff_mul_inclMatrix [DecidableEq r] (u : r ↪ n) {x : GL n R} : x ∈ parabolic (· ∉ range u) ↔ x.val * inclMatrix R u = inclMatrix R u * ((inclMatrix R u)ᵀ * (x.val * inclMatrix R u)) := by rw [inclMatrix_transpose_mul, eq_inclMatrix_mul_iff, mul_inclMatrix] change x.val.BlockTriangular (· ∉ range u) ↔ _ simpa only [Set.forall_mem_range, submatrix_apply, id_eq] using blockTriangular_notMem_iff x.val (range u) /-- The opposite parabolic: the image under g ↦ (gᵀ)⁻¹ of the block upper triangular group `New.parabolic` for the level function that is false on the image of u and true elsewhere. -/ def rangeParabolic (u : r ↪ n) : Subgroup (GL n R) := (parabolic (· ∉ range u)).map invTransposeGL.toMonoidHom omit [Fintype r] in /-- The opposite parabolic `rangeParabolic u` consists of the invertible matrices x whose entries with row in the image of u and column outside it vanish. -/ lemma mem_rangeParabolic_iff (u : r ↪ n) {x : GL n R} : x ∈ rangeParabolic u ↔ ∀ i : r, ∀ j ∉ range u, x (u i) j = 0 := by rw [rangeParabolic, Subgroup.mem_map_equiv, ← inv_mem_iff, ← map_inv] -- the inverse transpose of `x⁻¹` is `xᵀ`, and `xᵀ` is to be block upper triangular have h_val : (invTransposeGL.symm x⁻¹).val = x.valᵀ := congrArg (fun y : GL n R ↦ y.valᵀ) (inv_inv x) change (invTransposeGL.symm x⁻¹).val.BlockTriangular (· ∉ range u) ↔ _ rw [h_val, blockTriangular_notMem_iff] simp only [Set.forall_mem_range] exact ⟨fun h i j hj ↦ h j hj i, fun h j hj i ↦ h i j hj⟩ /-- For x in the opposite parabolic (entries with row in the image of u and column outside it vanish), the rows of x T indexed by u are the u-block of x times the rows of T indexed by u; here f selects columns of T. -/ lemma submatrix_mul_of_mem_rangeParabolic (u : r ↪ n) {x : GL n R} {f : ι → n'} (hx : x ∈ rangeParabolic u) : (x.val * T).submatrix u f = x.val.submatrix u u * T.submatrix u f := by refine submatrix_mul_of_eq_zero_outside _ _ u u f u.injective fun i _ k hk ↦ ?_ rw [(mem_rangeParabolic_iff u).1 hx i k hk, zero_mul] omit [Fintype r] in /-- The opposite parabolic `New.rangeParabolic u` has the same index in GL_n(R) as the block upper triangular group for the two blocks given by the image of u and its complement. -/ lemma index_rangeParabolic (u : r ↪ n) : (rangeParabolic (R := R) u).index = (parabolic (R := R) (· ∉ range u)).index := by simp [rangeParabolic] /-- The first diagonal block `x ↦ Aᵀ x A`, for `A = inclMatrix R u`, is a homomorphism from the block upper triangular group for the level function false on the image of `u` onto `GL_r(R)`. Its kernel is the stabilizer of the basis vectors `e_{u j}`, viewed in that group. -/ private lemma exists_surjective_parabolic_ker_eq_stabilizer [DecidableEq r] (u : r ↪ n) : ∃ φ : parabolic (R := R) (· ∉ range u) →* GL r R, Function.Surjective φ ∧ (MulAction.stabilizer (GL n R) (inclMatrix R u).col).subgroupOf (parabolic (· ∉ range u)) = φ.ker := by -- The first diagonal block is a homomorphism of `P` onto `GL_r(R)`, and its kernel is the -- stabiliser. let A : Matrix n r R := inclMatrix R u let P : Subgroup (GL n R) := parabolic (· ∉ range u) have h_mem (x : GL n R) : x ∈ P ↔ x.val * A = A * (Aᵀ * (x.val * A)) := mem_parabolic_iff_mul_inclMatrix u let block : P →* Matrix r r R := { toFun x := Aᵀ * ((x : GL n R).val * A) map_one' := by simp [A] map_mul' x y := by rw [Subgroup.coe_mul, Units.val_mul, Matrix.mul_assoc, (h_mem y).1 y.property, inclMatrix_transpose_mul_cancel_left] simp only [Matrix.mul_assoc] } have h_onto : Function.Surjective block.toHomUnits := fun g ↦ by have h_block : Aᵀ * ((u.extendGL _ g).val * A) = g := by rw [extendGL_mul_inclMatrix, inclMatrix_transpose_mul_cancel_left] have hg : u.extendGL _ g ∈ P := by rw [h_mem, h_block, extendGL_mul_inclMatrix] exact ⟨⟨u.extendGL _ g, hg⟩, Units.ext h_block⟩ have h_ker : (MulAction.stabilizer (GL n R) A.col).subgroupOf P = block.toHomUnits.ker := by ext ⟨x, hx⟩ rw [Subgroup.mem_subgroupOf, mem_stabilizer_col_iff, MonoidHom.mem_ker, Units.ext_iff] change x.val * A = A ↔ Aᵀ * (x.val * A) = 1 exact ⟨fun h ↦ by simp [h, A], fun h ↦ by rw [(h_mem x).1 hx, h, Matrix.mul_one]⟩ exact ⟨block.toHomUnits, h_onto, h_ker⟩ /-- In `GL_n(R)`, the index of `rangeParabolic u` times the order of `GL_r(R)` equals the index of the stabilizer of the basis vectors `e_{u j}`, i.e. of the matrices fixing each basis vector indexed by the image of `u`. Here `rangeParabolic u` is the image under `g ↦ (gᵀ)⁻¹` of the block upper triangular group `parabolic` for the level function that is false on the image of `u` and true elsewhere. (An infinite index or order counts as `0`.) -/ lemma index_rangeParabolic_mul_card_GL [DecidableEq r] (u : r ↪ n) : (rangeParabolic (R := R) u).index * Nat.card (GL r R) = (MulAction.stabilizer (GL n R) (inclMatrix R u).col).index := by -- Replace the opposite parabolic by the group `P` of the matrices that keep the span of the -- columns of `inclMatrix R u`; it has the same index and contains the stabiliser. The first -- diagonal block maps `P` onto `GL_r(R)` with kernel the stabiliser. have h_le : MulAction.stabilizer (GL n R) (inclMatrix R u).col ≤ parabolic (· ∉ range u) := fun x hx ↦ by rw [mem_parabolic_iff_mul_inclMatrix u, mem_stabilizer_col_iff.1 hx, inclMatrix_transpose_mul_self, Matrix.mul_one] obtain ⟨φ, h_onto, h_ker⟩ := exists_surjective_parabolic_ker_eq_stabilizer (R := R) u rw [index_rangeParabolic, ← Subgroup.relIndex_mul_index h_le, Subgroup.relIndex, h_ker, Subgroup.index_ker, MonoidHom.range_eq_top.2 h_onto, Subgroup.card_top, mul_comm] /-- Over a field, the orbit under `GL_n` of the family of the basis vectors indexed by `u` is the set of all linearly independent families indexed by `r`. -/ lemma orbit_col_inclMatrix (k : Type*) [Field k] (u : r ↪ n) : MulAction.orbit (GL n k) (inclMatrix k u).col = {s : r → n → k | LinearIndependent k s} := by have h_smul (g : GL n k) : g • (inclMatrix k u).col = (g.val * inclMatrix k u).col := rfl ext s simp only [MulAction.mem_orbit_iff, h_smul, mem_ofPred_eq] constructor · rintro ⟨g, rfl⟩ rw [← mulVec_injective_iff, ← coe_mulVecLin, mulVecLin_mul] exact (mulVec_injective_iff_isUnit.2 g.isUnit).comp (inclMatrix_mulVecLin_injective u k) · intro hs obtain ⟨g, hg⟩ := exists_GL_mul_inclMatrix u (b := (of s)ᵀ) (mulVec_injective_iff.2 hs) exact ⟨g, congrArg col hg⟩ variable {k : Type*} [Field k] [Finite k] /-- Over a finite field with `q` elements, the group of the matrices in `GL_n` that fix the `r` basis vectors indexed by `u` has index `∏_{i < r} (q ^ n - q ^ i)`, the number of independent families of `r` vectors. -/ lemma index_stabilizer_inclMatrix (u : r ↪ n) : (MulAction.stabilizer (GL n k) (inclMatrix k u).col).index = ∏ i ∈ Finset.range (Fintype.card r), (Nat.card k ^ Fintype.card n - Nat.card k ^ i) := by cases nonempty_fintype k -- The index is the number of independent families; reindex them by `Fin (card r)` to count them. have h_card : Nat.card {s : r → n → k | LinearIndependent k s} = Nat.card {s : Fin (Fintype.card r) → n → k // LinearIndependent k s} := Nat.card_congr (((Fintype.equivFin r).arrowCongr (.refl (n → k))).subtypeEquiv fun s ↦ (linearIndependent_equiv (Fintype.equivFin r).symm).symm) have h_le : Fintype.card r ≤ Module.finrank k (n → k) := by simpa using Fintype.card_le_of_embedding u rw [MulAction.index_stabilizer, orbit_col_inclMatrix, ← Nat.card_coe_set_eq, h_card, card_linearIndependent h_le, Module.finrank_fintype_fun_eq_card, Nat.card_eq_fintype_card, Fin.prod_univ_eq_prod_range fun i ↦ Fintype.card k ^ Fintype.card n - Fintype.card k ^ i] /-- Over a finite field with `q` elements, the index of the group of the matrices in `GL_n` that fix the `r` basis vectors indexed by `u` is the complex number `q ^ (n r) ∏_{n - r < i ≤ n} (1 - q⁻¹ ^ i)`. -/ lemma cast_index_stabilizer_inclMatrix (u : r ↪ n) : ((MulAction.stabilizer (GL n k) (inclMatrix k u).col).index : ℂ) = Nat.card k ^ (Fintype.card n * Fintype.card r) * ∏ i ∈ Finset.Icc (Fintype.card n - Fintype.card r + 1) (Fintype.card n), (1 - (Nat.card k : ℂ)⁻¹ ^ i) := by rw [index_stabilizer_inclMatrix] have h_le : Fintype.card r ≤ Fintype.card n := Fintype.card_le_of_embedding u have hq_pos : 0 < Nat.card k := Nat.card_pos set q := Nat.card k set N := Fintype.card n set M := Fintype.card r have h_factor (i : ℕ) (hi : i ∈ Finset.range M) : ((q ^ N - q ^ i : ℕ) : ℂ) = q ^ N * (1 - (q : ℂ)⁻¹ ^ (N - i)) := by have hi_le : i ≤ N := (Finset.mem_range.1 hi).le.trans h_le have hq_ne : (q : ℂ) ≠ 0 := Nat.cast_ne_zero.2 hq_pos.ne' rw [Nat.cast_sub (Nat.pow_le_pow_right hq_pos hi_le), inv_pow, pow_sub₀ _ hq_ne hi_le] push_cast field_simp have h_reindex : ∏ i ∈ Finset.range M, (1 - (q : ℂ)⁻¹ ^ (N - i)) = ∏ i ∈ Finset.Icc (N - M + 1) N, (1 - (q : ℂ)⁻¹ ^ i) := Finset.prod_nbij' (N - ·) (N - ·) (by grind) (by grind) (by grind) (by grind) fun _ _ ↦ rfl rw [Nat.cast_prod, Finset.prod_congr rfl h_factor, Finset.prod_mul_distrib, Finset.prod_const, Finset.card_range, pow_mul, h_reindex] end New end