module public import Mathlib.Analysis.Matrix.MeasurableSpace public import Mathlib.Analysis.CStarAlgebra.Classes public import TauCeti.Data.Matrix.Countable public import TauCeti.LinearAlgebra.Matrix.IndefiniteUnitaryGroup public import TauCeti.MeasureTheory.Constructions.Polish.Units public import TauCeti.Topology.Instances.Matrix public import TauCeti.Topology.MetricSpace.Polish.Matrix import Mathlib.Topology.Algebra.Group.Matrix import TauCeti.Analysis.Matrix.IndefiniteUnitaryGroup public import Lib.Speed /-! # Integral, congruence and unitary matrix groups over a ring, with their topology The file opens with a few general facts on induction, reindexing, compact, open and closed sets, and integrability. * `New.intGL`, `New.congruenceGL`: the matrices of `GL n R` that are invertible over a subring `O`, and the congruence subgroups among them; `New.intGL.toMatrix` reads such a matrix over `O`, and `New.intGL.map` applies a ring map out of `O`. * `New.U`: the unitary group of a matrix `J`, Tau Ceti's `Matrix.unitaryGroupOf J` of the `g` in `GL n R` with `star g * J * g = J`, with change of ring `New.U.map`, change of basis `New.U.conj` and determinant `New.U.det`. With Tau Ceti's `Matrix.unitaryGroupOf.isClosedEmbedding_val` and the bound on the entries of a unitary matrix, the complex unitary group of the identity matrix is compact. The file also supplies the measure space structure on matrices with its additive Haar measure, the Polish instance on unitary groups and the Borel instance on complex ones, and local compactness of unitary groups. The Polish, countability, local compactness and Borel instances on matrices and units come from Mathlib and Tau Ceti. -/ @[expose] public section noncomputable section attribute [fun_prop] Continuous.mul_const open Function Matrix MeasureTheory MulOpposite Set Notation Topology Units /-- Well-founded induction on an integer weight `w` over a finite type: a property `P` holds everywhere if it holds at each point as soon as it holds at all points of smaller weight. -/ lemma Finite.int_weight_induction {ι : Type*} [Finite ι] (w : ι → ℤ) {P : ι → Prop} (h_step : ∀ a : ι, (∀ b : ι, w b < w a → P b) → P a) (a : ι) : P a := (wellFounded_of_trans_of_irrefl fun a b : ι ↦ w a < w b).induction a h_step section Reindex variable {F : Sort*} {α β : Type*} [EquivLike F α β] /-- For an equivalence `e` from `α` to `β`, statements `∀ y, p y` and `∃ y, p y` about `β`, and finite sums and products over `β` of values in a type of universe 0, become those over `α` of the composite with `e`. The four rules are joined so that `simp` takes them as one argument. -/ lemma New.reindex_equiv (e : F) : (∀ {p : β → Prop}, (∀ y : β, p y) ↔ ∀ x : α, p (e x)) ∧ (∀ {p : β → Prop}, (∃ y : β, p y) ↔ ∃ x : α, p (e x)) ∧ ∀ [Fintype α] [Fintype β] {M : Type} (f : β → M), (∀ [AddCommMonoid M], ∑ i : β, f i = ∑ i : α, f (e i)) ∧ ∀ [CommMonoid M], ∏ i : β, f i = ∏ i : α, f (e i) := ⟨(EquivLike.surjective e).forall, (EquivLike.surjective e).exists, fun f ↦ ⟨((EquivLike.bijective e).sum_comp f).symm, ((EquivLike.bijective e).prod_comp f).symm⟩⟩ end Reindex variable {X Y : Type _} [TopologicalSpace X] [TopologicalSpace Y] {s K : Set X} {f : Y → X} /-- If K is compact and s is closed in a topological space, then s ∩ K is compact as a subset of the subspace s. -/ lemma IsCompact.preimage_val (hK : IsCompact K) (hs : IsClosed s := by infer_instance) : IsCompact (s ↓∩ K) := hs.isProperMap_subtypeVal.isCompact_preimage hK /-- The image of a compact set under a continuous map is compact; continuity is found by automation unless supplied. -/ lemma IsCompact.image_of_continuous (hs : IsCompact s) (f : X → Y) (hf : Continuous f := by fun_prop) : IsCompact (f '' s : Set Y) := hs.image hf /-- The preimage of an open set under a continuous map is open; continuity is found by automation unless supplied. -/ lemma IsOpen.preimage_of_continuous (hs : IsOpen s) (hf : Continuous f := by fun_prop) : IsOpen (f ⁻¹' s) := hs.preimage hf /-- The preimage of a closed set under a continuous map is closed; continuity is found by automation unless supplied. -/ lemma IsClosed.preimage_of_continuous (hs : IsClosed s) (hf : Continuous f := by fun_prop) : IsClosed (f ⁻¹' s) := hs.preimage hf variable {E : Type _} [NormedAddCommGroup E] [MeasurableSpace X] [OpensMeasurableSpace X] {ν : Measure X} [IsFiniteMeasureOnCompacts ν] {f : X → E} /-- A continuous function f from a Hausdorff space to a normed group is integrable on a compact set K, for a measure ν finite on compact sets. Continuity is proved automatically by default. -/ lemma IsCompact.integrableOn [T2Space X] (hK : IsCompact K) (f : X → E) (hf : Continuous f := by fun_prop) : IntegrableOn f K ν := hf.continuousOn.integrableOn_compact hK /-- A continuous function f of compact support with values in a normed group is integrable, for a measure ν finite on compact sets. Continuity is proved automatically by default. -/ lemma HasCompactSupport.integrable (hc : HasCompactSupport f) (hf : Continuous f := by fun_prop) : Integrable f ν := hf.integrable_of_hasCompactSupport hc /-- A continuous function from a compact space `X` to a normed group is integrable for every measure ν on `X` that is finite on compact sets. Continuity is proved automatically by default. -/ lemma New.DiscreteSeries.integrable_of_compactSpace [CompactSpace X] (hf : Continuous f := by fun_prop (disch := simp)) : Integrable f ν := HasCompactSupport.integrable (.of_compactSpace f) hf namespace New /-- A unit lifts along an injective monoid map if its value and inverse both lift. -/ lemma exists_units_map_eq {M N : Type*} [Monoid M] [Monoid N] (f : M →* N) (hf : Function.Injective f) {u : Nˣ} (hu : ↑u ∈ Set.range f) (hv : ↑u⁻¹ ∈ Set.range f) : ∃ v : Mˣ, Units.map f v = u := by obtain ⟨a, ha⟩ := hu obtain ⟨b, hb⟩ := hv exact ⟨⟨a, b, hf (by simp [ha, hb]), hf (by simp [ha, hb])⟩, Units.ext ha⟩ section Matrices variable {m n R S : Type*} [DecidableEq n] /-- The product measure on matrices, over Mathlib's `σ`-algebra `Matrix.instMeasurableSpace`. -/ instance [Fintype m] [Fintype n] [MeasureSpace R] : MeasureSpace (Matrix m n R) where volume := (volume : Measure (m → n → R)) /-! ### Special matrices -/ /-- For a map u: m → n of index sets, the n×m matrix whose j-th column is the standard basis vector e_{u(j)}. -/ def inclMatrix (R : Type*) [Zero R] [One R] (u : m → n) : Matrix n m R := submatrix (1 : Matrix n n R) id u /-- The diagonal complex matrix whose entries are the signs s_i = ±1. -/ def signMatrix (s : n → ℤˣ) : Matrix n n ℂ := Matrix.diagonal fun i : n ↦ (s i : ℂ) @[simp] lemma signMatrix_one : signMatrix (n := n) 1 = 1 := by simp [signMatrix] /-- The diagonal matrix of a vector of signs ε is Hermitian. -/ lemma conjTranspose_signMatrix {ε : n → ℤˣ} : (signMatrix ε)ᴴ = signMatrix ε := by simp [signMatrix] /-- Pairing two one-column matrices under a form gives a one-by-one matrix whose entry is the pairing of the corresponding vectors. -/ lemma gram_replicateCol {ι A : Type*} [Fintype ι] [Semiring A] [Star A] (J : Matrix ι ι A) (x y : ι → A) : (replicateCol Unit x)ᴴ * J * replicateCol Unit y = Matrix.scalar Unit (star x ⬝ᵥ J *ᵥ y) := by ext ⟨⟩ ⟨⟩ exact (dotProduct_mulVec (star x) J y).symm variable [Fintype n] [CommRing R] [CommRing S] {O : Subring R} /-- Multiplying M on the right by the inclusion matrix of u selects the columns u(j) of M. -/ lemma mul_inclMatrix {l : Type*} (M : Matrix l n R) (u : m → n) : M * inclMatrix R u = M.submatrix id u := mul_submatrix_one (Equiv.refl n) u M /-- Multiplying on the left by the adjoint of an inclusion matrix selects rows. -/ lemma conjTranspose_inclMatrix_mul [StarRing R] {l : Type*} (u : l → n) (M : Matrix n m R) : (inclMatrix R u)ᴴ * M = M.submatrix u id := by rw [inclMatrix, conjTranspose_submatrix, conjTranspose_one] exact one_submatrix_mul u (Equiv.refl n) M /-- The basis columns selected by an injective map are orthonormal. -/ lemma inclMatrix_gram_eq_one [StarRing R] [DecidableEq m] {e : m → n} (he : ∀ i j, e i = e j → i = j) : (inclMatrix R e)ᴴ * inclMatrix R e = 1 := by rw [conjTranspose_inclMatrix_mul] exact Matrix.submatrix_one e he /-- Multiplying by inclusion matrices on both sides selects a submatrix. -/ lemma conjTranspose_inclMatrix_mul_mul_inclMatrix [StarRing R] {l p : Type*} [Fintype m] [DecidableEq m] (M : Matrix n m R) (u : l → n) (v : p → m) : (inclMatrix R u)ᴴ * M * inclMatrix R v = M.submatrix u v := by simp only [conjTranspose_inclMatrix_mul, mul_inclMatrix, submatrix_submatrix, Function.comp_id, Function.id_comp] omit [Fintype n] in lemma one_map_ringHom (f : R →+* S) : (1 : Matrix n n R).map f = 1 := Matrix.map_one f f.map_zero f.map_one /-- The diagonal matrix of a vector of signs ε is its own inverse. -/ lemma signMatrix_mul_self (ε : n → ℤˣ) : signMatrix ε * signMatrix ε = 1 := by simp [signMatrix, ← Int.cast_mul] /-- The homomorphism sending a family of units of R to the diagonal matrix in GL_n(R) with these entries. -/ def diagGL : (n → Rˣ) →* GL n R := (Units.map (diagonalRingHom n R).toMonoidHom).comp MulEquiv.piUnits.symm.toMonoidHom @[simp] lemma coe_diagGL (t : n → Rˣ) : (diagGL t).val = Matrix.diagonal fun i : n ↦ ↑(t i) := rfl /-- The transpose of g, as an element of GL_n(R). -/ @[simps -isSimp] def transposeGL (g : GL n R) : GL n R where val := gᵀ inv := g⁻¹.valᵀ val_inv := by simp [← transpose_mul] inv_val := by simp [← transpose_mul] attribute [simp] val_transposeGL /-- For distinct indices i, j and a in R, the element 1 + aE_{ij} of GL_n(R), with inverse 1 − aE_{ij}. -/ @[simps -isSimp] def transvectionGL {i j : n} (h : i ≠ j) (a : R) : GL n R where val := transvection i j a inv := transvection i j (-a) val_inv := by simp [transvection_mul_transvection_same, h] inv_val := by simp [transvection_mul_transvection_same, h] attribute [simp] val_transvectionGL /-! ### Integral matrices and congruence subgroups -/ /-- For a subring O of R, the subgroup GL_n(O) of GL_n(R): matrices with entries in O whose inverse has entries in O. -/ def intGL (n : Type*) [Fintype n] [DecidableEq n] (O : Subring R) : Subgroup (GL n R) := (GeneralLinearGroup.map (n := n) O.subtype).range /-- A matrix lies in GL_n(O) if and only if its entries and those of its inverse lie in O. -/ lemma mem_intGL {g : GL n R} : g ∈ intGL n O ↔ (∀ i j : n, g i j ∈ O) ∧ ∀ i j : n, g⁻¹ i j ∈ O := by refine ⟨fun ⟨k, hk⟩ ↦ by simp [← hk, ← map_inv], fun ⟨h_val, h_inv⟩ ↦ ?_⟩ exact exists_units_map_eq (u := g) O.subtype.mapMatrix.toMonoidHom (Matrix.map_injective O.subtype_injective) ⟨of fun i j ↦ (⟨g i j, h_val i j⟩ : O), rfl⟩ ⟨of fun i j ↦ (⟨g⁻¹ i j, h_inv i j⟩ : O), rfl⟩ /-- The matrix over `O` with the entries of an element `k` of GL_n(O). -/ def intGL.toMatrix (k : intGL n O) : Matrix n n O := of fun i j ↦ ⟨((k : GL n R) : Matrix n n R) i j, (mem_intGL.mp k.prop).left i j⟩ /-- The entry of `toMatrix k`, the matrix over `O` of an integral matrix `k`, at `(i, j)` is the entry of `k`, read in `O`. -/ @[simp] lemma intGL.toMatrix_apply (k : intGL n O) (i j : n) : toMatrix k i j = ⟨((k : GL n R) : Matrix n n R) i j, (mem_intGL.mp k.prop).left i j⟩ := rfl /-- For a ring homomorphism f: O → S, the homomorphism GL_n(O) → GL_n(S) applying f to each entry. -/ def intGL.map (f : O →+* S) : intGL n O →* GL n S := (GeneralLinearGroup.map f).comp <| MonoidHom.toHomUnits { toFun := toMatrix map_one' := by aesop (add simp Matrix.one_apply) map_mul' := by aesop (add simp Matrix.mul_apply) } variable {f : O →+* S} {k : intGL n O} /-- The entries of the image of an integral matrix k are the images under f of its entries, read in `O`. -/ @[simp] lemma intGL.map_apply (i j : n) : map f k i j = f (toMatrix k i j) := rfl /-- An integral matrix `k` maps to `1` under `f` if and only if `f` kills every entry of `k - 1`, read in `O`. -/ lemma intGL.map_eq_one : map f k = 1 ↔ ∀ i j : n, f (toMatrix k i j - toMatrix (1 : intGL n O) i j) = 0 := by simp only [← map_one (map f), GeneralLinearGroup.ext_iff, map_apply, map_sub, sub_eq_zero] /-- For a subring O of R, the O-submodule of R spanned by a consists of the a y with y in O. -/ @[simp] lemma mem_span_singleton_iff_exists_mul {a x : R} : x ∈ O ∙ a ↔ ∃ y ∈ O, x = a * y := by simp [Submodule.mem_span_singleton, O.smul_def, mul_comm, eq_comm] /-- For an O-submodule M of R and a map e of index sets, the group of matrices in GL_n(O) whose rows e(i) are congruent to those of 1 modulo M; for e the identity, the principal congruence subgroup of level M. -/ def congruenceGL (M : Submodule O R) (e : m → n) : Subgroup (GL n R) := Subgroup.ofDiv {g ∈ intGL n O | ∀ (i : m) (j : n), (g.val - 1) (e i) j ∈ M} ⟨1, by simp⟩ <| by rintro g ⟨hg, hg_row⟩ k ⟨hk, hk_row⟩ refine ⟨div_mem hg hk, fun i j ↦ ?_⟩ -- `g k⁻¹ - 1 = ((g - 1) - (k - 1)) k⁻¹`, and `k⁻¹` has entries in `O`. have h_eq : (g * k⁻¹).val - 1 = ((g.val - 1) - (k.val - 1)) * k⁻¹.val := by simp [sub_mul] rw [h_eq, Matrix.mul_apply] refine sum_mem fun l _ ↦ ?_ rw [mul_comm] exact M.smul_mem ⟨k⁻¹.val l j, (mem_intGL.mp hk).right l j⟩ (sub_mem (hg_row i l) (hk_row i l)) end Matrices /-! ### Unitary groups -/ section Unitary variable {m n R S : Type*} [Fintype n] [CommRing R] [CommRing S] [StarRing R] [StarRing S] /-- For a hermitian form, orthogonality is symmetric, also for frames of different widths. -/ lemma gram_eq_zero_symm {p : Type*} {J : Matrix n n R} (hJ : J.IsHermitian) {v : Matrix n m R} {w : Matrix n p R} (hvw : vᴴ * (J * w) = 0) : wᴴ * (J * v) = 0 := by simpa [hJ.eq, Matrix.mul_assoc] using congrArg conjTranspose hvw /-- Orthogonality for a hermitian form `J` is symmetric. -/ lemma orthogonal_symm {J : Matrix n n R} (hJ : Jᴴ = J) {ρ ρ' : Type} {x : Matrix n ρ R} {y : Matrix n ρ' R} (h : xᴴ * J * y = 0) : yᴴ * J * x = 0 := by rw [Matrix.mul_assoc] at h ⊢ exact gram_eq_zero_symm hJ h /-- A ring map f that commutes with the involutions carries zᴴ B z to (f z)ᴴ (f B) (f z), including for a rectangular matrix z. -/ lemma map_conjTranspose_mul_mul (f : R →+* S) (hf : ∀ x : R, f (star x) = star (f x)) (z : Matrix n m R) (B : Matrix n n R) : (zᴴ * B * z).map f = (z.map f)ᴴ * B.map f * z.map f := by simp [conjTranspose_map _ hf] /-- The Gram matrix of XY for the form J is Yᴴ (Xᴴ J X) Y. -/ lemma gram_mul {c : Type*} [Fintype m] (X : Matrix n m R) (J : Matrix n n R) (Y : Matrix m c R) : (X * Y)ᴴ * J * (X * Y) = Yᴴ * (Xᴴ * J * X) * Y := by simp [Matrix.mul_assoc] /-- The Gram matrix of a product for the standard hermitian form. -/ lemma gram_mul_standard {c : Type*} [Fintype m] (X : Matrix n m R) (Y : Matrix m c R) : (X * Y)ᴴ * (X * Y) = Yᴴ * (Xᴴ * X) * Y := by simp [Matrix.mul_assoc] variable [DecidableEq n] /-- If x carries the form J to J' and y carries J' to J'', then xy carries J to J''. -/ lemma gram_mul_of_gram_eq {J J' J'' : Matrix n n R} {x y : GL n R} (hx : x.valᴴ * J * x = J') (hy : y.valᴴ * J' * y = J'') : (x * y).valᴴ * J * (x * y).val = J'' := by rw [Units.val_mul, gram_mul, hx, hy] /-- If x carries the form J to J', then its inverse carries J' to J. -/ lemma gram_inv_of_gram_eq {J J' : Matrix n n R} {x : GL n R} (hx : x.valᴴ * J * x = J') : x⁻¹.valᴴ * J' * x⁻¹ = J := by simp [← hx, ← gram_mul] /-- The unitary group U(J) of a matrix J over a commutative ring with involution: Tau Ceti's `Matrix.unitaryGroupOf J`, the g in GL_n(R) with `star g * J * g = J`. -/ abbrev U (J : Matrix n n R) : Subgroup (GL n R) := unitaryGroupOf J /-- For a vector of signs ε, the unitary group U(J) of the diagonal matrix J=diag(ε). -/ abbrev USign (ε : n → ℤˣ) := U (signMatrix ε) variable {J : Matrix n n R} -- An element of a unitary group is read as its matrix. instance : CoeOut (U J) (Matrix n n R) := ⟨(·.val.val)⟩ namespace U /-- For g in the unitary group U(J), one has J g⁻¹ = gᴴ J. -/ lemma form_mul_inv_eq (g : U J) : J * ((g⁻¹ : U J) : Matrix n n R) = (g : Matrix n n R)ᴴ * J := (mul_inv_eq_iff_eq_mul g.val).mpr (mem_unitaryGroupOf_iff.mp g.prop).symm /-- If J is an involution, the inverse of g in the unitary group U(J) is J gᴴ J. -/ lemma coe_inv (hJ : J * J = 1) (g : U J) : ((g⁻¹ : U J) : Matrix n n R) = J * (g : Matrix n n R)ᴴ * J := by rw [mul_assoc, ← form_mul_inv_eq, ← mul_assoc, hJ, one_mul] /-- In the unitary group of the identity matrix, the inverse is the conjugate transpose. -/ lemma inv_val_eq_conjTranspose (g : U (1 : Matrix n n R)) : ((g⁻¹ : U (1 : Matrix n n R)) : Matrix n n R) = (g : Matrix n n R)ᴴ := by simpa using form_mul_inv_eq g /-- An element g of U(J) preserves the pairing Aᴴ J B of matrices A and B. -/ lemma gram_invariant (g : U J) {a b : Type*} (A : Matrix n a R) (B : Matrix n b R) : ((g : Matrix n n R) * A)ᴴ * J * ((g : Matrix n n R) * B) = Aᴴ * J * B := by simp [Matrix.mul_assoc, ← form_mul_inv_eq] /-- An element g of U(J) preserves the sesquilinear form with matrix J. -/ lemma form_mulVec_mulVec (g : U J) (x y : n → R) : star (g *ᵥ x) ⬝ᵥ J *ᵥ g *ᵥ y = star x ⬝ᵥ J *ᵥ y := mem_unitaryGroupOf_iff_forall_dotProduct.mp g.prop x y /-- For invertible J and a matrix M with MᴴJM = J, the element of U(J) with matrix M. -/ @[simps! coe_val] def of (hJ : IsUnit J) M (h : Mᴴ * J * M = J) : U J := ⟨(isUnit_of_mul_isUnit_right (by rwa [h] : IsUnit (Mᴴ * J * M))).unit, mem_unitaryGroupOf_iff.2 h⟩ /-- For a ring homomorphism f commuting with the involutions and carrying J to J', the homomorphism U(J) → U(J') applying f to each entry. By default `simp` proves both conditions. -/ def map (f : R →+* S) (hf : ∀ x : R, f (star x) = star (f x) := by simp) {J : Matrix n n R} {J' : Matrix n n S} (h : J.map f = J' := by simp) : U J →* U J' := ((GeneralLinearGroup.map f).comp (U J).subtype).codRestrict (U J') fun g ↦ by -- Apply `f` to `gᴴ * J * g = J`. rw [mem_unitaryGroupOf_iff] change star ((g : Matrix n n R).map f) * J' * (g : Matrix n n R).map f = J' rw [star_eq_conjTranspose, ← h, ← map_conjTranspose_mul_mul f hf, ← star_eq_conjTranspose, mem_unitaryGroupOf_iff.mp g.prop] /-- Let `f : R → S` be an injective ring map that commutes with the involutions and carries the invertible n × n matrix `J` over `R` to `J'`. An element `g` of the unitary group `U J'` whose matrix is the image under `f` of a matrix `M` over `R` is the image of an element of `U J` with matrix `M`. -/ lemma mem_range_map {f : R →+* S} (hf_star : ∀ x : R, f (star x) = star (f x)) (hf_inj : Injective f) {J : Matrix n n R} (hJ : IsUnit J) {J' : Matrix n n S} (hJ_map : J.map f = J') {g : U J'} {M : Matrix n n R} (hM_map : M.map f = (g : Matrix n n S)) : ∃ k : U J, (k : Matrix n n R) = M ∧ map f hf_star hJ_map k = g := by -- `M` preserves `J` because its image under the injective map `f` preserves `J'`. have h_form : (Mᴴ * J * M).map f = J.map f := by rw [map_conjTranspose_mul_mul f hf_star, hM_map, hJ_map, ← star_eq_conjTranspose, mem_unitaryGroupOf_iff.mp g.prop] exact ⟨of hJ M (map_injective hf_inj h_form), rfl, Subtype.ext (Units.ext hM_map)⟩ /-- A unitary matrix descends along an injective star-preserving map when each entry descends. -/ lemma exists_map_eq_of_entries {f : R →+* S} (hf : ∀ x : R, f (star x) = star (f x)) (hinj : Injective f) {J : Matrix n n R} (hJ : IsUnit J) {J' : Matrix n n S} (hJJ : J.map f = J') (g : U J') (h : ∀ i j, (g : Matrix n n S) i j ∈ f.range) : ∃ k : U J, map f hf hJJ k = g := by choose M hM using h obtain ⟨k, -, hk⟩ := mem_range_map hf hinj hJ hJJ (M := .of M) (ext hM) exact ⟨k, hk⟩ /-- For x in GL_n(R) with xᴴJx = J', the isomorphism U(J') ≅ U(J), g ↦ x g x⁻¹. -/ @[simps! apply_coe symm_apply_coe] def conj (x : GL n R) {J} {J' : Matrix n n R} (h : x.valᴴ * J * x = J') : U J' ≃* U J where toFun g := ⟨x * g * x⁻¹, mem_unitaryGroupOf_iff.2 <| gram_mul_of_gram_eq (gram_mul_of_gram_eq h (mem_unitaryGroupOf_iff.1 g.property)) (gram_inv_of_gram_eq h)⟩ invFun g := ⟨x⁻¹ * g * x, mem_unitaryGroupOf_iff.2 <| gram_mul_of_gram_eq (gram_mul_of_gram_eq (gram_inv_of_gram_eq h) (mem_unitaryGroupOf_iff.1 g.property)) h⟩ left_inv g := by simp [mul_assoc] right_inv g := by simp [mul_assoc] map_mul' g k := by simp [mul_assoc] /-- For J with unit determinant, the determinant as a homomorphism from U(J) to the group of elements u of R with uū = 1. -/ def det (hJ : IsUnit J.det) : U J →* unitary R := MonoidHom.mk' (fun g ↦ ⟨(g : Matrix n n R).det, det_mem_unitary_of_mem_unitaryGroupOf ((isUnit_iff_isUnit_det J).mpr hJ) g.prop⟩) (by simp) /-- Let `f : R → S` be a continuous ring map that commutes with the involutions and carries `J` to `J'`. The induced map `U J → U J'` of unitary groups is continuous. -/ lemma continuous_map {f : R →+* S} [TopologicalSpace R] [TopologicalSpace S] (hf_cont : Continuous f := by fun_prop) {hf_star : ∀ x : R, f (star x) = star (f x)} {J' : Matrix n n S} {hJ_map : J.map f = J'} : Continuous (map f hf_star hJ_map : U J → U J') := (by fun_prop : Continuous fun g : U J ↦ GeneralLinearGroup.map f (g : GL n R)).subtype_mk _ end U end Unitary /-! ### Topology of unitary groups -/ section Topology variable {m n R S : Type*} [DecidableEq n] [Fintype n] [CommRing R] [StarRing R] [TopologicalSpace R] [IsTopologicalRing R] [ContinuousStar R] instance (J : Matrix n n R) [T2Space R] [LocallyCompactSpace R] : LocallyCompactSpace (U J) := (isClosed_unitaryGroupOf J).locallyCompactSpace instance (J : Matrix n n R) [PolishSpace R] : PolishSpace (U J) := (isClosed_unitaryGroupOf J).polishSpace variable {J : Matrix n n R} [T2Space R] omit [IsTopologicalRing R] [ContinuousStar R] in /-- A subgroup `H` of `U J` that is described by asking the entries `(i, j)` with `p i j` to equal those of the identity matrix is closed. -/ lemma isClosed_of_entries_eq_one {H : Subgroup (U J)} {p : n → n → Prop} (hH : ∀ {g : U J}, g ∈ H ↔ ∀ i j : n, p i j → (g : Matrix n n R) i j = (1 : Matrix n n R) i j) : IsClosed (H : Set (U J)) := by -- The `(i, j)` entry is continuous and constant on `H`, hence also on its closure. refine isClosed_of_closure_subset fun g hg ↦ hH.mpr fun i j hij ↦ ?_ exact EqOn.closure (f := fun k : U J ↦ (k : Matrix n n R) i j) (fun k hk ↦ hH.mp hk i j hij) (by fun_prop) continuous_const hg /-- An element of the complex unitary group U(1) of the identity matrix is a unitary matrix. -/ lemma U_one_mem_unitaryGroup (g : U (1 : Matrix n n ℂ)) : (g : Matrix n n ℂ) ∈ unitaryGroup n ℂ := by simpa [mem_unitaryGroup_iff', star_eq_conjTranspose] using mem_unitaryGroupOf_iff.mp g.prop instance : CompactSpace (U (1 : Matrix n n ℂ)) := by -- Pull back Tau Ceti's compact set of unitary matrices along the closed embedding. simpa [← isCompact_univ_iff, Set.preimage, U_one_mem_unitaryGroup] using (Matrix.unitaryGroupOf.isClosedEmbedding_val isUnit_one).isCompact_preimage (TauCeti.Matrix.isCompact_unitaryGroup (n := n) (𝕜 := ℂ)) instance : CompactSpace (U (signMatrix (n := n) 1)) := signMatrix_one.substr inferInstance /-- For a complex matrix J, the unitary group U(J) carries the Borel σ-algebra of its topology. -/ instance U.borelSpace {J : Matrix n n ℂ} : BorelSpace (U J) := inferInstance variable {A : Type*} [Fintype m] [AddGroup A] [TopologicalSpace A] [MeasureSpace A] [(volume (α := A)).IsAddHaarMeasure] [SigmaFinite (volume (α := A))] [MeasurableAdd A] instance : SigmaFinite (volume (α := Matrix m n A)) := Measure.pi.sigmaFinite _ /-- The product measure on functions from `n` to `A` is an additive Haar measure. -/ instance isAddHaarMeasure_pi : (volume (α := n → A)).IsAddHaarMeasure where instance : (volume (α := Matrix m n A)).IsAddHaarMeasure := isAddHaarMeasure_pi end Topology end New end