module public import Aesop.BuiltinRules public import Mathlib.Data.Matrix.ColumnRowPartitioned public import Lib.General.Groups.CongruenceSubgroups import TauCeti.LinearAlgebra.Matrix.LDU import TauCeti.LinearAlgebra.Matrix.Triangular /-! # Block triangular groups, unipotent Bessel groups, Levi and parahoric subgroups This file treats matrix groups over a commutative ring `R`, with an involution where unitary groups are concerned. The space has the basis `e₁, …, e_ϱ`, then a middle block, then `e*₁, …, e*_ϱ`; the index type is `New.SplitIndex ϱ μ`. The form `New.Shape.Form.splitGram T` consists of `ϱ` hyperbolic planes and the middle Gram matrix `T`. In `New.Shape.BesselIndex` the middle block is `κ` and one more vector `z`. The file also defines the Kronecker product of a finite family of matrices and the character `New.wave` of `ℂ`. * `New.BesselIndex.level`, `New.Shape.besselFrame`, `New.Shape.Form.frameGram`: the levels of the basis vectors, the frame `(e₁, …, e_ϱ, z)`, and the products of the frame with its image under a matrix `γ`. * `New.Shape.besselIndexEquiv`: the labelling of the basis by `κ` and a string of length `2ϱ + 1`. * `New.parabolic`, `New.agreeWithOneOn`, `New.unitriangular`: the block upper triangular matrices for a level function, the invertible matrices that agree with the identity on the entries picked out by a relation, and the block upper triangular matrices with all diagonal blocks `1`. * `New.Shape.Form.besselU`, `New.Shape.Form.besselU0`: subgroups of the unitary group `New.Shape.Form.G` cut out by such conditions, where `New.U` is the unitary group of a Gram matrix. * `New.levi`, `New.parahoric`: the Levi subgroups and the parahoric subgroups of `GL_k` over a commutative local ring. ## Relation to the literature Known; see `Lib.DiscreteSeries.Bruhat.FloorGroups` for sources. -/ @[expose] public section noncomputable section namespace New open Matrix Fin Finset IsLocalRing /-- The shape of a hermitian space with ϱ hyperbolic planes, a summand X₀ and a vector z: the number ϱ, a finite index set κ for X₀, and one index k₀ in κ. -/ structure Shape where /-- The number ϱ of hyperbolic planes. -/ ϱ : ℕ /-- The index set of a basis of X₀. -/ κ : Type /-- The instance that κ is finite. -/ [fintypeIndex : Fintype κ] /-- The instance that κ has decidable equality. -/ [decEqIndex : DecidableEq κ] /-- A distinguished index in κ. -/ k₀ : κ attribute [instance] Shape.fintypeIndex Shape.decEqIndex variable {R : Type*} [CommRing R] (𝔰 : Shape) {S : Type*} [Fintype S] {a b c : S → Type} (A : ∀ s : S, Matrix (a s) (b s) R) {R' : Type*} [CommRing R'] (φ : R →+* R') /-! ### Tensor products of matrices and a character -/ /-- The Kronecker product of a finite family of matrices A s: the entry at (β, α) is the product over s of the entries of A s at (β s, α s). -/ def kroneckerPi : Matrix (∀ s : S, a s) (∀ s : S, b s) R := of fun β α ↦ ∏ s : S, A s (β s) (α s) /-- The Kronecker product of the products A s * B s is the product of the Kronecker product of the matrices A s and that of the matrices B s. -/ lemma kroneckerPi_mul [DecidableEq S] [∀ s : S, Fintype (b s)] (B : ∀ s : S, Matrix (b s) (c s) R) : kroneckerPi (fun s : S ↦ A s * B s) = kroneckerPi A * kroneckerPi B := by simp [kroneckerPi, ← ext_iff, Matrix.mul_apply, prod_univ_sum, prod_mul_distrib] @[simp] lemma kroneckerPi_one [∀ s : S, DecidableEq (a s)] : kroneckerPi (fun s : S ↦ (1 : Matrix (a s) (a s) R)) = 1 := by simp [kroneckerPi, ← ext_iff, prod_boole, funext_iff, Matrix.one_apply] lemma kroneckerPi_map : kroneckerPi (fun s : S ↦ (A s).map φ) = (kroneckerPi A).map φ := by simp [kroneckerPi, ← ext_iff] /-- The function `c ↦ exp (c - conj c)`, a character of `ℂ` of absolute value `1`. -/ def wave (c : ℂ) : ℂ := Complex.exp (c - starRingEnd ℂ c) @[simp] lemma norm_wave (c : ℂ) : ‖wave c‖ = 1 := by simp [wave, Complex.norm_exp] /-! ### The basis, its levels, the form and the frame -/ /-- The index set made of ϱ indices, a middle set μ, and ϱ further indices, as a disjoint union. -/ abbrev SplitIndex (ϱ : ℕ) (μ : Type) : Type := Fin ϱ ⊕ μ ⊕ Fin ϱ /-- The index set of a basis of X₀ ⊕ ⟨z⟩: the indices κ of X₀ and one more index for z. -/ abbrev Shape.MiddleIndex : Type := 𝔰.κ ⊕ Unit /-- The index set of the basis e₁, …, e_ϱ, x_i (i in κ), z, e*₁, …, e*_ϱ, whose middle block is κ plus one point. -/ abbrev Shape.BesselIndex : Type := SplitIndex 𝔰.ϱ 𝔰.MiddleIndex /-- The number n = ϱ + 1 of vectors in the frame (e_1, …, e_ϱ, z). -/ abbrev Shape.n : ℕ := 𝔰.ϱ + 1 /-- The index, in the basis of the whole space, of the basis vector j of X₀. -/ abbrev Shape.indexX₀ (j : 𝔰.κ) : 𝔰.BesselIndex := Sum.inr (Sum.inl (Sum.inl j)) /-- The index of z in the basis of the whole space. -/ abbrev Shape.z : 𝔰.BesselIndex := Sum.inr (Sum.inl (Sum.inr ())) /-- The last position in the frame (e_1, …, e_ϱ, z), that of z. -/ abbrev Shape.top : Fin (𝔰.ϱ + 1) := last 𝔰.ϱ /-- The square matrices over R indexed by `New.Shape.MiddleIndex`, used as Gram matrices on X₀ ⊕ ⟨z⟩. -/ abbrev Shape.Form (R : Type*) : Type _ := Matrix 𝔰.MiddleIndex 𝔰.MiddleIndex R /-- The rank k of X₀: the number of elements of κ. -/ abbrev Shape.k : ℕ := Fintype.card 𝔰.κ /-- The rank r of the whole space: the number of elements of the basis index set `New.Shape.BesselIndex`. -/ abbrev Shape.r : ℕ := Fintype.card 𝔰.BesselIndex /-- The natural-number level of a basis index: i for index i of the first block, ϱ on the middle block, 2ϱ−i for index i of the last block. -/ def BesselIndex.level {ϱ : ℕ} {μ : Type} : SplitIndex ϱ μ → ℕ := (fun a ↦ a) ⊕ᵥ ((fun _ ↦ ϱ) ⊕ᵥ fun a ↦ 2 * ϱ - a) /-- The bijection from κ plus a string of length 2ϱ + 1 to the basis indices `New.Shape.BesselIndex`: κ goes to the x_i, and the string index a goes to e_a if a < ϱ, to z if a = ϱ and to e*_{2ϱ−a} if a > ϱ (e and e* numbered from 0). -/ def Shape.besselIndexEquiv : 𝔰.κ ⊕ Fin (2 * 𝔰.ϱ + 1) ≃ 𝔰.BesselIndex := -- The inverse sends `e_i` to `i`, keeps `κ`, sends `z` to `ϱ` and `e*_i` to `2 ϱ - i`. Equiv.symm <| Equiv.ofBijective (Sum.elim (fun i ↦ Sum.inr ⟨i, by grind⟩) (Sum.elim (Sum.elim Sum.inl fun _ ↦ Sum.inr ⟨𝔰.ϱ, by grind⟩) fun i ↦ Sum.inr ⟨2 * 𝔰.ϱ - i, by grind⟩)) <| by -- an injection between finite sets of the same size simp [↓Fintype.bijective_iff_injective_and_card, Function.Injective] grind variable {n : Type*} [Fintype n] [DecidableEq n] {α : Type*} [LinearOrder α] (lev : n → α) /-- The index of the basis vector e*_a, in the last of the three blocks. -/ @[match_pattern] abbrev eStar {μ : Type} {ϱ : ℕ} (a : Fin ϱ) : SplitIndex ϱ μ := Sum.inr (Sum.inr a) /-- The Gram matrix of hyperbolic planes indexed by σ plus the form T: identity blocks pair the two copies of σ, and T is the middle block. -/ abbrev Floors.hyperbolicGram {μ : Type*} (σ : Type*) [DecidableEq σ] (T : Matrix μ μ R) : Matrix (σ ⊕ μ ⊕ σ) (σ ⊕ μ ⊕ σ) R := fromBlocks 0 (fromCols 0 1) (fromRows 0 1) (T.fromBlocks 0 0 0) /-- Conjugate transpose interchanges the identity blocks pairing the two copies of `σ` and takes the conjugate transpose of the middle block. -/ lemma Floors.conjTranspose_hyperbolicGram [StarRing R] {μ σ : Type*} [DecidableEq σ] (T : Matrix μ μ R) : (Floors.hyperbolicGram σ T)ᴴ = Floors.hyperbolicGram σ Tᴴ := by simp [Floors.hyperbolicGram, fromBlocks_conjTranspose, conjTranspose_fromCols_eq_fromRows_conjTranspose, conjTranspose_fromRows_eq_fromCols_conjTranspose] /-- The two hyperbolic blocks swap the outer coordinates twice. Their product is block diagonal with middle block `T * U` and identity on each outer block. -/ lemma Floors.hyperbolicGram_mul {μ σ : Type*} [Fintype μ] [Fintype σ] [DecidableEq σ] (T U : Matrix μ μ R) : Floors.hyperbolicGram σ T * Floors.hyperbolicGram σ U = fromBlocks 1 0 0 (fromBlocks (T * U) 0 0 (1 : Matrix σ σ R)) := by ext (i | i | i) (j | j | j) <;> simp [Floors.hyperbolicGram, Matrix.mul_apply, Fintype.sum_sum_type, Matrix.one_apply] /-- The indices of the frame (e₁, …, e_ϱ, z) among the basis indices. -/ def Shape.besselFrame : Fin (𝔰.ϱ + 1) → 𝔰.BesselIndex := snoc Sum.inl 𝔰.z /-- The frame lists the first member of each hyperbolic pair and then z. It contains no dual member. -/ @[simp] lemma Shape.eStar_ne_besselFrame (a : Fin 𝔰.ϱ) (b : Fin 𝔰.n) : eStar a ≠ 𝔰.besselFrame b := by induction b using Fin.lastCases <;> simp [Shape.besselFrame] /-- For N in R, the diagonal matrix on κ plus one point with entries 1 on κ and −N at the extra point. -/ def Shape.middleGram (N : R) : 𝔰.Form R := fromBlocks 1 0 0 (of fun _ _ ↦ -N) variable {𝔰} (T : 𝔰.Form R) /-- The Gram matrix of ϱ hyperbolic planes and a middle space with Gram matrix T: identity blocks pair the first and last ϱ indices, T is the middle block, all else is zero. -/ def Shape.Form.splitGram : Matrix 𝔰.BesselIndex 𝔰.BesselIndex R := Floors.hyperbolicGram (Fin 𝔰.ϱ) T /-! ### Block triangular groups -/ /-- The subgroup of GL_n(R) of matrices that are block upper triangular for the level function lev. -/ def parabolic : Subgroup (GL n R) where carrier := {g : GL n R | g.val.BlockTriangular lev} mul_mem' := BlockTriangular.mul one_mem' := blockTriangular_one inv_mem' := by simp_all [blockTriangular_inv_of_blockTriangular] /-- For the order `False < True` on propositions, the level `· ∉ s` of `j` is below that of `i` exactly when `j` is in `s` and `i` is not. -/ lemma notMem_lt_notMem_iff {α : Type*} {s : Set α} {i j : α} : (j ∉ s) < (i ∉ s) ↔ j ∈ s ∧ i ∉ s := by grind [lt_iff_le_not_ge, le_Prop_eq] /-- With the indices in `s` as the first block, a matrix is block upper triangular exactly when every entry with row outside `s` and column in `s` vanishes. -/ lemma blockTriangular_notMem_iff {α β : Type*} [Zero β] (M : Matrix α α β) (s : Set α) : M.BlockTriangular (· ∉ s) ↔ ∀ i ∉ s, ∀ j ∈ s, M i j = 0 := by constructor · intro h i hi j hj exact h (notMem_lt_notMem_iff.2 ⟨hj, hi⟩) · intro h i j hij obtain ⟨hj, hi⟩ := notMem_lt_notMem_iff.1 hij exact h i hi j hj /-- The homomorphism sending a block upper triangular invertible matrix to its diagonal block of level a. -/ def blockHom (a : α) : parabolic (R := R) lev →* GL {i : n // lev i = a} R := MonoidHom.toHomUnits { toFun g := g.val.val.toSquareBlock lev a map_one' := toBlock_one_self _ map_mul' g h := by -- In `∑ x, g i x * h x j` with `i`, `j` of level `a`, a term with `x` of lower level has -- `g i x = 0`, and a term with `x` of higher level has `h x j = 0`. ext i j refine sum_congr_set {x : n | lev x = a} _ _ (fun _ _ ↦ rfl) fun x hx ↦ ?_ grind [@g.property i x, @h.property x j, not_lt] } open scoped Classical in /-- Let r be a relation on the indices such that r i j implies r i k or r k j for every k. This is the group of invertible matrices over R that agree with the identity matrix at every entry (i, j) with r i j. -/ def agreeWithOneOn (r : n → n → Prop) (R : Type*) [CommRing R] (h_split : ∀ i k j : n, r i j → r i k ∨ r k j) : Subgroup (GL n R) := Subgroup.ofDiv {u : GL n R | ∀ i j : n, r i j → u i j = (1 : Matrix n n R) i j} ⟨1, by simp⟩ <| by -- Compare `(x * y⁻¹) i j` with `(y * y⁻¹) i j` term by term. If `r i k` then `x i k = y i k`; -- otherwise `y⁻¹ k j = 0`, as `y` is block triangular for the level function that is `0` where -- `r i ·` holds and `1` elsewhere. intro x hx y hy i j hij have hy_inv : y⁻¹ ∈ parabolic fun k : n ↦ if r i k then 0 else 1 := by refine (parabolic _).inv_mem fun a b hab ↦ ?_ obtain ⟨hib, hia⟩ : r i b ∧ ¬ r i a := by grind have hab_ne : a ≠ b := fun h_eq ↦ hia (by rwa [h_eq]) exact (hy a b ((h_split i a b hib).resolve_left hia)).trans (one_apply_ne hab_ne) have h_term : ∀ k : n, x.val i k * y⁻¹.val k j = y.val i k * y⁻¹.val k j := fun k ↦ by by_cases hik : r i k · rw [hx i k hik, hy i k hik] · have h_zero : y⁻¹.val k j = 0 := hy_inv (by simp [hik, hij]) rw [h_zero, mul_zero, mul_zero] calc (x.val * y⁻¹.val) i j = ∑ k : n, y.val i k * y⁻¹.val k j := sum_congr rfl fun k _ ↦ h_term k _ = (y.val * y⁻¹.val) i j := rfl _ = (1 : Matrix n n R) i j := by rw [y.mul_inv] /-- The group of block upper triangular matrices all of whose diagonal blocks are the identity. -/ abbrev unitriangular (R : Type*) [CommRing R] : Subgroup (GL n R) := agreeWithOneOn (fun i j : n ↦ lev i ≥ lev j) R fun i k _ hij ↦ (le_total (lev k) (lev i)).imp_right hij.trans /-- A matrix lies in `agreeWithOneOn r R h_split` exactly when it agrees with the identity matrix at every entry (a, b) with r a b. -/ lemma mem_agreeWithOneOn {r : n → n → Prop} {h_split : ∀ i k j : n, r i j → r i k ∨ r k j} {x : GL n R} : x ∈ agreeWithOneOn r R h_split ↔ ∀ a b : n, r a b → x a b = (1 : Matrix n n R) a b := .rfl attribute [simp] mem_agreeWithOneOn /-- Multiplying on the left by an upper unitriangular `u` keeps the difference of the entries `(i, l)` of two matrices whose columns `l` agree below row `i`. -/ lemma mul_apply_sub_mul_apply_of_unitriangular {N : ℕ} {u : GL (Fin N) R} (hu : u ∈ unitriangular id R) {A B : Matrix (Fin N) (Fin N) R} {i l : Fin N} (h_below : ∀ a : Fin N, i < a → A a l = B a l) : (u.val * A) i l - (u.val * B) i l = A i l - B i l := by have h_entry (a : Fin N) (ha : a ≤ i) : u.val i a = (1 : Matrix (Fin N) (Fin N) R) i a := mem_agreeWithOneOn.mp hu i a ha rw [Matrix.mul_apply, Matrix.mul_apply, ← sum_sub_distrib, sum_eq_single i _ (by simp)] · simp [h_entry i le_rfl] · intro a _ ha obtain ha | ha := ha.lt_or_gt · simp [h_entry a ha.le, ha.ne'] · simp [h_below a ha] /-- If `d` is block upper triangular and `u` is block upper unitriangular, both for the level function `lev`, then `d⁻¹ * u * d` is block upper unitriangular for `lev`. -/ lemma conj_mem_unitriangular {lev : n → α} {u d : GL n R} (hd : d.val.BlockTriangular lev) (hu : u ∈ unitriangular lev R) : d⁻¹ * u * d ∈ unitriangular lev R := fun i j hij ↦ sub_eq_zero.mp <| by -- `u - 1` vanishes on and below the block diagonal, and multiplying by the block triangular -- `d⁻¹` and `d` preserves this; `d⁻¹ * (u - 1) * d = d⁻¹ * u * d - 1`. have h := hd.mul_apply_eq_zero_of_le' (((parabolic lev).inv_mem hd).mul_apply_eq_zero_of_le (N := u.val - 1) fun a b hab ↦ sub_eq_zero.mpr (hu a b hab)) hij rwa [Matrix.mul_sub, Matrix.sub_mul, Matrix.mul_one, d.inv_mul] at h /-- A matrix has determinant `1` if it is block upper unitriangular for the level function `lev`, that is, agrees with the identity matrix at every entry (a, b) with `lev b ≤ lev a`. -/ lemma det_eq_one_of_unitriangular {lev : n → α} {Z : Matrix n n R} (hZ : ∀ a b : n, lev b ≤ lev a → Z a b = (1 : Matrix n n R) a b) : Z.det = 1 := (blockUnitriangular_of_apply_eq_one_apply_of_not_lt fun a b h ↦ hZ a b (not_lt.1 h)).det_eq_one /-- The free entries of a block unitriangular matrix: the pairs `(i, j)` with `lev i < lev j`. -/ abbrev FreeEntry (lev : n → α) : Type _ := {p : n × n // lev p.1 < lev p.2} /-- A matrix that is block unitriangular for the level function `lev` (equal to `1` at the entries `(i, j)` with `lev j ≤ lev i`) is the same as a choice of its free entries. -/ def unitriangularEquiv (R : Type*) [CommRing R] : unitriangular lev R ≃ (FreeEntry lev → R) where toFun u p := (u : GL n R) p.val.1 p.val.2 invFun a := let Z : Matrix n n R := of fun i j ↦ if h : lev i < lev j then a ⟨(i, j), h⟩ else (1 : Matrix n n R) i j have hZ : ∀ i j : n, lev j ≤ lev i → Z i j = (1 : Matrix n n R) i j := fun _ _ hij ↦ dite_eq_right hij.not_gt have h_det : IsUnit Z.det := by simp [det_eq_one_of_unitriangular hZ] ⟨GeneralLinearGroup.mk'' Z h_det, hZ⟩ left_inv u := by ext i j change (if lev i < lev j then (u : GL n R) i j else (1 : Matrix n n R) i j) = (u : GL n R) i j exact ite_eq_left_iff.2 fun hij ↦ (u.property i j (not_lt.1 hij)).symm right_inv a := funext fun p ↦ dite_eq_left p.property /-! ### Minors, diagonal scalings, frame matrices and the unitary group -/ /-- The leading principal minor of order `l`: the determinant of the upper left `l × l` block of the `i × i` matrix `Z`, for `0 ≤ l ≤ i`. -/ def leadingMinor {i : ℕ} (Z : Matrix (Fin i) (Fin i) R) (l : Fin (i + 1)) : R := (Z.submatrix (castLE l.is_le) (castLE l.is_le)).det variable [StarRing R] (γ : Matrix 𝔰.BesselIndex 𝔰.BesselIndex R) /-- The diagonal matrix on μ with entry p at the index k₀ and 1 at every other index. -/ abbrev Filling.scaleAt {μ : Type*} [DecidableEq μ] (p : R) (k₀ : μ) : Matrix μ μ R := diagonal fun j : μ ↦ if j = k₀ then p else 1 /-- The columns of γ at the frame indices, that is the image γf of the frame f = (e₁,…,e_ϱ,z). -/ abbrev frameImage : Matrix 𝔰.BesselIndex (Fin (𝔰.ϱ + 1)) R := γ.submatrix id 𝔰.besselFrame /-- The (ϱ+1) × (ϱ+1) matrix of the products h(f_j, γ f_l) of the frame f with its image under γ, where h is the form `New.Shape.Form.splitGram T`. -/ def Shape.Form.frameGram : Matrix (Fin (𝔰.ϱ + 1)) (Fin (𝔰.ϱ + 1)) R := (T.splitGram * γ).submatrix 𝔰.besselFrame 𝔰.besselFrame /-- The unitary group of the form `New.Shape.Form.splitGram T` on the whole space: the invertible matrices that preserve this Gram matrix. -/ abbrev Shape.Form.G : Subgroup (GL 𝔰.BesselIndex R) := U T.splitGram variable {T} /-- The square submatrix of γ on the rows and columns of the frame (e₁, …, e_ϱ, z). -/ def frameMatrix (γ : T.G) : Matrix (Fin (𝔰.ϱ + 1)) (Fin (𝔰.ϱ + 1)) R := γ.val.val.submatrix 𝔰.besselFrame 𝔰.besselFrame /-! ### The Bessel groups, Levi and parahoric subgroups -/ /-- The Bessel unipotent group 𝖴: the isometries of `New.Shape.Form.splitGram T` that are block upper unitriangular for the levels `New.BesselIndex.level`, so that their middle diagonal block is the identity. -/ def Shape.Form.besselU : Subgroup T.G := (unitriangular BesselIndex.level R).subgroupOf T.G /-- The fixer of the frame in the unitary group: the elements that fix each of its vectors. -/ def Shape.Form.besselFixer : Subgroup T.G := (agreeWithOneOn (fun _ j : 𝔰.BesselIndex ↦ j ∈ Set.range 𝔰.besselFrame) R fun _ _ _ hj ↦ Or.inr hj).subgroupOf T.G /-- The elements of the Bessel unipotent group 𝖴 that fix each vector of the frame. -/ def Shape.Form.besselU0 : Subgroup T.G := T.besselU ⊓ T.besselFixer export Shape (besselFrame middleGram) export Shape.Form (splitGram frameGram besselU besselFixer besselU0) variable {k : ℕ} (W : Type) [CommRing W] [IsLocalRing W] (τ : Fin k → ℕ) /-- The Levi subgroup of a labelling τ of the indices: matrices in GL_k(W), W local, whose (i,j) entry vanishes whenever τ(i) ≠ τ(j). -/ def levi : Subgroup (GL (Fin k) W) := (agreeWithOneOn (fun i j : Fin k ↦ τ i ≠ τ j) W fun _ l _ hij ↦ (hij.ne_or_ne (τ l)).imp_right Ne.symm).copy {g : GL (Fin k) W | ∀ i j : Fin k, τ i ≠ τ j → g i j = 0} <| by ext g simp +contextual [ne_of_apply_ne τ] /-- The parahoric subgroup of a labelling τ: matrices in GL_k(W), W local, whose (i,j) entry lies in the maximal ideal whenever τ(i) < τ(j). -/ def parahoric : Subgroup (GL (Fin k) W) := (parabolic (OrderDual.toDual ∘ τ)).comap (GeneralLinearGroup.map (residue W)) end New end