module import Mathlib.Algebra.Order.Star.Int import TauCeti.LinearAlgebra.Matrix.Nonsingular.Inverse public import Lib.Weil.Periods.PointLattice import Lib.Adelic.Adeles.IdeleModulus import Lib.Adelic.Unitary.GramMatrix import Lib.Adelic.Witt.WittTheorem import Lib.General.LinearAlgebra.HermiteForm /-! # Iwasawa decomposition for the flag of the grades `New.Grading.exists_isGraded`: let `V` be a hermitian space over a CM field with a primitive root of unity of order 5040, with a grading `Y` of its basis. Every point of the finite adelic unitary group is moved by some unipotent element to a point whose lattice is graded. The lattice has a basis that does not lower grades (Hermite form). Witt's theorem over `Ô` corrects it so that its Gram matrix is that of its part of degree `0` (`New.Grading.exists_gram_mul_eq_gram_degreeZeroPart`). The map between the corrected basis and that part is a unipotent isometry. Notions from other files: * `New.Grading`: an indexing of the basis of a hermitian space by `X` and a string of `s` vectors in which the Gram matrix `V.J` is the standard one, `gradedGram Y.indexEquiv N`, with constant `N` (and `V.J⁻¹` is the one with constant `N⁻¹`); it gives every index a grade `Y.gradeOf i`. * `New.HasDegreeGe w' w d A`: the entry `A i k` is `0` whenever `w' i < w k + d`. * `New.intGL ι (Ô E)`: the invertible matrices with entries in the integral finite adeles `Ô E` whose inverse has entries there too. * `New.Space.lattice V x`: the vectors whose coordinates in the frame `V.xFin * x` are integral, where `x` is a finite adelic unitary matrix. * `New.Grading.IsGraded`: a lattice contains the part in each grade of each of its vectors. ## Relation to the literature Known result: the Iwasawa decomposition of an unramified unitary group. Source: J. Tits, Reductive groups over local fields, Proc. Sympos. Pure Math. 33 (1979), 3.3.2. -/ @[expose] public section open Matrix noncomputable section namespace New section DegreeZeroPart variable {R ι ι' ι'' : Type*} [CommRing R] {w : ι → ℤ} {w' : ι' → ℤ} {w'' : ι'' → ℤ} /-- The part of degree `0` of a matrix `A`, for weights `w'` on the rows and `w` on the columns: the entries `(i, k)` with `w' i = w k` are kept and the others are replaced by `0`. -/ def degreeZeroPart (w' : ι' → ℤ) (w : ι → ℤ) (A : Matrix ι' ι R) : Matrix ι' ι R := of fun i k ↦ if w' i = w k then A i k else 0 lemma degreeZeroPart_apply (A : Matrix ι' ι R) (i : ι') (k : ι) : degreeZeroPart w' w A i k = if w' i = w k then A i k else 0 := rfl lemma hasDegreeGe_degreeZeroPart (A : Matrix ι' ι R) : HasDegreeGe w' w 0 (degreeZeroPart w' w A) := fun i k h_lt ↦ by rw [degreeZeroPart_apply, ite_eq_right (by lia)] /-- If `A i k = 0` whenever `w' i < w k`, then removing the part of degree `0` from `A` leaves a matrix whose entries vanish whenever `w' i ≤ w k`. -/ lemma HasDegreeGe.sub_degreeZeroPart {A : Matrix ι' ι R} (hA : HasDegreeGe w' w 0 A) : HasDegreeGe w' w 1 (A - degreeZeroPart w' w A) := by grind [HasDegreeGe, degreeZeroPart_apply, Matrix.sub_apply] lemma degreeZeroPart_one [DecidableEq ι] : degreeZeroPart w w (1 : Matrix ι ι R) = 1 := by ext i k grind [degreeZeroPart_apply, Matrix.one_apply_ne] /-- On matrices of degree at least `0` (the entry `(i, k)` vanishes where the weight of the row is less than that of the column), taking the part of degree `0` (the entries where these two weights are equal) is multiplicative. -/ lemma degreeZeroPart_mul [Fintype ι'] {A : Matrix ι'' ι' R} {B : Matrix ι' ι R} (hA : HasDegreeGe w'' w' 0 A) (hB : HasDegreeGe w' w 0 B) : degreeZeroPart w'' w (A * B) = degreeZeroPart w'' w' A * degreeZeroPart w' w B := by ext i k -- A nonzero term has `w k ≤ w' l ≤ w'' i`, so `w'' i = w k` forces equality throughout. have h_term (l : ι') : (if w'' i = w k then A i l * B l k else 0) = degreeZeroPart w'' w' A i l * degreeZeroPart w' w B l k := by grind [HasDegreeGe, degreeZeroPart_apply] simp [degreeZeroPart_apply (A * B), Matrix.mul_apply, ← h_term] /-- For weights `w` on a finite index type `ι` and matrices `b`, `n`, `d'` over a commutative ring `R`, suppose `b` and `d'` have degree at least `0` (their `(i, k)` entries vanish whenever `w i < w k`), `n - 1` has degree at least `1` (its `(i, k)` entries vanish whenever `w i ≤ w k`), and the degree-`0` part of `b` times `d'` equals `1`. Then `b * n * d' - 1` has degree at least `1`. -/ private lemma hasDegreeGe_mul_mul_sub_one [Fintype ι] [DecidableEq ι] {b n d' : Matrix ι ι R} (hb : HasDegreeGe w w 0 b) (hn : HasDegreeGe w w 1 (n - 1)) (hd' : HasDegreeGe w w 0 d') (hd_inv : degreeZeroPart w w b * d' = 1) : HasDegreeGe w w 1 (b * n * d' - 1) := by have h_eq : b * n * d' - 1 = (b - degreeZeroPart w w b) * d' + b * (n - 1) * d' := by simp [sub_mul, mul_sub, hd_inv] have h_left : HasDegreeGe w w 1 ((b - degreeZeroPart w w b) * d') := hb.sub_degreeZeroPart.mul hd' (add_zero 1).ge have h_right : HasDegreeGe w w 1 (b * (n - 1) * d') := (hb.mul hn (zero_add 1).ge).mul hd' (add_zero 1).ge intro i k h_lt rw [h_eq, Matrix.add_apply, h_left i k h_lt, h_right i k h_lt, add_zero] /-- If all entries of `A` lie in the subring `O`, then so do those of its part of degree `0`. -/ lemma IsIntMatrix.degreeZeroPart {O : Subring R} {A : Matrix ι' ι R} (hA : IsIntMatrix O A) : IsIntMatrix O (degreeZeroPart w' w A) := fun i k ↦ by simp [degreeZeroPart_apply, ite_mem, hA i k] variable [StarRing R] /-- If `A` raises weights by at least `d`, from `w` on the columns to `w'` on the rows, then `Aᴴ` does so from `-w'` on the columns to `-w` on the rows. -/ lemma HasDegreeGe.conjTranspose {d : ℤ} {A : Matrix ι' ι R} (hA : HasDegreeGe w' w d A) : HasDegreeGe (-w) (-w') d Aᴴ := by grind [HasDegreeGe, conjTranspose_apply, star_zero, Pi.neg_apply] /-- Taking the part of degree `0` commutes with the conjugate transpose, the weights of rows and columns being negated and swapped. -/ lemma degreeZeroPart_conjTranspose (A : Matrix ι' ι R) : degreeZeroPart (-w) (-w') Aᴴ = (degreeZeroPart w' w A)ᴴ := by ext i k simp [degreeZeroPart, apply_ite star, eq_comm] end DegreeZeroPart variable {E X ι : Type} [Field E] [CMType E] [Fintype ι] [DecidableEq ι] [DecidableEq X] {ε : ι → ℤˣ} {s : ℕ} {N : E} {V : Space E ι ε} (Y : Grading V N X s) /-- For the orthonormal frame `g = V.xFin * x` (`V.xFin` is a fixed finite adelic frame with `V.xFinᴴ * V.J * V.xFin = 1`) of the lattice of a point `x` of the finite adelic unitary group, the matrix `g * gᴴ` is the image in the finite adeles of the inverse of the Gram matrix `V.J` of `V`. -/ lemma Space.frame_mul_conjTranspose (x : Gf E ι) : (V.xFin * x.val).val * (V.xFin * x.val).valᴴ = V.J⁻¹.map (algebraMap E (𝔸f E)) := by -- Invert the Gram identity for the inverse frame. rw [Matrix.map_nonsing_inv (algebraMap E (𝔸f E)), ← Space.gram_frame_inv x, Matrix.mul_inv_rev, ← Matrix.conjTranspose_nonsing_inv, ← GeneralLinearGroup.coe_inv, inv_inv] /-- Let `w : ι → ℤ` be weights, and let `G` and `G'` be matrices over `𝔸f E` with entries in `Ô E` such that `Gᴴ = G` and `G' * G = 1`. If `G i j = 0` when `w i + w j > 0` and `G' i j = 0` when `w i + w j < 0`, then `degreeZeroPart (-w) w G` is unimodular over `Ô E`. -/ private lemma isUnimodular_degreeZeroPart {w : ι → ℤ} {G G' : Matrix ι ι (𝔸f E)} (hG_herm : Gᴴ = G) (hG_int : IsIntMatrix (Ô E) G) (hG'_int : IsIntMatrix (Ô E) G') (h_inv : G' * G = 1) (hG_deg : HasDegreeGe (-w) w 0 G) (hG'_deg : HasDegreeGe w (-w) 0 G') : IsUnimodular (Ô E) (degreeZeroPart (-w) w G) := by have hG₀_herm : (degreeZeroPart (-w) w G)ᴴ = degreeZeroPart (-w) w G := by rw [← degreeZeroPart_conjTranspose, neg_neg, hG_herm] have hG₀_inv : degreeZeroPart w (-w) G' * degreeZeroPart (-w) w G = 1 := by rw [← degreeZeroPart_mul hG'_deg hG_deg, h_inv, degreeZeroPart_one] exact ⟨hG₀_herm, isPrimitiveMatrix_iff.1 ⟨hG_int.degreeZeroPart, _, hG'_int.degreeZeroPart, hG₀_inv⟩⟩ /-- Let `E` be a CM field with a primitive root of unity of order `5040`, let `P` be a predicate on `ι`, let `k` lie in `intGL ι (Ô E)`, and let `G₀` be a unimodular hermitian matrix over `Ô E`. If `G₀` equals `k.valᴴ * k.val` on all pairs `(i, j)` with `P i` and `P j`, then there is an `n ∈ intGL ι (Ô E)` such that `n.valᴴ * (k.valᴴ * k.val) * n.val = G₀` and `n.val i j = (1 : Matrix ι ι (𝔸f E)) i j` for every `i` and every `j` with `P j`. -/ private lemma exists_intGL_gram_eq_of_isUnimodular [HasPrimitiveRoot5040 E] {P : ι → Prop} {k : GL ι (𝔸f E)} {G₀ : Matrix ι ι (𝔸f E)} (hk : k ∈ intGL ι (Ô E)) (hG₀_unim : IsUnimodular (Ô E) G₀) (h_agree : ∀ {i j : ι}, P i → P j → G₀ i j = (k.valᴴ * k.val) i j) : ∃ n ∈ intGL ι (Ô E), n.valᴴ * (k.valᴴ * k.val) * n.val = G₀ ∧ ∀ (i : ι) {j : ι}, P j → n.val i j = (1 : Matrix ι ι (𝔸f E)) i j := by -- Since `G₀` is unimodular, it has an orthonormal basis `m`. The forms `k.valᴴ * k.val` and `G₀` -- agree on the basis vectors satisfying `P`, so Witt's theorem gives an `n` that fixes them. classical obtain ⟨m, hm, hm_gram⟩ := exists_orthonormal_Ô hG₀_unim have hk_gram : k⁻¹.valᴴ * (k.valᴴ * k.val) * k⁻¹.val = 1 := gram_inv_of_gram_eq (by rw [mul_one]) have hG₀ : m⁻¹.valᴴ * 1 * m⁻¹.val = G₀ := gram_inv_of_gram_eq hm_gram let p : {i : ι // P i} → ι := Subtype.val obtain ⟨κ, hκ, hκ_col⟩ : ∃ κ ∈ stdLevel E ι, κ.val.val * m⁻¹.val.submatrix id p = k.val.submatrix id p := by have h_cols (i j : {i : ι // P i}) : (m⁻¹.valᴴ * m⁻¹.val) (p i) (p j) = (k.valᴴ * k.val) (p i) (p j) := by rw [← h_agree i.property j.property, ← hG₀, mul_one] refine witt_Ô ?_ ?_ (ext h_cols) · exact (isPrimitiveMatrix_iff.2 ⟨m⁻¹, inv_mem hm, rfl⟩).submatrix_cols Subtype.val_injective · exact (isPrimitiveMatrix_iff.2 ⟨k, hk, rfl⟩).submatrix_cols Subtype.val_injective let n : GL ι (𝔸f E) := k⁻¹ * (κ.val * m⁻¹) have hκ_gram : κ.val.valᴴ * 1 * κ.val.val = 1 := mem_unitaryGroupOf_iff.1 κ.property have hn_gram : n.valᴴ * (k.valᴴ * k.val) * n.val = G₀ := gram_mul_of_gram_eq hk_gram (gram_mul_of_gram_eq hκ_gram hG₀) have hn_col (i : ι) {j : ι} (hj : P j) : n.val i j = (1 : Matrix ι ι (𝔸f E)) i j := calc n.val i j = (k⁻¹.val * (κ.val.val * m⁻¹.val.submatrix id p)) i ⟨j, hj⟩ := rfl _ = (k⁻¹.val * k.val.submatrix id p) i ⟨j, hj⟩ := by rw [hκ_col] _ = (k⁻¹.val * k.val) i j := rfl _ = (1 : Matrix ι ι (𝔸f E)) i j := by rw [k.inv_mul] exact ⟨n, mul_mem (inv_mem hk) (mul_mem hκ (inv_mem hm)), hn_gram, hn_col⟩ /-- Let `w : ι → ℤ` be weights, and let `G`, `G'`, `G₀`, and `n` be matrices over `𝔸f E` such that `G' * G = 1`, `G' i j = 0` when `w i + w j < 0`, and `G₀ i j = G i j` when `0 ≤ w i + w j`. If `nᴴ * G * n = G₀` and `n i j = (1 : Matrix ι ι (𝔸f E)) i j` when `0 ≤ w j`, then `n - 1` raises weights `w` by at least `1`, that is, `HasDegreeGe w w 1 (n - 1)`. -/ private lemma hasDegreeGe_sub_one_of_gram_eq {w : ι → ℤ} {G G' G₀ n : Matrix ι ι (𝔸f E)} (h_inv : G' * G = 1) (hG'_deg : HasDegreeGe w (-w) 0 G') (h_agree : ∀ {i j : ι}, 0 ≤ w i + w j → G₀ i j = G i j) (hn_gram : nᴴ * G * n = G₀) (hn_col : ∀ (i : ι) {j : ι}, 0 ≤ w j → n i j = (1 : Matrix ι ι (𝔸f E)) i j) : HasDegreeGe w w 1 (n - 1) := by intro i j h_lt obtain hj | hj := le_or_gt 0 (w j) · simp [hn_col i hj] -- The rows of `G * n` of weight at least `0` are those of `G₀`. have h_row {a : ι} (ha : 0 ≤ w a) : (G * n) a j = G₀ a j := calc (G * n) a j = (nᴴ * (G * n)) a j := by simp [Matrix.mul_apply (M := nᴴ), hn_col _ ha, Matrix.one_apply, apply_ite star] _ = G₀ a j := by rw [← mul_assoc, hn_gram] rw [show n - 1 = G' * (G * n - G) by rw [mul_sub, ← mul_assoc, h_inv, one_mul], Matrix.mul_apply] refine Finset.sum_eq_zero fun a _ ↦ ?_ obtain ha | ha := lt_or_ge (w i) (-w a) · rw [hG'_deg i a (by simpa using ha), zero_mul] · simp [h_row (show 0 ≤ w a by lia), h_agree (show 0 ≤ w a + w j by lia)] /-- Let `E` be a CM field with a primitive root of unity of order 5040, and let `k` lie in `GL(Ô)` (invertible over the integral finite adeles), with Gram matrix `G = kᴴ * k`. Suppose that `G i j = 0` for `w i + w j > 0` and `G⁻¹ i j = 0` for `w i + w j < 0`. Then a change of basis `n` in `GL(Ô)`, with `n - 1` raising the weights `w`, carries `G` to its part on the entries with `w i + w j = 0`. -/ lemma exists_gram_eq_degreeZeroPart [HasPrimitiveRoot5040 E] {w : ι → ℤ} {k : GL ι (𝔸f E)} (hk : k ∈ intGL ι (Ô E)) (hG_deg : HasDegreeGe (-w) w 0 (k.valᴴ * k.val)) (hG'_deg : HasDegreeGe w (-w) 0 (k⁻¹.val * k⁻¹.valᴴ)) : ∃ n ∈ intGL ι (Ô E), HasDegreeGe w w 1 (n.val - 1) ∧ n.valᴴ * (k.valᴴ * k.val) * n.val = degreeZeroPart (-w) w (k.valᴴ * k.val) := by -- The part `G₀` is unimodular (`isUnimodular_degreeZeroPart`), and `G` and `G₀` agree on the -- basis vectors of weight at least `0`, so `exists_intGL_gram_eq_of_isUnimodular` gives an `n` -- that fixes them; `hasDegreeGe_sub_one_of_gram_eq` then shows that `n - 1` raises weights. set G : Matrix ι ι (𝔸f E) := k.valᴴ * k.val set G' : Matrix ι ι (𝔸f E) := k⁻¹.val * k⁻¹.valᴴ set G₀ : Matrix ι ι (𝔸f E) := degreeZeroPart (-w) w G have h_inv : G' * G = 1 := by rw [mul_assoc, ← mul_assoc k⁻¹.valᴴ, ← conjTranspose_mul] simp have h_agree {i j : ι} (h_le : 0 ≤ w i + w j) : G₀ i j = G i j := by grind [degreeZeroPart_apply, hG_deg i j, Pi.neg_apply] have hG₀_unim : IsUnimodular (Ô E) G₀ := isUnimodular_degreeZeroPart (by simp [G]) (hk.isIntMatrix.conjTranspose.mul hk.isIntMatrix) (hk.isIntMatrix_inv.mul hk.isIntMatrix_inv.conjTranspose) h_inv hG_deg hG'_deg obtain ⟨n, hn_mem, hn_gram, hn_col⟩ := exists_intGL_gram_eq_of_isUnimodular (P := (0 ≤ w ·)) hk hG₀_unim fun hi hj ↦ h_agree (add_nonneg hi hj) exact ⟨n, hn_mem, hasDegreeGe_sub_one_of_gram_eq h_inv hG'_deg h_agree hn_gram hn_col, hn_gram⟩ namespace Grading /-- Hermite form for the flag of the grades: for an invertible adelic matrix `Z`, the `Ô`-lattice spanned by its columns has a basis `b` (so `Z⁻¹ * b ∈ GL(Ô)`) such that `b` and `b⁻¹` do not lower the grades of the grading `Y`. -/ lemma exists_basis_hasDegreeGe (Z : GL ι (𝔸f E)) : ∃ b : GL ι (𝔸f E), Z⁻¹ * b ∈ intGL ι (Ô E) ∧ HasDegreeGe Y.gradeOf Y.gradeOf 0 b.val ∧ HasDegreeGe Y.gradeOf Y.gradeOf 0 b⁻¹.val := by -- Upper triangularity for the reverse order on grades means that the basis does not lower grades. let wt : ι → ℤᵒᵈ := OrderDual.toDual ∘ Y.gradeOf have h_deg {A : Matrix ι ι (𝔸f E)} (hA : A.BlockTriangular wt) : HasDegreeGe Y.gradeOf Y.gradeOf 0 A := by simpa [HasDegreeGe, Matrix.BlockTriangular, wt] using hA obtain ⟨b, h_tri, h_prim⟩ : ∃ b : GL ι (𝔸f E), b.val.BlockTriangular wt ∧ IsPrimitiveMatrix (Ô E) (Z⁻¹.val * b.val) := isValuationPair_Ô.exists_isPrimitiveMatrix_mul (X := Z⁻¹.val) ⟨Z, Z.mul_inv⟩ wt have h_mem : Z⁻¹ * b ∈ intGL ι (Ô E) := by simpa only [isPrimitiveMatrix_iff, ← Units.val_mul, Units.val_inj, exists_eq_right] using h_prim exact ⟨b, h_mem, h_deg h_tri, h_deg ((parabolic wt).inv_mem h_tri)⟩ /-- The matrix `gradedGram Y.indexEquiv M`, the standard Gram matrix for the indexing of `Y` with any constant `M`, has row `i` zero outside column `Y.stringReversal i`, so it pairs grade `d` only with grade `-d`; this is stated for its image in the finite adeles. -/ lemma map_gradedGram_apply_eq_zero [Fintype X] (M : E) {i k : ι} (h_ne : -Y.gradeOf i ≠ Y.gradeOf k) : (gradedGram Y.indexEquiv M).map (algebraMap E (𝔸f E)) i k = 0 := by have hik : Y.stringReversal i ≠ k := by grind [Y.gradeOf_stringReversal i] rw [Matrix.map_apply, Y.gradedGram_apply_eq_zero M hik, map_zero] /-- The part of degree `0` of a matrix `A`, for the grades of `Y`, commutes with the projection to each grade. -/ lemma degreeZeroPart_mulVec_gradeProj (A : Matrix ι ι (𝔸f E)) (e : ℤ) (y : ι → 𝔸f E) : degreeZeroPart Y.gradeOf Y.gradeOf A *ᵥ Y.gradeProj e y = Y.gradeProj e (degreeZeroPart Y.gradeOf Y.gradeOf A *ᵥ y) := by simp only [gradeProj, mulVecLin_apply, mulVec_mulVec] congr 1 ext i k grind [mul_diagonal, diagonal_mul, degreeZeroPart_apply] /-- For a finite point `x` of `V`, let `b` be a basis of the lattice `V.lattice x` (that is, `b` differs from `V.xFin * x` by an element of `GL(Ô)`) such that `b` and `b⁻¹` do not lower the grades of the grading `Y`. Then for some `n` in `GL(Ô)`, with `n - 1` raising grades, the basis `b * n` has the same Gram matrix for the form `V.J` as the part of degree `0` of `b`. Here `E` is a CM field containing a primitive root of unity of order `5040`. -/ lemma exists_gram_mul_eq_gram_degreeZeroPart [Fintype X] [HasPrimitiveRoot5040 E] {x : Gf E ι} {b : GL ι (𝔸f E)} (hb_int : (V.xFin * x.val)⁻¹ * b ∈ intGL ι (Ô E)) (hb_deg : HasDegreeGe Y.gradeOf Y.gradeOf 0 b.val) (hb_inv_deg : HasDegreeGe Y.gradeOf Y.gradeOf 0 b⁻¹.val) : ∃ n ∈ intGL ι (Ô E), HasDegreeGe Y.gradeOf Y.gradeOf 1 (n.val - 1) ∧ (b.val * n.val)ᴴ * V.J.map (algebraMap E (𝔸f E)) * (b.val * n.val) = (degreeZeroPart Y.gradeOf Y.gradeOf b.val)ᴴ * V.J.map (algebraMap E (𝔸f E)) * degreeZeroPart Y.gradeOf Y.gradeOf b.val := by set w : ι → ℤ := Y.gradeOf set J : Matrix ι ι (𝔸f E) := V.J.map (algebraMap E (𝔸f E)) let J' : Matrix ι ι (𝔸f E) := V.J⁻¹.map (algebraMap E (𝔸f E)) -- The form and its inverse pair grade `d` only with grade `-d`. have hJ_zero {i k : ι} (h_ne : -w i ≠ w k) : J i k = 0 := by simpa only [J, Y.gram_eq] using Y.map_gradedGram_apply_eq_zero N h_ne have hJ'_deg : HasDegreeGe w (-w) 0 J' := fun i k h_lt ↦ by simp only [J', Y.J_inv_eq_gradedGram] exact Y.map_gradedGram_apply_eq_zero N⁻¹ (by grind [Pi.neg_apply]) have hJ_deg : HasDegreeGe (-w) w 0 J := fun i k h_lt ↦ hJ_zero (by grind [Pi.neg_apply]) have hJ_part : degreeZeroPart (-w) w J = J := Matrix.ext fun i k ↦ by grind [degreeZeroPart_apply, Pi.neg_apply] -- The matrix `k` of `b` in the orthonormal frame `g` of the lattice lies in `GL(Ô)`. set g : GL ι (𝔸f E) := V.xFin * x.val set k : GL ι (𝔸f E) := g⁻¹ * b have h_gram : k.valᴴ * k.val = b.valᴴ * J * b.val := by simp [k, g, J, ← Space.gram_frame_inv x, mul_assoc] have h_gram_inv : k⁻¹.val * k⁻¹.valᴴ = b⁻¹.val * J' * b⁻¹.valᴴ := by simp [k, g, J', ← Space.frame_mul_conjTranspose x, mul_assoc] have hbJ_deg : HasDegreeGe (-w) w 0 (b.valᴴ * J) := hb_deg.conjTranspose.mul hJ_deg (zero_add 0).ge have hG_deg : HasDegreeGe (-w) w 0 (k.valᴴ * k.val) := by simpa only [h_gram] using hbJ_deg.mul hb_deg (zero_add 0).ge have hG'_deg : HasDegreeGe w (-w) 0 (k⁻¹.val * k⁻¹.valᴴ) := by simpa only [h_gram_inv] using (hb_inv_deg.mul hJ'_deg (zero_add 0).ge).mul hb_inv_deg.conjTranspose (zero_add 0).ge obtain ⟨n, hn_int, hn_deg, hn⟩ := exists_gram_eq_degreeZeroPart hb_int hG_deg hG'_deg refine ⟨n, hn_int, hn_deg, ?_⟩ rw [gram_mul, ← h_gram, hn, h_gram, degreeZeroPart_mul hbJ_deg hb_deg, degreeZeroPart_mul hb_deg.conjTranspose hJ_deg, degreeZeroPart_conjTranspose, hJ_part] /-- Iwasawa decomposition for the flag of the grades of the grading `Y` of `V`, over a CM field with a primitive root of unity of order 5040: for every point `x` of the finite adelic unitary group there is a `u` such that `(1, u)`, the adelic element that is `1` at the infinite places, lies in `Y.unipotent` (its matrix in rational coordinates, minus `1`, raises grades) and the lattice `V.lattice (u * x)` of the point `u * x` is graded, that is, contains the part in each grade of each of its vectors. -/ lemma exists_isGraded [Fintype X] [HasPrimitiveRoot5040 E] (x : Gf E ι) : ∃ u : Gf E ι, ((1, u) : G E ε) ∈ Y.unipotent ∧ Y.IsGraded (V.lattice (u * x)) := by -- The lattice has a basis `b * n` with the Gram matrix of the part `d` of degree `0` of `b`. So -- `v = b * n * d⁻¹` is a unipotent isometry, and `v⁻¹` carries the lattice to the span of `d`. obtain ⟨b, hb_int, hb_deg, hb_inv_deg⟩ := Y.exists_basis_hasDegreeGe (V.xFin * x.val) obtain ⟨n, hn_int, hn_deg, hn⟩ := Y.exists_gram_mul_eq_gram_degreeZeroPart hb_int hb_deg hb_inv_deg set w : ι → ℤ := Y.gradeOf set J : Matrix ι ι (𝔸f E) := V.J.map (algebraMap E (𝔸f E)) set d : Matrix ι ι (𝔸f E) := degreeZeroPart w w b.val let d' : Matrix ι ι (𝔸f E) := degreeZeroPart w w b⁻¹.val have hd_inv : d * d' = 1 := by rw [← degreeZeroPart_mul hb_deg hb_inv_deg, b.mul_inv, degreeZeroPart_one] let v : Matrix ι ι (𝔸f E) := b.val * n.val * d' have hv_gram : vᴴ * J * v = J := by rw [gram_mul, hn, ← gram_mul, hd_inv, conjTranspose_one, one_mul, mul_one] have hv_deg : HasDegreeGe w w 1 (v - 1) := hasDegreeGe_mul_mul_sub_one hb_deg hn_deg (hasDegreeGe_degreeZeroPart _) hd_inv obtain ⟨g, hg⟩ : ∃ g : Gf E ι, V.ratCoordMatrixFin g = v := by refine ⟨U.of isUnit_one (V.xFin⁻¹.val * v * V.xFin.val) ?_, ?_⟩ · rw [gram_mul, gram_mul, gram_inv_of_gram_eq V.gram_xFin, hv_gram, V.gram_xFin] · simp [Space.ratCoordMatrixFin, mul_assoc] have hg_mem : ((1, g) : G E ε) ∈ Y.unipotent := Y.mem_unipotent_one_snd_iff.2 (hg ▸ hv_deg) have h_lattice (y : ι → 𝔸f E) : y ∈ V.lattice (g⁻¹ * x) ↔ d' *ᵥ y ∈ intVectors (Ô E) ι := by rw [← Space.mulVec_mem_lattice_mul (g := g), mul_inv_cancel_left, hg, ← mulVec_mem_intVectors_iff (mul_mem hb_int hn_int)] simp [Space.mem_lattice, v, intVectors, mul_assoc] refine ⟨g⁻¹, by simpa using inv_mem hg_mem, fun e y hy ↦ ?_⟩ rw [h_lattice] at hy ⊢ rw [Y.degreeZeroPart_mulVec_gradeProj] intro i simpa [gradeProj, mulVec_diagonal, ite_mem, d', w] using fun (_ : Y.gradeOf i = e) ↦ hy i end Grading end New end