filename
stringlengths
5
42
content
stringlengths
15
319k
Equivalence.lean
/- Copyright (c) 2022 Joël Riou. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joël Riou -/ import Mathlib.AlgebraicTopology.DoldKan.EquivalencePseudoabelian import Mathlib.AlgebraicTopology.DoldKan.Normalized /-! # The Dold-Kan correspondence The Dold-Kan correspondence states that for any abelian category `A`, there is an equivalence between the category of simplicial objects in `A` and the category of chain complexes in `A` (with degrees indexed by `ℕ` and the homological convention that the degree is decreased by the differentials). In this file, we finish the construction of this equivalence by providing `CategoryTheory.Abelian.DoldKan.equivalence` which is of type `SimplicialObject A ≌ ChainComplex A ℕ` for any abelian category `A`. The functor `SimplicialObject A ⥤ ChainComplex A ℕ` of this equivalence is definitionally equal to `normalizedMooreComplex A`. ## Overall strategy of the proof of the correspondence Before starting the implementation of the proof in Lean, the author noticed that the Dold-Kan equivalence not only applies to abelian categories, but should also hold generally for any pseudoabelian category `C` (i.e. a category with instances `[Preadditive C]` `[HasFiniteCoproducts C]` and `[IsIdempotentComplete C]`): this is `CategoryTheory.Idempotents.DoldKan.equivalence`. When the alternating face map complex `K[X]` of a simplicial object `X` in an abelian is studied, it is shown that it decomposes as a direct sum of the normalized subcomplex and of the degenerate subcomplex. The crucial observation is that in this decomposition, the projection on the normalized subcomplex can be defined in each degree using simplicial operators. Then, the definition of this projection `PInfty : K[X] ⟶ K[X]` can be carried out for any `X : SimplicialObject C` when `C` is a preadditive category. The construction of the endomorphism `PInfty` is done in the files `Homotopies.lean`, `Faces.lean`, `Projections.lean` and `PInfty.lean`. Eventually, as we would also like to show that the inclusion of the normalized Moore complex is a homotopy equivalence (cf. file `HomotopyEquivalence.lean`), this projection `PInfty` needs to be homotopic to the identity. In our construction, we get this for free because `PInfty` is obtained by altering the identity endomorphism by null homotopic maps. More details about this aspect of the proof are in the file `Homotopies.lean`. When the alternating face map complex `K[X]` is equipped with the idempotent endomorphism `PInfty`, it becomes an object in `Karoubi (ChainComplex C ℕ)` which is the idempotent completion of the category `ChainComplex C ℕ`. In `FunctorN.lean`, we obtain this functor `N₁ : SimplicialObject C ⥤ Karoubi (ChainComplex C ℕ)`, which is formally extended as `N₂ : Karoubi (SimplicialObject C) ⥤ Karoubi (ChainComplex C ℕ)`. (Here, some functors have an index which is the number of occurrences of `Karoubi` at the source or the target.) In `FunctorGamma.lean`, assuming that the category `C` is additive, we define the functor in the other direction `Γ₂ : Karoubi (ChainComplex C ℕ) ⥤ Karoubi (SimplicialObject C)` as the formal extension of a functor `Γ₀ : ChainComplex C ℕ ⥤ SimplicialObject C` which is defined similarly as in [*Simplicial Homotopy Theory* by Goerss-Jardine][goerss-jardine-2009]. In `Degeneracies.lean`, we show that `PInfty` vanishes on the image of degeneracy operators, which is one of the key properties that makes it possible to construct the isomorphism `N₂Γ₂ : Γ₂ ⋙ N₂ ≅ 𝟭 (Karoubi (ChainComplex C ℕ))`. The rest of the proof follows the strategy in the [original paper by Dold][dold1958]. We show that the functor `N₂` reflects isomorphisms in `NReflectsIso.lean`: this relies on a decomposition of the identity of `X _⦋n⦌` using `PInfty.f n` and degeneracies obtained in `Decomposition.lean`. Then, in `NCompGamma.lean`, we construct a natural transformation `Γ₂N₂.trans : N₂ ⋙ Γ₂ ⟶ 𝟭 (Karoubi (SimplicialObject C))`. It is shown that it is an isomorphism using the fact that `N₂` reflects isomorphisms, and because we can show that the composition `N₂ ⟶ N₂ ⋙ Γ₂ ⋙ N₂ ⟶ N₂` is the identity (see `identity_N₂`). The fact that `N₂` is defined as a formal direct factor makes the proof easier because we only have to compare endomorphisms of an alternating face map complex `K[X]` and we do not have to worry with inclusions of kernel subobjects. In `EquivalenceAdditive.lean`, we obtain the equivalence `equivalence : Karoubi (SimplicialObject C) ≌ Karoubi (ChainComplex C ℕ)`. It is in the namespace `CategoryTheory.Preadditive.DoldKan`. The functors in this equivalence are named `N` and `Γ`: by definition, they are `N₂` and `Γ₂`. In `EquivalencePseudoabelian.lean`, assuming `C` is idempotent complete, we obtain `equivalence : SimplicialObject C ≌ ChainComplex C ℕ` in the namespace `CategoryTheory.Idempotents.DoldKan`. This could be roughly obtained by composing the previous equivalence with the equivalences `SimplicialObject C ≌ Karoubi (SimplicialObject C)` and `Karoubi (ChainComplex C ℕ) ≌ ChainComplex C ℕ`. Instead, we polish this construction in `Compatibility.lean` by ensuring good definitional properties of the equivalence (e.g. the inverse functor is definitionally equal to `Γ₀' : ChainComplex C ℕ ⥤ SimplicialObject C`) and showing compatibilities for the unit and counit isomorphisms. In this file `Equivalence.lean`, assuming the category `A` is abelian, we obtain `equivalence : SimplicialObject A ≌ ChainComplex A ℕ` in the namespace `CategoryTheory.Abelian.DoldKan`. This is obtained by replacing the functor `CategoryTheory.Idempotents.DoldKan.N` of the equivalence in the pseudoabelian case with the isomorphic functor `normalizedMooreComplex A` thanks to the isomorphism obtained in `Normalized.lean`. TODO: Show functoriality properties of the three equivalences above. More precisely, for example in the case of abelian categories `A` and `B`, if `F : A ⥤ B` is an additive functor, we can show that the functors `N` for `A` and `B` are compatible with the functors `SimplicialObject A ⥤ SimplicialObject B` and `ChainComplex A ℕ ⥤ ChainComplex B ℕ` induced by `F`. (Note that this does not require that `F` is an exact functor!) TODO: Introduce the degenerate subcomplex `D[X]` which is generated by degenerate simplices, show that the projector `PInfty` corresponds to a decomposition `K[X] ≅ N[X] ⊞ D[X]`. TODO: dualise all of this as `CosimplicialObject A ⥤ CochainComplex A ℕ`. (It is unclear what is the best way to do this. The exact design may be decided when it is needed.) ## References * [Albrecht Dold, Homology of Symmetric Products and Other Functors of Complexes][dold1958] * [Paul G. Goerss, John F. Jardine, Simplicial Homotopy Theory][goerss-jardine-2009] -/ noncomputable section open CategoryTheory Category Idempotents variable {A : Type*} [Category A] [Abelian A] namespace CategoryTheory namespace Abelian namespace DoldKan open AlgebraicTopology.DoldKan /-- The functor `N` for the equivalence is `normalizedMooreComplex A` -/ def N : SimplicialObject A ⥤ ChainComplex A ℕ := AlgebraicTopology.normalizedMooreComplex A /-- The functor `Γ` for the equivalence is the same as in the pseudoabelian case. -/ def Γ : ChainComplex A ℕ ⥤ SimplicialObject A := Idempotents.DoldKan.Γ /-- The comparison isomorphism between `normalizedMooreComplex A` and the functor `Idempotents.DoldKan.N` from the pseudoabelian case -/ @[simps!] def comparisonN : (N : SimplicialObject A ⥤ _) ≅ Idempotents.DoldKan.N := calc N ≅ N ⋙ 𝟭 _ := Functor.leftUnitor N _ ≅ N ⋙ (toKaroubiEquivalence _).functor ⋙ (toKaroubiEquivalence _).inverse := Functor.isoWhiskerLeft _ (toKaroubiEquivalence _).unitIso _ ≅ (N ⋙ (toKaroubiEquivalence _).functor) ⋙ (toKaroubiEquivalence _).inverse := Iso.refl _ _ ≅ N₁ ⋙ (toKaroubiEquivalence _).inverse := Functor.isoWhiskerRight (N₁_iso_normalizedMooreComplex_comp_toKaroubi A).symm _ _ ≅ Idempotents.DoldKan.N := Iso.refl _ /-- The Dold-Kan equivalence for abelian categories -/ @[simps! functor] def equivalence : SimplicialObject A ≌ ChainComplex A ℕ := (Idempotents.DoldKan.equivalence (C := A)).changeFunctor comparisonN.symm theorem equivalence_inverse : (equivalence : SimplicialObject A ≌ _).inverse = Γ := rfl end DoldKan end Abelian end CategoryTheory
Equivalence.lean
/- Copyright (c) 2025 Christian Merten. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Christian Merten -/ import Mathlib.CategoryTheory.Galois.EssSurj import Mathlib.CategoryTheory.Action.Continuous import Mathlib.Topology.Category.FinTopCat /-! # Fiber functors induce an equivalence of categories Let `C` be a Galois category with fiber functor `F`. In this file we conclude that the induced functor from `C` to the category of finite, discrete `Aut F`-sets is an equivalence of categories. -/ universe u₂ u₁ w open CategoryTheory namespace CategoryTheory variable {C : Type u₁} [Category.{u₂} C] {F : C ⥤ FintypeCat.{w}} namespace PreGaloisCategory variable [GaloisCategory C] [FiberFunctor F] open scoped FintypeCatDiscrete variable (F) in /-- The induced functor from `C` to the category of finite, discrete `Aut F`-sets. -/ @[simps! obj_obj map] def functorToContAction : C ⥤ ContAction FintypeCat (Aut F) := ObjectProperty.lift _ (functorToAction F) (fun X ↦ continuousSMul_aut_fiber F X) instance : (functorToContAction F).Faithful := inferInstanceAs <| (ObjectProperty.lift _ _ _).Faithful instance : (functorToContAction F).Full := inferInstanceAs <| (ObjectProperty.lift _ _ _).Full instance {F : C ⥤ FintypeCat.{u₁}} [FiberFunctor F] : (functorToContAction F).EssSurj where mem_essImage X := by have : ContinuousSMul (Aut F) X.obj.V.carrier := X.2 obtain ⟨A, ⟨i⟩⟩ := exists_lift_of_continuous (F := F) X exact ⟨A, ⟨ObjectProperty.isoMk _ i⟩⟩ instance : (functorToContAction F).EssSurj := by let F' : C ⥤ FintypeCat.{u₁} := F ⋙ FintypeCat.uSwitch.{w, u₁} letI : FiberFunctor F' := FiberFunctor.comp_right _ have : (functorToContAction F').EssSurj := inferInstance let f : Aut F ≃ₜ* Aut F' := (autEquivAutWhiskerRight F (FintypeCat.uSwitchEquivalence.{w, u₁}).fullyFaithfulFunctor) let equiv : ContAction FintypeCat.{u₁} (Aut F') ≌ ContAction FintypeCat.{w} (Aut F) := (FintypeCat.uSwitchEquivalence.{u₁, w}.mapContAction (Aut F') (fun X ↦ by rw [Action.isContinuous_def] change Continuous ((fun p ↦ (FintypeCat.uSwitchEquiv X.obj.V).symm p) ∘ (fun p : Aut F' × _ ↦ (X.obj.ρ p.1) p.2) ∘ (fun p : Aut F' × _ ↦ (p.1, FintypeCat.uSwitchEquiv _ p.2))) have : Continuous (fun p : Aut F' × _ ↦ (X.obj.ρ p.1) p.2) := X.2.1 fun_prop) (fun X ↦ by rw [Action.isContinuous_def] change Continuous ((fun p ↦ (FintypeCat.uSwitchEquiv X.obj.V).symm p) ∘ (fun p : Aut F' × _ ↦ (X.obj.ρ p.1) p.2) ∘ (fun p : Aut F' × _ ↦ (p.1, FintypeCat.uSwitchEquiv _ p.2))) have : Continuous (fun p : Aut F' × _ ↦ (X.obj.ρ p.1) p.2) := X.2.1 fun_prop)).trans <| ContAction.resEquiv _ f have : functorToContAction F ≅ functorToContAction F' ⋙ equiv.functor := NatIso.ofComponents (fun X ↦ ObjectProperty.isoMk _ (Action.mkIso (FintypeCat.uSwitchEquivalence.unitIso.app _) (fun g ↦ FintypeCat.uSwitchEquivalence.unitIso.hom.naturality (g.hom.app X)))) (fun f ↦ by ext : 2 exact FintypeCat.uSwitchEquivalence.unitIso.hom.naturality (F.map f)) exact Functor.essSurj_of_iso this.symm /-- Any fiber functor `F` induces an equivalence of categories with the category of finite and discrete `Aut F`-sets. -/ @[stacks 0BN4] instance : (functorToContAction F).IsEquivalence where end PreGaloisCategory end CategoryTheory
Basic.lean
/- Copyright (c) 2020 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.Analysis.SpecialFunctions.Pow.NNReal import Mathlib.MeasureTheory.Constructions.BorelSpace.Complex import Mathlib.MeasureTheory.Constructions.BorelSpace.Metric import Mathlib.MeasureTheory.Constructions.BorelSpace.Real /-! # Measurability of real and complex functions We show that most standard real and complex functions are measurable, notably `exp`, `cos`, `sin`, `cosh`, `sinh`, `log`, `pow`, `arcsin`, `arccos`. See also `MeasureTheory.Function.SpecialFunctions.Arctan` and `MeasureTheory.Function.SpecialFunctions.Inner`, which have been split off to minimize imports. -/ -- Guard against import creep: assert_not_exists InnerProductSpace Real.arctan FiniteDimensional.proper noncomputable section open NNReal ENNReal MeasureTheory namespace Real variable {α : Type*} {_ : MeasurableSpace α} {f : α → ℝ} {μ : MeasureTheory.Measure α} @[measurability] theorem measurable_exp : Measurable exp := continuous_exp.measurable @[measurability] theorem measurable_log : Measurable log := measurable_of_measurable_on_compl_singleton 0 <| Continuous.measurable <| continuousOn_iff_continuous_restrict.1 continuousOn_log lemma measurable_of_measurable_exp (hf : Measurable (fun x ↦ exp (f x))) : Measurable f := by have : f = fun x ↦ log (exp (f x)) := by ext; rw [log_exp] rw [this] exact measurable_log.comp hf lemma aemeasurable_of_aemeasurable_exp (hf : AEMeasurable (fun x ↦ exp (f x)) μ) : AEMeasurable f μ := by have : f = fun x ↦ log (exp (f x)) := by ext; rw [log_exp] rw [this] exact measurable_log.comp_aemeasurable hf lemma aemeasurable_of_aemeasurable_exp_mul {t : ℝ} (ht : t ≠ 0) (hf : AEMeasurable (fun x ↦ exp (t * f x)) μ) : AEMeasurable f μ := by simpa only [mul_div_cancel_left₀ _ ht] using (aemeasurable_of_aemeasurable_exp hf).div (aemeasurable_const (b := t)) @[measurability] theorem measurable_sin : Measurable sin := continuous_sin.measurable @[measurability] theorem measurable_cos : Measurable cos := continuous_cos.measurable @[measurability] theorem measurable_sinh : Measurable sinh := continuous_sinh.measurable @[measurability] theorem measurable_cosh : Measurable cosh := continuous_cosh.measurable @[measurability] theorem measurable_arcsin : Measurable arcsin := continuous_arcsin.measurable @[measurability] theorem measurable_arccos : Measurable arccos := continuous_arccos.measurable end Real namespace Complex @[measurability] theorem measurable_re : Measurable re := continuous_re.measurable @[measurability] theorem measurable_im : Measurable im := continuous_im.measurable @[measurability] theorem measurable_ofReal : Measurable ((↑) : ℝ → ℂ) := continuous_ofReal.measurable @[measurability] theorem measurable_exp : Measurable exp := continuous_exp.measurable @[measurability] theorem measurable_sin : Measurable sin := continuous_sin.measurable @[measurability] theorem measurable_cos : Measurable cos := continuous_cos.measurable @[measurability] theorem measurable_sinh : Measurable sinh := continuous_sinh.measurable @[measurability] theorem measurable_cosh : Measurable cosh := continuous_cosh.measurable @[measurability] theorem measurable_arg : Measurable arg := have A : Measurable fun x : ℂ => Real.arcsin (x.im / ‖x‖) := Real.measurable_arcsin.comp (measurable_im.div measurable_norm) have B : Measurable fun x : ℂ => Real.arcsin ((-x).im / ‖x‖) := Real.measurable_arcsin.comp ((measurable_im.comp measurable_neg).div measurable_norm) Measurable.ite (isClosed_le continuous_const continuous_re).measurableSet A <| Measurable.ite (isClosed_le continuous_const continuous_im).measurableSet (B.add_const _) (B.sub_const _) @[measurability] theorem measurable_log : Measurable log := (measurable_ofReal.comp <| Real.measurable_log.comp measurable_norm).add <| (measurable_ofReal.comp measurable_arg).mul_const I end Complex section RealComposition open Real variable {α : Type*} {m : MeasurableSpace α} {f : α → ℝ} (hf : Measurable f) include hf @[measurability, fun_prop] protected theorem Measurable.exp : Measurable fun x => Real.exp (f x) := Real.measurable_exp.comp hf @[measurability, fun_prop] protected theorem Measurable.log : Measurable fun x => log (f x) := measurable_log.comp hf @[measurability, fun_prop] protected theorem Measurable.cos : Measurable fun x ↦ cos (f x) := measurable_cos.comp hf @[measurability, fun_prop] protected theorem Measurable.sin : Measurable fun x ↦ sin (f x) := measurable_sin.comp hf @[measurability, fun_prop] protected theorem Measurable.cosh : Measurable fun x ↦ cosh (f x) := measurable_cosh.comp hf @[measurability, fun_prop] protected theorem Measurable.sinh : Measurable fun x ↦ sinh (f x) := measurable_sinh.comp hf @[measurability, fun_prop] protected theorem Measurable.sqrt : Measurable fun x => √(f x) := continuous_sqrt.measurable.comp hf end RealComposition section RealComposition open Real variable {α : Type*} {m : MeasurableSpace α} {μ : Measure α} {f : α → ℝ} (hf : AEMeasurable f μ) include hf @[measurability, fun_prop] protected lemma AEMeasurable.exp : AEMeasurable (fun x ↦ exp (f x)) μ := measurable_exp.comp_aemeasurable hf @[measurability, fun_prop] protected lemma AEMeasurable.log : AEMeasurable (fun x ↦ log (f x)) μ := measurable_log.comp_aemeasurable hf @[measurability, fun_prop] protected lemma AEMeasurable.cos : AEMeasurable (fun x ↦ cos (f x)) μ := measurable_cos.comp_aemeasurable hf @[measurability, fun_prop] protected lemma AEMeasurable.sin : AEMeasurable (fun x ↦ sin (f x)) μ := measurable_sin.comp_aemeasurable hf @[measurability, fun_prop] protected lemma AEMeasurable.cosh : AEMeasurable (fun x ↦ cosh (f x)) μ := measurable_cosh.comp_aemeasurable hf @[measurability, fun_prop] protected lemma AEMeasurable.sinh : AEMeasurable (fun x ↦ sinh (f x)) μ := measurable_sinh.comp_aemeasurable hf @[measurability, fun_prop] protected lemma AEMeasurable.sqrt : AEMeasurable (fun x ↦ √(f x)) μ := continuous_sqrt.measurable.comp_aemeasurable hf end RealComposition section ComplexComposition open Complex variable {α : Type*} {m : MeasurableSpace α} {f : α → ℂ} (hf : Measurable f) include hf @[measurability, fun_prop] protected theorem Measurable.cexp : Measurable fun x => Complex.exp (f x) := Complex.measurable_exp.comp hf @[measurability, fun_prop] protected theorem Measurable.ccos : Measurable fun x => Complex.cos (f x) := Complex.measurable_cos.comp hf @[measurability, fun_prop] protected theorem Measurable.csin : Measurable fun x => Complex.sin (f x) := Complex.measurable_sin.comp hf @[measurability, fun_prop] protected theorem Measurable.ccosh : Measurable fun x => Complex.cosh (f x) := Complex.measurable_cosh.comp hf @[measurability, fun_prop] protected theorem Measurable.csinh : Measurable fun x => Complex.sinh (f x) := Complex.measurable_sinh.comp hf @[measurability, fun_prop] protected theorem Measurable.carg : Measurable fun x => arg (f x) := measurable_arg.comp hf @[measurability, fun_prop] protected theorem Measurable.clog : Measurable fun x => Complex.log (f x) := measurable_log.comp hf end ComplexComposition section ComplexComposition open Complex variable {α : Type*} {m : MeasurableSpace α} {μ : Measure α} {f : α → ℂ} (hf : AEMeasurable f μ) include hf @[measurability, fun_prop] protected lemma AEMeasurable.cexp : AEMeasurable (fun x ↦ exp (f x)) μ := measurable_exp.comp_aemeasurable hf @[measurability, fun_prop] protected lemma AEMeasurable.ccos : AEMeasurable (fun x ↦ cos (f x)) μ := measurable_cos.comp_aemeasurable hf @[measurability, fun_prop] protected lemma AEMeasurable.csin : AEMeasurable (fun x ↦ sin (f x)) μ := measurable_sin.comp_aemeasurable hf @[measurability, fun_prop] protected lemma AEMeasurable.ccosh : AEMeasurable (fun x ↦ cosh (f x)) μ := measurable_cosh.comp_aemeasurable hf @[measurability, fun_prop] protected lemma AEMeasurable.csinh : AEMeasurable (fun x ↦ sinh (f x)) μ := measurable_sinh.comp_aemeasurable hf @[measurability, fun_prop] protected lemma AEMeasurable.carg : AEMeasurable (fun x ↦ arg (f x)) μ := measurable_arg.comp_aemeasurable hf @[measurability, fun_prop] protected lemma AEMeasurable.clog : AEMeasurable (fun x ↦ log (f x)) μ := measurable_log.comp_aemeasurable hf end ComplexComposition @[measurability, fun_prop] protected theorem Measurable.complex_ofReal {α : Type*} {m : MeasurableSpace α} {f : α → ℝ} (hf : Measurable f) : Measurable fun x ↦ (f x : ℂ) := Complex.measurable_ofReal.comp hf @[measurability, fun_prop] protected theorem AEMeasurable.complex_ofReal {α : Type*} {m : MeasurableSpace α} {μ : Measure α} {f : α → ℝ} (hf : AEMeasurable f μ) : AEMeasurable (fun x ↦ (f x : ℂ)) μ := Complex.measurable_ofReal.comp_aemeasurable hf section PowInstances instance Complex.hasMeasurablePow : MeasurablePow ℂ ℂ := ⟨Measurable.ite (measurable_fst (measurableSet_singleton 0)) (Measurable.ite (measurable_snd (measurableSet_singleton 0)) measurable_one measurable_zero) (measurable_fst.clog.mul measurable_snd).cexp⟩ instance Real.hasMeasurablePow : MeasurablePow ℝ ℝ := ⟨Complex.measurable_re.comp <| (Complex.measurable_ofReal.comp measurable_fst).pow (Complex.measurable_ofReal.comp measurable_snd)⟩ instance NNReal.hasMeasurablePow : MeasurablePow ℝ≥0 ℝ := ⟨(measurable_fst.coe_nnreal_real.pow measurable_snd).subtype_mk⟩ instance ENNReal.hasMeasurablePow : MeasurablePow ℝ≥0∞ ℝ := by refine ⟨ENNReal.measurable_of_measurable_nnreal_prod ?_ ?_⟩ · simp_rw [ENNReal.coe_rpow_def] refine Measurable.ite ?_ measurable_const (measurable_fst.pow measurable_snd).coe_nnreal_ennreal exact MeasurableSet.inter (measurable_fst (measurableSet_singleton 0)) (measurable_snd measurableSet_Iio) · simp_rw [ENNReal.top_rpow_def] refine Measurable.ite measurableSet_Ioi measurable_const ?_ exact Measurable.ite (measurableSet_singleton 0) measurable_const measurable_const end PowInstances
Basic.lean
/- Copyright (c) 2018 Andreas Swerdlow. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Andreas Swerdlow, Kexing Ying -/ import Mathlib.Algebra.Algebra.Tower import Mathlib.LinearAlgebra.BilinearMap /-! # Bilinear form This file defines a bilinear form over a module. Basic ideas such as orthogonality are also introduced, as well as reflexive, symmetric, non-degenerate and alternating bilinear forms. Adjoints of linear maps with respect to a bilinear form are also introduced. A bilinear form on an `R`-(semi)module `M`, is a function from `M × M` to `R`, that is linear in both arguments. Comments will typically abbreviate "(semi)module" as just "module", but the definitions should be as general as possible. The result that there exists an orthogonal basis with respect to a symmetric, nondegenerate bilinear form can be found in `QuadraticForm.lean` with `exists_orthogonal_basis`. ## Notations Given any term `B` of type `BilinForm`, due to a coercion, can use the notation `B x y` to refer to the function field, ie. `B x y = B.bilin x y`. In this file we use the following type variables: - `M`, `M'`, ... are modules over the commutative semiring `R`, - `M₁`, `M₁'`, ... are modules over the commutative ring `R₁`, - `V`, ... is a vector space over the field `K`. ## References * <https://en.wikipedia.org/wiki/Bilinear_form> ## Tags Bilinear form, -/ export LinearMap (BilinForm) open LinearMap (BilinForm) universe u v w variable {R : Type*} {M : Type*} [CommSemiring R] [AddCommMonoid M] [Module R M] variable {S : Type*} [CommSemiring S] [Algebra S R] [Module S M] [IsScalarTower S R M] variable {R₁ : Type*} {M₁ : Type*} [CommRing R₁] [AddCommGroup M₁] [Module R₁ M₁] variable {V : Type*} {K : Type*} [Field K] [AddCommGroup V] [Module K V] variable {B : BilinForm R M} {B₁ : BilinForm R₁ M₁} namespace LinearMap namespace BilinForm theorem add_left (x y z : M) : B (x + y) z = B x z + B y z := map_add₂ _ _ _ _ theorem smul_left (a : R) (x y : M) : B (a • x) y = a * B x y := map_smul₂ _ _ _ _ theorem add_right (x y z : M) : B x (y + z) = B x y + B x z := map_add _ _ _ theorem smul_right (a : R) (x y : M) : B x (a • y) = a * B x y := map_smul _ _ _ theorem zero_left (x : M) : B 0 x = 0 := map_zero₂ _ _ theorem zero_right (x : M) : B x 0 = 0 := map_zero _ theorem neg_left (x y : M₁) : B₁ (-x) y = -B₁ x y := map_neg₂ _ _ _ theorem neg_right (x y : M₁) : B₁ x (-y) = -B₁ x y := map_neg _ _ theorem sub_left (x y z : M₁) : B₁ (x - y) z = B₁ x z - B₁ y z := map_sub₂ _ _ _ _ theorem sub_right (x y z : M₁) : B₁ x (y - z) = B₁ x y - B₁ x z := map_sub _ _ _ lemma smul_left_of_tower (r : S) (x y : M) : B (r • x) y = r • B x y := by rw [← IsScalarTower.algebraMap_smul R r, smul_left, Algebra.smul_def] lemma smul_right_of_tower (r : S) (x y : M) : B x (r • y) = r • B x y := by rw [← IsScalarTower.algebraMap_smul R r, smul_right, Algebra.smul_def] variable {D : BilinForm R M} {D₁ : BilinForm R₁ M₁} -- TODO: instantiate `FunLike` theorem coe_injective : Function.Injective ((fun B x y => B x y) : BilinForm R M → M → M → R) := fun B D h => by ext x y apply congrFun₂ h @[ext] theorem ext (H : ∀ x y : M, B x y = D x y) : B = D := ext₂ H theorem congr_fun (h : B = D) (x y : M) : B x y = D x y := congr_fun₂ h _ _ @[simp] theorem zero_apply (x y : M) : (0 : BilinForm R M) x y = 0 := rfl variable (B D B₁ D₁) @[simp] theorem add_apply (x y : M) : (B + D) x y = B x y + D x y := rfl @[simp] theorem neg_apply (x y : M₁) : (-B₁) x y = -B₁ x y := rfl @[simp] theorem sub_apply (x y : M₁) : (B₁ - D₁) x y = B₁ x y - D₁ x y := rfl /-- `coeFn` as an `AddMonoidHom` -/ @[simps] def coeFnAddMonoidHom : BilinForm R M →+ M → M → R where toFun := fun B x y => B x y map_zero' := rfl map_add' _ _ := rfl section flip /-- The flip of a bilinear form, obtained by exchanging the left and right arguments. -/ def flipHom : BilinForm R M ≃ₗ[R] BilinForm R M := LinearMap.lflip @[simp] theorem flip_apply (A : BilinForm R M) (x y : M) : flipHom A x y = A y x := rfl theorem flip_flip : flipHom.trans flipHom = LinearEquiv.refl R (BilinForm R M) := by ext A simp /-- The `flip` of a bilinear form over a commutative ring, obtained by exchanging the left and right arguments. -/ abbrev flip (B : BilinForm R M) := flipHom B end flip /-- The restriction of a bilinear form on a submodule. -/ @[simps! apply] def restrict (B : BilinForm R M) (W : Submodule R M) : BilinForm R W := LinearMap.domRestrict₁₂ B W W end BilinForm end LinearMap
Expr.lean
/- Copyright (c) 2019 Robert Y. Lewis. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro, Simon Hudon, Kim Morrison, Keeley Hoek, Robert Y. Lewis, Floris van Doorn -/ import Mathlib.Lean.Expr.Basic import Mathlib.Lean.Expr.ReplaceRec
gproduct.v
(* (c) Copyright 2006-2016 Microsoft Corporation and Inria. *) (* Distributed under the terms of CeCILL-B. *) From HB Require Import structures. From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq div. From mathcomp Require Import choice fintype bigop finset fingroup morphism. From mathcomp Require Import quotient action finfun. (******************************************************************************) (* Partial, semidirect, central, and direct products. *) (* ++ Internal products, with A, B : {set gT}, are partial operations : *) (* partial_product A B == A * B if A is a group normalised by the group B, *) (* and the empty set otherwise. *) (* A ><| B == A * B if this is a semi-direct product (i.e., if A *) (* is normalised by B and intersects it trivially). *) (* A \* B == A * B if this is a central product ([A, B] = 1). *) (* A \x B == A * B if this is a direct product. *) (* [complements to K in G] == set of groups H s.t. K * H = G and K :&: H = 1. *) (* [splits G, over K] == [complements to K in G] is not empty. *) (* remgr A B x == the right remainder in B of x mod A, i.e., *) (* some element of (A :* x) :&: B. *) (* divgr A B x == the "division" in B of x by A: for all x, *) (* x = divgr A B x * remgr A B x. *) (* ++ External products : *) (* pairg1, pair1g == the isomorphisms aT1 -> aT1 * aT2, aT2 -> aT1 * aT2. *) (* (aT1 * aT2 has a direct product group structure.) *) (* dfung1 i == the morphism gT i -> {dffun forall j, gt j} where *) (* gT : I -> finGroupType is a family of finite groups. *) (* sdprod_by to == the semidirect product defined by to : groupAction H K. *) (* This is a finGroupType; the actual semidirect product is *) (* the total set [set: sdprod_by to] on that type. *) (* sdpair[12] to == the isomorphisms injecting K and H into *) (* sdprod_by to = sdpair1 to @* K ><| sdpair2 to @* H. *) (* External central products (with identified centers) will be defined later *) (* in file center.v. *) (* ++ Morphisms on product groups: *) (* pprodm nAB fJ fAB == the morphism extending fA and fB on A <*> B when *) (* nAB : B \subset 'N(A), *) (* fJ : {in A & B, morph_act 'J 'J fA fB}, and *) (* fAB : {in A :&: B, fA =1 fB}. *) (* sdprodm defG fJ == the morphism extending fA and fB on G, given *) (* defG : A ><| B = G and *) (* fJ : {in A & B, morph_act 'J 'J fA fB}. *) (* xsdprodm fHKact == the total morphism on sdprod_by to induced by *) (* fH : {morphism H >-> rT}, fK : {morphism K >-> rT}, *) (* with to : groupAction K H, *) (* given fHKact : morph_act to 'J fH fK. *) (* cprodm defG cAB fAB == the morphism extending fA and fB on G, when *) (* defG : A \* B = G, *) (* cAB : fB @* B \subset 'C(fB @* A), *) (* and fAB : {in A :&: B, fA =1 fB}. *) (* dprodm defG cAB == the morphism extending fA and fB on G, when *) (* defG : A \x B = G and *) (* cAB : fA @* B \subset 'C(fA @* A) *) (* mulgm (x, y) == x * y; mulgm is an isomorphism from setX A B to G *) (* iff A \x B = G . *) (******************************************************************************) Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. Import GroupScope. Section Defs. Variables gT : finGroupType. Implicit Types A B C : {set gT}. Definition partial_product A B := if A == 1 then B else if B == 1 then A else if [&& group_set A, group_set B & B \subset 'N(A)] then A * B else set0. Definition semidirect_product A B := if A :&: B \subset 1%G then partial_product A B else set0. Definition central_product A B := if B \subset 'C(A) then partial_product A B else set0. Definition direct_product A B := if A :&: B \subset 1%G then central_product A B else set0. Definition complements_to_in A B := [set K : {group gT} | A :&: K == 1 & A * K == B]. Definition splits_over B A := complements_to_in A B != set0. (* Product remainder functions -- right variant only. *) Definition remgr A B x := repr (A :* x :&: B). Definition divgr A B x := x * (remgr A B x)^-1. End Defs. Arguments partial_product _ _%_g _%_g : clear implicits. Arguments semidirect_product _ _%_g _%_g : clear implicits. Arguments central_product _ _%_g _%_g : clear implicits. Arguments complements_to_in _ _%_g _%_g. Arguments splits_over _ _%_g _%_g. Arguments remgr _ _%_g _%_g _%_g. Arguments divgr _ _%_g _%_g _%_g. Arguments direct_product : clear implicits. Notation pprod := (partial_product _). Notation sdprod := (semidirect_product _). Notation cprod := (central_product _). Notation dprod := (direct_product _). Notation "G ><| H" := (sdprod G H)%g (at level 40, left associativity) : group_scope. Notation "G \* H" := (cprod G H)%g (at level 40, left associativity) : group_scope. Notation "G \x H" := (dprod G H)%g (at level 40, left associativity) : group_scope. Notation "[ 'complements' 'to' A 'in' B ]" := (complements_to_in A B) (format "[ 'complements' 'to' A 'in' B ]") : group_scope. Notation "[ 'splits' B , 'over' A ]" := (splits_over B A) (format "[ 'splits' B , 'over' A ]") : group_scope. (* Prenex Implicits remgl divgl. *) Prenex Implicits remgr divgr. Section InternalProd. Variable gT : finGroupType. Implicit Types A B C : {set gT}. Implicit Types G H K L M : {group gT}. Local Notation pprod := (partial_product gT). Local Notation sdprod := (semidirect_product gT) (only parsing). Local Notation cprod := (central_product gT) (only parsing). Local Notation dprod := (direct_product gT) (only parsing). Lemma pprod1g : left_id 1 pprod. Proof. by move=> A; rewrite /pprod eqxx. Qed. Lemma pprodg1 : right_id 1 pprod. Proof. by move=> A; rewrite /pprod eqxx; case: eqP. Qed. Variant are_groups A B : Prop := AreGroups K H of A = K & B = H. Lemma group_not0 G : set0 <> G. Proof. by move/setP/(_ 1); rewrite inE group1. Qed. Lemma mulg0 : right_zero (@set0 gT) mulg. Proof. by move=> A; apply/setP=> x; rewrite inE; apply/imset2P=> [[y z]]; rewrite inE. Qed. Lemma mul0g : left_zero (@set0 gT) mulg. Proof. by move=> A; apply/setP=> x; rewrite inE; apply/imset2P=> [[y z]]; rewrite inE. Qed. Lemma pprodP A B G : pprod A B = G -> [/\ are_groups A B, A * B = G & B \subset 'N(A)]. Proof. have Gnot0 := @group_not0 G; rewrite /pprod; do 2?case: eqP => [-> ->| _]. - by rewrite mul1g norms1; split; first exists 1%G G. - by rewrite mulg1 sub1G; split; first exists G 1%G. by case: and3P => // [[gA gB ->]]; split; first exists (Group gA) (Group gB). Qed. Lemma pprodE K H : H \subset 'N(K) -> pprod K H = K * H. Proof. move=> nKH; rewrite /pprod nKH !groupP /=. by do 2?case: eqP => [-> | _]; rewrite ?mulg1 ?mul1g. Qed. Lemma pprodEY K H : H \subset 'N(K) -> pprod K H = K <*> H. Proof. by move=> nKH; rewrite pprodE ?norm_joinEr. Qed. Lemma pprodW A B G : pprod A B = G -> A * B = G. Proof. by case/pprodP. Qed. Lemma pprodWC A B G : pprod A B = G -> B * A = G. Proof. by case/pprodP=> _ <- /normC. Qed. Lemma pprodWY A B G : pprod A B = G -> A <*> B = G. Proof. by case/pprodP=> [[K H -> ->] <- /norm_joinEr]. Qed. Lemma pprodJ A B x : pprod A B :^ x = pprod (A :^ x) (B :^ x). Proof. rewrite /pprod !conjsg_eq1 !group_setJ normJ conjSg -conjsMg. by do 3?case: ifP => // _; apply: conj0g. Qed. (* Properties of the remainders *) Lemma remgrMl K B x y : y \in K -> remgr K B (y * x) = remgr K B x. Proof. by move=> Ky; rewrite {1}/remgr rcosetM rcoset_id. Qed. Lemma remgrP K B x : (remgr K B x \in K :* x :&: B) = (x \in K * B). Proof. set y := _ x; apply/idP/mulsgP=> [|[g b Kg Bb x_gb]]. rewrite inE rcoset_sym mem_rcoset => /andP[Kxy' By]. by exists (x * y^-1) y; rewrite ?mulgKV. by apply: (mem_repr b); rewrite inE rcoset_sym mem_rcoset x_gb mulgK Kg. Qed. Lemma remgr1 K H x : x \in K -> remgr K H x = 1. Proof. by move=> Kx; rewrite /remgr rcoset_id ?repr_group. Qed. Lemma divgr_eq A B x : x = divgr A B x * remgr A B x. Proof. by rewrite mulgKV. Qed. Lemma divgrMl K B x y : x \in K -> divgr K B (x * y) = x * divgr K B y. Proof. by move=> Hx; rewrite /divgr remgrMl ?mulgA. Qed. Lemma divgr_id K H x : x \in K -> divgr K H x = x. Proof. by move=> Kx; rewrite /divgr remgr1 // invg1 mulg1. Qed. Lemma mem_remgr K B x : x \in K * B -> remgr K B x \in B. Proof. by rewrite -remgrP => /setIP[]. Qed. Lemma mem_divgr K B x : x \in K * B -> divgr K B x \in K. Proof. by rewrite -remgrP inE rcoset_sym mem_rcoset => /andP[]. Qed. Section DisjointRem. Variables K H : {group gT}. Hypothesis tiKH : K :&: H = 1. Lemma remgr_id x : x \in H -> remgr K H x = x. Proof. move=> Hx; apply/eqP; rewrite eq_mulgV1 (sameP eqP set1gP) -tiKH inE. rewrite -mem_rcoset groupMr ?groupV // -in_setI remgrP. by apply: subsetP Hx; apply: mulG_subr. Qed. Lemma remgrMid x y : x \in K -> y \in H -> remgr K H (x * y) = y. Proof. by move=> Kx Hy; rewrite remgrMl ?remgr_id. Qed. Lemma divgrMid x y : x \in K -> y \in H -> divgr K H (x * y) = x. Proof. by move=> Kx Hy; rewrite /divgr remgrMid ?mulgK. Qed. End DisjointRem. (* Intersection of a centraliser with a disjoint product. *) Lemma subcent_TImulg K H A : K :&: H = 1 -> A \subset 'N(K) :&: 'N(H) -> 'C_K(A) * 'C_H(A) = 'C_(K * H)(A). Proof. move=> tiKH /subsetIP[nKA nHA]; apply/eqP. rewrite group_modl ?subsetIr // eqEsubset setSI ?mulSg ?subsetIl //=. apply/subsetP=> _ /setIP[/mulsgP[x y Kx Hy ->] cAxy]. rewrite inE cAxy mem_mulg // inE Kx /=. apply/centP=> z Az; apply/commgP/conjg_fixP. move/commgP/conjg_fixP/(congr1 (divgr K H)): (centP cAxy z Az). by rewrite conjMg !divgrMid ?memJ_norm // (subsetP nKA, subsetP nHA). Qed. (* Complements, and splitting. *) Lemma complP H A B : reflect (A :&: H = 1 /\ A * H = B) (H \in [complements to A in B]). Proof. by apply: (iffP setIdP); case; split; apply/eqP. Qed. Lemma splitsP B A : reflect (exists H, H \in [complements to A in B]) [splits B, over A]. Proof. exact: set0Pn. Qed. Lemma complgC H K G : (H \in [complements to K in G]) = (K \in [complements to H in G]). Proof. rewrite !inE setIC; congr (_ && _). by apply/eqP/eqP=> defG; rewrite -(comm_group_setP _) // defG groupP. Qed. Section NormalComplement. Variables K H G : {group gT}. Hypothesis complH_K : H \in [complements to K in G]. Lemma remgrM : K <| G -> {in G &, {morph remgr K H : x y / x * y}}. Proof. case/normalP=> _; case/complP: complH_K => tiKH <- nK_KH x y KHx KHy. rewrite {1}(divgr_eq K H y) mulgA (conjgCV x) {2}(divgr_eq K H x) -2!mulgA. rewrite mulgA remgrMid //; last by rewrite groupMl mem_remgr. by rewrite groupMl !(=^~ mem_conjg, nK_KH, mem_divgr). Qed. Lemma divgrM : H \subset 'C(K) -> {in G &, {morph divgr K H : x y / x * y}}. Proof. move=> cKH; have /complP[_ defG] := complH_K. have nsKG: K <| G by rewrite -defG -cent_joinEr // normalYl cents_norm. move=> x y Gx Gy; rewrite {1}/divgr remgrM // invMg -!mulgA (mulgA y). by congr (_ * _); rewrite -(centsP cKH) ?groupV ?(mem_remgr, mem_divgr, defG). Qed. End NormalComplement. (* Semi-direct product *) Lemma sdprod1g : left_id 1 sdprod. Proof. by move=> A; rewrite /sdprod subsetIl pprod1g. Qed. Lemma sdprodg1 : right_id 1 sdprod. Proof. by move=> A; rewrite /sdprod subsetIr pprodg1. Qed. Lemma sdprodP A B G : A ><| B = G -> [/\ are_groups A B, A * B = G, B \subset 'N(A) & A :&: B = 1]. Proof. rewrite /sdprod; case: ifP => [trAB | _ /group_not0[] //]. case/pprodP=> gAB defG nBA; split=> {defG nBA}//. by case: gAB trAB => H K -> -> /trivgP. Qed. Lemma sdprodE K H : H \subset 'N(K) -> K :&: H = 1 -> K ><| H = K * H. Proof. by move=> nKH tiKH; rewrite /sdprod tiKH subxx pprodE. Qed. Lemma sdprodEY K H : H \subset 'N(K) -> K :&: H = 1 -> K ><| H = K <*> H. Proof. by move=> nKH tiKH; rewrite sdprodE ?norm_joinEr. Qed. Lemma sdprodWpp A B G : A ><| B = G -> pprod A B = G. Proof. by case/sdprodP=> [[K H -> ->] <- /pprodE]. Qed. Lemma sdprodW A B G : A ><| B = G -> A * B = G. Proof. by move/sdprodWpp/pprodW. Qed. Lemma sdprodWC A B G : A ><| B = G -> B * A = G. Proof. by move/sdprodWpp/pprodWC. Qed. Lemma sdprodWY A B G : A ><| B = G -> A <*> B = G. Proof. by move/sdprodWpp/pprodWY. Qed. Lemma sdprodJ A B x : (A ><| B) :^ x = A :^ x ><| B :^ x. Proof. rewrite /sdprod -conjIg sub_conjg conjs1g -pprodJ. by case: ifP => _ //; apply: imset0. Qed. Lemma sdprod_context G K H : K ><| H = G -> [/\ K <| G, H \subset G, K * H = G, H \subset 'N(K) & K :&: H = 1]. Proof. case/sdprodP=> _ <- nKH tiKH. by rewrite /normal mulG_subl mulG_subr mulG_subG normG. Qed. Lemma sdprod_compl G K H : K ><| H = G -> H \in [complements to K in G]. Proof. by case/sdprodP=> _ mulKH _ tiKH; apply/complP. Qed. Lemma sdprod_normal_complP G K H : K <| G -> reflect (K ><| H = G) (K \in [complements to H in G]). Proof. case/andP=> _ nKG; rewrite complgC. apply: (iffP idP); [case/complP=> tiKH mulKH | exact: sdprod_compl]. by rewrite sdprodE ?(subset_trans _ nKG) // -mulKH mulG_subr. Qed. Lemma sdprod_card G A B : A ><| B = G -> (#|A| * #|B|)%N = #|G|. Proof. by case/sdprodP=> [[H K -> ->] <- _ /TI_cardMg]. Qed. Lemma sdprod_isom G A B : A ><| B = G -> {nAB : B \subset 'N(A) | isom B (G / A) (restrm nAB (coset A))}. Proof. case/sdprodP=> [[K H -> ->] <- nKH tiKH]. by exists nKH; rewrite quotientMidl quotient_isom. Qed. Lemma sdprod_isog G A B : A ><| B = G -> B \isog G / A. Proof. by case/sdprod_isom=> nAB; apply: isom_isog. Qed. Lemma sdprod_subr G A B M : A ><| B = G -> M \subset B -> A ><| M = A <*> M. Proof. case/sdprodP=> [[K H -> ->] _ nKH tiKH] sMH. by rewrite sdprodEY ?(subset_trans sMH) //; apply/trivgP; rewrite -tiKH setIS. Qed. Lemma index_sdprod G A B : A ><| B = G -> #|B| = #|G : A|. Proof. case/sdprodP=> [[K H -> ->] <- _ tiHK]. by rewrite indexMg -indexgI setIC tiHK indexg1. Qed. Lemma index_sdprodr G A B M : A ><| B = G -> M \subset B -> #|B : M| = #|G : A <*> M|. Proof. move=> defG; case/sdprodP: defG (defG) => [[K H -> ->] mulKH nKH _] defG sMH. rewrite -!divgS //=; last by rewrite -genM_join gen_subG -mulKH mulgS. by rewrite -(sdprod_card defG) -(sdprod_card (sdprod_subr defG sMH)) divnMl. Qed. Lemma quotient_sdprodr_isom G A B M : A ><| B = G -> M <| B -> {f : {morphism B / M >-> coset_of (A <*> M)} | isom (B / M) (G / (A <*> M)) f & forall L, L \subset B -> f @* (L / M) = A <*> L / (A <*> M)}. Proof. move=> defG nsMH; have [defA defB]: A = <<A>>%G /\ B = <<B>>%G. by have [[K1 H1 -> ->] _ _ _] := sdprodP defG; rewrite /= !genGid. do [rewrite {}defA {}defB; move: {A}<<A>>%G {B}<<B>>%G => K H] in defG nsMH *. have [[nKH /isomP[injKH imKH]] sMH] := (sdprod_isom defG, normal_sub nsMH). have [[nsKG sHG mulKH _ _] nKM] := (sdprod_context defG, subset_trans sMH nKH). have nsKMG: K <*> M <| G. by rewrite -quotientYK // -mulKH -quotientK ?cosetpre_normal ?quotient_normal. have [/= f inj_f im_f] := third_isom (joing_subl K M) nsKG nsKMG. rewrite quotientYidl //= -imKH -(restrm_quotientE nKH sMH) in f inj_f im_f. have /domP[h [_ ker_h _ im_h]]: 'dom (f \o quotm _ nsMH) = H / M. by rewrite ['dom _]morphpre_quotm injmK. have{} im_h L: L \subset H -> h @* (L / M) = K <*> L / (K <*> M). move=> sLH; have [sLG sKKM] := (subset_trans sLH sHG, joing_subl K M). rewrite im_h morphim_comp morphim_quotm [_ @* L]restrm_quotientE ?im_f //. rewrite quotientY ?(normsG sKKM) ?(subset_trans sLG) ?normal_norm //. by rewrite (quotientS1 sKKM) joing1G. exists h => //; apply/isomP; split; last by rewrite im_h //= (sdprodWY defG). by rewrite ker_h injm_comp ?injm_quotm. Qed. Lemma quotient_sdprodr_isog G A B M : A ><| B = G -> M <| B -> B / M \isog G / (A <*> M). Proof. move=> defG; case/sdprodP: defG (defG) => [[K H -> ->] _ _ _] => defG nsMH. by have [h /isom_isog->] := quotient_sdprodr_isom defG nsMH. Qed. Lemma sdprod_modl A B G H : A ><| B = G -> A \subset H -> A ><| (B :&: H) = G :&: H. Proof. case/sdprodP=> {A B} [[A B -> ->]] <- nAB tiAB sAH. rewrite -group_modl ?sdprodE ?subIset ?nAB //. by rewrite setIA tiAB (setIidPl _) ?sub1G. Qed. Lemma sdprod_modr A B G H : A ><| B = G -> B \subset H -> (H :&: A) ><| B = H :&: G. Proof. case/sdprodP=> {A B}[[A B -> ->]] <- nAB tiAB sAH. rewrite -group_modr ?sdprodE ?normsI // ?normsG //. by rewrite -setIA tiAB (setIidPr _) ?sub1G. Qed. Lemma subcent_sdprod B C G A : B ><| C = G -> A \subset 'N(B) :&: 'N(C) -> 'C_B(A) ><| 'C_C(A) = 'C_G(A). Proof. case/sdprodP=> [[H K -> ->] <- nHK tiHK] nHKA {B C G}. rewrite sdprodE ?subcent_TImulg ?normsIG //. by rewrite -setIIl tiHK (setIidPl (sub1G _)). Qed. Lemma sdprod_recl n G K H K1 : #|G| <= n -> K ><| H = G -> K1 \proper K -> H \subset 'N(K1) -> exists G1 : {group gT}, [/\ #|G1| < n, G1 \subset G & K1 ><| H = G1]. Proof. move=> leGn; case/sdprodP=> _ defG nKH tiKH ltK1K nK1H. have tiK1H: K1 :&: H = 1 by apply/trivgP; rewrite -tiKH setSI ?proper_sub. exists (K1 <*> H)%G; rewrite /= -defG sdprodE // norm_joinEr //. rewrite ?mulSg ?proper_sub ?(leq_trans _ leGn) //=. by rewrite -defG ?TI_cardMg // ltn_pmul2r ?proper_card. Qed. Lemma sdprod_recr n G K H H1 : #|G| <= n -> K ><| H = G -> H1 \proper H -> exists G1 : {group gT}, [/\ #|G1| < n, G1 \subset G & K ><| H1 = G1]. Proof. move=> leGn; case/sdprodP=> _ defG nKH tiKH ltH1H. have [sH1H _] := andP ltH1H; have nKH1 := subset_trans sH1H nKH. have tiKH1: K :&: H1 = 1 by apply/trivgP; rewrite -tiKH setIS. exists (K <*> H1)%G; rewrite /= -defG sdprodE // norm_joinEr //. rewrite ?mulgS // ?(leq_trans _ leGn) //=. by rewrite -defG ?TI_cardMg // ltn_pmul2l ?proper_card. Qed. Lemma mem_sdprod G A B x : A ><| B = G -> x \in G -> exists y, exists z, [/\ y \in A, z \in B, x = y * z & {in A & B, forall u t, x = u * t -> u = y /\ t = z}]. Proof. case/sdprodP=> [[K H -> ->{A B}] <- _ tiKH] /mulsgP[y z Ky Hz ->{x}]. exists y; exists z; split=> // u t Ku Ht eqyzut. move: (congr1 (divgr K H) eqyzut) (congr1 (remgr K H) eqyzut). by rewrite !remgrMid // !divgrMid. Qed. (* Central product *) Lemma cprod1g : left_id 1 cprod. Proof. by move=> A; rewrite /cprod cents1 pprod1g. Qed. Lemma cprodg1 : right_id 1 cprod. Proof. by move=> A; rewrite /cprod sub1G pprodg1. Qed. Lemma cprodP A B G : A \* B = G -> [/\ are_groups A B, A * B = G & B \subset 'C(A)]. Proof. by rewrite /cprod; case: ifP => [cAB /pprodP[] | _ /group_not0[]]. Qed. Lemma cprodE G H : H \subset 'C(G) -> G \* H = G * H. Proof. by move=> cGH; rewrite /cprod cGH pprodE ?cents_norm. Qed. Lemma cprodEY G H : H \subset 'C(G) -> G \* H = G <*> H. Proof. by move=> cGH; rewrite cprodE ?cent_joinEr. Qed. Lemma cprodWpp A B G : A \* B = G -> pprod A B = G. Proof. by case/cprodP=> [[K H -> ->] <- /cents_norm/pprodE]. Qed. Lemma cprodW A B G : A \* B = G -> A * B = G. Proof. by move/cprodWpp/pprodW. Qed. Lemma cprodWC A B G : A \* B = G -> B * A = G. Proof. by move/cprodWpp/pprodWC. Qed. Lemma cprodWY A B G : A \* B = G -> A <*> B = G. Proof. by move/cprodWpp/pprodWY. Qed. Lemma cprodJ A B x : (A \* B) :^ x = A :^ x \* B :^ x. Proof. by rewrite /cprod centJ conjSg -pprodJ; case: ifP => _ //; apply: imset0. Qed. Lemma cprod_normal2 A B G : A \* B = G -> A <| G /\ B <| G. Proof. case/cprodP=> [[K H -> ->] <- cKH]; rewrite -cent_joinEr //. by rewrite normalYl normalYr !cents_norm // centsC. Qed. Lemma bigcprodW I (r : seq I) P F G : \big[cprod/1]_(i <- r | P i) F i = G -> \prod_(i <- r | P i) F i = G. Proof. elim/big_rec2: _ G => // i A B _ IH G /cprodP[[_ H _ defB] <- _]. by rewrite (IH H) defB. Qed. Lemma bigcprodWY I (r : seq I) P F G : \big[cprod/1]_(i <- r | P i) F i = G -> << \bigcup_(i <- r | P i) F i >> = G. Proof. elim/big_rec2: _ G => [|i A B _ IH G]; first by rewrite gen0. case/cprodP => [[K H -> defB] <- cKH]. by rewrite -[<<_>>]joing_idr (IH H) ?cent_joinEr -?defB. Qed. Lemma triv_cprod A B : (A \* B == 1) = (A == 1) && (B == 1). Proof. case A1: (A == 1); first by rewrite (eqP A1) cprod1g. apply/eqP=> /cprodP[[G H defA ->]] /eqP. by rewrite defA trivMg -defA A1. Qed. Lemma cprod_ntriv A B : A != 1 -> B != 1 -> A \* B = if [&& group_set A, group_set B & B \subset 'C(A)] then A * B else set0. Proof. move=> A1 B1; rewrite /cprod; case: ifP => cAB; rewrite ?cAB ?andbF //=. by rewrite /pprod -if_neg A1 -if_neg B1 cents_norm. Qed. Lemma trivg0 : (@set0 gT == 1) = false. Proof. by rewrite eqEcard cards0 cards1 andbF. Qed. Lemma group0 : group_set (@set0 gT) = false. Proof. by rewrite /group_set inE. Qed. Lemma cprod0g A : set0 \* A = set0. Proof. by rewrite /cprod centsC sub0set /pprod group0 trivg0 !if_same. Qed. Lemma cprodC : commutative cprod. Proof. rewrite /cprod => A B; case: ifP => cAB; rewrite centsC cAB // /pprod. by rewrite andbCA normC !cents_norm // 1?centsC //; do 2!case: eqP => // ->. Qed. Lemma cprodA : associative cprod. Proof. move=> A B C; case A1: (A == 1); first by rewrite (eqP A1) !cprod1g. case B1: (B == 1); first by rewrite (eqP B1) cprod1g cprodg1. case C1: (C == 1); first by rewrite (eqP C1) !cprodg1. rewrite !(triv_cprod, cprod_ntriv) ?{}A1 ?{}B1 ?{}C1 //. case: isgroupP => [[G ->{A}] | _]; last by rewrite group0. case: (isgroupP B) => [[H ->{B}] | _]; last by rewrite group0. case: (isgroupP C) => [[K ->{C}] | _]; last by rewrite group0 !andbF. case cGH: (H \subset 'C(G)); case cHK: (K \subset 'C(H)); last first. - by rewrite group0. - by rewrite group0 /= mulG_subG cGH andbF. - by rewrite group0 /= centM subsetI cHK !andbF. rewrite /= mulgA mulG_subG centM subsetI cGH cHK andbT -(cent_joinEr cHK). by rewrite -(cent_joinEr cGH) !groupP. Qed. HB.instance Definition _ := Monoid.isComLaw.Build {set gT} 1 cprod cprodA cprodC cprod1g. Lemma cprod_modl A B G H : A \* B = G -> A \subset H -> A \* (B :&: H) = G :&: H. Proof. case/cprodP=> [[U V -> -> {A B}]] defG cUV sUH. by rewrite cprodE; [rewrite group_modl ?defG | rewrite subIset ?cUV]. Qed. Lemma cprod_modr A B G H : A \* B = G -> B \subset H -> (H :&: A) \* B = H :&: G. Proof. by rewrite -!(cprodC B) !(setIC H); apply: cprod_modl. Qed. Lemma bigcprodYP (I : finType) (P : pred I) (H : I -> {group gT}) : reflect (forall i j, P i -> P j -> i != j -> H i \subset 'C(H j)) (\big[cprod/1]_(i | P i) H i == (\prod_(i | P i) H i)%G). Proof. apply: (iffP eqP) => [defG i j Pi Pj neq_ij | cHH]. rewrite (bigD1 j) // (bigD1 i) /= ?cprodA in defG; last exact/andP. by case/cprodP: defG => [[K _ /cprodP[//]]]. set Q := P; have sQP: subpred Q P by []; have [n leQn] := ubnP #|Q|. elim: n => // n IHn in (Q) leQn sQP *. have [i Qi | Q0] := pickP Q; last by rewrite !big_pred0. rewrite (cardD1x Qi) add1n ltnS !(bigD1 i Qi) /= in leQn *. rewrite {}IHn {n leQn}// => [|j /andP[/sQP //]]. rewrite bigprodGE cprodEY // gen_subG; apply/bigcupsP=> j /andP[neq_ji Qj]. by rewrite cHH ?sQP. Qed. Lemma bigcprodEY I r (P : pred I) (H : I -> {group gT}) G : abelian G -> (forall i, P i -> H i \subset G) -> \big[cprod/1]_(i <- r | P i) H i = (\prod_(i <- r | P i) H i)%G. Proof. move=> cGG sHG; apply/eqP; rewrite !(big_tnth _ _ r). by apply/bigcprodYP=> i j Pi Pj _; rewrite (sub_abelian_cent2 cGG) ?sHG. Qed. Lemma perm_bigcprod (I : eqType) r1 r2 (A : I -> {set gT}) G x : \big[cprod/1]_(i <- r1) A i = G -> {in r1, forall i, x i \in A i} -> perm_eq r1 r2 -> \prod_(i <- r1) x i = \prod_(i <- r2) x i. Proof. elim: r1 r2 G => [|i r1 IHr] r2 G defG Ax eq_r12. by rewrite perm_sym in eq_r12; rewrite (perm_small_eq _ eq_r12) ?big_nil. have /rot_to[n r3 Dr2]: i \in r2 by rewrite -(perm_mem eq_r12) mem_head. transitivity (\prod_(j <- rot n r2) x j). rewrite Dr2 !big_cons in defG Ax *; have [[_ G1 _ defG1] _ _] := cprodP defG. rewrite (IHr r3 G1) //; first by case/allP/andP: Ax => _ /allP. by rewrite -(perm_cons i) -Dr2 perm_sym perm_rot perm_sym. rewrite -(cat_take_drop n r2) [in LHS]cat_take_drop in eq_r12 *. rewrite (perm_big _ eq_r12) !big_cat /= !(big_nth i) !big_mkord in defG *. have /cprodP[[G1 G2 defG1 defG2] _ /centsP-> //] := defG. rewrite defG2 -(bigcprodW defG2) mem_prodg // => k _; apply: Ax. by rewrite (perm_mem eq_r12) mem_cat orbC mem_nth. rewrite defG1 -(bigcprodW defG1) mem_prodg // => k _; apply: Ax. by rewrite (perm_mem eq_r12) mem_cat mem_nth. Qed. Lemma reindex_bigcprod (I J : finType) (h : J -> I) P (A : I -> {set gT}) G x : {on SimplPred P, bijective h} -> \big[cprod/1]_(i | P i) A i = G -> {in SimplPred P, forall i, x i \in A i} -> \prod_(i | P i) x i = \prod_(j | P (h j)) x (h j). Proof. case=> h1 hK h1K defG Ax; have [e big_e [Ue mem_e] _] := big_enumP P. rewrite -!big_e in defG *; rewrite -(big_map h P x) -[RHS]big_filter filter_map. apply: perm_bigcprod defG _ _ => [i|]; first by rewrite mem_e => /Ax. have [r _ [Ur /= mem_r] _] := big_enumP; apply: uniq_perm Ue _ _ => [|i]. by rewrite map_inj_in_uniq // => i j; rewrite !mem_r ; apply: (can_in_inj hK). rewrite mem_e; apply/idP/mapP=> [Pi|[j r_j ->]]; last by rewrite -mem_r. by exists (h1 i); rewrite ?mem_r h1K. Qed. (* Direct product *) Lemma dprod1g : left_id 1 dprod. Proof. by move=> A; rewrite /dprod subsetIl cprod1g. Qed. Lemma dprodg1 : right_id 1 dprod. Proof. by move=> A; rewrite /dprod subsetIr cprodg1. Qed. Lemma dprodP A B G : A \x B = G -> [/\ are_groups A B, A * B = G, B \subset 'C(A) & A :&: B = 1]. Proof. rewrite /dprod; case: ifP => trAB; last by case/group_not0. by case/cprodP=> gAB; split=> //; case: gAB trAB => ? ? -> -> /trivgP. Qed. Lemma dprodE G H : H \subset 'C(G) -> G :&: H = 1 -> G \x H = G * H. Proof. by move=> cGH trGH; rewrite /dprod trGH sub1G cprodE. Qed. Lemma dprodEY G H : H \subset 'C(G) -> G :&: H = 1 -> G \x H = G <*> H. Proof. by move=> cGH trGH; rewrite /dprod trGH subxx cprodEY. Qed. Lemma dprodEcp A B : A :&: B = 1 -> A \x B = A \* B. Proof. by move=> trAB; rewrite /dprod trAB subxx. Qed. Lemma dprodEsd A B : B \subset 'C(A) -> A \x B = A ><| B. Proof. by rewrite /dprod /cprod => ->. Qed. Lemma dprodWcp A B G : A \x B = G -> A \* B = G. Proof. by move=> defG; have [_ _ _ /dprodEcp <-] := dprodP defG. Qed. Lemma dprodWsd A B G : A \x B = G -> A ><| B = G. Proof. by move=> defG; have [_ _ /dprodEsd <-] := dprodP defG. Qed. Lemma dprodW A B G : A \x B = G -> A * B = G. Proof. by move/dprodWsd/sdprodW. Qed. Lemma dprodWC A B G : A \x B = G -> B * A = G. Proof. by move/dprodWsd/sdprodWC. Qed. Lemma dprodWY A B G : A \x B = G -> A <*> B = G. Proof. by move/dprodWsd/sdprodWY. Qed. Lemma cprod_card_dprod G A B : A \* B = G -> #|A| * #|B| <= #|G| -> A \x B = G. Proof. by case/cprodP=> [[K H -> ->] <- cKH] /cardMg_TI; apply: dprodE. Qed. Lemma dprodJ A B x : (A \x B) :^ x = A :^ x \x B :^ x. Proof. rewrite /dprod -conjIg sub_conjg conjs1g -cprodJ. by case: ifP => _ //; apply: imset0. Qed. Lemma dprod_normal2 A B G : A \x B = G -> A <| G /\ B <| G. Proof. by move/dprodWcp/cprod_normal2. Qed. Lemma dprodYP K H : reflect (K \x H = K <*> H) (H \subset 'C(K) :\: K^#). Proof. rewrite subsetD -setI_eq0 setIDA setD_eq0 setIC subG1 /=. by apply: (iffP andP) => [[cKH /eqP/dprodEY->] | /dprodP[_ _ -> ->]]. Qed. Lemma dprodC : commutative dprod. Proof. by move=> A B; rewrite /dprod setIC cprodC. Qed. Lemma dprodWsdC A B G : A \x B = G -> B ><| A = G. Proof. by rewrite dprodC => /dprodWsd. Qed. Lemma dprodA : associative dprod. Proof. move=> A B C; case A1: (A == 1); first by rewrite (eqP A1) !dprod1g. case B1: (B == 1); first by rewrite (eqP B1) dprod1g dprodg1. case C1: (C == 1); first by rewrite (eqP C1) !dprodg1. rewrite /dprod (fun_if (cprod A)) (fun_if (cprod^~ C)) -cprodA. rewrite -(cprodC set0) !cprod0g cprod_ntriv ?B1 ?{}C1 //. case: and3P B1 => [[] | _ _]; last by rewrite cprodC cprod0g !if_same. case/isgroupP=> H ->; case/isgroupP=> K -> {B C}; move/cent_joinEr=> eHK H1. rewrite cprod_ntriv ?trivMg ?{}A1 ?{}H1 // mulG_subG. case: and4P => [[] | _]; last by rewrite !if_same. case/isgroupP=> G ->{A} _ cGH _; rewrite cprodEY // -eHK. case trGH: (G :&: H \subset _); case trHK: (H :&: K \subset _); last first. - by rewrite !if_same. - rewrite if_same; case: ifP => // trG_HK; case/negP: trGH. by apply: subset_trans trG_HK; rewrite setIS ?joing_subl. - rewrite if_same; case: ifP => // trGH_K; case/negP: trHK. by apply: subset_trans trGH_K; rewrite setSI ?joing_subr. do 2![case: ifP] => // trGH_K trG_HK; [case/negP: trGH_K | case/negP: trG_HK]. apply: subset_trans trHK; rewrite subsetI subsetIr -{2}(mulg1 H) -mulGS. rewrite setIC group_modl ?joing_subr //= cent_joinEr // -eHK. by rewrite -group_modr ?joing_subl //= setIC -(normC (sub1G _)) mulSg. apply: subset_trans trGH; rewrite subsetI subsetIl -{2}(mul1g H) -mulSG. rewrite setIC group_modr ?joing_subl //= eHK -(cent_joinEr cGH). by rewrite -group_modl ?joing_subr //= setIC (normC (sub1G _)) mulgS. Qed. HB.instance Definition _ := Monoid.isComLaw.Build {set gT} 1 dprod dprodA dprodC dprod1g. Lemma bigdprodWcp I (r : seq I) P F G : \big[dprod/1]_(i <- r | P i) F i = G -> \big[cprod/1]_(i <- r | P i) F i = G. Proof. elim/big_rec2: _ G => // i A B _ IH G /dprodP[[K H -> defB] <- cKH _]. by rewrite (IH H) // cprodE -defB. Qed. Lemma bigdprodW I (r : seq I) P F G : \big[dprod/1]_(i <- r | P i) F i = G -> \prod_(i <- r | P i) F i = G. Proof. by move/bigdprodWcp; apply: bigcprodW. Qed. Lemma bigdprodWY I (r : seq I) P F G : \big[dprod/1]_(i <- r | P i) F i = G -> << \bigcup_(i <- r | P i) F i >> = G. Proof. by move/bigdprodWcp; apply: bigcprodWY. Qed. Lemma bigdprodYP (I : finType) (P : pred I) (F : I -> {group gT}) : reflect (forall i, P i -> (\prod_(j | P j && (j != i)) F j)%G \subset 'C(F i) :\: (F i)^#) (\big[dprod/1]_(i | P i) F i == (\prod_(i | P i) F i)%G). Proof. apply: (iffP eqP) => [defG i Pi | dxG]. rewrite !(bigD1 i Pi) /= in defG; have [[_ G' _ defG'] _ _ _] := dprodP defG. by apply/dprodYP; rewrite -defG defG' bigprodGE (bigdprodWY defG'). set Q := P; have sQP: subpred Q P by []; have [n leQn] := ubnP #|Q|. elim: n => // n IHn in (Q) leQn sQP *. have [i Qi | Q0] := pickP Q; last by rewrite !big_pred0. rewrite (cardD1x Qi) add1n ltnS !(bigD1 i Qi) /= in leQn *. rewrite {}IHn {n leQn}// => [|j /andP[/sQP //]]. apply/dprodYP; apply: subset_trans (dxG i (sQP i Qi)); rewrite !bigprodGE. by apply: genS; apply/bigcupsP=> j /andP[Qj ne_ji]; rewrite (bigcup_max j) ?sQP. Qed. Lemma dprod_modl A B G H : A \x B = G -> A \subset H -> A \x (B :&: H) = G :&: H. Proof. case/dprodP=> [[U V -> -> {A B}]] defG cUV trUV sUH. rewrite dprodEcp; first by apply: cprod_modl; rewrite ?cprodE. by rewrite setIA trUV (setIidPl _) ?sub1G. Qed. Lemma dprod_modr A B G H : A \x B = G -> B \subset H -> (H :&: A) \x B = H :&: G. Proof. by rewrite -!(dprodC B) !(setIC H); apply: dprod_modl. Qed. Lemma subcent_dprod B C G A : B \x C = G -> A \subset 'N(B) :&: 'N(C) -> 'C_B(A) \x 'C_C(A) = 'C_G(A). Proof. move=> defG; have [_ _ cBC _] := dprodP defG; move: defG. by rewrite !dprodEsd 1?(centSS _ _ cBC) ?subsetIl //; apply: subcent_sdprod. Qed. Lemma dprod_card A B G : A \x B = G -> (#|A| * #|B|)%N = #|G|. Proof. by case/dprodP=> [[H K -> ->] <- _]; move/TI_cardMg. Qed. Lemma bigdprod_card I r (P : pred I) E G : \big[dprod/1]_(i <- r | P i) E i = G -> (\prod_(i <- r | P i) #|E i|)%N = #|G|. Proof. elim/big_rec2: _ G => [G <- | i A B _ IH G defG]; first by rewrite cards1. have [[_ H _ defH] _ _ _] := dprodP defG. by rewrite -(dprod_card defG) (IH H) defH. Qed. Lemma bigcprod_card_dprod I r (P : pred I) (A : I -> {set gT}) G : \big[cprod/1]_(i <- r | P i) A i = G -> \prod_(i <- r | P i) #|A i| <= #|G| -> \big[dprod/1]_(i <- r | P i) A i = G. Proof. elim: r G => [|i r IHr]; rewrite !(big_nil, big_cons) //; case: ifP => _ // G. case/cprodP=> [[K H -> defH]]; rewrite defH => <- cKH leKH_G. have /implyP := leq_trans leKH_G (dvdn_leq _ (dvdn_cardMg K H)). rewrite muln_gt0 leq_pmul2l !cardG_gt0 //= => /(IHr H defH){}defH. by rewrite defH dprodE // cardMg_TI // -(bigdprod_card defH). Qed. Lemma bigcprod_coprime_dprod (I : finType) (P : pred I) (A : I -> {set gT}) G : \big[cprod/1]_(i | P i) A i = G -> (forall i j, P i -> P j -> i != j -> coprime #|A i| #|A j|) -> \big[dprod/1]_(i | P i) A i = G. Proof. move=> defG coA; set Q := P in defG *; have sQP: subpred Q P by []. have [m leQm] := ubnP #|Q|; elim: m => // m IHm in (Q) leQm G defG sQP *. have [i Qi | Q0] := pickP Q; last by rewrite !big_pred0 in defG *. move: defG; rewrite !(bigD1 i Qi) /= => /cprodP[[Hi Gi defAi defGi] <-]. rewrite defAi defGi => cHGi. have{} defGi: \big[dprod/1]_(j | Q j && (j != i)) A j = Gi. by apply: IHm => [||j /andP[/sQP]] //; rewrite (cardD1x Qi) in leQm. rewrite defGi dprodE // coprime_TIg // -defAi -(bigdprod_card defGi). elim/big_rec: _ => [|j n /andP[neq_ji Qj] IHn]; first exact: coprimen1. by rewrite coprimeMr coprime_sym coA ?sQP. Qed. Lemma mem_dprod G A B x : A \x B = G -> x \in G -> exists y, exists z, [/\ y \in A, z \in B, x = y * z & {in A & B, forall u t, x = u * t -> u = y /\ t = z}]. Proof. move=> defG; have [_ _ cBA _] := dprodP defG. by apply: mem_sdprod; rewrite -dprodEsd. Qed. Lemma mem_bigdprod (I : finType) (P : pred I) F G x : \big[dprod/1]_(i | P i) F i = G -> x \in G -> exists c, [/\ forall i, P i -> c i \in F i, x = \prod_(i | P i) c i & forall e, (forall i, P i -> e i \in F i) -> x = \prod_(i | P i) e i -> forall i, P i -> e i = c i]. Proof. move=> defG; rewrite -(bigdprodW defG) => /prodsgP[c Fc ->]. have [r big_r [_ mem_r] _] := big_enumP P. exists c; split=> // e Fe eq_ce i Pi; rewrite -!{}big_r in defG eq_ce. have{Pi}: i \in r by rewrite mem_r. have{mem_r}: all P r by apply/allP=> j; rewrite mem_r. elim: r G defG eq_ce => // j r IHr G. rewrite !big_cons inE /= => /dprodP[[K H defK defH] _ _]. rewrite defK defH => tiFjH eq_ce /andP[Pj Pr]. suffices{i IHr} eq_cej: c j = e j. case/predU1P=> [-> //|]; apply: IHr defH _ Pr. by apply: (mulgI (c j)); rewrite eq_ce eq_cej. rewrite !(big_nth j) !big_mkord in defH eq_ce. move/(congr1 (divgr K H)): eq_ce; move/bigdprodW: defH => defH. move/(all_nthP j) in Pr. by rewrite !divgrMid // -?defK -?defH ?mem_prodg // => *; rewrite ?Fc ?Fe ?Pr. Qed. Lemma comm_prodG I r (G : I -> {group gT}) (P : {pred I}) : {in P &, forall i j, commute (G i) (G j)} -> (\prod_(i <- r | P i) G i)%G = \prod_(i <- r | P i) G i :> {set gT}. Proof. elim: r => /= [|i {}r IHr]; rewrite !(big_nil, big_cons)//=. case: ifP => //= Pi Gcomm; rewrite comm_joingE {}IHr// /commute. elim: r => [|j r IHr]; first by rewrite big_nil mulg1 mul1g. by rewrite big_cons; case: ifP => //= Pj; rewrite mulgA Gcomm// -!mulgA IHr. Qed. End InternalProd. Arguments complP {gT H A B}. Arguments splitsP {gT B A}. Arguments sdprod_normal_complP {gT G K H}. Arguments dprodYP {gT K H}. Arguments bigdprodYP {gT I P F}. Section MorphimInternalProd. Variables (gT rT : finGroupType) (D : {group gT}) (f : {morphism D >-> rT}). Section OneProd. Variables G H K : {group gT}. Hypothesis sGD : G \subset D. Lemma morphim_pprod : pprod K H = G -> pprod (f @* K) (f @* H) = f @* G. Proof. case/pprodP=> _ defG mKH; rewrite pprodE ?morphim_norms //. by rewrite -morphimMl ?(subset_trans _ sGD) -?defG // mulG_subl. Qed. Lemma morphim_coprime_sdprod : K ><| H = G -> coprime #|K| #|H| -> f @* K ><| f @* H = f @* G. Proof. rewrite /sdprod => defG coHK; move: defG. by rewrite !coprime_TIg ?coprime_morph // !subxx; apply: morphim_pprod. Qed. Lemma injm_sdprod : 'injm f -> K ><| H = G -> f @* K ><| f @* H = f @* G. Proof. move=> inj_f; case/sdprodP=> _ defG nKH tiKH. by rewrite /sdprod -injmI // tiKH morphim1 subxx morphim_pprod // pprodE. Qed. Lemma morphim_cprod : K \* H = G -> f @* K \* f @* H = f @* G. Proof. case/cprodP=> _ defG cKH; rewrite /cprod morphim_cents // morphim_pprod //. by rewrite pprodE // cents_norm // centsC. Qed. Lemma injm_dprod : 'injm f -> K \x H = G -> f @* K \x f @* H = f @* G. Proof. move=> inj_f; case/dprodP=> _ defG cHK tiKH. by rewrite /dprod -injmI // tiKH morphim1 subxx morphim_cprod // cprodE. Qed. Lemma morphim_coprime_dprod : K \x H = G -> coprime #|K| #|H| -> f @* K \x f @* H = f @* G. Proof. rewrite /dprod => defG coHK; move: defG. by rewrite !coprime_TIg ?coprime_morph // !subxx; apply: morphim_cprod. Qed. End OneProd. Implicit Type G : {group gT}. Lemma morphim_bigcprod I r (P : pred I) (H : I -> {group gT}) G : G \subset D -> \big[cprod/1]_(i <- r | P i) H i = G -> \big[cprod/1]_(i <- r | P i) f @* H i = f @* G. Proof. elim/big_rec2: _ G => [|i fB B Pi def_fB] G sGD defG. by rewrite -defG morphim1. case/cprodP: defG (defG) => [[Hi Gi -> defB] _ _]; rewrite defB => defG. rewrite (def_fB Gi) //; first exact: morphim_cprod. by apply: subset_trans sGD; case/cprod_normal2: defG => _ /andP[]. Qed. Lemma injm_bigdprod I r (P : pred I) (H : I -> {group gT}) G : G \subset D -> 'injm f -> \big[dprod/1]_(i <- r | P i) H i = G -> \big[dprod/1]_(i <- r | P i) f @* H i = f @* G. Proof. move=> sGD injf; elim/big_rec2: _ G sGD => [|i fB B Pi def_fB] G sGD defG. by rewrite -defG morphim1. case/dprodP: defG (defG) => [[Hi Gi -> defB] _ _ _]; rewrite defB => defG. rewrite (def_fB Gi) //; first exact: injm_dprod. by apply: subset_trans sGD; case/dprod_normal2: defG => _ /andP[]. Qed. Lemma morphim_coprime_bigdprod (I : finType) P (H : I -> {group gT}) G : G \subset D -> \big[dprod/1]_(i | P i) H i = G -> (forall i j, P i -> P j -> i != j -> coprime #|H i| #|H j|) -> \big[dprod/1]_(i | P i) f @* H i = f @* G. Proof. move=> sGD /bigdprodWcp defG coH; have def_fG := morphim_bigcprod sGD defG. by apply: bigcprod_coprime_dprod => // i j *; rewrite coprime_morph ?coH. Qed. End MorphimInternalProd. Section QuotientInternalProd. Variables (gT : finGroupType) (G K H M : {group gT}). Hypothesis nMG: G \subset 'N(M). Lemma quotient_pprod : pprod K H = G -> pprod (K / M) (H / M) = G / M. Proof. exact: morphim_pprod. Qed. Lemma quotient_coprime_sdprod : K ><| H = G -> coprime #|K| #|H| -> (K / M) ><| (H / M) = G / M. Proof. exact: morphim_coprime_sdprod. Qed. Lemma quotient_cprod : K \* H = G -> (K / M) \* (H / M) = G / M. Proof. exact: morphim_cprod. Qed. Lemma quotient_coprime_dprod : K \x H = G -> coprime #|K| #|H| -> (K / M) \x (H / M) = G / M. Proof. exact: morphim_coprime_dprod. Qed. End QuotientInternalProd. Section ExternalDirProd. Variables gT1 gT2 : finGroupType. Definition extprod_mulg (x y : gT1 * gT2) := (x.1 * y.1, x.2 * y.2). Definition extprod_invg (x : gT1 * gT2) := (x.1^-1, x.2^-1). Lemma extprod_mul1g : left_id (1, 1) extprod_mulg. Proof. by case=> x1 x2; congr (_, _); apply: mul1g. Qed. Lemma extprod_mulVg : left_inverse (1, 1) extprod_invg extprod_mulg. Proof. by move=> x; congr (_, _); apply: mulVg. Qed. Lemma extprod_mulgA : associative extprod_mulg. Proof. by move=> x y z; congr (_, _); apply: mulgA. Qed. HB.instance Definition _ := isMulGroup.Build (gT1 * gT2)%type extprod_mulgA extprod_mul1g extprod_mulVg. Lemma group_setX (H1 : {group gT1}) (H2 : {group gT2}) : group_set (setX H1 H2). Proof. apply/group_setP; split; first by rewrite !inE !group1. by case=> [x1 x2] [y1 y2] /[!inE] /andP[Hx1 Hx2] /andP[Hy1 Hy2] /[!groupM]. Qed. Canonical setX_group H1 H2 := Group (group_setX H1 H2). Definition pairg1 x : gT1 * gT2 := (x, 1). Definition pair1g x : gT1 * gT2 := (1, x). Lemma pairg1_morphM : {morph pairg1 : x y / x * y}. Proof. by move=> x y /=; rewrite {2}/mulg /= /extprod_mulg /= mul1g. Qed. Canonical pairg1_morphism := @Morphism _ _ setT _ (in2W pairg1_morphM). Lemma pair1g_morphM : {morph pair1g : x y / x * y}. Proof. by move=> x y /=; rewrite {2}/mulg /= /extprod_mulg /= mul1g. Qed. Canonical pair1g_morphism := @Morphism _ _ setT _ (in2W pair1g_morphM). Lemma fst_morphM : {morph (@fst gT1 gT2) : x y / x * y}. Proof. by move=> x y. Qed. Lemma snd_morphM : {morph (@snd gT1 gT2) : x y / x * y}. Proof. by move=> x y. Qed. Canonical fst_morphism := @Morphism _ _ setT _ (in2W fst_morphM). Canonical snd_morphism := @Morphism _ _ setT _ (in2W snd_morphM). Lemma injm_pair1g : 'injm pair1g. Proof. by apply/subsetP=> x /morphpreP[_ /set1P[->]]; apply: set11. Qed. Lemma injm_pairg1 : 'injm pairg1. Proof. by apply/subsetP=> x /morphpreP[_ /set1P[->]]; apply: set11. Qed. Lemma morphim_pairg1 (H1 : {set gT1}) : pairg1 @* H1 = setX H1 1. Proof. by rewrite -imset2_pair imset2_set1r morphimEsub ?subsetT. Qed. Lemma morphim_pair1g (H2 : {set gT2}) : pair1g @* H2 = setX 1 H2. Proof. by rewrite -imset2_pair imset2_set1l morphimEsub ?subsetT. Qed. Lemma morphim_fstX (H1: {set gT1}) (H2 : {group gT2}) : [morphism of fun x => x.1] @* setX H1 H2 = H1. Proof. apply/eqP; rewrite eqEsubset morphimE setTI /=. apply/andP; split; apply/subsetP=> x. by case/imsetP=> x0 /[1!inE] /andP[Hx1 _] ->. move=> Hx1; apply/imsetP; exists (x, 1); last by trivial. by rewrite in_setX Hx1 /=. Qed. Lemma morphim_sndX (H1: {group gT1}) (H2 : {set gT2}) : [morphism of fun x => x.2] @* setX H1 H2 = H2. Proof. apply/eqP; rewrite eqEsubset morphimE setTI /=. apply/andP; split; apply/subsetP=> x. by case/imsetP=> x0 /[1!inE] /andP[_ Hx2] ->. move=> Hx2; apply/imsetP; exists (1, x); last by []. by rewrite in_setX Hx2 andbT. Qed. Lemma setX_prod (H1 : {set gT1}) (H2 : {set gT2}) : setX H1 1 * setX 1 H2 = setX H1 H2. Proof. apply/setP=> [[x y]]; rewrite !inE /=. apply/imset2P/andP=> [[[x1 u1] [v1 y1]] | [Hx Hy]]. rewrite !inE /= => /andP[Hx1 /eqP->] /andP[/eqP-> Hx] [-> ->]. by rewrite mulg1 mul1g. exists (x, 1 : gT2) (1 : gT1, y); rewrite ?inE ?Hx ?eqxx //. by rewrite /mulg /= /extprod_mulg /= mulg1 mul1g. Qed. Lemma setX_dprod (H1 : {group gT1}) (H2 : {group gT2}) : setX H1 1 \x setX 1 H2 = setX H1 H2. Proof. rewrite dprodE ?setX_prod //. apply/centsP=> [[x u]] /[!inE]/= /andP[/eqP-> _] [v y]. by rewrite !inE /= => /andP[_ /eqP->]; congr (_, _); rewrite ?mul1g ?mulg1. apply/trivgP; apply/subsetP=> [[x y]]; rewrite !inE /= -!andbA. by case/and4P=> _ /eqP-> /eqP->; rewrite eqxx. Qed. Lemma isog_setX1 (H1 : {group gT1}) : isog H1 (setX H1 1). Proof. apply/isogP; exists [morphism of restrm (subsetT H1) pairg1]. by rewrite injm_restrm ?injm_pairg1. by rewrite morphim_restrm morphim_pairg1 setIid. Qed. Lemma isog_set1X (H2 : {group gT2}) : isog H2 (setX 1 H2). Proof. apply/isogP; exists [morphism of restrm (subsetT H2) pair1g]. by rewrite injm_restrm ?injm_pair1g. by rewrite morphim_restrm morphim_pair1g setIid. Qed. Lemma setX_gen (H1 : {set gT1}) (H2 : {set gT2}) : 1 \in H1 -> 1 \in H2 -> <<setX H1 H2>> = setX <<H1>> <<H2>>. Proof. move=> H1_1 H2_1; apply/eqP. rewrite eqEsubset gen_subG setXS ?subset_gen //. (* TODO: investigate why the occurrence selection changed *) rewrite -[in X in X \subset _]setX_prod. rewrite -morphim_pair1g -morphim_pairg1 !morphim_gen ?subsetT //. by rewrite morphim_pair1g morphim_pairg1 mul_subG // genS // setXS ?sub1set. Qed. End ExternalDirProd. Section ExternalDirDepProd. Variables (I : finType) (gT : I -> finGroupType). Notation gTn := {dffun forall i, gT i}. Implicit Types (H : forall i, {group gT i}) (x y : {dffun forall i, gT i}). Definition extnprod_mulg (x y : gTn) : gTn := [ffun i => (x i * y i)%g]. Definition extnprod_invg (x : gTn) : gTn := [ffun i => (x i)^-1%g]. Lemma extnprod_mul1g : left_id [ffun=> 1%g] extnprod_mulg. Proof. by move=> x; apply/ffunP => i; rewrite !ffunE mul1g. Qed. Lemma extnprod_mulVg : left_inverse [ffun=> 1%g] extnprod_invg extnprod_mulg. Proof. by move=> x; apply/ffunP => i; rewrite !ffunE mulVg. Qed. Lemma extnprod_mulgA : associative extnprod_mulg. Proof. by move=> x y z; apply/ffunP => i; rewrite !ffunE mulgA. Qed. HB.instance Definition _ := isMulGroup.Build {dffun forall i : I, gT i} extnprod_mulgA extnprod_mul1g extnprod_mulVg. Lemma oneg_ffun i : (1 : gTn) i = 1. Proof. by rewrite ffunE. Qed. Lemma mulg_ffun i (x y : gTn) : (x * y) i = x i * y i. Proof. by rewrite ffunE. Qed. Lemma invg_ffun i (x : gTn) : x^-1 i = (x i)^-1. Proof. by rewrite ffunE. Qed. Lemma prodg_ffun T (r : seq T) (F : T -> gTn) (P : {pred T}) i : (\prod_(t <- r | P t) F t) i = \prod_(t <- r | P t) F t i. Proof. exact: (big_morph _ (@mulg_ffun i) (@oneg_ffun i)). Qed. Lemma group_setXn H : group_set (setXn H). Proof. by apply/group_setP; split=> [|x y] /[!inE]/= => [|/forallP xH /forallP yH]; apply/forallP => i; rewrite ?ffunE (group1, groupM)// ?xH ?yH. Qed. Canonical setXn_group H := Group (group_setXn H). Definition dfung1 i (g : gT i) : gTn := finfun (dfwith (fun=> 1 : gT _) g). Lemma dfung1_id i (g : gT i) : dfung1 g i = g. Proof. by rewrite ffunE dfwith_in. Qed. Lemma dfung1_dflt i (g : gT i) j : i != j -> dfung1 g j = 1. Proof. by move=> ij; rewrite ffunE dfwith_out. Qed. Lemma dfung1_morphM i : {morph @dfung1 i : g h / g * h}. Proof. move=> g h; apply/ffunP=> j; have [{j}<-|nij] := eqVneq i j. by rewrite !(dfung1_id, ffunE). by rewrite !(dfung1_dflt, ffunE)// mulg1. Qed. Canonical dfung1_morphism i := @Morphism _ _ setT _ (in2W (@dfung1_morphM i)). Lemma dffunM i : {morph (fun x => x i) : x y / x * y}. Proof. by move=> x y; rewrite !ffunE. Qed. Canonical dffun_morphism i := @Morphism _ _ setT _ (in2W (@dffunM i)). Lemma injm_dfung1 i : 'injm (@dfung1 i). Proof. apply/subsetP => x /morphpreP[_ /set1P /ffunP/=/(_ i)]. by rewrite !(ffunE, dfung1_id) => ->; apply: set11. Qed. Lemma group_set_dfwith H i (G : {group gT i}) j : group_set (dfwith (H : forall k, {set gT k}) (G : {set _}) j). Proof. have [<-|ij] := eqVneq i j; first by rewrite !dfwith_in// groupP. by rewrite !dfwith_out // groupP. Qed. Canonical group_dfwith H i G j := Group (@group_set_dfwith H i G j). Lemma group_dfwithE H i G j : @group_dfwith H i G j = dfwith H G j. Proof. by apply/val_inj; have [<-|nij]/= := eqVneq i j; [rewrite !dfwith_in|rewrite !dfwith_out]. Qed. Fact set1gXn_key : unit. Proof. by []. Qed. Definition set1gXn {i} (H : {set gT i}) : {set {dffun forall i : I, gT i}} := locked_with set1gXn_key (setXn (dfwith (fun i0 : I => [1 gT _]%g) H)). Lemma set1gXnE {i} (H : {set gT i}) : set1gXn H = setXn (dfwith (fun i0 : I => [1 gT _]%g) H). Proof. by rewrite /set1gXn unlock. Qed. Lemma set1gXnP {i} (H : {set gT i}) x : reflect (exists2 h, h \in H & x = dfung1 h) (x \in set1gXn H). Proof. rewrite set1gXnE/=; apply: (iffP setXnP) => [xP|[h hH ->] j]; last first. by rewrite ffunE; case: dfwithP => [|k ?]; rewrite (dfwith_in, dfwith_out). exists (x i); first by have := xP i; rewrite dfwith_in. apply/ffunP => j; have := xP j; rewrite ffunE. case: dfwithP => // [xiH|k neq_ik]; first by rewrite dfwith_in. by move=> /set1gP->; rewrite dfwith_out. Qed. Lemma morphim_dfung1 i (G : {set gT i}) : @dfung1 i @* G = set1gXn G. Proof. by rewrite morphimEsub//=; apply/setP=> /= x; apply/imsetP/set1gXnP. Qed. Lemma morphim_dffunXn i H : dffun_morphism i @* setXn H = H i. Proof. apply/eqP; rewrite eqEsubset morphimE setTI /=. apply/andP; split; apply/subsetP=> x. by case/imsetP => x0 /[1!inE] /forallP/(_ i)/= ? ->. move=> Hx1; apply/imsetP; exists (dfung1 x); last by rewrite dfung1_id. by rewrite in_setXn; apply/forallP => j /[!ffunE]; case: dfwithP. Qed. Lemma set1gXn_group_set {i} (H : {group gT i}) : group_set (set1gXn H). Proof. by rewrite set1gXnE; exact: group_setXn. Qed. Canonical groupXn1 {i} (H : {group gT i}) := Group (set1gXn_group_set H). Lemma setXn_prod H : \prod_i set1gXn (H i) = setXn H. Proof. apply/setP => /= x; apply/prodsgP /setXnP => [[/= f fH {x}-> i]|xH /=]. rewrite prodg_ffun group_prod// => j _. by have /set1gXnP[x xH ->] := fH j isT; rewrite ffunE; case: dfwithP. exists (fun i => dfung1 (x i)) => [i _|]; first by apply/set1gXnP; exists (x i). apply/ffunP => i; rewrite prodg_ffun (big_only1 i) ?dfung1_id//. by move=> j ij _; rewrite dfung1_dflt. Qed. Lemma set1gXn_commute (H : forall i, {group gT i}) i j : commute (set1gXn (H i)) (set1gXn (H j)). Proof. have [-> //|neqij] := eqVneq j i. apply/centC/centsP => _ /set1gXnP [hi hiH ->] _ /set1gXnP [hj hjH ->]. apply/ffunP => k; rewrite !ffunE. by case: dfwithP => [|?]; rewrite ?mulg1 ?mul1g// dfwith_out// mulg1 mul1g. Qed. Lemma setXn_dprod H : \big[dprod/1]_i set1gXn (H i) = setXn H. Proof. rewrite -setXn_prod//=. suff -> : \big[dprod/1]_i groupXn1 (H i) = (\prod_i groupXn1 (H i))%G. by rewrite comm_prodG//=; apply: in2W; apply: set1gXn_commute. apply/eqP; apply/bigdprodYP => i //= _; rewrite subsetD. apply/andP; split. rewrite comm_prodG; last by apply: in2W; apply: set1gXn_commute. apply/centsP => _ /prodsgP[/= h_ h_P ->] _ /set1gXnP [h hH ->]. apply/ffunP => j; rewrite !ffunE/=. rewrite (big_morph _ (@dffunM j) (_ : _ = 1)) ?ffunE//. case: dfwithP => {j} [|? ?]; last by rewrite mulg1 mul1g. rewrite big1 ?mulg1 ?mul1g// => j neq_ji. by have /set1gXnP[? _ ->] := h_P j neq_ji; rewrite ffunE dfwith_out. rewrite -setI_eq0 -subset0; apply/subsetP => /= x; rewrite !inE. rewrite comm_prodG; last by apply: in2W; apply: set1gXn_commute. move=> /and3P[+ + /set1gXnP [h _ x_h]]; rewrite {x}x_h. move=> /prodsgP[x_ x_P /ffunP/(_ i)]; rewrite ffunE dfwith_in => {h}->. apply: contra_neqT => _; apply/ffunP => j; rewrite !ffunE/=. case: dfwithP => // {j}; rewrite (big_morph _ (@dffunM i) (_ : _ = 1)) ?ffunE//. rewrite big1// => j neq_ji. by have /set1gXnP[g gH /ffunP->] := x_P _ neq_ji; rewrite ffunE dfwith_out. Qed. Lemma isog_setXn i (G : {group gT i}) : G \isog set1gXn G. Proof. apply/(@isogP _ _ G); exists [morphism of restrm (subsetT G) (@dfung1 i)]. by rewrite injm_restrm ?injm_dfung1. by rewrite morphim_restrm morphim_dfung1 setIid. Qed. Lemma setXn_gen H : (forall i, 1 \in H i) -> <<setXn H>> = setXn (fun i => <<H i>>). Proof. move=> H1; apply/eqP; rewrite eqEsubset gen_subG setXnS/=; last first. by move=> ?; rewrite subset_gen. rewrite -[in X in X \subset _]setXn_prod; under eq_bigr do rewrite -morphim_dfung1 morphim_gen ?subsetT// morphim_dfung1. rewrite prod_subG// => i; rewrite genS // set1gXnE setXnS // => j. by case: dfwithP => // k _; rewrite sub1set. Qed. End ExternalDirDepProd. Lemma groupX0 (gT : 'I_0 -> finGroupType) (G : forall i, {group gT i}) : setXn G = 1%g. Proof. by apply/setP => ?; apply/setXnP/set1P => [_|_ []//]; apply/ffunP => -[]. Qed. Section ExternalSDirProd. Variables (aT rT : finGroupType) (D : {group aT}) (R : {group rT}). (* The pair (a, x) denotes the product sdpair2 a * sdpair1 x *) Inductive sdprod_by (to : groupAction D R) : predArgType := SdPair (ax : aT * rT) of ax \in setX D R. Coercion pair_of_sd to (u : sdprod_by to) := let: SdPair ax _ := u in ax. Variable to : groupAction D R. Notation sdT := (sdprod_by to). Notation sdval := (@pair_of_sd to). HB.instance Definition _ := [isSub for sdval]. #[hnf] HB.instance Definition _ := [Finite of sdT by <:]. Definition sdprod_one := SdPair to (group1 _). Lemma sdprod_inv_proof (u : sdT) : (u.1^-1, to u.2^-1 u.1^-1) \in setX D R. Proof. by case: u => [[a x]] /= /setXP[Da Rx]; rewrite inE gact_stable !groupV ?Da. Qed. Definition sdprod_inv u := SdPair to (sdprod_inv_proof u). Lemma sdprod_mul_proof (u v : sdT) : (u.1 * v.1, to u.2 v.1 * v.2) \in setX D R. Proof. case: u v => [[a x] /= /setXP[Da Rx]] [[b y] /= /setXP[Db Ry]]. by rewrite inE !groupM //= gact_stable. Qed. Definition sdprod_mul u v := SdPair to (sdprod_mul_proof u v). Lemma sdprod_mul1g : left_id sdprod_one sdprod_mul. Proof. move=> u; apply: val_inj; case: u => [[a x] /=]; case/setXP=> Da _. by rewrite gact1 // !mul1g. Qed. Lemma sdprod_mulVg : left_inverse sdprod_one sdprod_inv sdprod_mul. Proof. move=> u; apply: val_inj; case: u => [[a x] /=]; case/setXP=> Da _. by rewrite actKVin ?mulVg. Qed. Lemma sdprod_mulgA : associative sdprod_mul. Proof. move=> u v w; apply: val_inj; case: u => [[a x]] /=; case/setXP=> Da Rx. case: v w => [[b y]] /=; case/setXP=> Db Ry [[c z]] /=; case/setXP=> Dc Rz. by rewrite !(actMin to) // gactM ?gact_stable // !mulgA. Qed. HB.instance Definition _ := isMulGroup.Build sdT sdprod_mulgA sdprod_mul1g sdprod_mulVg. Definition sdprod_groupType : finGroupType := sdT. Definition sdpair1 x := insubd sdprod_one (1, x) : sdT. Definition sdpair2 a := insubd sdprod_one (a, 1) : sdT. Lemma sdpair1_morphM : {in R &, {morph sdpair1 : x y / x * y}}. Proof. move=> x y Rx Ry; apply: val_inj. by rewrite /= !val_insubd !inE !group1 !groupM ?Rx ?Ry //= mulg1 act1. Qed. Lemma sdpair2_morphM : {in D &, {morph sdpair2 : a b / a * b}}. Proof. move=> a b Da Db; apply: val_inj. by rewrite /= !val_insubd !inE !group1 !groupM ?Da ?Db //= mulg1 gact1. Qed. Canonical sdpair1_morphism := Morphism sdpair1_morphM. Canonical sdpair2_morphism := Morphism sdpair2_morphM. Lemma injm_sdpair1 : 'injm sdpair1. Proof. apply/subsetP=> x /setIP[Rx]. by rewrite !inE -val_eqE val_insubd inE Rx group1 /=; case/andP. Qed. Lemma injm_sdpair2 : 'injm sdpair2. Proof. apply/subsetP=> a /setIP[Da]. by rewrite !inE -val_eqE val_insubd inE Da group1 /=; case/andP. Qed. Lemma sdpairE (u : sdT) : u = sdpair2 u.1 * sdpair1 u.2. Proof. apply: val_inj; case: u => [[a x] /= /setXP[Da Rx]]. by rewrite !val_insubd !inE Da Rx !(group1, gact1) // mulg1 mul1g. Qed. Lemma sdpair_act : {in R & D, forall x a, sdpair1 (to x a) = sdpair1 x ^ sdpair2 a}. Proof. move=> x a Rx Da; apply: val_inj. rewrite /= !val_insubd !inE !group1 gact_stable ?Da ?Rx //=. by rewrite !mul1g mulVg invg1 mulg1 actKVin ?mul1g. Qed. Lemma sdpair_setact (G : {set rT}) a : G \subset R -> a \in D -> sdpair1 @* (to^~ a @: G) = (sdpair1 @* G) :^ sdpair2 a. Proof. move=> sGR Da; have GtoR := subsetP sGR; apply/eqP. rewrite eqEcard cardJg !(card_injm injm_sdpair1) //; last first. by apply/subsetP=> _ /imsetP[x Gx ->]; rewrite gact_stable ?GtoR. rewrite (card_imset _ (act_inj _ _)) leqnn andbT. apply/subsetP=> _ /morphimP[xa Rxa /imsetP[x Gx def_xa ->]]. rewrite mem_conjg -morphV // -sdpair_act ?groupV // def_xa actKin //. by rewrite mem_morphim ?GtoR. Qed. Lemma im_sdpair_norm : sdpair2 @* D \subset 'N(sdpair1 @* R). Proof. apply/subsetP=> _ /morphimP[a _ Da ->]. rewrite inE -sdpair_setact // morphimS //. by apply/subsetP=> _ /imsetP[x Rx ->]; rewrite gact_stable. Qed. Lemma im_sdpair_TI : (sdpair1 @* R) :&: (sdpair2 @* D) = 1. Proof. apply/trivgP; apply/subsetP=> _ /setIP[/morphimP[x _ Rx ->]]. case/morphimP=> a _ Da /eqP; rewrite inE -!val_eqE. by rewrite !val_insubd !inE Da Rx !group1 /eq_op /= eqxx; case/andP. Qed. Lemma im_sdpair : (sdpair1 @* R) * (sdpair2 @* D) = setT. Proof. apply/eqP; rewrite -subTset -(normC im_sdpair_norm). apply/subsetP=> /= u _; rewrite [u]sdpairE. by case: u => [[a x] /= /setXP[Da Rx]]; rewrite mem_mulg ?mem_morphim. Qed. Lemma sdprod_sdpair : sdpair1 @* R ><| sdpair2 @* D = setT. Proof. by rewrite sdprodE ?(im_sdpair_norm, im_sdpair, im_sdpair_TI). Qed. Variables (A : {set aT}) (G : {set rT}). Lemma gacentEsd : 'C_(|to)(A) = sdpair1 @*^-1 'C(sdpair2 @* A). Proof. apply/setP=> x; apply/idP/idP. case/setIP=> Rx /afixP cDAx; rewrite mem_morphpre //. apply/centP=> _ /morphimP[a Da Aa ->]; red. by rewrite conjgC -sdpair_act // cDAx // inE Da. case/morphpreP=> Rx cAx; rewrite inE Rx; apply/afixP=> a /setIP[Da Aa]. apply: (injmP injm_sdpair1); rewrite ?gact_stable /= ?sdpair_act //=. by rewrite /conjg (centP cAx) ?mulKg ?mem_morphim. Qed. Hypotheses (sAD : A \subset D) (sGR : G \subset R). Lemma astabEsd : 'C(G | to) = sdpair2 @*^-1 'C(sdpair1 @* G). Proof. have ssGR := subsetP sGR; apply/setP=> a; apply/idP/idP=> [cGa|]. rewrite mem_morphpre ?(astab_dom cGa) //. apply/centP=> _ /morphimP[x Rx Gx ->]; symmetry. by rewrite conjgC -sdpair_act ?(astab_act cGa) ?(astab_dom cGa). case/morphpreP=> Da cGa; rewrite !inE Da; apply/subsetP=> x Gx; rewrite inE. apply/eqP; apply: (injmP injm_sdpair1); rewrite ?gact_stable ?ssGR //=. by rewrite sdpair_act ?ssGR // /conjg -(centP cGa) ?mulKg ?mem_morphim ?ssGR. Qed. Lemma astabsEsd : 'N(G | to) = sdpair2 @*^-1 'N(sdpair1 @* G). Proof. apply/setP=> a; apply/idP/idP=> [nGa|]. have Da := astabs_dom nGa; rewrite mem_morphpre // inE sub_conjg. apply/subsetP=> _ /morphimP[x Rx Gx ->]. by rewrite mem_conjgV -sdpair_act // mem_morphim ?gact_stable ?astabs_act. case/morphpreP=> Da nGa; rewrite !inE Da; apply/subsetP=> x Gx. have Rx := subsetP sGR _ Gx; have Rxa: to x a \in R by rewrite gact_stable. rewrite inE -sub1set -(injmSK injm_sdpair1) ?morphim_set1 ?sub1set //=. by rewrite sdpair_act ?memJ_norm ?mem_morphim. Qed. Lemma actsEsd : [acts A, on G | to] = (sdpair2 @* A \subset 'N(sdpair1 @* G)). Proof. by rewrite sub_morphim_pre -?astabsEsd. Qed. End ExternalSDirProd. Section ProdMorph. Variables gT rT : finGroupType. Implicit Types A B : {set gT}. Implicit Types G H K : {group gT}. Implicit Types C D : {set rT}. Implicit Type L : {group rT}. Section defs. Variables (A B : {set gT}) (fA fB : gT -> FinGroup.sort rT). Definition pprodm of B \subset 'N(A) & {in A & B, morph_act 'J 'J fA fB} & {in A :&: B, fA =1 fB} := fun x => fA (divgr A B x) * fB (remgr A B x). End defs. Section Props. Variables H K : {group gT}. Variables (fH : {morphism H >-> rT}) (fK : {morphism K >-> rT}). Hypothesis nHK : K \subset 'N(H). Hypothesis actf : {in H & K, morph_act 'J 'J fH fK}. Hypothesis eqfHK : {in H :&: K, fH =1 fK}. Local Notation f := (pprodm nHK actf eqfHK). Lemma pprodmE x a : x \in H -> a \in K -> f (x * a) = fH x * fK a. Proof. move=> Hx Ka; have: x * a \in H * K by rewrite mem_mulg. rewrite -remgrP inE /f rcoset_sym mem_rcoset /divgr -mulgA groupMl //. case/andP; move: (remgr H K _) => b Hab Kb; rewrite morphM // -mulgA. have Kab: a * b^-1 \in K by rewrite groupM ?groupV. by congr (_ * _); rewrite eqfHK 1?inE ?Hab // -morphM // mulgKV. Qed. Lemma pprodmEl : {in H, f =1 fH}. Proof. by move=> x Hx; rewrite -(mulg1 x) pprodmE // morph1 !mulg1. Qed. Lemma pprodmEr : {in K, f =1 fK}. Proof. by move=> a Ka; rewrite -(mul1g a) pprodmE // morph1 !mul1g. Qed. Lemma pprodmM : {in H <*> K &, {morph f: x y / x * y}}. Proof. move=> xa yb; rewrite norm_joinEr //. move=> /imset2P[x a Ha Ka ->{xa}] /imset2P[y b Hy Kb ->{yb}]. have Hya: y ^ a^-1 \in H by rewrite -mem_conjg (normsP nHK). rewrite mulgA -(mulgA x) (conjgCV a y) (mulgA x) -mulgA !pprodmE 1?groupMl //. by rewrite morphM // actf ?groupV ?morphV // morphM // !mulgA mulgKV invgK. Qed. Canonical pprodm_morphism := Morphism pprodmM. Lemma morphim_pprodm A B : A \subset H -> B \subset K -> f @* (A * B) = fH @* A * fK @* B. Proof. move=> sAH sBK; rewrite [f @* _]morphimEsub /=; last first. by rewrite norm_joinEr // mulgSS. apply/setP=> y; apply/imsetP/idP=> [[_ /mulsgP[x a Ax Ba ->] ->{y}] |]. have Hx := subsetP sAH x Ax; have Ka := subsetP sBK a Ba. by rewrite pprodmE // imset2_f ?mem_morphim. case/mulsgP=> _ _ /morphimP[x Hx Ax ->] /morphimP[a Ka Ba ->] ->{y}. by exists (x * a); rewrite ?mem_mulg ?pprodmE. Qed. Lemma morphim_pprodml A : A \subset H -> f @* A = fH @* A. Proof. by move=> sAH; rewrite -{1}(mulg1 A) morphim_pprodm ?sub1G // morphim1 mulg1. Qed. Lemma morphim_pprodmr B : B \subset K -> f @* B = fK @* B. Proof. by move=> sBK; rewrite -{1}(mul1g B) morphim_pprodm ?sub1G // morphim1 mul1g. Qed. Lemma ker_pprodm : 'ker f = [set x * a^-1 | x in H, a in K & fH x == fK a]. Proof. apply/setP=> y; rewrite 3!inE {1}norm_joinEr //=. apply/andP/imset2P=> [[/mulsgP[x a Hx Ka ->{y}]]|[x a Hx]]. rewrite pprodmE // => fxa1. by exists x a^-1; rewrite ?invgK // inE groupVr ?morphV // eq_mulgV1 invgK. case/setIdP=> Kx /eqP fx ->{y}. by rewrite imset2_f ?pprodmE ?groupV ?morphV // fx mulgV. Qed. Lemma injm_pprodm : 'injm f = [&& 'injm fH, 'injm fK & fH @* H :&: fK @* K == fH @* K]. Proof. apply/idP/and3P=> [injf | [injfH injfK]]. rewrite eq_sym -{1}morphimIdom -(morphim_pprodml (subsetIl _ _)) injmI //. rewrite morphim_pprodml // morphim_pprodmr //=; split=> //. apply/injmP=> x y Hx Hy /=; rewrite -!pprodmEl //. by apply: (injmP injf); rewrite ?mem_gen ?inE ?Hx ?Hy. apply/injmP=> a b Ka Kb /=; rewrite -!pprodmEr //. by apply: (injmP injf); rewrite ?mem_gen //; apply/setUP; right. move/eqP=> fHK; rewrite ker_pprodm; apply/subsetP=> y. case/imset2P=> x a Hx /setIdP[Ka /eqP fxa] ->. have: fH x \in fH @* K by rewrite -fHK inE {2}fxa !mem_morphim. case/morphimP=> z Hz Kz /(injmP injfH) def_x. rewrite def_x // eqfHK ?inE ?Hz // in fxa. by rewrite def_x // (injmP injfK _ _ Kz Ka fxa) mulgV set11. Qed. End Props. Section Sdprodm. Variables H K G : {group gT}. Variables (fH : {morphism H >-> rT}) (fK : {morphism K >-> rT}). Hypothesis eqHK_G : H ><| K = G. Hypothesis actf : {in H & K, morph_act 'J 'J fH fK}. Lemma sdprodm_norm : K \subset 'N(H). Proof. by case/sdprodP: eqHK_G. Qed. Lemma sdprodm_sub : G \subset H <*> K. Proof. by case/sdprodP: eqHK_G => _ <- nHK _; rewrite norm_joinEr. Qed. Lemma sdprodm_eqf : {in H :&: K, fH =1 fK}. Proof. by case/sdprodP: eqHK_G => _ _ _ -> _ /set1P->; rewrite !morph1. Qed. Definition sdprodm := restrm sdprodm_sub (pprodm sdprodm_norm actf sdprodm_eqf). Canonical sdprodm_morphism := Eval hnf in [morphism of sdprodm]. Lemma sdprodmE a b : a \in H -> b \in K -> sdprodm (a * b) = fH a * fK b. Proof. exact: pprodmE. Qed. Lemma sdprodmEl a : a \in H -> sdprodm a = fH a. Proof. exact: pprodmEl. Qed. Lemma sdprodmEr b : b \in K -> sdprodm b = fK b. Proof. exact: pprodmEr. Qed. Lemma morphim_sdprodm A B : A \subset H -> B \subset K -> sdprodm @* (A * B) = fH @* A * fK @* B. Proof. move=> sAH sBK; rewrite /sdprodm morphim_restrm /= (setIidPr _) ?morphim_pprodm //. by case/sdprodP: eqHK_G => _ <- _ _; apply: mulgSS. Qed. Lemma im_sdprodm : sdprodm @* G = fH @* H * fK @* K. Proof. by rewrite -morphim_sdprodm //; case/sdprodP: eqHK_G => _ ->. Qed. Lemma morphim_sdprodml A : A \subset H -> sdprodm @* A = fH @* A. Proof. by move=> sHA; rewrite -{1}(mulg1 A) morphim_sdprodm ?sub1G // morphim1 mulg1. Qed. Lemma morphim_sdprodmr B : B \subset K -> sdprodm @* B = fK @* B. Proof. by move=> sBK; rewrite -{1}(mul1g B) morphim_sdprodm ?sub1G // morphim1 mul1g. Qed. Lemma ker_sdprodm : 'ker sdprodm = [set a * b^-1 | a in H, b in K & fH a == fK b]. Proof. rewrite ker_restrm (setIidPr _) ?subIset ?ker_pprodm //; apply/orP; left. by case/sdprodP: eqHK_G => _ <- nHK _; rewrite norm_joinEr. Qed. Lemma injm_sdprodm : 'injm sdprodm = [&& 'injm fH, 'injm fK & fH @* H :&: fK @* K == 1]. Proof. rewrite ker_sdprodm -(ker_pprodm sdprodm_norm actf sdprodm_eqf) injm_pprodm. congr [&& _, _ & _ == _]; have [_ _ _ tiHK] := sdprodP eqHK_G. by rewrite -morphimIdom tiHK morphim1. Qed. End Sdprodm. Section Cprodm. Variables H K G : {group gT}. Variables (fH : {morphism H >-> rT}) (fK : {morphism K >-> rT}). Hypothesis eqHK_G : H \* K = G. Hypothesis cfHK : fK @* K \subset 'C(fH @* H). Hypothesis eqfHK : {in H :&: K, fH =1 fK}. Lemma cprodm_norm : K \subset 'N(H). Proof. by rewrite cents_norm //; case/cprodP: eqHK_G. Qed. Lemma cprodm_sub : G \subset H <*> K. Proof. by case/cprodP: eqHK_G => _ <- cHK; rewrite cent_joinEr. Qed. Lemma cprodm_actf : {in H & K, morph_act 'J 'J fH fK}. Proof. case/cprodP: eqHK_G => _ _ cHK a b Ha Kb /=. by rewrite /conjg -(centsP cHK b) // -(centsP cfHK (fK b)) ?mulKg ?mem_morphim. Qed. Definition cprodm := restrm cprodm_sub (pprodm cprodm_norm cprodm_actf eqfHK). Canonical cprodm_morphism := Eval hnf in [morphism of cprodm]. Lemma cprodmE a b : a \in H -> b \in K -> cprodm (a * b) = fH a * fK b. Proof. exact: pprodmE. Qed. Lemma cprodmEl a : a \in H -> cprodm a = fH a. Proof. exact: pprodmEl. Qed. Lemma cprodmEr b : b \in K -> cprodm b = fK b. Proof. exact: pprodmEr. Qed. Lemma morphim_cprodm A B : A \subset H -> B \subset K -> cprodm @* (A * B) = fH @* A * fK @* B. Proof. move=> sAH sBK; rewrite [LHS]morphim_restrm /= (setIidPr _) ?morphim_pprodm //. by case/cprodP: eqHK_G => _ <- _; apply: mulgSS. Qed. Lemma im_cprodm : cprodm @* G = fH @* H * fK @* K. Proof. by have [_ defHK _] := cprodP eqHK_G; rewrite -{2}defHK morphim_cprodm. Qed. Lemma morphim_cprodml A : A \subset H -> cprodm @* A = fH @* A. Proof. by move=> sHA; rewrite -{1}(mulg1 A) morphim_cprodm ?sub1G // morphim1 mulg1. Qed. Lemma morphim_cprodmr B : B \subset K -> cprodm @* B = fK @* B. Proof. by move=> sBK; rewrite -{1}(mul1g B) morphim_cprodm ?sub1G // morphim1 mul1g. Qed. Lemma ker_cprodm : 'ker cprodm = [set a * b^-1 | a in H, b in K & fH a == fK b]. Proof. rewrite ker_restrm (setIidPr _) ?subIset ?ker_pprodm //; apply/orP; left. by case/cprodP: eqHK_G => _ <- cHK; rewrite cent_joinEr. Qed. Lemma injm_cprodm : 'injm cprodm = [&& 'injm fH, 'injm fK & fH @* H :&: fK @* K == fH @* K]. Proof. by rewrite ker_cprodm -(ker_pprodm cprodm_norm cprodm_actf eqfHK) injm_pprodm. Qed. End Cprodm. Section Dprodm. Variables G H K : {group gT}. Variables (fH : {morphism H >-> rT}) (fK : {morphism K >-> rT}). Hypothesis eqHK_G : H \x K = G. Hypothesis cfHK : fK @* K \subset 'C(fH @* H). Lemma dprodm_cprod : H \* K = G. Proof. by rewrite -eqHK_G /dprod; case/dprodP: eqHK_G => _ _ _ ->; rewrite subxx. Qed. Lemma dprodm_eqf : {in H :&: K, fH =1 fK}. Proof. by case/dprodP: eqHK_G => _ _ _ -> _ /set1P->; rewrite !morph1. Qed. Definition dprodm := cprodm dprodm_cprod cfHK dprodm_eqf. Canonical dprodm_morphism := Eval hnf in [morphism of dprodm]. Lemma dprodmE a b : a \in H -> b \in K -> dprodm (a * b) = fH a * fK b. Proof. exact: pprodmE. Qed. Lemma dprodmEl a : a \in H -> dprodm a = fH a. Proof. exact: pprodmEl. Qed. Lemma dprodmEr b : b \in K -> dprodm b = fK b. Proof. exact: pprodmEr. Qed. Lemma morphim_dprodm A B : A \subset H -> B \subset K -> dprodm @* (A * B) = fH @* A * fK @* B. Proof. exact: morphim_cprodm. Qed. Lemma im_dprodm : dprodm @* G = fH @* H * fK @* K. Proof. exact: im_cprodm. Qed. Lemma morphim_dprodml A : A \subset H -> dprodm @* A = fH @* A. Proof. exact: morphim_cprodml. Qed. Lemma morphim_dprodmr B : B \subset K -> dprodm @* B = fK @* B. Proof. exact: morphim_cprodmr. Qed. Lemma ker_dprodm : 'ker dprodm = [set a * b^-1 | a in H, b in K & fH a == fK b]. Proof. exact: ker_cprodm. Qed. Lemma injm_dprodm : 'injm dprodm = [&& 'injm fH, 'injm fK & fH @* H :&: fK @* K == 1]. Proof. rewrite injm_cprodm -(morphimIdom fH K). by case/dprodP: eqHK_G => _ _ _ ->; rewrite morphim1. Qed. End Dprodm. Lemma isog_dprod A B G C D L : A \x B = G -> C \x D = L -> isog A C -> isog B D -> isog G L. Proof. move=> defG {C D} /dprodP[[C D -> ->] defL cCD trCD]. case/dprodP: defG (defG) => {A B} [[A B -> ->] defG _ _] dG defC defD. case/isogP: defC defL cCD trCD => fA injfA <-{C}. case/isogP: defD => fB injfB <-{D} defL cCD trCD. apply/isogP; exists (dprodm_morphism dG cCD). by rewrite injm_dprodm injfA injfB trCD eqxx. by rewrite /= -{2}defG morphim_dprodm. Qed. End ProdMorph. Section ExtSdprodm. Variables gT aT rT : finGroupType. Variables (H : {group gT}) (K : {group aT}) (to : groupAction K H). Variables (fH : {morphism H >-> rT}) (fK : {morphism K >-> rT}). Hypothesis actf : {in H & K, morph_act to 'J fH fK}. Local Notation fsH := (fH \o invm (injm_sdpair1 to)). Local Notation fsK := (fK \o invm (injm_sdpair2 to)). Let DgH := sdpair1 to @* H. Let DgK := sdpair2 to @* K. Lemma xsdprodm_dom1 : DgH \subset 'dom fsH. Proof. by rewrite ['dom _]morphpre_invm. Qed. Local Notation gH := (restrm xsdprodm_dom1 fsH). Lemma xsdprodm_dom2 : DgK \subset 'dom fsK. Proof. by rewrite ['dom _]morphpre_invm. Qed. Local Notation gK := (restrm xsdprodm_dom2 fsK). Lemma im_sdprodm1 : gH @* DgH = fH @* H. Proof. by rewrite morphim_restrm setIid morphim_comp im_invm. Qed. Lemma im_sdprodm2 : gK @* DgK = fK @* K. Proof. by rewrite morphim_restrm setIid morphim_comp im_invm. Qed. Lemma xsdprodm_act : {in DgH & DgK, morph_act 'J 'J gH gK}. Proof. move=> fh fk; case/morphimP=> h _ Hh ->{fh}; case/morphimP=> k _ Kk ->{fk}. by rewrite /= -sdpair_act // /restrm /= !invmE ?actf ?gact_stable. Qed. Definition xsdprodm := sdprodm (sdprod_sdpair to) xsdprodm_act. Canonical xsdprod_morphism := [morphism of xsdprodm]. Lemma im_xsdprodm : xsdprodm @* setT = fH @* H * fK @* K. Proof. by rewrite -im_sdpair morphim_sdprodm // im_sdprodm1 im_sdprodm2. Qed. Lemma injm_xsdprodm : 'injm xsdprodm = [&& 'injm fH, 'injm fK & fH @* H :&: fK @* K == 1]. Proof. rewrite injm_sdprodm im_sdprodm1 im_sdprodm2 !subG1 /=. rewrite (ker_restrm xsdprodm_dom1) (ker_restrm xsdprodm_dom2) /= !ker_comp. rewrite !morphpre_invm !morphimIim. by rewrite !morphim_injm_eq1 ?subsetIl ?injm_sdpair1 ?injm_sdpair2. Qed. End ExtSdprodm. Section DirprodIsom. Variable gT : finGroupType. Implicit Types G H : {group gT}. Definition mulgm : gT * gT -> _ := uncurry mulg. Lemma imset_mulgm (A B : {set gT}) : mulgm @: setX A B = A * B. Proof. by rewrite -curry_imset2X. Qed. Lemma mulgmP H1 H2 G : reflect (H1 \x H2 = G) (misom (setX H1 H2) G mulgm). Proof. apply: (iffP misomP) => [[pM /isomP[injf /= <-]] | ]. have /dprodP[_ /= defX cH12] := setX_dprod H1 H2. rewrite -{4}defX {}defX => /(congr1 (fun A => morphm pM @* A)). move/(morphimS (morphm_morphism pM)): cH12 => /=. have sH1H: setX H1 1 \subset setX H1 H2 by rewrite setXS ?sub1G. have sH2H: setX 1 H2 \subset setX H1 H2 by rewrite setXS ?sub1G. rewrite morphim1 injm_cent ?injmI //= subsetI => /andP[_]. by rewrite !morphimEsub //= !imset_mulgm mulg1 mul1g; apply: dprodE. case/dprodP=> _ defG cH12 trH12. have fM: morphic (setX H1 H2) mulgm. apply/morphicP=> [[x1 x2] [y1 y2] /setXP[_ Hx2] /setXP[Hy1 _]]. by rewrite /= mulgA -(mulgA x1) -(centsP cH12 x2) ?mulgA. exists fM; apply/isomP; split; last by rewrite morphimEsub //= imset_mulgm. apply/subsetP=> [[x1 x2]]; rewrite !inE /= andbC -eq_invg_mul. case: eqP => //= <-; rewrite groupV -in_setI trH12 => /set1P->. by rewrite invg1 eqxx. Qed. End DirprodIsom. Arguments mulgmP {gT H1 H2 G}. Prenex Implicits mulgm.
Free.lean
/- Copyright (c) 2023 Dagur Asgeirsson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Dagur Asgeirsson -/ import Mathlib.LinearAlgebra.Dimension.Free import Mathlib.Algebra.Homology.ShortComplex.ModuleCat /-! # Exact sequences with free modules This file proves results about linear independence and span in exact sequences of modules. ## Main theorems * `linearIndependent_shortExact`: Given a short exact sequence `0 ⟶ X₁ ⟶ X₂ ⟶ X₃ ⟶ 0` of `R`-modules and linearly independent families `v : ι → X₁` and `w : ι' → X₃`, we get a linearly independent family `ι ⊕ ι' → X₂` * `span_rightExact`: Given an exact sequence `X₁ ⟶ X₂ ⟶ X₃ ⟶ 0` of `R`-modules and spanning families `v : ι → X₁` and `w : ι' → X₃`, we get a spanning family `ι ⊕ ι' → X₂` * Using `linearIndependent_shortExact` and `span_rightExact`, we prove `free_shortExact`: In a short exact sequence `0 ⟶ X₁ ⟶ X₂ ⟶ X₃ ⟶ 0` where `X₁` and `X₃` are free, `X₂` is free as well. ## Tags linear algebra, module, free -/ open CategoryTheory Module namespace ModuleCat variable {ι ι' R : Type*} [Ring R] {S : ShortComplex (ModuleCat R)} (hS : S.Exact) (hS' : S.ShortExact) {v : ι → S.X₁} open CategoryTheory Submodule Set section LinearIndependent variable (hv : LinearIndependent R v) {u : ι ⊕ ι' → S.X₂} (hw : LinearIndependent R (S.g ∘ u ∘ Sum.inr)) (hm : Mono S.f) (huv : u ∘ Sum.inl = S.f ∘ v) section include hS hw huv theorem disjoint_span_sum : Disjoint (span R (range (u ∘ Sum.inl))) (span R (range (u ∘ Sum.inr))) := by rw [huv, disjoint_comm] refine Disjoint.mono_right (span_mono (range_comp_subset_range _ _)) ?_ rw [← LinearMap.range_coe, span_eq (LinearMap.range S.f.hom), hS.moduleCat_range_eq_ker] exact range_ker_disjoint hw include hv hm in /-- In the commutative diagram ``` f g 0 --→ X₁ --→ X₂ --→ X₃ ↑ ↑ ↑ v| u| w| ι → ι ⊕ ι' ← ι' ``` where the top row is an exact sequence of modules and the maps on the bottom are `Sum.inl` and `Sum.inr`. If `u` is injective and `v` and `w` are linearly independent, then `u` is linearly independent. -/ theorem linearIndependent_leftExact : LinearIndependent R u := by rw [linearIndependent_sum] refine ⟨?_, LinearIndependent.of_comp S.g.hom hw, disjoint_span_sum hS hw huv⟩ rw [huv, LinearMap.linearIndependent_iff S.f.hom]; swap · rw [LinearMap.ker_eq_bot, ← mono_iff_injective] infer_instance exact hv end include hS' hv in /-- Given a short exact sequence `0 ⟶ X₁ ⟶ X₂ ⟶ X₃ ⟶ 0` of `R`-modules and linearly independent families `v : ι → N` and `w : ι' → P`, we get a linearly independent family `ι ⊕ ι' → M` -/ theorem linearIndependent_shortExact {w : ι' → S.X₃} (hw : LinearIndependent R w) : LinearIndependent R (Sum.elim (S.f ∘ v) (S.g.hom.toFun.invFun ∘ w)) := by apply linearIndependent_leftExact hS'.exact hv _ hS'.mono_f rfl dsimp convert hw ext apply Function.rightInverse_invFun ((epi_iff_surjective _).mp hS'.epi_g) end LinearIndependent section Span include hS in /-- In the commutative diagram ``` f g X₁ --→ X₂ --→ X₃ ↑ ↑ ↑ v| u| w| ι → ι ⊕ ι' ← ι' ``` where the top row is an exact sequence of modules and the maps on the bottom are `Sum.inl` and `Sum.inr`. If `v` spans `X₁` and `w` spans `X₃`, then `u` spans `X₂`. -/ theorem span_exact {β : Type*} {u : ι ⊕ β → S.X₂} (huv : u ∘ Sum.inl = S.f ∘ v) (hv : ⊤ ≤ span R (range v)) (hw : ⊤ ≤ span R (range (S.g ∘ u ∘ Sum.inr))) : ⊤ ≤ span R (range u) := by intro m _ have hgm : S.g m ∈ span R (range (S.g ∘ u ∘ Sum.inr)) := hw mem_top rw [Finsupp.mem_span_range_iff_exists_finsupp] at hgm obtain ⟨cm, hm⟩ := hgm let m' : S.X₂ := Finsupp.sum cm fun j a ↦ a • (u (Sum.inr j)) have hsub : m - m' ∈ LinearMap.range S.f.hom := by rw [hS.moduleCat_range_eq_ker] simp only [LinearMap.mem_ker, map_sub, sub_eq_zero] rw [← hm, map_finsuppSum] simp only [Function.comp_apply, map_smul] obtain ⟨n, hnm⟩ := hsub have hn : n ∈ span R (range v) := hv mem_top rw [Finsupp.mem_span_range_iff_exists_finsupp] at hn obtain ⟨cn, hn⟩ := hn rw [← hn, map_finsuppSum] at hnm rw [← sub_add_cancel m m', ← hnm,] simp only [map_smul] have hn' : (Finsupp.sum cn fun a b ↦ b • S.f (v a)) = (Finsupp.sum cn fun a b ↦ b • u (Sum.inl a)) := by congr; ext a b; rw [← Function.comp_apply (f := S.f), ← huv, Function.comp_apply] rw [hn'] apply add_mem · rw [Finsupp.mem_span_range_iff_exists_finsupp] use cn.mapDomain (Sum.inl) rw [Finsupp.sum_mapDomain_index_inj Sum.inl_injective] · rw [Finsupp.mem_span_range_iff_exists_finsupp] use cm.mapDomain (Sum.inr) rw [Finsupp.sum_mapDomain_index_inj Sum.inr_injective] include hS in /-- Given an exact sequence `X₁ ⟶ X₂ ⟶ X₃ ⟶ 0` of `R`-modules and spanning families `v : ι → X₁` and `w : ι' → X₃`, we get a spanning family `ι ⊕ ι' → X₂` -/ theorem span_rightExact {w : ι' → S.X₃} (hv : ⊤ ≤ span R (range v)) (hw : ⊤ ≤ span R (range w)) (hE : Epi S.g) : ⊤ ≤ span R (range (Sum.elim (S.f ∘ v) (S.g.hom.toFun.invFun ∘ w))) := by refine span_exact hS ?_ hv ?_ · simp only [AddHom.toFun_eq_coe, LinearMap.coe_toAddHom, Sum.elim_comp_inl] · convert hw simp only [AddHom.toFun_eq_coe, LinearMap.coe_toAddHom, Sum.elim_comp_inr] rw [ModuleCat.epi_iff_surjective] at hE rw [← Function.comp_assoc, Function.RightInverse.comp_eq_id (Function.rightInverse_invFun hE), Function.id_comp] end Span /-- In a short exact sequence `0 ⟶ X₁ ⟶ X₂ ⟶ X₃ ⟶ 0`, given bases for `X₁` and `X₃` indexed by `ι` and `ι'` respectively, we get a basis for `X₂` indexed by `ι ⊕ ι'`. -/ noncomputable def Basis.ofShortExact (bN : Basis ι R S.X₁) (bP : Basis ι' R S.X₃) : Basis (ι ⊕ ι') R S.X₂ := Basis.mk (linearIndependent_shortExact hS' bN.linearIndependent bP.linearIndependent) (span_rightExact hS'.exact (le_of_eq (bN.span_eq.symm)) (le_of_eq (bP.span_eq.symm)) hS'.epi_g) include hS' /-- In a short exact sequence `0 ⟶ X₁ ⟶ X₂ ⟶ X₃ ⟶ 0`, if `X₁` and `X₃` are free, then `X₂` is free. -/ theorem free_shortExact [Module.Free R S.X₁] [Module.Free R S.X₃] : Module.Free R S.X₂ := Module.Free.of_basis (Basis.ofShortExact hS' (Module.Free.chooseBasis R S.X₁) (Module.Free.chooseBasis R S.X₃)) theorem free_shortExact_rank_add [Module.Free R S.X₁] [Module.Free R S.X₃] [StrongRankCondition R] : Module.rank R S.X₂ = Module.rank R S.X₁ + Module.rank R S.X₃ := by haveI := free_shortExact hS' rw [Module.Free.rank_eq_card_chooseBasisIndex, Module.Free.rank_eq_card_chooseBasisIndex R S.X₁, Module.Free.rank_eq_card_chooseBasisIndex R S.X₃, Cardinal.add_def, Cardinal.eq] exact ⟨Basis.indexEquiv (Module.Free.chooseBasis R S.X₂) (Basis.ofShortExact hS' (Module.Free.chooseBasis R S.X₁) (Module.Free.chooseBasis R S.X₃))⟩ theorem free_shortExact_finrank_add {n p : ℕ} [Module.Free R S.X₁] [Module.Free R S.X₃] [Module.Finite R S.X₁] [Module.Finite R S.X₃] (hN : Module.finrank R S.X₁ = n) (hP : Module.finrank R S.X₃ = p) [StrongRankCondition R] : finrank R S.X₂ = n + p := by apply finrank_eq_of_rank_eq rw [free_shortExact_rank_add hS', ← hN, ← hP] simp only [Nat.cast_add, finrank_eq_rank] end ModuleCat
Defs.lean
/- Copyright (c) 2014 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro -/ import Mathlib.Data.Int.Cast.Defs import Mathlib.Logic.Basic /-! # Characteristic zero A ring `R` is called of characteristic zero if every natural number `n` is non-zero when considered as an element of `R`. Since this definition doesn't mention the multiplicative structure of `R` except for the existence of `1` in this file characteristic zero is defined for additive monoids with `1`. ## Main definition `CharZero` is the typeclass of an additive monoid with one such that the natural homomorphism from the natural numbers into it is injective. ## TODO * Unify with `CharP` (possibly using an out-parameter) -/ /-- Typeclass for monoids with characteristic zero. (This is usually stated on fields but it makes sense for any additive monoid with 1.) *Warning*: for a semiring `R`, `CharZero R` and `CharP R 0` need not coincide. * `CharZero R` requires an injection `ℕ ↪ R`; * `CharP R 0` asks that only `0 : ℕ` maps to `0 : R` under the map `ℕ → R`. For instance, endowing `{0, 1}` with addition given by `max` (i.e. `1` is absorbing), shows that `CharZero {0, 1}` does not hold and yet `CharP {0, 1} 0` does. This example is formalized in `Counterexamples/CharPZeroNeCharZero.lean`. -/ class CharZero (R) [AddMonoidWithOne R] : Prop where /-- An additive monoid with one has characteristic zero if the canonical map `ℕ → R` is injective. -/ cast_injective : Function.Injective (Nat.cast : ℕ → R) variable {R : Type*} theorem charZero_of_inj_zero [AddGroupWithOne R] (H : ∀ n : ℕ, (n : R) = 0 → n = 0) : CharZero R := ⟨@fun m n h => by induction m generalizing n with | zero => rw [H n]; rw [← h, Nat.cast_zero] | succ m ih => cases n · apply H; rw [h, Nat.cast_zero] · simp only [Nat.cast_succ, add_right_cancel_iff] at h; rwa [ih]⟩ namespace Nat variable [AddMonoidWithOne R] [CharZero R] theorem cast_injective : Function.Injective (Nat.cast : ℕ → R) := CharZero.cast_injective @[simp, norm_cast] theorem cast_inj {m n : ℕ} : (m : R) = n ↔ m = n := cast_injective.eq_iff @[simp, norm_cast] theorem cast_eq_zero {n : ℕ} : (n : R) = 0 ↔ n = 0 := by rw [← cast_zero, cast_inj] @[norm_cast] theorem cast_ne_zero {n : ℕ} : (n : R) ≠ 0 ↔ n ≠ 0 := not_congr cast_eq_zero theorem cast_add_one_ne_zero (n : ℕ) : (n + 1 : R) ≠ 0 := mod_cast n.succ_ne_zero @[simp, norm_cast] theorem cast_eq_one {n : ℕ} : (n : R) = 1 ↔ n = 1 := by rw [← cast_one, cast_inj] @[norm_cast] theorem cast_ne_one {n : ℕ} : (n : R) ≠ 1 ↔ n ≠ 1 := cast_eq_one.not instance (priority := 100) AtLeastTwo.toNeZero (n : ℕ) [n.AtLeastTwo] : NeZero n := ⟨Nat.ne_of_gt (Nat.le_of_lt one_lt)⟩ end Nat namespace OfNat variable [AddMonoidWithOne R] [CharZero R] @[simp] lemma ofNat_ne_zero (n : ℕ) [n.AtLeastTwo] : (ofNat(n) : R) ≠ 0 := Nat.cast_ne_zero.2 (NeZero.ne n) @[simp] lemma zero_ne_ofNat (n : ℕ) [n.AtLeastTwo] : 0 ≠ (ofNat(n) : R) := (ofNat_ne_zero n).symm @[simp] lemma ofNat_ne_one (n : ℕ) [n.AtLeastTwo] : (ofNat(n) : R) ≠ 1 := Nat.cast_ne_one.2 (Nat.AtLeastTwo.ne_one) @[simp] lemma one_ne_ofNat (n : ℕ) [n.AtLeastTwo] : (1 : R) ≠ ofNat(n) := (ofNat_ne_one n).symm @[simp] lemma ofNat_eq_ofNat {m n : ℕ} [m.AtLeastTwo] [n.AtLeastTwo] : (ofNat(m) : R) = ofNat(n) ↔ (ofNat m : ℕ) = ofNat n := Nat.cast_inj end OfNat namespace NeZero instance charZero {M} {n : ℕ} [NeZero n] [AddMonoidWithOne M] [CharZero M] : NeZero (n : M) := ⟨Nat.cast_ne_zero.mpr out⟩ instance charZero_one {M} [AddMonoidWithOne M] [CharZero M] : NeZero (1 : M) where out := by rw [← Nat.cast_one, Nat.cast_ne_zero] trivial instance charZero_ofNat {M} {n : ℕ} [n.AtLeastTwo] [AddMonoidWithOne M] [CharZero M] : NeZero (OfNat.ofNat n : M) := ⟨OfNat.ofNat_ne_zero n⟩ end NeZero
Qq.lean
import Mathlib.Util.Qq import Mathlib.Data.Finset.Basic open Qq Lean Elab Meta section mkSetLiteralQ /-- info: {1, 2, 3} : Finset ℕ -/ #guard_msgs in #check by_elab return mkSetLiteralQ q(Finset ℕ) [q(1), q(2), q(3)] /-- info: {1, 2, 3} : Multiset ℕ -/ #guard_msgs in #check by_elab return mkSetLiteralQ q(Multiset ℕ) [q(1), q(2), q(3)] /-- info: {1, 2, 3} : Set ℕ -/ #guard_msgs in #check by_elab return mkSetLiteralQ q(Set ℕ) [q(1), q(2), q(3)] /-- info: {1, 2, 3} : List ℕ -/ #guard_msgs in #check by_elab return mkSetLiteralQ q(List ℕ) [q(1), q(2), q(3)] /-- info: {0 ^ 2, 1 ^ 2, 2 ^ 2, 3 ^ 2} : Finset ℕ -/ #guard_msgs in #check by_elab return mkSetLiteralQ q(Finset ℕ) (List.range 4 |>.map fun n : ℕ ↦ q($n^2)) end mkSetLiteralQ
Content.lean
/- Copyright (c) 2020 Aaron Anderson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Aaron Anderson -/ import Mathlib.Algebra.GCDMonoid.Finset import Mathlib.Algebra.Polynomial.CancelLeads import Mathlib.Algebra.Polynomial.EraseLead import Mathlib.Algebra.Polynomial.FieldDivision /-! # GCD structures on polynomials Definitions and basic results about polynomials over GCD domains, particularly their contents and primitive polynomials. ## Main Definitions Let `p : R[X]`. - `p.content` is the `gcd` of the coefficients of `p`. - `p.IsPrimitive` indicates that `p.content = 1`. ## Main Results - `Polynomial.content_mul`: if `p q : R[X]`, then `(p * q).content = p.content * q.content`. - `Polynomial.NormalizedGcdMonoid`: the polynomial ring of a GCD domain is itself a GCD domain. ## Note This has nothing to do with minimal polynomials of primitive elements in finite fields. -/ namespace Polynomial section Primitive variable {R : Type*} [CommSemiring R] /-- A polynomial is primitive when the only constant polynomials dividing it are units. Note: This has nothing to do with minimal polynomials of primitive elements in finite fields. -/ def IsPrimitive (p : R[X]) : Prop := ∀ r : R, C r ∣ p → IsUnit r theorem isPrimitive_iff_isUnit_of_C_dvd {p : R[X]} : p.IsPrimitive ↔ ∀ r : R, C r ∣ p → IsUnit r := Iff.rfl @[simp] theorem isPrimitive_one : IsPrimitive (1 : R[X]) := fun _ h => isUnit_C.mp (isUnit_of_dvd_one h) theorem Monic.isPrimitive {p : R[X]} (hp : p.Monic) : p.IsPrimitive := by rintro r ⟨q, h⟩ exact isUnit_of_mul_eq_one r (q.coeff p.natDegree) (by rwa [← coeff_C_mul, ← h]) theorem IsPrimitive.ne_zero [Nontrivial R] {p : R[X]} (hp : p.IsPrimitive) : p ≠ 0 := by rintro rfl exact (hp 0 (dvd_zero (C 0))).ne_zero rfl theorem isPrimitive_of_dvd {p q : R[X]} (hp : IsPrimitive p) (hq : q ∣ p) : IsPrimitive q := fun a ha => isPrimitive_iff_isUnit_of_C_dvd.mp hp a (dvd_trans ha hq) /-- An irreducible nonconstant polynomial over a domain is primitive. -/ theorem _root_.Irreducible.isPrimitive [NoZeroDivisors R] {p : Polynomial R} (hp : Irreducible p) (hp' : p.natDegree ≠ 0) : p.IsPrimitive := by rintro r ⟨q, hq⟩ suffices ¬IsUnit q by simpa using ((hp.2 hq).resolve_right this).map Polynomial.constantCoeff intro H have hr : r ≠ 0 := by rintro rfl; simp_all obtain ⟨s, hs, rfl⟩ := Polynomial.isUnit_iff.mp H simp [hq, Polynomial.natDegree_C_mul hr] at hp' end Primitive variable {R : Type*} [CommRing R] [IsDomain R] section NormalizedGCDMonoid variable [NormalizedGCDMonoid R] /-- `p.content` is the `gcd` of the coefficients of `p`. -/ def content (p : R[X]) : R := p.support.gcd p.coeff theorem content_dvd_coeff {p : R[X]} (n : ℕ) : p.content ∣ p.coeff n := by by_cases h : n ∈ p.support · apply Finset.gcd_dvd h rw [mem_support_iff, Classical.not_not] at h rw [h] apply dvd_zero @[simp] theorem content_C {r : R} : (C r).content = normalize r := by rw [content] by_cases h0 : r = 0 · simp [h0] have h : (C r).support = {0} := support_monomial _ h0 simp [h] @[simp] theorem content_zero : content (0 : R[X]) = 0 := by rw [← C_0, content_C, normalize_zero] @[simp] theorem content_one : content (1 : R[X]) = 1 := by rw [← C_1, content_C, normalize_one] theorem content_X_mul {p : R[X]} : content (X * p) = content p := by rw [content, content, Finset.gcd_def, Finset.gcd_def] refine congr rfl ?_ have h : (X * p).support = p.support.map ⟨Nat.succ, Nat.succ_injective⟩ := by ext a simp only [Finset.mem_map, Function.Embedding.coeFn_mk, Ne, mem_support_iff] rcases a with - | a · simp rw [mul_comm, coeff_mul_X] constructor · intro h use a · rintro ⟨b, ⟨h1, h2⟩⟩ rw [← Nat.succ_injective h2] apply h1 rw [h] simp only [Finset.map_val, Function.comp_apply, Function.Embedding.coeFn_mk, Multiset.map_map] refine congr (congr rfl ?_) rfl ext a rw [mul_comm] simp [coeff_mul_X] @[simp] theorem content_X_pow {k : ℕ} : content ((X : R[X]) ^ k) = 1 := by induction' k with k hi · simp rw [pow_succ', content_X_mul, hi] @[simp] theorem content_X : content (X : R[X]) = 1 := by rw [← mul_one X, content_X_mul, content_one] theorem content_C_mul (r : R) (p : R[X]) : (C r * p).content = normalize r * p.content := by by_cases h0 : r = 0; · simp [h0] rw [content]; rw [content]; rw [← Finset.gcd_mul_left] refine congr (congr rfl ?_) ?_ <;> ext <;> simp [h0, mem_support_iff] @[simp] theorem content_monomial {r : R} {k : ℕ} : content (monomial k r) = normalize r := by rw [← C_mul_X_pow_eq_monomial, content_C_mul, content_X_pow, mul_one] theorem content_eq_zero_iff {p : R[X]} : content p = 0 ↔ p = 0 := by rw [content, Finset.gcd_eq_zero_iff] constructor <;> intro h · ext n by_cases h0 : n ∈ p.support · rw [h n h0, coeff_zero] · rw [mem_support_iff] at h0 push_neg at h0 simp [h0] · intro x simp [h] -- Porting note: this reduced with simp so created `normUnit_content` and put simp on it theorem normalize_content {p : R[X]} : normalize p.content = p.content := Finset.normalize_gcd @[simp] theorem normUnit_content {p : R[X]} : normUnit (content p) = 1 := by by_cases hp0 : p.content = 0 · simp [hp0] · ext apply mul_left_cancel₀ hp0 rw [← normalize_apply, normalize_content, Units.val_one, mul_one] theorem content_eq_gcd_range_of_lt (p : R[X]) (n : ℕ) (h : p.natDegree < n) : p.content = (Finset.range n).gcd p.coeff := by apply dvd_antisymm_of_normalize_eq normalize_content Finset.normalize_gcd · rw [Finset.dvd_gcd_iff] intro i _ apply content_dvd_coeff _ · apply Finset.gcd_mono intro i simp only [mem_support_iff, Ne, Finset.mem_range] contrapose! intro h1 apply coeff_eq_zero_of_natDegree_lt (lt_of_lt_of_le h h1) theorem content_eq_gcd_range_succ (p : R[X]) : p.content = (Finset.range p.natDegree.succ).gcd p.coeff := content_eq_gcd_range_of_lt _ _ (Nat.lt_succ_self _) theorem content_eq_gcd_leadingCoeff_content_eraseLead (p : R[X]) : p.content = GCDMonoid.gcd p.leadingCoeff (eraseLead p).content := by by_cases h : p = 0 · simp [h] rw [← leadingCoeff_eq_zero, leadingCoeff, ← Ne, ← mem_support_iff] at h rw [content, ← Finset.insert_erase h, Finset.gcd_insert, leadingCoeff, content, eraseLead_support] refine congr rfl (Finset.gcd_congr rfl fun i hi => ?_) rw [Finset.mem_erase] at hi rw [eraseLead_coeff, if_neg hi.1] theorem dvd_content_iff_C_dvd {p : R[X]} {r : R} : r ∣ p.content ↔ C r ∣ p := by rw [C_dvd_iff_dvd_coeff] constructor · intro h i apply h.trans (content_dvd_coeff _) · intro h rw [content, Finset.dvd_gcd_iff] intro i _ apply h i theorem C_content_dvd (p : R[X]) : C p.content ∣ p := dvd_content_iff_C_dvd.1 dvd_rfl theorem isPrimitive_iff_content_eq_one {p : R[X]} : p.IsPrimitive ↔ p.content = 1 := by rw [← normalize_content, normalize_eq_one, IsPrimitive] simp_rw [← dvd_content_iff_C_dvd] exact ⟨fun h => h p.content (dvd_refl p.content), fun h r hdvd => isUnit_of_dvd_unit hdvd h⟩ theorem IsPrimitive.content_eq_one {p : R[X]} (hp : p.IsPrimitive) : p.content = 1 := isPrimitive_iff_content_eq_one.mp hp section PrimPart /-- The primitive part of a polynomial `p` is the primitive polynomial gained by dividing `p` by `p.content`. If `p = 0`, then `p.primPart = 1`. -/ noncomputable def primPart (p : R[X]) : R[X] := letI := Classical.decEq R if p = 0 then 1 else Classical.choose (C_content_dvd p) theorem eq_C_content_mul_primPart (p : R[X]) : p = C p.content * p.primPart := by by_cases h : p = 0; · simp [h] rw [primPart, if_neg h, ← Classical.choose_spec (C_content_dvd p)] @[simp] theorem primPart_zero : primPart (0 : R[X]) = 1 := if_pos rfl theorem isPrimitive_primPart (p : R[X]) : p.primPart.IsPrimitive := by by_cases h : p = 0; · simp [h] rw [← content_eq_zero_iff] at h rw [isPrimitive_iff_content_eq_one] apply mul_left_cancel₀ h conv_rhs => rw [p.eq_C_content_mul_primPart, mul_one, content_C_mul, normalize_content] theorem content_primPart (p : R[X]) : p.primPart.content = 1 := p.isPrimitive_primPart.content_eq_one theorem primPart_ne_zero (p : R[X]) : p.primPart ≠ 0 := p.isPrimitive_primPart.ne_zero theorem natDegree_primPart (p : R[X]) : p.primPart.natDegree = p.natDegree := by by_cases h : C p.content = 0 · rw [C_eq_zero, content_eq_zero_iff] at h simp [h] conv_rhs => rw [p.eq_C_content_mul_primPart, natDegree_mul h p.primPart_ne_zero, natDegree_C, zero_add] @[simp] theorem IsPrimitive.primPart_eq {p : R[X]} (hp : p.IsPrimitive) : p.primPart = p := by rw [← one_mul p.primPart, ← C_1, ← hp.content_eq_one, ← p.eq_C_content_mul_primPart] theorem isUnit_primPart_C (r : R) : IsUnit (C r).primPart := by by_cases h0 : r = 0 · simp [h0] unfold IsUnit refine ⟨⟨C ↑(normUnit r)⁻¹, C ↑(normUnit r), by rw [← RingHom.map_mul, Units.inv_mul, C_1], by rw [← RingHom.map_mul, Units.mul_inv, C_1]⟩, ?_⟩ rw [← normalize_eq_zero, ← C_eq_zero] at h0 apply mul_left_cancel₀ h0 conv_rhs => rw [← content_C, ← (C r).eq_C_content_mul_primPart] simp only [normalize_apply, RingHom.map_mul] rw [mul_assoc, ← RingHom.map_mul, Units.mul_inv, C_1, mul_one] theorem primPart_dvd (p : R[X]) : p.primPart ∣ p := Dvd.intro_left (C p.content) p.eq_C_content_mul_primPart.symm theorem aeval_primPart_eq_zero {S : Type*} [Ring S] [IsDomain S] [Algebra R S] [NoZeroSMulDivisors R S] {p : R[X]} {s : S} (hpzero : p ≠ 0) (hp : aeval s p = 0) : aeval s p.primPart = 0 := by rw [eq_C_content_mul_primPart p, map_mul, aeval_C] at hp have hcont : p.content ≠ 0 := fun h => hpzero (content_eq_zero_iff.1 h) replace hcont := Function.Injective.ne (FaithfulSMul.algebraMap_injective R S) hcont rw [map_zero] at hcont exact eq_zero_of_ne_zero_of_mul_left_eq_zero hcont hp theorem eval₂_primPart_eq_zero {S : Type*} [CommSemiring S] [IsDomain S] {f : R →+* S} (hinj : Function.Injective f) {p : R[X]} {s : S} (hpzero : p ≠ 0) (hp : eval₂ f s p = 0) : eval₂ f s p.primPart = 0 := by rw [eq_C_content_mul_primPart p, eval₂_mul, eval₂_C] at hp have hcont : p.content ≠ 0 := fun h => hpzero (content_eq_zero_iff.1 h) replace hcont := Function.Injective.ne hinj hcont rw [map_zero] at hcont exact eq_zero_of_ne_zero_of_mul_left_eq_zero hcont hp end PrimPart theorem gcd_content_eq_of_dvd_sub {a : R} {p q : R[X]} (h : C a ∣ p - q) : GCDMonoid.gcd a p.content = GCDMonoid.gcd a q.content := by rw [content_eq_gcd_range_of_lt p (max p.natDegree q.natDegree).succ (lt_of_le_of_lt (le_max_left _ _) (Nat.lt_succ_self _))] rw [content_eq_gcd_range_of_lt q (max p.natDegree q.natDegree).succ (lt_of_le_of_lt (le_max_right _ _) (Nat.lt_succ_self _))] apply Finset.gcd_eq_of_dvd_sub intro x _ obtain ⟨w, hw⟩ := h use w.coeff x rw [← coeff_sub, hw, coeff_C_mul] theorem content_mul_aux {p q : R[X]} : GCDMonoid.gcd (p * q).eraseLead.content p.leadingCoeff = GCDMonoid.gcd (p.eraseLead * q).content p.leadingCoeff := by rw [gcd_comm (content _) _, gcd_comm (content _) _] apply gcd_content_eq_of_dvd_sub rw [← self_sub_C_mul_X_pow, ← self_sub_C_mul_X_pow, sub_mul, sub_sub, add_comm, sub_add, sub_sub_cancel, leadingCoeff_mul, RingHom.map_mul, mul_assoc, mul_assoc] apply dvd_sub (Dvd.intro _ rfl) (Dvd.intro _ rfl) @[simp] theorem content_mul {p q : R[X]} : (p * q).content = p.content * q.content := by classical suffices h : ∀ (n : ℕ) (p q : R[X]), (p * q).degree < n → (p * q).content = p.content * q.content by apply h apply lt_of_le_of_lt degree_le_natDegree (WithBot.coe_lt_coe.2 (Nat.lt_succ_self _)) intro n induction' n with n ih · intro p q hpq rw [Nat.cast_zero, Nat.WithBot.lt_zero_iff, degree_eq_bot, mul_eq_zero] at hpq rcases hpq with (rfl | rfl) <;> simp intro p q hpq by_cases p0 : p = 0 · simp [p0] by_cases q0 : q = 0 · simp [q0] rw [degree_eq_natDegree (mul_ne_zero p0 q0), Nat.cast_lt, Nat.lt_succ_iff_lt_or_eq, ← Nat.cast_lt (α := WithBot ℕ), ← degree_eq_natDegree (mul_ne_zero p0 q0), natDegree_mul p0 q0] at hpq rcases hpq with (hlt | heq) · apply ih _ _ hlt rw [← p.natDegree_primPart, ← q.natDegree_primPart, ← Nat.cast_inj (R := WithBot ℕ), Nat.cast_add, ← degree_eq_natDegree p.primPart_ne_zero, ← degree_eq_natDegree q.primPart_ne_zero] at heq rw [p.eq_C_content_mul_primPart, q.eq_C_content_mul_primPart] suffices h : (q.primPart * p.primPart).content = 1 by rw [mul_assoc, content_C_mul, content_C_mul, mul_comm p.primPart, mul_assoc, content_C_mul, content_C_mul, h, mul_one, content_primPart, content_primPart, mul_one, mul_one] rw [← normalize_content, normalize_eq_one, isUnit_iff_dvd_one, content_eq_gcd_leadingCoeff_content_eraseLead, leadingCoeff_mul, gcd_comm] apply (gcd_mul_dvd_mul_gcd _ _ _).trans rw [content_mul_aux, ih, content_primPart, mul_one, gcd_comm, ← content_eq_gcd_leadingCoeff_content_eraseLead, content_primPart, one_mul, mul_comm q.primPart, content_mul_aux, ih, content_primPart, mul_one, gcd_comm, ← content_eq_gcd_leadingCoeff_content_eraseLead, content_primPart] · rw [← heq, degree_mul, WithBot.add_lt_add_iff_right] · apply degree_erase_lt p.primPart_ne_zero · rw [Ne, degree_eq_bot] apply q.primPart_ne_zero · rw [mul_comm, ← heq, degree_mul, WithBot.add_lt_add_iff_left] · apply degree_erase_lt q.primPart_ne_zero · rw [Ne, degree_eq_bot] apply p.primPart_ne_zero theorem IsPrimitive.mul {p q : R[X]} (hp : p.IsPrimitive) (hq : q.IsPrimitive) : (p * q).IsPrimitive := by rw [isPrimitive_iff_content_eq_one, content_mul, hp.content_eq_one, hq.content_eq_one, mul_one] @[simp] theorem primPart_mul {p q : R[X]} (h0 : p * q ≠ 0) : (p * q).primPart = p.primPart * q.primPart := by rw [Ne, ← content_eq_zero_iff, ← C_eq_zero] at h0 apply mul_left_cancel₀ h0 conv_lhs => rw [← (p * q).eq_C_content_mul_primPart, p.eq_C_content_mul_primPart, q.eq_C_content_mul_primPart] rw [content_mul, RingHom.map_mul] ring theorem IsPrimitive.dvd_primPart_iff_dvd {p q : R[X]} (hp : p.IsPrimitive) (hq : q ≠ 0) : p ∣ q.primPart ↔ p ∣ q := by refine ⟨fun h => h.trans (Dvd.intro_left _ q.eq_C_content_mul_primPart.symm), fun h => ?_⟩ rcases h with ⟨r, rfl⟩ apply Dvd.intro _ rw [primPart_mul hq, hp.primPart_eq] theorem exists_primitive_lcm_of_isPrimitive {p q : R[X]} (hp : p.IsPrimitive) (hq : q.IsPrimitive) : ∃ r : R[X], r.IsPrimitive ∧ ∀ s : R[X], p ∣ s ∧ q ∣ s ↔ r ∣ s := by classical have h : ∃ (n : ℕ) (r : R[X]), r.natDegree = n ∧ r.IsPrimitive ∧ p ∣ r ∧ q ∣ r := ⟨(p * q).natDegree, p * q, rfl, hp.mul hq, dvd_mul_right _ _, dvd_mul_left _ _⟩ rcases Nat.find_spec h with ⟨r, rdeg, rprim, pr, qr⟩ refine ⟨r, rprim, fun s => ⟨?_, fun rs => ⟨pr.trans rs, qr.trans rs⟩⟩⟩ suffices hs : ∀ (n : ℕ) (s : R[X]), s.natDegree = n → p ∣ s ∧ q ∣ s → r ∣ s from hs s.natDegree s rfl clear s by_contra! con rcases Nat.find_spec con with ⟨s, sdeg, ⟨ps, qs⟩, rs⟩ have s0 : s ≠ 0 := by contrapose! rs simp [rs] have hs := Nat.find_min' h ⟨_, s.natDegree_primPart, s.isPrimitive_primPart, (hp.dvd_primPart_iff_dvd s0).2 ps, (hq.dvd_primPart_iff_dvd s0).2 qs⟩ rw [← rdeg] at hs by_cases sC : s.natDegree ≤ 0 · rw [eq_C_of_natDegree_le_zero (le_trans hs sC), isPrimitive_iff_content_eq_one, content_C, normalize_eq_one] at rprim rw [eq_C_of_natDegree_le_zero (le_trans hs sC), ← dvd_content_iff_C_dvd] at rs apply rs rprim.dvd have hcancel := natDegree_cancelLeads_lt_of_natDegree_le_natDegree hs (lt_of_not_ge sC) rw [sdeg] at hcancel apply Nat.find_min con hcancel refine ⟨_, rfl, ⟨dvd_cancelLeads_of_dvd_of_dvd pr ps, dvd_cancelLeads_of_dvd_of_dvd qr qs⟩, fun rcs => rs ?_⟩ rw [← rprim.dvd_primPart_iff_dvd s0] rw [cancelLeads, tsub_eq_zero_iff_le.mpr hs, pow_zero, mul_one] at rcs have h := dvd_add rcs (Dvd.intro_left (C (leadingCoeff s) * X ^ (natDegree s - natDegree r)) rfl) have hC0 := rprim.ne_zero rw [Ne, ← leadingCoeff_eq_zero, ← C_eq_zero] at hC0 rw [sub_add_cancel, ← rprim.dvd_primPart_iff_dvd (mul_ne_zero hC0 s0)] at h rcases isUnit_primPart_C r.leadingCoeff with ⟨u, hu⟩ apply h.trans (Associated.symm ⟨u, _⟩).dvd rw [primPart_mul (mul_ne_zero hC0 s0), hu, mul_comm] theorem dvd_iff_content_dvd_content_and_primPart_dvd_primPart {p q : R[X]} (hq : q ≠ 0) : p ∣ q ↔ p.content ∣ q.content ∧ p.primPart ∣ q.primPart := by constructor · rintro ⟨r, rfl⟩ rw [content_mul, p.isPrimitive_primPart.dvd_primPart_iff_dvd hq] exact ⟨dvd_mul_right .., dvd_mul_of_dvd_left p.primPart_dvd _⟩ · rintro ⟨h₁, h₂⟩ rw [p.eq_C_content_mul_primPart, q.eq_C_content_mul_primPart] gcongr noncomputable instance (priority := 100) normalizedGcdMonoid : NormalizedGCDMonoid R[X] := letI := Classical.decEq R normalizedGCDMonoidOfExistsLCM fun p q => by rcases exists_primitive_lcm_of_isPrimitive p.isPrimitive_primPart q.isPrimitive_primPart with ⟨r, rprim, hr⟩ refine ⟨C (lcm p.content q.content) * r, fun s => ?_⟩ by_cases hs : s = 0 · simp [hs] by_cases hpq : C (lcm p.content q.content) = 0 · rw [C_eq_zero, lcm_eq_zero_iff, content_eq_zero_iff, content_eq_zero_iff] at hpq rcases hpq with (hpq | hpq) <;> simp [hpq, hs] iterate 3 rw [dvd_iff_content_dvd_content_and_primPart_dvd_primPart hs] rw [content_mul, rprim.content_eq_one, mul_one, content_C, normalize_lcm, lcm_dvd_iff, primPart_mul (mul_ne_zero hpq rprim.ne_zero), rprim.primPart_eq, (isUnit_primPart_C (lcm p.content q.content)).mul_left_dvd, ← hr s.primPart] tauto theorem degree_gcd_le_left {p : R[X]} (hp : p ≠ 0) (q) : (gcd p q).degree ≤ p.degree := by have := natDegree_le_iff_degree_le.mp (natDegree_le_of_dvd (gcd_dvd_left p q) hp) rwa [degree_eq_natDegree hp] theorem degree_gcd_le_right (p) {q : R[X]} (hq : q ≠ 0) : (gcd p q).degree ≤ q.degree := by rw [gcd_comm] exact degree_gcd_le_left hq p end NormalizedGCDMonoid end Polynomial
Group.lean
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Patrick Massot, Yury Kudryashov, Rémy Degenne -/ import Mathlib.Algebra.Order.Group.Abs import Mathlib.Algebra.Order.Group.Basic import Mathlib.Algebra.Order.Ring.Defs import Mathlib.Data.Int.Cast.Basic import Mathlib.Order.Interval.Set.Basic import Mathlib.Logic.Pairwise /-! ### Lemmas about arithmetic operations and intervals. -/ variable {α : Type*} namespace Set section OrderedCommGroup variable [CommGroup α] [PartialOrder α] [IsOrderedMonoid α] {a c d : α} /-! `inv_mem_Ixx_iff`, `sub_mem_Ixx_iff` -/ @[to_additive] theorem inv_mem_Icc_iff : a⁻¹ ∈ Set.Icc c d ↔ a ∈ Set.Icc d⁻¹ c⁻¹ := and_comm.trans <| and_congr inv_le' le_inv' @[to_additive] theorem inv_mem_Ico_iff : a⁻¹ ∈ Set.Ico c d ↔ a ∈ Set.Ioc d⁻¹ c⁻¹ := and_comm.trans <| and_congr inv_lt' le_inv' @[to_additive] theorem inv_mem_Ioc_iff : a⁻¹ ∈ Set.Ioc c d ↔ a ∈ Set.Ico d⁻¹ c⁻¹ := and_comm.trans <| and_congr inv_le' lt_inv' @[to_additive] theorem inv_mem_Ioo_iff : a⁻¹ ∈ Set.Ioo c d ↔ a ∈ Set.Ioo d⁻¹ c⁻¹ := and_comm.trans <| and_congr inv_lt' lt_inv' end OrderedCommGroup section OrderedAddCommGroup variable [AddCommGroup α] [PartialOrder α] [IsOrderedAddMonoid α] {a b c d : α} /-! `add_mem_Ixx_iff_left` -/ theorem add_mem_Icc_iff_left : a + b ∈ Set.Icc c d ↔ a ∈ Set.Icc (c - b) (d - b) := (and_congr sub_le_iff_le_add le_sub_iff_add_le).symm theorem add_mem_Ico_iff_left : a + b ∈ Set.Ico c d ↔ a ∈ Set.Ico (c - b) (d - b) := (and_congr sub_le_iff_le_add lt_sub_iff_add_lt).symm theorem add_mem_Ioc_iff_left : a + b ∈ Set.Ioc c d ↔ a ∈ Set.Ioc (c - b) (d - b) := (and_congr sub_lt_iff_lt_add le_sub_iff_add_le).symm theorem add_mem_Ioo_iff_left : a + b ∈ Set.Ioo c d ↔ a ∈ Set.Ioo (c - b) (d - b) := (and_congr sub_lt_iff_lt_add lt_sub_iff_add_lt).symm /-! `add_mem_Ixx_iff_right` -/ theorem add_mem_Icc_iff_right : a + b ∈ Set.Icc c d ↔ b ∈ Set.Icc (c - a) (d - a) := (and_congr sub_le_iff_le_add' le_sub_iff_add_le').symm theorem add_mem_Ico_iff_right : a + b ∈ Set.Ico c d ↔ b ∈ Set.Ico (c - a) (d - a) := (and_congr sub_le_iff_le_add' lt_sub_iff_add_lt').symm theorem add_mem_Ioc_iff_right : a + b ∈ Set.Ioc c d ↔ b ∈ Set.Ioc (c - a) (d - a) := (and_congr sub_lt_iff_lt_add' le_sub_iff_add_le').symm theorem add_mem_Ioo_iff_right : a + b ∈ Set.Ioo c d ↔ b ∈ Set.Ioo (c - a) (d - a) := (and_congr sub_lt_iff_lt_add' lt_sub_iff_add_lt').symm /-! `sub_mem_Ixx_iff_left` -/ theorem sub_mem_Icc_iff_left : a - b ∈ Set.Icc c d ↔ a ∈ Set.Icc (c + b) (d + b) := and_congr le_sub_iff_add_le sub_le_iff_le_add theorem sub_mem_Ico_iff_left : a - b ∈ Set.Ico c d ↔ a ∈ Set.Ico (c + b) (d + b) := and_congr le_sub_iff_add_le sub_lt_iff_lt_add theorem sub_mem_Ioc_iff_left : a - b ∈ Set.Ioc c d ↔ a ∈ Set.Ioc (c + b) (d + b) := and_congr lt_sub_iff_add_lt sub_le_iff_le_add theorem sub_mem_Ioo_iff_left : a - b ∈ Set.Ioo c d ↔ a ∈ Set.Ioo (c + b) (d + b) := and_congr lt_sub_iff_add_lt sub_lt_iff_lt_add /-! `sub_mem_Ixx_iff_right` -/ theorem sub_mem_Icc_iff_right : a - b ∈ Set.Icc c d ↔ b ∈ Set.Icc (a - d) (a - c) := and_comm.trans <| and_congr sub_le_comm le_sub_comm theorem sub_mem_Ico_iff_right : a - b ∈ Set.Ico c d ↔ b ∈ Set.Ioc (a - d) (a - c) := and_comm.trans <| and_congr sub_lt_comm le_sub_comm theorem sub_mem_Ioc_iff_right : a - b ∈ Set.Ioc c d ↔ b ∈ Set.Ico (a - d) (a - c) := and_comm.trans <| and_congr sub_le_comm lt_sub_comm theorem sub_mem_Ioo_iff_right : a - b ∈ Set.Ioo c d ↔ b ∈ Set.Ioo (a - d) (a - c) := and_comm.trans <| and_congr sub_lt_comm lt_sub_comm -- I think that symmetric intervals deserve attention and API: they arise all the time, -- for instance when considering metric balls in `ℝ`. theorem mem_Icc_iff_abs_le {R : Type*} [AddCommGroup R] [LinearOrder R] [IsOrderedAddMonoid R] {x y z : R} : |x - y| ≤ z ↔ y ∈ Icc (x - z) (x + z) := abs_le.trans <| and_comm.trans <| and_congr sub_le_comm neg_le_sub_iff_le_add /-! `sub_mem_Ixx_zero_right` and `sub_mem_Ixx_zero_iff_right`; this specializes the previous lemmas to the case of reflecting the interval. -/ theorem sub_mem_Icc_zero_iff_right : b - a ∈ Icc 0 b ↔ a ∈ Icc 0 b := by simp only [sub_mem_Icc_iff_right, sub_self, sub_zero] theorem sub_mem_Ico_zero_iff_right : b - a ∈ Ico 0 b ↔ a ∈ Ioc 0 b := by simp only [sub_mem_Ico_iff_right, sub_self, sub_zero] theorem sub_mem_Ioc_zero_iff_right : b - a ∈ Ioc 0 b ↔ a ∈ Ico 0 b := by simp only [sub_mem_Ioc_iff_right, sub_self, sub_zero] theorem sub_mem_Ioo_zero_iff_right : b - a ∈ Ioo 0 b ↔ a ∈ Ioo 0 b := by simp only [sub_mem_Ioo_iff_right, sub_self, sub_zero] end OrderedAddCommGroup section LinearOrderedAddCommGroup variable [AddCommGroup α] [LinearOrder α] [IsOrderedAddMonoid α] /-- If we remove a smaller interval from a larger, the result is nonempty -/ theorem nonempty_Ico_sdiff {x dx y dy : α} (h : dy < dx) (hx : 0 < dx) : Nonempty ↑(Ico x (x + dx) \ Ico y (y + dy)) := by rcases lt_or_ge x y with h' | h' · use x simp [*, not_le.2 h'] · use max x (x + dy) simp [*] end LinearOrderedAddCommGroup /-! ### Lemmas about disjointness of translates of intervals -/ open scoped Function -- required for scoped `on` notation section PairwiseDisjoint section OrderedCommGroup variable [CommGroup α] [PartialOrder α] [IsOrderedMonoid α] (a b : α) @[to_additive] theorem pairwise_disjoint_Ioc_mul_zpow : Pairwise (Disjoint on fun n : ℤ => Ioc (a * b ^ n) (a * b ^ (n + 1))) := by simp +unfoldPartialApp only [Function.onFun] simp_rw [Set.disjoint_iff] intro m n hmn x hx apply hmn have hb : 1 < b := by have : a * b ^ m < a * b ^ (m + 1) := hx.1.1.trans_le hx.1.2 rwa [mul_lt_mul_iff_left, ← mul_one (b ^ m), zpow_add_one, mul_lt_mul_iff_left] at this have i1 := hx.1.1.trans_le hx.2.2 have i2 := hx.2.1.trans_le hx.1.2 rw [mul_lt_mul_iff_left, zpow_lt_zpow_iff_right hb, Int.lt_add_one_iff] at i1 i2 exact le_antisymm i1 i2 @[to_additive] theorem pairwise_disjoint_Ico_mul_zpow : Pairwise (Disjoint on fun n : ℤ => Ico (a * b ^ n) (a * b ^ (n + 1))) := by simp +unfoldPartialApp only [Function.onFun] simp_rw [Set.disjoint_iff] intro m n hmn x hx apply hmn have hb : 1 < b := by have : a * b ^ m < a * b ^ (m + 1) := hx.1.1.trans_lt hx.1.2 rwa [mul_lt_mul_iff_left, ← mul_one (b ^ m), zpow_add_one, mul_lt_mul_iff_left] at this have i1 := hx.1.1.trans_lt hx.2.2 have i2 := hx.2.1.trans_lt hx.1.2 rw [mul_lt_mul_iff_left, zpow_lt_zpow_iff_right hb, Int.lt_add_one_iff] at i1 i2 exact le_antisymm i1 i2 @[to_additive] theorem pairwise_disjoint_Ioo_mul_zpow : Pairwise (Disjoint on fun n : ℤ => Ioo (a * b ^ n) (a * b ^ (n + 1))) := fun _ _ hmn => (pairwise_disjoint_Ioc_mul_zpow a b hmn).mono Ioo_subset_Ioc_self Ioo_subset_Ioc_self @[to_additive] theorem pairwise_disjoint_Ioc_zpow : Pairwise (Disjoint on fun n : ℤ => Ioc (b ^ n) (b ^ (n + 1))) := by simpa only [one_mul] using pairwise_disjoint_Ioc_mul_zpow 1 b @[to_additive] theorem pairwise_disjoint_Ico_zpow : Pairwise (Disjoint on fun n : ℤ => Ico (b ^ n) (b ^ (n + 1))) := by simpa only [one_mul] using pairwise_disjoint_Ico_mul_zpow 1 b @[to_additive] theorem pairwise_disjoint_Ioo_zpow : Pairwise (Disjoint on fun n : ℤ => Ioo (b ^ n) (b ^ (n + 1))) := by simpa only [one_mul] using pairwise_disjoint_Ioo_mul_zpow 1 b end OrderedCommGroup section OrderedRing variable [Ring α] [PartialOrder α] [IsOrderedRing α] (a : α) theorem pairwise_disjoint_Ioc_add_intCast : Pairwise (Disjoint on fun n : ℤ => Ioc (a + n) (a + n + 1)) := by simpa only [zsmul_one, Int.cast_add, Int.cast_one, ← add_assoc] using pairwise_disjoint_Ioc_add_zsmul a (1 : α) theorem pairwise_disjoint_Ico_add_intCast : Pairwise (Disjoint on fun n : ℤ => Ico (a + n) (a + n + 1)) := by simpa only [zsmul_one, Int.cast_add, Int.cast_one, ← add_assoc] using pairwise_disjoint_Ico_add_zsmul a (1 : α) theorem pairwise_disjoint_Ioo_add_intCast : Pairwise (Disjoint on fun n : ℤ => Ioo (a + n) (a + n + 1)) := by simpa only [zsmul_one, Int.cast_add, Int.cast_one, ← add_assoc] using pairwise_disjoint_Ioo_add_zsmul a (1 : α) variable (α) theorem pairwise_disjoint_Ico_intCast : Pairwise (Disjoint on fun n : ℤ => Ico (n : α) (n + 1)) := by simpa only [zero_add] using pairwise_disjoint_Ico_add_intCast (0 : α) theorem pairwise_disjoint_Ioo_intCast : Pairwise (Disjoint on fun n : ℤ => Ioo (n : α) (n + 1)) := by simpa only [zero_add] using pairwise_disjoint_Ioo_add_intCast (0 : α) theorem pairwise_disjoint_Ioc_intCast : Pairwise (Disjoint on fun n : ℤ => Ioc (n : α) (n + 1)) := by simpa only [zero_add] using pairwise_disjoint_Ioc_add_intCast (0 : α) end OrderedRing end PairwiseDisjoint end Set
AddCircle.lean
/- Copyright (c) 2022 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Analysis.Normed.Group.Quotient import Mathlib.Analysis.NormedSpace.Pointwise import Mathlib.Topology.Instances.AddCircle.Real /-! # The additive circle as a normed group We define the normed group structure on `AddCircle p`, for `p : ℝ`. For example if `p = 1` then: `‖(x : AddCircle 1)‖ = |x - round x|` for any `x : ℝ` (see `UnitAddCircle.norm_eq`). ## Main definitions: * `AddCircle.norm_eq`: a characterisation of the norm on `AddCircle p` ## TODO * The fact `InnerProductGeometry.angle (Real.cos θ) (Real.sin θ) = ‖(θ : Real.Angle)‖` -/ noncomputable section open Metric QuotientAddGroup Set open Int hiding mem_zmultiples_iff open AddSubgroup namespace AddCircle variable (p : ℝ) instance : NormedAddCommGroup (AddCircle p) := QuotientAddGroup.instNormedAddCommGroup _ @[simp] theorem norm_coe_mul (x : ℝ) (t : ℝ) : ‖(↑(t * x) : AddCircle (t * p))‖ = |t| * ‖(x : AddCircle p)‖ := by obtain rfl | ht := eq_or_ne t 0 · simp simp only [norm_eq_infDist, ← Real.norm_eq_abs, ← infDist_smul₀ ht, smul_zero] congr 1 with m simp_rw [zmultiples, eq_iff_sub_mem, zsmul_eq_mul, mul_left_comm, ← smul_eq_mul, Set.range_smul] simp [mem_smul_set_iff_inv_smul_mem₀ ht, mul_sub, ht] theorem norm_neg_period (x : ℝ) : ‖(x : AddCircle (-p))‖ = ‖(x : AddCircle p)‖ := by suffices ‖(↑(-1 * x) : AddCircle (-1 * p))‖ = ‖(x : AddCircle p)‖ by rw [← this, neg_one_mul] simp simp only [norm_coe_mul, abs_neg, abs_one, one_mul] @[simp] theorem norm_eq_of_zero {x : ℝ} : ‖(x : AddCircle (0 : ℝ))‖ = |x| := by suffices { y : ℝ | (y : AddCircle (0 : ℝ)) = (x : AddCircle (0 : ℝ)) } = {x} by simp [norm_eq_infDist, this] ext y simp [eq_iff_sub_mem, sub_eq_zero] theorem norm_eq {x : ℝ} : ‖(x : AddCircle p)‖ = |x - round (p⁻¹ * x) * p| := by suffices ∀ x : ℝ, ‖(x : AddCircle (1 : ℝ))‖ = |x - round x| by rcases eq_or_ne p 0 with (rfl | hp) · simp have hx := norm_coe_mul p x p⁻¹ rw [abs_inv, eq_inv_mul_iff_mul_eq₀ ((not_congr abs_eq_zero).mpr hp)] at hx rw [← hx, inv_mul_cancel₀ hp, this, ← abs_mul, mul_sub, mul_inv_cancel_left₀ hp, mul_comm p] clear! x p intros x simp only [le_antisymm_iff, le_norm_iff, Real.norm_eq_abs] refine ⟨le_of_forall_le fun r hr ↦ ?_, ?_⟩ · rw [abs_sub_round_eq_min, le_inf_iff] rw [le_norm_iff] at hr constructor · simpa [abs_of_nonneg] using hr (fract x) · simpa [abs_sub_comm (fract x)] using hr (fract x - 1) (by simp [← self_sub_floor, ← sub_eq_zero, sub_sub]; simp) · simpa [zmultiples, QuotientAddGroup.eq, zsmul_eq_mul, mul_one, mem_mk, mem_range, and_imp, forall_exists_index, eq_neg_add_iff_add_eq, ← eq_sub_iff_add_eq, forall_swap (α := ℕ)] using round_le _ theorem norm_eq' (hp : 0 < p) {x : ℝ} : ‖(x : AddCircle p)‖ = p * |p⁻¹ * x - round (p⁻¹ * x)| := by conv_rhs => congr rw [← abs_eq_self.mpr hp.le] rw [← abs_mul, mul_sub, mul_inv_cancel_left₀ hp.ne.symm, norm_eq, mul_comm p] theorem norm_le_half_period {x : AddCircle p} (hp : p ≠ 0) : ‖x‖ ≤ |p| / 2 := by obtain ⟨x⟩ := x change ‖(x : AddCircle p)‖ ≤ |p| / 2 rw [norm_eq, ← mul_le_mul_left (abs_pos.mpr (inv_ne_zero hp)), ← abs_mul, mul_sub, mul_left_comm, ← mul_div_assoc, ← abs_mul, inv_mul_cancel₀ hp, mul_one, abs_one] exact abs_sub_round (p⁻¹ * x) @[simp] theorem norm_half_period_eq : ‖(↑(p / 2) : AddCircle p)‖ = |p| / 2 := by rcases eq_or_ne p 0 with (rfl | hp); · simp rw [norm_eq, ← mul_div_assoc, inv_mul_cancel₀ hp, one_div, round_two_inv, Int.cast_one, one_mul, (by linarith : p / 2 - p = -(p / 2)), abs_neg, abs_div, abs_two] theorem norm_coe_eq_abs_iff {x : ℝ} (hp : p ≠ 0) : ‖(x : AddCircle p)‖ = |x| ↔ |x| ≤ |p| / 2 := by refine ⟨fun hx => hx ▸ norm_le_half_period p hp, fun hx => ?_⟩ suffices ∀ p : ℝ, 0 < p → |x| ≤ p / 2 → ‖(x : AddCircle p)‖ = |x| by rcases hp.symm.lt_or_gt with (hp | hp) · rw [abs_eq_self.mpr hp.le] at hx exact this p hp hx · rw [← norm_neg_period] rw [abs_eq_neg_self.mpr hp.le] at hx exact this (-p) (neg_pos.mpr hp) hx clear hx intro p hp hx rcases eq_or_ne x (p / (2 : ℝ)) with (rfl | hx') · simp [abs_div] suffices round (p⁻¹ * x) = 0 by simp [norm_eq, this] rw [round_eq_zero_iff] obtain ⟨hx₁, hx₂⟩ := abs_le.mp hx replace hx₂ := Ne.lt_of_le hx' hx₂ constructor · rwa [← mul_le_mul_left hp, ← mul_assoc, mul_inv_cancel₀ hp.ne.symm, one_mul, mul_neg, ← mul_div_assoc, mul_one] · rwa [← mul_lt_mul_left hp, ← mul_assoc, mul_inv_cancel₀ hp.ne.symm, one_mul, ← mul_div_assoc, mul_one] open Metric theorem closedBall_eq_univ_of_half_period_le (hp : p ≠ 0) (x : AddCircle p) {ε : ℝ} (hε : |p| / 2 ≤ ε) : closedBall x ε = univ := eq_univ_iff_forall.mpr fun x => by simpa only [mem_closedBall, dist_eq_norm] using (norm_le_half_period p hp).trans hε @[simp] theorem coe_real_preimage_closedBall_period_zero (x ε : ℝ) : (↑) ⁻¹' closedBall (x : AddCircle (0 : ℝ)) ε = closedBall x ε := by ext y simp [dist_eq_norm, ← QuotientAddGroup.mk_sub] theorem coe_real_preimage_closedBall_eq_iUnion (x ε : ℝ) : (↑) ⁻¹' closedBall (x : AddCircle p) ε = ⋃ z : ℤ, closedBall (x + z • p) ε := by rcases eq_or_ne p 0 with (rfl | hp) · simp [iUnion_const] ext y simp only [dist_eq_norm, mem_preimage, mem_closedBall, zsmul_eq_mul, mem_iUnion, Real.norm_eq_abs, ← QuotientAddGroup.mk_sub, norm_eq, ← sub_sub] refine ⟨fun h => ⟨round (p⁻¹ * (y - x)), h⟩, ?_⟩ rintro ⟨n, hn⟩ rw [← mul_le_mul_left (abs_pos.mpr <| inv_ne_zero hp), ← abs_mul, mul_sub, mul_comm _ p, inv_mul_cancel_left₀ hp] at hn ⊢ exact (round_le (p⁻¹ * (y - x)) n).trans hn theorem coe_real_preimage_closedBall_inter_eq {x ε : ℝ} (s : Set ℝ) (hs : s ⊆ closedBall x (|p| / 2)) : (↑) ⁻¹' closedBall (x : AddCircle p) ε ∩ s = if ε < |p| / 2 then closedBall x ε ∩ s else s := by rcases le_or_gt (|p| / 2) ε with hε | hε · rcases eq_or_ne p 0 with (rfl | hp) · simp only [abs_zero, zero_div] at hε simp only [not_lt.mpr hε, coe_real_preimage_closedBall_period_zero, abs_zero, zero_div, if_false, inter_eq_right] exact hs.trans (closedBall_subset_closedBall <| by simp [hε]) simp [closedBall_eq_univ_of_half_period_le p hp (↑x) hε, not_lt.mpr hε] · suffices ∀ z : ℤ, closedBall (x + z • p) ε ∩ s = if z = 0 then closedBall x ε ∩ s else ∅ by simp [-zsmul_eq_mul, coe_real_preimage_closedBall_eq_iUnion, iUnion_inter, iUnion_ite, this, hε] intro z simp only [Real.closedBall_eq_Icc] at hs ⊢ rcases eq_or_ne z 0 with (rfl | hz) · simp simp only [hz, zsmul_eq_mul, if_false, eq_empty_iff_forall_notMem] rintro y ⟨⟨hy₁, hy₂⟩, hy₀⟩ obtain ⟨hy₃, hy₄⟩ := hs hy₀ rcases lt_trichotomy 0 p with (hp | (rfl : 0 = p) | hp) · rcases Int.cast_le_neg_one_or_one_le_cast_of_ne_zero ℝ hz with hz' | hz' · have : ↑z * p ≤ -p := by nlinarith linarith [abs_eq_self.mpr hp.le] · have : p ≤ ↑z * p := by nlinarith linarith [abs_eq_self.mpr hp.le] · simp only [mul_zero, add_zero, abs_zero, zero_div] at hy₁ hy₂ hε linarith · rcases Int.cast_le_neg_one_or_one_le_cast_of_ne_zero ℝ hz with hz' | hz' · have : -p ≤ ↑z * p := by nlinarith linarith [abs_eq_neg_self.mpr hp.le] · have : ↑z * p ≤ p := by nlinarith linarith [abs_eq_neg_self.mpr hp.le] section FiniteOrderPoints variable {p} [hp : Fact (0 < p)] theorem norm_div_natCast {m n : ℕ} : ‖(↑(↑m / ↑n * p) : AddCircle p)‖ = p * (↑(min (m % n) (n - m % n)) / n) := by have : p⁻¹ * (↑m / ↑n * p) = ↑m / ↑n := by rw [mul_comm _ p, inv_mul_cancel_left₀ hp.out.ne.symm] rw [norm_eq' p hp.out, this, abs_sub_round_div_natCast_eq] theorem exists_norm_eq_of_isOfFinAddOrder {u : AddCircle p} (hu : IsOfFinAddOrder u) : ∃ k : ℕ, ‖u‖ = p * (k / addOrderOf u) := by let n := addOrderOf u change ∃ k : ℕ, ‖u‖ = p * (k / n) obtain ⟨m, -, -, hm⟩ := exists_gcd_eq_one_of_isOfFinAddOrder hu refine ⟨min (m % n) (n - m % n), ?_⟩ rw [← hm, norm_div_natCast] theorem le_add_order_smul_norm_of_isOfFinAddOrder {u : AddCircle p} (hu : IsOfFinAddOrder u) (hu' : u ≠ 0) : p ≤ addOrderOf u • ‖u‖ := by obtain ⟨n, hn⟩ := exists_norm_eq_of_isOfFinAddOrder hu replace hu : (addOrderOf u : ℝ) ≠ 0 := by norm_cast exact (addOrderOf_pos_iff.mpr hu).ne' conv_lhs => rw [← mul_one p] rw [hn, nsmul_eq_mul, ← mul_assoc, mul_comm _ p, mul_assoc, mul_div_cancel₀ _ hu, mul_le_mul_left hp.out, Nat.one_le_cast, Nat.one_le_iff_ne_zero] contrapose! hu' simpa only [hu', Nat.cast_zero, zero_div, mul_zero, norm_eq_zero] using hn end FiniteOrderPoints end AddCircle namespace UnitAddCircle theorem norm_eq {x : ℝ} : ‖(x : UnitAddCircle)‖ = |x - round x| := by simp [AddCircle.norm_eq] end UnitAddCircle
perm.v
(* (c) Copyright 2006-2016 Microsoft Corporation and Inria. *) (* Distributed under the terms of CeCILL-B. *) From HB Require Import structures. From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq path. From mathcomp Require Import choice fintype tuple finfun bigop finset binomial. From mathcomp Require Import fingroup morphism. (******************************************************************************) (* This file contains the definition and properties associated to the group *) (* of permutations of an arbitrary finite type. *) (* {perm T} == the type of permutations of a finite type T, i.e., *) (* injective (finite) functions from T to T. Permutations *) (* coerce to CiC functions. *) (* 'S_n == the set of all permutations of 'I_n, i.e., of *) (* {0,.., n-1} *) (* perm_on A u == u is a permutation with support A, i.e., u only *) (* displaces elements of A (u x != x implies x \in A). *) (* tperm x y == the transposition of x, y. *) (* aperm x s == the image of x under the action of the permutation s. *) (* := s x *) (* cast_perm Emn s == the 'S_m permutation cast as a 'S_n permutation using *) (* Emn : m = n *) (* porbit s x == the set of all elements that are in the same cycle of *) (* the permutation s as x, i.e., {x, s x, (s ^+ 2) x, ...}.*) (* porbits s == the set of all the cycles of the permutation s. *) (* (s : bool) == s is an odd permutation (the coercion is called *) (* odd_perm). *) (* dpair u == u is a pair (x, y) of distinct objects (i.e., x != y). *) (* Sym S == the set of permutations with support S *) (* lift_perm i j s == the permutation obtained by lifting s : 'S_n.-1 over *) (* (i |-> j), that maps i to j and lift i k to *) (* lift j (s k). *) (* Canonical structures are defined allowing permutations to be an eqType, *) (* choiceType, countType, finType, subType, finGroupType; permutations with *) (* composition form a group, therefore inherit all generic group notations: *) (* 1 == identity permutation, * == composition, ^-1 == inverse permutation. *) (******************************************************************************) Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. Import GroupScope. Section PermDefSection. Variable T : finType. Inductive perm_type : predArgType := Perm (pval : {ffun T -> T}) & injectiveb pval. Definition pval p := let: Perm f _ := p in f. Definition perm_of := perm_type. Identity Coercion type_of_perm : perm_of >-> perm_type. HB.instance Definition _ := [isSub for pval]. HB.instance Definition _ := [Finite of perm_type by <:]. Lemma perm_proof (f : T -> T) : injective f -> injectiveb (finfun f). Proof. by move=> f_inj; apply/injectiveP; apply: eq_inj f_inj _ => x; rewrite ffunE. Qed. End PermDefSection. Arguments perm_of T%_type. Notation "{ 'perm' T }" := (perm_of T) (format "{ 'perm' T }") : type_scope. Arguments pval _ _%_g. Bind Scope group_scope with perm_type. Bind Scope group_scope with perm_of. Notation "''S_' n" := {perm 'I_n} (at level 8, n at level 2, format "''S_' n"). HB.lock Definition perm T f injf := Perm (@perm_proof T f injf). Canonical perm_unlock := Unlockable perm.unlock. HB.lock Definition fun_of_perm T (u : perm_type T) : T -> T := val u. Canonical fun_of_perm_unlock := Unlockable fun_of_perm.unlock. Coercion fun_of_perm : perm_type >-> Funclass. Section Theory. Variable T : finType. Implicit Types (x y : T) (s t : {perm T}) (S : {set T}). Lemma permP s t : s =1 t <-> s = t. Proof. by split=> [| -> //]; rewrite unlock => eq_sv; apply/val_inj/ffunP. Qed. Lemma pvalE s : pval s = s :> (T -> T). Proof. by rewrite [@fun_of_perm]unlock. Qed. Lemma permE f f_inj : @perm T f f_inj =1 f. Proof. by move=> x; rewrite -pvalE [@perm]unlock ffunE. Qed. Lemma perm_inj {s} : injective s. Proof. by rewrite -!pvalE; apply: (injectiveP _ (valP s)). Qed. Hint Resolve perm_inj : core. Lemma perm_onto s : codom s =i predT. Proof. by apply/subset_cardP; rewrite ?card_codom ?subset_predT. Qed. Definition perm_one := perm (@inj_id T). Lemma perm_invK s : cancel (fun x => iinv (perm_onto s x)) s. Proof. by move=> x /=; rewrite f_iinv. Qed. Definition perm_inv s := perm (can_inj (perm_invK s)). Definition perm_mul s t := perm (inj_comp (@perm_inj t) (@perm_inj s)). Lemma perm_oneP : left_id perm_one perm_mul. Proof. by move=> s; apply/permP => x; rewrite permE /= permE. Qed. Lemma perm_invP : left_inverse perm_one perm_inv perm_mul. Proof. by move=> s; apply/permP=> x; rewrite !permE /= permE f_iinv. Qed. Lemma perm_mulP : associative perm_mul. Proof. by move=> s t u; apply/permP=> x; do !rewrite permE /=. Qed. HB.instance Definition _ := isMulGroup.Build (perm_type T) perm_mulP perm_oneP perm_invP. Lemma perm1 x : (1 : {perm T}) x = x. Proof. by rewrite permE. Qed. Lemma permM s t x : (s * t) x = t (s x). Proof. by rewrite permE. Qed. Lemma permK s : cancel s s^-1. Proof. by move=> x; rewrite -permM mulgV perm1. Qed. Lemma permKV s : cancel s^-1 s. Proof. by have:= permK s^-1; rewrite invgK. Qed. Lemma permJ s t x : (s ^ t) (t x) = t (s x). Proof. by rewrite !permM permK. Qed. Lemma permX s x n : (s ^+ n) x = iter n s x. Proof. by elim: n => [|n /= <-]; rewrite ?perm1 // -permM expgSr. Qed. Lemma permX_fix s x n : s x = x -> (s ^+ n) x = x. Proof. move=> Hs; elim: n => [|n IHn]; first by rewrite expg0 perm1. by rewrite expgS permM Hs. Qed. Lemma im_permV s S : s^-1 @: S = s @^-1: S. Proof. exact: can2_imset_pre (permKV s) (permK s). Qed. Lemma preim_permV s S : s^-1 @^-1: S = s @: S. Proof. by rewrite -im_permV invgK. Qed. Definition perm_on S : pred {perm T} := fun s => [pred x | s x != x] \subset S. Lemma perm_closed S s x : perm_on S s -> (s x \in S) = (x \in S). Proof. move/subsetP=> s_on_S; have [-> // | nfix_s_x] := eqVneq (s x) x. by rewrite !s_on_S // inE /= ?(inj_eq perm_inj). Qed. Lemma perm_on1 H : perm_on H 1. Proof. by apply/subsetP=> x; rewrite inE /= perm1 eqxx. Qed. Lemma perm_onM H s t : perm_on H s -> perm_on H t -> perm_on H (s * t). Proof. move/subsetP=> sH /subsetP tH; apply/subsetP => x; rewrite inE /= permM. by have [-> /tH | /sH] := eqVneq (s x) x. Qed. Lemma perm_onV H s : perm_on H s -> perm_on H s^-1. Proof. move=> /subsetP sH; apply/subsetP => i /[!inE] sVi; apply: sH; rewrite inE. by apply: contra_neq sVi => si_id; rewrite -[in LHS]si_id permK. Qed. Lemma out_perm S u x : perm_on S u -> x \notin S -> u x = x. Proof. by move=> uS; apply: contraNeq (subsetP uS x). Qed. Lemma im_perm_on u S : perm_on S u -> u @: S = S. Proof. move=> Su; rewrite -preim_permV; apply/setP=> x. by rewrite !inE -(perm_closed _ Su) permKV. Qed. Lemma perm_on_id u S : perm_on S u -> #|S| <= 1 -> u = 1%g. Proof. rewrite leq_eqVlt ltnS leqn0 => pSu S10; apply/permP => t; rewrite perm1. case/orP : S10; last first. by move/eqP/cards0_eq => S0; apply: (out_perm pSu); rewrite S0 inE. move=> /cards1P[x Sx]. have [-> | ntx] := eqVneq t x; last by apply: (out_perm pSu); rewrite Sx inE. by apply/eqP; have := perm_closed x pSu; rewrite Sx !inE => ->. Qed. Lemma perm_onC (S1 S2 : {set T}) (u1 u2 : {perm T}) : perm_on S1 u1 -> perm_on S2 u2 -> [disjoint S1 & S2] -> commute u1 u2. Proof. move=> pS1 pS2 S12; apply/permP => t; rewrite !permM. case/boolP : (t \in S1) => tS1. have /[!disjoint_subset] /subsetP {}S12 := S12. by rewrite !(out_perm pS2) //; apply: S12; rewrite // perm_closed. case/boolP : (t \in S2) => tS2. have /[1!disjoint_sym] /[!disjoint_subset] /subsetP {}S12 := S12. by rewrite !(out_perm pS1) //; apply: S12; rewrite // perm_closed. by rewrite (out_perm pS1) // (out_perm pS2) // (out_perm pS1). Qed. Lemma imset_perm1 (S : {set T}) : [set (1 : {perm T}) x | x in S] = S. Proof. apply: im_perm_on; exact: perm_on1. Qed. Lemma tperm_proof x y : involutive [fun z => z with x |-> y, y |-> x]. Proof. move=> z /=; case: (z =P x) => [-> | ne_zx]; first by rewrite eqxx; case: eqP. by case: (z =P y) => [->| ne_zy]; [rewrite eqxx | do 2?case: eqP]. Qed. Definition tperm x y := perm (can_inj (tperm_proof x y)). Variant tperm_spec x y z : T -> Type := | TpermFirst of z = x : tperm_spec x y z y | TpermSecond of z = y : tperm_spec x y z x | TpermNone of z <> x & z <> y : tperm_spec x y z z. Lemma tpermP x y z : tperm_spec x y z (tperm x y z). Proof. by rewrite permE /=; do 2?[case: eqP => /=]; constructor; auto. Qed. Lemma tpermL x y : tperm x y x = y. Proof. by case: tpermP. Qed. Lemma tpermR x y : tperm x y y = x. Proof. by case: tpermP. Qed. Lemma tpermD x y z : x != z -> y != z -> tperm x y z = z. Proof. by case: tpermP => // ->; rewrite eqxx. Qed. Lemma tpermC x y : tperm x y = tperm y x. Proof. by apply/permP => z; do 2![case: tpermP => //] => ->. Qed. Lemma tperm1 x : tperm x x = 1. Proof. by apply/permP => z; rewrite perm1; case: tpermP. Qed. Lemma tpermK x y : involutive (tperm x y). Proof. by move=> z; rewrite !permE tperm_proof. Qed. Lemma tpermKg x y : involutive (mulg (tperm x y)). Proof. by move=> s; apply/permP=> z; rewrite !permM tpermK. Qed. Lemma tpermV x y : (tperm x y)^-1 = tperm x y. Proof. by set t := tperm x y; rewrite -{2}(mulgK t t) -mulgA tpermKg. Qed. Lemma tperm2 x y : tperm x y * tperm x y = 1. Proof. by rewrite -{1}tpermV mulVg. Qed. Lemma tperm_on x y : perm_on [set x; y] (tperm x y). Proof. by apply/subsetP => z /[!inE]; case: tpermP => [->|->|]; rewrite eqxx // orbT. Qed. Lemma card_perm A : #|perm_on A| = (#|A|)`!. Proof. pose ffA := {ffun {x | x \in A} -> T}. rewrite -ffactnn -{2}(card_sig [in A]) /= -card_inj_ffuns_on. pose fT (f : ffA) := [ffun x => oapp f x (insub x)]. pose pfT f := insubd (1 : {perm T}) (fT f). pose fA s : ffA := [ffun u => s (val u)]. rewrite -!sum1dep_card -sum1_card (reindex_onto fA pfT) => [|f]. apply: eq_bigl => p; rewrite andbC; apply/idP/and3P=> [onA | []]; first split. - apply/eqP; suffices fTAp: fT (fA p) = pval p. by apply/permP=> x; rewrite -!pvalE insubdK fTAp //; apply: (valP p). apply/ffunP=> x; rewrite ffunE pvalE. by case: insubP => [u _ <- | /out_perm->] //=; rewrite ffunE. - by apply/forallP=> [[x Ax]]; rewrite ffunE /= perm_closed. - by apply/injectiveP=> u v; rewrite !ffunE => /perm_inj; apply: val_inj. move/eqP=> <- _ _; apply/subsetP=> x; rewrite !inE -pvalE val_insubd fun_if. by rewrite if_arg ffunE; case: insubP; rewrite // pvalE perm1 if_same eqxx. case/andP=> /forallP-onA /injectiveP-f_inj. apply/ffunP=> u; rewrite ffunE -pvalE insubdK; first by rewrite ffunE valK. apply/injectiveP=> {u} x y; rewrite !ffunE. case: insubP => [u _ <-|]; case: insubP => [v _ <-|] //=; first by move/f_inj->. by move=> Ay' def_y; rewrite -def_y [_ \in A]onA in Ay'. by move=> Ax' def_x; rewrite def_x [_ \in A]onA in Ax'. Qed. End Theory. Prenex Implicits tperm permK permKV tpermK. Arguments perm_inj {T s} [x1 x2] eq_sx12. (* Shorthand for using a permutation to reindex a bigop. *) Notation reindex_perm s := (reindex_inj (@perm_inj _ s)). Lemma inj_tperm (T T' : finType) (f : T -> T') x y z : injective f -> f (tperm x y z) = tperm (f x) (f y) (f z). Proof. by move=> injf; rewrite !permE /= !(inj_eq injf) !(fun_if f). Qed. Section tpermJ. Variables (T : finType). Implicit Types (x y z : T) (s : {perm T}). Lemma tpermJ x y s : (tperm x y) ^ s = tperm (s x) (s y). Proof. by apply/permP => z; rewrite -(permKV s z) permJ; apply/inj_tperm/perm_inj. Qed. Lemma tpermJ_tperm x y z : x != z -> y != z -> tperm x z ^ tperm x y = tperm y z. Proof. by move=> nxz nyz; rewrite tpermJ tpermL [tperm _ _ z]tpermD. Qed. End tpermJ. Lemma tuple_permP {T : eqType} {n} {s : seq T} {t : n.-tuple T} : reflect (exists p : 'S_n, s = [tuple tnth t (p i) | i < n]) (perm_eq s t). Proof. apply: (iffP idP) => [|[p ->]]; last first. rewrite /= (map_comp (tnth t)) -{1}(map_tnth_enum t) perm_map //. apply: uniq_perm => [||i]; rewrite ?enum_uniq //. by apply/injectiveP; apply: perm_inj. by rewrite mem_enum -[i](permKV p) image_f. case: n => [|n] in t *; last have x0 := tnth t ord0. rewrite tuple0 => /perm_small_eq-> //. by exists 1; rewrite [mktuple _]tuple0. case/(perm_iotaP x0); rewrite size_tuple => Is eqIst ->{s}. have uniqIs: uniq Is by rewrite (perm_uniq eqIst) iota_uniq. have szIs: size Is == n.+1 by rewrite (perm_size eqIst) !size_tuple. have pP i : tnth (Tuple szIs) i < n.+1. by rewrite -[_ < _](mem_iota 0) -(perm_mem eqIst) mem_tnth. have inj_p: injective (fun i => Ordinal (pP i)). by apply/injectiveP/(@map_uniq _ _ val); rewrite -map_comp map_tnth_enum. exists (perm inj_p); rewrite -[Is]/(tval (Tuple szIs)); congr (tval _). by apply: eq_from_tnth => i; rewrite tnth_map tnth_mktuple permE (tnth_nth x0). Qed. (* Note that porbit s x is the orbit of x by <[s]> under the action aperm. *) (* Hence, the porbit lemmas below are special cases of more general lemmas *) (* on orbits that will be stated in action.v. *) (* Defining porbit directly here avoids a dependency of matrix.v on *) (* action.v and hence morphism.v. *) Definition aperm (T : finType) x (s : {perm T}) := s x. HB.lock Definition porbit (T : finType) (s : {perm T}) x := aperm x @: <[s]>. Canonical porbit_unlockable := Unlockable porbit.unlock. Definition porbits (T : finType) (s : {perm T}) := porbit s @: T. Section PermutationParity. Variable T : finType. Implicit Types (s t u v : {perm T}) (x y z a b : T). Definition odd_perm (s : perm_type T) := odd #|T| (+) odd #|porbits s|. Lemma apermE x s : aperm x s = s x. Proof. by []. Qed. Lemma mem_porbit s i x : (s ^+ i) x \in porbit s x. Proof. by rewrite [@porbit]unlock (imset_f (aperm x)) ?mem_cycle. Qed. Lemma porbit_id s x : x \in porbit s x. Proof. by rewrite -{1}[x]perm1 (mem_porbit s 0). Qed. Lemma card_porbit_neq0 s x : #|porbit s x| != 0. Proof. by rewrite -lt0n card_gt0; apply/set0Pn; exists x; exact: porbit_id. Qed. Lemma uniq_traject_porbit s x : uniq (traject s x #|porbit s x|). Proof. case def_n: #|_| => // [n]; rewrite looping_uniq. apply: contraL (card_size (traject s x n)) => /loopingP t_sx. rewrite -ltnNge size_traject -def_n ?subset_leq_card // porbit.unlock. by apply/subsetP=> _ /imsetP[_ /cycleP[i ->] ->]; rewrite /aperm permX t_sx. Qed. Lemma porbit_traject s x : porbit s x =i traject s x #|porbit s x|. Proof. apply: fsym; apply/subset_cardP. by rewrite (card_uniqP _) ?size_traject ?uniq_traject_porbit. by apply/subsetP=> _ /trajectP[i _ ->]; rewrite -permX mem_porbit. Qed. Lemma iter_porbit s x : iter #|porbit s x| s x = x. Proof. case def_n: #|_| (uniq_traject_porbit s x) => [//|n] Ut. have: looping s x n.+1. by rewrite -def_n -[looping _ _ _]porbit_traject -permX mem_porbit. rewrite /looping => /trajectP[[|i] //= lt_i_n /perm_inj eq_i_n_sx]. move: lt_i_n; rewrite ltnS ltn_neqAle andbC => /andP[le_i_n /negP[]]. by rewrite -(nth_uniq x _ _ Ut) ?size_traject ?nth_traject // eq_i_n_sx. Qed. Lemma eq_porbit_mem s x y : (porbit s x == porbit s y) = (x \in porbit s y). Proof. apply/eqP/idP; first by move<-; exact: porbit_id. rewrite porbit.unlock => /imsetP[si s_si ->]. apply/setP => z; apply/imsetP/imsetP=> [] [sj s_sj ->]. by exists (si * sj); rewrite ?groupM /aperm ?permM. exists (si^-1 * sj); first by rewrite groupM ?groupV. by rewrite /aperm permM permK. Qed. Lemma porbit_sym s x y : (x \in porbit s y) = (y \in porbit s x). Proof. by rewrite -!eq_porbit_mem eq_sym. Qed. Lemma porbit_perm s i x : porbit s ((s ^+ i) x) = porbit s x. Proof. by apply/eqP; rewrite eq_porbit_mem mem_porbit. Qed. Lemma porbitPmin s x y : y \in porbit s x -> exists2 i, i < #[s] & y = (s ^+ i) x. Proof. by rewrite porbit.unlock=> /imsetP [z /cyclePmin[ i Hi ->{z}] ->{y}]; exists i. Qed. Lemma porbitP s x y : reflect (exists i, y = (s ^+ i) x) (y \in porbit s x). Proof. apply (iffP idP) => [/porbitPmin [i _ ->]| [i ->]]; last exact: mem_porbit. by exists i. Qed. Lemma porbitV s : porbit s^-1 =1 porbit s. Proof. move=> x; apply/setP => y; rewrite porbit_sym. by apply/porbitP/porbitP => -[i ->]; exists i; rewrite expgVn ?permK ?permKV. Qed. Lemma porbitsV s : porbits s^-1 = porbits s. Proof. rewrite /porbits; apply/setP => y. by apply/imsetP/imsetP => -[x _ ->{y}]; exists x; rewrite // porbitV. Qed. Lemma porbit_setP s t x : porbit s x =i porbit t x <-> porbit s x = porbit t x. Proof. by rewrite porbit.unlock; exact: setP. Qed. Lemma porbits_mul_tperm s x y : let t := tperm x y in #|porbits (t * s)| + (x \notin porbit s y).*2 = #|porbits s| + (x != y). Proof. pose xf a b u := seq.find (pred2 a b) (traject u (u a) #|porbit u a|). have xf_size a b u: xf a b u <= #|porbit u a|. by rewrite (leq_trans (find_size _ _)) ?size_traject. have lt_xf a b u n : n < xf a b u -> ~~ pred2 a b ((u ^+ n.+1) a). move=> lt_n; apply: contraFN (before_find (u a) lt_n). by rewrite permX iterSr nth_traject // (leq_trans lt_n). pose t a b u := tperm a b * u. have tC a b u : t a b u = t b a u by rewrite /t tpermC. have tK a b: involutive (t a b) by move=> u; apply: tpermKg. have tXC a b u n: n <= xf a b u -> (t a b u ^+ n.+1) b = (u ^+ n.+1) a. elim: n => [|n IHn] lt_n_f; first by rewrite permM tpermR. rewrite !(expgSr _ n.+1) !permM {}IHn 1?ltnW //; congr (u _). by case/lt_xf/norP: lt_n_f => ne_a ne_b; rewrite tpermD // eq_sym. have eq_xf a b u: pred2 a b ((u ^+ (xf a b u).+1) a). have ua_a: a \in porbit u (u a) by rewrite porbit_sym (mem_porbit _ 1). have has_f: has (pred2 a b) (traject u (u a) #|porbit u (u a)|). by apply/hasP; exists a; rewrite /= ?eqxx -?porbit_traject. have:= nth_find (u a) has_f; rewrite has_find size_traject in has_f. rewrite -eq_porbit_mem in ua_a. by rewrite nth_traject // -iterSr -permX -(eqP ua_a). have xfC a b u: xf b a (t a b u) = xf a b u. without loss lt_a: a b u / xf b a (t a b u) < xf a b u. move=> IHab; set m := xf b a _; set n := xf a b u. by case: (ltngtP m n) => // ltx; [apply: IHab | rewrite -[m]IHab tC tK]. by move/lt_xf: (lt_a); rewrite -(tXC a b) 1?ltnW //= orbC [_ || _]eq_xf. pose ts := t x y s; rewrite /= -[_ * s]/ts. pose dp u := #|porbits u :\ porbit u y :\ porbit u x|. rewrite !(addnC #|_|) (cardsD1 (porbit ts y)) imset_f ?inE //. rewrite (cardsD1 (porbit ts x)) inE imset_f ?inE //= -/(dp ts) {}/ts. rewrite (cardsD1 (porbit s y)) (cardsD1 (porbit s x)) !(imset_f, inE) //. rewrite -/(dp s) !addnA !eq_porbit_mem andbT; congr (_ + _); last first. wlog suffices: s / dp s <= dp (t x y s). by move=> IHs; apply/eqP; rewrite eqn_leq -{2}(tK x y s) !IHs. apply/subset_leq_card/subsetP=> {dp} C. rewrite !inE andbA andbC !(eq_sym C) => /and3P[/imsetP[z _ ->{C}]]. rewrite 2!eq_porbit_mem => sxz syz. suffices ts_z: porbit (t x y s) z = porbit s z. by rewrite -ts_z !eq_porbit_mem {1 2}ts_z sxz syz imset_f ?inE. suffices exp_id n: ((t x y s) ^+ n) z = (s ^+ n) z. apply/porbit_setP => u; apply/idP/idP=> /porbitP[i ->]. by rewrite /aperm exp_id mem_porbit. by rewrite /aperm -exp_id mem_porbit. elim: n => // n IHn; rewrite !expgSr !permM {}IHn tpermD //. by apply: contraNneq sxz => ->; apply: mem_porbit. by apply: contraNneq syz => ->; apply: mem_porbit. case: eqP {dp} => [<- | ne_xy]; first by rewrite /t tperm1 mul1g porbit_id. suff ->: (x \in porbit (t x y s) y) = (x \notin porbit s y) by case: (x \in _). without loss xf_x: s x y ne_xy / (s ^+ (xf x y s).+1) x = x. move=> IHs; have ne_yx := nesym ne_xy; have:= eq_xf x y s; set n := xf x y s. case/pred2P=> [|snx]; first exact: IHs. by rewrite -[x \in _]negbK ![x \in _]porbit_sym -{}IHs ?xfC ?tXC // tC tK. rewrite -{1}xf_x -(tXC _ _ _ _ (leqnn _)) mem_porbit; symmetry. rewrite -eq_porbit_mem eq_sym eq_porbit_mem porbit_traject. apply/trajectP=> [[n _ snx]]. have: looping s x (xf x y s).+1 by rewrite /looping -permX xf_x inE eqxx. move/loopingP/(_ n); rewrite -{n}snx. case/trajectP=> [[_|i]]; first exact: nesym; rewrite ltnS -permX => lt_i def_y. by move/lt_xf: lt_i; rewrite def_y /= eqxx orbT. Qed. Lemma odd_perm1 : odd_perm 1 = false. Proof. rewrite /odd_perm card_imset ?addbb // => x y; move/eqP; rewrite eq_porbit_mem. by rewrite porbit.unlock cycle1 imset_set1 /aperm perm1 inE=> /eqP. Qed. Lemma odd_mul_tperm x y s : odd_perm (tperm x y * s) = (x != y) (+) odd_perm s. Proof. rewrite addbC -addbA -[~~ _]oddb -oddD -porbits_mul_tperm. by rewrite oddD odd_double addbF. Qed. Lemma odd_tperm x y : odd_perm (tperm x y) = (x != y). Proof. by rewrite -[_ y]mulg1 odd_mul_tperm odd_perm1 addbF. Qed. Definition dpair (eT : eqType) := [pred t | t.1 != t.2 :> eT]. Arguments dpair {eT}. Lemma prod_tpermP s : {ts : seq (T * T) | s = \prod_(t <- ts) tperm t.1 t.2 & all dpair ts}. Proof. have [n] := ubnP #|[pred x | s x != x]|; elim: n s => // n IHn s /ltnSE-le_s_n. case: (pickP (fun x => s x != x)) => [x s_x | s_id]; last first. exists nil; rewrite // big_nil; apply/permP=> x. by apply/eqP/idPn; rewrite perm1 s_id. have [|ts def_s ne_ts] := IHn (tperm x (s^-1 x) * s); last first. exists ((x, s^-1 x) :: ts); last by rewrite /= -(canF_eq (permK _)) s_x. by rewrite big_cons -def_s mulgA tperm2 mul1g. rewrite (cardD1 x) !inE s_x in le_s_n; apply: leq_ltn_trans le_s_n. apply: subset_leq_card; apply/subsetP=> y. rewrite !inE permM permE /= -(canF_eq (permK _)). have [-> | ne_yx] := eqVneq y x; first by rewrite permKV eqxx. by case: (s y =P x) => // -> _; rewrite eq_sym. Qed. Lemma odd_perm_prod ts : all dpair ts -> odd_perm (\prod_(t <- ts) tperm t.1 t.2) = odd (size ts). Proof. elim: ts => [_|t ts IHts] /=; first by rewrite big_nil odd_perm1. by case/andP=> dt12 dts; rewrite big_cons odd_mul_tperm dt12 IHts. Qed. Lemma odd_permM : {morph odd_perm : s1 s2 / s1 * s2 >-> s1 (+) s2}. Proof. move=> s1 s2; case: (prod_tpermP s1) => ts1 ->{s1} dts1. case: (prod_tpermP s2) => ts2 ->{s2} dts2. by rewrite -big_cat !odd_perm_prod ?all_cat ?dts1 // size_cat oddD. Qed. Lemma odd_permV s : odd_perm s^-1 = odd_perm s. Proof. by rewrite -{2}(mulgK s s) !odd_permM -addbA addKb. Qed. Lemma odd_permJ s1 s2 : odd_perm (s1 ^ s2) = odd_perm s1. Proof. by rewrite !odd_permM odd_permV addbC addbK. Qed. Lemma gen_tperm x : <<[set tperm x y | y in T]>>%g = [set: {perm T}]. Proof. apply/eqP; rewrite eqEsubset subsetT/=; apply/subsetP => s _. have [ts -> _] := prod_tpermP s; rewrite group_prod// => -[/= y z] _. have [<-|Nyz] := eqVneq y z; first by rewrite tperm1 group1. have [<-|Nxz] := eqVneq x z; first by rewrite tpermC mem_gen ?imset_f. by rewrite -(tpermJ_tperm Nxz Nyz) groupJ ?mem_gen ?imset_f. Qed. End PermutationParity. Coercion odd_perm : perm_type >-> bool. Arguments dpair {eT}. Prenex Implicits porbit dpair porbits aperm. Section Symmetry. Variables (T : finType) (S : {set T}). Definition Sym : {set {perm T}} := [set s | perm_on S s]. Lemma Sym_group_set : group_set Sym. Proof. apply/group_setP; split => [|s t] /[!inE]; [exact: perm_on1 | exact: perm_onM]. Qed. Canonical Sym_group : {group {perm T}} := Group Sym_group_set. Lemma card_Sym : #|Sym| = #|S|`!. Proof. by rewrite cardsE /= card_perm. Qed. End Symmetry. Section LiftPerm. (* Somewhat more specialised constructs for permutations on ordinals. *) Variable n : nat. Implicit Types i j : 'I_n.+1. Implicit Types s t : 'S_n. Lemma card_Sn : #|'S_(n)| = n`!. Proof. rewrite (eq_card (B := perm_on [set : 'I_n])). by rewrite card_perm /= cardsE /= card_ord. move=> p; rewrite inE unfold_in /perm_on /=. by apply/esym/subsetP => i _; rewrite in_set. Qed. Definition lift_perm_fun i j s k := if unlift i k is Some k' then lift j (s k') else j. Lemma lift_permK i j s : cancel (lift_perm_fun i j s) (lift_perm_fun j i s^-1). Proof. rewrite /lift_perm_fun => k. by case: (unliftP i k) => [j'|] ->; rewrite (liftK, unlift_none) ?permK. Qed. Definition lift_perm i j s := perm (can_inj (lift_permK i j s)). Lemma lift_perm_id i j s : lift_perm i j s i = j. Proof. by rewrite permE /lift_perm_fun unlift_none. Qed. Lemma lift_perm_lift i j s k' : lift_perm i j s (lift i k') = lift j (s k') :> 'I_n.+1. Proof. by rewrite permE /lift_perm_fun liftK. Qed. Lemma lift_permM i j k s t : lift_perm i j s * lift_perm j k t = lift_perm i k (s * t). Proof. apply/permP=> i1; case: (unliftP i i1) => [i2|] ->{i1}. by rewrite !(permM, lift_perm_lift). by rewrite permM !lift_perm_id. Qed. Lemma lift_perm1 i : lift_perm i i 1 = 1. Proof. by apply: (mulgI (lift_perm i i 1)); rewrite lift_permM !mulg1. Qed. Lemma lift_permV i j s : (lift_perm i j s)^-1 = lift_perm j i s^-1. Proof. by apply/eqP; rewrite eq_invg_mul lift_permM mulgV lift_perm1. Qed. Lemma odd_lift_perm i j s : lift_perm i j s = odd i (+) odd j (+) s :> bool. Proof. rewrite -{1}(mul1g s) -(lift_permM _ j) odd_permM. congr (_ (+) _); last first. case: (prod_tpermP s) => ts ->{s} _. elim: ts => [|t ts IHts] /=; first by rewrite big_nil lift_perm1 !odd_perm1. rewrite big_cons odd_mul_tperm -(lift_permM _ j) odd_permM {}IHts //. congr (_ (+) _); transitivity (tperm (lift j t.1) (lift j t.2)); last first. by rewrite odd_tperm (inj_eq (pcan_inj (liftK j))). congr odd_perm; apply/permP=> k; case: (unliftP j k) => [k'|] ->. by rewrite lift_perm_lift inj_tperm //; apply: lift_inj. by rewrite lift_perm_id tpermD // eq_sym neq_lift. suff{i j s} odd_lift0 (k : 'I_n.+1): lift_perm ord0 k 1 = odd k :> bool. rewrite -!odd_lift0 -{2}invg1 -lift_permV odd_permV -odd_permM. by rewrite lift_permM mulg1. elim: {k}(k : nat) {1 3}k (erefl (k : nat)) => [|m IHm] k def_k. by rewrite (_ : k = ord0) ?lift_perm1 ?odd_perm1 //; apply: val_inj. have le_mn: m < n.+1 by [rewrite -def_k ltnW]; pose j := Ordinal le_mn. rewrite -(mulg1 1)%g -(lift_permM _ j) odd_permM {}IHm // addbC. rewrite (_ : _ 1 = tperm j k); first by rewrite odd_tperm neq_ltn/= def_k leqnn. apply/permP=> i; case: (unliftP j i) => [i'|] ->; last first. by rewrite lift_perm_id tpermL. apply: ord_inj; rewrite lift_perm_lift !permE /= eq_sym -if_neg neq_lift. rewrite fun_if -val_eqE /= def_k /bump ltn_neqAle andbC. case: leqP => [_ | lt_i'm] /=; last by rewrite -if_neg neq_ltn leqW. by rewrite add1n eqSS; case: eqVneq. Qed. End LiftPerm. Prenex Implicits lift_perm lift_permK. Lemma permS0 : all_equal_to (1 : 'S_0). Proof. by move=> g; apply/permP; case. Qed. Lemma permS1 : all_equal_to (1 : 'S_1). Proof. by move=> g; apply/permP => i; rewrite !ord1. Qed. Lemma permS01 n : n <= 1 -> all_equal_to (1 : 'S_n). Proof. by case: n => [|[|]//=] _ g; rewrite (permS0, permS1). Qed. Section CastSn. Definition cast_perm m n (eq_mn : m = n) (s : 'S_m) := let: erefl in _ = n := eq_mn return 'S_n in s. Lemma cast_perm_id n eq_n s : cast_perm eq_n s = s :> 'S_n. Proof. by apply/permP => i; rewrite /cast_perm /= eq_axiomK. Qed. Lemma cast_ord_permE m n eq_m_n (s : 'S_m) i : @cast_ord m n eq_m_n (s i) = (cast_perm eq_m_n s) (cast_ord eq_m_n i). Proof. by subst m; rewrite cast_perm_id !cast_ord_id. Qed. Lemma cast_permE m n (eq_m_n : m = n) (s : 'S_m) (i : 'I_n) : cast_perm eq_m_n s i = cast_ord eq_m_n (s (cast_ord (esym eq_m_n) i)). Proof. by rewrite cast_ord_permE cast_ordKV. Qed. Lemma cast_perm_comp m n p (eq_m_n : m = n) (eq_n_p : n = p) s : cast_perm eq_n_p (cast_perm eq_m_n s) = cast_perm (etrans eq_m_n eq_n_p) s. Proof. by case: _ / eq_n_p. Qed. Lemma cast_permK m n eq_m_n : cancel (@cast_perm m n eq_m_n) (cast_perm (esym eq_m_n)). Proof. by subst m. Qed. Lemma cast_permKV m n eq_m_n : cancel (cast_perm (esym eq_m_n)) (@cast_perm m n eq_m_n). Proof. by subst m. Qed. Lemma cast_perm_sym m n (eq_m_n : m = n) s t : s = cast_perm eq_m_n t -> t = cast_perm (esym eq_m_n) s. Proof. by move/(canLR (cast_permK _)). Qed. Lemma cast_perm_inj m n eq_m_n : injective (@cast_perm m n eq_m_n). Proof. exact: can_inj (cast_permK eq_m_n). Qed. Lemma cast_perm_morphM m n eq_m_n : {morph @cast_perm m n eq_m_n : x y / x * y >-> x * y}. Proof. by subst m. Qed. Canonical morph_of_cast_perm m n eq_m_n := @Morphism _ _ setT (cast_perm eq_m_n) (in2W (@cast_perm_morphM m n eq_m_n)). Lemma isom_cast_perm m n eq_m_n : isom setT setT (@cast_perm m n eq_m_n). Proof. case: {n} _ / eq_m_n; apply/isomP; split. exact/injmP/(in2W (@cast_perm_inj _ _ _)). by apply/setP => /= s /[!inE]; apply/imsetP; exists s; rewrite ?inE. Qed. End CastSn.
test_ssrAC.v
From mathcomp Require Import all_boot ssralg. Section Tests. Lemma test_orb (a b c d : bool) : (a || b) || (c || d) = (a || c) || (b || d). Proof. time by rewrite orbACA. Abort. Lemma test_orb (a b c d : bool) : (a || b) || (c || d) = (a || c) || (b || d). Proof. time by rewrite (AC (2*2) ((1*3)*(2*4))). Abort. Lemma test_orb (a b c d : bool) : (a || b) || (c || d) = (a || c) || (b || d). Proof. time by rewrite orb.[AC (2*2) ((1*3)*(2*4))]. Qed. Lemma test_addn (a b c d : nat) : a + b + c + d = a + c + b + d. Proof. time by rewrite -addnA addnAC addnA addnAC. Abort. Lemma test_addn (a b c d : nat) : a + b + c + d = a + c + b + d. Proof. time by rewrite (ACl (1*3*2*4)). Abort. Lemma test_addn (a b c d : nat) : a + b + c + d = a + c + b + d. Proof. time by rewrite addn.[ACl 1*3*2*4]. Qed. Lemma test_addr (R : comRingType) (a b c d : R) : (a + b + c + d = a + c + b + d)%R. Proof. time by rewrite -GRing.addrA GRing.addrAC GRing.addrA GRing.addrAC. Abort. Lemma test_addr (R : comRingType) (a b c d : R) : (a + b + c + d = a + c + b + d)%R. Proof. time by rewrite (ACl (1*3*2*4)). Abort. Lemma test_addr (R : comRingType) (a b c d : R) : (a + b + c + d = a + c + b + d)%R. Proof. time by rewrite (@GRing.add R).[ACl 1*3*2*4]. Qed. Local Open Scope ring_scope. Import GRing.Theory. Lemma test_mulr (R : comRingType) (x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 : R) (x10 x11 x12 x13 x14 x15 x16 x17 x18 x19 : R) : (x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) * (x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19) * (x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) * (x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19) = (x0 * x2 * x4 * x9) * (x1 * x3 * x5 * x7) * x6 * x8 * (x10 * x12 * x14 * x19) * (x11 * x13 * x15 * x17) * x16 * x18 * (x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) * (x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19) *(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) * (x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19) * (x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) *(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) * (x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19) * (x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) * (x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) * (x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19) *(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) * (x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19) * (x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) *(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) * (x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19) * (x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) * (x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) * (x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19) *(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) * (x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19) * (x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) *(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) * (x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19) * (x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) * (x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19) * (x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) * (x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) * (x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19) *(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) * (x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19) * (x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) *(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) * (x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19) * (x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) * (x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) * (x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19) *(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) * (x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19) * (x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) *(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) * (x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19) * (x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9)* (x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19) * (x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) * (x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) * (x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19) *(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) * (x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19) * (x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) *(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) * (x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19) * (x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) * (x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) * (x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19) *(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) * (x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19) * (x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) *(x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) * (x10 * x11) * (x12 * x13) * (x14 * x15) * (x16 * x17 * x18 * x19) * (x0 * x1) * (x2 * x3) * (x4 * x5) * (x6 * x7 * x8 * x9) . Proof. pose s := ((2 * 4 * 9 * 1 * 3 * 5 * 7 * 6 * 8 * 20 * 21 * 22 * 23) * 25 * 26 * 27 * 28 * (29 * 30 * 31) * 32 * 33 * 34 * 35 * 36 * 37 * 38 * 39 * 40 * 41 * (10 * 12 * 14 * 19 * 11 * 13 * 15 * 17 * 16 * 18 * 24) * (42 * 43 * 44 * 45 * 46 * 47 * 48 * 49) * 50 * 52 * 53 * 54 * 55 * 56 * 57 * 58 * 59 * 51* 60 * 62 * 63 * 64 * 65 * 66 * 67 * 68 * 69 * 61* 70 * 72 * 73 * 74 * 75 * 76 * 77 * 78 * 79 * 71 * 80 * 82 * 83 * 84 * 85 * 86 * 87 * 88 * 89 * 81* 90 * 92 * 93 * 94 * 95 * 96 * 97 * 98 * 99 * 91 * 100 * ((102 * 104 * 109 * 101 * 103 * 105 * 107 * 106 * 108 * 120 * 121 * 122 * 123) * 125 * 126 * 127 * 128 * (129 * 130 * 131) * 132 * 133 * 134 * 135 * 136 * 137 * 138 * 139 * 140 * 141 * (110 * 112 * 114 * 119 * 111 * 113 * 115 * 117 * 116 * 118 * 124) * (142 * 143 * 144 * 145 * 146 * 147 * 148 * 149) * 150 * 152 * 153 * 154 * 155 * 156 * 157 * 158 * 159 * 151* 160 * 162 * 163 * 164 * 165 * 166 * 167 * 168 * 169 * 161* 170 * 172 * 173 * 174 * 175 * 176 * 177 * 178 * 179 * 171 * 180 * 182 * 183 * 184 * 185 * 186 * 187 * 188 * 189 * 181* 190 * 192 * 193 * 194 * 195 * 196 * 197 * 198 * 199 * 191) )%AC. time have := (@GRing.mul R).[ACl s]. time rewrite (@GRing.mul R).[ACl s]. Abort. End Tests.
inertia.v
(* (c) Copyright 2006-2016 Microsoft Corporation and Inria. *) (* Distributed under the terms of CeCILL-B. *) From HB Require Import structures. From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq path. From mathcomp Require Import choice fintype div tuple finfun bigop prime order. From mathcomp Require Import ssralg ssrnum finset fingroup morphism perm. From mathcomp Require Import automorphism quotient action zmodp cyclic center. From mathcomp Require Import gproduct commutator gseries nilpotent pgroup. From mathcomp Require Import sylow maximal frobenius matrix mxalgebra. From mathcomp Require Import mxrepresentation vector algC classfun character. From mathcomp Require Import archimedean. Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. Import Order.TTheory GroupScope GRing.Theory Num.Theory. Local Open Scope ring_scope. (******************************************************************************) (* This file contains the definitions and properties of inertia groups: *) (* (phi ^ y)%CF == the y-conjugate of phi : 'CF(G), i.e., the class *) (* function mapping x ^ y to phi x provided y normalises G. *) (* We take (phi ^ y)%CF = phi when y \notin 'N(G). *) (* (phi ^: G)%CF == the sequence of all distinct conjugates of phi : 'CF(H) *) (* by all y in G. *) (* 'I[phi] == the inertia group of phi : CF(H), i.e., the set of y *) (* such that (phi ^ y)%CF = phi AND H :^ y = y. *) (* 'I_G[phi] == the inertia group of phi in G, i.e., G :&: 'I[phi]. *) (* conjg_Iirr i y == the index j : Iirr G such that ('chi_i ^ y)%CF = 'chi_j. *) (* cfclass_Iirr G i == the image of G under conjg_Iirr i, i.e., the set of j *) (* such that 'chi_j \in ('chi_i ^: G)%CF. *) (* mul_Iirr i j == the index k such that 'chi_j * 'chi_i = 'chi[G]_k, *) (* or 0 if 'chi_j * 'chi_i is reducible. *) (* mul_mod_Iirr i j := mul_Iirr i (mod_Iirr j), for j : Iirr (G / H). *) (******************************************************************************) Reserved Notation "''I[' phi ]" (format "''I[' phi ]"). Reserved Notation "''I_' G [ phi ]" (G at level 2, format "''I_' G [ phi ]"). Section ConjDef. Variables (gT : finGroupType) (B : {set gT}) (y : gT) (phi : 'CF(B)). Local Notation G := <<B>>. Fact cfConjg_subproof : is_class_fun G [ffun x => phi (if y \in 'N(G) then x ^ y^-1 else x)]. Proof. apply: intro_class_fun => [x z _ Gz | x notGx]. have [nGy | _] := ifP; last by rewrite cfunJgen. by rewrite -conjgM conjgC conjgM cfunJgen // memJ_norm ?groupV. by rewrite cfun0gen //; case: ifP => // nGy; rewrite memJ_norm ?groupV. Qed. Definition cfConjg := Cfun 1 cfConjg_subproof. End ConjDef. Prenex Implicits cfConjg. Notation "f ^ y" := (cfConjg y f) : cfun_scope. Section Conj. Variables (gT : finGroupType) (G : {group gT}). Implicit Type phi : 'CF(G). Lemma cfConjgE phi y x : y \in 'N(G) -> (phi ^ y)%CF x = phi (x ^ y^-1)%g. Proof. by rewrite cfunElock genGid => ->. Qed. Lemma cfConjgEJ phi y x : y \in 'N(G) -> (phi ^ y)%CF (x ^ y) = phi x. Proof. by move/cfConjgE->; rewrite conjgK. Qed. Lemma cfConjgEout phi y : y \notin 'N(G) -> (phi ^ y = phi)%CF. Proof. by move/negbTE=> notNy; apply/cfunP=> x; rewrite !cfunElock genGid notNy. Qed. Lemma cfConjgEin phi y (nGy : y \in 'N(G)) : (phi ^ y)%CF = cfIsom (norm_conj_isom nGy) phi. Proof. apply/cfun_inP=> x Gx. by rewrite cfConjgE // -{2}[x](conjgKV y) cfIsomE ?memJ_norm ?groupV. Qed. Lemma cfConjgMnorm phi : {in 'N(G) &, forall y z, phi ^ (y * z) = (phi ^ y) ^ z}%CF. Proof. move=> y z nGy nGz. by apply/cfunP=> x; rewrite !cfConjgE ?groupM // invMg conjgM. Qed. Lemma cfConjg_id phi y : y \in G -> (phi ^ y)%CF = phi. Proof. move=> Gy; apply/cfunP=> x; have nGy := subsetP (normG G) y Gy. by rewrite -(cfunJ _ _ Gy) cfConjgEJ. Qed. (* Isaacs' 6.1.b *) Lemma cfConjgM L phi : G <| L -> {in L &, forall y z, phi ^ (y * z) = (phi ^ y) ^ z}%CF. Proof. by case/andP=> _ /subsetP nGL; apply: sub_in2 (cfConjgMnorm phi). Qed. Lemma cfConjgJ1 phi : (phi ^ 1)%CF = phi. Proof. by apply/cfunP=> x; rewrite cfConjgE ?group1 // invg1 conjg1. Qed. Lemma cfConjgK y : cancel (cfConjg y) (cfConjg y^-1 : 'CF(G) -> 'CF(G)). Proof. move=> phi; apply/cfunP=> x; rewrite !cfunElock groupV /=. by case: ifP => -> //; rewrite conjgKV. Qed. Lemma cfConjgKV y : cancel (cfConjg y^-1) (cfConjg y : 'CF(G) -> 'CF(G)). Proof. by move=> phi /=; rewrite -{1}[y]invgK cfConjgK. Qed. Lemma cfConjg1 phi y : (phi ^ y)%CF 1%g = phi 1%g. Proof. by rewrite cfunElock conj1g if_same. Qed. Fact cfConjg_is_linear y : linear (cfConjg y : 'CF(G) -> 'CF(G)). Proof. by move=> a phi psi; apply/cfunP=> x; rewrite !cfunElock. Qed. HB.instance Definition _ y := GRing.isSemilinear.Build _ _ _ _ (cfConjg y) (GRing.semilinear_linear (cfConjg_is_linear y)). Lemma cfConjg_cfuniJ A y : y \in 'N(G) -> ('1_A ^ y)%CF = '1_(A :^ y) :> 'CF(G). Proof. move=> nGy; apply/cfunP=> x; rewrite !cfunElock genGid nGy -sub_conjgV. by rewrite -class_lcoset -class_rcoset norm_rlcoset ?memJ_norm ?groupV. Qed. Lemma cfConjg_cfuni A y : y \in 'N(A) -> ('1_A ^ y)%CF = '1_A :> 'CF(G). Proof. by have [/cfConjg_cfuniJ-> /normP-> | /cfConjgEout] := boolP (y \in 'N(G)). Qed. Lemma cfConjg_cfun1 y : (1 ^ y)%CF = 1 :> 'CF(G). Proof. by rewrite -cfuniG; have [/cfConjg_cfuni|/cfConjgEout] := boolP (y \in 'N(G)). Qed. Fact cfConjg_is_monoid_morphism y : monoid_morphism (cfConjg y : _ -> 'CF(G)). Proof. split=> [|phi psi]; first exact: cfConjg_cfun1. by apply/cfunP=> x; rewrite !cfunElock. Qed. #[warning="-deprecated-since-mathcomp-2.5.0", deprecated(since="mathcomp 2.5.0", note="use `cfConjg_is_monoid_morphism` instead")] Definition cfConjg_is_multiplicative y := (fun g => (g.2,g.1)) (cfConjg_is_monoid_morphism y). HB.instance Definition _ y := GRing.isMonoidMorphism.Build _ _ (cfConjg y) (cfConjg_is_monoid_morphism y). Lemma cfConjg_eq1 phi y : ((phi ^ y)%CF == 1) = (phi == 1). Proof. by apply: rmorph_eq1; apply: can_inj (cfConjgK y). Qed. Lemma cfAutConjg phi u y : cfAut u (phi ^ y) = (cfAut u phi ^ y)%CF. Proof. by apply/cfunP=> x; rewrite !cfunElock. Qed. Lemma conj_cfConjg phi y : (phi ^ y)^*%CF = (phi^* ^ y)%CF. Proof. exact: cfAutConjg. Qed. Lemma cfker_conjg phi y : y \in 'N(G) -> cfker (phi ^ y) = cfker phi :^ y. Proof. move=> nGy; rewrite cfConjgEin // cfker_isom. by rewrite morphim_conj (setIidPr (cfker_sub _)). Qed. Lemma cfDetConjg phi y : cfDet (phi ^ y) = (cfDet phi ^ y)%CF. Proof. have [nGy | not_nGy] := boolP (y \in 'N(G)); last by rewrite !cfConjgEout. by rewrite !cfConjgEin cfDetIsom. Qed. End Conj. Section Inertia. Variable gT : finGroupType. Definition inertia (B : {set gT}) (phi : 'CF(B)) := [set y in 'N(B) | (phi ^ y)%CF == phi]. Local Notation "''I[' phi ]" := (inertia phi) : group_scope. Local Notation "''I_' G [ phi ]" := (G%g :&: 'I[phi]) : group_scope. Fact group_set_inertia (H : {group gT}) phi : group_set 'I[phi : 'CF(H)]. Proof. apply/group_setP; split; first by rewrite inE group1 /= cfConjgJ1. move=> y z /setIdP[nHy /eqP n_phi_y] /setIdP[nHz n_phi_z]. by rewrite inE groupM //= cfConjgMnorm ?n_phi_y. Qed. Canonical inertia_group H phi := Group (@group_set_inertia H phi). Local Notation "''I[' phi ]" := (inertia_group phi) : Group_scope. Local Notation "''I_' G [ phi ]" := (G :&: 'I[phi])%G : Group_scope. Variables G H : {group gT}. Implicit Type phi : 'CF(H). Lemma inertiaJ phi y : y \in 'I[phi] -> (phi ^ y)%CF = phi. Proof. by case/setIdP=> _ /eqP->. Qed. Lemma inertia_valJ phi x y : y \in 'I[phi] -> phi (x ^ y)%g = phi x. Proof. by case/setIdP=> nHy /eqP {1}<-; rewrite cfConjgEJ. Qed. (* To disambiguate basic inclucion lemma names we capitalize Inertia for *) (* lemmas concerning the localized inertia group 'I_G[phi]. *) Lemma Inertia_sub phi : 'I_G[phi] \subset G. Proof. exact: subsetIl. Qed. Lemma norm_inertia phi : 'I[phi] \subset 'N(H). Proof. by rewrite ['I[_]]setIdE subsetIl. Qed. Lemma sub_inertia phi : H \subset 'I[phi]. Proof. by apply/subsetP=> y Hy; rewrite inE cfConjg_id ?(subsetP (normG H)) /=. Qed. Lemma normal_inertia phi : H <| 'I[phi]. Proof. by rewrite /normal sub_inertia norm_inertia. Qed. Lemma sub_Inertia phi : H \subset G -> H \subset 'I_G[phi]. Proof. by rewrite subsetI sub_inertia andbT. Qed. Lemma norm_Inertia phi : 'I_G[phi] \subset 'N(H). Proof. by rewrite setIC subIset ?norm_inertia. Qed. Lemma normal_Inertia phi : H \subset G -> H <| 'I_G[phi]. Proof. by rewrite /normal norm_Inertia andbT; apply: sub_Inertia. Qed. Lemma cfConjg_eqE phi : H <| G -> {in G &, forall y z, (phi ^ y == phi ^ z)%CF = (z \in 'I_G[phi] :* y)}. Proof. case/andP=> _ nHG y z Gy; rewrite -{1 2}[z](mulgKV y) groupMr // mem_rcoset. move: {z}(z * _)%g => z Gz; rewrite 2!inE Gz cfConjgMnorm ?(subsetP nHG) //=. by rewrite eq_sym (can_eq (cfConjgK y)). Qed. Lemma cent_sub_inertia phi : 'C(H) \subset 'I[phi]. Proof. apply/subsetP=> y cHy; have nHy := subsetP (cent_sub H) y cHy. rewrite inE nHy; apply/eqP/cfun_inP=> x Hx; rewrite cfConjgE //. by rewrite /conjg invgK mulgA (centP cHy) ?mulgK. Qed. Lemma cent_sub_Inertia phi : 'C_G(H) \subset 'I_G[phi]. Proof. exact: setIS (cent_sub_inertia phi). Qed. Lemma center_sub_Inertia phi : H \subset G -> 'Z(G) \subset 'I_G[phi]. Proof. by move/centS=> sHG; rewrite setIS // (subset_trans sHG) // cent_sub_inertia. Qed. Lemma conjg_inertia phi y : y \in 'N(H) -> 'I[phi] :^ y = 'I[phi ^ y]. Proof. move=> nHy; apply/setP=> z; rewrite !['I[_]]setIdE conjIg conjGid // !in_setI. apply/andb_id2l=> nHz; rewrite mem_conjg !inE. by rewrite !cfConjgMnorm ?in_group ?(can2_eq (cfConjgKV y) (cfConjgK y)) ?invgK. Qed. Lemma inertia0 : 'I[0 : 'CF(H)] = 'N(H). Proof. by apply/setP=> x; rewrite !inE linear0 eqxx andbT. Qed. Lemma inertia_add phi psi : 'I[phi] :&: 'I[psi] \subset 'I[phi + psi]. Proof. rewrite !['I[_]]setIdE -setIIr setIS //. by apply/subsetP=> x /[!(inE, linearD)]/= /andP[/eqP-> /eqP->]. Qed. Lemma inertia_sum I r (P : pred I) (Phi : I -> 'CF(H)) : 'N(H) :&: \bigcap_(i <- r | P i) 'I[Phi i] \subset 'I[\sum_(i <- r | P i) Phi i]. Proof. elim/big_rec2: _ => [|i K psi Pi sK_Ipsi]; first by rewrite setIT inertia0. by rewrite setICA; apply: subset_trans (setIS _ sK_Ipsi) (inertia_add _ _). Qed. Lemma inertia_scale a phi : 'I[phi] \subset 'I[a *: phi]. Proof. apply/subsetP=> x /setIdP[nHx /eqP Iphi_x]. by rewrite inE nHx linearZ /= Iphi_x. Qed. Lemma inertia_scale_nz a phi : a != 0 -> 'I[a *: phi] = 'I[phi]. Proof. move=> nz_a; apply/eqP. by rewrite eqEsubset -{2}(scalerK nz_a phi) !inertia_scale. Qed. Lemma inertia_opp phi : 'I[- phi] = 'I[phi]. Proof. by rewrite -scaleN1r inertia_scale_nz // oppr_eq0 oner_eq0. Qed. Lemma inertia1 : 'I[1 : 'CF(H)] = 'N(H). Proof. by apply/setP=> x; rewrite inE rmorph1 eqxx andbT. Qed. Lemma Inertia1 : H <| G -> 'I_G[1 : 'CF(H)] = G. Proof. by rewrite inertia1 => /normal_norm/setIidPl. Qed. Lemma inertia_mul phi psi : 'I[phi] :&: 'I[psi] \subset 'I[phi * psi]. Proof. rewrite !['I[_]]setIdE -setIIr setIS //. by apply/subsetP=> x /[!(inE, rmorphM)]/= /andP[/eqP-> /eqP->]. Qed. Lemma inertia_prod I r (P : pred I) (Phi : I -> 'CF(H)) : 'N(H) :&: \bigcap_(i <- r | P i) 'I[Phi i] \subset 'I[\prod_(i <- r | P i) Phi i]. Proof. elim/big_rec2: _ => [|i K psi Pi sK_psi]; first by rewrite inertia1 setIT. by rewrite setICA; apply: subset_trans (setIS _ sK_psi) (inertia_mul _ _). Qed. Lemma inertia_injective (chi : 'CF(H)) : {in H &, injective chi} -> 'I[chi] = 'C(H). Proof. move=> inj_chi; apply/eqP; rewrite eqEsubset cent_sub_inertia andbT. apply/subsetP=> y Ichi_y; have /setIdP[nHy _] := Ichi_y. apply/centP=> x Hx; apply/esym/commgP/conjg_fixP. by apply/inj_chi; rewrite ?memJ_norm ?(inertia_valJ _ Ichi_y). Qed. Lemma inertia_irr_prime p i : #|H| = p -> prime p -> i != 0 -> 'I['chi[H]_i] = 'C(H). Proof. by move=> <- pr_H /(irr_prime_injP pr_H); apply: inertia_injective. Qed. Lemma inertia_irr0 : 'I['chi[H]_0] = 'N(H). Proof. by rewrite irr0 inertia1. Qed. (* Isaacs' 6.1.c *) Lemma cfConjg_iso y : isometry (cfConjg y : 'CF(H) -> 'CF(H)). Proof. move=> phi psi; congr (_ * _). have [nHy | not_nHy] := boolP (y \in 'N(H)); last by rewrite !cfConjgEout. rewrite (reindex_astabs 'J y) ?astabsJ //=. by apply: eq_bigr=> x _; rewrite !cfConjgEJ. Qed. (* Isaacs' 6.1.d *) Lemma cfdot_Res_conjg psi phi y : y \in G -> '['Res[H, G] psi, phi ^ y] = '['Res[H] psi, phi]. Proof. move=> Gy; rewrite -(cfConjg_iso y _ phi); congr '[_, _]; apply/cfunP=> x. rewrite !cfunElock !genGid; case nHy: (y \in 'N(H)) => //. by rewrite !(fun_if psi) cfunJ ?memJ_norm ?groupV. Qed. (* Isaac's 6.1.e *) Lemma cfConjg_char (chi : 'CF(H)) y : chi \is a character -> (chi ^ y)%CF \is a character. Proof. have [nHy Nchi | /cfConjgEout-> //] := boolP (y \in 'N(H)). by rewrite cfConjgEin cfIsom_char. Qed. Lemma cfConjg_lin_char (chi : 'CF(H)) y : chi \is a linear_char -> (chi ^ y)%CF \is a linear_char. Proof. by case/andP=> Nchi chi1; rewrite qualifE/= cfConjg1 cfConjg_char. Qed. Lemma cfConjg_irr y chi : chi \in irr H -> (chi ^ y)%CF \in irr H. Proof. by rewrite !irrEchar cfConjg_iso => /andP[/cfConjg_char->]. Qed. Definition conjg_Iirr i y := cfIirr ('chi[H]_i ^ y)%CF. Lemma conjg_IirrE i y : 'chi_(conjg_Iirr i y) = ('chi_i ^ y)%CF. Proof. by rewrite cfIirrE ?cfConjg_irr ?mem_irr. Qed. Lemma conjg_IirrK y : cancel (conjg_Iirr^~ y) (conjg_Iirr^~ y^-1%g). Proof. by move=> i; apply/irr_inj; rewrite !conjg_IirrE cfConjgK. Qed. Lemma conjg_IirrKV y : cancel (conjg_Iirr^~ y^-1%g) (conjg_Iirr^~ y). Proof. by rewrite -{2}[y]invgK; apply: conjg_IirrK. Qed. Lemma conjg_Iirr_inj y : injective (conjg_Iirr^~ y). Proof. exact: can_inj (conjg_IirrK y). Qed. Lemma conjg_Iirr_eq0 i y : (conjg_Iirr i y == 0) = (i == 0). Proof. by rewrite -!irr_eq1 conjg_IirrE cfConjg_eq1. Qed. Lemma conjg_Iirr0 x : conjg_Iirr 0 x = 0. Proof. by apply/eqP; rewrite conjg_Iirr_eq0. Qed. Lemma cfdot_irr_conjg i y : H <| G -> y \in G -> '['chi_i, 'chi_i ^ y]_H = (y \in 'I_G['chi_i])%:R. Proof. move=> nsHG Gy; rewrite -conjg_IirrE cfdot_irr -(inj_eq irr_inj) conjg_IirrE. by rewrite -{1}['chi_i]cfConjgJ1 cfConjg_eqE ?mulg1. Qed. Definition cfclass (A : {set gT}) (phi : 'CF(A)) (B : {set gT}) := [seq (phi ^ repr Tx)%CF | Tx in rcosets 'I_B[phi] B]. Local Notation "phi ^: G" := (cfclass phi G) : cfun_scope. Lemma size_cfclass i : size ('chi[H]_i ^: G)%CF = #|G : 'I_G['chi_i]|. Proof. by rewrite size_map -cardE. Qed. Lemma cfclassP (A : {group gT}) phi psi : reflect (exists2 y, y \in A & psi = phi ^ y)%CF (psi \in phi ^: A)%CF. Proof. apply: (iffP imageP) => [[_ /rcosetsP[y Ay ->] ->] | [y Ay ->]]. by case: repr_rcosetP => z /setIdP[Az _]; exists (z * y)%g; rewrite ?groupM. without loss nHy: y Ay / y \in 'N(H). have [nHy | /cfConjgEout->] := boolP (y \in 'N(H)); first exact. by move/(_ 1%g); rewrite !group1 !cfConjgJ1; apply. exists ('I_A[phi] :* y); first by rewrite -rcosetE imset_f. case: repr_rcosetP => z /setIP[_ /setIdP[nHz /eqP Tz]]. by rewrite cfConjgMnorm ?Tz. Qed. Lemma cfclassInorm phi : (phi ^: 'N_G(H) =i phi ^: G)%CF. Proof. move=> xi; apply/cfclassP/cfclassP=> [[x /setIP[Gx _] ->] | [x Gx ->]]. by exists x. have [Nx | /cfConjgEout-> //] := boolP (x \in 'N(H)). by exists x; first apply/setIP. by exists 1%g; rewrite ?group1 ?cfConjgJ1. Qed. Lemma cfclass_refl phi : phi \in (phi ^: G)%CF. Proof. by apply/cfclassP; exists 1%g => //; rewrite cfConjgJ1. Qed. Lemma cfclass_transr phi psi : (psi \in phi ^: G)%CF -> (phi ^: G =i psi ^: G)%CF. Proof. rewrite -cfclassInorm; case/cfclassP=> x Gx -> xi; rewrite -!cfclassInorm. have nHN: {subset 'N_G(H) <= 'N(H)} by apply/subsetP; apply: subsetIr. apply/cfclassP/cfclassP=> [[y Gy ->] | [y Gy ->]]. by exists (x^-1 * y)%g; rewrite -?cfConjgMnorm ?groupM ?groupV ?nHN // mulKVg. by exists (x * y)%g; rewrite -?cfConjgMnorm ?groupM ?nHN. Qed. Lemma cfclass_sym phi psi : (psi \in phi ^: G)%CF = (phi \in psi ^: G)%CF. Proof. by apply/idP/idP=> /cfclass_transr <-; apply: cfclass_refl. Qed. Lemma cfclass_uniq phi : H <| G -> uniq (phi ^: G)%CF. Proof. move=> nsHG; rewrite map_inj_in_uniq ?enum_uniq // => Ty Tz; rewrite !mem_enum. move=> {Ty}/rcosetsP[y Gy ->] {Tz}/rcosetsP[z Gz ->] /eqP. case: repr_rcosetP => u Iphi_u; case: repr_rcosetP => v Iphi_v. have [[Gu _] [Gv _]] := (setIdP Iphi_u, setIdP Iphi_v). rewrite cfConjg_eqE ?groupM // => /rcoset_eqP. by rewrite !rcosetM (rcoset_id Iphi_v) (rcoset_id Iphi_u). Qed. Lemma cfclass_invariant phi : G \subset 'I[phi] -> (phi ^: G)%CF = phi. Proof. move/setIidPl=> IGphi; rewrite /cfclass IGphi // rcosets_id. by rewrite /(image _ _) enum_set1 /= repr_group cfConjgJ1. Qed. Lemma cfclass1 : H <| G -> (1 ^: G)%CF = [:: 1 : 'CF(H)]. Proof. by move/normal_norm=> nHG; rewrite cfclass_invariant ?inertia1. Qed. Definition cfclass_Iirr (A : {set gT}) i := conjg_Iirr i @: A. Lemma cfclass_IirrE i j : (j \in cfclass_Iirr G i) = ('chi_j \in 'chi_i ^: G)%CF. Proof. apply/imsetP/cfclassP=> [[y Gy ->] | [y]]; exists y; rewrite ?conjg_IirrE //. by apply: irr_inj; rewrite conjg_IirrE. Qed. Lemma eq_cfclass_IirrE i j : (cfclass_Iirr G j == cfclass_Iirr G i) = (j \in cfclass_Iirr G i). Proof. apply/eqP/idP=> [<- | iGj]; first by rewrite cfclass_IirrE cfclass_refl. by apply/setP=> k; rewrite !cfclass_IirrE in iGj *; apply/esym/cfclass_transr. Qed. Lemma im_cfclass_Iirr i : H <| G -> perm_eq [seq 'chi_j | j in cfclass_Iirr G i] ('chi_i ^: G)%CF. Proof. move=> nsHG; have UchiG := cfclass_uniq 'chi_i nsHG. apply: uniq_perm; rewrite ?(map_inj_uniq irr_inj) ?enum_uniq // => phi. apply/imageP/idP=> [[j iGj ->] | /cfclassP[y]]; first by rewrite -cfclass_IirrE. by exists (conjg_Iirr i y); rewrite ?imset_f ?conjg_IirrE. Qed. Lemma card_cfclass_Iirr i : H <| G -> #|cfclass_Iirr G i| = #|G : 'I_G['chi_i]|. Proof. move=> nsHG; rewrite -size_cfclass -(perm_size (im_cfclass_Iirr i nsHG)). by rewrite size_map -cardE. Qed. Lemma reindex_cfclass R idx (op : Monoid.com_law idx) (F : 'CF(H) -> R) i : H <| G -> \big[op/idx]_(chi <- ('chi_i ^: G)%CF) F chi = \big[op/idx]_(j | 'chi_j \in ('chi_i ^: G)%CF) F 'chi_j. Proof. move/im_cfclass_Iirr/(perm_big _) <-; rewrite big_image /=. by apply: eq_bigl => j; rewrite cfclass_IirrE. Qed. Lemma cfResInd j: H <| G -> 'Res[H] ('Ind[G] 'chi_j) = #|H|%:R^-1 *: (\sum_(y in G) 'chi_j ^ y)%CF. Proof. case/andP=> [sHG /subsetP nHG]. rewrite (reindex_inj invg_inj); apply/cfun_inP=> x Hx. rewrite cfResE // cfIndE // ?cfunE ?sum_cfunE; congr (_ * _). by apply: eq_big => [y | y Gy]; rewrite ?cfConjgE ?groupV ?invgK ?nHG. Qed. (* This is Isaacs, Theorem (6.2) *) Lemma Clifford_Res_sum_cfclass i j : H <| G -> j \in irr_constt ('Res[H, G] 'chi_i) -> 'Res[H] 'chi_i = '['Res[H] 'chi_i, 'chi_j] *: (\sum_(chi <- ('chi_j ^: G)%CF) chi). Proof. move=> nsHG chiHj; have [sHG /subsetP nHG] := andP nsHG. rewrite reindex_cfclass //= big_mkcond. rewrite {1}['Res _]cfun_sum_cfdot linear_sum /=; apply: eq_bigr => k _. have [[y Gy ->] | ] := altP (cfclassP _ _ _); first by rewrite cfdot_Res_conjg. apply: contraNeq; rewrite scaler0 scaler_eq0 orbC => /norP[_ chiHk]. have{chiHk chiHj}: '['Res[H] ('Ind[G] 'chi_j), 'chi_k] != 0. rewrite !inE !cfdot_Res_l in chiHj chiHk *. apply: contraNneq chiHk; rewrite cfdot_sum_irr => /psumr_eq0P/(_ i isT)/eqP. rewrite -cfdotC cfdotC mulf_eq0 conjC_eq0 (negbTE chiHj) /= => -> // i1. by rewrite -cfdotC natr_ge0 // rpredM ?Cnat_cfdot_char ?cfInd_char ?irr_char. rewrite cfResInd // cfdotZl mulf_eq0 cfdot_suml => /norP[_]. apply: contraR => chiGk'j; rewrite big1 // => x Gx; apply: contraNeq chiGk'j. rewrite -conjg_IirrE cfdot_irr pnatr_eq0; case: (_ =P k) => // <- _. by rewrite conjg_IirrE; apply/cfclassP; exists x. Qed. Lemma cfRes_Ind_invariant psi : H <| G -> G \subset 'I[psi] -> 'Res ('Ind[G, H] psi) = #|G : H|%:R *: psi. Proof. case/andP=> sHG _ /subsetP IGpsi; apply/cfun_inP=> x Hx. rewrite cfResE ?cfIndE ?natf_indexg // cfunE -mulrA mulrCA; congr (_ * _). by rewrite mulr_natl -sumr_const; apply: eq_bigr => y /IGpsi/inertia_valJ->. Qed. (* This is Isaacs, Corollary (6.7). *) Corollary constt0_Res_cfker i : H <| G -> 0 \in irr_constt ('Res[H] 'chi[G]_i) -> H \subset cfker 'chi[G]_i. Proof. move=> nsHG /(Clifford_Res_sum_cfclass nsHG); have [sHG nHG] := andP nsHG. rewrite irr0 cfdot_Res_l cfclass1 // big_seq1 cfInd_cfun1 //. rewrite cfdotZr conjC_nat => def_chiH. apply/subsetP=> x Hx; rewrite cfkerEirr inE -!(cfResE _ sHG) //. by rewrite def_chiH !cfunE cfun11 cfun1E Hx. Qed. (* This is Isaacs, Lemma (6.8). *) Lemma dvdn_constt_Res1_irr1 i j : H <| G -> j \in irr_constt ('Res[H, G] 'chi_i) -> exists n, 'chi_i 1%g = n%:R * 'chi_j 1%g. Proof. move=> nsHG chiHj; have [sHG nHG] := andP nsHG; rewrite -(cfResE _ sHG) //. rewrite {1}(Clifford_Res_sum_cfclass nsHG chiHj) cfunE sum_cfunE. have /natrP[n ->]: '['Res[H] 'chi_i, 'chi_j] \in Num.nat. by rewrite Cnat_cfdot_char ?cfRes_char ?irr_char. exists (n * size ('chi_j ^: G)%CF)%N; rewrite natrM -mulrA; congr (_ * _). rewrite mulr_natl -[size _]card_ord big_tnth -sumr_const; apply: eq_bigr => k _. by have /cfclassP[y Gy ->]:= mem_tnth k (in_tuple _); rewrite cfConjg1. Qed. Lemma cfclass_Ind phi psi : H <| G -> psi \in (phi ^: G)%CF -> 'Ind[G] phi = 'Ind[G] psi. Proof. move=> nsHG /cfclassP[y Gy ->]; have [sHG /subsetP nHG] := andP nsHG. apply/cfun_inP=> x Hx; rewrite !cfIndE //; congr (_ * _). rewrite (reindex_acts 'R _ (groupVr Gy)) ?astabsR //=. by apply: eq_bigr => z Gz; rewrite conjgM cfConjgE ?nHG. Qed. End Inertia. Arguments inertia {gT B%_g} phi%_CF. Arguments cfclass {gT A%_g} phi%_CF B%_g. Arguments conjg_Iirr_inj {gT H} y [i1 i2] : rename. Notation "''I[' phi ] " := (inertia phi) : group_scope. Notation "''I[' phi ] " := (inertia_group phi) : Group_scope. Notation "''I_' G [ phi ] " := (G%g :&: 'I[phi]) : group_scope. Notation "''I_' G [ phi ] " := (G :&: 'I[phi])%G : Group_scope. Notation "phi ^: G" := (cfclass phi G) : cfun_scope. Section ConjRestrict. Variables (gT : finGroupType) (G H K : {group gT}). Lemma cfConjgRes_norm phi y : y \in 'N(K) -> y \in 'N(H) -> ('Res[K, H] phi ^ y)%CF = 'Res (phi ^ y)%CF. Proof. move=> nKy nHy; have [sKH | not_sKH] := boolP (K \subset H); last first. by rewrite !cfResEout // rmorph_alg cfConjg1. by apply/cfun_inP=> x Kx; rewrite !(cfConjgE, cfResE) ?memJ_norm ?groupV. Qed. Lemma cfConjgRes phi y : H <| G -> K <| G -> y \in G -> ('Res[K, H] phi ^ y)%CF = 'Res (phi ^ y)%CF. Proof. move=> /andP[_ nHG] /andP[_ nKG] Gy. by rewrite cfConjgRes_norm ?(subsetP nHG) ?(subsetP nKG). Qed. Lemma sub_inertia_Res phi : G \subset 'N(K) -> 'I_G[phi] \subset 'I_G['Res[K, H] phi]. Proof. move=> nKG; apply/subsetP=> y /setIP[Gy /setIdP[nHy /eqP Iphi_y]]. by rewrite 2!inE Gy cfConjgRes_norm ?(subsetP nKG) ?Iphi_y /=. Qed. Lemma cfConjgInd_norm phi y : y \in 'N(K) -> y \in 'N(H) -> ('Ind[H, K] phi ^ y)%CF = 'Ind (phi ^ y)%CF. Proof. move=> nKy nHy; have [sKH | not_sKH] := boolP (K \subset H). by rewrite !cfConjgEin (cfIndIsom (norm_conj_isom nHy)). rewrite !cfIndEout // linearZ -(cfConjg_iso y) rmorph1 /=; congr (_ *: _). by rewrite cfConjg_cfuni ?norm1 ?inE. Qed. Lemma cfConjgInd phi y : H <| G -> K <| G -> y \in G -> ('Ind[H, K] phi ^ y)%CF = 'Ind (phi ^ y)%CF. Proof. move=> /andP[_ nHG] /andP[_ nKG] Gy. by rewrite cfConjgInd_norm ?(subsetP nHG) ?(subsetP nKG). Qed. Lemma sub_inertia_Ind phi : G \subset 'N(H) -> 'I_G[phi] \subset 'I_G['Ind[H, K] phi]. Proof. move=> nHG; apply/subsetP=> y /setIP[Gy /setIdP[nKy /eqP Iphi_y]]. by rewrite 2!inE Gy cfConjgInd_norm ?(subsetP nHG) ?Iphi_y /=. Qed. End ConjRestrict. Section MoreInertia. Variables (gT : finGroupType) (G H : {group gT}) (i : Iirr H). Let T := 'I_G['chi_i]. Lemma inertia_id : 'I_T['chi_i] = T. Proof. by rewrite -setIA setIid. Qed. Lemma cfclass_inertia : ('chi[H]_i ^: T)%CF = [:: 'chi_i]. Proof. rewrite /cfclass inertia_id rcosets_id /(image _ _) enum_set1 /=. by rewrite repr_group cfConjgJ1. Qed. End MoreInertia. Section ConjMorph. Variables (aT rT : finGroupType) (D G H : {group aT}) (f : {morphism D >-> rT}). Lemma cfConjgMorph (phi : 'CF(f @* H)) y : y \in D -> y \in 'N(H) -> (cfMorph phi ^ y)%CF = cfMorph (phi ^ f y). Proof. move=> Dy nHy; have [sHD | not_sHD] := boolP (H \subset D); last first. by rewrite !cfMorphEout // rmorph_alg cfConjg1. apply/cfun_inP=> x Gx; rewrite !(cfConjgE, cfMorphE) ?memJ_norm ?groupV //. by rewrite morphJ ?morphV ?groupV // (subsetP sHD). by rewrite (subsetP (morphim_norm _ _)) ?mem_morphim. Qed. Lemma inertia_morph_pre (phi : 'CF(f @* H)) : H <| G -> G \subset D -> 'I_G[cfMorph phi] = G :&: f @*^-1 'I_(f @* G)[phi]. Proof. case/andP=> sHG nHG sGD; have sHD := subset_trans sHG sGD. apply/setP=> y; rewrite !in_setI; apply: andb_id2l => Gy. have [Dy nHy] := (subsetP sGD y Gy, subsetP nHG y Gy). rewrite Dy inE nHy 4!inE mem_morphim // -morphimJ ?(normP nHy) // subxx /=. rewrite cfConjgMorph //; apply/eqP/eqP=> [Iphi_y | -> //]. by apply/cfun_inP=> _ /morphimP[x Dx Hx ->]; rewrite -!cfMorphE ?Iphi_y. Qed. Lemma inertia_morph_im (phi : 'CF(f @* H)) : H <| G -> G \subset D -> f @* 'I_G[cfMorph phi] = 'I_(f @* G)[phi]. Proof. move=> nsHG sGD; rewrite inertia_morph_pre // morphim_setIpre. by rewrite (setIidPr _) ?Inertia_sub. Qed. Variables (R S : {group rT}). Variables (g : {morphism G >-> rT}) (h : {morphism H >-> rT}). Hypotheses (isoG : isom G R g) (isoH : isom H S h). Hypotheses (eq_hg : {in H, h =1 g}) (sHG : H \subset G). (* This does not depend on the (isoG : isom G R g) assumption. *) Lemma cfConjgIsom phi y : y \in G -> y \in 'N(H) -> (cfIsom isoH phi ^ g y)%CF = cfIsom isoH (phi ^ y). Proof. move=> Gy nHy; have [_ defS] := isomP isoH. rewrite morphimEdom (eq_in_imset eq_hg) -morphimEsub // in defS. apply/cfun_inP=> gx; rewrite -{1}defS => /morphimP[x Gx Hx ->] {gx}. rewrite cfConjgE; last by rewrite -defS inE -morphimJ ?(normP nHy). by rewrite -morphV -?morphJ -?eq_hg ?cfIsomE ?cfConjgE ?memJ_norm ?groupV. Qed. Lemma inertia_isom phi : 'I_R[cfIsom isoH phi] = g @* 'I_G[phi]. Proof. have [[_ defS] [injg <-]] := (isomP isoH, isomP isoG). rewrite morphimEdom (eq_in_imset eq_hg) -morphimEsub // in defS. rewrite /inertia !setIdE morphimIdom setIA -{1}defS -injm_norm ?injmI //. apply/setP=> gy /[!inE]; apply: andb_id2l => /morphimP[y Gy nHy ->] {gy}. rewrite cfConjgIsom // -sub1set -morphim_set1 // injmSK ?sub1set //= inE. apply/eqP/eqP=> [Iphi_y | -> //]. by apply/cfun_inP=> x Hx; rewrite -!(cfIsomE isoH) ?Iphi_y. Qed. End ConjMorph. Section ConjQuotient. Variables gT : finGroupType. Implicit Types G H K : {group gT}. Lemma cfConjgMod_norm H K (phi : 'CF(H / K)) y : y \in 'N(K) -> y \in 'N(H) -> ((phi %% K) ^ y)%CF = (phi ^ coset K y %% K)%CF. Proof. exact: cfConjgMorph. Qed. Lemma cfConjgMod G H K (phi : 'CF(H / K)) y : H <| G -> K <| G -> y \in G -> ((phi %% K) ^ y)%CF = (phi ^ coset K y %% K)%CF. Proof. move=> /andP[_ nHG] /andP[_ nKG] Gy. by rewrite cfConjgMod_norm ?(subsetP nHG) ?(subsetP nKG). Qed. Lemma cfConjgQuo_norm H K (phi : 'CF(H)) y : y \in 'N(K) -> y \in 'N(H) -> ((phi / K) ^ coset K y)%CF = (phi ^ y / K)%CF. Proof. move=> nKy nHy; have keryK: (K \subset cfker (phi ^ y)) = (K \subset cfker phi). by rewrite cfker_conjg // -{1}(normP nKy) conjSg. have [kerK | not_kerK] := boolP (K \subset cfker phi); last first. by rewrite !cfQuoEout ?rmorph_alg ?cfConjg1 ?keryK. apply/cfun_inP=> _ /morphimP[x nKx Hx ->]. have nHyb: coset K y \in 'N(H / K) by rewrite inE -morphimJ ?(normP nHy). rewrite !(cfConjgE, cfQuoEnorm) ?keryK // ?in_setI ?Hx //. rewrite -morphV -?morphJ ?groupV // cfQuoEnorm //. by rewrite inE memJ_norm ?Hx ?groupJ ?groupV. Qed. Lemma cfConjgQuo G H K (phi : 'CF(H)) y : H <| G -> K <| G -> y \in G -> ((phi / K) ^ coset K y)%CF = (phi ^ y / K)%CF. Proof. move=> /andP[_ nHG] /andP[_ nKG] Gy. by rewrite cfConjgQuo_norm ?(subsetP nHG) ?(subsetP nKG). Qed. Lemma inertia_mod_pre G H K (phi : 'CF(H / K)) : H <| G -> K <| G -> 'I_G[phi %% K] = G :&: coset K @*^-1 'I_(G / K)[phi]. Proof. by move=> nsHG /andP[_]; apply: inertia_morph_pre. Qed. Lemma inertia_mod_quo G H K (phi : 'CF(H / K)) : H <| G -> K <| G -> ('I_G[phi %% K] / K)%g = 'I_(G / K)[phi]. Proof. by move=> nsHG /andP[_]; apply: inertia_morph_im. Qed. Lemma inertia_quo G H K (phi : 'CF(H)) : H <| G -> K <| G -> K \subset cfker phi -> 'I_(G / K)[phi / K] = ('I_G[phi] / K)%g. Proof. move=> nsHG nsKG kerK; rewrite -inertia_mod_quo ?cfQuoK //. by rewrite (normalS _ (normal_sub nsHG)) // (subset_trans _ (cfker_sub phi)). Qed. End ConjQuotient. Section InertiaSdprod. Variables (gT : finGroupType) (K H G : {group gT}). Hypothesis defG : K ><| H = G. Lemma cfConjgSdprod phi y : y \in 'N(K) -> y \in 'N(H) -> (cfSdprod defG phi ^ y = cfSdprod defG (phi ^ y))%CF. Proof. move=> nKy nHy. have nGy: y \in 'N(G) by rewrite -sub1set -(sdprodW defG) normsM ?sub1set. rewrite -{2}[phi](cfSdprodK defG) cfConjgRes_norm // cfRes_sdprodK //. by rewrite cfker_conjg // -{1}(normP nKy) conjSg cfker_sdprod. Qed. Lemma inertia_sdprod (L : {group gT}) phi : L \subset 'N(K) -> L \subset 'N(H) -> 'I_L[cfSdprod defG phi] = 'I_L[phi]. Proof. move=> nKL nHL; have nGL: L \subset 'N(G) by rewrite -(sdprodW defG) normsM. apply/setP=> z; rewrite !in_setI ![z \in 'I[_]]inE; apply: andb_id2l => Lz. rewrite cfConjgSdprod ?(subsetP nKL) ?(subsetP nHL) ?(subsetP nGL) //=. by rewrite (can_eq (cfSdprodK defG)). Qed. End InertiaSdprod. Section InertiaDprod. Variables (gT : finGroupType) (G K H : {group gT}). Implicit Type L : {group gT}. Hypothesis KxH : K \x H = G. Lemma cfConjgDprodl phi y : y \in 'N(K) -> y \in 'N(H) -> (cfDprodl KxH phi ^ y = cfDprodl KxH (phi ^ y))%CF. Proof. by move=> nKy nHy; apply: cfConjgSdprod. Qed. Lemma cfConjgDprodr psi y : y \in 'N(K) -> y \in 'N(H) -> (cfDprodr KxH psi ^ y = cfDprodr KxH (psi ^ y))%CF. Proof. by move=> nKy nHy; apply: cfConjgSdprod. Qed. Lemma cfConjgDprod phi psi y : y \in 'N(K) -> y \in 'N(H) -> (cfDprod KxH phi psi ^ y = cfDprod KxH (phi ^ y) (psi ^ y))%CF. Proof. by move=> nKy nHy; rewrite rmorphM /= cfConjgDprodl ?cfConjgDprodr. Qed. Lemma inertia_dprodl L phi : L \subset 'N(K) -> L \subset 'N(H) -> 'I_L[cfDprodl KxH phi] = 'I_L[phi]. Proof. by move=> nKL nHL; apply: inertia_sdprod. Qed. Lemma inertia_dprodr L psi : L \subset 'N(K) -> L \subset 'N(H) -> 'I_L[cfDprodr KxH psi] = 'I_L[psi]. Proof. by move=> nKL nHL; apply: inertia_sdprod. Qed. Lemma inertia_dprod L (phi : 'CF(K)) (psi : 'CF(H)) : L \subset 'N(K) -> L \subset 'N(H) -> phi 1%g != 0 -> psi 1%g != 0 -> 'I_L[cfDprod KxH phi psi] = 'I_L[phi] :&: 'I_L[psi]. Proof. move=> nKL nHL nz_phi nz_psi; apply/eqP; rewrite eqEsubset subsetI. rewrite -{1}(inertia_scale_nz psi nz_phi) -{1}(inertia_scale_nz phi nz_psi). rewrite -(cfDprod_Resl KxH) -(cfDprod_Resr KxH) !sub_inertia_Res //=. by rewrite -inertia_dprodl -?inertia_dprodr // -setIIr setIS ?inertia_mul. Qed. Lemma inertia_dprod_irr L i j : L \subset 'N(K) -> L \subset 'N(H) -> 'I_L[cfDprod KxH 'chi_i 'chi_j] = 'I_L['chi_i] :&: 'I_L['chi_j]. Proof. by move=> nKL nHL; rewrite inertia_dprod ?irr1_neq0. Qed. End InertiaDprod. Section InertiaBigdprod. Variables (gT : finGroupType) (I : finType) (P : pred I). Variables (A : I -> {group gT}) (G : {group gT}). Implicit Type L : {group gT}. Hypothesis defG : \big[dprod/1%g]_(i | P i) A i = G. Section ConjBig. Variable y : gT. Hypothesis nAy: forall i, P i -> y \in 'N(A i). Lemma cfConjgBigdprodi i (phi : 'CF(A i)) : (cfBigdprodi defG phi ^ y = cfBigdprodi defG (phi ^ y))%CF. Proof. rewrite cfConjgDprodl; try by case: ifP => [/nAy// | _]; rewrite norm1 inE. congr (cfDprodl _ _); case: ifP => [Pi | _]. by rewrite cfConjgRes_norm ?nAy. by apply/cfun_inP=> _ /set1P->; rewrite !(cfRes1, cfConjg1). rewrite -sub1set norms_gen ?norms_bigcup // sub1set. by apply/bigcapP=> j /andP[/nAy]. Qed. Lemma cfConjgBigdprod phi : (cfBigdprod defG phi ^ y = cfBigdprod defG (fun i => phi i ^ y))%CF. Proof. by rewrite rmorph_prod /=; apply: eq_bigr => i _; apply: cfConjgBigdprodi. Qed. End ConjBig. Section InertiaBig. Variable L : {group gT}. Hypothesis nAL : forall i, P i -> L \subset 'N(A i). Lemma inertia_bigdprodi i (phi : 'CF(A i)) : P i -> 'I_L[cfBigdprodi defG phi] = 'I_L[phi]. Proof. move=> Pi; rewrite inertia_dprodl ?Pi ?cfRes_id ?nAL //. by apply/norms_gen/norms_bigcup/bigcapsP=> j /andP[/nAL]. Qed. Lemma inertia_bigdprod phi (Phi := cfBigdprod defG phi) : Phi 1%g != 0 -> 'I_L[Phi] = L :&: \bigcap_(i | P i) 'I_L[phi i]. Proof. move=> nz_Phi; apply/eqP; rewrite eqEsubset; apply/andP; split. rewrite subsetI Inertia_sub; apply/bigcapsP=> i Pi. have [] := cfBigdprodK nz_Phi Pi; move: (_ / _) => a nz_a <-. by rewrite inertia_scale_nz ?sub_inertia_Res //= ?nAL. rewrite subsetI subsetIl; apply: subset_trans (inertia_prod _ _ _). apply: setISS. by rewrite -(bigdprodWY defG) norms_gen ?norms_bigcup //; apply/bigcapsP. apply/bigcapsP=> i Pi; rewrite (bigcap_min i) //. by rewrite -inertia_bigdprodi ?subsetIr. Qed. Lemma inertia_bigdprod_irr Iphi (phi := fun i => 'chi_(Iphi i)) : 'I_L[cfBigdprod defG phi] = L :&: \bigcap_(i | P i) 'I_L[phi i]. Proof. rewrite inertia_bigdprod // -[cfBigdprod _ _]cfIirrE ?irr1_neq0 //. by apply: cfBigdprod_irr => i _; apply: mem_irr. Qed. End InertiaBig. End InertiaBigdprod. Section ConsttInertiaBijection. Variables (gT : finGroupType) (H G : {group gT}) (t : Iirr H). Hypothesis nsHG : H <| G. Local Notation theta := 'chi_t. Local Notation T := 'I_G[theta]%G. Local Notation "` 'T'" := 'I_(gval G)[theta] (format "` 'T'") : group_scope. Let calA := irr_constt ('Ind[T] theta). Let calB := irr_constt ('Ind[G] theta). Local Notation AtoB := (Ind_Iirr G). (* This is Isaacs, Theorem (6.11). *) Theorem constt_Inertia_bijection : [/\ (*a*) {in calA, forall s, 'Ind[G] 'chi_s \in irr G}, (*b*) {in calA &, injective (Ind_Iirr G)}, Ind_Iirr G @: calA =i calB, (*c*) {in calA, forall s (psi := 'chi_s) (chi := 'Ind[G] psi), [predI irr_constt ('Res chi) & calA] =i pred1 s} & (*d*) {in calA, forall s (psi := 'chi_s) (chi := 'Ind[G] psi), '['Res psi, theta] = '['Res chi, theta]}]. Proof. have [sHG sTG]: H \subset G /\ T \subset G by rewrite subsetIl normal_sub. have nsHT : H <| T := normal_Inertia theta sHG; have sHT := normal_sub nsHT. have AtoB_P s (psi := 'chi_s) (chi := 'Ind[G] psi): s \in calA -> [/\ chi \in irr G, AtoB s \in calB & '['Res psi, theta] = '['Res chi, theta]]. - rewrite constt_Ind_Res => sHt; have [r sGr] := constt_cfInd_irr s sTG. rewrite constt_Ind_Res. have rTs: s \in irr_constt ('Res[T] 'chi_r) by rewrite -constt_Ind_Res. have NrT: 'Res[T] 'chi_r \is a character by rewrite cfRes_char ?irr_char. have rHt: t \in irr_constt ('Res[H] 'chi_r). by have:= constt_Res_trans NrT rTs sHt; rewrite cfResRes. pose e := '['Res[H] 'chi_r, theta]; set f := '['Res[H] psi, theta]. have DrH: 'Res[H] 'chi_r = e *: \sum_(xi <- (theta ^: G)%CF) xi. exact: Clifford_Res_sum_cfclass. have DpsiH: 'Res[H] psi = f *: theta. rewrite (Clifford_Res_sum_cfclass nsHT sHt). by rewrite cfclass_invariant ?subsetIr ?big_seq1. have ub_chi_r: 'chi_r 1%g <= chi 1%g ?= iff ('chi_r == chi). have Nchi: chi \is a character by rewrite cfInd_char ?irr_char. have [chi1 Nchi1->] := constt_charP _ Nchi sGr. rewrite addrC cfunE -leifBLR subrr eq_sym -subr_eq0 addrK. by split; rewrite ?char1_ge0 // eq_sym char1_eq0. have lb_chi_r: chi 1%g <= 'chi_r 1%g ?= iff (f == e). rewrite cfInd1 // -(cfRes1 H) DpsiH -(cfRes1 H 'chi_r) DrH !cfunE sum_cfunE. rewrite (eq_big_seq (fun _ => theta 1%g)) => [|i]; last first. by case/cfclassP=> y _ ->; rewrite cfConjg1. rewrite reindex_cfclass //= sumr_const -(eq_card (cfclass_IirrE _ _)). rewrite mulr_natl mulrnAr card_cfclass_Iirr //. rewrite (mono_leif (ler_pMn2r (indexg_gt0 G T))). rewrite (mono_leif (ler_pM2r (irr1_gt0 t))); apply: leif_eq. by rewrite /e -(cfResRes _ sHT) ?cfdot_Res_ge_constt. have [_ /esym] := leif_trans ub_chi_r lb_chi_r; rewrite eqxx. by case/andP=> /eqP Dchi /eqP->; rewrite cfIirrE -/chi -?Dchi ?mem_irr. have part_c: {in calA, forall s (chi := 'Ind[G] 'chi_s), [predI irr_constt ('Res[T] chi) & calA] =i pred1 s}. - move=> s As chi s1; have [irr_chi _ /eqP Dchi_theta] := AtoB_P s As. have chiTs: s \in irr_constt ('Res[T] chi). by rewrite irr_consttE cfdot_Res_l irrWnorm ?oner_eq0. apply/andP/eqP=> [[/= chiTs1 As1] | -> //]. apply: contraTeq Dchi_theta => s's1; rewrite lt_eqF // -/chi. have [|phi Nphi DchiT] := constt_charP _ _ chiTs. by rewrite cfRes_char ?cfInd_char ?irr_char. have [|phi1 Nphi1 Dphi] := constt_charP s1 Nphi _. rewrite irr_consttE -(canLR (addKr _) DchiT) addrC cfdotBl cfdot_irr. by rewrite mulrb ifN_eqC ?subr0. rewrite -(cfResRes chi sHT sTG) DchiT Dphi !rmorphD !cfdotDl /=. rewrite -ltrBDl subrr ltr_wpDr ?lt_def //; rewrite natr_ge0 ?Cnat_cfdot_char ?cfRes_char ?irr_char //. by rewrite andbT -irr_consttE -constt_Ind_Res. do [split=> //; try by move=> s /AtoB_P[]] => [s1 s2 As1 As2 | r]. have [[irr_s1G _ _] [irr_s2G _ _]] := (AtoB_P _ As1, AtoB_P _ As2). move/(congr1 (tnth (irr G))); rewrite !cfIirrE // => eq_s12_G. apply/eqP; rewrite -[_ == _]part_c // inE /= As1 -eq_s12_G. by rewrite -As1 [_ && _]part_c // inE /=. apply/imsetP/idP=> [[s /AtoB_P[_ BsG _] -> //] | Br]. have /exists_inP[s rTs As]: [exists s in irr_constt ('Res 'chi_r), s \in calA]. rewrite -negb_forall_in; apply: contra Br => /eqfun_inP => o_tT_rT. rewrite -(cfIndInd _ sTG sHT) -cfdot_Res_r ['Res _]cfun_sum_constt. by rewrite cfdot_sumr big1 // => i rTi; rewrite cfdotZr o_tT_rT ?mulr0. exists s => //; have [/irrP[r1 DsG] _ _] := AtoB_P s As. by apply/eqP; rewrite /AtoB -constt_Ind_Res DsG irrK constt_irr in rTs *. Qed. End ConsttInertiaBijection. Section ExtendInvariantIrr. Variable gT : finGroupType. Implicit Types G H K L M N : {group gT}. Section ConsttIndExtendible. Variables (G N : {group gT}) (t : Iirr N) (c : Iirr G). Let theta := 'chi_t. Let chi := 'chi_c. Definition mul_Iirr b := cfIirr ('chi_b * chi). Definition mul_mod_Iirr (b : Iirr (G / N)) := mul_Iirr (mod_Iirr b). Hypotheses (nsNG : N <| G) (cNt : 'Res[N] chi = theta). Let sNG : N \subset G. Proof. exact: normal_sub. Qed. Let nNG : G \subset 'N(N). Proof. exact: normal_norm. Qed. Lemma extendible_irr_invariant : G \subset 'I[theta]. Proof. apply/subsetP=> y Gy; have nNy := subsetP nNG y Gy. rewrite inE nNy; apply/eqP/cfun_inP=> x Nx; rewrite cfConjgE // -cNt. by rewrite !cfResE ?memJ_norm ?cfunJ ?groupV. Qed. Let IGtheta := extendible_irr_invariant. (* This is Isaacs, Theorem (6.16) *) Theorem constt_Ind_mul_ext f (phi := 'chi_f) (psi := phi * theta) : G \subset 'I[phi] -> psi \in irr N -> let calS := irr_constt ('Ind phi) in [/\ {in calS, forall b, 'chi_b * chi \in irr G}, {in calS &, injective mul_Iirr}, irr_constt ('Ind psi) =i [seq mul_Iirr b | b in calS] & 'Ind psi = \sum_(b in calS) '['Ind phi, 'chi_b] *: 'chi_(mul_Iirr b)]. Proof. move=> IGphi irr_psi calS. have IGpsi: G \subset 'I[psi]. by rewrite (subset_trans _ (inertia_mul _ _)) // subsetI IGphi. pose e b := '['Ind[G] phi, 'chi_b]; pose d b g := '['chi_b * chi, 'chi_g * chi]. have Ne b: e b \in Num.nat by rewrite Cnat_cfdot_char ?cfInd_char ?irr_char. have egt0 b: b \in calS -> e b > 0 by rewrite natr_gt0. have DphiG: 'Ind phi = \sum_(b in calS) e b *: 'chi_b := cfun_sum_constt _. have DpsiG: 'Ind psi = \sum_(b in calS) e b *: 'chi_b * chi. by rewrite /psi -cNt cfIndM // DphiG mulr_suml. pose d_delta := [forall b in calS, forall g in calS, d b g == (b == g)%:R]. have charMchi b: 'chi_b * chi \is a character by rewrite rpredM ?irr_char. have [_]: '['Ind[G] phi] <= '['Ind[G] psi] ?= iff d_delta. pose sum_delta := \sum_(b in calS) e b * \sum_(g in calS) e g * (b == g)%:R. pose sum_d := \sum_(b in calS) e b * \sum_(g in calS) e g * d b g. have ->: '['Ind[G] phi] = sum_delta. rewrite DphiG cfdot_suml; apply: eq_bigr => b _; rewrite cfdotZl cfdot_sumr. by congr (_ * _); apply: eq_bigr => g; rewrite cfdotZr cfdot_irr conj_natr. have ->: '['Ind[G] psi] = sum_d. rewrite DpsiG cfdot_suml; apply: eq_bigr => b _. rewrite -scalerAl cfdotZl cfdot_sumr; congr (_ * _). by apply: eq_bigr => g _; rewrite -scalerAl cfdotZr conj_natr. have eMmono := mono_leif (ler_pM2l (egt0 _ _)). apply: leif_sum => b /eMmono->; apply: leif_sum => g /eMmono->. split; last exact: eq_sym. have /natrP[n Dd]: d b g \in Num.nat by rewrite Cnat_cfdot_char. have [Db | _] := eqP; rewrite Dd leC_nat // -ltC_nat -Dd Db cfnorm_gt0. by rewrite -char1_eq0 // cfunE mulf_neq0 ?irr1_neq0. rewrite -!cfdot_Res_l ?cfRes_Ind_invariant // !cfdotZl cfnorm_irr irrWnorm //. rewrite eqxx => /esym/forall_inP/(_ _ _)/eqfun_inP; rewrite /d /= => Dd. have irrMchi: {in calS, forall b, 'chi_b * chi \in irr G}. by move=> b Sb; rewrite /= irrEchar charMchi Dd ?eqxx. have injMchi: {in calS &, injective mul_Iirr}. move=> b g Sb Sg /(congr1 (fun s => '['chi_s, 'chi_(mul_Iirr g)]))/eqP. by rewrite cfnorm_irr !cfIirrE ?irrMchi ?Dd // pnatr_eq1; case: (b =P g). have{DpsiG} ->: 'Ind psi = \sum_(b in calS) e b *: 'chi_(mul_Iirr b). by rewrite DpsiG; apply: eq_bigr => b Sb; rewrite -scalerAl cfIirrE ?irrMchi. split=> // i; rewrite irr_consttE cfdot_suml; apply/idP/idP=> [|/imageP[b Sb ->]]. apply: contraR => N'i; rewrite big1 // => b Sb. rewrite cfdotZl cfdot_irr mulrb ifN_eqC ?mulr0 //. by apply: contraNneq N'i => ->; apply: image_f. rewrite gt_eqF // (bigD1 b) //= cfdotZl cfnorm_irr mulr1 ltr_wpDr ?egt0 //. apply: sumr_ge0 => g /andP[Sg _]; rewrite cfdotZl cfdot_irr. by rewrite mulr_ge0 ?ler0n ?natr_ge0. Qed. (* This is Isaacs, Corollary (6.17) (due to Gallagher). *) Corollary constt_Ind_ext : [/\ forall b : Iirr (G / N), 'chi_(mod_Iirr b) * chi \in irr G, injective mul_mod_Iirr, irr_constt ('Ind theta) =i codom mul_mod_Iirr & 'Ind theta = \sum_b 'chi_b 1%g *: 'chi_(mul_mod_Iirr b)]. Proof. have IHchi0: G \subset 'I['chi[N]_0] by rewrite inertia_irr0. have [] := constt_Ind_mul_ext IHchi0; rewrite irr0 ?mul1r ?mem_irr //. set psiG := 'Ind 1 => irrMchi injMchi constt_theta {2}->. have dot_psiG b: '[psiG, 'chi_(mod_Iirr b)] = 'chi[G / N]_b 1%g. rewrite mod_IirrE // -cfdot_Res_r cfRes_sub_ker ?cfker_mod //. by rewrite cfdotZr cfnorm1 mulr1 conj_natr ?cfMod1 ?Cnat_irr1. have mem_psiG (b : Iirr (G / N)): mod_Iirr b \in irr_constt psiG. by rewrite irr_consttE dot_psiG irr1_neq0. have constt_psiG b: (b \in irr_constt psiG) = (N \subset cfker 'chi_b). apply/idP/idP=> [psiGb | /quo_IirrK <- //]. by rewrite constt0_Res_cfker // -constt_Ind_Res irr0. split=> [b | b g /injMchi/(can_inj (mod_IirrK nsNG))-> // | b0 | ]. - exact: irrMchi. - rewrite constt_theta. apply/imageP/imageP=> [][b psiGb ->]; last by exists (mod_Iirr b). by exists (quo_Iirr N b) => //; rewrite /mul_mod_Iirr quo_IirrK -?constt_psiG. rewrite (reindex_onto _ _ (in1W (mod_IirrK nsNG))) /=. apply/esym/eq_big => b; first by rewrite constt_psiG quo_IirrKeq. by rewrite -dot_psiG /mul_mod_Iirr => /eqP->. Qed. End ConsttIndExtendible. (* This is Isaacs, Theorem (6.19). *) Theorem invariant_chief_irr_cases G K L s (theta := 'chi[K]_s) : chief_factor G L K -> abelian (K / L) -> G \subset 'I[theta] -> let t := #|K : L| in [\/ 'Res[L] theta \in irr L, exists2 e, exists p, 'Res[L] theta = e%:R *: 'chi_p & (e ^ 2)%N = t | exists2 p, injective p & 'Res[L] theta = \sum_(i < t) 'chi_(p i)]. Proof. case/andP=> /maxgroupP[/andP[ltLK nLG] maxL] nsKG abKbar IGtheta t. have [sKG nKG] := andP nsKG; have sLG := subset_trans (proper_sub ltLK) sKG. have nsLG: L <| G by apply/andP. have nsLK := normalS (proper_sub ltLK) sKG nsLG; have [sLK nLK] := andP nsLK. have [p0 sLp0] := constt_cfRes_irr L s; rewrite -/theta in sLp0. pose phi := 'chi_p0; pose T := 'I_G[phi]. have sTG: T \subset G := subsetIl G _. have /eqP mulKT: (K * T)%g == G. rewrite eqEcard mulG_subG sKG sTG -LagrangeMr -indexgI -(Lagrange sTG) /= -/T. rewrite mulnC leq_mul // setIA (setIidPl sKG) -!size_cfclass // -/phi. rewrite uniq_leq_size ?cfclass_uniq // => _ /cfclassP[x Gx ->]. have: conjg_Iirr p0 x \in irr_constt ('Res theta). have /inertiaJ <-: x \in 'I[theta] := subsetP IGtheta x Gx. by rewrite -(cfConjgRes _ nsKG) // irr_consttE conjg_IirrE // cfConjg_iso. apply: contraR; rewrite -conjg_IirrE // => not_sLp0x. rewrite (Clifford_Res_sum_cfclass nsLK sLp0) cfdotZl cfdot_suml. rewrite big1_seq ?mulr0 // => _ /cfclassP[y Ky ->]; rewrite -conjg_IirrE //. rewrite cfdot_irr mulrb ifN_eq ?(contraNneq _ not_sLp0x) // => <-. by rewrite conjg_IirrE //; apply/cfclassP; exists y. have nsKT_G: K :&: T <| G. rewrite /normal subIset ?sKG // -mulKT setIA (setIidPl sKG) mulG_subG. rewrite normsIG // sub_der1_norm ?subsetIl //. exact: subset_trans (der1_min nLK abKbar) (sub_Inertia _ sLK). have [e DthL]: exists e, 'Res theta = e%:R *: \sum_(xi <- (phi ^: K)%CF) xi. rewrite (Clifford_Res_sum_cfclass nsLK sLp0) -/phi; set e := '[_, _]. exists (Num.truncn e). by rewrite truncnK ?Cnat_cfdot_char ?cfRes_char ?irr_char. have [defKT | ltKT_K] := eqVneq (K :&: T) K; last first. have defKT: K :&: T = L. apply: maxL; last by rewrite subsetI sLK sub_Inertia. by rewrite normal_norm // properEneq ltKT_K subsetIl. have t_cast: size (phi ^: K)%CF = t. by rewrite size_cfclass //= -{2}(setIidPl sKG) -setIA defKT. pose phiKt := Tuple (introT eqP t_cast); pose p i := cfIirr (tnth phiKt i). have pK i: 'chi_(p i) = (phi ^: K)%CF`_i. rewrite cfIirrE; first by rewrite (tnth_nth 0). by have /cfclassP[y _ ->] := mem_tnth i phiKt; rewrite cfConjg_irr ?mem_irr. constructor 3; exists p => [i j /(congr1 (tnth (irr L)))/eqP| ]. by apply: contraTeq; rewrite !pK !nth_uniq ?t_cast ?cfclass_uniq. have{} DthL: 'Res theta = e%:R *: \sum_(i < t) (phi ^: K)%CF`_i. by rewrite DthL (big_nth 0) big_mkord t_cast. suffices /eqP e1: e == 1 by rewrite DthL e1 scale1r; apply: eq_bigr. have Dth1: theta 1%g = e%:R * t%:R * phi 1%g. rewrite -[t]card_ord -mulrA -(cfRes1 L) DthL cfunE; congr (_ * _). rewrite mulr_natl -sumr_const sum_cfunE -t_cast; apply: eq_bigr => i _. by have /cfclassP[y _ ->] := mem_nth 0 (valP i); rewrite cfConjg1. rewrite eqn_leq lt0n (contraNneq _ (irr1_neq0 s)); last first. by rewrite Dth1 => ->; rewrite !mul0r. rewrite -leC_nat -(ler_pM2r (gt0CiG K L)) -/t -(ler_pM2r (irr1_gt0 p0)). rewrite mul1r -Dth1 -cfInd1 //. by rewrite char1_ge_constt ?cfInd_char ?irr_char ?constt_Ind_Res. have IKphi: 'I_K[phi] = K by rewrite -{1}(setIidPl sKG) -setIA. have{} DthL: 'Res[L] theta = e%:R *: phi. by rewrite DthL -[rhs in (_ ^: rhs)%CF]IKphi cfclass_inertia big_seq1. pose mmLth := @mul_mod_Iirr K L s. have linKbar := char_abelianP _ abKbar. have LmodL i: ('chi_i %% L)%CF \is a linear_char := cfMod_lin_char (linKbar i). have mmLthE i: 'chi_(mmLth i) = ('chi_i %% L)%CF * theta. by rewrite cfIirrE ?mod_IirrE // mul_lin_irr ?mem_irr. have mmLthL i: 'Res[L] 'chi_(mmLth i) = 'Res[L] theta. rewrite mmLthE rmorphM /= cfRes_sub_ker ?cfker_mod ?lin_char1 //. by rewrite scale1r mul1r. have [inj_Mphi | /injectivePn[i [j i'j eq_mm_ij]]] := boolP (injectiveb mmLth). suffices /eqP e1: e == 1 by constructor 1; rewrite DthL e1 scale1r mem_irr. rewrite eqn_leq lt0n (contraNneq _ (irr1_neq0 s)); last first. by rewrite -(cfRes1 L) DthL cfunE => ->; rewrite !mul0r. rewrite -leq_sqr -leC_nat natrX -(ler_pM2r (irr1_gt0 p0)) -mulrA mul1r. have ->: e%:R * 'chi_p0 1%g = 'Res[L] theta 1%g by rewrite DthL cfunE. rewrite cfRes1 -(ler_pM2l (gt0CiG K L)) -cfInd1 // -/phi. rewrite -card_quotient // -card_Iirr_abelian // mulr_natl. rewrite ['Ind phi]cfun_sum_cfdot sum_cfunE (bigID [in codom mmLth]) /=. rewrite ler_wpDr ?sumr_ge0 // => [i _|]. by rewrite char1_ge0 ?rpredZ_nat ?Cnat_cfdot_char ?cfInd_char ?irr_char. rewrite -big_uniq //= big_image -sumr_const ler_sum // => i _. rewrite cfunE -[in leRHS](cfRes1 L) -cfdot_Res_r mmLthL cfRes1. by rewrite DthL cfdotZr rmorph_nat cfnorm_irr mulr1. constructor 2; exists e; first by exists p0. pose mu := (('chi_i / 'chi_j)%R %% L)%CF; pose U := cfker mu. have lin_mu: mu \is a linear_char by rewrite cfMod_lin_char ?rpred_div. have Uj := lin_char_unitr (linKbar j). have ltUK: U \proper K. rewrite /proper cfker_sub /U; have /irrP[k Dmu] := lin_char_irr lin_mu. rewrite Dmu subGcfker -irr_eq1 -Dmu cfMod_eq1 //. by rewrite (can2_eq (divrK Uj) (mulrK Uj)) mul1r (inj_eq irr_inj). suffices: theta \in 'CF(K, L). rewrite -cfnorm_Res_leif // DthL cfnormZ !cfnorm_irr !mulr1 normr_nat. by rewrite -natrX eqC_nat => /eqP. have <-: gcore U G = L. apply: maxL; last by rewrite sub_gcore ?cfker_mod. by rewrite gcore_norm (sub_proper_trans (gcore_sub _ _)). apply/cfun_onP=> x; apply: contraNeq => nz_th_x. apply/bigcapP=> y /(subsetP IGtheta)/setIdP[nKy /eqP th_y]. apply: contraR nz_th_x; rewrite mem_conjg -{}th_y cfConjgE {nKy}//. move: {x y}(x ^ _) => x U'x; have [Kx | /cfun0-> //] := boolP (x \in K). have /eqP := congr1 (fun k => (('chi_j %% L)%CF^-1 * 'chi_k) x) eq_mm_ij. rewrite -rmorphV // !mmLthE !mulrA -!rmorphM mulVr // rmorph1 !cfunE. rewrite (mulrC _^-1) -/mu -subr_eq0 -mulrBl cfun1E Kx mulf_eq0 => /orP[]//. rewrite mulrb subr_eq0 -(lin_char1 lin_mu) [_ == _](contraNF _ U'x) //. by rewrite /U cfkerEchar ?lin_charW // inE Kx. Qed. (* This is Isaacs, Corollary (6.19). *) Corollary cfRes_prime_irr_cases G N s p (chi := 'chi[G]_s) : N <| G -> #|G : N| = p -> prime p -> [\/ 'Res[N] chi \in irr N | exists2 c, injective c & 'Res[N] chi = \sum_(i < p) 'chi_(c i)]. Proof. move=> /andP[sNG nNG] iGN pr_p. have chiefGN: chief_factor G N G. apply/andP; split=> //; apply/maxgroupP. split=> [|M /andP[/andP[sMG ltMG] _] sNM]. by rewrite /proper sNG -indexg_gt1 iGN prime_gt1. apply/esym/eqP; rewrite eqEsubset sNM -indexg_eq1 /= eq_sym. rewrite -(eqn_pmul2l (indexg_gt0 G M)) muln1 Lagrange_index // iGN. by apply/eqP/prime_nt_dvdP; rewrite ?indexg_eq1 // -iGN indexgS. have abGbar: abelian (G / N). by rewrite cyclic_abelian ?prime_cyclic ?card_quotient ?iGN. have IGchi: G \subset 'I[chi] by apply: sub_inertia. have [] := invariant_chief_irr_cases chiefGN abGbar IGchi; first by left. case=> e _ /(congr1 (fun m => odd (logn p m)))/eqP/idPn[]. by rewrite lognX mul2n odd_double iGN logn_prime // eqxx. by rewrite iGN; right. Qed. (* This is Isaacs, Corollary (6.20). *) Corollary prime_invariant_irr_extendible G N s p : N <| G -> #|G : N| = p -> prime p -> G \subset 'I['chi_s] -> {t | 'Res[N, G] 'chi_t = 'chi_s}. Proof. move=> nsNG iGN pr_p IGchi. have [t sGt] := constt_cfInd_irr s (normal_sub nsNG); exists t. have [e DtN]: exists e, 'Res 'chi_t = e%:R *: 'chi_s. rewrite constt_Ind_Res in sGt. rewrite (Clifford_Res_sum_cfclass nsNG sGt) cfclass_invariant // big_seq1. set e := '[_, _]; exists (Num.truncn e). by rewrite truncnK ?Cnat_cfdot_char ?cfRes_char ?irr_char. have [/irrWnorm/eqP | [c injc DtNc]] := cfRes_prime_irr_cases t nsNG iGN pr_p. rewrite DtN cfnormZ cfnorm_irr normr_nat mulr1 -natrX pnatr_eq1. by rewrite muln_eq1 andbb => /eqP->; rewrite scale1r. have nz_e: e != 0. have: 'Res[N] 'chi_t != 0 by rewrite cfRes_eq0 // ?irr_char ?irr_neq0. by rewrite DtN; apply: contraNneq => ->; rewrite scale0r. have [i s'ci]: exists i, c i != s. pose i0 := Ordinal (prime_gt0 pr_p); pose i1 := Ordinal (prime_gt1 pr_p). have [<- | ] := eqVneq (c i0) s; last by exists i0. by exists i1; rewrite (inj_eq injc). have /esym/eqP/idPn[] := congr1 (cfdotr 'chi_(c i)) DtNc; rewrite {1}DtN /=. rewrite cfdot_suml cfdotZl cfdot_irr mulrb ifN_eqC // mulr0. rewrite (bigD1 i) //= cfnorm_irr big1 ?addr0 ?oner_eq0 // => j i'j. by rewrite cfdot_irr mulrb ifN_eq ?(inj_eq injc). Qed. (* This is Isaacs, Lemma (6.24). *) Lemma extend_to_cfdet G N s c0 u : let theta := 'chi_s in let lambda := cfDet theta in let mu := 'chi_u in N <| G -> coprime #|G : N| (Num.truncn (theta 1%g)) -> 'Res[N, G] 'chi_c0 = theta -> 'Res[N, G] mu = lambda -> exists2 c, 'Res 'chi_c = theta /\ cfDet 'chi_c = mu & forall c1, 'Res 'chi_c1 = theta -> cfDet 'chi_c1 = mu -> c1 = c. Proof. move=> theta lambda mu nsNG; set e := #|G : N|; set f := Num.truncn _. set eta := 'chi_c0 => co_e_f etaNth muNlam; have [sNG nNG] := andP nsNG. have fE: f%:R = theta 1%g by rewrite truncnK ?Cnat_irr1. pose nu := cfDet eta; have lin_nu: nu \is a linear_char := cfDet_lin_char _. have nuNlam: 'Res nu = lambda by rewrite -cfDetRes ?irr_char ?etaNth. have lin_lam: lambda \is a linear_char := cfDet_lin_char _. have lin_mu: mu \is a linear_char. by have:= lin_lam; rewrite -muNlam; apply: cfRes_lin_lin; apply: irr_char. have [Unu Ulam] := (lin_char_unitr lin_nu, lin_char_unitr lin_lam). pose alpha := mu / nu. have alphaN_1: 'Res[N] alpha = 1 by rewrite rmorph_div //= muNlam nuNlam divrr. have lin_alpha: alpha \is a linear_char by apply: rpred_div. have alpha_e: alpha ^+ e = 1. have kerNalpha: N \subset cfker alpha. by rewrite -subsetIidl -cfker_Res ?lin_charW // alphaN_1 cfker_cfun1. apply/eqP; rewrite -(cfQuoK nsNG kerNalpha) -rmorphXn cfMod_eq1 //. rewrite -dvdn_cforder /e -card_quotient //. by rewrite cforder_lin_char_dvdG ?cfQuo_lin_char. have det_alphaXeta b: cfDet (alpha ^+ b * eta) = alpha ^+ (b * f) * nu. by rewrite cfDet_mul_lin ?rpredX ?irr_char // -exprM -(cfRes1 N) etaNth. have [b bf_mod_e]: exists b, b * f = 1 %[mod e]. rewrite -(chinese_modl co_e_f 1 0) /chinese !mul0n addn0 !mul1n mulnC. by exists (egcdn f e).1. have alpha_bf: alpha ^+ (b * f) = alpha. by rewrite -(expr_mod _ alpha_e) bf_mod_e expr_mod. have /irrP[c Dc]: alpha ^+ b * eta \in irr G. by rewrite mul_lin_irr ?rpredX ?mem_irr. have chiN: 'Res 'chi_c = theta. by rewrite -Dc rmorphM rmorphXn /= alphaN_1 expr1n mul1r. have det_chi: cfDet 'chi_c = mu by rewrite -Dc det_alphaXeta alpha_bf divrK. exists c => // c2 c2Nth det_c2_mu; apply: irr_inj. have [irrMc _ imMc _] := constt_Ind_ext nsNG chiN. have /codomP[s2 Dc2]: c2 \in codom (@mul_mod_Iirr G N c). by rewrite -imMc constt_Ind_Res c2Nth constt_irr ?inE. have{} Dc2: 'chi_c2 = ('chi_s2 %% N)%CF * 'chi_c. by rewrite Dc2 cfIirrE // mod_IirrE. have s2_lin: 'chi_s2 \is a linear_char. rewrite qualifE/= irr_char; apply/eqP/(mulIf (irr1_neq0 c)). rewrite mul1r -[in RHS](cfRes1 N) chiN -c2Nth cfRes1. by rewrite Dc2 cfunE cfMod1. have s2Xf_1: 'chi_s2 ^+ f = 1. apply/(can_inj (cfModK nsNG))/(mulIr (lin_char_unitr lin_mu))/esym. rewrite rmorph1 rmorphXn /= mul1r -{1}det_c2_mu Dc2 -det_chi. by rewrite cfDet_mul_lin ?cfMod_lin_char ?irr_char // -(cfRes1 N) chiN. suffices /eqP s2_1: 'chi_s2 == 1 by rewrite Dc2 s2_1 rmorph1 mul1r. rewrite -['chi_s2]expr1 -dvdn_cforder -(eqnP co_e_f) dvdn_gcd. by rewrite /e -card_quotient ?cforder_lin_char_dvdG //= dvdn_cforder s2Xf_1. Qed. (* This is Isaacs, Theorem (6.25). *) Theorem solvable_irr_extendible_from_det G N s (theta := 'chi[N]_s) : N <| G -> solvable (G / N) -> G \subset 'I[theta] -> coprime #|G : N| (Num.truncn (theta 1%g)) -> [exists c, 'Res 'chi[G]_c == theta] = [exists u, 'Res 'chi[G]_u == cfDet theta]. Proof. set e := #|G : N|; set f := Num.truncn _ => nsNG solG IGtheta co_e_f. apply/exists_eqP/exists_eqP=> [[c cNth] | [u uNdth]]. have /lin_char_irr/irrP[u Du] := cfDet_lin_char 'chi_c. by exists u; rewrite -Du -cfDetRes ?irr_char ?cNth. move: {2}e.+1 (ltnSn e) => m. elim: m => // m IHm in G u e nsNG solG IGtheta co_e_f uNdth *. rewrite ltnS => le_e; have [sNG nNG] := andP nsNG. have [<- | ltNG] := eqsVneq N G; first by exists s; rewrite cfRes_id. have [G0 maxG0 sNG0]: {G0 | maxnormal (gval G0) G G & N \subset G0}. by apply: maxgroup_exists; rewrite properEneq ltNG sNG. have [/andP[ltG0G nG0G] maxG0_P] := maxgroupP maxG0. set mu := 'chi_u in uNdth; have lin_mu: mu \is a linear_char. by rewrite qualifE/= irr_char -(cfRes1 N) uNdth /= lin_char1 ?cfDet_lin_char. have sG0G := proper_sub ltG0G; have nsNG0 := normalS sNG0 sG0G nsNG. have nsG0G: G0 <| G by apply/andP. have /lin_char_irr/irrP[u0 Du0] := cfRes_lin_char G0 lin_mu. have u0Ndth: 'Res 'chi_u0 = cfDet theta by rewrite -Du0 cfResRes. have IG0theta: G0 \subset 'I[theta]. by rewrite (subset_trans sG0G) // -IGtheta subsetIr. have coG0f: coprime #|G0 : N| f by rewrite (coprime_dvdl _ co_e_f) ?indexSg. have{m IHm le_e} [c0 c0Ns]: exists c0, 'Res 'chi[G0]_c0 = theta. have solG0: solvable (G0 / N) := solvableS (quotientS N sG0G) solG. apply: IHm nsNG0 solG0 IG0theta coG0f u0Ndth (leq_trans _ le_e). by rewrite -(ltn_pmul2l (cardG_gt0 N)) !Lagrange ?proper_card. have{c0 c0Ns} [c0 [c0Ns dc0_u0] Uc0] := extend_to_cfdet nsNG0 coG0f c0Ns u0Ndth. have IGc0: G \subset 'I['chi_c0]. apply/subsetP=> x Gx; rewrite inE (subsetP nG0G) //= -conjg_IirrE. apply/eqP; congr 'chi__; apply: Uc0; rewrite conjg_IirrE. by rewrite -(cfConjgRes _ nsG0G nsNG) // c0Ns inertiaJ ?(subsetP IGtheta). by rewrite cfDetConjg dc0_u0 -Du0 (cfConjgRes _ _ nsG0G) // cfConjg_id. have prG0G: prime #|G : G0|. have [h injh im_h] := third_isom sNG0 nsNG nsG0G. rewrite -card_quotient // -im_h // card_injm //. rewrite simple_sol_prime 1?quotient_sol //. by rewrite /simple -(injm_minnormal injh) // im_h // maxnormal_minnormal. have [t tG0c0] := prime_invariant_irr_extendible nsG0G (erefl _) prG0G IGc0. by exists t; rewrite /theta -c0Ns -tG0c0 cfResRes. Qed. (* This is Isaacs, Theorem (6.26). *) Theorem extend_linear_char_from_Sylow G N (lambda : 'CF(N)) : N <| G -> lambda \is a linear_char -> G \subset 'I[lambda] -> (forall p, p \in \pi('o(lambda)%CF) -> exists2 Hp : {group gT}, [/\ N \subset Hp, Hp \subset G & p.-Sylow(G / N) (Hp / N)%g] & exists u, 'Res 'chi[Hp]_u = lambda) -> exists u, 'Res[N, G] 'chi_u = lambda. Proof. set m := 'o(lambda)%CF => nsNG lam_lin IGlam p_ext_lam. have [sNG nNG] := andP nsNG; have linN := @cfRes_lin_lin _ _ N. wlog [p p_lam]: lambda @m lam_lin IGlam p_ext_lam / exists p : nat, \pi(m) =i (p : nat_pred). - move=> IHp; have [linG [cf [inj_cf _ lin_cf onto_cf]]] := lin_char_group N. case=> cf1 cfM cfX _ cf_order; have [lam cf_lam] := onto_cf _ lam_lin. pose mu p := cf lam.`_p; pose pi_m p := p \in \pi(m). have Dm: m = #[lam] by rewrite /m cfDet_order_lin // cf_lam cf_order. have Dlambda: lambda = \prod_(p < m.+1 | pi_m p) mu p. rewrite -(big_morph cf cfM cf1) big_mkcond cf_lam /pi_m Dm; congr (cf _). rewrite -{1}[lam]prod_constt big_mkord; apply: eq_bigr => p _. by case: ifPn => // p'lam; apply/constt1P; rewrite /p_elt p'natEpi. have lin_mu p: mu p \is a linear_char by rewrite /mu cfX -cf_lam rpredX. suffices /fin_all_exists [u uNlam] (p : 'I_m.+1): exists u, pi_m p -> 'Res[N, G] 'chi_u = mu p. - pose nu := \prod_(p < m.+1 | pi_m p) 'chi_(u p). have lin_nu: nu \is a linear_char. by apply: rpred_prod => p m_p; rewrite linN ?irr_char ?uNlam. have /irrP[u1 Dnu] := lin_char_irr lin_nu. by exists u1; rewrite Dlambda -Dnu rmorph_prod; apply: eq_bigr. have [m_p | _] := boolP (pi_m p); last by exists 0. have o_mu: \pi('o(mu p)%CF) =i (p : nat_pred). rewrite cfDet_order_lin // cf_order orderE /=. have [|pr_p _ [k ->]] := pgroup_pdiv (p_elt_constt p lam). by rewrite cycle_eq1 (sameP eqP constt1P) /p_elt p'natEpi // negbK -Dm. by move=> q; rewrite pi_of_exp // pi_of_prime. have IGmu: G \subset 'I[mu p]. rewrite (subset_trans IGlam) // /mu cfX -cf_lam. elim: (chinese _ _ _ _) => [|k IHk]; first by rewrite inertia1 norm_inertia. by rewrite exprS (subset_trans _ (inertia_mul _ _)) // subsetIidl. have [q||u] := IHp _ (lin_mu p) IGmu; [ | by exists p | by exists u]. rewrite o_mu => /eqnP-> {q}. have [Hp sylHp [u uNlam]] := p_ext_lam p m_p; exists Hp => //. rewrite /mu cfX -cf_lam -uNlam -rmorphXn /=; set nu := _ ^+ _. have /lin_char_irr/irrP[v ->]: nu \is a linear_char; last by exists v. by rewrite rpredX // linN ?irr_char ?uNlam. have pi_m_p: p \in \pi(m) by rewrite p_lam !inE. have [pr_p mgt0]: prime p /\ (m > 0)%N. by have:= pi_m_p; rewrite mem_primes => /and3P[]. have p_m: p.-nat m by rewrite -(eq_pnat _ p_lam) pnat_pi. have{p_ext_lam} [H [sNH sHG sylHbar] [v vNlam]] := p_ext_lam p pi_m_p. have co_p_GH: coprime p #|G : H|. rewrite -(index_quotient_eq _ sHG nNG) ?subIset ?sNH ?orbT //. by rewrite (pnat_coprime (pnat_id pr_p)) //; have [] := and3P sylHbar. have lin_v: 'chi_v \is a linear_char by rewrite linN ?irr_char ?vNlam. pose nuG := 'Ind[G] 'chi_v. have [c vGc co_p_f]: exists2 c, c \in irr_constt nuG & ~~ (p %| 'chi_c 1%g)%C. apply/exists_inP; rewrite -negb_forall_in. apply: contraL co_p_GH => /forall_inP p_dv_v1. rewrite prime_coprime // negbK -dvdC_nat -[rhs in (_ %| rhs)%C]mulr1. rewrite -(lin_char1 lin_v) -cfInd1 // ['Ind _]cfun_sum_constt /=. rewrite sum_cfunE rpred_sum // => i /p_dv_v1 p_dv_chi1i. rewrite cfunE dvdC_mull // intr_nat //. by rewrite Cnat_cfdot_char ?cfInd_char ?irr_char. pose f := Num.truncn ('chi_c 1%g); pose b := (egcdn f m).1. have fK: f%:R = 'chi_c 1%g by rewrite truncnK ?Cnat_irr1. have fb_mod_m: f * b = 1 %[mod m]. have co_m_f: coprime m f. by rewrite (pnat_coprime p_m) ?p'natE // -dvdC_nat CdivE fK. by rewrite -(chinese_modl co_m_f 1 0) /chinese !mul0n addn0 mul1n. have /irrP[s Dlam] := lin_char_irr lam_lin. have cHv: v \in irr_constt ('Res[H] 'chi_c) by rewrite -constt_Ind_Res. have{cHv} cNs: s \in irr_constt ('Res[N] 'chi_c). rewrite -(cfResRes _ sNH) ?(constt_Res_trans _ cHv) ?cfRes_char ?irr_char //. by rewrite vNlam Dlam constt_irr !inE. have DcN: 'Res[N] 'chi_c = lambda *+ f. have:= Clifford_Res_sum_cfclass nsNG cNs. rewrite cfclass_invariant -Dlam // big_seq1 Dlam => DcN. have:= cfRes1 N 'chi_c; rewrite DcN cfunE -Dlam lin_char1 // mulr1 => ->. by rewrite -scaler_nat fK. have /lin_char_irr/irrP[d Dd]: cfDet 'chi_c ^+ b \is a linear_char. by rewrite rpredX // cfDet_lin_char. exists d; rewrite -{}Dd rmorphXn /= -cfDetRes ?irr_char // DcN. rewrite cfDetMn ?lin_charW // -exprM cfDet_id //. rewrite -(expr_mod _ (exp_cforder _)) -cfDet_order_lin // -/m. by rewrite fb_mod_m /m cfDet_order_lin // expr_mod ?exp_cforder. Qed. (* This is Isaacs, Corollary (6.27). *) Corollary extend_coprime_linear_char G N (lambda : 'CF(N)) : N <| G -> lambda \is a linear_char -> G \subset 'I[lambda] -> coprime #|G : N| 'o(lambda)%CF -> exists u, [/\ 'Res 'chi[G]_u = lambda, 'o('chi_u)%CF = 'o(lambda)%CF & forall v, 'Res 'chi_v = lambda -> coprime #|G : N| 'o('chi_v)%CF -> v = u]. Proof. set e := #|G : N| => nsNG lam_lin IGlam co_e_lam; have [sNG nNG] := andP nsNG. have [p lam_p | v vNlam] := extend_linear_char_from_Sylow nsNG lam_lin IGlam. exists N; last first. by have /irrP[u ->] := lin_char_irr lam_lin; exists u; rewrite cfRes_id. split=> //; rewrite trivg_quotient /pHall sub1G pgroup1 indexg1. rewrite card_quotient //= -/e (pi'_p'nat _ lam_p) //. rewrite -coprime_pi' ?indexg_gt0 1?coprime_sym //. by have:= lam_p; rewrite mem_primes => /and3P[]. set nu := 'chi_v in vNlam. have lin_nu: nu \is a linear_char. by rewrite (@cfRes_lin_lin _ _ N) ?vNlam ?irr_char. have [b be_mod_lam]: exists b, b * e = 1 %[mod 'o(lambda)%CF]. rewrite -(chinese_modr co_e_lam 0 1) /chinese !mul0n !mul1n mulnC. by set b := _.1; exists b. have /irrP[u Du]: nu ^+ (b * e) \in irr G by rewrite lin_char_irr ?rpredX. exists u; set mu := 'chi_u in Du *. have uNlam: 'Res mu = lambda. rewrite cfDet_order_lin // in be_mod_lam. rewrite -Du rmorphXn /= vNlam -(expr_mod _ (exp_cforder _)) //. by rewrite be_mod_lam expr_mod ?exp_cforder. have lin_mu: mu \is a linear_char by rewrite -Du rpredX. have o_mu: ('o(mu) = 'o(lambda))%CF. have dv_o_lam_mu: 'o(lambda)%CF %| 'o(mu)%CF. by rewrite !cfDet_order_lin // -uNlam cforder_Res. have kerNnu_olam: N \subset cfker (nu ^+ 'o(lambda)%CF). rewrite -subsetIidl -cfker_Res ?rpredX ?irr_char //. by rewrite rmorphXn /= vNlam cfDet_order_lin // exp_cforder cfker_cfun1. apply/eqP; rewrite eqn_dvd dv_o_lam_mu andbT cfDet_order_lin //. rewrite dvdn_cforder -Du exprAC -dvdn_cforder dvdn_mull //. rewrite -(cfQuoK nsNG kerNnu_olam) cforder_mod // /e -card_quotient //. by rewrite cforder_lin_char_dvdG ?cfQuo_lin_char ?rpredX. split=> // t tNlam co_e_t. have lin_t: 'chi_t \is a linear_char. by rewrite (@cfRes_lin_lin _ _ N) ?tNlam ?irr_char. have Ut := lin_char_unitr lin_t. have kerN_mu_t: N \subset cfker (mu / 'chi_t)%R. rewrite -subsetIidl -cfker_Res ?lin_charW ?rpred_div ?rmorph_div //. by rewrite /= uNlam tNlam divrr ?lin_char_unitr ?cfker_cfun1. have co_e_mu_t: coprime e #[(mu / 'chi_t)%R]%CF. suffices dv_o_mu_t: #[(mu / 'chi_t)%R]%CF %| 'o(mu)%CF * 'o('chi_t)%CF. by rewrite (coprime_dvdr dv_o_mu_t) // coprimeMr o_mu co_e_lam. rewrite !cfDet_order_lin //; apply/dvdn_cforderP=> x Gx. rewrite invr_lin_char // !cfunE exprMn -rmorphXn {2}mulnC /=. by rewrite !(dvdn_cforderP _) ?conjC1 ?mulr1 // dvdn_mulr. have /eqP mu_t_1: mu / 'chi_t == 1. rewrite -(dvdn_cforder (_ / _)%R 1) -(eqnP co_e_mu_t) dvdn_gcd dvdnn andbT. rewrite -(cfQuoK nsNG kerN_mu_t) cforder_mod // /e -card_quotient //. by rewrite cforder_lin_char_dvdG ?cfQuo_lin_char ?rpred_div. by apply: irr_inj; rewrite -['chi_t]mul1r -mu_t_1 divrK. Qed. (* This is Isaacs, Corollary (6.28). *) Corollary extend_solvable_coprime_irr G N t (theta := 'chi[N]_t) : N <| G -> solvable (G / N) -> G \subset 'I[theta] -> coprime #|G : N| ('o(theta)%CF * Num.truncn (theta 1%g)) -> exists c, [/\ 'Res 'chi[G]_c = theta, 'o('chi_c)%CF = 'o(theta)%CF & forall d, 'Res 'chi_d = theta -> coprime #|G : N| 'o('chi_d)%CF -> d = c]. Proof. set e := #|G : N|; set f := Num.truncn _ => nsNG solG IGtheta. rewrite coprimeMr => /andP[co_e_th co_e_f]. have [sNG nNG] := andP nsNG; pose lambda := cfDet theta. have lin_lam: lambda \is a linear_char := cfDet_lin_char theta. have IGlam: G \subset 'I[lambda]. apply/subsetP=> y /(subsetP IGtheta)/setIdP[nNy /eqP th_y]. by rewrite inE nNy /= -cfDetConjg th_y. have co_e_lam: coprime e 'o(lambda)%CF by rewrite cfDet_order_lin. have [//|u [uNlam o_u Uu]] := extend_coprime_linear_char nsNG lin_lam IGlam. have /exists_eqP[c cNth]: [exists c, 'Res 'chi[G]_c == theta]. rewrite solvable_irr_extendible_from_det //. by apply/exists_eqP; exists u. have{c cNth} [c [cNth det_c] Uc] := extend_to_cfdet nsNG co_e_f cNth uNlam. have lin_u: 'chi_u \is a linear_char by rewrite -det_c cfDet_lin_char. exists c; split=> // [|c0 c0Nth co_e_c0]. by rewrite !cfDet_order_lin // -det_c in o_u. have lin_u0: cfDet 'chi_c0 \is a linear_char := cfDet_lin_char 'chi_c0. have /irrP[u0 Du0] := lin_char_irr lin_u0. have co_e_u0: coprime e 'o('chi_u0)%CF by rewrite -Du0 cfDet_order_lin. have eq_u0u: u0 = u by apply: Uu; rewrite // -Du0 -cfDetRes ?irr_char ?c0Nth. by apply: Uc; rewrite // Du0 eq_u0u. Qed. End ExtendInvariantIrr. Section Frobenius. Variables (gT : finGroupType) (G K : {group gT}). (* Because he only defines Frobenius groups in chapter 7, Isaacs does not *) (* state these theorems using the Frobenius property. *) Hypothesis frobGK : [Frobenius G with kernel K]. (* This is Isaacs, Theorem 6.34(a1). *) Theorem inertia_Frobenius_ker i : i != 0 -> 'I_G['chi[K]_i] = K. Proof. have [_ _ nsKG regK] := Frobenius_kerP frobGK; have [sKG nKG] := andP nsKG. move=> nzi; apply/eqP; rewrite eqEsubset sub_Inertia // andbT. apply/subsetP=> x /setIP[Gx /setIdP[nKx /eqP x_stab_i]]. have actIirrK: is_action G (@conjg_Iirr _ K). split=> [y j k eq_jk | j y z Gy Gz]. by apply/irr_inj/(can_inj (cfConjgK y)); rewrite -!conjg_IirrE eq_jk. by apply: irr_inj; rewrite !conjg_IirrE (cfConjgM _ nsKG). pose ito := Action actIirrK; pose cto := ('Js \ (subsetT G))%act. have acts_Js : [acts G, on classes K | 'Js]. apply/subsetP=> y Gy; have nKy := subsetP nKG y Gy. rewrite !inE; apply/subsetP=> _ /imsetP[z Gz ->] /[!inE]/=. rewrite -class_rcoset norm_rlcoset // class_lcoset. by apply: imset_f; rewrite memJ_norm. have acts_cto : [acts G, on classes K | cto] by rewrite astabs_ract subsetIidl. pose m := #|'Fix_(classes K | cto)[x]|. have def_m: #|'Fix_ito[x]| = m. apply: card_afix_irr_classes => // j y _ Ky /imsetP[_ /imsetP[z Kz ->] ->]. by rewrite conjg_IirrE cfConjgEJ // cfunJ. have: (m != 1)%N. rewrite -def_m (cardD1 (0 : Iirr K)) (cardD1 i) !(inE, sub1set) /=. by rewrite conjg_Iirr0 nzi eqxx -(inj_eq irr_inj) conjg_IirrE x_stab_i eqxx. apply: contraR => notKx; apply/cards1P; exists 1%g; apply/esym/eqP. rewrite eqEsubset !(sub1set, inE) classes1 /= conjs1g eqxx /=. apply/subsetP=> _ /setIP[/imsetP[y Ky ->] /afix1P /= cyKx]. have /imsetP[z Kz def_yx]: y ^ x \in y ^: K. by rewrite -cyKx; apply: imset_f; apply: class_refl. rewrite inE classG_eq1; apply: contraR notKx => nty. rewrite -(groupMr x (groupVr Kz)). apply: (subsetP (regK y _)); first exact/setD1P. rewrite !inE groupMl // groupV (subsetP sKG) //=. by rewrite conjg_set1 conjgM def_yx conjgK. Qed. (* This is Isaacs, Theorem 6.34(a2) *) Theorem irr_induced_Frobenius_ker i : i != 0 -> 'Ind[G, K] 'chi_i \in irr G. Proof. move/inertia_Frobenius_ker/group_inj=> defK. have [_ _ nsKG _] := Frobenius_kerP frobGK. have [] := constt_Inertia_bijection i nsKG; rewrite defK cfInd_id => -> //. by rewrite constt_irr !inE. Qed. (* This is Isaacs, Theorem 6.34(b) *) Theorem Frobenius_Ind_irrP j : reflect (exists2 i, i != 0 & 'chi_j = 'Ind[G, K] 'chi_i) (~~ (K \subset cfker 'chi_j)). Proof. have [_ _ nsKG _] := Frobenius_kerP frobGK; have [sKG nKG] := andP nsKG. apply: (iffP idP) => [not_chijK1 | [i nzi ->]]; last first. by rewrite cfker_Ind_irr ?sub_gcore // subGcfker. have /neq0_has_constt[i chijKi]: 'Res[K] 'chi_j != 0 by apply: Res_irr_neq0. have nz_i: i != 0. by apply: contraNneq not_chijK1 => i0; rewrite constt0_Res_cfker // -i0. have /irrP[k def_chik] := irr_induced_Frobenius_ker nz_i. have: '['chi_j, 'chi_k] != 0 by rewrite -def_chik -cfdot_Res_l. by rewrite cfdot_irr pnatr_eq0; case: (j =P k) => // ->; exists i. Qed. End Frobenius.
Imo1972Q5.lean
/- Copyright (c) 2020 Ruben Van de Velde, Stanislas Polu. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Ruben Van de Velde, Stanislas Polu -/ import Mathlib.Data.Real.Basic import Mathlib.Analysis.Normed.Module.Basic /-! # IMO 1972 Q5 Problem: `f` and `g` are real-valued functions defined on the real line. For all `x` and `y`, `f(x + y) + f(x - y) = 2f(x)g(y)`. `f` is not identically zero and `|f(x)| ≤ 1` for all `x`. Prove that `|g(x)| ≤ 1` for all `x`. -/ /-- This proof begins by introducing the supremum of `f`, `k ≤ 1` as well as `k' = k / ‖g y‖`. We then suppose that the conclusion does not hold (`hneg`) and show that `k ≤ k'` (by `2 * (‖f x‖ * ‖g y‖) ≤ 2 * k` obtained from the main hypothesis `hf1`) and that `k' < k` (obtained from `hneg` directly), finally raising a contradiction with `k' < k'`. (Authored by Stanislas Polu inspired by Ruben Van de Velde). -/ theorem imo1972_q5 (f g : ℝ → ℝ) (hf1 : ∀ x, ∀ y, f (x + y) + f (x - y) = 2 * f x * g y) (hf2 : ∀ y, ‖f y‖ ≤ 1) (hf3 : ∃ x, f x ≠ 0) (y : ℝ) : ‖g y‖ ≤ 1 := by -- Suppose the conclusion does not hold. by_contra! hneg set S := Set.range fun x => ‖f x‖ -- Introduce `k`, the supremum of `f`. let k : ℝ := sSup S -- Show that `‖f x‖ ≤ k`. have hk₁ : ∀ x, ‖f x‖ ≤ k := by have h : BddAbove S := ⟨1, Set.forall_mem_range.mpr hf2⟩ intro x exact le_csSup h (Set.mem_range_self x) -- Show that `2 * (‖f x‖ * ‖g y‖) ≤ 2 * k`. have hk₂ : ∀ x, 2 * (‖f x‖ * ‖g y‖) ≤ 2 * k := fun x ↦ calc 2 * (‖f x‖ * ‖g y‖) = ‖2 * f x * g y‖ := by simp [mul_assoc] _ = ‖f (x + y) + f (x - y)‖ := by rw [hf1] _ ≤ ‖f (x + y)‖ + ‖f (x - y)‖ := norm_add_le _ _ _ ≤ k + k := add_le_add (hk₁ _) (hk₁ _) _ = 2 * k := (two_mul _).symm set k' := k / ‖g y‖ -- Demonstrate that `k' < k` using `hneg`. have H₁ : k' < k := by have h₁ : 0 < k := by obtain ⟨x, hx⟩ := hf3 calc 0 < ‖f x‖ := norm_pos_iff.mpr hx _ ≤ k := hk₁ x rw [div_lt_iff₀] · apply lt_mul_of_one_lt_right h₁ hneg · exact zero_lt_one.trans hneg -- Demonstrate that `k ≤ k'` using `hk₂`. have H₂ : k ≤ k' := by have h₁ : ∃ x : ℝ, x ∈ S := by use ‖f 0‖; exact Set.mem_range_self 0 have h₂ : ∀ x, ‖f x‖ ≤ k' := by intro x rw [le_div_iff₀] · apply (mul_le_mul_left zero_lt_two).mp (hk₂ x) · exact zero_lt_one.trans hneg apply csSup_le h₁ rintro y' ⟨yy, rfl⟩ exact h₂ yy -- Conclude by obtaining a contradiction, `k' < k'`. apply lt_irrefl k' calc k' < k := H₁ _ ≤ k' := H₂ /-- IMO 1972 Q5 Problem: `f` and `g` are real-valued functions defined on the real line. For all `x` and `y`, `f(x + y) + f(x - y) = 2f(x)g(y)`. `f` is not identically zero and `|f(x)| ≤ 1` for all `x`. Prove that `|g(x)| ≤ 1` for all `x`. This is a more concise version of the proof proposed by Ruben Van de Velde. -/ theorem imo1972_q5' (f g : ℝ → ℝ) (hf1 : ∀ x, ∀ y, f (x + y) + f (x - y) = 2 * f x * g y) (hf2 : BddAbove (Set.range fun x => ‖f x‖)) (hf3 : ∃ x, f x ≠ 0) (y : ℝ) : ‖g y‖ ≤ 1 := by obtain ⟨x, hx⟩ := hf3 set k := ⨆ x, ‖f x‖ have h : ∀ x, ‖f x‖ ≤ k := le_ciSup hf2 by_contra! H have hgy : 0 < ‖g y‖ := by linarith have k_pos : 0 < k := lt_of_lt_of_le (norm_pos_iff.mpr hx) (h x) have : k / ‖g y‖ < k := (div_lt_iff₀ hgy).mpr (lt_mul_of_one_lt_right k_pos H) have : k ≤ k / ‖g y‖ := by suffices ∀ x, ‖f x‖ ≤ k / ‖g y‖ from ciSup_le this intro x suffices 2 * (‖f x‖ * ‖g y‖) ≤ 2 * k by rwa [le_div_iff₀ hgy, ← mul_le_mul_left (zero_lt_two : (0 : ℝ) < 2)] calc 2 * (‖f x‖ * ‖g y‖) = ‖2 * f x * g y‖ := by simp [mul_assoc] _ = ‖f (x + y) + f (x - y)‖ := by rw [hf1] _ ≤ ‖f (x + y)‖ + ‖f (x - y)‖ := abs_add _ _ _ ≤ 2 * k := by linarith [h (x + y), h (x - y)] linarith
all_character.v
From mathcomp Require Export character. From mathcomp Require Export classfun. From mathcomp Require Export inertia. From mathcomp Require Export integral_char. From mathcomp Require Export mxabelem. From mathcomp Require Export mxrepresentation. From mathcomp Require Export vcharacter.
Holder.lean
/- Copyright (c) 2025 Jireh Loreaux. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jireh Loreaux -/ import Mathlib.Data.ENNReal.Inv /-! # Hölder triples This file defines a new class: `ENNReal.HolderTriple` which takes arguments `p q r : ℝ≥0∞`, with `r` marked as a `semiOutParam`, and states that `p⁻¹ + q⁻¹ = r⁻¹`. This is exactly the condition for which **Hölder's inequality** is valid (see `MeasureTheory.MemLp.smul`). This allows us to declare a heterogeneous scalar multiplication (`HSMul`) instance on `MeasureTheory.Lp` spaces. In this file we provide many convenience lemmas in the presence of a `HolderTriple` instance. All these are easily provable from facts about `ℝ≥0∞`, but it's convenient not to be forced to reprove them each time. For convenience we also define `ENNReal.HolderConjugate` (with arguments `p q`) as an abbreviation for `ENNReal.HolderTriple p q 1`. -/ namespace ENNReal /-- A class stating that `p q r : ℝ≥0∞` satisfy `p⁻¹ + q⁻¹ = r⁻¹`. This is exactly the condition for which **Hölder's inequality** is valid (see `MeasureTheory.MemLp.smul`). When `r := 1`, one generally says that `p q` are **Hölder conjugate**. This class exists so that we can define a heterogeneous scalar multiplication on `MeasureTheory.Lp`, and this is why `r` must be marked as a `semiOutParam`. We don't mark it as an `outParam` because this would prevent Lean from using `HolderTriple p q r` and `HolderTriple p q r'` within a single proof, as may be occasionally convenient. -/ @[mk_iff] class HolderTriple (p q : ℝ≥0∞) (r : semiOutParam ℝ≥0∞) : Prop where inv_add_inv_eq_inv (p q r) : p⁻¹ + q⁻¹ = r⁻¹ /-- An abbreviation for `ENNReal.HolderTriple p q 1`, this class states `p⁻¹ + q⁻¹ = 1`. -/ abbrev HolderConjugate (p q : ℝ≥0∞) := HolderTriple p q 1 lemma holderConjugate_iff {p q : ℝ≥0∞} : HolderConjugate p q ↔ p⁻¹ + q⁻¹ = 1 := by simp [holderTriple_iff] /-! ### Hölder triples -/ namespace HolderTriple /-- This is not marked as an instance so that Lean doesn't always find this one and a more canonical value of `r` can be used. -/ lemma of (p q : ℝ≥0∞) : HolderTriple p q (p⁻¹ + q⁻¹)⁻¹ where inv_add_inv_eq_inv := inv_inv _ |>.symm /- This instance causes a trivial loop, but this is exactly the kind of loop that Lean should be able to detect and avoid. -/ instance symm {p q r : ℝ≥0∞} [hpqr : HolderTriple p q r] : HolderTriple q p r where inv_add_inv_eq_inv := add_comm p⁻¹ q⁻¹ ▸ hpqr.inv_add_inv_eq_inv instance instInfty (p : ℝ≥0∞) : HolderTriple p ∞ p where inv_add_inv_eq_inv := by simp instance instZero (p : ℝ≥0∞) : HolderTriple p 0 0 where inv_add_inv_eq_inv := by simp variable (p q r : ℝ≥0∞) [HolderTriple p q r] lemma inv_eq : r⁻¹ = p⁻¹ + q⁻¹ := (inv_add_inv_eq_inv ..).symm lemma unique (r' : ℝ≥0∞) [hr' : HolderTriple p q r'] : r = r' := by rw [← inv_inj, inv_eq p q r, inv_eq p q r'] lemma one_div_add_one_div : 1 / p + 1 / q = 1 / r := by simpa using inv_add_inv_eq_inv .. lemma one_div_eq : 1 / r = 1 / p + 1 / q := one_div_add_one_div p q r |>.symm lemma inv_inv_add_inv : (p⁻¹ + q⁻¹)⁻¹ = r := by simp [inv_add_inv_eq_inv p q r] include q in lemma le : r ≤ p := by simp [← ENNReal.inv_le_inv, ← @inv_inv_add_inv p q r, inv_inv] include q in protected lemma inv_le_inv : p⁻¹ ≤ r⁻¹ := by simp [ENNReal.inv_le_inv, le p q r] variable {r} in lemma inv_sub_inv_eq_inv (hr : r ≠ 0) : r⁻¹ - q⁻¹ = p⁻¹ := by apply ENNReal.sub_eq_of_eq_add (ne_of_lt ?_) (inv_eq p q r) calc q⁻¹ ≤ r⁻¹ := HolderTriple.inv_le_inv q p r _ < ∞ := by simpa using pos_iff_ne_zero.mpr hr /-- assumes `q ≠ 0` instead of `r ≠ 0`. -/ lemma inv_sub_inv_eq_inv' (hq : q ≠ 0) : r⁻¹ - q⁻¹ = p⁻¹ := by obtain (rfl | hr) := eq_zero_or_pos r · suffices p = 0 by simpa [this] by_contra! hp have := calc 0⁻¹ = p⁻¹ + q⁻¹ := inv_eq p q 0 _ < ⊤ + ⊤ := by simp [hp, hq, pos_iff_ne_zero] _ = ⊤ := by simp simp_all · exact inv_sub_inv_eq_inv p q hr.ne' variable {r} in lemma unique_of_ne_zero (q' : ℝ≥0∞) (hr : r ≠ 0) [HolderTriple p q' r] : q = q' := by rw [← inv_inj, ← inv_sub_inv_eq_inv q p hr, ← inv_sub_inv_eq_inv q' p hr] lemma holderConjugate_div_div (hr₀ : r ≠ 0) (hr : r ≠ ∞) : HolderConjugate (p / r) (q / r) where inv_add_inv_eq_inv := by rw [ENNReal.inv_div (.inl hr) (.inl hr₀), ENNReal.inv_div (.inl hr) (.inl hr₀), div_eq_mul_inv, div_eq_mul_inv, ← mul_add, inv_add_inv_eq_inv p q r, ENNReal.mul_inv_cancel hr₀ hr, inv_one] end HolderTriple /-! ### Hölder conjugates -/ namespace HolderConjugate /- This instance causes a trivial loop, but this is exactly the kind of loop that Lean should be able to detect and avoid. -/ instance symm {p q : ℝ≥0∞} [hpq : HolderConjugate p q] : HolderConjugate q p := inferInstance instance instTwoTwo : HolderConjugate 2 2 where inv_add_inv_eq_inv := by rw [← two_mul, ENNReal.mul_inv_cancel] all_goals norm_num -- I'm not sure this is necessary, but maybe it's nice to have around given the `abbrev`. instance instOneInfty : HolderConjugate 1 ∞ := inferInstance variable (p q : ℝ≥0∞) [HolderConjugate p q] include q in lemma one_le : 1 ≤ p := HolderTriple.le p q 1 include q in lemma pos : 0 < p := zero_lt_one.trans_le (one_le p q) include q in lemma ne_zero : p ≠ 0 := pos p q |>.ne' lemma inv_add_inv_eq_one : p⁻¹ + q⁻¹ = 1 := @inv_one ℝ≥0∞ _ ▸ HolderTriple.inv_add_inv_eq_inv p q 1 lemma one_sub_inv : 1 - p⁻¹ = q⁻¹ := @inv_one ℝ≥0∞ _ ▸ HolderTriple.inv_sub_inv_eq_inv q p one_ne_zero lemma unique (q' : ℝ≥0∞) [hq' : HolderConjugate p q'] : q = q' := HolderTriple.unique_of_ne_zero p q q' one_ne_zero lemma eq_top_iff_eq_one : p = ∞ ↔ q = 1 := by constructor · rintro rfl rw [← inv_inv q, ← one_sub_inv ∞ q] simp · rintro rfl rw [← inv_inv p, ← one_sub_inv 1 p] simp lemma ne_top_iff_ne_one : p ≠ ∞ ↔ q ≠ 1 := by rw [not_iff_not, eq_top_iff_eq_one p q] lemma lt_top_iff_one_lt : p < ∞ ↔ 1 < q := by rw [lt_top_iff_ne_top, ne_top_iff_ne_one _ q, ne_comm, lt_iff_le_and_ne] simp [one_le q p] lemma sub_one_mul_inv (hp : p ≠ ⊤) : (p - 1) * p⁻¹ = q⁻¹ := by have := pos p q |>.ne' rw [ENNReal.sub_mul (by aesop), ENNReal.mul_inv_cancel this (by omega)] simp [one_sub_inv p q] end HolderConjugate end ENNReal
Basic.lean
/- Copyright (c) 2020 Kim Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kim Morrison -/ import Mathlib.Algebra.Category.Grp.Basic import Mathlib.Algebra.Ring.PUnit import Mathlib.CategoryTheory.Adjunction.Limits import Mathlib.CategoryTheory.Conj import Mathlib.CategoryTheory.Limits.FunctorCategory.Basic import Mathlib.CategoryTheory.Limits.Preserves.Basic import Mathlib.CategoryTheory.SingleObj import Mathlib.Tactic.ApplyFun /-! # `Action V G`, the category of actions of a monoid `G` inside some category `V`. The prototypical example is `V = ModuleCat R`, where `Action (ModuleCat R) G` is the category of `R`-linear representations of `G`. We check `Action V G ≌ (CategoryTheory.singleObj G ⥤ V)`, and construct the restriction functors `res {G H} [Monoid G] [Monoid H] (f : G →* H) : Action V H ⥤ Action V G`. -/ universe u v open CategoryTheory Limits variable (V : Type*) [Category V] -- Note: this is _not_ a categorical action of `G` on `V`. /-- An `Action V G` represents a bundled action of the monoid `G` on an object of some category `V`. As an example, when `V = ModuleCat R`, this is an `R`-linear representation of `G`, while when `V = Type` this is a `G`-action. -/ structure Action (G : Type*) [Monoid G] where /-- The object this action acts on -/ V : V /-- The underlying monoid homomorphism of this action -/ ρ : G →* End V namespace Action variable {V} theorem ρ_one {G : Type*} [Monoid G] (A : Action V G) : A.ρ 1 = 𝟙 A.V := by simp /-- When a group acts, we can lift the action to the group of automorphisms. -/ @[simps] def ρAut {G : Type*} [Group G] (A : Action V G) : G →* Aut A.V where toFun g := { hom := A.ρ g inv := A.ρ (g⁻¹ : G) hom_inv_id := (A.ρ.map_mul (g⁻¹ : G) g).symm.trans (by rw [inv_mul_cancel, ρ_one]) inv_hom_id := (A.ρ.map_mul g (g⁻¹ : G)).symm.trans (by rw [mul_inv_cancel, ρ_one]) } map_one' := Aut.ext A.ρ.map_one map_mul' x y := Aut.ext (A.ρ.map_mul x y) variable (G : Type*) [Monoid G] section /-- The action defined by sending every group element to the identity. -/ @[simps] def trivial (X : V) : Action V G := { V := X, ρ := 1 } instance inhabited' : Inhabited (Action (Type*) G) := ⟨⟨PUnit, 1⟩⟩ instance : Inhabited (Action AddCommGrp G) := ⟨trivial G <| AddCommGrp.of PUnit⟩ end variable {G} /-- A homomorphism of `Action V G`s is a morphism between the underlying objects, commuting with the action of `G`. -/ @[ext] structure Hom (M N : Action V G) where /-- The morphism between the underlying objects of this action -/ hom : M.V ⟶ N.V comm : ∀ g : G, M.ρ g ≫ hom = hom ≫ N.ρ g := by cat_disch namespace Hom attribute [reassoc] comm attribute [local simp] comm comm_assoc /-- The identity morphism on an `Action V G`. -/ @[simps] def id (M : Action V G) : Action.Hom M M where hom := 𝟙 M.V instance (M : Action V G) : Inhabited (Action.Hom M M) := ⟨id M⟩ /-- The composition of two `Action V G` homomorphisms is the composition of the underlying maps. -/ @[simps] def comp {M N K : Action V G} (p : Action.Hom M N) (q : Action.Hom N K) : Action.Hom M K where hom := p.hom ≫ q.hom end Hom instance : Category (Action V G) where Hom M N := Hom M N id M := Hom.id M comp f g := Hom.comp f g lemma hom_injective {M N : Action V G} : Function.Injective (Hom.hom : (M ⟶ N) → (M.V ⟶ N.V)) := fun _ _ ↦ Hom.ext @[ext] lemma hom_ext {M N : Action V G} (φ₁ φ₂ : M ⟶ N) (h : φ₁.hom = φ₂.hom) : φ₁ = φ₂ := Hom.ext h @[simp] theorem id_hom (M : Action V G) : (𝟙 M : Hom M M).hom = 𝟙 M.V := rfl @[simp, reassoc] theorem comp_hom {M N K : Action V G} (f : M ⟶ N) (g : N ⟶ K) : (f ≫ g : Hom M K).hom = f.hom ≫ g.hom := rfl @[reassoc (attr := simp)] theorem hom_inv_hom {M N : Action V G} (f : M ≅ N) : f.hom.hom ≫ f.inv.hom = 𝟙 M.V := by rw [← comp_hom, Iso.hom_inv_id, id_hom] @[reassoc (attr := simp)] theorem inv_hom_hom {M N : Action V G} (f : M ≅ N) : f.inv.hom ≫ f.hom.hom = 𝟙 N.V := by rw [← comp_hom, Iso.inv_hom_id, id_hom] /-- Construct an isomorphism of `G` actions/representations from an isomorphism of the underlying objects, where the forward direction commutes with the group action. -/ @[simps] def mkIso {M N : Action V G} (f : M.V ≅ N.V) (comm : ∀ g : G, M.ρ g ≫ f.hom = f.hom ≫ N.ρ g := by cat_disch) : M ≅ N where hom := { hom := f.hom comm := comm } inv := { hom := f.inv comm := fun g => by have w := comm g =≫ f.inv; simp at w; simp [w] } instance (priority := 100) isIso_of_hom_isIso {M N : Action V G} (f : M ⟶ N) [IsIso f.hom] : IsIso f := (mkIso (asIso f.hom) f.comm).isIso_hom instance isIso_hom_mk {M N : Action V G} (f : M.V ⟶ N.V) [IsIso f] (w) : @IsIso _ _ M N (Hom.mk f w) := (mkIso (asIso f) w).isIso_hom instance {M N : Action V G} (f : M ≅ N) : IsIso f.hom.hom where out := ⟨f.inv.hom, by simp⟩ instance {M N : Action V G} (f : M ≅ N) : IsIso f.inv.hom where out := ⟨f.hom.hom, by simp⟩ namespace FunctorCategoryEquivalence /-- Auxiliary definition for `functorCategoryEquivalence`. -/ @[simps] def functor : Action V G ⥤ SingleObj G ⥤ V where obj M := { obj := fun _ => M.V map := fun g => M.ρ g map_id := fun _ => M.ρ.map_one map_comp := fun g h => M.ρ.map_mul h g } map f := { app := fun _ => f.hom naturality := fun _ _ g => f.comm g } /-- Auxiliary definition for `functorCategoryEquivalence`. -/ @[simps] def inverse : (SingleObj G ⥤ V) ⥤ Action V G where obj F := { V := F.obj PUnit.unit ρ := { toFun := fun g => F.map g map_one' := F.map_id PUnit.unit map_mul' := fun g h => F.map_comp h g } } map f := { hom := f.app PUnit.unit comm := fun g => f.naturality g } /-- Auxiliary definition for `functorCategoryEquivalence`. -/ @[simps!] def unitIso : 𝟭 (Action V G) ≅ functor ⋙ inverse := NatIso.ofComponents fun M => mkIso (Iso.refl _) /-- Auxiliary definition for `functorCategoryEquivalence`. -/ @[simps!] def counitIso : inverse ⋙ functor ≅ 𝟭 (SingleObj G ⥤ V) := NatIso.ofComponents fun M => NatIso.ofComponents fun _ => Iso.refl _ end FunctorCategoryEquivalence section open FunctorCategoryEquivalence variable (V G) /-- The category of actions of `G` in the category `V` is equivalent to the functor category `singleObj G ⥤ V`. -/ @[simps] def functorCategoryEquivalence : Action V G ≌ SingleObj G ⥤ V where functor := functor inverse := inverse unitIso := unitIso counitIso := counitIso instance : (FunctorCategoryEquivalence.functor (V := V) (G := G)).IsEquivalence := (functorCategoryEquivalence V G).isEquivalence_functor instance : (FunctorCategoryEquivalence.inverse (V := V) (G := G)).IsEquivalence := (functorCategoryEquivalence V G).isEquivalence_inverse end section Forget variable (V G) /-- (implementation) The forgetful functor from bundled actions to the underlying objects. Use the `CategoryTheory.forget` API provided by the `HasForget` instance below, rather than using this directly. -/ @[simps] def forget : Action V G ⥤ V where obj M := M.V map f := f.hom instance : (forget V G).Faithful where map_injective w := Hom.ext w instance [HasForget V] : HasForget (Action V G) where forget := forget V G ⋙ HasForget.forget /-- The type of `V`-morphisms that can be lifted back to morphisms in the category `Action`. -/ abbrev HomSubtype {FV : V → V → Type*} {CV : V → Type*} [∀ X Y, FunLike (FV X Y) (CV X) (CV Y)] [ConcreteCategory V FV] (M N : Action V G) := { f : FV M.V N.V // ∀ g : G, f ∘ ConcreteCategory.hom (M.ρ g) = ConcreteCategory.hom (N.ρ g) ∘ f } instance {FV : V → V → Type*} {CV : V → Type*} [∀ X Y, FunLike (FV X Y) (CV X) (CV Y)] [ConcreteCategory V FV] (M N : Action V G) : FunLike (HomSubtype V G M N) (CV M.V) (CV N.V) where coe f := f.1 coe_injective' _ _ h := Subtype.ext (DFunLike.coe_injective h) instance {FV : V → V → Type*} {CV : V → Type*} [∀ X Y, FunLike (FV X Y) (CV X) (CV Y)] [ConcreteCategory V FV] : ConcreteCategory (Action V G) (HomSubtype V G) where hom f := ⟨ConcreteCategory.hom (C := V) f.1, fun g => by ext simpa using CategoryTheory.congr_fun (f.2 g) _⟩ ofHom f := ⟨ConcreteCategory.ofHom (C := V) f, fun g => ConcreteCategory.ext_apply fun x => by simpa [ConcreteCategory.hom_ofHom] using congr_fun (f.2 g) x⟩ hom_ofHom _ := by dsimp; ext; simp [ConcreteCategory.hom_ofHom] ofHom_hom _ := by ext; simp [ConcreteCategory.ofHom_hom] id_apply := ConcreteCategory.id_apply (C := V) comp_apply _ _ := ConcreteCategory.comp_apply (C := V) _ _ instance hasForgetToV [HasForget V] : HasForget₂ (Action V G) V where forget₂ := forget V G /-- The forgetful functor is intertwined by `functorCategoryEquivalence` with evaluation at `PUnit.star`. -/ def functorCategoryEquivalenceCompEvaluation : (functorCategoryEquivalence V G).functor ⋙ (evaluation _ _).obj PUnit.unit ≅ forget V G := Iso.refl _ noncomputable instance preservesLimits_forget [HasLimits V] : PreservesLimits (forget V G) := Limits.preservesLimits_of_natIso (Action.functorCategoryEquivalenceCompEvaluation V G) noncomputable instance preservesColimits_forget [HasColimits V] : PreservesColimits (forget V G) := preservesColimits_of_natIso (Action.functorCategoryEquivalenceCompEvaluation V G) -- TODO construct categorical images? end Forget theorem Iso.conj_ρ {M N : Action V G} (f : M ≅ N) (g : G) : N.ρ g = ((forget V G).mapIso f).conj (M.ρ g) := by rw [Iso.conj_apply, Iso.eq_inv_comp]; simp [f.hom.comm] /-- Actions/representations of the trivial group are just objects in the ambient category. -/ def actionPunitEquivalence : Action V PUnit ≌ V where functor := forget V _ inverse := { obj := fun X => ⟨X, 1⟩ map := fun f => ⟨f, fun ⟨⟩ => by simp⟩ } unitIso := NatIso.ofComponents fun X => mkIso (Iso.refl _) fun ⟨⟩ => by simp only [Functor.id_obj, MonoidHom.one_apply, End.one_def, Functor.comp_obj, forget_obj, Iso.refl_hom, Category.comp_id] exact ρ_one X counitIso := NatIso.ofComponents fun _ => Iso.refl _ variable (V) /-- The "restriction" functor along a monoid homomorphism `f : G ⟶ H`, taking actions of `H` to actions of `G`. (This makes sense for any homomorphism, but the name is natural when `f` is a monomorphism.) -/ @[simps] def res {G H : Type*} [Monoid G] [Monoid H] (f : G →* H) : Action V H ⥤ Action V G where obj M := { V := M.V ρ := M.ρ.comp f } map p := { hom := p.hom comm := fun g => p.comm (f g) } /-- The natural isomorphism from restriction along the identity homomorphism to the identity functor on `Action V G`. -/ @[simps!] def resId {G : Type*} [Monoid G] : res V (MonoidHom.id G) ≅ 𝟭 (Action V G) := NatIso.ofComponents fun M => mkIso (Iso.refl _) /-- The natural isomorphism from the composition of restrictions along homomorphisms to the restriction along the composition of homomorphism. -/ @[simps!] def resComp {G H K : Type*} [Monoid G] [Monoid H] [Monoid K] (f : G →* H) (g : H →* K) : res V g ⋙ res V f ≅ res V (g.comp f) := NatIso.ofComponents fun M => mkIso (Iso.refl _) /-- Restricting scalars along equal maps is naturally isomorphic. -/ @[simps! hom inv] def resCongr {G H : Type*} [Monoid G] [Monoid H] {f f' : G →* H} (h : f = f') : Action.res V f ≅ Action.res V f' := NatIso.ofComponents (fun _ ↦ Action.mkIso (Iso.refl _)) /-- Restricting scalars along a monoid isomorphism induces an equivalence of categories. -/ @[simps! functor inverse] def resEquiv {G H : Type*} [Monoid G] [Monoid H] (f : G ≃* H) : Action V H ≌ Action V G where functor := Action.res _ f inverse := Action.res _ f.symm unitIso := Action.resCongr (f := MonoidHom.id H) V (by ext; simp) ≪≫ (Action.resComp _ _ _).symm counitIso := Action.resComp _ _ _ ≪≫ Action.resCongr (f' := MonoidHom.id G) V (by ext; simp) -- TODO promote `res` to a pseudofunctor from -- the locally discrete bicategory constructed from `Monᵒᵖ` to `Cat`, sending `G` to `Action V G`. variable {G H : Type*} [Monoid G] [Monoid H] (f : G →* H) /-- The functor from `Action V H` to `Action V G` induced by a morphism `f : G → H` is faithful. -/ instance : (res V f).Faithful where map_injective {X} {Y} g₁ g₂ h := by ext rw [← res_map_hom _ f g₁, ← res_map_hom _ f g₂, h] /-- The functor from `Action V H` to `Action V G` induced by a morphism `f : G → H` is full if `f` is surjective. -/ lemma full_res (f_surj : Function.Surjective f) : (res V f).Full where map_surjective {X} {Y} g := by use ⟨g.hom, fun h ↦ ?_⟩ · ext simp · obtain ⟨a, rfl⟩ := f_surj h have : X.ρ (f a) = ((res V f).obj X).ρ a := rfl rw [this, g.comm a] simp end Action namespace CategoryTheory.Functor variable {V} {W : Type*} [Category W] /-- A functor between categories induces a functor between the categories of `G`-actions within those categories. -/ @[simps] def mapAction (F : V ⥤ W) (G : Type*) [Monoid G] : Action V G ⥤ Action W G where obj M := { V := F.obj M.V ρ := { toFun := fun g => F.map (M.ρ g) map_one' := by simp map_mul' := fun g h => by dsimp rw [map_mul, End.mul_def, F.map_comp] } } map f := { hom := F.map f.hom comm := fun g => by dsimp; rw [← F.map_comp, f.comm, F.map_comp] } map_id M := by ext; simp only [Action.id_hom, F.map_id] map_comp f g := by ext; simp only [Action.comp_hom, F.map_comp] instance (F : V ⥤ W) (G : Type*) [Monoid G] [F.Faithful] : (F.mapAction G).Faithful where map_injective eq := by ext apply_fun (fun f ↦ f.hom) at eq exact F.map_injective eq /-- A fully faithful functor between categories induces a fully faithful functor between the categories of `G`-actions within those categories. -/ def FullyFaithful.mapAction {F : V ⥤ W} (h : F.FullyFaithful) (G : Type*) [Monoid G] : (F.mapAction G).FullyFaithful where preimage f := by refine ⟨h.preimage f.hom, fun _ ↦ h.map_injective ?_⟩ simp only [map_comp, map_preimage] exact f.comm _ instance (F : V ⥤ W) (G : Type*) [Monoid G] [F.Faithful] [F.Full] : (F.mapAction G).Full := ((Functor.FullyFaithful.ofFullyFaithful F).mapAction G).full variable (G : Type*) [Monoid G] /-- `Functor.mapAction` is functorial in the functor. -/ @[simps! hom inv] def mapActionComp {T : Type*} [Category T] (F : V ⥤ W) (F' : W ⥤ T) : (F ⋙ F').mapAction G ≅ F.mapAction G ⋙ F'.mapAction G := NatIso.ofComponents (fun X ↦ Iso.refl _) /-- `Functor.mapAction` preserves isomorphisms of functors. -/ @[simps! hom inv] def mapActionCongr {F F' : V ⥤ W} (e : F ≅ F') : F.mapAction G ≅ F'.mapAction G := NatIso.ofComponents (fun X ↦ Action.mkIso (e.app X.V)) end Functor /-- An equivalence of categories induces an equivalence of the categories of `G`-actions within those categories. -/ @[simps functor inverse] def Equivalence.mapAction {V W : Type*} [Category V] [Category W] (G : Type*) [Monoid G] (E : V ≌ W) : Action V G ≌ Action W G where functor := E.functor.mapAction G inverse := E.inverse.mapAction G unitIso := Functor.mapActionCongr G E.unitIso ≪≫ Functor.mapActionComp G _ _ counitIso := (Functor.mapActionComp G _ _).symm ≪≫ Functor.mapActionCongr G E.counitIso functor_unitIso_comp X := by ext; simp end CategoryTheory
Recall.lean
import Mathlib.Tactic.Recall import Mathlib.Analysis.Calculus.Deriv.Basic import Mathlib.Analysis.SpecialFunctions.Trigonometric.Basic import Mathlib.Data.Complex.Trigonometric set_option linter.style.setOption false -- Remark: When the test is run by make/CI, this option is not set, so we set it here. set_option pp.unicode.fun true set_option autoImplicit true /- Motivating examples from the initial Zulip thread: https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/recall.20command -/ section variable {𝕜 : Type _} [NontriviallyNormedField 𝕜] variable {E : Type _} [AddCommGroup E] [Module 𝕜 E] [TopologicalSpace E] variable {F : Type _} [AddCommGroup F] [Module 𝕜 F] [TopologicalSpace F] recall HasFDerivAt (f : E → F) (f' : E →L[𝕜] F) (x : E) := HasFDerivAtFilter f f' x (nhds x) end /-- error: value mismatch Complex.exp has value id but is expected to have value fun z ↦ (Complex.exp' z).lim -/ #guard_msgs in recall Complex.exp : ℂ → ℂ := id /-- error: value mismatch Real.pi has value 0 but is expected to have value 2 * Classical.choose Real.exists_cos_eq_zero -/ #guard_msgs in recall Real.pi : ℝ := 0 /- Other example tests -/ recall id (x : α) : α := x /-- error: Type mismatch @id has type {α : Sort u_1} → α → α → ℕ of sort `Type u_1` but is expected to have type {α : Sort u} → α → α of sort `Sort (imax (u + 1) u)` -/ #guard_msgs in recall id (_x _y : α) : ℕ := 0 recall id (_x : α) : α def foo := 22 recall foo := 22 recall foo : Nat /-- error: value mismatch foo has value 23 but is expected to have value 22 -/ #guard_msgs in recall foo := 23 recall Nat.add_comm (n m : Nat) : n + m = m + n -- Caveat: the binder kinds are not checked recall Nat.add_comm {n m : Nat} : n + m = m + n -- https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/recall.20command/near/376648750 recall add_assoc {G : Type _} [AddSemigroup G] (a b c : G) : a + b + c = a + (b + c) recall add_assoc /-- error: unknown constant 'nonexistent' -/ #guard_msgs in recall nonexistent axiom bar : Nat /-- error: constant 'bar' has no defined value -/ #guard_msgs in recall bar := bar recall List.cons_append (a : α) (as bs : List α) : (a :: as) ++ bs = a :: (as ++ bs) := rfl
mxrepresentation.v
(* (c) Copyright 2006-2016 Microsoft Corporation and Inria. *) (* Distributed under the terms of CeCILL-B. *) From HB Require Import structures. From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq path. From mathcomp Require Import div choice fintype tuple finfun bigop prime. From mathcomp Require Import ssralg poly polydiv finset fingroup morphism. From mathcomp Require Import perm automorphism quotient finalg action zmodp. From mathcomp Require Import commutator cyclic center pgroup matrix mxalgebra. From mathcomp Require Import mxalgebra mxpoly. (******************************************************************************) (* This file provides linkage between classic Group Theory and commutative *) (* algebra -- representation theory. Since general abstract linear algebra is *) (* still being sorted out, we develop the required theory here on the *) (* assumption that all vector spaces are matrix spaces, indeed that most are *) (* row matrix spaces; our representation theory is specialized to the latter *) (* case. We provide many definitions and results of representation theory: *) (* enveloping algebras, reducible, irreducible and absolutely irreducible *) (* representations, representation centralisers, submodules and kernels, *) (* simple and semisimple modules, the Schur lemmas, Maschke's theorem, *) (* components, socles, homomorphisms and isomorphisms, the Jacobson density *) (* theorem, similar representations, the Jordan-Holder theorem, Clifford's *) (* theorem and Wedderburn components, regular representations and the *) (* Wedderburn structure theorem for semisimple group rings, and the *) (* construction of a splitting field of an irreducible representation, and of *) (* reduced, tensored, and factored representations. *) (* mx_representation F G n == the Structure type for representations of G *) (* with n x n matrices with coefficients in F. Note that *) (* rG : mx_representation F G n coerces to a function from *) (* the element type of G to 'M_n, and conversely all such *) (* functions have a Canonical mx_representation. *) (* mx_repr G r <-> r : gT -> 'M_n defines a (matrix) group representation *) (* on G : {set gT} (Prop predicate). *) (* enveloping_algebra_mx rG == a #|G| x (n ^ 2) matrix whose rows are the *) (* mxvec encodings of the image of G under rG, and whose *) (* row space therefore encodes the enveloping algebra of *) (* the representation of G. *) (* rker rG == the kernel of the representation of r on G, i.e., the *) (* subgroup of elements of G mapped to the identity by rG. *) (* mx_faithful rG == the representation rG of G is faithful (its kernel is *) (* trivial). *) (* rfix_mx rG H == an n x n matrix whose row space is the set of vectors *) (* fixed (centralised) by the representation of H by rG. *) (* rcent rG A == the subgroup of G whose representation via rG commutes *) (* with the square matrix A. *) (* rcenter rG == the subgroup of G whose representation via rG consists of *) (* scalar matrices. *) (* centgmx rG f <=> f commutes with every matrix in the representation of G *) (* (i.e., f is a total rG-homomorphism). *) (* rstab rG U == the subgroup of G whose representation via r fixes all *) (* vectors in U, pointwise. *) (* rstabs rG U == the subgroup of G whose representation via r fixes the row *) (* space of U globally. *) (* mxmodule rG U <=> the row-space of the matrix U is a module (globally *) (* invariant) under the representation rG of G. *) (* max_submod rG U V <-> U < V and U is not a proper of any proper *) (* rG-submodule of V (if both U and V are modules, *) (* then U is a maximal proper submodule of V). *) (* mx_subseries rG Us <=> Us : seq 'M_n is a list of rG-modules *) (* mx_composition_series rG Us <-> Us is an increasing composition series *) (* for an rG-module (namely, last 0 Us). *) (* mxsimple rG M <-> M is a simple rG-module (i.e., minimal and nontrivial) *) (* This is a Prop predicate on square matrices. *) (* mxnonsimple rG U <-> U is constructively not a submodule, that is, U *) (* contains a proper nontrivial submodule. *) (* mxnonsimple_sat rG U == U is not a simple as an rG-module. *) (* This is a bool predicate, which requires a decField *) (* structure on the scalar field. *) (* mxsemisimple rG W <-> W is constructively a direct sum of simple modules. *) (* mxsplits rG V U <-> V splits over U in rG, i.e., U has an rG-invariant *) (* complement in V. *) (* mx_completely_reducible rG V <-> V splits over all its submodules; note *) (* that this is only classically equivalent to stating that *) (* V is semisimple. *) (* mx_irreducible rG <-> the representation rG is irreducible, i.e., the full *) (* module 1%:M of rG is simple. *) (* mx_absolutely_irreducible rG == the representation rG of G is absolutely *) (* irreducible: its enveloping algebra is the full matrix *) (* ring. This is only classically equivalent to the more *) (* standard ``rG does not reduce in any field extension''. *) (* group_splitting_field F G <-> F is a splitting field for the group G: *) (* every irreducible representation of G is absolutely *) (* irreducible. Any field can be embedded classically into a *) (* splitting field. *) (* group_closure_field F gT <-> F is a splitting field for every group *) (* G : {group gT}, and indeed for any section of such a *) (* group. This is a convenient constructive substitute for *) (* algebraic closures, that can be constructed classically. *) (* dom_hom_mx rG f == a square matrix encoding the set of vectors for which *) (* multiplication by the n x n matrix f commutes with the *) (* representation of G, i.e., the largest domain on which *) (* f is an rG homomorphism. *) (* mx_iso rG U V <-> U and V are (constructively) rG-isomorphic; this is *) (* a Prop predicate. *) (* mx_simple_iso rG U V == U and V are rG-isomorphic if one of them is *) (* simple; this is a bool predicate. *) (* cyclic_mx rG u == the cyclic rG-module generated by the row vector u *) (* annihilator_mx rG u == the annihilator of the row vector u in the *) (* enveloping algebra the representation rG. *) (* row_hom_mx rG u == the image of u by the set of all rG-homomorphisms on *) (* its cyclic module, or, equivalently, the null-space of the *) (* annihilator of u. *) (* component_mx rG M == when M is a simple rG-module, the component of M in *) (* the representation rG, i.e. the module generated by all *) (* the (simple) modules rG-isomorphic to M. *) (* socleType rG == a Structure that represents the type of all components *) (* of rG (more precisely, it coerces to such a type via *) (* socle_sort). For sG : socleType, values of type sG (to be *) (* exact, socle_sort sG) coerce to square matrices. For any *) (* representation rG we can construct sG : socleType rG *) (* classically; the socleType structure encapsulates this *) (* use of classical logic. *) (* DecSocleType rG == a socleType rG structure, for a representation over a *) (* decidable field type. DecSocleType rG is opaque. *) (* socle_base W == for W : (sG : socleType), a simple module whose *) (* component is W; socle_simple W and socle_module W are *) (* proofs that socle_base W is a simple module. *) (* socle_mult W == the multiplicity of socle_base W in W : sG. *) (* := \rank W %/ \rank (socle_base W) *) (* Socle sG == the Socle of rG, given sG : socleType rG, i.e., the *) (* (direct) sum of all the components of rG. *) (* mx_rsim rG rG' <-> rG and rG' are similar representations of the same *) (* group G. Note that rG and rG' must then have equal, but *) (* not necessarily convertible, degree. *) (* submod_repr modU == a representation of G on 'rV_(\rank U) equivalent to *) (* the restriction of rG to U (here modU : mxmodule rG U). *) (* socle_repr W := submod_repr (socle_module W) *) (* val/in_submod rG U == the projections resp. from/onto 'rV_(\rank U), *) (* that correspond to submod_repr r G U (these work both on *) (* vectors and row spaces). *) (* factmod_repr modV == a representation of G on 'rV_(\rank (cokermx V)) that *) (* is equivalent to the factor module 'rV_n / V induced by V *) (* and rG (here modV : mxmodule rG V). *) (* val/in_factmod rG U == the projections for factmod_repr r G U. *) (* section_repr modU modV == the restriction to in_factmod V U of the factor *) (* representation factmod_repr modV (for modU : mxmodule rG U *) (* and modV : mxmodule rG V); section_repr modU modV is *) (* irreducible iff max_submod rG U V. *) (* subseries_repr modUs i == the representation for the section module *) (* in_factmod (0 :: Us)`_i Us`_i, where *) (* modUs : mx_subseries rG Us. *) (* series_repr compUs i == the representation for the section module *) (* in_factmod (0 :: Us)`_i Us`_i, where *) (* compUs : mx_composition_series rG Us. The Jordan-Holder *) (* theorem asserts the uniqueness of the set of such *) (* representations, up to similarity and permutation. *) (* regular_repr F G == the regular F-representation of the group G. *) (* group_ring F G == a #|G| x #|G|^2 matrix that encodes the free group *) (* ring of G -- that is, the enveloping algebra of the *) (* regular F-representation of G. *) (* gring_index x == the index corresponding to x \in G in the matrix *) (* encoding of regular_repr and group_ring. *) (* gring_row A == the row vector corresponding to A \in group_ring F G in *) (* the regular FG-module. *) (* gring_proj x A == the 1 x 1 matrix holding the coefficient of x \in G in *) (* (A \in group_ring F G)%MS. *) (* gring_mx rG u == the image of a row vector u of the regular FG-module, *) (* in the enveloping algebra of another representation rG. *) (* gring_op rG A == the image of a matrix of the free group ring of G, *) (* in the enveloping algebra of rG. *) (* gset_mx F G C == the group sum of C in the free group ring of G -- the *) (* sum of the images of all the x \in C in group_ring F G. *) (* classg_base F G == a #|classes G| x #|G|^2 matrix whose rows encode the *) (* group sums of the conjugacy classes of G -- this is a *) (* basis of 'Z(group_ring F G)%MS. *) (* irrType F G == a type indexing irreducible representations of G over a *) (* field F, provided its characteristic does not divide the *) (* order of G; it also indexes Wedderburn subrings. *) (* := socleType (regular_repr F G) *) (* irr_repr i == the irreducible representation corresponding to the *) (* index i : irrType sG *) (* := socle_repr i as i coerces to a component matrix. *) (* 'n_i, irr_degree i == the degree of irr_repr i; the notation is only *) (* active after Open Scope group_ring_scope. *) (* linear_irr sG == the set of sG-indices of linear irreducible *) (* representations of G. *) (* irr_comp sG rG == the sG-index of the unique irreducible representation *) (* similar to rG, at least when rG is irreducible and the *) (* characteristic is coprime. *) (* irr_mode i z == the unique eigenvalue of irr_repr i z, at least when *) (* irr_repr i z is scalar (e.g., when z \in 'Z(G)). *) (* [1 sG]%irr == the index of the principal representation of G, in *) (* sG : irrType F G. The i argument of irr_repr, irr_degree *) (* and irr_mode is in the %irr scope. This notation may be *) (* replaced locally by an interpretation of 1%irr as [1 sG] *) (* for some specific irrType sG. *) (* 'R_i, Wedderburn_subring i == the subring (indeed, the component) of the *) (* free group ring of G corresponding to the component i : sG *) (* of the regular FG-module, where sG : irrType F g. In *) (* coprime characteristic the Wedderburn structure theorem *) (* asserts that the free group ring is the direct sum of *) (* these subrings; as with 'n_i above, the notation is only *) (* active in group_ring_scope. *) (* 'e_i, Wedderburn_id i == the projection of the identity matrix 1%:M on the *) (* Wedderburn subring of i : sG (with sG a socleType). In *) (* coprime characteristic this is the identity element of *) (* the subring, and the basis of its center if the field F is *) (* a splitting field. As 'R_i, 'e_i is in group_ring_scope. *) (* subg_repr rG sHG == the restriction to H of the representation rG of G; *) (* here sHG : H \subset G. *) (* eqg_repr rG eqHG == the representation rG of G viewed a a representation *) (* of H; here eqHG : G == H. *) (* morphpre_repr f rG == the representation of f @*^-1 G obtained by *) (* composing the group morphism f with rG. *) (* morphim_repr rGf sGD == the representation of G induced by a *) (* representation rGf of f @* G; here sGD : G \subset D where *) (* D is the domain of the group morphism f. *) (* rconj_repr rG uB == the conjugate representation x |-> B * rG x * B^-1; *) (* here uB : B \in unitmx. *) (* quo_repr sHK nHG == the representation of G / H induced by rG, given *) (* sHK : H \subset rker rG, and nHG : G \subset 'N(H). *) (* kquo_repr rG == the representation induced on G / rker rG by rG. *) (* map_repr f rG == the representation f \o rG, whose module is the tensor *) (* product of the module of rG with the extension field into *) (* which f : {rmorphism F -> Fstar} embeds F. *) (* 'Cl%act == the transitive action of G on the Wedderburn components of *) (* H, with nsGH : H <| G, given by Clifford's theorem. More *) (* precisely this is a total action of G on socle_sort sH, *) (* where sH : socleType (subg_repr rG (normal_sub sGH)). *) (* We build on the MatrixFormula toolkit to define decision procedures for *) (* the reducibility property: *) (* mxmodule_form rG U == a formula asserting that the interpretation of U is *) (* a module of the representation rG. *) (* mxnonsimple_form rG U == a formula asserting that the interpretation of U *) (* contains a proper nontrivial rG-module. *) (* mxnonsimple_sat rG U <=> mxnonsimple_form rG U is satisfied. *) (* More involved constructions are encapsulated in two Coq submodules: *) (* MatrixGenField == a module that encapsulates the lengthy details of the *) (* construction of appropriate extension fields. We assume we *) (* have an irreducible representation rG of a group G, and a *) (* non-scalar matrix A that centralises rG(G), as this data *) (* is readily extracted from the Jacobson density theorem. It *) (* then follows from Schur's lemma that the ring generated by *) (* A is a field on which the extension of the representation *) (* rG of G is reducible. Note that this is equivalent to the *) (* more traditional quotient of the polynomial ring by an *) (* irreducible polynomial (the minimal polynomial of A), but *) (* much better suited to our needs. *) (* Here are the main definitions of MatrixGenField; they all have three *) (* proofs as arguments: (implicit) rG : mx_repr n G, irrG : mx_irreducible rG *) (* and cGA : centgmx rG A. These ensure the validity of the construction and *) (* allow us to define Canonical instances; we assume degree_mxminpoly A > 1 *) (* (which is equivalent to ~~ is_scalar_mx A) only to prove reducibility. *) (* + gen_of irrG cGA == the carrier type of the field generated by A. It is *) (* at least equipped with a fieldType structure; we also *) (* propagate any decFieldType/finFieldType structures on the *) (* original field. *) (* + gen irrG cGA == the morphism injecting into gen_of irrG cGA. *) (* + groot irrG cGA == the root of mxminpoly A in the gen_of irrG cGA field. *) (* + pval x, rVval x, mxval x == the interpretation of x : gen_of irrG cGA *) (* as a polynomial, a row vector, and a matrix, respectively. *) (* Both irrG and cGA are implicit arguments here. *) (* + gen_repr irrG cGA == an alternative to the field extension *) (* representation, which consists in reconsidering the *) (* original module as a module over the new gen_of field, *) (* thereby DIVIDING the original dimension n by the degree of *) (* the minimal polynomial of A. This can be simpler than the *) (* extension method, is actually required by the proof that *) (* odd groups are p-stable (B & G 6.1-2, and Appendix A), but *) (* is only applicable if G is the LARGEST group represented *) (* by rG (e.g., NOT for B & G 2.6). *) (* + gen_dim A == the dimension of gen_repr irrG cGA (only depends on A). *) (* + in_gen irrG cGA W == the ROWWISE image of a matrix W : 'M[F]_(m, n), *) (* i.e., interpreting W as a sequence of m tow vectors, *) (* under the bijection from rG to gen_repr irrG cGA. *) (* The sequence length m is a maximal implicit argument *) (* passed between the explicit argument cGA and W. *) (* + val_gen W == the ROWWISE image of an 'M[gen_of irrG cGA]_(m, gen_dim A) *) (* matrix W under the bijection from gen_repr irrG cGA to rG. *) (* + rowval_gen W == the ROWSPACE image of W under the bijection from *) (* gen_repr irrG cGA to rG, i.e., a 'M[F]_n matrix whose row *) (* space is the image of the row space of W. *) (* This is the A-ideal generated by val_gen W. *) (* + gen_sat e f <=> f : GRing.formula (gen_of irrG cGA) is satisfied in *) (* environment e : seq (gen_of irrG cGA), provided F has a *) (* decFieldType structure. *) (* + gen_env e, gen_term t, gen_form f == interpretations of environments, *) (* terms, and RING formulas over gen_of irrG cGA as row *) (* vector formulae, used to construct gen_sat. *) (******************************************************************************) Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. Declare Scope irrType_scope. Declare Scope group_ring_scope. Import GroupScope GRing.Theory. Local Open Scope ring_scope. Reserved Notation "''n_' i" (at level 8, i at level 2, format "''n_' i"). Reserved Notation "''R_' i" (at level 8, i at level 2, format "''R_' i"). Reserved Notation "''e_' i" (at level 8, i at level 2, format "''e_' i"). Delimit Scope irrType_scope with irr. Section RingRepr. Variable R : comUnitRingType. Section OneRepresentation. Variable gT : finGroupType. Definition mx_repr (G : {set gT}) n (r : gT -> 'M[R]_n) := r 1%g = 1%:M /\ {in G &, {morph r : x y / (x * y)%g >-> x *m y}}. Structure mx_representation G n := MxRepresentation { repr_mx :> gT -> 'M_n; _ : mx_repr G repr_mx }. Variables (G : {group gT}) (n : nat) (rG : mx_representation G n). Arguments rG _%_group_scope : extra scopes. Lemma repr_mx1 : rG 1 = 1%:M. Proof. by case: rG => r []. Qed. Lemma repr_mxM : {in G &, {morph rG : x y / (x * y)%g >-> x *m y}}. Proof. by case: rG => r []. Qed. Lemma repr_mxK m x : x \in G -> cancel ((@mulmx R m n n)^~ (rG x)) (mulmx^~ (rG x^-1)). Proof. by move=> Gx U; rewrite -mulmxA -repr_mxM ?groupV // mulgV repr_mx1 mulmx1. Qed. Lemma repr_mxKV m x : x \in G -> cancel ((@mulmx R m n n)^~ (rG x^-1)) (mulmx^~ (rG x)). Proof. by rewrite -groupV -{3}[x]invgK; apply: repr_mxK. Qed. Lemma repr_mx_unit x : x \in G -> rG x \in unitmx. Proof. by move=> Gx; case/mulmx1_unit: (repr_mxKV Gx 1%:M). Qed. Lemma repr_mxV : {in G, {morph rG : x / x^-1%g >-> invmx x}}. Proof. by move=> x Gx /=; rewrite -[rG x^-1](mulKmx (repr_mx_unit Gx)) mulmxA repr_mxK. Qed. (* This is only used in the group ring construction below, as we only have *) (* developped the theory of matrix subalgebras for F-algebras. *) Definition enveloping_algebra_mx := \matrix_(i < #|G|) mxvec (rG (enum_val i)). Section Stabiliser. Variables (m : nat) (U : 'M[R]_(m, n)). Definition rstab := [set x in G | U *m rG x == U]. Lemma rstab_sub : rstab \subset G. Proof. by apply/subsetP=> x; case/setIdP. Qed. Lemma rstab_group_set : group_set rstab. Proof. apply/group_setP; rewrite inE group1 repr_mx1 mulmx1; split=> //= x y. case/setIdP=> Gx cUx; case/setIdP=> Gy cUy; rewrite inE repr_mxM ?groupM //. by rewrite mulmxA (eqP cUx). Qed. Canonical rstab_group := Group rstab_group_set. End Stabiliser. (* Centralizer subgroup and central homomorphisms. *) Section CentHom. Variable f : 'M[R]_n. Definition rcent := [set x in G | f *m rG x == rG x *m f]. Lemma rcent_sub : rcent \subset G. Proof. by apply/subsetP=> x; case/setIdP. Qed. Lemma rcent_group_set : group_set rcent. Proof. apply/group_setP; rewrite inE group1 repr_mx1 mulmx1 mul1mx; split=> //= x y. case/setIdP=> Gx; move/eqP=> cfx; case/setIdP=> Gy; move/eqP=> cfy. by rewrite inE repr_mxM ?groupM //= -mulmxA -cfy !mulmxA cfx. Qed. Canonical rcent_group := Group rcent_group_set. Definition centgmx := G \subset rcent. Lemma centgmxP : reflect (forall x, x \in G -> f *m rG x = rG x *m f) centgmx. Proof. by apply: (iffP subsetP) => cGf x Gx; have /[!(inE, Gx)] /eqP := cGf x Gx. Qed. End CentHom. (* Representation kernel, and faithful representations. *) Definition rker := rstab 1%:M. Canonical rker_group := Eval hnf in [group of rker]. Lemma rkerP x : reflect (x \in G /\ rG x = 1%:M) (x \in rker). Proof. by apply: (iffP setIdP) => [] [->]; move/eqP; rewrite mul1mx. Qed. Lemma rker_norm : G \subset 'N(rker). Proof. apply/subsetP=> x Gx; rewrite inE sub_conjg; apply/subsetP=> y. case/rkerP=> Gy ry1; rewrite mem_conjgV !inE groupJ //=. by rewrite !repr_mxM ?groupM ?groupV // ry1 !mulmxA mulmx1 repr_mxKV. Qed. Lemma rker_normal : rker <| G. Proof. by rewrite /normal rstab_sub rker_norm. Qed. Definition mx_faithful := rker \subset [1]. Lemma mx_faithful_inj : mx_faithful -> {in G &, injective rG}. Proof. move=> ffulG x y Gx Gy eq_rGxy; apply/eqP; rewrite eq_mulgV1 -in_set1. rewrite (subsetP ffulG) // inE groupM ?repr_mxM ?groupV //= eq_rGxy. by rewrite mulmxA repr_mxK. Qed. Lemma rker_linear : n = 1 -> G^`(1)%g \subset rker. Proof. move=> n1; rewrite gen_subG; apply/subsetP=> xy; case/imset2P=> x y Gx Gy ->. rewrite !inE groupR //= /commg mulgA -invMg repr_mxM ?groupV ?groupM //. rewrite mulmxA (can2_eq (repr_mxK _) (repr_mxKV _)) ?groupM //. rewrite !repr_mxV ?repr_mxM ?groupM //; move: (rG x) (rG y). by rewrite n1 => rx ry; rewrite (mx11_scalar rx) scalar_mxC. Qed. (* Representation center. *) Definition rcenter := [set g in G | is_scalar_mx (rG g)]. Fact rcenter_group_set : group_set rcenter. Proof. apply/group_setP; split=> [|x y]. by rewrite inE group1 repr_mx1 scalar_mx_is_scalar. move=> /setIdP[Gx /is_scalar_mxP[a defx]] /setIdP[Gy /is_scalar_mxP[b defy]]. by rewrite !inE groupM ?repr_mxM // defx defy -scalar_mxM ?scalar_mx_is_scalar. Qed. Canonical rcenter_group := Group rcenter_group_set. Lemma rcenter_normal : rcenter <| G. Proof. rewrite /normal /rcenter {1}setIdE subsetIl; apply/subsetP=> x Gx /[1!inE]. apply/subsetP=> _ /imsetP[y /setIdP[Gy /is_scalar_mxP[c rGy]] ->]. rewrite inE !repr_mxM ?groupM ?groupV //= mulmxA rGy scalar_mxC repr_mxKV //. exact: scalar_mx_is_scalar. Qed. End OneRepresentation. Arguments rkerP {gT G n rG x}. Section Proper. Variables (gT : finGroupType) (G : {group gT}) (n' : nat). Local Notation n := n'.+1. Variable rG : mx_representation G n. Lemma repr_mxMr : {in G &, {morph rG : x y / (x * y)%g >-> x * y}}. Proof. exact: repr_mxM. Qed. Lemma repr_mxVr : {in G, {morph rG : x / (x^-1)%g >-> x^-1}}. Proof. exact: repr_mxV. Qed. Lemma repr_mx_unitr x : x \in G -> rG x \is a GRing.unit. Proof. exact: repr_mx_unit. Qed. Lemma repr_mxX m : {in G, {morph rG : x / (x ^+ m)%g >-> x ^+ m}}. Proof. elim: m => [|m IHm] x Gx; rewrite /= ?repr_mx1 // expgS exprS -IHm //. by rewrite repr_mxM ?groupX. Qed. End Proper. Section ChangeGroup. Variables (gT : finGroupType) (G H : {group gT}) (n : nat). Variables (rG : mx_representation G n). Section SubGroup. Hypothesis sHG : H \subset G. Lemma subg_mx_repr : mx_repr H rG. Proof. by split=> [|x y Hx Hy]; rewrite (repr_mx1, repr_mxM) ?(subsetP sHG). Qed. Definition subg_repr := MxRepresentation subg_mx_repr. Local Notation rH := subg_repr. Lemma rcent_subg U : rcent rH U = H :&: rcent rG U. Proof. by apply/setP=> x; rewrite !inE andbA -in_setI (setIidPl sHG). Qed. Section Stabiliser. Variables (m : nat) (U : 'M[R]_(m, n)). Lemma rstab_subg : rstab rH U = H :&: rstab rG U. Proof. by apply/setP=> x; rewrite !inE andbA -in_setI (setIidPl sHG). Qed. End Stabiliser. Lemma rker_subg : rker rH = H :&: rker rG. Proof. exact: rstab_subg. Qed. Lemma subg_mx_faithful : mx_faithful rG -> mx_faithful rH. Proof. by apply: subset_trans; rewrite rker_subg subsetIr. Qed. End SubGroup. Section SameGroup. Hypothesis eqGH : G :==: H. Lemma eqg_repr_proof : H \subset G. Proof. by rewrite (eqP eqGH). Qed. Definition eqg_repr := subg_repr eqg_repr_proof. Local Notation rH := eqg_repr. Lemma rcent_eqg U : rcent rH U = rcent rG U. Proof. by rewrite rcent_subg -(eqP eqGH) (setIidPr _) ?rcent_sub. Qed. Section Stabiliser. Variables (m : nat) (U : 'M[R]_(m, n)). Lemma rstab_eqg : rstab rH U = rstab rG U. Proof. by rewrite rstab_subg -(eqP eqGH) (setIidPr _) ?rstab_sub. Qed. End Stabiliser. Lemma rker_eqg : rker rH = rker rG. Proof. exact: rstab_eqg. Qed. Lemma eqg_mx_faithful : mx_faithful rH = mx_faithful rG. Proof. by rewrite /mx_faithful rker_eqg. Qed. End SameGroup. End ChangeGroup. Section Morphpre. Variables (aT rT : finGroupType) (D : {group aT}) (f : {morphism D >-> rT}). Variables (G : {group rT}) (n : nat) (rG : mx_representation G n). Lemma morphpre_mx_repr : mx_repr (f @*^-1 G) (rG \o f). Proof. split=> [|x y]; first by rewrite /= morph1 repr_mx1. case/morphpreP=> Dx Gfx; case/morphpreP=> Dy Gfy. by rewrite /= morphM ?repr_mxM. Qed. Canonical morphpre_repr := MxRepresentation morphpre_mx_repr. Local Notation rGf := morphpre_repr. Section Stabiliser. Variables (m : nat) (U : 'M[R]_(m, n)). Lemma rstab_morphpre : rstab rGf U = f @*^-1 (rstab rG U). Proof. by apply/setP=> x; rewrite !inE andbA. Qed. End Stabiliser. Lemma rker_morphpre : rker rGf = f @*^-1 (rker rG). Proof. exact: rstab_morphpre. Qed. End Morphpre. Section Morphim. Variables (aT rT : finGroupType) (G D : {group aT}) (f : {morphism D >-> rT}). Variables (n : nat) (rGf : mx_representation (f @* G) n). Definition morphim_mx of G \subset D := fun x => rGf (f x). Hypothesis sGD : G \subset D. Lemma morphim_mxE x : morphim_mx sGD x = rGf (f x). Proof. by []. Qed. Let sG_f'fG : G \subset f @*^-1 (f @* G). Proof. by rewrite -sub_morphim_pre. Qed. Lemma morphim_mx_repr : mx_repr G (morphim_mx sGD). Proof. exact: subg_mx_repr (morphpre_repr f rGf) sG_f'fG. Qed. Canonical morphim_repr := MxRepresentation morphim_mx_repr. Local Notation rG := morphim_repr. Section Stabiliser. Variables (m : nat) (U : 'M[R]_(m, n)). Lemma rstab_morphim : rstab rG U = G :&: f @*^-1 rstab rGf U. Proof. by rewrite -rstab_morphpre -(rstab_subg _ sG_f'fG). Qed. End Stabiliser. Lemma rker_morphim : rker rG = G :&: f @*^-1 (rker rGf). Proof. exact: rstab_morphim. Qed. End Morphim. Section Conjugate. Variables (gT : finGroupType) (G : {group gT}) (n : nat). Variables (rG : mx_representation G n) (B : 'M[R]_n). Definition rconj_mx of B \in unitmx := fun x => B *m rG x *m invmx B. Hypothesis uB : B \in unitmx. Lemma rconj_mx_repr : mx_repr G (rconj_mx uB). Proof. split=> [|x y Gx Gy]; rewrite /rconj_mx ?repr_mx1 ?mulmx1 ?mulmxV ?repr_mxM //. by rewrite !mulmxA mulmxKV. Qed. Canonical rconj_repr := MxRepresentation rconj_mx_repr. Local Notation rGB := rconj_repr. Lemma rconj_mxE x : rGB x = B *m rG x *m invmx B. Proof. by []. Qed. Lemma rconj_mxJ m (W : 'M_(m, n)) x : W *m rGB x *m B = W *m B *m rG x. Proof. by rewrite !mulmxA mulmxKV. Qed. Lemma rcent_conj A : rcent rGB A = rcent rG (invmx B *m A *m B). Proof. apply/setP=> x; rewrite !inE /= rconj_mxE !mulmxA. rewrite (can2_eq (mulmxKV uB) (mulmxK uB)) -!mulmxA. by rewrite -(can2_eq (mulKVmx uB) (mulKmx uB)). Qed. Lemma rstab_conj m (U : 'M_(m, n)) : rstab rGB U = rstab rG (U *m B). Proof. apply/setP=> x; rewrite !inE /= rconj_mxE !mulmxA. by rewrite (can2_eq (mulmxKV uB) (mulmxK uB)). Qed. Lemma rker_conj : rker rGB = rker rG. Proof. apply/setP=> x; rewrite !inE /= mulmxA (can2_eq (mulmxKV uB) (mulmxK uB)). by rewrite mul1mx -scalar_mxC (inj_eq (can_inj (mulKmx uB))) mul1mx. Qed. Lemma conj_mx_faithful : mx_faithful rGB = mx_faithful rG. Proof. by rewrite /mx_faithful rker_conj. Qed. End Conjugate. Section Quotient. Variables (gT : finGroupType) (G : {group gT}) (n : nat). Variable rG : mx_representation G n. Definition quo_mx (H : {set gT}) of H \subset rker rG & G \subset 'N(H) := fun Hx : coset_of H => rG (repr Hx). Section SubQuotient. Variable H : {group gT}. Hypotheses (krH : H \subset rker rG) (nHG : G \subset 'N(H)). Let nHGs := subsetP nHG. Lemma quo_mx_coset x : x \in G -> quo_mx krH nHG (coset H x) = rG x. Proof. move=> Gx; rewrite /quo_mx val_coset ?nHGs //; case: repr_rcosetP => z Hz. by case/rkerP: (subsetP krH z Hz) => Gz rz1; rewrite repr_mxM // rz1 mul1mx. Qed. Lemma quo_mx_repr : mx_repr (G / H)%g (quo_mx krH nHG). Proof. split=> [|Hx Hy]; first by rewrite /quo_mx repr_coset1 repr_mx1. case/morphimP=> x Nx Gx ->{Hx}; case/morphimP=> y Ny Gy ->{Hy}. by rewrite -morphM // !quo_mx_coset ?groupM ?repr_mxM. Qed. Canonical quo_repr := MxRepresentation quo_mx_repr. Local Notation rGH := quo_repr. Lemma quo_repr_coset x : x \in G -> rGH (coset H x) = rG x. Proof. exact: quo_mx_coset. Qed. Lemma rcent_quo A : rcent rGH A = (rcent rG A / H)%g. Proof. apply/setP=> Hx /[!inE]; apply/andP/idP=> [[]|]; case/morphimP=> x Nx Gx ->{Hx}. by rewrite quo_repr_coset // => cAx; rewrite mem_morphim // inE Gx. by case/setIdP: Gx => Gx cAx; rewrite quo_repr_coset ?mem_morphim. Qed. Lemma rstab_quo m (U : 'M_(m, n)) : rstab rGH U = (rstab rG U / H)%g. Proof. apply/setP=> Hx /[!inE]; apply/andP/idP=> [[]|]; case/morphimP=> x Nx Gx ->{Hx}. by rewrite quo_repr_coset // => nUx; rewrite mem_morphim // inE Gx. by case/setIdP: Gx => Gx nUx; rewrite quo_repr_coset ?mem_morphim. Qed. Lemma rker_quo : rker rGH = (rker rG / H)%g. Proof. exact: rstab_quo. Qed. End SubQuotient. Definition kquo_mx := quo_mx (subxx (rker rG)) (rker_norm rG). Lemma kquo_mxE : kquo_mx = quo_mx (subxx (rker rG)) (rker_norm rG). Proof. by []. Qed. Canonical kquo_repr := @MxRepresentation _ _ _ kquo_mx (quo_mx_repr _ _). Lemma kquo_repr_coset x : x \in G -> kquo_repr (coset (rker rG) x) = rG x. Proof. exact: quo_repr_coset. Qed. Lemma kquo_mx_faithful : mx_faithful kquo_repr. Proof. by rewrite /mx_faithful rker_quo trivg_quotient. Qed. End Quotient. Section Regular. Variables (gT : finGroupType) (G : {group gT}). Definition gcard := #|G|. (* hides the projections to set *) Local Notation nG := gcard. Definition gring_index (x : gT) := enum_rank_in (group1 G) x. Lemma gring_valK : cancel enum_val gring_index. Proof. exact: enum_valK_in. Qed. Lemma gring_indexK : {in G, cancel gring_index enum_val}. Proof. exact: enum_rankK_in. Qed. Definition regular_mx x : 'M[R]_nG := \matrix_i delta_mx 0 (gring_index (enum_val i * x)). Lemma regular_mx_repr : mx_repr G regular_mx. Proof. split=> [|x y Gx Gy]; apply/row_matrixP=> i; rewrite !rowK. by rewrite mulg1 row1 gring_valK. by rewrite row_mul rowK -rowE rowK mulgA gring_indexK // groupM ?enum_valP. Qed. Canonical regular_repr := MxRepresentation regular_mx_repr. Local Notation aG := regular_repr. Definition group_ring := enveloping_algebra_mx aG. Local Notation R_G := group_ring. Definition gring_row : 'M[R]_nG -> 'rV_nG := row (gring_index 1). HB.instance Definition _ := GRing.Linear.on gring_row. Lemma gring_row_mul A B : gring_row (A *m B) = gring_row A *m B. Proof. exact: row_mul. Qed. Definition gring_proj x := row (gring_index x) \o trmx \o gring_row. HB.instance Definition _ x := GRing.Linear.on (gring_proj x). Lemma gring_projE : {in G &, forall x y, gring_proj x (aG y) = (x == y)%:R}. Proof. move=> x y Gx Gy; rewrite /gring_proj /= /gring_row rowK gring_indexK //=. rewrite mul1g trmx_delta rowE mul_delta_mx_cond [delta_mx 0 0]mx11_scalar !mxE. by rewrite /= -(inj_eq (can_inj gring_valK)) !gring_indexK. Qed. Lemma regular_mx_faithful : mx_faithful aG. Proof. apply/subsetP=> x /setIdP[Gx]. rewrite mul1mx inE => /eqP/(congr1 (gring_proj 1%g)). rewrite -(repr_mx1 aG) !gring_projE ?group1 // eqxx eq_sym. by case: (x == _) => // /eqP; rewrite eq_sym oner_eq0. Qed. Section GringMx. Variables (n : nat) (rG : mx_representation G n). Definition gring_mx := vec_mx \o mulmxr (enveloping_algebra_mx rG). HB.instance Definition _ := GRing.Linear.on gring_mx. Lemma gring_mxJ a x : x \in G -> gring_mx (a *m aG x) = gring_mx a *m rG x. Proof. move=> Gx; rewrite /gring_mx /= ![a *m _]mulmx_sum_row. rewrite !(mulmx_suml, linear_sum); apply: eq_bigr => i _. rewrite linearZ -!scalemxAl linearZ /=; congr (_ *: _) => {a}. rewrite !rowK /= !mxvecK -rowE rowK mxvecK. by rewrite gring_indexK ?groupM ?repr_mxM ?enum_valP. Qed. End GringMx. Lemma gring_mxK : cancel (gring_mx aG) gring_row. Proof. move=> a; rewrite /gring_mx /= mulmx_sum_row !linear_sum /= [RHS]row_sum_delta. apply: eq_bigr => i _; rewrite 2!linearZ /= /gring_row !(rowK, mxvecK). by rewrite gring_indexK // mul1g gring_valK. Qed. Section GringOp. Variables (n : nat) (rG : mx_representation G n). Definition gring_op := gring_mx rG \o gring_row. HB.instance Definition _ := GRing.Linear.on gring_op. Lemma gring_opE a : gring_op a = gring_mx rG (gring_row a). Proof. by []. Qed. Lemma gring_opG x : x \in G -> gring_op (aG x) = rG x. Proof. move=> Gx; rewrite gring_opE /gring_row rowK gring_indexK // mul1g. by rewrite /gring_mx /= -rowE rowK mxvecK gring_indexK. Qed. Lemma gring_op1 : gring_op 1%:M = 1%:M. Proof. by rewrite -(repr_mx1 aG) gring_opG ?repr_mx1. Qed. Lemma gring_opJ A b : gring_op (A *m gring_mx aG b) = gring_op A *m gring_mx rG b. Proof. rewrite /gring_mx /= ![b *m _]mulmx_sum_row !linear_sum. apply: eq_bigr => i _; rewrite !linearZ /= !rowK !mxvecK. by rewrite gring_opE gring_row_mul gring_mxJ ?enum_valP. Qed. Lemma gring_op_mx b : gring_op (gring_mx aG b) = gring_mx rG b. Proof. by rewrite -[_ b]mul1mx gring_opJ gring_op1 mul1mx. Qed. Lemma gring_mxA a b : gring_mx rG (a *m gring_mx aG b) = gring_mx rG a *m gring_mx rG b. Proof. by rewrite -(gring_op_mx a) -gring_opJ gring_opE gring_row_mul gring_mxK. Qed. End GringOp. End Regular. End RingRepr. Arguments mx_representation R {gT} G%_g n%_N. Arguments mx_repr {R gT} G%_g {n%_N} r. Arguments group_ring R {gT} G%_g. Arguments regular_repr R {gT} G%_g. Arguments centgmxP {R gT G n rG f}. Arguments rkerP {R gT G n rG x}. Arguments repr_mxK {R gT G%_G n%_N} rG {m%_N} [x%_g] Gx. Arguments repr_mxKV {R gT G%_G n%_N} rG {m%_N} [x%_g] Gx. Arguments gring_valK {gT G%_G} i%_R : rename. Arguments gring_indexK {gT G%_G} x%_g. Arguments gring_mxK {R gT G%_G} v%_R : rename. Section ChangeOfRing. Variables (aR rR : comUnitRingType) (f : {rmorphism aR -> rR}). Local Notation "A ^f" := (map_mx (GRing.RMorphism.sort f) A) : ring_scope. Variables (gT : finGroupType) (G : {group gT}). Lemma map_regular_mx x : (regular_mx aR G x)^f = regular_mx rR G x. Proof. by apply/matrixP=> i j; rewrite !mxE rmorph_nat. Qed. Lemma map_gring_row (A : 'M_#|G|) : (gring_row A)^f = gring_row A^f. Proof. by rewrite map_row. Qed. Lemma map_gring_proj x (A : 'M_#|G|) : (gring_proj x A)^f = gring_proj x A^f. Proof. by rewrite map_row -map_trmx map_gring_row. Qed. Section OneRepresentation. Variables (n : nat) (rG : mx_representation aR G n). Definition map_repr_mx (f0 : aR -> rR) rG0 (g : gT) : 'M_n := map_mx f0 (rG0 g). Lemma map_mx_repr : mx_repr G (map_repr_mx f rG). Proof. split=> [|x y Gx Gy]; first by rewrite /map_repr_mx repr_mx1 map_mx1. by rewrite -map_mxM -repr_mxM. Qed. Canonical map_repr := MxRepresentation map_mx_repr. Local Notation rGf := map_repr. Lemma map_reprE x : rGf x = (rG x)^f. Proof. by []. Qed. Lemma map_reprJ m (A : 'M_(m, n)) x : (A *m rG x)^f = A^f *m rGf x. Proof. exact: map_mxM. Qed. Lemma map_enveloping_algebra_mx : (enveloping_algebra_mx rG)^f = enveloping_algebra_mx rGf. Proof. by apply/row_matrixP=> i; rewrite -map_row !rowK map_mxvec. Qed. Lemma map_gring_mx a : (gring_mx rG a)^f = gring_mx rGf a^f. Proof. by rewrite map_vec_mx map_mxM map_enveloping_algebra_mx. Qed. Lemma map_gring_op A : (gring_op rG A)^f = gring_op rGf A^f. Proof. by rewrite map_gring_mx map_gring_row. Qed. End OneRepresentation. Lemma map_regular_repr : map_repr (regular_repr aR G) =1 regular_repr rR G. Proof. exact: map_regular_mx. Qed. Lemma map_group_ring : (group_ring aR G)^f = group_ring rR G. Proof. rewrite map_enveloping_algebra_mx; apply/row_matrixP=> i. by rewrite !rowK map_regular_repr. Qed. (* Stabilisers, etc, are only mapped properly for fields. *) End ChangeOfRing. Section FieldRepr. Variable F : fieldType. Section OneRepresentation. Variable gT : finGroupType. Variables (G : {group gT}) (n : nat) (rG : mx_representation F G n). Arguments rG _%_group_scope : extra scopes. Local Notation E_G := (enveloping_algebra_mx rG). Lemma repr_mx_free x : x \in G -> row_free (rG x). Proof. by move=> Gx; rewrite row_free_unit repr_mx_unit. Qed. Section Stabilisers. Variables (m : nat) (U : 'M[F]_(m, n)). Definition rstabs := [set x in G | U *m rG x <= U]%MS. Lemma rstabs_sub : rstabs \subset G. Proof. by apply/subsetP=> x /setIdP[]. Qed. Lemma rstabs_group_set : group_set rstabs. Proof. apply/group_setP; rewrite inE group1 repr_mx1 mulmx1. split=> //= x y /setIdP[Gx nUx] /setIdP[Gy]; rewrite inE repr_mxM ?groupM //. by apply: submx_trans; rewrite mulmxA submxMr. Qed. Canonical rstabs_group := Group rstabs_group_set. Lemma rstab_act x m1 (W : 'M_(m1, n)) : x \in rstab rG U -> (W <= U)%MS -> W *m rG x = W. Proof. by case/setIdP=> _ /eqP cUx /submxP[w ->]; rewrite -mulmxA cUx. Qed. Lemma rstabs_act x m1 (W : 'M_(m1, n)) : x \in rstabs -> (W <= U)%MS -> (W *m rG x <= U)%MS. Proof. by case/setIdP=> [_ nUx] sWU; apply: submx_trans nUx; apply: submxMr. Qed. Definition mxmodule := G \subset rstabs. Lemma mxmoduleP : reflect {in G, forall x, U *m rG x <= U}%MS mxmodule. Proof. by apply: (iffP subsetP) => modU x Gx; have:= modU x Gx; rewrite !inE ?Gx. Qed. End Stabilisers. Arguments mxmoduleP {m U}. Lemma rstabS m1 m2 (U : 'M_(m1, n)) (V : 'M_(m2, n)) : (U <= V)%MS -> rstab rG V \subset rstab rG U. Proof. case/submxP=> u ->; apply/subsetP=> x. by rewrite !inE => /andP[-> /= /eqP cVx]; rewrite -mulmxA cVx. Qed. Lemma eqmx_rstab m1 m2 (U : 'M_(m1, n)) (V : 'M_(m2, n)) : (U :=: V)%MS -> rstab rG U = rstab rG V. Proof. by move=> eqUV; apply/eqP; rewrite eqEsubset !rstabS ?eqUV. Qed. Lemma eqmx_rstabs m1 m2 (U : 'M_(m1, n)) (V : 'M_(m2, n)) : (U :=: V)%MS -> rstabs U = rstabs V. Proof. by move=> eqUV; apply/setP=> x; rewrite !inE eqUV (eqmxMr _ eqUV). Qed. Lemma eqmx_module m1 m2 (U : 'M_(m1, n)) (V : 'M_(m2, n)) : (U :=: V)%MS -> mxmodule U = mxmodule V. Proof. by move=> eqUV; rewrite /mxmodule (eqmx_rstabs eqUV). Qed. Lemma mxmodule0 m : mxmodule (0 : 'M_(m, n)). Proof. by apply/mxmoduleP=> x _; rewrite mul0mx. Qed. Lemma mxmodule1 : mxmodule 1%:M. Proof. by apply/mxmoduleP=> x _; rewrite submx1. Qed. Lemma mxmodule_trans m1 m2 (U : 'M_(m1, n)) (W : 'M_(m2, n)) x : mxmodule U -> x \in G -> (W <= U -> W *m rG x <= U)%MS. Proof. by move=> modU Gx sWU; apply: submx_trans (mxmoduleP modU x Gx); apply: submxMr. Qed. Lemma mxmodule_eigenvector m (U : 'M_(m, n)) : mxmodule U -> \rank U = 1 -> {u : 'rV_n & {a | (U :=: u)%MS & {in G, forall x, u *m rG x = a x *: u}}}. Proof. move=> modU linU; set u := nz_row U; exists u. have defU: (U :=: u)%MS. apply/eqmxP; rewrite andbC -(geq_leqif (mxrank_leqif_eq _)) ?nz_row_sub //. by rewrite linU lt0n mxrank_eq0 nz_row_eq0 -mxrank_eq0 linU. pose a x := (u *m rG x *m pinvmx u) 0 0; exists a => // x Gx. by rewrite -mul_scalar_mx -mx11_scalar mulmxKpV // -defU mxmodule_trans ?defU. Qed. Lemma addsmx_module m1 m2 U V : @mxmodule m1 U -> @mxmodule m2 V -> mxmodule (U + V)%MS. Proof. move=> modU modV; apply/mxmoduleP=> x Gx. by rewrite addsmxMr addsmxS ?(mxmoduleP _ x Gx). Qed. Lemma sumsmx_module I r (P : pred I) U : (forall i, P i -> mxmodule (U i)) -> mxmodule (\sum_(i <- r | P i) U i)%MS. Proof. by move=> modU; elim/big_ind: _; [apply: mxmodule0 | apply: addsmx_module | ]. Qed. Lemma capmx_module m1 m2 U V : @mxmodule m1 U -> @mxmodule m2 V -> mxmodule (U :&: V)%MS. Proof. move=> modU modV; apply/mxmoduleP=> x Gx. by rewrite sub_capmx !mxmodule_trans ?capmxSl ?capmxSr. Qed. Lemma bigcapmx_module I r (P : pred I) U : (forall i, P i -> mxmodule (U i)) -> mxmodule (\bigcap_(i <- r | P i) U i)%MS. Proof. by move=> modU; elim/big_ind: _; [apply: mxmodule1 | apply: capmx_module | ]. Qed. (* Sub- and factor representations induced by a (sub)module. *) Section Submodule. Variable U : 'M[F]_n. Definition val_submod m : 'M_(m, \rank U) -> 'M_(m, n) := mulmxr (row_base U). Definition in_submod m : 'M_(m, n) -> 'M_(m, \rank U) := mulmxr (invmx (row_ebase U) *m pid_mx (\rank U)). HB.instance Definition _ m := GRing.Linear.on (@val_submod m). HB.instance Definition _ m := GRing.Linear.on (@in_submod m). Lemma val_submodE m W : @val_submod m W = W *m val_submod 1%:M. Proof. by rewrite mulmxA mulmx1. Qed. Lemma in_submodE m W : @in_submod m W = W *m in_submod 1%:M. Proof. by rewrite mulmxA mulmx1. Qed. Lemma val_submod1 : (val_submod 1%:M :=: U)%MS. Proof. by rewrite /val_submod /= mul1mx; apply: eq_row_base. Qed. Lemma val_submodP m W : (@val_submod m W <= U)%MS. Proof. by rewrite mulmx_sub ?eq_row_base. Qed. Lemma val_submodK m : cancel (@val_submod m) (@in_submod m). Proof. move=> W; rewrite /in_submod /= -!mulmxA mulKVmx ?row_ebase_unit //. by rewrite pid_mx_id ?rank_leq_row // pid_mx_1 mulmx1. Qed. Lemma val_submod_inj m : injective (@val_submod m). Proof. exact: can_inj (@val_submodK m). Qed. Lemma val_submodS m1 m2 (V : 'M_(m1, \rank U)) (W : 'M_(m2, \rank U)) : (val_submod V <= val_submod W)%MS = (V <= W)%MS. Proof. apply/idP/idP=> sVW; last exact: submxMr. by rewrite -[V]val_submodK -[W]val_submodK submxMr. Qed. Lemma in_submodK m W : (W <= U)%MS -> val_submod (@in_submod m W) = W. Proof. case/submxP=> w ->; rewrite /val_submod /= -!mulmxA. congr (_ *m _); rewrite -{1}[U]mulmx_ebase !mulmxA mulmxK ?row_ebase_unit //. by rewrite -2!(mulmxA (col_ebase U)) !pid_mx_id ?rank_leq_row // mulmx_ebase. Qed. Lemma val_submod_eq0 m W : (@val_submod m W == 0) = (W == 0). Proof. by rewrite -!submx0 -val_submodS linear0 !(submx0, eqmx0). Qed. Lemma in_submod_eq0 m W : (@in_submod m W == 0) = (W <= U^C)%MS. Proof. apply/eqP/submxP=> [W_U0 | [w ->{W}]]. exists (W *m invmx (row_ebase U)). rewrite mulmxA mulmxBr mulmx1 -(pid_mx_id _ _ _ (leqnn _)). rewrite mulmxA -(mulmxA W) [W *m (_ *m _)]W_U0 mul0mx subr0. by rewrite mulmxKV ?row_ebase_unit. rewrite /in_submod /= -!mulmxA mulKVmx ?row_ebase_unit //. by rewrite mul_copid_mx_pid ?rank_leq_row ?mulmx0. Qed. Lemma mxrank_in_submod m (W : 'M_(m, n)) : (W <= U)%MS -> \rank (in_submod W) = \rank W. Proof. by move=> sWU; apply/eqP; rewrite eqn_leq -{3}(in_submodK sWU) !mxrankM_maxl. Qed. Definition val_factmod m : _ -> 'M_(m, n) := mulmxr (row_base (cokermx U) *m row_ebase U). Definition in_factmod m : 'M_(m, n) -> _ := mulmxr (col_base (cokermx U)). HB.instance Definition _ m := GRing.Linear.on (@val_factmod m). HB.instance Definition _ m := GRing.Linear.on (@in_factmod m). Lemma val_factmodE m W : @val_factmod m W = W *m val_factmod 1%:M. Proof. by rewrite mulmxA mulmx1. Qed. Lemma in_factmodE m W : @in_factmod m W = W *m in_factmod 1%:M. Proof. by rewrite mulmxA mulmx1. Qed. Lemma val_factmodP m W : (@val_factmod m W <= U^C)%MS. Proof. by rewrite mulmx_sub {m W}// (eqmxMr _ (eq_row_base _)) -mulmxA submxMl. Qed. Lemma val_factmodK m : cancel (@val_factmod m) (@in_factmod m). Proof. move=> W /=; rewrite /in_factmod /=; set Uc := cokermx U. apply: (row_free_inj (row_base_free Uc)); rewrite -mulmxA mulmx_base. rewrite /val_factmod /= 2!mulmxA -/Uc mulmxK ?row_ebase_unit //. have /submxP[u ->]: (row_base Uc <= Uc)%MS by rewrite eq_row_base. by rewrite -!mulmxA copid_mx_id ?rank_leq_row. Qed. Lemma val_factmod_inj m : injective (@val_factmod m). Proof. exact: can_inj (@val_factmodK m). Qed. Lemma val_factmodS m1 m2 (V : 'M_(m1, _)) (W : 'M_(m2, _)) : (val_factmod V <= val_factmod W)%MS = (V <= W)%MS. Proof. apply/idP/idP=> sVW; last exact: submxMr. by rewrite -[V]val_factmodK -[W]val_factmodK submxMr. Qed. Lemma val_factmod_eq0 m W : (@val_factmod m W == 0) = (W == 0). Proof. by rewrite -!submx0 -val_factmodS linear0 !(submx0, eqmx0). Qed. Lemma in_factmod_eq0 m (W : 'M_(m, n)) : (in_factmod W == 0) = (W <= U)%MS. Proof. rewrite submxE -!mxrank_eq0 -{2}[_ U]mulmx_base mulmxA. by rewrite (mxrankMfree _ (row_base_free _)). Qed. Lemma in_factmodK m (W : 'M_(m, n)) : (W <= U^C)%MS -> val_factmod (in_factmod W) = W. Proof. case/submxP=> w ->{W}; rewrite /val_factmod /= -2!mulmxA. congr (_ *m _); rewrite (mulmxA (col_base _)) mulmx_base -2!mulmxA. by rewrite mulKVmx ?row_ebase_unit // mulmxA copid_mx_id ?rank_leq_row. Qed. Lemma in_factmod_addsK m (W : 'M_(m, n)) : (in_factmod (U + W)%MS :=: in_factmod W)%MS. Proof. apply: eqmx_trans (addsmxMr _ _ _) _. by rewrite ((_ *m _ =P 0) _) ?in_factmod_eq0 //; apply: adds0mx. Qed. Lemma add_sub_fact_mod m (W : 'M_(m, n)) : val_submod (in_submod W) + val_factmod (in_factmod W) = W. Proof. rewrite /val_submod /val_factmod /= -!mulmxA -mulmxDr. rewrite addrC ![in X in X + _](mulmxA (pid_mx _)) pid_mx_id //. rewrite (mulmxA (col_ebase _)) (mulmxA _ _ (row_ebase _)) mulmx_ebase. rewrite (mulmxA (pid_mx _)) pid_mx_id // mulmxA -mulmxDl -mulmxDr. by rewrite subrK mulmx1 mulmxA mulmxKV ?row_ebase_unit. Qed. Lemma proj_factmodS m (W : 'M_(m, n)) : (val_factmod (in_factmod W) <= U + W)%MS. Proof. by rewrite -{2}[W]add_sub_fact_mod addsmx_addKl ?val_submodP ?addsmxSr. Qed. Lemma in_factmodsK m (W : 'M_(m, n)) : (U <= W)%MS -> (U + val_factmod (in_factmod W) :=: W)%MS. Proof. move/addsmx_idPr; apply: eqmx_trans (eqmx_sym _). by rewrite -{1}[W]add_sub_fact_mod; apply: addsmx_addKl; apply: val_submodP. Qed. Lemma mxrank_in_factmod m (W : 'M_(m, n)) : (\rank (in_factmod W) + \rank U)%N = \rank (U + W). Proof. rewrite -in_factmod_addsK in_factmodE; set fU := in_factmod 1%:M. suffices <-: ((U + W) :&: kermx fU :=: U)%MS by rewrite mxrank_mul_ker. apply: eqmx_trans (capmx_idPr (addsmxSl U W)). apply: cap_eqmx => //; apply/eqmxP/rV_eqP => u. by rewrite (sameP sub_kermxP eqP) -in_factmodE in_factmod_eq0. Qed. Definition submod_mx of mxmodule U := fun x => in_submod (val_submod 1%:M *m rG x). Definition factmod_mx of mxmodule U := fun x => in_factmod (val_factmod 1%:M *m rG x). Hypothesis Umod : mxmodule U. Lemma in_submodJ m (W : 'M_(m, n)) x : (W <= U)%MS -> in_submod (W *m rG x) = in_submod W *m submod_mx Umod x. Proof. move=> sWU; rewrite mulmxA; congr (in_submod _). by rewrite mulmxA -val_submodE in_submodK. Qed. Lemma val_submodJ m (W : 'M_(m, \rank U)) x : x \in G -> val_submod (W *m submod_mx Umod x) = val_submod W *m rG x. Proof. move=> Gx; rewrite 2!(mulmxA W) -val_submodE in_submodK //. by rewrite mxmodule_trans ?val_submodP. Qed. Lemma submod_mx_repr : mx_repr G (submod_mx Umod). Proof. rewrite /submod_mx; split=> [|x y Gx Gy /=]. by rewrite repr_mx1 mulmx1 val_submodK. rewrite -in_submodJ; first by rewrite repr_mxM ?mulmxA. by rewrite mxmodule_trans ?val_submodP. Qed. Canonical submod_repr := MxRepresentation submod_mx_repr. Lemma in_factmodJ m (W : 'M_(m, n)) x : x \in G -> in_factmod (W *m rG x) = in_factmod W *m factmod_mx Umod x. Proof. move=> Gx; rewrite -{1}[W]add_sub_fact_mod mulmxDl linearD /=. apply: (canLR (subrK _)); apply: etrans (_ : 0 = _). apply/eqP; rewrite in_factmod_eq0 (submx_trans _ (mxmoduleP Umod x Gx)) //. by rewrite submxMr ?val_submodP. by rewrite /in_factmod /val_factmod /= !mulmxA mulmx1 ?subrr. Qed. Lemma val_factmodJ m (W : 'M_(m, \rank (cokermx U))) x : x \in G -> val_factmod (W *m factmod_mx Umod x) = val_factmod (in_factmod (val_factmod W *m rG x)). Proof. by move=> Gx; rewrite -{1}[W]val_factmodK -in_factmodJ. Qed. Lemma factmod_mx_repr : mx_repr G (factmod_mx Umod). Proof. split=> [|x y Gx Gy /=]. by rewrite /factmod_mx repr_mx1 mulmx1 val_factmodK. by rewrite -in_factmodJ // -mulmxA -repr_mxM. Qed. Canonical factmod_repr := MxRepresentation factmod_mx_repr. (* For character theory. *) Lemma mxtrace_sub_fact_mod x : \tr (submod_repr x) + \tr (factmod_repr x) = \tr (rG x). Proof. rewrite -[submod_repr x]mulmxA mxtrace_mulC -val_submodE addrC. rewrite -[factmod_repr x]mulmxA mxtrace_mulC -val_factmodE addrC. by rewrite -mxtraceD add_sub_fact_mod. Qed. End Submodule. (* Properties of enveloping algebra as a subspace of 'rV_(n ^ 2). *) Lemma envelop_mx_id x : x \in G -> (rG x \in E_G)%MS. Proof. by move=> Gx; rewrite (eq_row_sub (enum_rank_in Gx x)) // rowK enum_rankK_in. Qed. Lemma envelop_mx1 : (1%:M \in E_G)%MS. Proof. by rewrite -(repr_mx1 rG) envelop_mx_id. Qed. Lemma envelop_mxP A : reflect (exists a, A = \sum_(x in G) a x *: rG x) (A \in E_G)%MS. Proof. have G_1 := group1 G; have bijG := enum_val_bij_in G_1. set h := enum_val in bijG; have Gh: h _ \in G by apply: enum_valP. apply: (iffP submxP) => [[u defA] | [a ->]]. exists (fun x => u 0 (enum_rank_in G_1 x)); apply: (can_inj mxvecK). rewrite defA mulmx_sum_row linear_sum (reindex h) //=. by apply: eq_big => [i | i _]; rewrite ?Gh // rowK linearZ enum_valK_in. exists (\row_i a (h i)); rewrite mulmx_sum_row linear_sum (reindex h) //=. by apply: eq_big => [i | i _]; rewrite ?Gh // mxE rowK linearZ. Qed. Lemma envelop_mxM A B : (A \in E_G -> B \in E_G -> A *m B \in E_G)%MS. Proof. move=> {A B} /envelop_mxP[a ->] /envelop_mxP[b ->]. rewrite mulmx_suml !linear_sum summx_sub //= => x Gx. rewrite !linear_sum summx_sub //= => y Gy. rewrite -scalemxAl 3!linearZ !scalemx_sub//= -repr_mxM //. by rewrite envelop_mx_id ?groupM. Qed. Lemma mxmodule_envelop m1 m2 (U : 'M_(m1, n)) (W : 'M_(m2, n)) A : (mxmodule U -> mxvec A <= E_G -> W <= U -> W *m A <= U)%MS. Proof. move=> modU /envelop_mxP[a ->] sWU; rewrite linear_sum summx_sub //= => x Gx. by rewrite -scalemxAr scalemx_sub ?mxmodule_trans. Qed. (* Module homomorphisms; any square matrix f defines a module homomorphism *) (* over some domain, namely, dom_hom_mx f. *) Definition dom_hom_mx f : 'M_n := kermx (lin1_mx (mxvec \o mulmx (cent_mx_fun E_G f) \o lin_mul_row)). Lemma hom_mxP m f (W : 'M_(m, n)) : reflect (forall x, x \in G -> W *m rG x *m f = W *m f *m rG x) (W <= dom_hom_mx f)%MS. Proof. apply: (iffP row_subP) => [cGf x Gx | cGf i]. apply/row_matrixP=> i; apply/eqP; rewrite -subr_eq0 -!mulmxA -!linearB /=. have:= sub_kermxP (cGf i); rewrite mul_rV_lin1 /=. move/(canRL mxvecK)/row_matrixP/(_ (enum_rank_in Gx x))/eqP; rewrite !linear0. by rewrite !row_mul rowK mul_vec_lin /= mul_vec_lin_row enum_rankK_in. apply/sub_kermxP; rewrite mul_rV_lin1 /=; apply: (canLR vec_mxK). apply/row_matrixP=> j; rewrite !row_mul rowK mul_vec_lin /= mul_vec_lin_row. by rewrite -!row_mul mulmxBr !mulmxA cGf ?enum_valP // subrr !linear0. Qed. Arguments hom_mxP {m f W}. Lemma hom_envelop_mxC m f (W : 'M_(m, n)) A : (W <= dom_hom_mx f -> A \in E_G -> W *m A *m f = W *m f *m A)%MS. Proof. move/hom_mxP=> cWfG /envelop_mxP[a ->]; rewrite !linear_sum mulmx_suml. by apply: eq_bigr => x Gx /=; rewrite -2!scalemxAr -scalemxAl cWfG. Qed. Lemma dom_hom_invmx f : f \in unitmx -> (dom_hom_mx (invmx f) :=: dom_hom_mx f *m f)%MS. Proof. move=> injf; set U := dom_hom_mx _; apply/eqmxP. rewrite -{1}[U](mulmxKV injf) submxMr; apply/hom_mxP=> x Gx. by rewrite -[_ *m rG x](hom_mxP _) ?mulmxK. by rewrite -[_ *m rG x](hom_mxP _) ?mulmxKV. Qed. Lemma dom_hom_mx_module f : mxmodule (dom_hom_mx f). Proof. apply/mxmoduleP=> x Gx; apply/hom_mxP=> y Gy. rewrite -[_ *m rG y]mulmxA -repr_mxM // 2?(hom_mxP _) ?groupM //. by rewrite repr_mxM ?mulmxA. Qed. Lemma hom_mxmodule m (U : 'M_(m, n)) f : (U <= dom_hom_mx f)%MS -> mxmodule U -> mxmodule (U *m f). Proof. move/hom_mxP=> cGfU modU; apply/mxmoduleP=> x Gx. by rewrite -cGfU // submxMr // (mxmoduleP modU). Qed. Lemma kermx_hom_module m (U : 'M_(m, n)) f : (U <= dom_hom_mx f)%MS -> mxmodule U -> mxmodule (U :&: kermx f)%MS. Proof. move=> homUf modU; apply/mxmoduleP=> x Gx. rewrite sub_capmx mxmodule_trans ?capmxSl //=. apply/sub_kermxP; rewrite (hom_mxP _) ?(submx_trans (capmxSl _ _)) //. by rewrite (sub_kermxP (capmxSr _ _)) mul0mx. Qed. Lemma scalar_mx_hom a m (U : 'M_(m, n)) : (U <= dom_hom_mx a%:M)%MS. Proof. by apply/hom_mxP=> x Gx; rewrite -!mulmxA scalar_mxC. Qed. Lemma proj_mx_hom (U V : 'M_n) : (U :&: V = 0)%MS -> mxmodule U -> mxmodule V -> (U + V <= dom_hom_mx (proj_mx U V))%MS. Proof. move=> dxUV modU modV; apply/hom_mxP=> x Gx. rewrite -{1}(add_proj_mx dxUV (submx_refl _)) !mulmxDl addrC. rewrite {1}[_ *m _]proj_mx_0 ?add0r //; last first. by rewrite mxmodule_trans ?proj_mx_sub. by rewrite [_ *m _](proj_mx_id dxUV) // mxmodule_trans ?proj_mx_sub. Qed. (* The subspace fixed by a subgroup H of G; it is a module if H <| G. *) (* The definition below is extensionally equivalent to the straightforward *) (* \bigcap_(x in H) kermx (rG x - 1%:M) *) (* but it avoids the dependency on the choice function; this allows it to *) (* commute with ring morphisms. *) Definition rfix_mx (H : {set gT}) := let commrH := \matrix_(i < #|H|) mxvec (rG (enum_val i) - 1%:M) in kermx (lin1_mx (mxvec \o mulmx commrH \o lin_mul_row)). Lemma rfix_mxP m (W : 'M_(m, n)) (H : {set gT}) : reflect (forall x, x \in H -> W *m rG x = W) (W <= rfix_mx H)%MS. Proof. rewrite /rfix_mx; set C := \matrix_i _. apply: (iffP row_subP) => [cHW x Hx | cHW j]. apply/row_matrixP=> j; apply/eqP; rewrite -subr_eq0 row_mul. move/sub_kermxP: {cHW}(cHW j); rewrite mul_rV_lin1 /=; move/(canRL mxvecK). move/row_matrixP/(_ (enum_rank_in Hx x)); rewrite row_mul rowK !linear0. by rewrite enum_rankK_in // mul_vec_lin_row mulmxBr mulmx1 => ->. apply/sub_kermxP; rewrite mul_rV_lin1 /=; apply: (canLR vec_mxK). apply/row_matrixP=> i; rewrite row_mul rowK mul_vec_lin_row -row_mul. by rewrite mulmxBr mulmx1 cHW ?enum_valP // subrr !linear0. Qed. Arguments rfix_mxP {m W}. Lemma rfix_mx_id (H : {set gT}) x : x \in H -> rfix_mx H *m rG x = rfix_mx H. Proof. exact/rfix_mxP. Qed. Lemma rfix_mxS (H K : {set gT}) : H \subset K -> (rfix_mx K <= rfix_mx H)%MS. Proof. by move=> sHK; apply/rfix_mxP=> x Hx; apply: rfix_mxP (subsetP sHK x Hx). Qed. Lemma rfix_mx_conjsg (H : {set gT}) x : x \in G -> H \subset G -> (rfix_mx (H :^ x) :=: rfix_mx H *m rG x)%MS. Proof. move=> Gx sHG; pose rf y := rfix_mx (H :^ y). suffices{x Gx} IH: {in G &, forall y z, rf y *m rG z <= rf (y * z)%g}%MS. apply/eqmxP; rewrite -/(rf x) -[H]conjsg1 -/(rf 1%g). rewrite -{4}[x] mul1g -{1}[rf x](repr_mxKV rG Gx) -{1}(mulgV x). by rewrite submxMr IH ?groupV. move=> x y Gx Gy; apply/rfix_mxP=> zxy; rewrite actM => /imsetP[zx Hzx ->]. have Gzx: zx \in G by apply: subsetP Hzx; rewrite conj_subG. rewrite -mulmxA -repr_mxM ?groupM ?groupV // -conjgC repr_mxM // mulmxA. by rewrite rfix_mx_id. Qed. Lemma norm_sub_rstabs_rfix_mx (H : {set gT}) : H \subset G -> 'N_G(H) \subset rstabs (rfix_mx H). Proof. move=> sHG; apply/subsetP=> x /setIP[Gx nHx]; rewrite inE Gx. apply/rfix_mxP=> y Hy; have Gy := subsetP sHG y Hy. have Hyx: (y ^ x^-1)%g \in H by rewrite memJ_norm ?groupV. rewrite -mulmxA -repr_mxM // conjgCV repr_mxM ?(subsetP sHG _ Hyx) // mulmxA. by rewrite (rfix_mx_id Hyx). Qed. Lemma normal_rfix_mx_module H : H <| G -> mxmodule (rfix_mx H). Proof. case/andP=> sHG nHG. by rewrite /mxmodule -{1}(setIidPl nHG) norm_sub_rstabs_rfix_mx. Qed. Lemma rfix_mx_module : mxmodule (rfix_mx G). Proof. exact: normal_rfix_mx_module. Qed. Lemma rfix_mx_rstabC (H : {set gT}) m (U : 'M[F]_(m, n)) : H \subset G -> (H \subset rstab rG U) = (U <= rfix_mx H)%MS. Proof. move=> sHG; apply/subsetP/rfix_mxP=> cHU x Hx. by rewrite (rstab_act (cHU x Hx)). by rewrite !inE (subsetP sHG) //= cHU. Qed. (* The cyclic module generated by a single vector. *) Definition cyclic_mx u := <<E_G *m lin_mul_row u>>%MS. Lemma cyclic_mxP u v : reflect (exists2 A, A \in E_G & v = u *m A)%MS (v <= cyclic_mx u)%MS. Proof. rewrite genmxE; apply: (iffP submxP) => [[a] | [A /submxP[a defA]]] -> {v}. exists (vec_mx (a *m E_G)); last by rewrite mulmxA mul_rV_lin1. by rewrite vec_mxK submxMl. by exists a; rewrite mulmxA mul_rV_lin1 /= -defA mxvecK. Qed. Arguments cyclic_mxP {u v}. Lemma cyclic_mx_id u : (u <= cyclic_mx u)%MS. Proof. by apply/cyclic_mxP; exists 1%:M; rewrite ?mulmx1 ?envelop_mx1. Qed. Lemma cyclic_mx_eq0 u : (cyclic_mx u == 0) = (u == 0). Proof. rewrite -!submx0; apply/idP/idP. by apply: submx_trans; apply: cyclic_mx_id. move/submx0null->; rewrite genmxE; apply/row_subP=> i. by rewrite row_mul mul_rV_lin1 /= mul0mx ?sub0mx. Qed. Lemma cyclic_mx_module u : mxmodule (cyclic_mx u). Proof. apply/mxmoduleP=> x Gx; apply/row_subP=> i; rewrite row_mul. have [A E_A ->{i}] := @cyclic_mxP u _ (row_sub i _); rewrite -mulmxA. by apply/cyclic_mxP; exists (A *m rG x); rewrite ?envelop_mxM ?envelop_mx_id. Qed. Lemma cyclic_mx_sub m u (W : 'M_(m, n)) : mxmodule W -> (u <= W)%MS -> (cyclic_mx u <= W)%MS. Proof. move=> modU Wu; rewrite genmxE; apply/row_subP=> i. by rewrite row_mul mul_rV_lin1 /= mxmodule_envelop // vec_mxK row_sub. Qed. Lemma hom_cyclic_mx u f : (u <= dom_hom_mx f)%MS -> (cyclic_mx u *m f :=: cyclic_mx (u *m f))%MS. Proof. move=> domf_u; apply/eqmxP; rewrite !(eqmxMr _ (genmxE _)). apply/genmxP; rewrite genmx_id; congr <<_>>%MS; apply/row_matrixP=> i. by rewrite !row_mul !mul_rV_lin1 /= hom_envelop_mxC // vec_mxK row_sub. Qed. (* The annihilator of a single vector. *) Definition annihilator_mx u := (E_G :&: kermx (lin_mul_row u))%MS. Lemma annihilator_mxP u A : reflect (A \in E_G /\ u *m A = 0)%MS (A \in annihilator_mx u)%MS. Proof. rewrite sub_capmx; apply: (iffP andP) => [[-> /sub_kermxP]|[-> uA0]]. by rewrite mul_rV_lin1 /= mxvecK. by split=> //; apply/sub_kermxP; rewrite mul_rV_lin1 /= mxvecK. Qed. (* The subspace of homomorphic images of a row vector. *) Definition row_hom_mx u := (\bigcap_j kermx (vec_mx (row j (annihilator_mx u))))%MS. Lemma row_hom_mxP u v : reflect (exists2 f, u <= dom_hom_mx f & u *m f = v)%MS (v <= row_hom_mx u)%MS. Proof. apply: (iffP sub_bigcapmxP) => [iso_uv | [f hom_uf <-] i _]. have{iso_uv} uv0 A: (A \in E_G)%MS /\ u *m A = 0 -> v *m A = 0. move/annihilator_mxP=> /submxP[a defA]. rewrite -[A]mxvecK {A}defA [a *m _]mulmx_sum_row !linear_sum big1 // => i _. by rewrite !linearZ /= (sub_kermxP _) ?scaler0 ?iso_uv. pose U := E_G *m lin_mul_row u; pose V := E_G *m lin_mul_row v. pose f := pinvmx U *m V. have hom_uv_f x: x \in G -> u *m rG x *m f = v *m rG x. move=> Gx; apply/eqP; rewrite 2!mulmxA mul_rV_lin1 -subr_eq0 -mulmxBr /=. rewrite uv0 // linearB /= mulmxBr vec_mxK; split. (* FIXME: slow *) by rewrite addmx_sub ?submxMl // eqmx_opp envelop_mx_id. have Uux: (u *m rG x <= U)%MS. by rewrite -(genmxE U) mxmodule_trans ?cyclic_mx_id ?cyclic_mx_module. by rewrite -{2}(mulmxKpV Uux) [_ *m U]mulmxA mul_rV_lin1 subrr. have def_uf: u *m f = v. by rewrite -[u]mulmx1 -[v]mulmx1 -(repr_mx1 rG) hom_uv_f. by exists f => //; apply/hom_mxP=> x Gx; rewrite def_uf hom_uv_f. apply/sub_kermxP; set A := vec_mx _. have: (A \in annihilator_mx u)%MS by rewrite vec_mxK row_sub. by case/annihilator_mxP => E_A uA0; rewrite -hom_envelop_mxC // uA0 mul0mx. Qed. (* Sub-, isomorphic, simple, semisimple and completely reducible modules. *) (* All these predicates are intuitionistic (since, e.g., testing simplicity *) (* requires a splitting algorithm fo r the mas field). They are all *) (* specialized to square matrices, to avoid spurious height parameters. *) (* Module isomorphism is an intentional property in general, but it can be *) (* decided when one of the two modules is known to be simple. *) Variant mx_iso (U V : 'M_n) : Prop := MxIso f of f \in unitmx & (U <= dom_hom_mx f)%MS & (U *m f :=: V)%MS. Lemma eqmx_iso U V : (U :=: V)%MS -> mx_iso U V. Proof. by move=> eqUV; exists 1%:M; rewrite ?unitmx1 ?scalar_mx_hom ?mulmx1. Qed. Lemma mx_iso_refl U : mx_iso U U. Proof. exact: eqmx_iso. Qed. Lemma mx_iso_sym U V : mx_iso U V -> mx_iso V U. Proof. case=> f injf homUf defV; exists (invmx f); first by rewrite unitmx_inv. by rewrite dom_hom_invmx // -defV submxMr. by rewrite -[U](mulmxK injf); apply: eqmxMr (eqmx_sym _). Qed. Lemma mx_iso_trans U V W : mx_iso U V -> mx_iso V W -> mx_iso U W. Proof. case=> f injf homUf defV [g injg homVg defW]. exists (f *m g); first by rewrite unitmx_mul injf. by apply/hom_mxP=> x Gx; rewrite !mulmxA 2?(hom_mxP _) ?defV. by rewrite mulmxA; apply: eqmx_trans (eqmxMr g defV) defW. Qed. Lemma mxrank_iso U V : mx_iso U V -> \rank U = \rank V. Proof. by case=> f injf _ <-; rewrite mxrankMfree ?row_free_unit. Qed. Lemma mx_iso_module U V : mx_iso U V -> mxmodule U -> mxmodule V. Proof. by case=> f _ homUf defV; rewrite -(eqmx_module defV); apply: hom_mxmodule. Qed. (* Simple modules (we reserve the term "irreducible" for representations). *) Definition mxsimple (V : 'M_n) := [/\ mxmodule V, V != 0 & forall U : 'M_n, mxmodule U -> (U <= V)%MS -> U != 0 -> (V <= U)%MS]. Definition mxnonsimple (U : 'M_n) := exists V : 'M_n, [&& mxmodule V, (V <= U)%MS, V != 0 & \rank V < \rank U]. Lemma mxsimpleP U : [/\ mxmodule U, U != 0 & ~ mxnonsimple U] <-> mxsimple U. Proof. do [split => [] [modU nzU simU]; split] => // [V modV sVU nzV | [V]]. apply/idPn; rewrite -(ltn_leqif (mxrank_leqif_sup sVU)) => ltVU. by case: simU; exists V; apply/and4P. by case/and4P=> modV sVU nzV; apply/negP; rewrite -leqNgt mxrankS ?simU. Qed. Lemma mxsimple_module U : mxsimple U -> mxmodule U. Proof. by case. Qed. Lemma mxsimple_exists m (U : 'M_(m, n)) : mxmodule U -> U != 0 -> classically (exists2 V, mxsimple V & V <= U)%MS. Proof. move=> modU nzU [] // simU; move: {2}_.+1 (ltnSn (\rank U)) => r leUr. elim: r => // r IHr in m U leUr modU nzU simU. have genU := genmxE U; apply: (simU); exists <<U>>%MS; last by rewrite genU. apply/mxsimpleP; split; rewrite ?(eqmx_eq0 genU) ?(eqmx_module genU) //. case=> V; rewrite !genU=> /and4P[modV sVU nzV ltVU]; case: notF. apply: IHr nzV _ => // [|[W simW sWV]]; first exact: leq_trans ltVU _. by apply: simU; exists W => //; apply: submx_trans sWV sVU. Qed. Lemma mx_iso_simple U V : mx_iso U V -> mxsimple U -> mxsimple V. Proof. move=> isoUV [modU nzU simU]; have [f injf homUf defV] := isoUV. split=> [||W modW sWV nzW]; first by rewrite (mx_iso_module isoUV). by rewrite -(eqmx_eq0 defV) -(mul0mx n f) (can_eq (mulmxK injf)). rewrite -defV -[W](mulmxKV injf) submxMr //; set W' := W *m _. have sW'U: (W' <= U)%MS by rewrite -[U](mulmxK injf) submxMr ?defV. rewrite (simU W') //; last by rewrite -(can_eq (mulmxK injf)) mul0mx mulmxKV. rewrite hom_mxmodule ?dom_hom_invmx // -[W](mulmxKV injf) submxMr //. exact: submx_trans sW'U homUf. Qed. Lemma mxsimple_cyclic u U : mxsimple U -> u != 0 -> (u <= U)%MS -> (U :=: cyclic_mx u)%MS. Proof. case=> [modU _ simU] nz_u Uu; apply/eqmxP; set uG := cyclic_mx u. have s_uG_U: (uG <= U)%MS by rewrite cyclic_mx_sub. by rewrite simU ?cyclic_mx_eq0 ?submx_refl // cyclic_mx_module. Qed. (* The surjective part of Schur's lemma. *) Lemma mx_Schur_onto m (U : 'M_(m, n)) V f : mxmodule U -> mxsimple V -> (U <= dom_hom_mx f)%MS -> (U *m f <= V)%MS -> U *m f != 0 -> (U *m f :=: V)%MS. Proof. move=> modU [modV _ simV] homUf sUfV nzUf. apply/eqmxP; rewrite sUfV -(genmxE (U *m f)). rewrite simV ?(eqmx_eq0 (genmxE _)) ?genmxE //. by rewrite (eqmx_module (genmxE _)) hom_mxmodule. Qed. (* The injective part of Schur's lemma. *) Lemma mx_Schur_inj U f : mxsimple U -> (U <= dom_hom_mx f)%MS -> U *m f != 0 -> (U :&: kermx f)%MS = 0. Proof. case=> [modU _ simU] homUf nzUf; apply/eqP; apply: contraR nzUf => nz_ker. rewrite (sameP eqP sub_kermxP) (sameP capmx_idPl eqmxP) simU ?capmxSl //. exact: kermx_hom_module. Qed. (* The injectve part of Schur's lemma, stated as isomorphism with the image. *) Lemma mx_Schur_inj_iso U f : mxsimple U -> (U <= dom_hom_mx f)%MS -> U *m f != 0 -> mx_iso U (U *m f). Proof. move=> simU homUf nzUf; have [modU _ _] := simU. have eqUfU: \rank (U *m f) = \rank U by apply/mxrank_injP; rewrite mx_Schur_inj. have{eqUfU} [g invg defUf] := complete_unitmx eqUfU. suffices homUg: (U <= dom_hom_mx g)%MS by exists g; rewrite ?defUf. apply/hom_mxP=> x Gx; have [ux defUx] := submxP (mxmoduleP modU x Gx). by rewrite -defUf -(hom_mxP homUf) // defUx -!(mulmxA ux) defUf. Qed. (* The isomorphism part of Schur's lemma. *) Lemma mx_Schur_iso U V f : mxsimple U -> mxsimple V -> (U <= dom_hom_mx f)%MS -> (U *m f <= V)%MS -> U *m f != 0 -> mx_iso U V. Proof. move=> simU simV homUf sUfV nzUf; have [modU _ _] := simU. have [g invg homUg defUg] := mx_Schur_inj_iso simU homUf nzUf. exists g => //; apply: mx_Schur_onto; rewrite ?defUg //. by rewrite -!submx0 defUg in nzUf *. Qed. (* A boolean test for module isomorphism that is only valid for simple *) (* modules; this is the only case that matters in practice. *) Lemma nz_row_mxsimple U : mxsimple U -> nz_row U != 0. Proof. by case=> _ nzU _; rewrite nz_row_eq0. Qed. Definition mxsimple_iso (U V : 'M_n) := [&& mxmodule V, (V :&: row_hom_mx (nz_row U))%MS != 0 & \rank V <= \rank U]. Lemma mxsimple_isoP U V : mxsimple U -> reflect (mx_iso U V) (mxsimple_iso U V). Proof. move=> simU; pose u := nz_row U. have [Uu nz_u]: (u <= U)%MS /\ u != 0 by rewrite nz_row_sub nz_row_mxsimple. apply: (iffP and3P) => [[modV] | isoUV]; last first. split; last by rewrite (mxrank_iso isoUV). by case: (mx_iso_simple isoUV simU). have [f injf homUf defV] := isoUV; apply/rowV0Pn; exists (u *m f). rewrite sub_capmx -defV submxMr //. by apply/row_hom_mxP; exists f; first apply: (submx_trans Uu). by rewrite -(mul0mx _ f) (can_eq (mulmxK injf)) nz_u. case/rowV0Pn=> v; rewrite sub_capmx => /andP[Vv]. case/row_hom_mxP => f homMf def_v nz_v eqrUV. pose uG := cyclic_mx u; pose vG := cyclic_mx v. have def_vG: (uG *m f :=: vG)%MS by rewrite /vG -def_v; apply: hom_cyclic_mx. have defU: (U :=: uG)%MS by apply: mxsimple_cyclic. have mod_uG: mxmodule uG by rewrite cyclic_mx_module. have homUf: (U <= dom_hom_mx f)%MS. by rewrite defU cyclic_mx_sub ?dom_hom_mx_module. have isoUf: mx_iso U (U *m f). apply: mx_Schur_inj_iso => //; apply: contra nz_v; rewrite -!submx0. by rewrite (eqmxMr f defU) def_vG; apply: submx_trans (cyclic_mx_id v). apply: mx_iso_trans (isoUf) (eqmx_iso _); apply/eqmxP. have sUfV: (U *m f <= V)%MS by rewrite (eqmxMr f defU) def_vG cyclic_mx_sub. by rewrite -mxrank_leqif_eq ?eqn_leq 1?mxrankS // -(mxrank_iso isoUf). Qed. Lemma mxsimple_iso_simple U V : mxsimple_iso U V -> mxsimple U -> mxsimple V. Proof. by move=> isoUV simU; apply: mx_iso_simple (simU); apply/mxsimple_isoP. Qed. (* For us, "semisimple" means "sum of simple modules"; this is classically, *) (* but not intuitionistically, equivalent to the "completely reducible" *) (* alternate characterization. *) Implicit Type I : finType. Variant mxsemisimple (V : 'M_n) := MxSemisimple I U (W := (\sum_(i : I) U i)%MS) of forall i, mxsimple (U i) & (W :=: V)%MS & mxdirect W. (* This is a slight generalization of Aschbacher 12.5 for finite sets. *) Lemma sum_mxsimple_direct_compl m I W (U : 'M_(m, n)) : let V := (\sum_(i : I) W i)%MS in (forall i : I, mxsimple (W i)) -> mxmodule U -> (U <= V)%MS -> {J : {set I} | let S := U + \sum_(i in J) W i in S :=: V /\ mxdirect S}%MS. Proof. move=> V simW modU sUV; pose V_ (J : {set I}) := (\sum_(i in J) W i)%MS. pose dxU (J : {set I}) := mxdirect (U + V_ J). have [J maxJ]: {J | maxset dxU J}; last case/maxsetP: maxJ => dxUVJ maxJ. apply: ex_maxset; exists set0. by rewrite /dxU mxdirectE /V_ /= !big_set0 addn0 addsmx0 /=. have modWJ: mxmodule (V_ J) by apply: sumsmx_module => i _; case: (simW i). exists J; split=> //; apply/eqmxP; rewrite addsmx_sub sUV; apply/andP; split. by apply/sumsmx_subP=> i Ji; rewrite (sumsmx_sup i). rewrite -/(V_ J); apply/sumsmx_subP=> i _. case Ji: (i \in J). by apply: submx_trans (addsmxSr _ _); apply: (sumsmx_sup i). have [modWi nzWi simWi] := simW i. rewrite (sameP capmx_idPl eqmxP) simWi ?capmxSl ?capmx_module ?addsmx_module //. apply: contraFT (Ji); rewrite negbK => dxWiUVJ. rewrite -(maxJ (i |: J)) ?setU11 ?subsetUr // /dxU. rewrite mxdirectE /= !big_setU1 ?Ji //=. rewrite addnCA addsmxA (addsmxC U) -addsmxA -mxdirectE /=. by rewrite mxdirect_addsE /= mxdirect_trivial -/(dxU _) dxUVJ. Qed. Lemma sum_mxsimple_direct_sub I W (V : 'M_n) : (forall i : I, mxsimple (W i)) -> (\sum_i W i :=: V)%MS -> {J : {set I} | let S := \sum_(i in J) W i in S :=: V /\ mxdirect S}%MS. Proof. move=> simW defV. have [|J [defS dxS]] := sum_mxsimple_direct_compl simW (mxmodule0 n). exact: sub0mx. exists J; split; last by rewrite mxdirectE /= adds0mx mxrank0 in dxS. by apply: eqmx_trans defV; rewrite adds0mx_id in defS. Qed. Lemma mxsemisimple0 : mxsemisimple 0. Proof. exists 'I_0 (fun _ => 0); [by case | by rewrite big_ord0 | ]. by rewrite mxdirectE /= !big_ord0 mxrank0. Qed. Lemma intro_mxsemisimple (I : Type) r (P : pred I) W V : (\sum_(i <- r | P i) W i :=: V)%MS -> (forall i, P i -> W i != 0 -> mxsimple (W i)) -> mxsemisimple V. Proof. move=> defV simW; pose W_0 := [pred i | W i == 0]. have [-> | nzV] := eqVneq V 0; first exact: mxsemisimple0. case def_r: r => [| i0 r'] => [|{r' def_r}]. by rewrite -mxrank_eq0 -defV def_r big_nil mxrank0 in nzV. move: defV; rewrite (bigID W_0) /= addsmxC -big_filter !(big_nth i0) !big_mkord. rewrite addsmxC big1 ?adds0mx_id => [|i /andP[_ /eqP] //]. set tI := 'I_(_); set r_ := nth _ _ => defV. have{simW} simWr (i : tI) : mxsimple (W (r_ i)). case: i => m /=; set Pr := fun i => _ => lt_m_r /=. suffices: (Pr (r_ m)) by case/andP; apply: simW. apply: all_nthP m lt_m_r; apply/all_filterP. by rewrite -filter_predI; apply: eq_filter => i; rewrite /= andbb. have [J []] := sum_mxsimple_direct_sub simWr defV. case: (set_0Vmem J) => [-> V0 | [j0 Jj0]]. by rewrite -mxrank_eq0 -V0 big_set0 mxrank0 in nzV. pose K := {j | j \in J}; pose k0 : K := Sub j0 Jj0. have bij_KJ: {on J, bijective (sval : K -> _)}. by exists (insubd k0) => [k _ | j Jj]; rewrite ?valKd ?insubdK. have J_K (k : K) : sval k \in J by apply: valP k. rewrite mxdirectE /= !(reindex _ bij_KJ) !(eq_bigl _ _ J_K) -mxdirectE /= -/tI. exact: MxSemisimple. Qed. Lemma mxsimple_semisimple U : mxsimple U -> mxsemisimple U. Proof. move=> simU; apply: (intro_mxsemisimple (_ : \sum_(i < 1) U :=: U))%MS => //. by rewrite big_ord1. Qed. Lemma addsmx_semisimple U V : mxsemisimple U -> mxsemisimple V -> mxsemisimple (U + V)%MS. Proof. case=> [I W /= simW defU _] [J T /= simT defV _]. have defUV: (\sum_ij sum_rect (fun _ => 'M_n) W T ij :=: U + V)%MS. by rewrite big_sumType /=; apply: adds_eqmx. by apply: intro_mxsemisimple defUV _; case=> /=. Qed. Lemma sumsmx_semisimple (I : finType) (P : pred I) V : (forall i, P i -> mxsemisimple (V i)) -> mxsemisimple (\sum_(i | P i) V i)%MS. Proof. move=> ssimV; elim/big_ind: _ => //; first exact: mxsemisimple0. exact: addsmx_semisimple. Qed. Lemma eqmx_semisimple U V : (U :=: V)%MS -> mxsemisimple U -> mxsemisimple V. Proof. by move=> eqUV [I W S simW defU dxS]; exists I W => //; apply: eqmx_trans eqUV. Qed. Lemma hom_mxsemisimple (V f : 'M_n) : mxsemisimple V -> (V <= dom_hom_mx f)%MS -> mxsemisimple (V *m f). Proof. case=> I W /= simW defV _; rewrite -defV => /sumsmx_subP homWf. have{defV} defVf: (\sum_i W i *m f :=: V *m f)%MS. by apply: eqmx_trans (eqmx_sym _) (eqmxMr f defV); apply: sumsmxMr. apply: (intro_mxsemisimple defVf) => i _ nzWf. by apply: mx_iso_simple (simW i); apply: mx_Schur_inj_iso; rewrite ?homWf. Qed. Lemma mxsemisimple_module U : mxsemisimple U -> mxmodule U. Proof. case=> I W /= simW defU _. by rewrite -(eqmx_module defU) sumsmx_module // => i _; case: (simW i). Qed. (* Completely reducible modules, and Maeschke's Theorem. *) Variant mxsplits (V U : 'M_n) := MxSplits (W : 'M_n) of mxmodule W & (U + W :=: V)%MS & mxdirect (U + W). Definition mx_completely_reducible V := forall U, mxmodule U -> (U <= V)%MS -> mxsplits V U. Lemma mx_reducibleS U V : mxmodule U -> (U <= V)%MS -> mx_completely_reducible V -> mx_completely_reducible U. Proof. move=> modU sUV redV U1 modU1 sU1U. have [W modW defV dxU1W] := redV U1 modU1 (submx_trans sU1U sUV). exists (W :&: U)%MS; first exact: capmx_module. by apply/eqmxP; rewrite !matrix_modl // capmxSr sub_capmx defV sUV /=. by apply/mxdirect_addsP; rewrite capmxA (mxdirect_addsP dxU1W) cap0mx. Qed. Lemma mx_Maschke_pchar : [pchar F]^'.-group G -> mx_completely_reducible 1%:M. Proof. rewrite /pgroup pcharf'_nat; set nG := _%:R => nzG U => /mxmoduleP Umod _. pose phi := nG^-1 *: (\sum_(x in G) rG x^-1 *m pinvmx U *m U *m rG x). have phiG x: x \in G -> phi *m rG x = rG x *m phi. move=> Gx; rewrite -scalemxAl -scalemxAr; congr (_ *: _). rewrite {2}(reindex_acts 'R _ Gx) ?astabsR //= mulmx_suml mulmx_sumr. apply: eq_bigr => y Gy; rewrite !mulmxA -repr_mxM ?groupV ?groupM //. by rewrite invMg mulKVg repr_mxM ?mulmxA. have Uphi: U *m phi = U. rewrite -scalemxAr mulmx_sumr (eq_bigr (fun _ => U)) => [|x Gx]. by rewrite sumr_const -scaler_nat !scalerA mulVf ?scale1r. by rewrite 3!mulmxA mulmxKpV ?repr_mxKV ?Umod ?groupV. have tiUker: (U :&: kermx phi = 0)%MS. apply/eqP/rowV0P=> v; rewrite sub_capmx => /andP[/submxP[u ->] /sub_kermxP]. by rewrite -mulmxA Uphi. exists (kermx phi); last exact/mxdirect_addsP. apply/mxmoduleP=> x Gx; apply/sub_kermxP. by rewrite -mulmxA -phiG // mulmxA mulmx_ker mul0mx. apply/eqmxP; rewrite submx1 sub1mx. rewrite /row_full mxrank_disjoint_sum //= mxrank_ker. suffices ->: (U :=: phi)%MS by rewrite subnKC ?rank_leq_row. apply/eqmxP; rewrite -{1}Uphi submxMl scalemx_sub //. by rewrite summx_sub // => x Gx; rewrite -mulmxA mulmx_sub ?Umod. Qed. Lemma mxsemisimple_reducible V : mxsemisimple V -> mx_completely_reducible V. Proof. case=> [I W /= simW defV _] U modU sUV; rewrite -defV in sUV. have [J [defV' dxV]] := sum_mxsimple_direct_compl simW modU sUV. exists (\sum_(i in J) W i)%MS. - by apply: sumsmx_module => i _; case: (simW i). - exact: eqmx_trans defV' defV. by rewrite mxdirect_addsE (sameP eqP mxdirect_addsP) /= in dxV; case/and3P: dxV. Qed. Lemma mx_reducible_semisimple V : mxmodule V -> mx_completely_reducible V -> classically (mxsemisimple V). Proof. move=> modV redV [] // nssimV; have [r leVr] := ubnP (\rank V). elim: r => // r IHr in V leVr modV redV nssimV. have [V0 | nzV] := eqVneq V 0. by rewrite nssimV ?V0 //; apply: mxsemisimple0. apply: (mxsimple_exists modV nzV) => [[U simU sUV]]; have [modU nzU _] := simU. have [W modW defUW dxUW] := redV U modU sUV. have sWV: (W <= V)%MS by rewrite -defUW addsmxSr. apply: IHr (mx_reducibleS modW sWV redV) _ => // [|ssimW]. rewrite ltnS -defUW (mxdirectP dxUW) /= in leVr; apply: leq_trans leVr. by rewrite -add1n leq_add2r lt0n mxrank_eq0. apply: nssimV (eqmx_semisimple defUW (addsmx_semisimple _ ssimW)). exact: mxsimple_semisimple. Qed. Lemma mxsemisimpleS U V : mxmodule U -> (U <= V)%MS -> mxsemisimple V -> mxsemisimple U. Proof. move=> modU sUV ssimV. have [W modW defUW dxUW]:= mxsemisimple_reducible ssimV modU sUV. move/mxdirect_addsP: dxUW => dxUW. have defU : (V *m proj_mx U W :=: U)%MS. by apply/eqmxP; rewrite proj_mx_sub -{1}[U](proj_mx_id dxUW) ?submxMr. apply: eqmx_semisimple defU _; apply: hom_mxsemisimple ssimV _. by rewrite -defUW proj_mx_hom. Qed. Lemma hom_mxsemisimple_iso I P U W f : let V := (\sum_(i : I | P i) W i)%MS in mxsimple U -> (forall i, P i -> W i != 0 -> mxsimple (W i)) -> (V <= dom_hom_mx f)%MS -> (U <= V *m f)%MS -> {i | P i & mx_iso (W i) U}. Proof. move=> V simU simW homVf sUVf; have [modU nzU _] := simU. have ssimVf: mxsemisimple (V *m f). exact: hom_mxsemisimple (intro_mxsemisimple (eqmx_refl V) simW) homVf. have [U' modU' defVf] := mxsemisimple_reducible ssimVf modU sUVf. move/mxdirect_addsP=> dxUU'; pose p := f *m proj_mx U U'. case: (pickP (fun i => P i && (W i *m p != 0))) => [i /andP[Pi nzWip] | no_i]. have sWiV: (W i <= V)%MS by rewrite (sumsmx_sup i). have sWipU: (W i *m p <= U)%MS by rewrite mulmxA proj_mx_sub. exists i => //; apply: (mx_Schur_iso (simW i Pi _) simU _ sWipU nzWip). by apply: contraNneq nzWip => ->; rewrite mul0mx. apply: (submx_trans sWiV); apply/hom_mxP=> x Gx. by rewrite mulmxA [_ *m p]mulmxA 2?(hom_mxP _) -?defVf ?proj_mx_hom. case/negP: nzU; rewrite -submx0 -[U](proj_mx_id dxUU') //. rewrite (submx_trans (submxMr _ sUVf)) // -mulmxA -/p sumsmxMr. by apply/sumsmx_subP=> i Pi; move/negbT: (no_i i); rewrite Pi negbK submx0. Qed. (* The component associated to a given irreducible module. *) Section Components. Fact component_mx_key : unit. Proof. by []. Qed. Definition component_mx_expr (U : 'M[F]_n) := (\sum_i cyclic_mx (row i (row_hom_mx (nz_row U))))%MS. Definition component_mx := locked_with component_mx_key component_mx_expr. Canonical component_mx_unfoldable := [unlockable fun component_mx]. Variable U : 'M[F]_n. Hypothesis simU : mxsimple U. Let u := nz_row U. Let iso_u := row_hom_mx u. Let nz_u : u != 0 := nz_row_mxsimple simU. Let Uu : (u <= U)%MS := nz_row_sub U. Let defU : (U :=: cyclic_mx u)%MS := mxsimple_cyclic simU nz_u Uu. Local Notation compU := (component_mx U). Lemma component_mx_module : mxmodule compU. Proof. by rewrite unlock sumsmx_module // => i; rewrite cyclic_mx_module. Qed. Lemma genmx_component : <<compU>>%MS = compU. Proof. by rewrite [in compU]unlock genmx_sums; apply: eq_bigr => i; rewrite genmx_id. Qed. Lemma component_mx_def : {I : finType & {W : I -> 'M_n | forall i, mx_iso U (W i) & compU = \sum_i W i}}%MS. Proof. pose r i := row i iso_u; pose r_nz i := r i != 0; pose I := {i | r_nz i}. exists I; exists (fun i => cyclic_mx (r (sval i))) => [i|]. apply/mxsimple_isoP=> //; apply/and3P. split; first by rewrite cyclic_mx_module. apply/rowV0Pn; exists (r (sval i)); last exact: (svalP i). by rewrite sub_capmx cyclic_mx_id row_sub. have [f hom_u_f <-] := @row_hom_mxP u (r (sval i)) (row_sub _ _). by rewrite defU -hom_cyclic_mx ?mxrankM_maxl. rewrite -(eq_bigr _ (fun _ _ => genmx_id _)) -genmx_sums -genmx_component. rewrite [in compU]unlock; apply/genmxP/andP; split; last first. by apply/sumsmx_subP => i _; rewrite (sumsmx_sup (sval i)). apply/sumsmx_subP => i _. case i0: (r_nz i); first by rewrite (sumsmx_sup (Sub i i0)). by move/negbFE: i0; rewrite -cyclic_mx_eq0 => /eqP->; apply: sub0mx. Qed. Lemma component_mx_semisimple : mxsemisimple compU. Proof. have [I [W isoUW ->]] := component_mx_def. apply: intro_mxsemisimple (eqmx_refl _) _ => i _ _. exact: mx_iso_simple (isoUW i) simU. Qed. Lemma mx_iso_component V : mx_iso U V -> (V <= compU)%MS. Proof. move=> isoUV; have [f injf homUf defV] := isoUV. have simV := mx_iso_simple isoUV simU. have hom_u_f := submx_trans Uu homUf. have ->: (V :=: cyclic_mx (u *m f))%MS. apply: eqmx_trans (hom_cyclic_mx hom_u_f). exact: eqmx_trans (eqmx_sym defV) (eqmxMr _ defU). have iso_uf: (u *m f <= iso_u)%MS by apply/row_hom_mxP; exists f. rewrite genmxE; apply/row_subP=> j; rewrite row_mul mul_rV_lin1 /=. set a := vec_mx _; apply: submx_trans (submxMr _ iso_uf) _. apply/row_subP=> i; rewrite row_mul [in compU]unlock (sumsmx_sup i) //. by apply/cyclic_mxP; exists a; rewrite // vec_mxK row_sub. Qed. Lemma component_mx_id : (U <= compU)%MS. Proof. exact: mx_iso_component (mx_iso_refl U). Qed. Lemma hom_component_mx_iso f V : mxsimple V -> (compU <= dom_hom_mx f)%MS -> (V <= compU *m f)%MS -> mx_iso U V. Proof. have [I [W isoUW ->]] := component_mx_def => simV homWf sVWf. have [i _ _|i _ ] := hom_mxsemisimple_iso simV _ homWf sVWf. exact: mx_iso_simple (simU). exact: mx_iso_trans. Qed. Lemma component_mx_iso V : mxsimple V -> (V <= compU)%MS -> mx_iso U V. Proof. move=> simV; rewrite -[compU]mulmx1. exact: hom_component_mx_iso (scalar_mx_hom _ _). Qed. Lemma hom_component_mx f : (compU <= dom_hom_mx f)%MS -> (compU *m f <= compU)%MS. Proof. move=> hom_f. have [I W /= simW defW _] := hom_mxsemisimple component_mx_semisimple hom_f. rewrite -defW; apply/sumsmx_subP=> i _; apply: mx_iso_component. by apply: hom_component_mx_iso hom_f _ => //; rewrite -defW (sumsmx_sup i). Qed. End Components. Lemma component_mx_isoP U V : mxsimple U -> mxsimple V -> reflect (mx_iso U V) (component_mx U == component_mx V). Proof. move=> simU simV; apply: (iffP eqP) => isoUV. by apply: component_mx_iso; rewrite ?isoUV ?component_mx_id. rewrite -(genmx_component U) -(genmx_component V); apply/genmxP. wlog suffices: U V simU simV isoUV / (component_mx U <= component_mx V)%MS. by move=> IH; rewrite !IH //; apply: mx_iso_sym. have [I [W isoWU ->]] := component_mx_def simU. apply/sumsmx_subP => i _; apply: mx_iso_component => //. exact: mx_iso_trans (mx_iso_sym isoUV) (isoWU i). Qed. Lemma component_mx_disjoint U V : mxsimple U -> mxsimple V -> component_mx U != component_mx V -> (component_mx U :&: component_mx V = 0)%MS. Proof. move=> simU simV neUV; apply: contraNeq neUV => ntUV. apply: (mxsimple_exists _ ntUV) => [|[W simW]]. by rewrite capmx_module ?component_mx_module. rewrite sub_capmx => /andP[sWU sWV]; apply/component_mx_isoP=> //. by apply: mx_iso_trans (_ : mx_iso U W) (mx_iso_sym _); apply: component_mx_iso. Qed. Section Socle. Record socleType := EnumSocle { socle_base_enum : seq 'M[F]_n; _ : forall M, M \in socle_base_enum -> mxsimple M; _ : forall M, mxsimple M -> has (mxsimple_iso M) socle_base_enum }. Lemma socle_exists : classically socleType. Proof. pose V : 'M[F]_n := 0; have: mxsemisimple V by apply: mxsemisimple0. have: n - \rank V < n.+1 by rewrite mxrank0 subn0. elim: _.+1 V => // n' IHn' V; rewrite ltnS => le_nV_n' ssimV. case=> // maxV; apply: (maxV); have [I /= U simU defV _] := ssimV. exists (codom U) => [M | M simM]; first by case/mapP=> i _ ->. suffices sMV: (M <= V)%MS. rewrite -defV -(mulmx1 (\sum_i _)%MS) in sMV. have [//| i _] := hom_mxsemisimple_iso simM _ (scalar_mx_hom _ _) sMV. move/mx_iso_sym=> isoM; apply/hasP. by exists (U i); [apply: codom_f | apply/mxsimple_isoP]. have ssimMV := addsmx_semisimple (mxsimple_semisimple simM) ssimV. apply: contraLR isT => nsMV; apply: IHn' ssimMV _ maxV. apply: leq_trans le_nV_n'; rewrite ltn_sub2l //. rewrite ltn_neqAle rank_leq_row andbT -[_ == _]sub1mx. by apply: contra nsMV; apply: submx_trans; apply: submx1. rewrite (ltn_leqif (mxrank_leqif_sup _)) ?addsmxSr //. by rewrite addsmx_sub submx_refl andbT. Qed. Section SocleDef. Variable sG0 : socleType. Definition socle_enum := map component_mx (socle_base_enum sG0). Lemma component_socle M : mxsimple M -> component_mx M \in socle_enum. Proof. rewrite /socle_enum; case: sG0 => e0 /= sim_e mem_e simM. have /hasP[M' e0M' isoMM'] := mem_e M simM; apply/mapP; exists M' => //. by apply/eqP/component_mx_isoP; [|apply: sim_e | apply/mxsimple_isoP]. Qed. Inductive socle_sort : predArgType := PackSocle W of W \in socle_enum. Local Notation sG := socle_sort. Local Notation e0 := (socle_base_enum sG0). Definition socle_base W := let: PackSocle W _ := W in e0`_(index W socle_enum). Coercion socle_val W : 'M[F]_n := component_mx (socle_base W). Definition socle_mult (W : sG) := (\rank W %/ \rank (socle_base W))%N. Lemma socle_simple W : mxsimple (socle_base W). Proof. case: W => M /=; rewrite /= /socle_enum /=; case: sG0 => e sim_e _ /= e_M. by apply: sim_e; rewrite mem_nth // -(size_map component_mx) index_mem. Qed. Definition socle_module (W : sG) := mxsimple_module (socle_simple W). Definition socle_repr W := submod_repr (socle_module W). Lemma nz_socle (W : sG) : W != 0 :> 'M_n. Proof. have simW := socle_simple W; have [_ nzW _] := simW; apply: contra nzW. by rewrite -!submx0; apply: submx_trans (component_mx_id simW). Qed. Lemma socle_mem (W : sG) : (W : 'M_n) \in socle_enum. Proof. exact: component_socle (socle_simple _). Qed. Lemma PackSocleK W e0W : @PackSocle W e0W = W :> 'M_n. Proof. rewrite /socle_val /= in e0W *; rewrite -(nth_map _ 0) ?nth_index //. by rewrite -(size_map component_mx) index_mem. Qed. HB.instance Definition _ := isSub.Build _ _ sG socle_sort_rect PackSocleK. HB.instance Definition _ := [Choice of sG by <:]. Lemma socleP (W W' : sG) : reflect (W = W') (W == W')%MS. Proof. by rewrite (sameP genmxP eqP) !{1}genmx_component; apply: (W =P _). Qed. Fact socle_can_subproof : cancel (fun W => SeqSub (socle_mem W)) (fun s => PackSocle (valP s)). Proof. by move=> W /=; apply: val_inj; rewrite /= PackSocleK. Qed. HB.instance Definition _ := isCountable.Build sG (pcan_pickleK (can_pcan socle_can_subproof)). HB.instance Definition _ := isFinite.Build sG (pcan_enumP (can_pcan socle_can_subproof)). End SocleDef. Coercion socle_sort : socleType >-> predArgType. Variable sG : socleType. Section SubSocle. Variable P : pred sG. Notation S := (\sum_(W : sG | P W) socle_val W)%MS. Lemma subSocle_module : mxmodule S. Proof. by rewrite sumsmx_module // => W _; apply: component_mx_module. Qed. Lemma subSocle_semisimple : mxsemisimple S. Proof. apply: sumsmx_semisimple => W _; apply: component_mx_semisimple. exact: socle_simple. Qed. Local Notation ssimS := subSocle_semisimple. Lemma subSocle_iso M : mxsimple M -> (M <= S)%MS -> {W : sG | P W & mx_iso (socle_base W) M}. Proof. move=> simM sMS; have [modM nzM _] := simM. have [V /= modV defMV] := mxsemisimple_reducible ssimS modM sMS. move/mxdirect_addsP=> dxMV; pose p := proj_mx M V; pose Sp (W : sG) := W *m p. case: (pickP [pred i | P i & Sp i != 0]) => [/= W | Sp0]; last first. case/negP: nzM; rewrite -submx0 -[M](proj_mx_id dxMV) //. rewrite (submx_trans (submxMr _ sMS)) // sumsmxMr big1 // => W P_W. by apply/eqP; move/negbT: (Sp0 W); rewrite /= P_W negbK. rewrite {}/Sp /= => /andP[P_W nzSp]; exists W => //. have homWp: (W <= dom_hom_mx p)%MS. apply: submx_trans (proj_mx_hom dxMV modM modV). by rewrite defMV (sumsmx_sup W). have simWP := socle_simple W; apply: hom_component_mx_iso (homWp) _ => //. by rewrite (mx_Schur_onto _ simM) ?proj_mx_sub ?component_mx_module. Qed. Lemma capmx_subSocle m (M : 'M_(m, n)) : mxmodule M -> (M :&: S :=: \sum_(W : sG | P W) (M :&: W))%MS. Proof. move=> modM; apply/eqmxP/andP; split; last first. by apply/sumsmx_subP=> W P_W; rewrite capmxS // (sumsmx_sup W). have modMS: mxmodule (M :&: S)%MS by rewrite capmx_module ?subSocle_module. have [J /= U simU defMS _] := mxsemisimpleS modMS (capmxSr M S) ssimS. rewrite -defMS; apply/sumsmx_subP=> j _. have [sUjV sUjS]: (U j <= M /\ U j <= S)%MS. by apply/andP; rewrite -sub_capmx -defMS (sumsmx_sup j). have [W P_W isoWU] := subSocle_iso (simU j) sUjS. rewrite (sumsmx_sup W) // sub_capmx sUjV mx_iso_component //. exact: socle_simple. Qed. End SubSocle. Lemma subSocle_direct P : mxdirect (\sum_(W : sG | P W) W). Proof. apply/mxdirect_sumsP=> W _; apply/eqP. rewrite -submx0 capmx_subSocle ?component_mx_module //. apply/sumsmx_subP=> W' /andP[_ neWW']. by rewrite capmxC component_mx_disjoint //; apply: socle_simple. Qed. Definition Socle := (\sum_(W : sG) W)%MS. Lemma simple_Socle M : mxsimple M -> (M <= Socle)%MS. Proof. move=> simM; have socM := component_socle sG simM. by rewrite (sumsmx_sup (PackSocle socM)) // PackSocleK component_mx_id. Qed. Lemma semisimple_Socle U : mxsemisimple U -> (U <= Socle)%MS. Proof. by case=> I M /= simM <- _; apply/sumsmx_subP=> i _; apply: simple_Socle. Qed. Lemma reducible_Socle U : mxmodule U -> mx_completely_reducible U -> (U <= Socle)%MS. Proof. move=> modU redU; apply: (mx_reducible_semisimple modU redU). exact: semisimple_Socle. Qed. Lemma genmx_Socle : <<Socle>>%MS = Socle. Proof. by rewrite genmx_sums; apply: eq_bigr => W; rewrite genmx_component. Qed. Lemma reducible_Socle1 : mx_completely_reducible 1%:M -> Socle = 1%:M. Proof. move=> redG; rewrite -genmx1 -genmx_Socle; apply/genmxP. by rewrite submx1 reducible_Socle ?mxmodule1. Qed. Lemma Socle_module : mxmodule Socle. Proof. exact: subSocle_module. Qed. Lemma Socle_semisimple : mxsemisimple Socle. Proof. exact: subSocle_semisimple. Qed. Lemma Socle_direct : mxdirect Socle. Proof. exact: subSocle_direct. Qed. Lemma Socle_iso M : mxsimple M -> {W : sG | mx_iso (socle_base W) M}. Proof. by move=> simM; case/subSocle_iso: (simple_Socle simM) => // W _; exists W. Qed. End Socle. (* Centralizer subgroup and central homomorphisms. *) Section CentHom. Variable f : 'M[F]_n. Lemma row_full_dom_hom : row_full (dom_hom_mx f) = centgmx rG f. Proof. by rewrite -sub1mx; apply/hom_mxP/centgmxP=> cfG x /cfG; rewrite !mul1mx. Qed. Lemma memmx_cent_envelop : (f \in 'C(E_G))%MS = centgmx rG f. Proof. apply/cent_rowP/centgmxP=> [cfG x Gx | cfG i]. by have:= cfG (enum_rank_in Gx x); rewrite rowK mxvecK enum_rankK_in. by rewrite rowK mxvecK /= cfG ?enum_valP. Qed. Lemma kermx_centg_module : centgmx rG f -> mxmodule (kermx f). Proof. move/centgmxP=> cGf; apply/mxmoduleP=> x Gx; apply/sub_kermxP. by rewrite -mulmxA -cGf // mulmxA mulmx_ker mul0mx. Qed. Lemma centgmx_hom m (U : 'M_(m, n)) : centgmx rG f -> (U <= dom_hom_mx f)%MS. Proof. by rewrite -row_full_dom_hom -sub1mx; apply: submx_trans (submx1 _). Qed. End CentHom. (* (Globally) irreducible, and absolutely irreducible representations. Note *) (* that unlike "reducible", "absolutely irreducible" can easily be decided. *) Definition mx_irreducible := mxsimple 1%:M. Lemma mx_irrP : mx_irreducible <-> n > 0 /\ (forall U, @mxmodule n U -> U != 0 -> row_full U). Proof. rewrite /mx_irreducible /mxsimple mxmodule1 -mxrank_eq0 mxrank1 -lt0n. do [split=> [[_ -> irrG] | [-> irrG]]; split=> // U] => [modU | modU _] nzU. by rewrite -sub1mx (irrG U) ?submx1. by rewrite sub1mx irrG. Qed. (* Schur's lemma for endomorphisms. *) Lemma mx_Schur : mx_irreducible -> forall f, centgmx rG f -> f != 0 -> f \in unitmx. Proof. move/mx_Schur_onto=> irrG f. rewrite -row_full_dom_hom -!row_full_unit -!sub1mx => cGf nz. by rewrite -[f]mul1mx irrG ?submx1 ?mxmodule1 ?mul1mx. Qed. Definition mx_absolutely_irreducible := (n > 0) && row_full E_G. Lemma mx_abs_irrP : reflect (n > 0 /\ exists a_, forall A, A = \sum_(x in G) a_ x A *: rG x) mx_absolutely_irreducible. Proof. have G_1 := group1 G; have bijG := enum_val_bij_in G_1. set h := enum_val in bijG; have Gh : h _ \in G by apply: enum_valP. rewrite /mx_absolutely_irreducible; case: (n > 0); last by right; case. apply: (iffP row_fullP) => [[E' E'G] | [_ [a_ a_G]]]. split=> //; exists (fun x B => (mxvec B *m E') 0 (enum_rank_in G_1 x)) => B. apply: (can_inj mxvecK); rewrite -{1}[mxvec B]mulmx1 -{}E'G mulmxA. move: {B E'}(_ *m E') => u; apply/rowP=> j. rewrite linear_sum (reindex h) //= mxE summxE. by apply: eq_big => [k| k _]; rewrite ?Gh // enum_valK_in linearZ !mxE. exists (\matrix_(j, i) a_ (h i) (vec_mx (row j 1%:M))). apply/row_matrixP=> i; rewrite -[row i 1%:M]vec_mxK {}[vec_mx _]a_G. apply/rowP=> j; rewrite linear_sum (reindex h) //= 2!mxE summxE. by apply: eq_big => [k| k _]; [rewrite Gh | rewrite linearZ !mxE]. Qed. Lemma mx_abs_irr_cent_scalar : mx_absolutely_irreducible -> forall A, centgmx rG A -> is_scalar_mx A. Proof. case/mx_abs_irrP=> n_gt0 [a_ a_G] A /centgmxP cGA. have{cGA a_G} cMA B: A *m B = B *m A. rewrite {}[B]a_G mulmx_suml mulmx_sumr. by apply: eq_bigr => x Gx; rewrite -scalemxAl -scalemxAr cGA. pose i0 := Ordinal n_gt0; apply/is_scalar_mxP; exists (A i0 i0). apply/matrixP=> i j; move/matrixP/(_ i0 j): (esym (cMA (delta_mx i0 i))). rewrite -[A *m _]trmxK trmx_mul trmx_delta -!(@mul_delta_mx _ n 1 n 0) -!mulmxA. by rewrite -!rowE !mxE !big_ord1 !mxE !eqxx !mulr_natl /= andbT eq_sym. Qed. Lemma mx_abs_irrW : mx_absolutely_irreducible -> mx_irreducible. Proof. case/mx_abs_irrP=> n_gt0 [a_ a_G]; apply/mx_irrP; split=> // U Umod. case/rowV0Pn=> u Uu; rewrite -mxrank_eq0 -lt0n row_leq_rank -sub1mx. case/submxP: Uu => v ->{u} /row_freeP[u' vK]; apply/row_subP=> i. rewrite rowE scalar_mxC -{}vK -2![_ *m _]mulmxA; move: {u' i}(u' *m _) => A. rewrite mulmx_sub {v}// [A]a_G linear_sum summx_sub //= => x Gx. by rewrite -scalemxAr scalemx_sub // (mxmoduleP Umod). Qed. Lemma linear_mx_abs_irr : n = 1 -> mx_absolutely_irreducible. Proof. move=> n1; rewrite /mx_absolutely_irreducible /row_full eqn_leq rank_leq_col. rewrite {1 2 3}n1 /= lt0n mxrank_eq0; apply: contraTneq envelop_mx1 => ->. by rewrite eqmx0 submx0 mxvec_eq0 -mxrank_eq0 mxrank1 n1. Qed. Lemma abelian_abs_irr : abelian G -> mx_absolutely_irreducible = (n == 1). Proof. move=> cGG; apply/idP/eqP=> [absG|]; last exact: linear_mx_abs_irr. have [n_gt0 _] := andP absG. pose M := <<delta_mx 0 (Ordinal n_gt0) : 'rV[F]_n>>%MS. have rM: \rank M = 1 by rewrite genmxE mxrank_delta. suffices defM: (M == 1%:M)%MS by rewrite (eqmxP defM) mxrank1 in rM. case: (mx_abs_irrW absG) => _ _ ->; rewrite ?submx1 -?mxrank_eq0 ?rM //. apply/mxmoduleP=> x Gx; suffices: is_scalar_mx (rG x). by case/is_scalar_mxP=> a ->; rewrite mul_mx_scalar scalemx_sub. apply: (mx_abs_irr_cent_scalar absG). by apply/centgmxP=> y Gy; rewrite -!repr_mxM // (centsP cGG). Qed. End OneRepresentation. Arguments mxmoduleP {gT G n rG m U}. Arguments envelop_mxP {gT G n rG A}. Arguments hom_mxP {gT G n rG m f W}. Arguments rfix_mxP {gT G n rG m W}. Arguments cyclic_mxP {gT G n rG u v}. Arguments annihilator_mxP {gT G n rG u A}. Arguments row_hom_mxP {gT G n rG u v}. Arguments mxsimple_isoP {gT G n rG U V}. Arguments socleP {gT G n rG sG0 W W'}. Arguments mx_abs_irrP {gT G n rG}. Arguments val_submod {n U m} W. Arguments in_submod {n} U {m} W. Arguments val_submodK {n U m} W : rename. Arguments in_submodK {n U m} [W] sWU. Arguments val_submod_inj {n U m} [W1 W2] : rename. Arguments val_factmod {n U m} W. Arguments in_factmod {n} U {m} W. Arguments val_factmodK {n U m} W : rename. Arguments in_factmodK {n} U {m} [W] sWU. Arguments val_factmod_inj {n U m} [W1 W2] : rename. Section Proper. Variables (gT : finGroupType) (G : {group gT}) (n' : nat). Local Notation n := n'.+1. Variable rG : mx_representation F G n. Lemma envelop_mx_ring : mxring (enveloping_algebra_mx rG). Proof. apply/andP; split; first by apply/mulsmx_subP; apply: envelop_mxM. apply/mxring_idP; exists 1%:M; split=> *; rewrite ?mulmx1 ?mul1mx //. by rewrite -mxrank_eq0 mxrank1. exact: envelop_mx1. Qed. End Proper. Section JacobsonDensity. Variables (gT : finGroupType) (G : {group gT}) (n : nat). Variable rG : mx_representation F G n. Hypothesis irrG : mx_irreducible rG. Local Notation E_G := (enveloping_algebra_mx rG). Local Notation Hom_G := 'C(E_G)%MS. Lemma mx_Jacobson_density : ('C(Hom_G) <= E_G)%MS. Proof. apply/row_subP=> iB; rewrite -[row iB _]vec_mxK; move defB: (vec_mx _) => B. have{defB} cBcE: (B \in 'C(Hom_G))%MS by rewrite -defB vec_mxK row_sub. have rGnP: mx_repr G (fun x => lin_mx (mulmxr (rG x)) : 'A_n). split=> [|x y Gx Gy]; apply/row_matrixP=> i. by rewrite !rowE mul_rV_lin repr_mx1 /= !mulmx1 vec_mxK. by rewrite !rowE mulmxA !mul_rV_lin repr_mxM //= mxvecK mulmxA. move def_rGn: (MxRepresentation rGnP) => rGn. pose E_Gn := enveloping_algebra_mx rGn. pose e1 : 'rV[F]_(n ^ 2) := mxvec 1%:M; pose U := cyclic_mx rGn e1. have U_e1: (e1 <= U)%MS by rewrite cyclic_mx_id. have modU: mxmodule rGn U by rewrite cyclic_mx_module. pose Bn : 'M_(n ^ 2) := lin_mx (mulmxr B). suffices U_e1Bn: (e1 *m Bn <= U)%MS. rewrite mul_vec_lin /= mul1mx in U_e1Bn; apply: submx_trans U_e1Bn _. rewrite genmxE; apply/row_subP=> i; rewrite row_mul rowK mul_vec_lin_row. by rewrite -def_rGn mul_vec_lin /= mul1mx (eq_row_sub i) ?rowK. have{cBcE} cBncEn A: centgmx rGn A -> A *m Bn = Bn *m A. rewrite -def_rGn => cAG; apply/row_matrixP; case/mxvec_indexP=> j k /=. rewrite !rowE !mulmxA -mxvec_delta -(mul_delta_mx (0 : 'I_1)). rewrite mul_rV_lin mul_vec_lin /= -mulmxA; apply: (canLR vec_mxK). apply/row_matrixP=> i; set dj0 := delta_mx j 0. have /= defAij := mul_rV_lin1 (row i \o vec_mx \o mulmxr A \o mxvec \o mulmx dj0). rewrite -defAij row_mul -defAij -!mulmxA (cent_mxP cBcE) {k}//. rewrite memmx_cent_envelop; apply/centgmxP=> x Gx; apply/row_matrixP=> k. rewrite !row_mul !rowE !{}defAij /= -row_mul mulmxA mul_delta_mx. congr (row i _); rewrite -(mul_vec_lin (mulmxr (rG x))) -mulmxA. by rewrite -(centgmxP cAG) // mulmxA mx_rV_lin. suffices redGn: mx_completely_reducible rGn 1%:M. have [V modV defUV] := redGn _ modU (submx1 _); move/mxdirect_addsP=> dxUV. rewrite -(proj_mx_id dxUV U_e1) -mulmxA {}cBncEn 1?mulmxA ?proj_mx_sub //. by rewrite -row_full_dom_hom -sub1mx -defUV proj_mx_hom. pose W i : 'M[F]_(n ^ 2) := <<lin1_mx (mxvec \o mulmx (delta_mx i 0))>>%MS. have defW: (\sum_i W i :=: 1%:M)%MS. apply/eqmxP; rewrite submx1; apply/row_subP; case/mxvec_indexP=> i j. rewrite row1 -mxvec_delta (sumsmx_sup i) // genmxE; apply/submxP. by exists (delta_mx 0 j); rewrite mul_rV_lin1 /= mul_delta_mx. apply: mxsemisimple_reducible; apply: (intro_mxsemisimple defW) => i _ nzWi. split=> // [|Vi modVi sViWi nzVi]. apply/mxmoduleP=> x Gx; rewrite genmxE (eqmxMr _ (genmxE _)) -def_rGn. apply/row_subP=> j; rewrite rowE mulmxA !mul_rV_lin1 /= mxvecK -mulmxA. by apply/submxP; move: (_ *m rG x) => v; exists v; rewrite mul_rV_lin1. do [rewrite !genmxE; set f := lin1_mx _] in sViWi *. have f_free: row_free f. apply/row_freeP; exists (lin1_mx (row i \o vec_mx)); apply/row_matrixP=> j. by rewrite row1 rowE mulmxA !mul_rV_lin1 /= mxvecK rowE !mul_delta_mx. pose V := <<Vi *m pinvmx f>>%MS; have Vidf := mulmxKpV sViWi. suffices: (1%:M <= V)%MS by rewrite genmxE -(submxMfree _ _ f_free) mul1mx Vidf. case: irrG => _ _ ->; rewrite ?submx1 //; last first. by rewrite -mxrank_eq0 genmxE -(mxrankMfree _ f_free) Vidf mxrank_eq0. apply/mxmoduleP=> x Gx; rewrite genmxE (eqmxMr _ (genmxE _)). rewrite -(submxMfree _ _ f_free) Vidf. apply: submx_trans (mxmoduleP modVi x Gx); rewrite -{2}Vidf. apply/row_subP=> j; apply: (eq_row_sub j); rewrite row_mul -def_rGn. by rewrite !(row_mul _ _ f) !mul_rV_lin1 /= mxvecK !row_mul !mulmxA. Qed. Lemma cent_mx_scalar_abs_irr : \rank Hom_G <= 1 -> mx_absolutely_irreducible rG. Proof. rewrite leqNgt => /(has_non_scalar_mxP (scalar_mx_cent _ _)) scal_cE. apply/andP; split; first by case/mx_irrP: irrG. rewrite -sub1mx; apply: submx_trans mx_Jacobson_density. apply/memmx_subP=> B _; apply/cent_mxP=> A cGA. case scalA: (is_scalar_mx A); last by case: scal_cE; exists A; rewrite ?scalA. by case/is_scalar_mxP: scalA => a ->; rewrite scalar_mxC. Qed. End JacobsonDensity. Section ChangeGroup. Variables (gT : finGroupType) (G H : {group gT}) (n : nat). Variables (rG : mx_representation F G n). Section SubGroup. Hypothesis sHG : H \subset G. Local Notation rH := (subg_repr rG sHG). Lemma rfix_subg : rfix_mx rH = rfix_mx rG. Proof. by []. Qed. Section Stabilisers. Variables (m : nat) (U : 'M[F]_(m, n)). Lemma rstabs_subg : rstabs rH U = H :&: rstabs rG U. Proof. by apply/setP=> x; rewrite !inE andbA -in_setI (setIidPl sHG). Qed. Lemma mxmodule_subg : mxmodule rG U -> mxmodule rH U. Proof. by rewrite /mxmodule rstabs_subg subsetI subxx; apply: subset_trans. Qed. End Stabilisers. Lemma mxsimple_subg M : mxmodule rG M -> mxsimple rH M -> mxsimple rG M. Proof. by move=> modM [_ nzM minM]; split=> // U /mxmodule_subg; apply: minM. Qed. Lemma subg_mx_irr : mx_irreducible rH -> mx_irreducible rG. Proof. by apply: mxsimple_subg; apply: mxmodule1. Qed. Lemma subg_mx_abs_irr : mx_absolutely_irreducible rH -> mx_absolutely_irreducible rG. Proof. rewrite /mx_absolutely_irreducible -!sub1mx => /andP[-> /submx_trans-> //]. apply/row_subP=> i; rewrite rowK /= envelop_mx_id //. by rewrite (subsetP sHG) ?enum_valP. Qed. End SubGroup. Section SameGroup. Hypothesis eqGH : G :==: H. Local Notation rH := (eqg_repr rG eqGH). Lemma rfix_eqg : rfix_mx rH = rfix_mx rG. Proof. by []. Qed. Section Stabilisers. Variables (m : nat) (U : 'M[F]_(m, n)). Lemma rstabs_eqg : rstabs rH U = rstabs rG U. Proof. by rewrite rstabs_subg -(eqP eqGH) (setIidPr _) ?rstabs_sub. Qed. Lemma mxmodule_eqg : mxmodule rH U = mxmodule rG U. Proof. by rewrite /mxmodule rstabs_eqg -(eqP eqGH). Qed. End Stabilisers. Lemma mxsimple_eqg M : mxsimple rH M <-> mxsimple rG M. Proof. rewrite /mxsimple mxmodule_eqg. split=> [] [-> -> minM]; split=> // U modU; by apply: minM; rewrite mxmodule_eqg in modU *. Qed. Lemma eqg_mx_irr : mx_irreducible rH <-> mx_irreducible rG. Proof. exact: mxsimple_eqg. Qed. Lemma eqg_mx_abs_irr : mx_absolutely_irreducible rH = mx_absolutely_irreducible rG. Proof. by congr (_ && (_ == _)); rewrite /enveloping_algebra_mx /= -(eqP eqGH). Qed. End SameGroup. End ChangeGroup. Section Morphpre. Variables (aT rT : finGroupType) (D : {group aT}) (f : {morphism D >-> rT}). Variables (G : {group rT}) (n : nat) (rG : mx_representation F G n). Local Notation rGf := (morphpre_repr f rG). Section Stabilisers. Variables (m : nat) (U : 'M[F]_(m, n)). Lemma rstabs_morphpre : rstabs rGf U = f @*^-1 (rstabs rG U). Proof. by apply/setP=> x; rewrite !inE andbA. Qed. Lemma mxmodule_morphpre : G \subset f @* D -> mxmodule rGf U = mxmodule rG U. Proof. by move=> sGf; rewrite /mxmodule rstabs_morphpre morphpreSK. Qed. End Stabilisers. Lemma rfix_morphpre (H : {set aT}) : H \subset D -> (rfix_mx rGf H :=: rfix_mx rG (f @* H))%MS. Proof. move=> sHD; apply/eqmxP/andP; split. by apply/rfix_mxP=> _ /morphimP[x _ Hx ->]; rewrite rfix_mx_id. by apply/rfix_mxP=> x Hx; rewrite rfix_mx_id ?mem_morphim ?(subsetP sHD). Qed. Lemma morphpre_mx_irr : G \subset f @* D -> (mx_irreducible rGf <-> mx_irreducible rG). Proof. move/mxmodule_morphpre=> modG; split=> /mx_irrP[n_gt0 irrG]; by apply/mx_irrP; split=> // U modU; apply: irrG; rewrite modG in modU *. Qed. Lemma morphpre_mx_abs_irr : G \subset f @* D -> mx_absolutely_irreducible rGf = mx_absolutely_irreducible rG. Proof. move=> sGfD; congr (_ && (_ == _)); apply/eqP; rewrite mxrank_leqif_sup //. apply/row_subP=> i; rewrite rowK. case/morphimP: (subsetP sGfD _ (enum_valP i)) => x Dx _ def_i. by rewrite def_i (envelop_mx_id rGf) // !inE Dx -def_i enum_valP. apply/row_subP=> i; rewrite rowK (envelop_mx_id rG) //. by case/morphpreP: (enum_valP i). Qed. End Morphpre. Section Morphim. Variables (aT rT : finGroupType) (G D : {group aT}) (f : {morphism D >-> rT}). Variables (n : nat) (rGf : mx_representation F (f @* G) n). Hypothesis sGD : G \subset D. Let sG_f'fG : G \subset f @*^-1 (f @* G). Proof. by rewrite -sub_morphim_pre. Qed. Local Notation rG := (morphim_repr rGf sGD). Section Stabilisers. Variables (m : nat) (U : 'M[F]_(m, n)). Lemma rstabs_morphim : rstabs rG U = G :&: f @*^-1 rstabs rGf U. Proof. by rewrite -rstabs_morphpre -(rstabs_subg _ sG_f'fG). Qed. Lemma mxmodule_morphim : mxmodule rG U = mxmodule rGf U. Proof. by rewrite /mxmodule rstabs_morphim subsetI subxx -sub_morphim_pre. Qed. End Stabilisers. Lemma rfix_morphim (H : {set aT}) : H \subset D -> (rfix_mx rG H :=: rfix_mx rGf (f @* H))%MS. Proof. exact: rfix_morphpre. Qed. Lemma mxsimple_morphim M : mxsimple rG M <-> mxsimple rGf M. Proof. rewrite /mxsimple mxmodule_morphim. split=> [] [-> -> minM]; split=> // U modU; by apply: minM; rewrite mxmodule_morphim in modU *. Qed. Lemma morphim_mx_irr : (mx_irreducible rG <-> mx_irreducible rGf). Proof. exact: mxsimple_morphim. Qed. Lemma morphim_mx_abs_irr : mx_absolutely_irreducible rG = mx_absolutely_irreducible rGf. Proof. have fG_onto: f @* G \subset restrm sGD f @* G. by rewrite (morphim_restrm sGD) setIid. rewrite -(morphpre_mx_abs_irr _ fG_onto); congr (_ && (_ == _)). by rewrite /enveloping_algebra_mx /= morphpre_restrm (setIidPl _). Qed. End Morphim. Section Submodule. Variables (gT : finGroupType) (G : {group gT}) (n : nat). Variables (rG : mx_representation F G n) (U : 'M[F]_n) (Umod : mxmodule rG U). Local Notation rU := (submod_repr Umod). Local Notation rU' := (factmod_repr Umod). Lemma rfix_submod (H : {set gT}) : H \subset G -> (rfix_mx rU H :=: in_submod U (U :&: rfix_mx rG H))%MS. Proof. move=> sHG; apply/eqmxP/andP; split; last first. apply/rfix_mxP=> x Hx; rewrite -in_submodJ ?capmxSl //. by rewrite (rfix_mxP H _) ?capmxSr. rewrite -val_submodS in_submodK ?capmxSl // sub_capmx val_submodP //=. apply/rfix_mxP=> x Hx. by rewrite -(val_submodJ Umod) ?(subsetP sHG) ?rfix_mx_id. Qed. Lemma rfix_factmod (H : {set gT}) : H \subset G -> (in_factmod U (rfix_mx rG H) <= rfix_mx rU' H)%MS. Proof. move=> sHG; apply/rfix_mxP=> x Hx. by rewrite -(in_factmodJ Umod) ?(subsetP sHG) ?rfix_mx_id. Qed. Lemma rstab_submod m (W : 'M_(m, \rank U)) : rstab rU W = rstab rG (val_submod W). Proof. apply/setP=> x /[!inE]; apply: andb_id2l => Gx. by rewrite -(inj_eq val_submod_inj) val_submodJ. Qed. Lemma rstabs_submod m (W : 'M_(m, \rank U)) : rstabs rU W = rstabs rG (val_submod W). Proof. apply/setP=> x /[!inE]; apply: andb_id2l => Gx. by rewrite -val_submodS val_submodJ. Qed. Lemma val_submod_module m (W : 'M_(m, \rank U)) : mxmodule rG (val_submod W) = mxmodule rU W. Proof. by rewrite /mxmodule rstabs_submod. Qed. Lemma in_submod_module m (V : 'M_(m, n)) : (V <= U)%MS -> mxmodule rU (in_submod U V) = mxmodule rG V. Proof. by move=> sVU; rewrite -val_submod_module in_submodK. Qed. Lemma rstab_factmod m (W : 'M_(m, n)) : rstab rG W \subset rstab rU' (in_factmod U W). Proof. by apply/subsetP=> x /setIdP[Gx /eqP cUW]; rewrite inE Gx -in_factmodJ //= cUW. Qed. Lemma rstabs_factmod m (W : 'M_(m, \rank (cokermx U))) : rstabs rU' W = rstabs rG (U + val_factmod W)%MS. Proof. apply/setP=> x /[!inE]; apply: andb_id2l => Gx. rewrite addsmxMr addsmx_sub (submx_trans (mxmoduleP Umod x Gx)) ?addsmxSl //. rewrite -val_factmodS val_factmodJ //= val_factmodS; apply/idP/idP=> nWx. rewrite (submx_trans (addsmxSr U _)) // -(in_factmodsK (addsmxSl U _)) //. by rewrite addsmxS // val_factmodS in_factmod_addsK. rewrite in_factmodE (submx_trans (submxMr _ nWx)) // -in_factmodE. by rewrite in_factmod_addsK val_factmodK. Qed. Lemma val_factmod_module m (W : 'M_(m, \rank (cokermx U))) : mxmodule rG (U + val_factmod W)%MS = mxmodule rU' W. Proof. by rewrite /mxmodule rstabs_factmod. Qed. Lemma in_factmod_module m (V : 'M_(m, n)) : mxmodule rU' (in_factmod U V) = mxmodule rG (U + V)%MS. Proof. rewrite -(eqmx_module _ (in_factmodsK (addsmxSl U V))). by rewrite val_factmod_module (eqmx_module _ (in_factmod_addsK _ _)). Qed. Lemma rker_submod : rker rU = rstab rG U. Proof. by rewrite /rker rstab_submod; apply: eqmx_rstab (val_submod1 U). Qed. Lemma rstab_norm : G \subset 'N(rstab rG U). Proof. by rewrite -rker_submod rker_norm. Qed. Lemma rstab_normal : rstab rG U <| G. Proof. by rewrite -rker_submod rker_normal. Qed. Lemma submod_mx_faithful : mx_faithful rU -> mx_faithful rG. Proof. by apply: subset_trans; rewrite rker_submod rstabS ?submx1. Qed. Lemma rker_factmod : rker rG \subset rker rU'. Proof. apply/subsetP=> x /rkerP[Gx cVx]. by rewrite inE Gx /= /factmod_mx cVx mul1mx mulmx1 val_factmodK. Qed. Lemma factmod_mx_faithful : mx_faithful rU' -> mx_faithful rG. Proof. exact: subset_trans rker_factmod. Qed. Lemma submod_mx_irr : mx_irreducible rU <-> mxsimple rG U. Proof. split=> [] [_ nzU simU]. rewrite -mxrank_eq0 mxrank1 mxrank_eq0 in nzU; split=> // V modV sVU nzV. rewrite -(in_submodK sVU) -val_submod1 val_submodS. rewrite -(genmxE (in_submod U V)) simU ?genmxE ?submx1 //=. by rewrite (eqmx_module _ (genmxE _)) in_submod_module. by rewrite -submx0 genmxE -val_submodS in_submodK // linear0 eqmx0 submx0. apply/mx_irrP; rewrite lt0n mxrank_eq0; split=> // V modV. rewrite -(inj_eq val_submod_inj) linear0 -(eqmx_eq0 (genmxE _)) => nzV. rewrite -sub1mx -val_submodS val_submod1 -(genmxE (val_submod V)). rewrite simU ?genmxE ?val_submodP //=. by rewrite (eqmx_module _ (genmxE _)) val_submod_module. Qed. End Submodule. Section Conjugate. Variables (gT : finGroupType) (G : {group gT}) (n : nat). Variables (rG : mx_representation F G n) (B : 'M[F]_n). Hypothesis uB : B \in unitmx. Local Notation rGB := (rconj_repr rG uB). Lemma rfix_conj (H : {set gT}) : (rfix_mx rGB H :=: B *m rfix_mx rG H *m invmx B)%MS. Proof. apply/eqmxP/andP; split. rewrite -mulmxA (eqmxMfull (_ *m _)) ?row_full_unit //. rewrite -[rfix_mx rGB H](mulmxK uB) submxMr //; apply/rfix_mxP=> x Hx. apply: (canRL (mulmxKV uB)); rewrite -(rconj_mxJ _ uB) mulmxK //. by rewrite rfix_mx_id. apply/rfix_mxP=> x Gx; rewrite -3!mulmxA; congr (_ *m _). by rewrite !mulmxA mulmxKV // rfix_mx_id. Qed. Lemma rstabs_conj m (U : 'M_(m, n)) : rstabs rGB U = rstabs rG (U *m B). Proof. apply/setP=> x; rewrite !inE rconj_mxE !mulmxA. by rewrite -{2}[U](mulmxK uB) submxMfree // row_free_unit unitmx_inv. Qed. Lemma mxmodule_conj m (U : 'M_(m, n)) : mxmodule rGB U = mxmodule rG (U *m B). Proof. by rewrite /mxmodule rstabs_conj. Qed. Lemma conj_mx_irr : mx_irreducible rGB <-> mx_irreducible rG. Proof. have Bfree: row_free B by rewrite row_free_unit. split => /mx_irrP[n_gt0 irrG]; apply/mx_irrP; split=> // U. rewrite -[U](mulmxKV uB) -mxmodule_conj -mxrank_eq0 /row_full mxrankMfree //. by rewrite mxrank_eq0; apply: irrG. rewrite -mxrank_eq0 /row_full -(mxrankMfree _ Bfree) mxmodule_conj mxrank_eq0. exact: irrG. Qed. End Conjugate. Section Quotient. Variables (gT : finGroupType) (G : {group gT}) (n : nat). Variables (rG : mx_representation F G n) (H : {group gT}). Hypotheses (krH : H \subset rker rG) (nHG : G \subset 'N(H)). Let nHGs := subsetP nHG. Local Notation rGH := (quo_repr krH nHG). Local Notation E_ r := (enveloping_algebra_mx r). Lemma quo_mx_quotient : (E_ rGH :=: E_ rG)%MS. Proof. apply/eqmxP/andP; split; apply/row_subP=> i. rewrite rowK; case/morphimP: (enum_valP i) => x _ Gx ->{i}. rewrite quo_repr_coset // (eq_row_sub (enum_rank_in Gx x)) // rowK. by rewrite enum_rankK_in. rewrite rowK -(quo_mx_coset krH nHG) ?enum_valP //; set Hx := coset H _. have GHx: Hx \in (G / H)%g by rewrite mem_quotient ?enum_valP. by rewrite (eq_row_sub (enum_rank_in GHx Hx)) // rowK enum_rankK_in. Qed. Lemma rfix_quo (K : {group gT}) : K \subset G -> (rfix_mx rGH (K / H)%g :=: rfix_mx rG K)%MS. Proof. move=> sKG; apply/eqmxP/andP; (split; apply/rfix_mxP) => [x Kx | Hx]. have Gx := subsetP sKG x Kx; rewrite -(quo_mx_coset krH nHG) // rfix_mx_id //. by rewrite mem_morphim ?(subsetP nHG). case/morphimP=> x _ Kx ->; have Gx := subsetP sKG x Kx. by rewrite quo_repr_coset ?rfix_mx_id. Qed. Lemma rstabs_quo m (U : 'M_(m, n)) : rstabs rGH U = (rstabs rG U / H)%g. Proof. apply/setP=> Hx /[!inE]; apply/andP/idP=> [[]|] /morphimP[x Nx Gx ->{Hx}]. by rewrite quo_repr_coset // => nUx; rewrite mem_morphim // inE Gx. by case/setIdP: Gx => Gx nUx; rewrite quo_repr_coset ?mem_morphim. Qed. Lemma mxmodule_quo m (U : 'M_(m, n)) : mxmodule rGH U = mxmodule rG U. Proof. rewrite /mxmodule rstabs_quo quotientSGK // ?(subset_trans krH) //. by apply/subsetP=> x /[!inE]/andP[-> /[1!mul1mx]/eqP->/=]; rewrite mulmx1. Qed. Lemma quo_mx_irr : mx_irreducible rGH <-> mx_irreducible rG. Proof. split; case/mx_irrP=> n_gt0 irrG; apply/mx_irrP; split=> // U modU; by apply: irrG; rewrite mxmodule_quo in modU *. Qed. End Quotient. Section SplittingField. Implicit Type gT : finGroupType. Definition group_splitting_field gT (G : {group gT}) := forall n (rG : mx_representation F G n), mx_irreducible rG -> mx_absolutely_irreducible rG. Definition group_closure_field gT := forall G : {group gT}, group_splitting_field G. Lemma quotient_splitting_field gT (G : {group gT}) (H : {set gT}) : G \subset 'N(H) -> group_splitting_field G -> group_splitting_field (G / H). Proof. move=> nHG splitG n rGH irrGH. by rewrite -(morphim_mx_abs_irr _ nHG) splitG //; apply/morphim_mx_irr. Qed. Lemma coset_splitting_field gT (H : {set gT}) : group_closure_field gT -> group_closure_field (coset_of H). Proof. move=> split_gT Gbar; have ->: Gbar = (coset H @*^-1 Gbar / H)%G. by apply: val_inj; rewrite /= /quotient morphpreK ?sub_im_coset. by apply: quotient_splitting_field; [apply: subsetIl | apply: split_gT]. Qed. End SplittingField. Section Abelian. Variables (gT : finGroupType) (G : {group gT}). Lemma mx_faithful_irr_center_cyclic n (rG : mx_representation F G n) : mx_faithful rG -> mx_irreducible rG -> cyclic 'Z(G). Proof. case: n rG => [|n] rG injG irrG; first by case/mx_irrP: irrG. move/trivgP: injG => KrG1; pose rZ := subg_repr rG (center_sub _). apply: (div_ring_mul_group_cyclic (repr_mx1 rZ)) (repr_mxM rZ) _ _; last first. exact: center_abelian. move=> x; rewrite -[[set _]]KrG1 !inE mul1mx -subr_eq0 andbC; set U := _ - _. do 2![case/andP]=> Gx cGx; rewrite Gx /=; apply: (mx_Schur irrG). apply/centgmxP=> y Gy; rewrite mulmxBl mulmxBr mulmx1 mul1mx. by rewrite -!repr_mxM // (centP cGx). Qed. Lemma mx_faithful_irr_abelian_cyclic n (rG : mx_representation F G n) : mx_faithful rG -> mx_irreducible rG -> abelian G -> cyclic G. Proof. move=> injG irrG cGG; rewrite -(setIidPl cGG). exact: mx_faithful_irr_center_cyclic injG irrG. Qed. Hypothesis splitG : group_splitting_field G. Lemma mx_irr_abelian_linear n (rG : mx_representation F G n) : mx_irreducible rG -> abelian G -> n = 1. Proof. by move=> irrG cGG; apply/eqP; rewrite -(abelian_abs_irr rG) ?splitG. Qed. Lemma mxsimple_abelian_linear n (rG : mx_representation F G n) M : abelian G -> mxsimple rG M -> \rank M = 1. Proof. move=> cGG simM; have [modM _ _] := simM. by move/(submod_mx_irr modM)/mx_irr_abelian_linear: simM => ->. Qed. Lemma linear_mxsimple n (rG : mx_representation F G n) (M : 'M_n) : mxmodule rG M -> \rank M = 1 -> mxsimple rG M. Proof. move=> modM rM1; apply/(submod_mx_irr modM). by apply: mx_abs_irrW; rewrite linear_mx_abs_irr. Qed. End Abelian. Section AbelianQuotient. Variables (gT : finGroupType) (G : {group gT}). Variables (n : nat) (rG : mx_representation F G n). Lemma center_kquo_cyclic : mx_irreducible rG -> cyclic 'Z(G / rker rG)%g. Proof. move=> irrG; apply: mx_faithful_irr_center_cyclic (kquo_mx_faithful rG) _. exact/quo_mx_irr. Qed. Lemma der1_sub_rker : group_splitting_field G -> mx_irreducible rG -> (G^`(1) \subset rker rG)%g = (n == 1)%N. Proof. move=> splitG irrG; apply/idP/idP; last by move/eqP; apply: rker_linear. move/sub_der1_abelian; move/(abelian_abs_irr (kquo_repr rG))=> <-. by apply: (quotient_splitting_field (rker_norm _) splitG); apply/quo_mx_irr. Qed. End AbelianQuotient. Section Similarity. Variables (gT : finGroupType) (G : {group gT}). Local Notation reprG := (mx_representation F G). Variant mx_rsim n1 (rG1 : reprG n1) n2 (rG2 : reprG n2) : Prop := MxReprSim B of n1 = n2 & row_free B & forall x, x \in G -> rG1 x *m B = B *m rG2 x. Lemma mxrank_rsim n1 n2 (rG1 : reprG n1) (rG2 : reprG n2) : mx_rsim rG1 rG2 -> n1 = n2. Proof. by case. Qed. Lemma mx_rsim_refl n (rG : reprG n) : mx_rsim rG rG. Proof. exists 1%:M => // [|x _]; first by rewrite row_free_unit unitmx1. by rewrite mulmx1 mul1mx. Qed. Lemma mx_rsim_sym n1 n2 (rG1 : reprG n1) (rG2 : reprG n2) : mx_rsim rG1 rG2 -> mx_rsim rG2 rG1. Proof. case=> B def_n1; rewrite def_n1 in rG1 B *. rewrite row_free_unit => injB homB; exists (invmx B) => // [|x Gx]. by rewrite row_free_unit unitmx_inv. by apply: canRL (mulKmx injB) _; rewrite mulmxA -homB ?mulmxK. Qed. Lemma mx_rsim_trans n1 n2 n3 (rG1 : reprG n1) (rG2 : reprG n2) (rG3 : reprG n3) : mx_rsim rG1 rG2 -> mx_rsim rG2 rG3 -> mx_rsim rG1 rG3. Proof. case=> [B1 defn1 freeB1 homB1] [B2 defn2 freeB2 homB2]. exists (B1 *m B2); rewrite /row_free ?mxrankMfree 1?defn1 // => x Gx. by rewrite mulmxA homB1 // -!mulmxA homB2. Qed. Lemma mx_rsim_def n1 n2 (rG1 : reprG n1) (rG2 : reprG n2) : mx_rsim rG1 rG2 -> exists B, exists2 B', B' *m B = 1%:M & forall x, x \in G -> rG1 x = B *m rG2 x *m B'. Proof. case=> B def_n1; rewrite def_n1 in rG1 B *; rewrite row_free_unit => injB homB. by exists B, (invmx B) => [|x Gx]; rewrite ?mulVmx // -homB // mulmxK. Qed. Lemma mx_rsim_iso n (rG : reprG n) (U V : 'M_n) (modU : mxmodule rG U) (modV : mxmodule rG V) : mx_rsim (submod_repr modU) (submod_repr modV) <-> mx_iso rG U V. Proof. split=> [[B eqrUV injB homB] | [f injf homf defV]]. have: \rank (U *m val_submod (in_submod U 1%:M *m B)) = \rank U. do 2!rewrite mulmxA mxrankMfree ?row_base_free //. by rewrite -(eqmxMr _ (val_submod1 U)) -in_submodE val_submodK mxrank1. case/complete_unitmx => f injf defUf; exists f => //. apply/hom_mxP=> x Gx; rewrite -defUf -2!mulmxA -(val_submodJ modV) //. rewrite -(mulmxA _ B) -homB // val_submodE 3!(mulmxA U) (mulmxA _ _ B). rewrite -in_submodE -in_submodJ //. have [u ->] := submxP (mxmoduleP modU x Gx). by rewrite in_submodE -mulmxA -defUf !mulmxA !mulmx1. apply/eqmxP; rewrite -mxrank_leqif_eq. by rewrite mxrankMfree ?eqrUV ?row_free_unit. by rewrite -defUf mulmxA val_submodP. have eqrUV: \rank U = \rank V by rewrite -defV mxrankMfree ?row_free_unit. exists (in_submod V (val_submod 1%:M *m f)) => // [|x Gx]. rewrite /row_free {6}eqrUV -[_ == _]sub1mx -val_submodS. rewrite in_submodK; last by rewrite -defV submxMr ?val_submodP. by rewrite val_submod1 -defV submxMr ?val_submod1. rewrite -in_submodJ; last by rewrite -defV submxMr ?val_submodP. rewrite -(hom_mxP (submx_trans (val_submodP _) homf)) // -(val_submodJ modU) //. by rewrite mul1mx 2!(mulmxA ((submod_repr _) x)) -val_submodE. Qed. Lemma mx_rsim_irr n1 n2 (rG1 : reprG n1) (rG2 : reprG n2) : mx_rsim rG1 rG2 -> mx_irreducible rG1 -> mx_irreducible rG2. Proof. case/mx_rsim_sym=> f def_n2; rewrite {n2}def_n2 in f rG2 * => injf homf. case/mx_irrP=> n1_gt0 minG; apply/mx_irrP; split=> // U modU nzU. rewrite /row_full -(mxrankMfree _ injf) -genmxE. apply: minG; last by rewrite -mxrank_eq0 genmxE mxrankMfree // mxrank_eq0. rewrite (eqmx_module _ (genmxE _)); apply/mxmoduleP=> x Gx. by rewrite -mulmxA -homf // mulmxA submxMr // (mxmoduleP modU). Qed. Lemma mx_rsim_abs_irr n1 n2 (rG1 : reprG n1) (rG2 : reprG n2) : mx_rsim rG1 rG2 -> mx_absolutely_irreducible rG1 = mx_absolutely_irreducible rG2. Proof. case=> f def_n2; rewrite -{n2}def_n2 in f rG2 *. rewrite row_free_unit => injf homf; congr (_ && (_ == _)). pose Eg (g : 'M[F]_n1) := lin_mx (mulmxr (invmx g) \o mulmx g). have free_Ef: row_free (Eg f). apply/row_freeP; exists (Eg (invmx f)); apply/row_matrixP=> i. rewrite rowE row1 mulmxA mul_rV_lin mx_rV_lin /=. by rewrite invmxK !{1}mulmxA mulmxKV // -mulmxA mulKmx // vec_mxK. symmetry; rewrite -(mxrankMfree _ free_Ef); congr (\rank _). apply/row_matrixP=> i; rewrite row_mul !rowK mul_vec_lin /=. by rewrite -homf ?enum_valP // mulmxK. Qed. Lemma rker_mx_rsim n1 n2 (rG1 : reprG n1) (rG2 : reprG n2) : mx_rsim rG1 rG2 -> rker rG1 = rker rG2. Proof. case=> f def_n2; rewrite -{n2}def_n2 in f rG2 *. rewrite row_free_unit => injf homf. apply/setP=> x; rewrite !inE !mul1mx; apply: andb_id2l => Gx. by rewrite -(can_eq (mulmxK injf)) homf // -scalar_mxC (can_eq (mulKmx injf)). Qed. Lemma mx_rsim_faithful n1 n2 (rG1 : reprG n1) (rG2 : reprG n2) : mx_rsim rG1 rG2 -> mx_faithful rG1 = mx_faithful rG2. Proof. by move=> simG12; rewrite /mx_faithful (rker_mx_rsim simG12). Qed. Lemma mx_rsim_factmod n (rG : reprG n) U V (modU : mxmodule rG U) (modV : mxmodule rG V) : (U + V :=: 1%:M)%MS -> mxdirect (U + V) -> mx_rsim (factmod_repr modV) (submod_repr modU). Proof. move=> addUV dxUV. have eqUV: \rank U = \rank (cokermx V). by rewrite mxrank_coker -{3}(mxrank1 F n) -addUV (mxdirectP dxUV) addnK. have{} dxUV: (U :&: V = 0)%MS by apply/mxdirect_addsP. exists (in_submod U (val_factmod 1%:M *m proj_mx U V)) => // [|x Gx]. rewrite /row_free -{6}eqUV -[_ == _]sub1mx -val_submodS val_submod1. rewrite in_submodK ?proj_mx_sub // -{1}[U](proj_mx_id dxUV) //. rewrite -{1}(add_sub_fact_mod V U) mulmxDl proj_mx_0 ?val_submodP // add0r. by rewrite submxMr // val_factmodS submx1. rewrite -in_submodJ ?proj_mx_sub // -(hom_mxP _) //; last first. by apply: submx_trans (submx1 _) _; rewrite -addUV proj_mx_hom. rewrite mulmxA; congr (_ *m _); rewrite mulmxA -val_factmodE; apply/eqP. rewrite eq_sym -subr_eq0 -mulmxBl proj_mx_0 //. by rewrite -[_ *m rG x](add_sub_fact_mod V) addrK val_submodP. Qed. Lemma mxtrace_rsim n1 n2 (rG1 : reprG n1) (rG2 : reprG n2) : mx_rsim rG1 rG2 -> {in G, forall x, \tr (rG1 x) = \tr (rG2 x)}. Proof. case/mx_rsim_def=> B [B' B'B def_rG1] x Gx. by rewrite def_rG1 // mxtrace_mulC mulmxA B'B mul1mx. Qed. Lemma mx_rsim_scalar n1 n2 (rG1 : reprG n1) (rG2 : reprG n2) x c : x \in G -> mx_rsim rG1 rG2 -> rG1 x = c%:M -> rG2 x = c%:M. Proof. move=> Gx /mx_rsim_sym[B _ Bfree rG2_B] rG1x. by apply: (row_free_inj Bfree); rewrite rG2_B // rG1x scalar_mxC. Qed. End Similarity. Section Socle. Variables (gT : finGroupType) (G : {group gT}). Variables (n : nat) (rG : mx_representation F G n) (sG : socleType rG). Lemma socle_irr (W : sG) : mx_irreducible (socle_repr W). Proof. by apply/submod_mx_irr; apply: socle_simple. Qed. Lemma socle_rsimP (W1 W2 : sG) : reflect (mx_rsim (socle_repr W1) (socle_repr W2)) (W1 == W2). Proof. have [simW1 simW2] := (socle_simple W1, socle_simple W2). by apply: (iffP (component_mx_isoP simW1 simW2)); move/mx_rsim_iso; apply. Qed. Local Notation mG U := (mxmodule rG U). Local Notation sr modV := (submod_repr modV). Lemma mx_rsim_in_submod U V (modU : mG U) (modV : mG V) : let U' := <<in_submod V U>>%MS in (U <= V)%MS -> exists modU' : mxmodule (sr modV) U', mx_rsim (sr modU) (sr modU'). Proof. move=> U' sUV; have modU': mxmodule (sr modV) U'. by rewrite (eqmx_module _ (genmxE _)) in_submod_module. have rankU': \rank U = \rank U' by rewrite genmxE mxrank_in_submod. pose v1 := val_submod 1%:M; pose U1 := v1 _ U. have sU1V: (U1 <= V)%MS by rewrite val_submod1. have sU1U': (in_submod V U1 <= U')%MS by rewrite genmxE submxMr ?val_submod1. exists modU', (in_submod U' (in_submod V U1)) => // [|x Gx]. apply/row_freeP; exists (v1 _ _ *m v1 _ _ *m in_submod U 1%:M). rewrite mulmxA [X in X *m _]mulmxA -in_submodE. by rewrite -!val_submodE !in_submodK ?val_submodK. rewrite -!in_submodJ // -(val_submodJ modU) // mul1mx. by rewrite 2!{1}in_submodE mulmxA (mulmxA _ U1) -val_submodE -!in_submodE. Qed. Lemma rsim_submod1 U (modU : mG U) : (U :=: 1%:M)%MS -> mx_rsim (sr modU) rG. Proof. move=> U1; exists (val_submod 1%:M) => [||x Gx]; first by rewrite U1 mxrank1. by rewrite /row_free val_submod1. by rewrite -(val_submodJ modU) // mul1mx -val_submodE. Qed. Lemma mxtrace_submod1 U (modU : mG U) : (U :=: 1%:M)%MS -> {in G, forall x, \tr (sr modU x) = \tr (rG x)}. Proof. by move=> defU; apply: mxtrace_rsim (rsim_submod1 modU defU). Qed. Lemma mxtrace_dadd_mod U V W (modU : mG U) (modV : mG V) (modW : mG W) : (U + V :=: W)%MS -> mxdirect (U + V) -> {in G, forall x, \tr (sr modU x) + \tr (sr modV x) = \tr (sr modW x)}. Proof. move=> defW dxW x Gx; have [sUW sVW]: (U <= W)%MS /\ (V <= W)%MS. by apply/andP; rewrite -addsmx_sub defW. pose U' := <<in_submod W U>>%MS; pose V' := <<in_submod W V>>%MS. have addUV': (U' + V' :=: 1%:M)%MS. apply/eqmxP; rewrite submx1 /= (adds_eqmx (genmxE _) (genmxE _)). by rewrite -addsmxMr -val_submodS val_submod1 in_submodK ?defW. have dxUV': mxdirect (U' + V'). apply/eqnP; rewrite /= addUV' mxrank1 !genmxE !mxrank_in_submod //. by rewrite -(mxdirectP dxW) /= defW. have [modU' simU] := mx_rsim_in_submod modU modW sUW. have [modV' simV] := mx_rsim_in_submod modV modW sVW. rewrite (mxtrace_rsim simU) // (mxtrace_rsim simV) //. rewrite -(mxtrace_sub_fact_mod modV') addrC; congr (_ + _). by rewrite (mxtrace_rsim (mx_rsim_factmod modU' modV' addUV' dxUV')). Qed. Lemma mxtrace_dsum_mod (I : finType) (P : pred I) U W (modU : forall i, mG (U i)) (modW : mG W) : let S := (\sum_(i | P i) U i)%MS in (S :=: W)%MS -> mxdirect S -> {in G, forall x, \sum_(i | P i) \tr (sr (modU i) x) = \tr (sr modW x)}. Proof. move=> /= sumS dxS x Gx; have [m lePm] := ubnP #|P|. elim: m => // m IHm in P lePm W modW sumS dxS *. have [j /= Pj | P0] := pickP P; last first. case: sumS (_ x); rewrite !big_pred0 // mxrank0 => <- _ rWx. by rewrite [rWx]flatmx0 linear0. rewrite ltnS (cardD1x Pj) in lePm. rewrite mxdirectE /= !(bigD1 j Pj) -mxdirectE mxdirect_addsE /= in dxS sumS *. have [_ dxW' dxW] := and3P dxS; rewrite (sameP eqP mxdirect_addsP) in dxW. rewrite (IHm _ _ _ (sumsmx_module _ (fun i _ => modU i)) (eqmx_refl _)) //. exact: mxtrace_dadd_mod. Qed. Lemma mxtrace_component U (simU : mxsimple rG U) : let V := component_mx rG U in let modV := component_mx_module rG U in let modU := mxsimple_module simU in {in G, forall x, \tr (sr modV x) = \tr (sr modU x) *+ (\rank V %/ \rank U)}. Proof. move=> V modV modU x Gx. have [I W S simW defV dxV] := component_mx_semisimple simU. rewrite -(mxtrace_dsum_mod (fun i => mxsimple_module (simW i)) modV defV) //. have rankU_gt0: \rank U > 0 by rewrite lt0n mxrank_eq0; case simU. have isoW i: mx_iso rG U (W i). by apply: component_mx_iso; rewrite ?simU // -defV (sumsmx_sup i). have ->: (\rank V %/ \rank U)%N = #|I|. symmetry; rewrite -(mulnK #|I| rankU_gt0); congr (_ %/ _)%N. rewrite -defV (mxdirectP dxV) /= -sum_nat_const. by apply: eq_bigr => i _; apply: mxrank_iso. rewrite -sumr_const; apply: eq_bigr => i _; symmetry. by apply: mxtrace_rsim Gx; apply/mx_rsim_iso; apply: isoW. Qed. Lemma mxtrace_Socle : let modS := Socle_module sG in {in G, forall x, \tr (sr modS x) = \sum_(W : sG) \tr (socle_repr W x) *+ socle_mult W}. Proof. move=> /= x Gx /=; pose modW (W : sG) := component_mx_module rG (socle_base W). rewrite -(mxtrace_dsum_mod modW _ (eqmx_refl _) (Socle_direct sG)) //. by apply: eq_bigr => W _; rewrite (mxtrace_component (socle_simple W)). Qed. End Socle. Section Clifford. Variables (gT : finGroupType) (G H : {group gT}). Hypothesis nsHG : H <| G. Variables (n : nat) (rG : mx_representation F G n). Let sHG := normal_sub nsHG. Let nHG := normal_norm nsHG. Let rH := subg_repr rG sHG. Lemma Clifford_simple M x : mxsimple rH M -> x \in G -> mxsimple rH (M *m rG x). Proof. have modmG m U y: y \in G -> (mxmodule rH) m U -> mxmodule rH (U *m rG y). move=> Gy modU; apply/mxmoduleP=> h Hh; have Gh := subsetP sHG h Hh. rewrite -mulmxA -repr_mxM // conjgCV repr_mxM ?groupJ ?groupV // mulmxA. by rewrite submxMr ?(mxmoduleP modU) // -mem_conjg (normsP nHG). have nzmG m y (U : 'M_(m, n)): y \in G -> (U *m rG y == 0) = (U == 0). by move=> Gy; rewrite -{1}(mul0mx m (rG y)) (can_eq (repr_mxK rG Gy)). case=> [modM nzM simM] Gx; have Gx' := groupVr Gx. split=> [||U modU sUMx nzU]; rewrite ?modmG ?nzmG //. rewrite -(repr_mxKV rG Gx U) submxMr //. by rewrite (simM (U *m _)) ?modmG ?nzmG // -(repr_mxK rG Gx M) submxMr. Qed. Lemma Clifford_hom x m (U : 'M_(m, n)) : x \in 'C_G(H) -> (U <= dom_hom_mx rH (rG x))%MS. Proof. case/setIP=> Gx cHx; apply/rV_subP=> v _{U}. apply/hom_mxP=> h Hh; have Gh := subsetP sHG h Hh. by rewrite -!mulmxA /= -!repr_mxM // (centP cHx). Qed. Lemma Clifford_iso x U : x \in 'C_G(H) -> mx_iso rH U (U *m rG x). Proof. move=> cHx; have [Gx _] := setIP cHx. by exists (rG x); rewrite ?repr_mx_unit ?Clifford_hom. Qed. Lemma Clifford_iso2 x U V : mx_iso rH U V -> x \in G -> mx_iso rH (U *m rG x) (V *m rG x). Proof. case=> [f injf homUf defV] Gx; have Gx' := groupVr Gx. pose fx := rG (x^-1)%g *m f *m rG x; exists fx; last 1 first. - by rewrite !mulmxA repr_mxK //; apply: eqmxMr. - by rewrite !unitmx_mul andbC !repr_mx_unit. apply/hom_mxP=> h Hh; have Gh := subsetP sHG h Hh. rewrite -(mulmxA U) -repr_mxM // conjgCV repr_mxM ?groupJ // !mulmxA. rewrite !repr_mxK // (hom_mxP homUf) -?mem_conjg ?(normsP nHG) //=. by rewrite !repr_mxM ?invgK ?groupM // !mulmxA repr_mxKV. Qed. Lemma Clifford_componentJ M x : mxsimple rH M -> x \in G -> (component_mx rH (M *m rG x) :=: component_mx rH M *m rG x)%MS. Proof. set simH := mxsimple rH; set cH := component_mx rH. have actG: {in G, forall y M, simH M -> cH M *m rG y <= cH (M *m rG y)}%MS. move=> {M} y Gy /= M simM; have [I [U isoU def_cHM]] := component_mx_def simM. rewrite /cH def_cHM sumsmxMr; apply/sumsmx_subP=> i _. by apply: mx_iso_component; [apply: Clifford_simple | apply: Clifford_iso2]. move=> simM Gx; apply/eqmxP; rewrite actG // -/cH. rewrite -{1}[cH _](repr_mxKV rG Gx) submxMr // -{2}[M](repr_mxK rG Gx). by rewrite actG ?groupV //; apply: Clifford_simple. Qed. Hypothesis irrG : mx_irreducible rG. Lemma Clifford_basis M : mxsimple rH M -> {X : {set gT} | X \subset G & let S := \sum_(x in X) M *m rG x in S :=: 1%:M /\ mxdirect S}%MS. Proof. move=> simM. have simMG (g : [subg G]) : mxsimple rH (M *m rG (val g)). by case: g => x Gx; apply: Clifford_simple. have [|XG [defX1 dxX1]] := sum_mxsimple_direct_sub simMG (_ : _ :=: 1%:M)%MS. apply/eqmxP; case irrG => _ _ ->; rewrite ?submx1 //; last first. rewrite -submx0; apply/sumsmx_subP; move/(_ 1%g (erefl _)); apply: negP. by rewrite submx0 repr_mx1 mulmx1; case simM. apply/mxmoduleP=> x Gx; rewrite sumsmxMr; apply/sumsmx_subP=> [[y Gy]] /= _. by rewrite (sumsmx_sup (subg G (y * x)))// subgK ?groupM// -mulmxA repr_mxM. exists (val @: XG); first by apply/subsetP=> ?; case/imsetP=> [[x Gx]] _ ->. have bij_val: {on val @: XG, bijective (@sgval _ G)}. exists (subg G) => [g _ | x]; first exact: sgvalK. by case/imsetP=> [[x' Gx]] _ ->; rewrite subgK. have defXG g: (val g \in val @: XG) = (g \in XG). by apply/imsetP/idP=> [[h XGh] | XGg]; [move/val_inj-> | exists g]. by rewrite /= mxdirectE /= !(reindex _ bij_val) !(eq_bigl _ _ defXG). Qed. Variable sH : socleType rH. Definition Clifford_act (W : sH) x := let Gx := subgP (subg G x) in PackSocle (component_socle sH (Clifford_simple (socle_simple W) Gx)). Let valWact W x : (Clifford_act W x :=: W *m rG (sgval (subg G x)))%MS. Proof. rewrite PackSocleK; apply: Clifford_componentJ (subgP _). exact: socle_simple. Qed. Fact Clifford_is_action : is_action G Clifford_act. Proof. split=> [x W W' eqWW' | W x y Gx Gy]. pose Gx := subgP (subg G x); apply/socleP; apply/eqmxP. rewrite -(repr_mxK rG Gx W) -(repr_mxK rG Gx W'); apply: eqmxMr. apply: eqmx_trans (eqmx_sym _) (valWact _ _). by rewrite -eqWW'; apply: valWact. apply/socleP; rewrite !{1}valWact 2!{1}(eqmxMr _ (valWact _ _)). by rewrite !subgK ?groupM ?repr_mxM ?mulmxA ?andbb. Qed. Definition Clifford_action := Action Clifford_is_action. Local Notation "'Cl" := Clifford_action : action_scope. Lemma val_Clifford_act W x : x \in G -> ('Cl%act W x :=: W *m rG x)%MS. Proof. by move=> Gx; apply: eqmx_trans (valWact _ _) _; rewrite subgK. Qed. Lemma Clifford_atrans : [transitive G, on [set: sH] | 'Cl]. Proof. have [_ nz1 _] := irrG. apply: mxsimple_exists (mxmodule1 rH) nz1 _ _ => [[M simM _]]. pose W1 := PackSocle (component_socle sH simM). have [X sXG [def1 _]] := Clifford_basis simM; move/subsetP: sXG => sXG. apply/imsetP; exists W1; first by rewrite inE. symmetry; apply/setP=> W /[1!inE]; have simW := socle_simple W. have:= submx1 (socle_base W); rewrite -def1 -[(\sum_(x in X) _)%MS]mulmx1. case/(hom_mxsemisimple_iso simW) => [x Xx _ | | x Xx isoMxW]. - by apply: Clifford_simple; rewrite ?sXG. - exact: scalar_mx_hom. have Gx := sXG x Xx; apply/imsetP; exists x => //; apply/socleP/eqmxP/eqmx_sym. apply: eqmx_trans (val_Clifford_act _ Gx) _; rewrite PackSocleK. apply: eqmx_trans (eqmx_sym (Clifford_componentJ simM Gx)) _. apply/eqmxP; rewrite (sameP genmxP eqP) !{1}genmx_component. by apply/component_mx_isoP=> //; apply: Clifford_simple. Qed. Lemma Clifford_Socle1 : Socle sH = 1%:M. Proof. case/imsetP: Clifford_atrans => W _ _; have simW := socle_simple W. have [X sXG [def1 _]] := Clifford_basis simW. rewrite reducible_Socle1 //; apply: mxsemisimple_reducible. apply: intro_mxsemisimple def1 _ => x /(subsetP sXG) Gx _. exact: Clifford_simple. Qed. Lemma Clifford_rank_components (W : sH) : (#|sH| * \rank W)%N = n. Proof. rewrite -{9}(mxrank1 F n) -Clifford_Socle1. rewrite (mxdirectP (Socle_direct sH)) /= -sum_nat_const. apply: eq_bigr => W1 _; have [W0 _ W0G] := imsetP Clifford_atrans. have{} W0G W': W' \in orbit 'Cl G W0 by rewrite -W0G inE. have [/orbitP[x Gx <-] /orbitP[y Gy <-]] := (W0G W, W0G W1). by rewrite !{1}val_Clifford_act // !mxrankMfree // !repr_mx_free. Qed. Theorem Clifford_component_basis M : mxsimple rH M -> {t : nat & {x_ : sH -> 'I_t -> gT | forall W, let sW := (\sum_j M *m rG (x_ W j))%MS in [/\ forall j, x_ W j \in G, (sW :=: W)%MS & mxdirect sW]}}. Proof. move=> simM; pose t := (n %/ #|sH| %/ \rank M)%N; exists t. have [X /subsetP sXG [defX1 dxX1]] := Clifford_basis simM. pose sMv (W : sH) x := (M *m rG x <= W)%MS; pose Xv := [pred x in X | sMv _ x]. have sXvG W: {subset Xv W <= G} by move=> x /andP[/sXG]. have defW W: (\sum_(x in Xv W) M *m rG x :=: W)%MS. apply/eqmxP; rewrite -(geq_leqif (mxrank_leqif_eq _)); last first. by apply/sumsmx_subP=> x /andP[]. rewrite -(leq_add2r (\sum_(W' | W' != W) \rank W')) -((bigD1 W) predT) //=. rewrite -(mxdirectP (Socle_direct sH)) /= -/(Socle _) Clifford_Socle1 -defX1. apply: leq_trans (mxrankS _) (mxrank_sum_leqif _).1 => /=. rewrite (bigID (sMv W))%MS addsmxS //=. apply/sumsmx_subP=> x /andP[Xx notW_Mx]; have Gx := sXG x Xx. have simMx := Clifford_simple simM Gx. pose Wx := PackSocle (component_socle sH simMx). have sMxWx: (M *m rG x <= Wx)%MS by rewrite PackSocleK component_mx_id. by rewrite (sumsmx_sup Wx) //; apply: contra notW_Mx => /eqP <-. have dxXv W: mxdirect (\sum_(x in Xv W) M *m rG x). move: dxX1; rewrite !mxdirectE /= !(bigID (sMv W) [in X]) /=. by rewrite -mxdirectE mxdirect_addsE /= => /andP[]. have def_t W: #|Xv W| = t. rewrite /t -{1}(Clifford_rank_components W) mulKn 1?(cardD1 W) //. rewrite -defW (mxdirectP (dxXv W)) /= (eq_bigr (fun _ => \rank M)) => [|x]. rewrite sum_nat_const mulnK //; last by rewrite lt0n mxrank_eq0; case simM. by move/sXvG=> Gx; rewrite mxrankMfree // row_free_unit repr_mx_unit. exists (fun W i => enum_val (cast_ord (esym (def_t W)) i)) => W. case: {def_t}t / (def_t W) => sW. case: (pickP (Xv W)) => [x0 XvWx0 | XvW0]; last first. by case/negP: (nz_socle W); rewrite -submx0 -defW big_pred0. have{x0 XvWx0} reXv := reindex _ (enum_val_bij_in XvWx0). have def_sW: (sW :=: W)%MS. apply: eqmx_trans (defW W); apply/eqmxP; apply/genmxP; congr <<_>>%MS. rewrite reXv /=; apply: eq_big => [j | j _]; first by have:= enum_valP j. by rewrite cast_ord_id. split=> // [j|]; first by rewrite (sXvG W) ?enum_valP. apply/mxdirectP; rewrite def_sW -(defW W) /= (mxdirectP (dxXv W)) /= reXv /=. by apply: eq_big => [j | j _]; [move: (enum_valP j) | rewrite cast_ord_id]. Qed. Lemma Clifford_astab : H <*> 'C_G(H) \subset 'C([set: sH] | 'Cl). Proof. rewrite join_subG !subsetI sHG subsetIl /=; apply/andP; split. apply/subsetP=> h Hh /[1!inE]; have Gh := subsetP sHG h Hh. apply/subsetP=> W _; have simW := socle_simple W; have [modW _ _] := simW. have simWh: mxsimple rH (socle_base W *m rG h) by apply: Clifford_simple. rewrite inE -val_eqE /= PackSocleK eq_sym. apply/component_mx_isoP; rewrite ?subgK //; apply: component_mx_iso => //. by apply: submx_trans (component_mx_id simW); move/mxmoduleP: modW => ->. apply/subsetP=> z cHz /[1!inE]; have [Gz _] := setIP cHz. apply/subsetP=> W _; have simW := socle_simple W; have [modW _ _] := simW. have simWz: mxsimple rH (socle_base W *m rG z) by apply: Clifford_simple. rewrite inE -val_eqE /= PackSocleK eq_sym. by apply/component_mx_isoP; rewrite ?subgK //; apply: Clifford_iso. Qed. Lemma Clifford_astab1 (W : sH) : 'C[W | 'Cl] = rstabs rG W. Proof. apply/setP=> x /[!inE]; apply: andb_id2l => Gx. rewrite sub1set inE (sameP eqP socleP) !val_Clifford_act //. rewrite andb_idr // => sWxW; rewrite -mxrank_leqif_sup //. by rewrite mxrankMfree ?repr_mx_free. Qed. Lemma Clifford_rstabs_simple (W : sH) : mxsimple (subg_repr rG (rstabs_sub rG W)) W. Proof. split => [||U modU sUW nzU]; last 2 [exact: nz_socle]. by rewrite /mxmodule rstabs_subg setIid. have modUH: mxmodule rH U. apply/mxmoduleP=> h Hh; rewrite (mxmoduleP modU) //. rewrite /= -Clifford_astab1 !(inE, sub1set) (subsetP sHG) //. rewrite (astab_act (subsetP Clifford_astab h _)) ?inE //=. by rewrite mem_gen // inE Hh. apply: (mxsimple_exists modUH nzU) => [[M simM sMU]]. have [t [x_ /(_ W)[Gx_ defW _]]] := Clifford_component_basis simM. rewrite -defW; apply/sumsmx_subP=> j _; set x := x_ W j. have{Gx_} Gx: x \in G by rewrite Gx_. apply: submx_trans (submxMr _ sMU) _; apply: (mxmoduleP modU). rewrite inE -val_Clifford_act Gx //; set Wx := 'Cl%act W x. case: (eqVneq Wx W) (simM) => [-> //=|] neWxW [_ /negP[]]; rewrite -submx0. rewrite (canF_eq (actKin 'Cl Gx)) in neWxW. rewrite -(component_mx_disjoint _ _ neWxW); try exact: socle_simple. rewrite sub_capmx {1}(submx_trans sMU sUW) val_Clifford_act ?groupV //. by rewrite -(eqmxMr _ defW) sumsmxMr (sumsmx_sup j) ?repr_mxK. Qed. End Clifford. Section JordanHolder. Variables (gT : finGroupType) (G : {group gT}). Variables (n : nat) (rG : mx_representation F G n). Local Notation modG := ((mxmodule rG) n). Lemma section_module (U V : 'M_n) (modU : modG U) (modV : modG V) : mxmodule (factmod_repr modU) <<in_factmod U V>>%MS. Proof. by rewrite (eqmx_module _ (genmxE _)) in_factmod_module addsmx_module. Qed. Definition section_repr U V (modU : modG U) (modV : modG V) := submod_repr (section_module modU modV). Lemma mx_factmod_sub U modU : mx_rsim (@section_repr U _ modU (mxmodule1 rG)) (factmod_repr modU). Proof. exists (val_submod 1%:M) => [||x Gx]. - apply: (@addIn (\rank U)); rewrite genmxE mxrank_in_factmod mxrank_coker. by rewrite (addsmx_idPr (submx1 U)) mxrank1 subnK ?rank_leq_row. - by rewrite /row_free val_submod1. by rewrite -[_ x]mul1mx -val_submodE val_submodJ. Qed. Definition max_submod (U V : 'M_n) := (U < V)%MS /\ (forall W, ~ [/\ modG W, U < W & W < V])%MS. Lemma max_submodP U V (modU : modG U) (modV : modG V) : (U <= V)%MS -> (max_submod U V <-> mx_irreducible (section_repr modU modV)). Proof. move=> sUV; split=> [[ltUV maxU] | ]. apply/mx_irrP; split=> [|WU modWU nzWU]. by rewrite genmxE lt0n mxrank_eq0 in_factmod_eq0; case/andP: ltUV. rewrite -sub1mx -val_submodS val_submod1 genmxE. pose W := (U + val_factmod (val_submod WU))%MS. suffices sVW: (V <= W)%MS. rewrite {2}in_factmodE (submx_trans (submxMr _ sVW)) //. rewrite addsmxMr -!in_factmodE val_factmodK. by rewrite ((in_factmod U U =P 0) _) ?adds0mx ?in_factmod_eq0. move/and3P: {maxU}(maxU W); apply: contraR; rewrite /ltmx addsmxSl => -> /=. move: modWU; rewrite /mxmodule rstabs_submod rstabs_factmod => -> /=. rewrite addsmx_sub submx_refl -in_factmod_eq0 val_factmodK. move: nzWU; rewrite -[_ == 0](inj_eq val_submod_inj) linear0 => ->. rewrite -(in_factmodsK sUV) addsmxS // val_factmodS. by rewrite -(genmxE (in_factmod U V)) val_submodP. case/mx_irrP; rewrite lt0n {1}genmxE mxrank_eq0 in_factmod_eq0 => ltUV maxV. split=> // [|W [modW /andP[sUW ltUW] /andP[sWV /negP[]]]]; first exact/andP. rewrite -(in_factmodsK sUV) -(in_factmodsK sUW) addsmxS // val_factmodS. rewrite -genmxE -val_submod1; set VU := <<_>>%MS. have sW_VU: (in_factmod U W <= VU)%MS. by rewrite genmxE -val_factmodS !submxMr. rewrite -(in_submodK sW_VU) val_submodS -(genmxE (in_submod _ _)). rewrite sub1mx maxV //. rewrite (eqmx_module _ (genmxE _)) in_submod_module ?genmxE ?submxMr //. by rewrite in_factmod_module addsmx_module. rewrite -submx0 [(_ <= 0)%MS]genmxE -val_submodS linear0 in_submodK //. by rewrite eqmx0 submx0 in_factmod_eq0. Qed. Lemma max_submod_eqmx U1 U2 V1 V2 : (U1 :=: U2)%MS -> (V1 :=: V2)%MS -> max_submod U1 V1 -> max_submod U2 V2. Proof. move=> eqU12 eqV12 [ltUV1 maxU1]. by split=> [|W]; rewrite -(lt_eqmx eqU12) -(lt_eqmx eqV12). Qed. Definition mx_subseries := all modG. Definition mx_composition_series V := mx_subseries V /\ (forall i, i < size V -> max_submod (0 :: V)`_i V`_i). Local Notation mx_series := mx_composition_series. Fact mx_subseries_module V i : mx_subseries V -> mxmodule rG V`_i. Proof. move=> modV; have [|leVi] := ltnP i (size V); first exact: all_nthP. by rewrite nth_default ?mxmodule0. Qed. Fact mx_subseries_module' V i : mx_subseries V -> mxmodule rG (0 :: V)`_i. Proof. by move=> modV; rewrite mx_subseries_module //= mxmodule0. Qed. Definition subseries_repr V i (modV : all modG V) := section_repr (mx_subseries_module' i modV) (mx_subseries_module i modV). Definition series_repr V i (compV : mx_composition_series V) := subseries_repr i (proj1 compV). Lemma mx_series_lt V : mx_composition_series V -> path ltmx 0 V. Proof. by case=> _ compV; apply/(pathP 0)=> i /compV[]. Qed. Lemma max_size_mx_series (V : seq 'M[F]_n) : path ltmx 0 V -> size V <= \rank (last 0 V). Proof. rewrite -[size V]addn0 -(mxrank0 F n n); elim: V 0 => //= V1 V IHV V0. rewrite ltmxErank -andbA => /and3P[_ ltV01 ltV]. by apply: leq_trans (IHV _ ltV); rewrite addSnnS leq_add2l. Qed. Lemma mx_series_repr_irr V i (compV : mx_composition_series V) : i < size V -> mx_irreducible (series_repr i compV). Proof. case: compV => modV compV /compV maxVi; apply/max_submodP => //. by apply: ltmxW; case: maxVi. Qed. Lemma mx_series_rcons U V : mx_series (rcons U V) <-> [/\ mx_series U, modG V & max_submod (last 0 U) V]. Proof. rewrite /mx_series /mx_subseries all_rcons size_rcons -rcons_cons. split=> [ [/andP[modU modV] maxU] | [[modU maxU] modV maxV]]. split=> //; last first. by have:= maxU _ (leqnn _); rewrite !nth_rcons leqnn ltnn eqxx -last_nth. by split=> // i ltiU; have:= maxU i (ltnW ltiU); rewrite !nth_rcons leqW ltiU. rewrite modV; split=> // i; rewrite !nth_rcons ltnS leq_eqVlt. case: eqP => [-> _ | /= _ ltiU]; first by rewrite ltnn ?eqxx -last_nth. by rewrite ltiU; apply: maxU. Qed. Theorem mx_Schreier U : mx_subseries U -> path ltmx 0 U -> classically (exists V, [/\ mx_series V, last 0 V :=: 1%:M & subseq U V])%MS. Proof. move: U => U0; set U := {1 2}U0; have: subseq U0 U := subseq_refl U. pose n' := n.+1; have: n < size U + n' by rewrite leq_addl. elim: n' U => [|n' IH_U] U ltUn' sU0U modU incU [] // noV. rewrite addn0 ltnNge in ltUn'; case/negP: ltUn'. by rewrite (leq_trans (max_size_mx_series incU)) ?rank_leq_row. apply: (noV); exists U; split => //; first split=> // i lt_iU; last first. apply/eqmxP; apply: contraT => neU1. apply: {IH_U}(IH_U (rcons U 1%:M)) noV. - by rewrite size_rcons addSnnS. - by rewrite (subseq_trans sU0U) ?subseq_rcons. - by rewrite /mx_subseries all_rcons mxmodule1. by rewrite rcons_path ltmxEneq neU1 submx1 !andbT. set U'i := _`_i; set Ui := _`_i; have defU := cat_take_drop i U. have defU'i: U'i = last 0 (take i U). rewrite (last_nth 0) /U'i -{1}defU -cat_cons nth_cat /=. by rewrite size_take lt_iU leqnn. move: incU; rewrite -defU cat_path (drop_nth 0) //= -/Ui -defU'i. set U' := take i U; set U'' := drop _ U; case/and3P=> incU' ltUi incU''. split=> // W [modW ltUW ltWV]; case: notF. apply: {IH_U}(IH_U (U' ++ W :: Ui :: U'')) noV; last 2 first. - by rewrite /mx_subseries -drop_nth // all_cat /= modW -all_cat defU. - by rewrite cat_path /= -defU'i; apply/and4P. - by rewrite -drop_nth // size_cat /= addnS -size_cat defU addSnnS. by rewrite (subseq_trans sU0U) // -defU cat_subseq // -drop_nth ?subseq_cons. Qed. Lemma mx_second_rsim U V (modU : modG U) (modV : modG V) : let modI := capmx_module modU modV in let modA := addsmx_module modU modV in mx_rsim (section_repr modI modU) (section_repr modV modA). Proof. move=> modI modA; set nI := {1}(\rank _). have sIU := capmxSl U V; have sVA := addsmxSr U V. pose valI := val_factmod (val_submod (1%:M : 'M_nI)). have UvalI: (valI <= U)%MS. rewrite -(addsmx_idPr sIU) (submx_trans _ (proj_factmodS _ _)) //. by rewrite submxMr // val_submod1 genmxE. exists (valI *m in_factmod _ 1%:M *m in_submod _ 1%:M) => [||x Gx]. - apply: (@addIn (\rank (U :&: V) + \rank V)%N); rewrite genmxE addnA addnCA. rewrite /nI genmxE !{1}mxrank_in_factmod 2?(addsmx_idPr _) //. by rewrite -mxrank_sum_cap addnC. - rewrite -kermx_eq0; apply/rowV0P=> u; rewrite (sameP sub_kermxP eqP). rewrite mulmxA -in_submodE mulmxA -in_factmodE -(inj_eq val_submod_inj). rewrite linear0 in_submodK ?in_factmod_eq0 => [Vvu|]; last first. by rewrite genmxE addsmxC in_factmod_addsK submxMr // mulmx_sub. apply: val_submod_inj; apply/eqP; rewrite linear0 -[val_submod u]val_factmodK. rewrite val_submodE val_factmodE -mulmxA -val_factmodE -/valI. by rewrite in_factmod_eq0 sub_capmx mulmx_sub. symmetry; rewrite -{1}in_submodE -{1}in_submodJ; last first. by rewrite genmxE addsmxC in_factmod_addsK -in_factmodE submxMr. rewrite -{1}in_factmodE -{1}in_factmodJ // mulmxA in_submodE; congr (_ *m _). apply/eqP; rewrite mulmxA -in_factmodE -subr_eq0 -linearB in_factmod_eq0. apply: submx_trans (capmxSr U V); rewrite -in_factmod_eq0 linearB /=. rewrite subr_eq0 {1}(in_factmodJ modI) // val_factmodK eq_sym. rewrite /valI val_factmodE mulmxA -val_factmodE val_factmodK. by rewrite -[submod_mx _ _]mul1mx -val_submodE val_submodJ. Qed. Lemma section_eqmx_add U1 U2 V1 V2 modU1 modU2 modV1 modV2 : (U1 :=: U2)%MS -> (U1 + V1 :=: U2 + V2)%MS -> mx_rsim (@section_repr U1 V1 modU1 modV1) (@section_repr U2 V2 modU2 modV2). Proof. move=> eqU12 eqV12; set n1 := {1}(\rank _). pose v1 := val_factmod (val_submod (1%:M : 'M_n1)). have sv12: (v1 <= U2 + V2)%MS. rewrite -eqV12 (submx_trans _ (proj_factmodS _ _)) //. by rewrite submxMr // val_submod1 genmxE. exists (v1 *m in_factmod _ 1%:M *m in_submod _ 1%:M) => [||x Gx]. - apply: (@addIn (\rank U1)); rewrite {2}eqU12 /n1 !{1}genmxE. by rewrite !{1}mxrank_in_factmod eqV12. - rewrite -kermx_eq0; apply/rowV0P=> u; rewrite (sameP sub_kermxP eqP) mulmxA. rewrite -in_submodE mulmxA -in_factmodE -(inj_eq val_submod_inj) linear0. rewrite in_submodK ?in_factmod_eq0 -?eqU12 => [U1uv1|]; last first. by rewrite genmxE -(in_factmod_addsK U2 V2) submxMr // mulmx_sub. apply: val_submod_inj; apply/eqP; rewrite linear0 -[val_submod _]val_factmodK. by rewrite in_factmod_eq0 val_factmodE val_submodE -mulmxA -val_factmodE. symmetry; rewrite -{1}in_submodE -{1}in_factmodE -{1}in_submodJ; last first. by rewrite genmxE -(in_factmod_addsK U2 V2) submxMr. rewrite -{1}in_factmodJ // mulmxA in_submodE; congr (_ *m _); apply/eqP. rewrite mulmxA -in_factmodE -subr_eq0 -linearB in_factmod_eq0 -eqU12. rewrite -in_factmod_eq0 linearB /= subr_eq0 {1}(in_factmodJ modU1) //. rewrite val_factmodK /v1 val_factmodE eq_sym mulmxA -val_factmodE val_factmodK. by rewrite -[_ *m _]mul1mx mulmxA -val_submodE val_submodJ. Qed. Lemma section_eqmx U1 U2 V1 V2 modU1 modU2 modV1 modV2 (eqU : (U1 :=: U2)%MS) (eqV : (V1 :=: V2)%MS) : mx_rsim (@section_repr U1 V1 modU1 modV1) (@section_repr U2 V2 modU2 modV2). Proof. by apply: section_eqmx_add => //; apply: adds_eqmx. Qed. Lemma mx_butterfly U V W modU modV modW : ~~ (U == V)%MS -> max_submod U W -> max_submod V W -> let modUV := capmx_module modU modV in max_submod (U :&: V)%MS U /\ mx_rsim (@section_repr V W modV modW) (@section_repr _ U modUV modU). Proof. move=> neUV maxU maxV modUV; have{neUV maxU} defW: (U + V :=: W)%MS. wlog{neUV modUV} ltUV: U V modU modV maxU maxV / ~~ (V <= U)%MS. by case/nandP: neUV => ?; first rewrite addsmxC; apply. apply/eqmxP/idPn=> neUVW; case: maxU => ltUW; case/(_ (U + V)%MS). rewrite addsmx_module // ltmxE ltmxEneq neUVW addsmxSl !addsmx_sub. by have [ltVW _] := maxV; rewrite submx_refl andbT ltUV !ltmxW. have sUV_U := capmxSl U V; have sVW: (V <= W)%MS by rewrite -defW addsmxSr. set goal := mx_rsim _ _; suffices{maxV} simUV: goal. split=> //; apply/(max_submodP modUV modU sUV_U). by apply: mx_rsim_irr simUV _; apply/max_submodP. apply: {goal}mx_rsim_sym. by apply: mx_rsim_trans (mx_second_rsim modU modV) _; apply: section_eqmx. Qed. Lemma mx_JordanHolder_exists U V : mx_composition_series U -> modG V -> max_submod V (last 0 U) -> {W : seq 'M_n | mx_composition_series W & last 0 W = V}. Proof. elim/last_ind: U V => [|U Um IHU] V compU modV; first by case; rewrite ltmx0. rewrite last_rcons => maxV; case/mx_series_rcons: compU => compU modUm maxUm. case eqUV: (last 0 U == V)%MS. case/lastP: U eqUV compU {maxUm IHU} => [|U' Um']. by rewrite andbC; move/eqmx0P->; exists [::]. rewrite last_rcons; move/eqmxP=> eqU'V; case/mx_series_rcons=> compU _ maxUm'. exists (rcons U' V); last by rewrite last_rcons. by apply/mx_series_rcons; split => //; apply: max_submod_eqmx maxUm'. set Um' := last 0 U in maxUm eqUV; have [modU _] := compU. have modUm': modG Um' by rewrite /Um' (last_nth 0) mx_subseries_module'. have [|||W compW lastW] := IHU (V :&: Um')%MS; rewrite ?capmx_module //. by case: (mx_butterfly modUm' modV modUm); rewrite ?eqUV // {1}capmxC. exists (rcons W V); last by rewrite last_rcons. apply/mx_series_rcons; split; rewrite // lastW. by case: (mx_butterfly modV modUm' modUm); rewrite // andbC eqUV. Qed. Let rsim_rcons U V compU compUV i : i < size U -> mx_rsim (@series_repr U i compU) (@series_repr (rcons U V) i compUV). Proof. by move=> ltiU; apply: section_eqmx; rewrite -?rcons_cons nth_rcons ?leqW ?ltiU. Qed. Let last_mod U (compU : mx_series U) : modG (last 0 U). Proof. by case: compU => modU _; rewrite (last_nth 0) (mx_subseries_module' _ modU). Qed. Let rsim_last U V modUm modV compUV : mx_rsim (@section_repr (last 0 U) V modUm modV) (@series_repr (rcons U V) (size U) compUV). Proof. apply: section_eqmx; last by rewrite nth_rcons ltnn eqxx. by rewrite -rcons_cons nth_rcons leqnn -last_nth. Qed. Local Notation rsimT := mx_rsim_trans. Local Notation rsimC := mx_rsim_sym. Lemma mx_JordanHolder U V compU compV : let m := size U in (last 0 U :=: last 0 V)%MS -> m = size V /\ (exists p : 'S_m, forall i : 'I_m, mx_rsim (@series_repr U i compU) (@series_repr V (p i) compV)). Proof. move Dr: {-}(size U) => r; move/eqP in Dr. elim: r U V Dr compU compV => /= [|r IHr] U V. move/nilP->; case/lastP: V => [|V Vm] /= ? compVm; rewrite ?last_rcons => Vm0. by split=> //; exists 1%g; case. by case/mx_series_rcons: (compVm) => _ _ []; rewrite -(lt_eqmx Vm0) ltmx0. case/lastP: U => // [U Um]; rewrite size_rcons eqSS => szUr compUm. case/mx_series_rcons: (compUm); set Um' := last 0 U => compU modUm maxUm. case/lastP: V => [|V Vm] compVm; rewrite ?last_rcons ?size_rcons /= => eqUVm. by case/mx_series_rcons: (compUm) => _ _ []; rewrite (lt_eqmx eqUVm) ltmx0. case/mx_series_rcons: (compVm); set Vm' := last 0 V => compV modVm maxVm. have [modUm' modVm']: modG Um' * modG Vm' := (last_mod compU, last_mod compV). pose i_m := @ord_max (size U). have [eqUVm' | neqUVm'] := altP (@eqmxP _ _ _ _ Um' Vm'). have [szV [p sim_p]] := IHr U V szUr compU compV eqUVm'. split; first by rewrite szV. exists (lift_perm i_m i_m p) => i; case: (unliftP i_m i) => [j|] ->{i}. apply: rsimT (rsimC _) (rsimT (sim_p j) _). by rewrite lift_max; apply: rsim_rcons. by rewrite lift_perm_lift lift_max; apply: rsim_rcons; rewrite -szV. have simUVm := section_eqmx modUm' modVm' modUm modVm eqUVm' eqUVm. apply: rsimT (rsimC _) (rsimT simUVm _); first exact: rsim_last. by rewrite lift_perm_id /= szV; apply: rsim_last. have maxVUm: max_submod Vm' Um by apply: max_submod_eqmx (eqmx_sym _) maxVm. have:= mx_butterfly modUm' modVm' modUm neqUVm' maxUm maxVUm. move: (capmx_module _ _); set Wm := (Um' :&: Vm')%MS => modWm [maxWUm simWVm]. have:= mx_butterfly modVm' modUm' modUm _ maxVUm maxUm. move: (capmx_module _ _); rewrite andbC capmxC -/Wm => modWmV [// | maxWVm]. rewrite {modWmV}(bool_irrelevance modWmV modWm) => simWUm. have [W compW lastW] := mx_JordanHolder_exists compU modWm maxWUm. have compWU: mx_series (rcons W Um') by apply/mx_series_rcons; rewrite lastW. have compWV: mx_series (rcons W Vm') by apply/mx_series_rcons; rewrite lastW. have [|szW [pU pUW]] := IHr U _ szUr compU compWU; first by rewrite last_rcons. rewrite size_rcons in szW; have ltWU: size W < size U by rewrite -szW. have{IHr} := IHr _ V _ compWV compV; rewrite last_rcons size_rcons -szW. case=> {r szUr}// szV [pV pWV]; split; first by rewrite szV. pose j_m := Ordinal ltWU; pose i_m' := lift i_m j_m. exists (lift_perm i_m i_m pU * tperm i_m i_m' * lift_perm i_m i_m pV)%g => i. rewrite !permM; case: (unliftP i_m i) => [j {simWUm}|] ->{i}; last first. rewrite lift_perm_id tpermL lift_perm_lift lift_max {simWVm}. apply: rsimT (rsimT (pWV j_m) _); last by apply: rsim_rcons; rewrite -szV. apply: rsimT (rsimC _) {simWUm}(rsimT simWUm _); first exact: rsim_last. by rewrite -lastW in modWm *; apply: rsim_last. apply: rsimT (rsimC _) {pUW}(rsimT (pUW j) _). by rewrite lift_max; apply: rsim_rcons. rewrite lift_perm_lift; case: (unliftP j_m (pU j)) => [k|] ->{j pU}. rewrite tpermD ?(inj_eq lift_inj) ?neq_lift //. rewrite lift_perm_lift !lift_max; set j := lift j_m k. have ltjW: j < size W by have:= ltn_ord k; rewrite -(lift_max k) /= {1 3}szW. apply: rsimT (rsimT (pWV j) _); last by apply: rsim_rcons; rewrite -szV. by apply: rsimT (rsimC _) (rsim_rcons compW _ _); first apply: rsim_rcons. apply: rsimT {simWVm}(rsimC (rsimT simWVm _)) _. by rewrite -lastW in modWm *; apply: rsim_last. rewrite tpermR lift_perm_id /= szV. by apply: rsimT (rsim_last modVm' modVm _); apply: section_eqmx. Qed. Lemma mx_JordanHolder_max U (m := size U) V compU modV : (last 0 U :=: 1%:M)%MS -> mx_irreducible (@factmod_repr _ G n rG V modV) -> exists i : 'I_m, mx_rsim (factmod_repr modV) (@series_repr U i compU). Proof. rewrite {}/m; set Um := last 0 U => Um1 irrV. have modUm: modG Um := last_mod compU; have simV := rsimC (mx_factmod_sub modV). have maxV: max_submod V Um. move/max_submodP: (mx_rsim_irr simV irrV) => /(_ (submx1 _)). by apply: max_submod_eqmx; last apply: eqmx_sym. have [W compW lastW] := mx_JordanHolder_exists compU modV maxV. have compWU: mx_series (rcons W Um) by apply/mx_series_rcons; rewrite lastW. have:= mx_JordanHolder compU compWU; rewrite last_rcons size_rcons. case=> // szW [p pUW]; have ltWU: size W < size U by rewrite szW. pose i := Ordinal ltWU; exists ((p^-1)%g i). apply: rsimT simV (rsimT _ (rsimC (pUW _))); rewrite permKV. apply: rsimT (rsimC _) (rsim_last (last_mod compW) modUm _). by apply: section_eqmx; rewrite ?lastW. Qed. End JordanHolder. Bind Scope irrType_scope with socle_sort. Section Regular. Variables (gT : finGroupType) (G : {group gT}). Local Notation nG := #|pred_of_set (gval G)|. Local Notation aG := (regular_repr F G). Local Notation R_G := (group_ring F G). Lemma gring_free : row_free R_G. Proof. apply/row_freeP; exists (lin1_mx (row (gring_index G 1) \o vec_mx)). apply/row_matrixP=> i; rewrite row_mul rowK mul_rV_lin1 /= mxvecK rowK row1. by rewrite gring_indexK // mul1g gring_valK. Qed. Lemma gring_op_id A : (A \in R_G)%MS -> gring_op aG A = A. Proof. case/envelop_mxP=> a ->{A}; rewrite linear_sum. by apply: eq_bigr => x Gx; rewrite linearZ /= gring_opG. Qed. Lemma gring_rowK A : (A \in R_G)%MS -> gring_mx aG (gring_row A) = A. Proof. exact: gring_op_id. Qed. Lemma mem_gring_mx m a (M : 'M_(m, nG)) : (gring_mx aG a \in M *m R_G)%MS = (a <= M)%MS. Proof. by rewrite vec_mxK submxMfree ?gring_free. Qed. Lemma mem_sub_gring m A (M : 'M_(m, nG)) : (A \in M *m R_G)%MS = (A \in R_G)%MS && (gring_row A <= M)%MS. Proof. rewrite -(andb_idl (memmx_subP (submxMl _ _) A)); apply: andb_id2l => R_A. by rewrite -mem_gring_mx gring_rowK. Qed. Section GringMx. Variables (n : nat) (rG : mx_representation F G n). Lemma gring_mxP a : (gring_mx rG a \in enveloping_algebra_mx rG)%MS. Proof. by rewrite vec_mxK submxMl. Qed. Lemma gring_opM A B : (B \in R_G)%MS -> gring_op rG (A *m B) = gring_op rG A *m gring_op rG B. Proof. by move=> R_B; rewrite -gring_opJ gring_rowK. Qed. Hypothesis irrG : mx_irreducible rG. Lemma rsim_regular_factmod : {U : 'M_nG & {modU : mxmodule aG U & mx_rsim rG (factmod_repr modU)}}. Proof. pose v : 'rV[F]_n := nz_row 1%:M. pose fU := lin1_mx (mulmx v \o gring_mx rG); pose U := kermx fU. have modU: mxmodule aG U. apply/mxmoduleP => x Gx; apply/sub_kermxP/row_matrixP=> i. rewrite 2!row_mul row0; move: (row i U) (sub_kermxP (row_sub i U)) => u. by rewrite !mul_rV_lin1 /= gring_mxJ // mulmxA => ->; rewrite mul0mx. have def_n: \rank (cokermx U) = n. apply/eqP; rewrite mxrank_coker mxrank_ker subKn ?rank_leq_row // -genmxE. rewrite -[_ == _]sub1mx; have [_ _ ->] := irrG; rewrite ?submx1 //. rewrite (eqmx_module _ (genmxE _)); apply/mxmoduleP=> x Gx. apply/row_subP=> i; apply: eq_row_sub (gring_index G (enum_val i * x)) _. rewrite !rowE mulmxA !mul_rV_lin1 /= -mulmxA -gring_mxJ //. by rewrite -rowE rowK. rewrite (eqmx_eq0 (genmxE _)); apply/rowV0Pn. exists v; last exact: (nz_row_mxsimple irrG). apply/submxP; exists (gring_row (aG 1%g)); rewrite mul_rV_lin1 /=. by rewrite -gring_opE gring_opG // repr_mx1 mulmx1. exists U; exists modU; apply: mx_rsim_sym. exists (val_factmod 1%:M *m fU) => // [|x Gx]. rewrite /row_free eqn_leq rank_leq_row /= -subn_eq0 -mxrank_ker mxrank_eq0. apply/rowV0P=> u /sub_kermxP; rewrite mulmxA => /sub_kermxP. by rewrite -/U -in_factmod_eq0 mulmxA mulmx1 val_factmodK => /eqP. rewrite mulmxA -val_factmodE (canRL (addKr _) (add_sub_fact_mod U _)). rewrite mulmxDl mulNmx (sub_kermxP (val_submodP _)) oppr0 add0r. apply/row_matrixP=> i; move: (val_factmod _) => zz. by rewrite !row_mul !mul_rV_lin1 /= gring_mxJ // mulmxA. Qed. Lemma rsim_regular_series U (compU : mx_composition_series aG U) : (last 0 U :=: 1%:M)%MS -> exists i : 'I_(size U), mx_rsim rG (series_repr i compU). Proof. move=> lastU; have [V [modV simGV]] := rsim_regular_factmod. have irrV := mx_rsim_irr simGV irrG. have [i simVU] := mx_JordanHolder_max compU lastU irrV. by exists i; apply: mx_rsim_trans simGV simVU. Qed. Hypothesis F'G : [pchar F]^'.-group G. Lemma rsim_regular_submod_pchar : {U : 'M_nG & {modU : mxmodule aG U & mx_rsim rG (submod_repr modU)}}. Proof. have [V [modV eqG'V]] := rsim_regular_factmod. have [U modU defVU dxVU] := mx_Maschke_pchar F'G modV (submx1 V). exists U; exists modU; apply: mx_rsim_trans eqG'V _. by apply: mx_rsim_factmod; rewrite ?mxdirectE /= addsmxC // addnC. Qed. End GringMx. Definition gset_mx (A : {set gT}) := \sum_(x in A) aG x. Local Notation tG := #|pred_of_set (classes (gval G))|. Definition classg_base := \matrix_(k < tG) mxvec (gset_mx (enum_val k)). Let groupCl : {in G, forall x, {subset x ^: G <= G}}. Proof. by move=> x Gx; apply: subsetP; apply: class_subG. Qed. Lemma classg_base_free : row_free classg_base. Proof. rewrite -kermx_eq0; apply/rowV0P=> v /sub_kermxP; rewrite mulmx_sum_row => v0. apply/rowP=> k /[1!mxE]. have [x Gx def_k] := imsetP (enum_valP k). transitivity (@gring_proj F _ G x (vec_mx 0) 0 0); last first. by rewrite !linear0 !mxE. rewrite -{}v0 !linear_sum (bigD1 k) //= 2!linearZ /= rowK mxvecK def_k. rewrite linear_sum (bigD1 x) ?class_refl //= gring_projE // eqxx. rewrite !big1 ?addr0 ?mxE ?mulr1 // => [k' | y /andP[xGy ne_yx]]; first 1 last. by rewrite gring_projE ?(groupCl Gx xGy) // eq_sym (negPf ne_yx). rewrite rowK 2!linearZ /= mxvecK -(inj_eq enum_val_inj) def_k eq_sym. have [z Gz ->] := imsetP (enum_valP k'). move/eqP=> not_Gxz; rewrite linear_sum big1 ?scaler0 //= => y zGy. rewrite gring_projE ?(groupCl Gz zGy) //. by case: eqP zGy => // <- /class_eqP. Qed. Lemma classg_base_center : (classg_base :=: 'Z(R_G))%MS. Proof. apply/eqmxP/andP; split. apply/row_subP=> k; rewrite rowK /gset_mx sub_capmx {1}linear_sum. have [x Gx ->{k}] := imsetP (enum_valP k); have sxGG := groupCl Gx. rewrite summx_sub => [|y xGy]; last by rewrite envelop_mx_id ?sxGG. rewrite memmx_cent_envelop; apply/centgmxP=> y Gy. rewrite {2}(reindex_acts 'J _ Gy) ?astabsJ ?class_norm //=. rewrite mulmx_suml mulmx_sumr; apply: eq_bigr => z; move/sxGG=> Gz. by rewrite -!repr_mxM ?groupJ -?conjgC. apply/memmx_subP=> A; rewrite sub_capmx memmx_cent_envelop. case/andP=> /envelop_mxP[a ->{A}] cGa. rewrite (partition_big_imset (class^~ G)) -/(classes G) /=. rewrite linear_sum summx_sub //= => xG GxG; have [x Gx def_xG] := imsetP GxG. apply: submx_trans (scalemx_sub (a x) (submx_refl _)). rewrite (eq_row_sub (enum_rank_in GxG xG)) // linearZ /= rowK enum_rankK_in //. rewrite !linear_sum {xG GxG}def_xG; apply: eq_big => [y | xy] /=. apply/idP/andP=> [| [_ xGy]]; last by rewrite -(eqP xGy) class_refl. by case/imsetP=> z Gz ->; rewrite groupJ // classGidl. case/imsetP=> y Gy ->{xy}; rewrite linearZ; congr (_ *: _). move/(canRL (repr_mxK aG Gy)): (centgmxP cGa y Gy); have Gy' := groupVr Gy. move/(congr1 (gring_proj x)); rewrite -mulmxA mulmx_suml !linear_sum. rewrite (bigD1 x Gx) big1 => [|z /andP[Gz]]; rewrite linearZ /=; last first. by rewrite eq_sym gring_projE // => /negPf->; rewrite scaler0. rewrite gring_projE // eqxx scalemx1 (bigD1 (x ^ y)%g) ?groupJ //=. rewrite big1 => [|z /andP[Gz]]; rewrite -scalemxAl 2!linearZ /=. rewrite !addr0 -!repr_mxM ?groupM // mulgA mulKVg mulgK => /rowP/(_ 0). by rewrite gring_projE // eqxx scalemx1 !mxE. rewrite eq_sym -(can_eq (conjgKV y)) conjgK conjgE invgK. by rewrite -!repr_mxM ?gring_projE ?groupM // => /negPf->; rewrite scaler0. Qed. Lemma regular_module_ideal m (M : 'M_(m, nG)) : mxmodule aG M = right_mx_ideal R_G (M *m R_G). Proof. apply/idP/idP=> modM. apply/mulsmx_subP=> A B; rewrite !mem_sub_gring => /andP[R_A M_A] R_B. by rewrite envelop_mxM // gring_row_mul (mxmodule_envelop modM). apply/mxmoduleP=> x Gx; apply/row_subP=> i; rewrite row_mul -mem_gring_mx. rewrite gring_mxJ // (mulsmx_subP modM) ?envelop_mx_id //. by rewrite mem_gring_mx row_sub. Qed. Definition irrType := socleType aG. Identity Coercion type_of_irrType : irrType >-> socleType. Variable sG : irrType. Definition irr_degree (i : sG) := \rank (socle_base i). Local Notation "'n_ i" := (irr_degree i) : group_ring_scope. Local Open Scope group_ring_scope. Lemma irr_degreeE i : 'n_i = \rank (socle_base i). Proof. by []. Qed. Lemma irr_degree_gt0 i : 'n_i > 0. Proof. by rewrite lt0n mxrank_eq0; case: (socle_simple i). Qed. Definition irr_repr i : mx_representation F G 'n_i := socle_repr i. Lemma irr_reprE i x : irr_repr i x = submod_mx (socle_module i) x. Proof. by []. Qed. Lemma rfix_regular : (rfix_mx aG G :=: gring_row (gset_mx G))%MS. Proof. apply/eqmxP/andP; split; last first. apply/rfix_mxP => x Gx; rewrite -gring_row_mul; congr gring_row. rewrite {2}/gset_mx (reindex_astabs 'R x) ?astabsR //= mulmx_suml. by apply: eq_bigr => y Gy; rewrite repr_mxM. apply/rV_subP=> v /rfix_mxP cGv. have /envelop_mxP[a def_v]: (gring_mx aG v \in R_G)%MS. by rewrite vec_mxK submxMl. suffices ->: v = a 1%g *: gring_row (gset_mx G) by rewrite scalemx_sub. rewrite -linearZ scaler_sumr -[v]gring_mxK def_v; congr (gring_row _). apply: eq_bigr => x Gx; congr (_ *: _). move/rowP/(_ 0): (congr1 (gring_proj x \o gring_mx aG) (cGv x Gx)). rewrite /= gring_mxJ // def_v mulmx_suml !linear_sum (bigD1 1%g) //=. rewrite repr_mx1 -scalemxAl mul1mx linearZ /= gring_projE // eqxx scalemx1. rewrite big1 ?addr0 ?mxE /= => [ | y /andP[Gy nt_y]]; last first. rewrite -scalemxAl linearZ -repr_mxM //= gring_projE ?groupM //. by rewrite eq_sym eq_mulgV1 mulgK (negPf nt_y) scaler0. rewrite (bigD1 x) //= linearZ /= gring_projE // eqxx scalemx1. rewrite big1 ?addr0 ?mxE // => y /andP[Gy ne_yx]. by rewrite linearZ /= gring_projE // eq_sym (negPf ne_yx) scaler0. Qed. Lemma principal_comp_subproof : mxsimple aG (rfix_mx aG G). Proof. apply: linear_mxsimple; first exact: rfix_mx_module. apply/eqP; rewrite rfix_regular eqn_leq rank_leq_row lt0n mxrank_eq0. apply/eqP => /(congr1 (gring_proj 1 \o gring_mx aG)); apply/eqP. rewrite /= -[gring_mx _ _]/(gring_op _ _) !linear0 !linear_sum (bigD1 1%g) //=. rewrite gring_opG ?gring_projE // eqxx big1 ?addr0 ?oner_eq0 // => x. by case/andP=> Gx nt_x; rewrite gring_opG // gring_projE // eq_sym (negPf nt_x). Qed. Fact principal_comp_key : unit. Proof. by []. Qed. Definition principal_comp_def := PackSocle (component_socle sG principal_comp_subproof). Definition principal_comp := locked_with principal_comp_key principal_comp_def. Local Notation "1" := principal_comp : irrType_scope. Lemma irr1_rfix : (1%irr :=: rfix_mx aG G)%MS. Proof. rewrite [1%irr]unlock PackSocleK; apply/eqmxP. rewrite (component_mx_id principal_comp_subproof) andbT. have [I [W isoW ->]] := component_mx_def principal_comp_subproof. apply/sumsmx_subP=> i _; have [f _ hom_f <-]:= isoW i. (* FIX ME : this takes time *) by apply/rfix_mxP=> x Gx; rewrite -(hom_mxP hom_f) // (rfix_mxP G _). Qed. Lemma rank_irr1 : \rank 1%irr = 1. Proof. apply/eqP; rewrite eqn_leq lt0n mxrank_eq0 nz_socle andbT. by rewrite irr1_rfix rfix_regular rank_leq_row. Qed. Lemma degree_irr1 : 'n_1 = 1. Proof. apply/eqP; rewrite eqn_leq irr_degree_gt0 -rank_irr1. by rewrite mxrankS ?component_mx_id //; apply: socle_simple. Qed. Definition Wedderburn_subring (i : sG) := <<i *m R_G>>%MS. Local Notation "''R_' i" := (Wedderburn_subring i) : group_ring_scope. Let sums_R : (\sum_i 'R_i :=: Socle sG *m R_G)%MS. Proof. apply/eqmxP; set R_S := (_ <= _)%MS. have sRS: R_S by apply/sumsmx_subP=> i; rewrite genmxE submxMr ?(sumsmx_sup i). rewrite sRS -(mulmxKpV sRS) mulmxA submxMr //; apply/sumsmx_subP=> i _. rewrite -(submxMfree _ _ gring_free) -(mulmxA _ _ R_G) mulmxKpV //. by rewrite (sumsmx_sup i) ?genmxE. Qed. Lemma Wedderburn_ideal i : mx_ideal R_G 'R_i. Proof. apply/andP; split; last first. rewrite /right_mx_ideal genmxE (muls_eqmx (genmxE _) (eqmx_refl _)). by rewrite -[(_ <= _)%MS]regular_module_ideal component_mx_module. apply/mulsmx_subP=> A B R_A; rewrite !genmxE !mem_sub_gring => /andP[R_B SiB]. rewrite envelop_mxM {R_A}// gring_row_mul -{R_B}(gring_rowK R_B). pose f := mulmx (gring_row A) \o gring_mx aG. rewrite -[_ *m _](mul_rV_lin1 f). suffices: (i *m lin1_mx f <= i)%MS by apply: submx_trans; rewrite submxMr. apply: hom_component_mx; first exact: socle_simple. apply/rV_subP=> v _; apply/hom_mxP=> x Gx. by rewrite !mul_rV_lin1 /f /= gring_mxJ ?mulmxA. Qed. Lemma Wedderburn_direct : mxdirect (\sum_i 'R_i)%MS. Proof. apply/mxdirectP; rewrite /= sums_R mxrankMfree ?gring_free //. rewrite (mxdirectP (Socle_direct sG)); apply: eq_bigr=> i _ /=. by rewrite genmxE mxrankMfree ?gring_free. Qed. Lemma Wedderburn_disjoint i j : i != j -> ('R_i :&: 'R_j)%MS = 0. Proof. move=> ne_ij; apply/eqP; rewrite -submx0 capmxC. by rewrite -(mxdirect_sumsP Wedderburn_direct j) // capmxS // (sumsmx_sup i). Qed. Lemma Wedderburn_annihilate i j : i != j -> ('R_i * 'R_j)%MS = 0. Proof. move=> ne_ij; apply/eqP; rewrite -submx0 -(Wedderburn_disjoint ne_ij). rewrite sub_capmx; apply/andP; split. case/andP: (Wedderburn_ideal i) => _; apply: submx_trans. by rewrite mulsmxS // genmxE submxMl. case/andP: (Wedderburn_ideal j) => idlRj _; apply: submx_trans idlRj. by rewrite mulsmxS // genmxE submxMl. Qed. Lemma Wedderburn_mulmx0 i j A B : i != j -> (A \in 'R_i)%MS -> (B \in 'R_j)%MS -> A *m B = 0. Proof. move=> ne_ij RiA RjB; apply: memmx0. by rewrite -(Wedderburn_annihilate ne_ij) mem_mulsmx. Qed. Hypothesis F'G : [pchar F]^'.-group G. Lemma irr_mx_sum_pchar : (\sum_(i : sG) i = 1%:M)%MS. Proof. by apply: reducible_Socle1; apply: mx_Maschke_pchar. Qed. Lemma Wedderburn_sum_pchar : (\sum_i 'R_i :=: R_G)%MS. Proof. by apply: eqmx_trans sums_R _; rewrite /Socle irr_mx_sum_pchar mul1mx. Qed. Definition Wedderburn_id i := vec_mx (mxvec 1%:M *m proj_mx 'R_i (\sum_(j | j != i) 'R_j)%MS). Local Notation "''e_' i" := (Wedderburn_id i) : group_ring_scope. Lemma Wedderburn_sum_id_pchar : \sum_i 'e_i = 1%:M. Proof. rewrite -linear_sum; apply: canLR mxvecK _. have: (1%:M \in R_G)%MS := envelop_mx1 aG. rewrite -Wedderburn_sum_pchar. case/(sub_dsumsmx Wedderburn_direct) => e Re -> _. apply: eq_bigr => i _; have dxR := mxdirect_sumsP Wedderburn_direct i (erefl _). rewrite (bigD1 i) // mulmxDl proj_mx_id ?Re // proj_mx_0 ?addr0 //=. by rewrite summx_sub // => j ne_ji; rewrite (sumsmx_sup j) ?Re. Qed. Lemma Wedderburn_id_mem i : ('e_i \in 'R_i)%MS. Proof. by rewrite vec_mxK proj_mx_sub. Qed. Lemma Wedderburn_is_id_pchar i : mxring_id 'R_i 'e_i. Proof. have ideRi A: (A \in 'R_i)%MS -> 'e_i *m A = A. move=> RiA; rewrite -{2}[A]mul1mx -Wedderburn_sum_id_pchar mulmx_suml. rewrite (bigD1 i) //= big1 ?addr0 // => j ne_ji. by rewrite (Wedderburn_mulmx0 ne_ji) ?Wedderburn_id_mem. split=> // [||A RiA]; first 2 [exact: Wedderburn_id_mem]. apply: contraNneq (nz_socle i) => e0. apply/rowV0P=> v; rewrite -mem_gring_mx -(genmxE (i *m _)) => /ideRi. by rewrite e0 mul0mx => /(canLR gring_mxK); rewrite linear0. rewrite -{2}[A]mulmx1 -Wedderburn_sum_id_pchar mulmx_sumr (bigD1 i) //=. rewrite big1 ?addr0 // => j; rewrite eq_sym => ne_ij. by rewrite (Wedderburn_mulmx0 ne_ij) ?Wedderburn_id_mem. Qed. Lemma Wedderburn_closed_pchar i : ('R_i * 'R_i = 'R_i)%MS. Proof. rewrite -{3}['R_i]genmx_id -/'R_i -genmx_muls; apply/genmxP. have [idlRi idrRi] := andP (Wedderburn_ideal i). apply/andP; split. by apply: submx_trans idrRi; rewrite mulsmxS // genmxE submxMl. have [_ Ri_e ideRi _] := Wedderburn_is_id_pchar i. by apply/memmx_subP=> A RiA; rewrite -[A]ideRi ?mem_mulsmx. Qed. Lemma Wedderburn_is_ring_pchar i : mxring 'R_i. Proof. rewrite /mxring /left_mx_ideal Wedderburn_closed_pchar submx_refl. by apply/mxring_idP; exists 'e_i; apply: Wedderburn_is_id_pchar. Qed. Lemma Wedderburn_min_ideal_pchar m i (E : 'A_(m, nG)) : E != 0 -> (E <= 'R_i)%MS -> mx_ideal R_G E -> (E :=: 'R_i)%MS. Proof. move=> nzE sE_Ri /andP[idlE idrE]; apply/eqmxP; rewrite sE_Ri. pose M := E *m pinvmx R_G; have defE: E = M *m R_G. by rewrite mulmxKpV // (submx_trans sE_Ri) // genmxE submxMl. have modM: mxmodule aG M by rewrite regular_module_ideal -defE. have simSi := socle_simple i; set Si := socle_base i in simSi. have [I [W isoW defW]]:= component_mx_def simSi. rewrite /'R_i /socle_val /= defW genmxE defE submxMr //. apply/sumsmx_subP=> j _. have simW := mx_iso_simple (isoW j) simSi; have [modW _ minW] := simW. have [{minW}dxWE | nzWE] := eqVneq (W j :&: M)%MS 0; last first. by rewrite (sameP capmx_idPl eqmxP) minW ?capmxSl ?capmx_module. have [_ Rei ideRi _] := Wedderburn_is_id_pchar i. have:= nzE; rewrite -submx0 => /memmx_subP[A E_A]. rewrite -(ideRi _ (memmx_subP sE_Ri _ E_A)). have:= E_A; rewrite defE mem_sub_gring => /andP[R_A M_A]. have:= Rei; rewrite genmxE mem_sub_gring => /andP[Re]. rewrite -{2}(gring_rowK Re) /socle_val defW => /sub_sumsmxP[e ->]. rewrite !(linear_sum, mulmx_suml) summx_sub //= => k _. rewrite -(gring_rowK R_A) -gring_mxA -mulmxA gring_rowK //. rewrite ((W k *m _ =P 0) _) ?linear0 ?sub0mx //. have [f _ homWf defWk] := mx_iso_trans (mx_iso_sym (isoW j)) (isoW k). rewrite -submx0 -{k defWk}(eqmxMr _ defWk) -(hom_envelop_mxC homWf) //. rewrite -(mul0mx _ f) submxMr {f homWf}// -dxWE sub_capmx. rewrite (mxmodule_envelop modW) //=; apply/row_subP=> k. rewrite row_mul -mem_gring_mx -(gring_rowK R_A) gring_mxA gring_rowK //. by rewrite -defE (memmx_subP idlE) // mem_mulsmx ?gring_mxP. Qed. Section IrrComponent. (* The component of the socle of the regular module that is associated to an *) (* irreducible representation. *) Variables (n : nat) (rG : mx_representation F G n). Local Notation E_G := (enveloping_algebra_mx rG). Let not_rsim_op0_pchar (iG j : sG) A : mx_rsim rG (socle_repr iG) -> iG != j -> (A \in 'R_j)%MS -> gring_op rG A = 0. Proof. case/mx_rsim_def=> f [f' _ hom_f] ne_iG_j RjA. transitivity (f *m in_submod _ (val_submod 1%:M *m A) *m f'). have{RjA}: (A \in R_G)%MS by rewrite -Wedderburn_sum_pchar (sumsmx_sup j). case/envelop_mxP=> a ->{A}; rewrite !(linear_sum, mulmx_suml). by apply: eq_bigr => x Gx; rewrite 4!linearZ /= -scalemxAl -hom_f ?gring_opG. rewrite (_ : _ *m A = 0) ?(linear0, mul0mx) //. apply/row_matrixP=> i; rewrite row_mul row0 -[row _ _]gring_mxK -gring_row_mul. rewrite (Wedderburn_mulmx0 ne_iG_j) ?linear0 // genmxE mem_gring_mx. by rewrite (row_subP _) // val_submod1 component_mx_id //; apply: socle_simple. Qed. Definition irr_comp := odflt 1%irr [pick i | gring_op rG 'e_i != 0]. Local Notation iG := irr_comp. Hypothesis irrG : mx_irreducible rG. Lemma rsim_irr_comp_pchar : mx_rsim rG (irr_repr iG). Proof. have [M [modM rsimM]] := rsim_regular_submod_pchar irrG F'G. have simM: mxsimple aG M. case/mx_irrP: irrG => n_gt0 minG. have [f def_n injf homf] := mx_rsim_sym rsimM. apply/(submod_mx_irr modM)/mx_irrP. split=> [|U modU nzU]; first by rewrite def_n. rewrite /row_full -(mxrankMfree _ injf) -genmxE {4}def_n. apply: minG; last by rewrite -mxrank_eq0 genmxE mxrankMfree // mxrank_eq0. rewrite (eqmx_module _ (genmxE _)); apply/mxmoduleP=> x Gx. by rewrite -mulmxA -homf // mulmxA submxMr // (mxmoduleP modU). pose i := PackSocle (component_socle sG simM). have{modM} rsimM: mx_rsim rG (socle_repr i). apply: mx_rsim_trans rsimM (mx_rsim_sym _); apply/mx_rsim_iso. apply: (component_mx_iso (socle_simple _)) => //. by rewrite [component_mx _ _]PackSocleK component_mx_id. have [<- // | ne_i_iG] := eqVneq i iG. suffices {i M simM ne_i_iG rsimM}: gring_op rG 'e_iG != 0. by rewrite (not_rsim_op0_pchar rsimM ne_i_iG) ?Wedderburn_id_mem ?eqxx. rewrite /iG; case: pickP => //= G0. suffices: rG 1%g == 0. by case/idPn; rewrite -mxrank_eq0 repr_mx1 mxrank1 -lt0n; case/mx_irrP: irrG. rewrite -gring_opG // repr_mx1 -Wedderburn_sum_id_pchar linear_sum big1 //. by move=> j _; move/eqP: (G0 j). Qed. Lemma irr_comp'_op0_pchar j A : j != iG -> (A \in 'R_j)%MS -> gring_op rG A = 0. Proof. by rewrite eq_sym; apply: not_rsim_op0_pchar rsim_irr_comp_pchar. Qed. Lemma irr_comp_envelop_pchar : ('R_iG *m lin_mx (gring_op rG) :=: E_G)%MS. Proof. apply/eqmxP/andP; split; apply/row_subP=> i. by rewrite row_mul mul_rV_lin gring_mxP. rewrite rowK /= -gring_opG ?enum_valP // -mul_vec_lin -gring_opG ?enum_valP //. rewrite vec_mxK /= -mulmxA mulmx_sub {i}//= -(eqmxMr _ Wedderburn_sum_pchar). rewrite (bigD1 iG) //= addsmxMr addsmxC [_ *m _](sub_kermxP _) ?adds0mx //=. apply/sumsmx_subP => j ne_j_iG; apply/memmx_subP=> A RjA; apply/sub_kermxP. by rewrite mul_vec_lin /= (irr_comp'_op0_pchar ne_j_iG RjA) linear0. Qed. Lemma ker_irr_comp_op_pchar : ('R_iG :&: kermx (lin_mx (gring_op rG)))%MS = 0. Proof. apply/eqP; rewrite -submx0; apply/memmx_subP=> A. rewrite sub_capmx /= submx0 mxvec_eq0 => /andP[R_A]. rewrite (sameP sub_kermxP eqP) mul_vec_lin mxvec_eq0 /= => opA0. have [_ Re ideR _] := Wedderburn_is_id_pchar iG; rewrite -[A]ideR {ideR}//. move: Re; rewrite genmxE mem_sub_gring /socle_val => /andP[Re]. rewrite -{2}(gring_rowK Re) -submx0. pose simMi := socle_simple iG; have [J [M isoM ->]] := component_mx_def simMi. case/sub_sumsmxP=> e ->; rewrite linear_sum mulmx_suml summx_sub // => j _. rewrite -(in_submodK (submxMl _ (M j))); move: (in_submod _ _) => v. have modMj: mxmodule aG (M j) by apply: mx_iso_module (isoM j) _; case: simMi. have rsimMj: mx_rsim rG (submod_repr modMj). by apply: mx_rsim_trans rsim_irr_comp_pchar _; apply/mx_rsim_iso. have [f [f' _ hom_f]] := mx_rsim_def (mx_rsim_sym rsimMj); rewrite submx0. have <-: (gring_mx aG (val_submod (v *m (f *m gring_op rG A *m f')))) = 0. by rewrite (eqP opA0) !(mul0mx, linear0). have: (A \in R_G)%MS by rewrite -Wedderburn_sum_pchar (sumsmx_sup iG). case/envelop_mxP=> a ->; rewrite !(linear_sum, mulmx_suml) /=; apply/eqP. apply: eq_bigr=> x Gx; rewrite 3!linearZ -scalemxAl 3!linearZ /=. by rewrite gring_opG // -hom_f // val_submodJ // gring_mxJ. Qed. Lemma regular_op_inj_pchar : {in [pred A | (A \in 'R_iG)%MS] &, injective (gring_op rG)}. Proof. move=> A B RnA RnB /= eqAB; apply/eqP; rewrite -subr_eq0 -mxvec_eq0 -submx0. rewrite -ker_irr_comp_op_pchar sub_capmx (sameP sub_kermxP eqP) mul_vec_lin. by rewrite 2!raddfB /= eqAB subrr linear0 addmx_sub ?eqmx_opp /=. Qed. Lemma rank_irr_comp_pchar : \rank 'R_iG = \rank E_G. Proof. rewrite -irr_comp_envelop_pchar; apply/esym/mxrank_injP. by rewrite ker_irr_comp_op_pchar. Qed. End IrrComponent. Lemma irr_comp_rsim_pchar n1 n2 rG1 rG2 : @mx_rsim _ G n1 rG1 n2 rG2 -> irr_comp rG1 = irr_comp rG2. Proof. case=> f eq_n12; rewrite -eq_n12 in rG2 f * => inj_f hom_f. rewrite /irr_comp; apply/f_equal/eq_pick => i; rewrite -!mxrank_eq0. (* [congr (odflt 1%irr _)] works but is very slow *) rewrite -(mxrankMfree _ inj_f); symmetry; rewrite -(eqmxMfull _ inj_f). have /envelop_mxP[e ->{i}]: ('e_i \in R_G)%MS. by rewrite -Wedderburn_sum_pchar (sumsmx_sup i) ?Wedderburn_id_mem. congr (\rank _ != _); rewrite !(mulmx_suml, linear_sum); apply: eq_bigr => x Gx. by rewrite 3!linearZ -scalemxAl /= !gring_opG ?hom_f. Qed. Lemma irr_reprK_pchar i : irr_comp (irr_repr i) = i. Proof. apply/eqP; apply/component_mx_isoP; try exact: socle_simple. by move/mx_rsim_iso: (rsim_irr_comp_pchar (socle_irr i)); apply: mx_iso_sym. Qed. Lemma irr_repr'_op0_pchar i j A : j != i -> (A \in 'R_j)%MS -> gring_op (irr_repr i) A = 0. Proof. move=> neq_ij /(irr_comp'_op0_pchar _). by move=> ->; [|apply: socle_irr|rewrite irr_reprK_pchar]. Qed. Lemma op_Wedderburn_id_pchar i : gring_op (irr_repr i) 'e_i = 1%:M. Proof. rewrite -(gring_op1 (irr_repr i)) -Wedderburn_sum_id_pchar. rewrite linear_sum (bigD1 i) //= addrC big1 ?add0r // => j neq_ji. exact: irr_repr'_op0_pchar (Wedderburn_id_mem j). Qed. Lemma irr_comp_id_pchar (M : 'M_nG) (modM : mxmodule aG M) (iM : sG) : mxsimple aG M -> (M <= iM)%MS -> irr_comp (submod_repr modM) = iM. Proof. move=> simM sMiM; rewrite -[iM]irr_reprK_pchar. apply/esym/irr_comp_rsim_pchar/mx_rsim_iso/component_mx_iso => //. exact: socle_simple. Qed. Lemma irr1_repr x : x \in G -> irr_repr 1 x = 1%:M. Proof. move=> Gx; suffices: x \in rker (irr_repr 1) by case/rkerP. apply: subsetP x Gx; rewrite rker_submod rfix_mx_rstabC // -irr1_rfix. by apply: component_mx_id; apply: socle_simple. Qed. Hypothesis splitG : group_splitting_field G. Lemma rank_Wedderburn_subring_pchar i : \rank 'R_i = ('n_i ^ 2)%N. Proof. apply/eqP; rewrite -{1}[i]irr_reprK_pchar; have irrSi := socle_irr i. by case/andP: (splitG irrSi) => _; rewrite rank_irr_comp_pchar. Qed. Lemma sum_irr_degree_pchar : (\sum_i 'n_i ^ 2 = nG)%N. Proof. apply: etrans (eqnP gring_free). rewrite -Wedderburn_sum_pchar (mxdirectP Wedderburn_direct) /=. by apply: eq_bigr => i _; rewrite rank_Wedderburn_subring_pchar. Qed. Lemma irr_mx_mult_pchar i : socle_mult i = 'n_i. Proof. rewrite /socle_mult -(mxrankMfree _ gring_free) -genmxE. by rewrite rank_Wedderburn_subring_pchar mulKn ?irr_degree_gt0. Qed. Lemma mxtrace_regular_pchar : {in G, forall x, \tr (aG x) = \sum_i \tr (socle_repr i x) *+ 'n_i}. Proof. move=> x Gx; have soc1: (Socle sG :=: 1%:M)%MS by rewrite -irr_mx_sum_pchar. rewrite -(mxtrace_submod1 (Socle_module sG) soc1) // mxtrace_Socle //. by apply: eq_bigr => i _; rewrite irr_mx_mult_pchar. Qed. Definition linear_irr := [set i | 'n_i == 1]. Lemma irr_degree_abelian : abelian G -> forall i, 'n_i = 1. Proof. by move=> cGG i; apply: mxsimple_abelian_linear (socle_simple i). Qed. Lemma linear_irr_comp_pchar i : 'n_i = 1 -> (i :=: socle_base i)%MS. Proof. move=> ni1; apply/eqmxP; rewrite andbC -mxrank_leqif_eq -/'n_i. rewrite -(mxrankMfree _ gring_free) -genmxE. by rewrite rank_Wedderburn_subring_pchar ni1. exact: component_mx_id (socle_simple i). Qed. Lemma Wedderburn_subring_center_pchar i : ('Z('R_i) :=: mxvec 'e_i)%MS. Proof. have [nz_e Re ideR idRe] := Wedderburn_is_id_pchar i. have Ze: (mxvec 'e_i <= 'Z('R_i))%MS. rewrite sub_capmx [(_ <= _)%MS]Re. by apply/cent_mxP=> A R_A; rewrite ideR // idRe. pose irrG := socle_irr i; set rG := socle_repr i in irrG. pose E_G := enveloping_algebra_mx rG; have absG := splitG irrG. apply/eqmxP; rewrite andbC -(geq_leqif (mxrank_leqif_eq Ze)). have ->: \rank (mxvec 'e_i) = (0 + 1)%N. by apply/eqP; rewrite eqn_leq rank_leq_row lt0n mxrank_eq0 mxvec_eq0. rewrite -(mxrank_mul_ker _ (lin_mx (gring_op rG))) addnC leq_add //. rewrite leqn0 mxrank_eq0 -submx0 -(ker_irr_comp_op_pchar irrG) capmxS //. by rewrite irr_reprK_pchar capmxSl. apply: leq_trans (mxrankS _) (rank_leq_row (mxvec 1%:M)). apply/memmx_subP=> Ar; case/submxP=> a ->{Ar}. rewrite mulmxA mul_rV_lin /=; set A := vec_mx _. rewrite memmx1 (mx_abs_irr_cent_scalar absG) // -memmx_cent_envelop. apply/cent_mxP=> Br; rewrite -(irr_comp_envelop_pchar irrG) irr_reprK_pchar. case/submxP=> b /(canRL mxvecK) ->{Br}; rewrite mulmxA mx_rV_lin /=. set B := vec_mx _; have RiB: (B \in 'R_i)%MS by rewrite vec_mxK submxMl. have sRiR: ('R_i <= R_G)%MS by rewrite -Wedderburn_sum_pchar (sumsmx_sup i). have: (A \in 'Z('R_i))%MS by rewrite vec_mxK submxMl. rewrite sub_capmx => /andP[RiA /cent_mxP cRiA]. by rewrite -!gring_opM ?(memmx_subP sRiR) 1?cRiA. Qed. Lemma Wedderburn_center_pchar : ('Z(R_G) :=: \matrix_(i < #|sG|) mxvec 'e_(enum_val i))%MS. Proof. have:= mxdirect_sums_center Wedderburn_sum_pchar Wedderburn_direct Wedderburn_ideal. move/eqmx_trans; apply; apply/eqmxP/andP; split. apply/sumsmx_subP=> i _; rewrite Wedderburn_subring_center_pchar. by apply: (eq_row_sub (enum_rank i)); rewrite rowK enum_rankK. apply/row_subP=> i; rewrite rowK -Wedderburn_subring_center_pchar. by rewrite (sumsmx_sup (enum_val i)). Qed. Lemma card_irr_pchar : #|sG| = tG. Proof. rewrite -(eqnP classg_base_free) classg_base_center. have:= mxdirect_sums_center Wedderburn_sum_pchar Wedderburn_direct Wedderburn_ideal. move->; rewrite (mxdirectP _) /=; last first. apply/mxdirect_sumsP=> i _; apply/eqP; rewrite -submx0. rewrite -{2}(mxdirect_sumsP Wedderburn_direct i) // capmxS ?capmxSl //=. by apply/sumsmx_subP=> j neji; rewrite (sumsmx_sup j) ?capmxSl. rewrite -sum1_card; apply: eq_bigr => i _; apply/eqP. rewrite Wedderburn_subring_center_pchar eqn_leq rank_leq_row lt0n mxrank_eq0. by rewrite andbT mxvec_eq0; case: (Wedderburn_is_id_pchar i). Qed. Section CenterMode. Variable i : sG. Let i0 := Ordinal (irr_degree_gt0 i). Definition irr_mode x := irr_repr i x i0 i0. Lemma irr_mode1 : irr_mode 1 = 1. Proof. by rewrite /irr_mode repr_mx1 mxE eqxx. Qed. Lemma irr_center_scalar : {in 'Z(G), forall x, irr_repr i x = (irr_mode x)%:M}. Proof. rewrite /irr_mode => x /setIP[Gx cGx]. suffices [a ->]: exists a, irr_repr i x = a%:M by rewrite mxE eqxx. apply/is_scalar_mxP; apply: (mx_abs_irr_cent_scalar (splitG (socle_irr i))). by apply/centgmxP=> y Gy; rewrite -!{1}repr_mxM 1?(centP cGx). Qed. Lemma irr_modeM : {in 'Z(G) &, {morph irr_mode : x y / (x * y)%g >-> x * y}}. Proof. move=> x y Zx Zy; rewrite {1}/irr_mode repr_mxM ?(subsetP (center_sub G)) //. by rewrite !irr_center_scalar // -scalar_mxM mxE eqxx. Qed. Lemma irr_modeX n : {in 'Z(G), {morph irr_mode : x / (x ^+ n)%g >-> x ^+ n}}. Proof. elim: n => [|n IHn] x Zx; first exact: irr_mode1. by rewrite expgS irr_modeM ?groupX // exprS IHn. Qed. Lemma irr_mode_unit : {in 'Z(G), forall x, irr_mode x \is a GRing.unit}. Proof. move=> x Zx /=; have:= unitr1 F. by rewrite -irr_mode1 -(mulVg x) irr_modeM ?groupV // unitrM; case/andP=> _. Qed. Lemma irr_mode_neq0 : {in 'Z(G), forall x, irr_mode x != 0}. Proof. by move=> x /irr_mode_unit; rewrite unitfE. Qed. Lemma irr_modeV : {in 'Z(G), {morph irr_mode : x / (x^-1)%g >-> x^-1}}. Proof. move=> x Zx /=; rewrite -[_^-1]mul1r; apply: canRL (mulrK (irr_mode_unit Zx)) _. by rewrite -irr_modeM ?groupV // mulVg irr_mode1. Qed. End CenterMode. Lemma irr1_mode x : x \in G -> irr_mode 1 x = 1. Proof. by move=> Gx; rewrite /irr_mode irr1_repr ?mxE. Qed. End Regular. Local Notation "[ 1 sG ]" := (principal_comp sG) : irrType_scope. Section LinearIrr. Variables (gT : finGroupType) (G : {group gT}). Lemma card_linear_irr (sG : irrType G) : [pchar F]^'.-group G -> group_splitting_field G -> #|linear_irr sG| = #|G : G^`(1)|%g. Proof. move=> F'G splitG; apply/eqP. wlog sGq: / irrType (G / G^`(1))%G by apply: socle_exists. have [_ nG'G] := andP (der_normal 1 G); apply/eqP; rewrite -card_quotient //. have cGqGq: abelian (G / G^`(1))%g by apply: sub_der1_abelian. have F'Gq: [pchar F]^'.-group (G / G^`(1))%g by apply: morphim_pgroup. have splitGq: group_splitting_field (G / G^`(1))%G. exact: quotient_splitting_field. rewrite -(sum_irr_degree_pchar sGq) // -sum1_card. pose rG (j : sGq) := morphim_repr (socle_repr j) nG'G. have irrG j: mx_irreducible (rG j) by apply/morphim_mx_irr; apply: socle_irr. rewrite (reindex (fun j => irr_comp sG (rG j))) /=. apply: eq_big => [j | j _]; last by rewrite irr_degree_abelian. have [_ lin_j _ _] := rsim_irr_comp_pchar sG F'G (irrG j). by rewrite inE -lin_j -irr_degreeE irr_degree_abelian. pose sGlin := {i | i \in linear_irr sG}. have sG'k (i : sGlin) : G^`(1)%g \subset rker (irr_repr (val i)). by case: i => i /= /[!inE] lin; rewrite rker_linear //=; apply/eqP. pose h' u := irr_comp sGq (quo_repr (sG'k u) nG'G). have irrGq u: mx_irreducible (quo_repr (sG'k u) nG'G). by apply/quo_mx_irr; apply: socle_irr. exists (fun i => oapp h' [1 sGq]%irr (insub i)) => [j | i] lin_i. rewrite (insubT [in _] lin_i) /=; apply/esym/eqP/socle_rsimP. apply: mx_rsim_trans (rsim_irr_comp_pchar sGq F'Gq (irrGq _)). have [g lin_g inj_g hom_g] := rsim_irr_comp_pchar sG F'G (irrG j). exists g => [||G'x]; last 1 [case/morphimP=> x _ Gx ->] || by []. by rewrite quo_repr_coset ?hom_g. rewrite (insubT (mem _) lin_i) /=; apply/esym/eqP/socle_rsimP. set u := Sub i lin_i. apply: mx_rsim_trans (rsim_irr_comp_pchar sG F'G (irrG _)). have [g lin_g inj_g hom_g] := rsim_irr_comp_pchar sGq F'Gq (irrGq u). exists g => [||x Gx]; last 1 [have:= hom_g (coset _ x)] || by []. by rewrite quo_repr_coset; first by apply; rewrite mem_quotient. Qed. Lemma primitive_root_splitting_abelian (z : F) : #|G|.-primitive_root z -> abelian G -> group_splitting_field G. Proof. move=> ozG cGG [|n] rG irrG; first by case/mx_irrP: irrG. case: (pickP [pred x in G | ~~ is_scalar_mx (rG x)]) => [x | scalG]. case/andP=> Gx nscal_rGx; have: horner_mx (rG x) ('X^#|G| - 1) == 0. rewrite rmorphB rmorphXn /= horner_mx_C horner_mx_X. rewrite -repr_mxX ?inE // ((_ ^+ _ =P 1)%g _) ?repr_mx1 ?subrr //. by rewrite -order_dvdn order_dvdG. case/idPn; rewrite -mxrank_eq0 -(factor_Xn_sub_1 ozG). elim: #|G| => [|i IHi]; first by rewrite big_nil horner_mx_C mxrank1. rewrite big_nat_recr => [|//]; rewrite rmorphM mxrankMfree {IHi}//=. rewrite row_free_unit rmorphB /= horner_mx_X horner_mx_C. rewrite (mx_Schur irrG) ?subr_eq0 //; last first. by apply: contraNneq nscal_rGx => ->; apply: scalar_mx_is_scalar. rewrite -memmx_cent_envelop raddfB. rewrite addmx_sub ?eqmx_opp ?scalar_mx_cent //= memmx_cent_envelop. by apply/centgmxP=> j Zh_j; rewrite -!repr_mxM // (centsP cGG). pose M := <<delta_mx 0 0 : 'rV[F]_n.+1>>%MS. have linM: \rank M = 1 by rewrite genmxE mxrank_delta. have modM: mxmodule rG M. apply/mxmoduleP=> x Gx; move/idPn: (scalG x); rewrite /= Gx negbK. by case/is_scalar_mxP=> ? ->; rewrite scalar_mxC submxMl. apply: linear_mx_abs_irr; apply/eqP; rewrite eq_sym -linM. by case/mx_irrP: irrG => _; apply; rewrite // -mxrank_eq0 linM. Qed. Lemma cycle_repr_structure_pchar x (sG : irrType G) : G :=: <[x]> -> [pchar F]^'.-group G -> group_splitting_field G -> exists2 w : F, #|G|.-primitive_root w & exists iphi : 'I_#|G| -> sG, [/\ bijective iphi, #|sG| = #|G|, forall i, irr_mode (iphi i) x = w ^+ i & forall i, irr_repr (iphi i) x = (w ^+ i)%:M]. Proof. move=> defG; rewrite {defG}(group_inj defG) -/#[x] in sG * => F'X splitF. have Xx := cycle_id x; have cXX := cycle_abelian x. have card_sG: #|sG| = #[x]. by rewrite card_irr_pchar //; apply/eqP; rewrite -card_classes_abelian. have linX := irr_degree_abelian splitF cXX (_ : sG). pose r (W : sG) := irr_mode W x. have scalX W: irr_repr W x = (r W)%:M. by apply: irr_center_scalar; rewrite ?(center_idP _). have inj_r: injective r. move=> V W eqVW; rewrite -(irr_reprK_pchar F'X V) -(irr_reprK_pchar F'X W). move: (irr_repr V) (irr_repr W) (scalX V) (scalX W). rewrite !linX {}eqVW => rV rW <- rWx; apply: irr_comp_rsim_pchar => //. exists 1%:M; rewrite ?row_free_unit ?unitmx1 // => xk; case/cycleP=> k ->{xk}. by rewrite mulmx1 mul1mx !repr_mxX // rWx. have rx1 W: r W ^+ #[x] = 1. by rewrite -irr_modeX ?(center_idP _) // expg_order irr_mode1. have /hasP[w _ prim_w]: has #[x].-primitive_root (map r (enum sG)). rewrite has_prim_root 1?map_inj_uniq ?enum_uniq //; first 1 last. by rewrite size_map -cardE card_sG. by apply/allP=> _ /mapP[W _ ->]; rewrite unity_rootE rx1. have iphi'P := prim_rootP prim_w (rx1 _); pose iphi' := sval (iphi'P _). have def_r W: r W = w ^+ iphi' W by apply: svalP (iphi'P W). have inj_iphi': injective iphi'. by move=> i j eq_ij; apply: inj_r; rewrite !def_r eq_ij. have iphiP: codom iphi' =i 'I_#[x]. by apply/subset_cardP; rewrite ?subset_predT // card_ord card_image. pose iphi i := iinv (iphiP i); exists w => //; exists iphi. have iphiK: cancel iphi iphi' by move=> i; apply: f_iinv. have r_iphi i: r (iphi i) = w ^+ i by rewrite def_r iphiK. split=> // [|i]; last by rewrite scalX r_iphi. by exists iphi' => // W; rewrite /iphi iinv_f. Qed. Lemma splitting_cyclic_primitive_root_pchar : cyclic G -> [pchar F]^'.-group G -> group_splitting_field G -> classically {z : F | #|G|.-primitive_root z}. Proof. case/cyclicP=> x defG F'G splitF; case=> // IH. wlog sG: / irrType G by apply: socle_exists. have [w prim_w _] := cycle_repr_structure_pchar sG defG F'G splitF. by apply: IH; exists w. Qed. End LinearIrr. End FieldRepr. #[deprecated(since="mathcomp 2.4.0", note="Use mx_Maschke_pchar instead.")] Notation mx_Maschke := (mx_Maschke_pchar) (only parsing). #[deprecated(since="mathcomp 2.4.0", note="Use rsim_regular_submod_pchar instead.")] Notation rsim_regular_submod := (rsim_regular_submod_pchar) (only parsing). #[deprecated(since="mathcomp 2.4.0", note="Use irr_mx_sum_pchar instead.")] Notation irr_mx_sum := (irr_mx_sum_pchar) (only parsing). #[deprecated(since="mathcomp 2.4.0", note="Use Wedderburn_sum_pchar instead.")] Notation Wedderburn_sum := (Wedderburn_sum_pchar) (only parsing). #[deprecated(since="mathcomp 2.4.0", note="Use Wedderburn_sum_id_pchar instead.")] Notation Wedderburn_sum_id := (Wedderburn_sum_id_pchar) (only parsing). #[deprecated(since="mathcomp 2.4.0", note="Use Wedderburn_is_id_pchar instead.")] Notation Wedderburn_is_id:= (Wedderburn_is_id_pchar) (only parsing). #[deprecated(since="mathcomp 2.4.0", note="Use Wedderburn_closed_pchar instead.")] Notation Wedderburn_closed := (Wedderburn_closed_pchar) (only parsing). #[deprecated(since="mathcomp 2.4.0", note="Use Wedderburn_is_ring_pchar instead.")] Notation Wedderburn_is_ring := (Wedderburn_is_ring_pchar) (only parsing). #[deprecated(since="mathcomp 2.4.0", note="Use Wedderburn_min_ideal_pchar instead.")] Notation Wedderburn_min_ideal := (Wedderburn_min_ideal_pchar) (only parsing). #[deprecated(since="mathcomp 2.4.0", note="Use rsim_irr_comp_pchar instead.")] Notation rsim_irr_comp := (rsim_irr_comp_pchar) (only parsing). #[deprecated(since="mathcomp 2.4.0", note="Use irr_comp'_op0_pchar instead.")] Notation irr_comp'_op0 := (irr_comp'_op0_pchar) (only parsing). #[deprecated(since="mathcomp 2.4.0", note="Use irr_comp_envelop_pchar instead.")] Notation irr_comp_envelop := (irr_comp_envelop_pchar) (only parsing). #[deprecated(since="mathcomp 2.4.0", note="Use ker_irr_comp_op_pchar instead.")] Notation ker_irr_comp_op := (ker_irr_comp_op_pchar) (only parsing). #[deprecated(since="mathcomp 2.4.0", note="Use regular_op_inj_pchar instead.")] Notation regular_op_inj := (regular_op_inj_pchar) (only parsing). #[deprecated(since="mathcomp 2.4.0", note="Use rank_irr_comp_pchar instead.")] Notation rank_irr_comp := (rank_irr_comp_pchar) (only parsing). #[deprecated(since="mathcomp 2.4.0", note="Use irr_comp_rsim_pchar instead.")] Notation irr_comp_rsim := (irr_comp_rsim_pchar) (only parsing). #[deprecated(since="mathcomp 2.4.0", note="Use irr_reprK_pchar instead.")] Notation irr_reprK := (irr_reprK_pchar) (only parsing). #[deprecated(since="mathcomp 2.4.0", note="Use irr_repr'_op0_pchar instead.")] Notation irr_repr'_op0 := (irr_repr'_op0_pchar) (only parsing). #[deprecated(since="mathcomp 2.4.0", note="Use op_Wedderburn_id_pchar instead.")] Notation op_Wedderburn_id := (op_Wedderburn_id_pchar) (only parsing). #[deprecated(since="mathcomp 2.4.0", note="Use irr_comp_id_pchar instead.")] Notation irr_comp_id := (irr_comp_id_pchar) (only parsing). #[deprecated(since="mathcomp 2.4.0", note="Use rank_Wedderburn_subring_pchar instead.")] Notation rank_Wedderburn_subring := (rank_Wedderburn_subring_pchar) (only parsing). #[deprecated(since="mathcomp 2.4.0", note="Use sum_irr_degree_pchar instead.")] Notation sum_irr_degree := (sum_irr_degree_pchar) (only parsing). #[deprecated(since="mathcomp 2.4.0", note="Use irr_mx_mult_pchar instead.")] Notation irr_mx_mult := (irr_mx_mult_pchar) (only parsing). #[deprecated(since="mathcomp 2.4.0", note="Use mxtrace_regular_pchar instead.")] Notation mxtrace_regular := (mxtrace_regular_pchar) (only parsing). #[deprecated(since="mathcomp 2.4.0", note="Use linear_irr_comp_pchar instead.")] Notation linear_irr_comp := (linear_irr_comp_pchar) (only parsing). #[deprecated(since="mathcomp 2.4.0", note="Use Wedderburn_subring_center_pchar instead.")] Notation Wedderburn_subring_center := (Wedderburn_subring_center_pchar) (only parsing). #[deprecated(since="mathcomp 2.4.0", note="Use Wedderburn_center_pchar instead.")] Notation Wedderburn_center := (Wedderburn_center_pchar) (only parsing). #[deprecated(since="mathcomp 2.4.0", note="Use card_irr_pchar instead.")] Notation card_irr := (card_irr_pchar) (only parsing). #[deprecated(since="mathcomp 2.4.0", note="Use cycle_repr_structure_pchar instead.")] Notation cycle_repr_structure := (cycle_repr_structure_pchar) (only parsing). #[deprecated(since="mathcomp 2.4.0", note="Use splitting_cyclic_primitive_root_pchar instead.")] Notation splitting_cyclic_primitive_root := (splitting_cyclic_primitive_root_pchar) (only parsing). Arguments rfix_mx {F gT G%_g n%_N} rG H%_g. Arguments gset_mx F {gT} G%_g A%_g. Arguments classg_base F {gT} G%_g _%_g : extra scopes. Arguments irrType F {gT} G%_g. Arguments mxmoduleP {F gT G n rG m U}. Arguments envelop_mxP {F gT G n rG A}. Arguments hom_mxP {F gT G n rG m f W}. Arguments mx_Maschke_pchar [F gT G n] rG _ [U]. Arguments rfix_mxP {F gT G n rG m W}. Arguments cyclic_mxP {F gT G n rG u v}. Arguments annihilator_mxP {F gT G n rG u A}. Arguments row_hom_mxP {F gT G n rG u v}. Arguments mxsimple_isoP {F gT G n rG U V}. Arguments socle_exists [F gT G n]. Arguments socleP {F gT G n rG sG0 W W'}. Arguments mx_abs_irrP {F gT G n rG}. Arguments socle_rsimP {F gT G n rG sG W1 W2}. Arguments val_submod {F n U m} W. Arguments in_submod {F n} U {m} W. Arguments val_submodK {F n U m} W : rename. Arguments in_submodK {F n U m} [W] sWU. Arguments val_submod_inj {F n U m} [W1 W2] : rename. Arguments val_factmod {F n U m} W. Arguments in_factmod {F n} U {m} W. Arguments val_factmodK {F n U m} W : rename. Arguments in_factmodK {F n} U {m} [W] sWU. Arguments val_factmod_inj {F n U m} [W1 W2] : rename. Notation "'Cl" := (Clifford_action _) : action_scope. Arguments gring_row {R gT G} A. Arguments gring_rowK {F gT G} [A] RG_A. Bind Scope irrType_scope with socle_sort. Notation "[ 1 sG ]" := (principal_comp sG) : irrType_scope. Arguments irr_degree {F gT G%_G sG} i%_irr. Arguments irr_repr {F gT G%_G sG} i%_irr _%_g : extra scopes. Arguments irr_mode {F gT G%_G sG} i%_irr z%_g : rename. Notation "''n_' i" := (irr_degree i) : group_ring_scope. Notation "''R_' i" := (Wedderburn_subring i) : group_ring_scope. Notation "''e_' i" := (Wedderburn_id i) : group_ring_scope. Section DecideRed. Import MatrixFormula. Local Notation term := GRing.term. Local Notation True := GRing.True. Local Notation And := GRing.And (only parsing). Local Notation morphAnd f := ((big_morph f) true andb). Local Notation eval := GRing.eval. Local Notation holds := GRing.holds. Local Notation qf_form := GRing.qf_form. Local Notation qf_eval := GRing.qf_eval. Section Definitions. Variables (F : fieldType) (gT : finGroupType) (G : {group gT}) (n : nat). Variable rG : mx_representation F G n. Definition mxmodule_form (U : 'M[term F]_n) := \big[And/True]_(x in G) submx_form (mulmx_term U (mx_term (rG x))) U. Lemma mxmodule_form_qf U : qf_form (mxmodule_form U). Proof. by rewrite (morphAnd (@qf_form _)) ?big1 //= => x _; rewrite submx_form_qf. Qed. Lemma eval_mxmodule U e : qf_eval e (mxmodule_form U) = mxmodule rG (eval_mx e U). Proof. rewrite (morphAnd (qf_eval e)) //= big_andE /=. apply/forallP/mxmoduleP=> Umod x; move/implyP: (Umod x); by rewrite eval_submx eval_mulmx eval_mx_term. Qed. Definition mxnonsimple_form (U : 'M[term F]_n) := let V := vec_mx (row_var F (n * n) 0) in let nzV := (~ mxrank_form 0 V)%T in let properVU := (submx_form V U /\ ~ submx_form U V)%T in (Exists_row_form (n * n) 0 (mxmodule_form V /\ nzV /\ properVU))%T. End Definitions. Variables (F : decFieldType) (gT : finGroupType) (G : {group gT}) (n : nat). Variable rG : mx_representation F G n. Definition mxnonsimple_sat U := GRing.sat (@row_env _ (n * n) [::]) (mxnonsimple_form rG (mx_term U)). Lemma mxnonsimpleP U : U != 0 -> reflect (mxnonsimple rG U) (mxnonsimple_sat U). Proof. rewrite /mxnonsimple_sat {1}/mxnonsimple_form; set Vt := vec_mx _ => /= nzU. pose nsim V := [&& mxmodule rG V, (V <= U)%MS, V != 0 & \rank V < \rank U]. set nsimUt := (_ /\ _)%T; have: qf_form nsimUt. by rewrite /= mxmodule_form_qf !mxrank_form_qf !submx_form_qf. move/GRing.qf_evalP; set qev := @GRing.qf_eval _ => qevP. have qev_nsim u: qev (row_env [:: u]) nsimUt = nsim n (vec_mx u). rewrite /nsim -mxrank_eq0 /qev /= eval_mxmodule eval_mxrank. rewrite !eval_submx eval_mx_term eval_vec_mx eval_row_var /=. do 2!bool_congr; apply: andb_id2l => sUV. by rewrite ltn_neqAle andbC !mxrank_leqif_sup. have n2gt0: n ^ 2 > 0. by move: nzU; rewrite muln_gt0 -mxrank_eq0 unlock; case: posnP (U) => // ->. apply: (iffP satP) => [|[V nsimV]]. by case/Exists_rowP=> // v; move/qevP; rewrite qev_nsim; exists (vec_mx v). apply/Exists_rowP=> //; exists (mxvec V); apply/qevP. by rewrite qev_nsim mxvecK. Qed. Lemma dec_mxsimple_exists (U : 'M_n) : mxmodule rG U -> U != 0 -> {V | mxsimple rG V & V <= U}%MS. Proof. have [m] := ubnP (\rank U); elim: m U => // m IHm U leUm modU nzU. have [nsimU | simU] := mxnonsimpleP nzU; last first. by exists U; first apply/mxsimpleP. move: (xchooseP nsimU); move: (xchoose _) => W /and4P[modW sWU nzW ltWU]. case: (IHm W) => // [|V simV sVW]; first exact: leq_trans ltWU _. by exists V; last apply: submx_trans sVW sWU. Qed. Lemma dec_mx_reducible_semisimple U : mxmodule rG U -> mx_completely_reducible rG U -> mxsemisimple rG U. Proof. have [m] := ubnP (\rank U); elim: m U => // m IHm U leUm modU redU. have [U0 | nzU] := eqVneq U 0. have{} U0: (\sum_(i < 0) 0 :=: U)%MS by rewrite big_ord0 U0. by apply: (intro_mxsemisimple U0); case. have [V simV sVU] := dec_mxsimple_exists modU nzU; have [modV nzV _] := simV. have [W modW defVW dxVW] := redU V modV sVU. have [||I W_ /= simW defW _] := IHm W _ modW. - rewrite ltnS in leUm; apply: leq_trans leUm. by rewrite -defVW (mxdirectP dxVW) /= -add1n leq_add2r lt0n mxrank_eq0. - by apply: mx_reducibleS redU; rewrite // -defVW addsmxSr. suffices defU: (\sum_i oapp W_ V i :=: U)%MS. by apply: (intro_mxsemisimple defU) => [] [|i] //=. apply: eqmx_trans defVW; rewrite (bigD1 None) //=; apply/eqmxP. have [i0 _ | I0] := pickP I. by rewrite (reindex some) ?addsmxS ?defW //; exists (odflt i0) => //; case. rewrite big_pred0 //; last by case=> // /I0. by rewrite !addsmxS ?sub0mx // -defW big_pred0. Qed. Lemma DecSocleType : socleType rG. Proof. have [n0 | n_gt0] := posnP n. by exists [::] => // M [_]; rewrite -mxrank_eq0 -leqn0 -n0 rank_leq_row. have n2_gt0: n ^ 2 > 0 by rewrite muln_gt0 n_gt0. pose span Ms := (\sum_(M <- Ms) component_mx rG M)%MS. have: {in [::], forall M, mxsimple rG M} by []. have [m] := ubnP (n - \rank (span [::])). elim: m [::] => // m IHm Ms /ltnSE-Ms_ge_n simMs. pose V := span Ms; pose Vt := mx_term V. pose Ut i := vec_mx (row_var F (n * n) i); pose Zt := mx_term (0 : 'M[F]_n). pose exU i f := Exists_row_form (n * n) i (~ submx_form (Ut i) Zt /\ f (Ut i)). pose meetUVf U := exU 1 (fun W => submx_form W Vt /\ submx_form W U)%T. pose mx_sat := GRing.sat (@row_env F (n * n) [::]). have ev_sub0 := GRing.qf_evalP _ (submx_form_qf _ Zt). have ev_mod := GRing.qf_evalP _ (mxmodule_form_qf rG _). pose ev := (eval_mxmodule, eval_submx, eval_vec_mx, eval_row_var, eval_mx_term). case haveU: (mx_sat (exU 0 (fun U => mxmodule_form rG U /\ ~ meetUVf _ U)%T)). have [U modU]: {U : 'M_n | mxmodule rG U & (U != 0) && ((U :&: V)%MS == 0)}. apply: sig2W; case/Exists_rowP: (satP haveU) => //= u [nzU [modU tiUV]]. exists (vec_mx u); first by move/ev_mod: modU; rewrite !ev. set W := (_ :&: V)%MS; move/ev_sub0: nzU; rewrite !ev -!submx0 => -> /=. apply/idPn=> nzW; case: tiUV; apply/Exists_rowP=> //; exists (mxvec W). apply/GRing.qf_evalP; rewrite /= ?submx_form_qf // !ev mxvecK nzW /=. by rewrite andbC -sub_capmx. case/andP=> nzU tiUV; have [M simM sMU] := dec_mxsimple_exists modU nzU. apply: (IHm (M :: Ms)) => [|M']; last first. by case/predU1P=> [-> //|]; apply: simMs. have [_ nzM _] := simM. suffices ltVMV: \rank V < \rank (span (M :: Ms)). rewrite (leq_trans _ Ms_ge_n) // ltn_sub2l ?(leq_trans ltVMV) //. exact: rank_leq_row. rewrite /span big_cons (ltn_leqif (mxrank_leqif_sup (addsmxSr _ _))). apply: contra nzM; rewrite addsmx_sub -submx0 -(eqP tiUV) sub_capmx sMU. by case/andP=> sMV _; rewrite (submx_trans _ sMV) ?component_mx_id. exists Ms => // M simM; have [modM nzM minM] := simM. have sMV: (M <= V)%MS. apply: contraFT haveU => not_sMV; apply/satP/Exists_rowP=> //. exists (mxvec M); split; first by apply/ev_sub0; rewrite !ev mxvecK submx0. split; first by apply/ev_mod; rewrite !ev mxvecK. apply/Exists_rowP=> // [[w]]. apply/GRing.qf_evalP; rewrite /= ?submx_form_qf // !ev /= mxvecK submx0. rewrite -nz_row_eq0 -(cyclic_mx_eq0 rG); set W := cyclic_mx _ _. apply: contra not_sMV => /and3P[nzW Vw Mw]. have{Vw Mw} [sWV sWM]: (W <= V /\ W <= M)%MS. rewrite !cyclic_mx_sub ?(submx_trans (nz_row_sub _)) //. by rewrite sumsmx_module // => M' _; apply: component_mx_module. by rewrite (submx_trans _ sWV) // minM ?cyclic_mx_module. wlog sG: / socleType rG by apply: socle_exists. have sVS: (V <= \sum_(W : sG | has (fun Mi => Mi <= W) Ms) W)%MS. rewrite [V](big_nth 0) big_mkord; apply/sumsmx_subP=> i _. set Mi := Ms`_i; have MsMi: Mi \in Ms by apply: mem_nth. have simMi := simMs _ MsMi; have S_Mi := component_socle sG simMi. rewrite (sumsmx_sup (PackSocle S_Mi)) ?PackSocleK //. by apply/hasP; exists Mi; rewrite ?component_mx_id. have [W MsW isoWM] := subSocle_iso simM (submx_trans sMV sVS). have [Mi MsMi sMiW] := hasP MsW; apply/hasP; exists Mi => //. have [simMi simW] := (simMs _ MsMi, socle_simple W); apply/mxsimple_isoP=> //. exact: mx_iso_trans (mx_iso_sym isoWM) (component_mx_iso simW simMi sMiW). Qed. End DecideRed. Prenex Implicits mxmodule_form mxnonsimple_form mxnonsimple_sat. (* Change of representation field (by tensoring) *) Section ChangeOfField. Variables (aF rF : fieldType) (f : {rmorphism aF -> rF}). Local Notation "A ^f" := (map_mx (GRing.RMorphism.sort f) A) : ring_scope. Variables (gT : finGroupType) (G : {group gT}). Section OneRepresentation. Variables (n : nat) (rG : mx_representation aF G n). Local Notation rGf := (map_repr f rG). Lemma map_rfix_mx H : (rfix_mx rG H)^f = rfix_mx rGf H. Proof. rewrite map_kermx //; congr (kermx _); apply: map_lin1_mx => //= v. rewrite map_mxvec map_mxM; congr (mxvec (_ *m _)); last first. by apply: map_lin1_mx => //= u; rewrite map_mxM map_vec_mx. by apply/row_matrixP=> i; rewrite -map_row !rowK map_mxvec map_mxB map_mx1. Qed. Lemma rcent_map A : rcent rGf A^f = rcent rG A. Proof. by apply/setP=> x; rewrite !inE -!map_mxM inj_eq //; apply: map_mx_inj. Qed. Lemma rstab_map m (U : 'M_(m, n)) : rstab rGf U^f = rstab rG U. Proof. by apply/setP=> x; rewrite !inE -!map_mxM inj_eq //; apply: map_mx_inj. Qed. Lemma rstabs_map m (U : 'M_(m, n)) : rstabs rGf U^f = rstabs rG U. Proof. by apply/setP=> x; rewrite !inE -!map_mxM ?map_submx. Qed. Lemma centgmx_map A : centgmx rGf A^f = centgmx rG A. Proof. by rewrite /centgmx rcent_map. Qed. Lemma mxmodule_map m (U : 'M_(m, n)) : mxmodule rGf U^f = mxmodule rG U. Proof. by rewrite /mxmodule rstabs_map. Qed. Lemma mxsimple_map (U : 'M_n) : mxsimple rGf U^f -> mxsimple rG U. Proof. case; rewrite map_mx_eq0 // mxmodule_map // => modU nzU minU. split=> // V modV sVU nzV; rewrite -(map_submx f). by rewrite (minU V^f) //= ?mxmodule_map ?map_mx_eq0 // map_submx. Qed. Lemma mx_irr_map : mx_irreducible rGf -> mx_irreducible rG. Proof. by move=> irrGf; apply: mxsimple_map; rewrite map_mx1. Qed. Lemma rker_map : rker rGf = rker rG. Proof. by rewrite /rker -rstab_map map_mx1. Qed. Lemma map_mx_faithful : mx_faithful rGf = mx_faithful rG. Proof. by rewrite /mx_faithful rker_map. Qed. Lemma map_mx_abs_irr : mx_absolutely_irreducible rGf = mx_absolutely_irreducible rG. Proof. by rewrite /mx_absolutely_irreducible -map_enveloping_algebra_mx row_full_map. Qed. End OneRepresentation. Lemma mx_rsim_map n1 n2 rG1 rG2 : @mx_rsim _ _ G n1 rG1 n2 rG2 -> mx_rsim (map_repr f rG1) (map_repr f rG2). Proof. case=> g eqn12 inj_g hom_g. by exists g^f => // [|x Gx]; rewrite ?row_free_map // -!map_mxM ?hom_g. Qed. Lemma map_section_repr n (rG : mx_representation aF G n) rGf U V (modU : mxmodule rG U) (modV : mxmodule rG V) (modUf : mxmodule rGf U^f) (modVf : mxmodule rGf V^f) : map_repr f rG =1 rGf -> mx_rsim (map_repr f (section_repr modU modV)) (section_repr modUf modVf). Proof. move=> def_rGf; set VU := <<_>>%MS. pose valUV := val_factmod (val_submod (1%:M : 'M[aF]_(\rank VU))). have sUV_Uf: (valUV^f <= U^f + V^f)%MS. rewrite -map_addsmx map_submx; apply: submx_trans (proj_factmodS _ _). by rewrite val_factmodS val_submod1 genmxE. exists (in_submod _ (in_factmod U^f valUV^f)) => [||x Gx]. - rewrite !genmxE -(mxrank_map f) map_mxM map_col_base. by case: (\rank (cokermx U)) / (mxrank_map _ _); rewrite map_cokermx. - rewrite -kermx_eq0 -submx0; apply/rV_subP=> u. rewrite (sameP sub_kermxP eqP) submx0 -val_submod_eq0. rewrite val_submodE -mulmxA -val_submodE in_submodK; last first. by rewrite genmxE -(in_factmod_addsK _ V^f) submxMr. rewrite in_factmodE mulmxA -in_factmodE in_factmod_eq0. move/(submxMr (in_factmod U 1%:M *m in_submod VU 1%:M)^f). rewrite -mulmxA -!map_mxM //; do 2!rewrite mulmxA -in_factmodE -in_submodE. rewrite val_factmodK val_submodK map_mx1 mulmx1. have ->: in_factmod U U = 0 by apply/eqP; rewrite in_factmod_eq0. by rewrite linear0 map_mx0 eqmx0 submx0. rewrite {1}in_submodE mulmxA -in_submodE -in_submodJ; last first. by rewrite genmxE -(in_factmod_addsK _ V^f) submxMr. congr (in_submod _ _); rewrite -in_factmodJ // in_factmodE mulmxA -in_factmodE. apply/eqP; rewrite -subr_eq0 -def_rGf -!map_mxM -linearB in_factmod_eq0. rewrite -map_mxB map_submx -in_factmod_eq0 linearB. rewrite /= (in_factmodJ modU) // val_factmodK. rewrite [valUV]val_factmodE mulmxA -val_factmodE val_factmodK. rewrite -val_submodE in_submodK ?subrr //. by rewrite mxmodule_trans ?section_module // val_submod1. Qed. Lemma map_regular_subseries U i (modU : mx_subseries (regular_repr aF G) U) (modUf : mx_subseries (regular_repr rF G) [seq M^f | M <- U]) : mx_rsim (map_repr f (subseries_repr i modU)) (subseries_repr i modUf). Proof. set mf := map _ in modUf *; rewrite /subseries_repr. do 2!move: (mx_subseries_module' _ _) (mx_subseries_module _ _). have mf_i V: nth 0^f (mf V) i = (V`_i)^f. case: (ltnP i (size V)) => [ltiV | leVi]; first exact: nth_map. by rewrite !nth_default ?size_map. rewrite -(map_mx0 f) mf_i (mf_i (0 :: U)) => modUi'f modUif modUi' modUi. by apply: map_section_repr; apply: map_regular_repr. Qed. Lemma extend_group_splitting_field : group_splitting_field aF G -> group_splitting_field rF G. Proof. move=> splitG n rG irrG. have modU0: all ((mxmodule (regular_repr aF G)) #|G|) [::] by []. apply: (mx_Schreier modU0 _) => // [[U [compU lastU _]]]; have [modU _]:= compU. pose Uf := map (map_mx f) U. have{lastU} lastUf: (last 0 Uf :=: 1%:M)%MS. by rewrite -(map_mx0 f) -(map_mx1 f) last_map; apply/map_eqmx. have modUf: mx_subseries (regular_repr rF G) Uf. rewrite /mx_subseries all_map; apply: etrans modU; apply: eq_all => Ui /=. rewrite -mxmodule_map; apply: eq_subset_r => x. by rewrite !inE map_regular_repr. have absUf i: i < size U -> mx_absolutely_irreducible (subseries_repr i modUf). move=> lt_i_U; rewrite -(mx_rsim_abs_irr (map_regular_subseries i modU _)). rewrite map_mx_abs_irr; apply: splitG. by apply: mx_rsim_irr (mx_series_repr_irr compU lt_i_U); apply: section_eqmx. have compUf: mx_composition_series (regular_repr rF G) Uf. split=> // i; rewrite size_map => ltiU. move/max_submodP: (mx_abs_irrW (absUf i ltiU)); apply. rewrite -{2}(map_mx0 f) -map_cons !(nth_map 0) ?leqW //. by rewrite map_submx // ltmxW // (pathP _ (mx_series_lt compU)). have [[i ltiU] simUi] := rsim_regular_series irrG compUf lastUf. have{} simUi: mx_rsim rG (subseries_repr i modUf). by apply: mx_rsim_trans simUi _; apply: section_eqmx. by rewrite (mx_rsim_abs_irr simUi) absUf; rewrite size_map in ltiU. Qed. End ChangeOfField. (* Construction of a splitting field FA of an irreducible representation, for *) (* a matrix A in the centraliser of the representation. FA is the row-vector *) (* space of the matrix algebra generated by A with basis 1, A, ..., A ^+ d.-1 *) (* or, equivalently, the polynomials in {poly F} taken mod the (irreducible) *) (* minimal polynomial pA of A (of degree d). *) (* The details of the construction of FA are encapsulated in a submodule. *) Module Import MatrixGenField. (* The type definition must come before the main section so that the Bind *) (* Scope directive applies to all lemmas and definition discharged at the *) (* of the section. *) Record gen_of {F : fieldType} {gT : finGroupType} {G : {group gT}} {n' : nat} {rG : mx_representation F G n'.+1} {A : 'M[F]_n'.+1} (irrG : mx_irreducible rG) (cGA : centgmx rG A) := Gen {rVval : 'rV[F]_(degree_mxminpoly A)}. Local Arguments rVval {F gT G%_G n'%_N rG A%_R irrG cGA} x%_R : rename. Bind Scope ring_scope with gen_of. Section GenField. Variables (F : fieldType) (gT : finGroupType) (G : {group gT}) (n' : nat). Local Notation n := n'.+1. Variables (rG : mx_representation F G n) (A : 'M[F]_n). Local Notation d := (degree_mxminpoly A). Local Notation Ad := (powers_mx A d). Local Notation pA := (mxminpoly A). Let d_gt0 := mxminpoly_nonconstant A. Local Notation irr := mx_irreducible. Hypotheses (irrG : irr rG) (cGA : centgmx rG A). Notation FA := (gen_of irrG cGA). Let inFA := Gen irrG cGA. #[export, hnf] HB.instance Definition _ := [isNew for rVval : FA -> 'rV_d]. #[export] HB.instance Definition _ := [Choice of FA by <:]. Definition gen0 := inFA 0. Definition genN (x : FA) := inFA (- val x). Definition genD (x y : FA) := inFA (val x + val y). Lemma gen_addA : associative genD. Proof. by move=> x y z; apply: val_inj; rewrite /= addrA. Qed. Lemma gen_addC : commutative genD. Proof. by move=> x y; apply: val_inj; rewrite /= addrC. Qed. Lemma gen_add0r : left_id gen0 genD. Proof. by move=> x; apply: val_inj; rewrite /= add0r. Qed. Lemma gen_addNr : left_inverse gen0 genN genD. Proof. by move=> x; apply: val_inj; rewrite /= addNr. Qed. #[export] HB.instance Definition _ := GRing.isZmodule.Build FA gen_addA gen_addC gen_add0r gen_addNr. Definition pval (x : FA) := rVpoly (val x). Definition mxval (x : FA) := horner_mx A (pval x). Definition gen (x : F) := inFA (poly_rV x%:P). Lemma genK x : mxval (gen x) = x%:M. Proof. by rewrite /mxval [pval _]poly_rV_K ?horner_mx_C // size_polyC; case: (x != 0). Qed. Lemma mxval_inj : injective mxval. Proof. exact: inj_comp horner_rVpoly_inj val_inj. Qed. Lemma mxval0 : mxval 0 = 0. Proof. by rewrite /mxval [pval _]raddf0 rmorph0. Qed. Lemma mxvalN : {morph mxval : x / - x}. Proof. by move=> x; rewrite /mxval [pval _](@raddfN 'rV[F]_d) rmorphN. Qed. Lemma mxvalD : {morph mxval : x y / x + y}. Proof. by move=> x y; rewrite /mxval [pval _]raddfD rmorphD. Qed. Definition mxval_sum := big_morph mxval mxvalD mxval0. Definition gen1 := inFA (poly_rV 1). Definition genM x y := inFA (poly_rV (pval x * pval y %% pA)). Definition genV x := inFA (poly_rV (mx_inv_horner A (mxval x)^-1)). Lemma mxval_gen1 : mxval gen1 = 1%:M. Proof. by rewrite /mxval [pval _]poly_rV_K ?size_poly1 // horner_mx_C. Qed. Lemma mxval_genM : {morph mxval : x y / genM x y >-> x *m y}. Proof. move=> x y; rewrite /mxval [pval _]poly_rV_K ?size_mod_mxminpoly //. by rewrite -horner_mxK mx_inv_hornerK ?horner_mx_mem // rmorphM. Qed. Lemma mxval_genV : {morph mxval : x / genV x >-> invmx x}. Proof. move=> x; rewrite /mxval [pval _]poly_rV_K ?size_poly ?mx_inv_hornerK //. pose m B : 'M[F]_(n * n) := lin_mx (mulmxr B); set B := mxval x. case uB: (B \is a GRing.unit); last by rewrite invr_out ?uB ?horner_mx_mem. have defAd: Ad = Ad *m m B *m m B^-1. apply/row_matrixP=> i. by rewrite !row_mul mul_rV_lin /= mx_rV_lin /= mulmxK ?vec_mxK. rewrite -[B^-1]mul1mx -(mul_vec_lin (mulmxr B^-1)) defAd submxMr //. rewrite -mxval_gen1 (submx_trans (horner_mx_mem _ _)) // {1}defAd. rewrite -(geq_leqif (mxrank_leqif_sup _)) ?mxrankM_maxl // -{}defAd. apply/row_subP=> i; rewrite row_mul rowK mul_vec_lin /= -{2}[A]horner_mx_X. by rewrite -rmorphXn mulmxE -rmorphM horner_mx_mem. Qed. Lemma gen_mulA : associative genM. Proof. by move=> x y z; apply: mxval_inj; rewrite !mxval_genM mulmxA. Qed. Lemma gen_mulC : commutative genM. Proof. by move=> x y; rewrite /genM mulrC. Qed. Lemma gen_mul1r : left_id gen1 genM. Proof. by move=> x; apply: mxval_inj; rewrite mxval_genM mxval_gen1 mul1mx. Qed. Lemma gen_mulDr : left_distributive genM +%R. Proof. by move=> x y z; apply: mxval_inj; rewrite !(mxvalD, mxval_genM) mulmxDl. Qed. Lemma gen_ntriv : gen1 != 0. Proof. by rewrite -(inj_eq mxval_inj) mxval_gen1 mxval0 oner_eq0. Qed. #[export] HB.instance Definition _ := GRing.Zmodule_isComNzRing.Build FA gen_mulA gen_mulC gen_mul1r gen_mulDr gen_ntriv. Lemma mxval1 : mxval 1 = 1%:M. Proof. exact: mxval_gen1. Qed. Lemma mxvalM : {morph mxval : x y / x * y >-> x *m y}. Proof. exact: mxval_genM. Qed. Lemma mxval_is_zmod_morphism : zmod_morphism mxval. Proof. by move=> x y; rewrite mxvalD mxvalN. Qed. #[warning="-deprecated-since-mathcomp-2.5.0", deprecated(since="mathcomp 2.5.0", note="use `mxval_is_zmod_morphism` instead")] Definition mxval_sub := mxval_is_zmod_morphism. #[export] HB.instance Definition _ := GRing.isZmodMorphism.Build FA 'M[F]_n mxval mxval_is_zmod_morphism. Lemma mxval_is_monoid_morphism : monoid_morphism mxval. Proof. by split; [apply: mxval1 | apply: mxvalM]. Qed. #[warning="-deprecated-since-mathcomp-2.5.0", deprecated(since="mathcomp 2.5.0", note="use `mxval_is_monoid_morphism` instead")] Definition mxval_is_multiplicative := (fun g => (g.2,g.1)) mxval_is_monoid_morphism. #[export] HB.instance Definition _ := GRing.isMonoidMorphism.Build FA 'M[F]_n mxval mxval_is_monoid_morphism. Lemma mxval_centg x : centgmx rG (mxval x). Proof. rewrite [mxval _]horner_rVpoly -memmx_cent_envelop vec_mxK {x}mulmx_sub //. apply/row_subP=> k; rewrite rowK memmx_cent_envelop; apply/centgmxP => g Gg /=. by rewrite !mulmxE commrX // /GRing.comm -mulmxE (centgmxP cGA). Qed. Lemma gen_mulVr x : x != 0 -> genV x * x = 1. Proof. rewrite -(inj_eq mxval_inj) mxval0. move/(mx_Schur irrG (mxval_centg x)) => u_x. by apply: mxval_inj; rewrite mxvalM mxval_genV mxval1 mulVmx. Qed. Lemma gen_invr0 : genV 0 = 0. Proof. by apply: mxval_inj; rewrite mxval_genV !mxval0 -{2}invr0. Qed. #[export] HB.instance Definition _ := GRing.ComNzRing_isField.Build FA gen_mulVr gen_invr0. Lemma mxvalV : {morph mxval : x / x^-1 >-> invmx x}. Proof. exact: mxval_genV. Qed. Lemma gen_is_zmod_morphism : zmod_morphism gen. Proof. by move=> x y; apply: mxval_inj; rewrite genK !rmorphB /= !genK. Qed. #[warning="-deprecated-since-mathcomp-2.5.0", deprecated(since="mathcomp 2.5.0", note="use `gen_is_zmod_morphism` instead")] Definition gen_is_additive := gen_is_zmod_morphism. Lemma gen_is_monoid_morphism : monoid_morphism gen. Proof. by split=> // x y; apply: mxval_inj; rewrite genK !rmorphM /= !genK. Qed. #[warning="-deprecated-since-mathcomp-2.5.0", deprecated(since="mathcomp 2.5.0", note="use `gen_is_monoid_morphism` instead")] Definition gen_is_multiplicative := (fun g => (g.2,g.1)) gen_is_monoid_morphism. #[export] HB.instance Definition _ := GRing.isZmodMorphism.Build F FA gen gen_is_zmod_morphism. #[export] HB.instance Definition _ := GRing.isMonoidMorphism.Build F FA gen gen_is_monoid_morphism. (* The generated field contains a root of the minimal polynomial (in some *) (* cases we want to use the construction solely for that purpose). *) Definition groot := inFA (poly_rV ('X %% pA)). Lemma mxval_groot : mxval groot = A. Proof. rewrite /mxval [pval _]poly_rV_K ?size_mod_mxminpoly // -horner_mxK. by rewrite mx_inv_hornerK ?horner_mx_mem // horner_mx_X. Qed. Lemma mxval_grootXn k : mxval (groot ^+ k) = A ^+ k. Proof. by rewrite rmorphXn /= mxval_groot. Qed. Lemma map_mxminpoly_groot : (map_poly gen pA).[groot] = 0. Proof. (* The [_ groot] prevents divergence of simpl. *) apply: mxval_inj; rewrite -horner_map [_ groot]/= mxval_groot mxval0. rewrite -(mx_root_minpoly A); congr ((_ : {poly _}).[A]). by apply/polyP=> i; rewrite 3!coef_map; apply: genK. Qed. (* Plugging the extension morphism gen into the ext_repr construction *) (* yields a (reducible) tensored representation. *) Lemma non_linear_gen_reducible : d > 1 -> mxnonsimple (map_repr gen rG) 1%:M. Proof. rewrite ltnNge mxminpoly_linear_is_scalar => Anscal. pose Af := map_mx gen A; exists (kermx (Af - groot%:M)). rewrite submx1 kermx_centg_module /=; last first. apply/centgmxP=> z Gz; rewrite mulmxBl [RHS]mulmxBr [in RHS]scalar_mxC. by rewrite -!map_mxM 1?(centgmxP cGA). rewrite andbC mxrank_ker -subn_gt0 mxrank1 subKn ?rank_leq_row // lt0n. rewrite mxrank_eq0 subr_eq0; case: eqP => [defAf | _]. rewrite -(map_mx_is_scalar gen) -/Af in Anscal. by case/is_scalar_mxP: Anscal; exists groot. rewrite -mxrank_eq0 mxrank_ker subn_eq0 row_leq_rank. apply/row_freeP=> [[XA' XAK]]. have pAf0: (mxminpoly Af).[groot] == 0. by rewrite mxminpoly_map ?map_mxminpoly_groot. have{pAf0} [q def_pAf]:= factor_theorem _ _ pAf0. have q_nz: q != 0. case: eqP (congr1 (fun p : {poly _} => size p) def_pAf) => // ->. by rewrite size_mxminpoly mul0r size_poly0. have qAf0: horner_mx Af q = 0. rewrite -[_ q]mulr1 -[1]XAK mulrA -{2}(horner_mx_X Af) -(horner_mx_C Af). by rewrite -rmorphB -rmorphM -def_pAf /= mx_root_minpoly mul0r. have{qAf0} := dvdp_leq q_nz (mxminpoly_min qAf0); rewrite def_pAf. by rewrite size_Mmonic ?monicXsubC // polyseqXsubC addn2 ltnn. Qed. (* An alternative to the above, used in the proof of the p-stability of *) (* groups of odd order, is to reconsider the original vector space as a *) (* vector space of dimension n / e over FA. This is applicable only if G is *) (* the largest group represented on the original vector space (i.e., if we *) (* are not studying a representation of G induced by one of a larger group, *) (* as in B & G Theorem 2.6 for instance). We can't fully exploit one of the *) (* benefits of this approach -- that the type domain for the vector space can *) (* remain unchanged -- because we're restricting ourselves to row matrices; *) (* we have to use explicit bijections to convert between the two views. *) Definition subbase nA (B : 'rV_nA) : 'M_(nA * d, n) := \matrix_ik mxvec (\matrix_(i, k) (row (B 0 i) (A ^+ k))) 0 ik. Lemma gen_dim_ex_proof : exists nA, [exists B : 'rV_nA, row_free (subbase B)]. Proof. by exists 0; apply/existsP; exists 0; rewrite /row_free unlock. Qed. Lemma gen_dim_ub_proof nA : [exists B : 'rV_nA, row_free (subbase B)] -> (nA <= n)%N. Proof. case/existsP=> B /eqnP def_nAd. by rewrite (leq_trans _ (rank_leq_col (subbase B))) // def_nAd leq_pmulr. Qed. Definition gen_dim := ex_maxn gen_dim_ex_proof gen_dim_ub_proof. Notation nA := gen_dim. Definition gen_base : 'rV_nA := odflt 0 [pick B | row_free (subbase B)]. Definition base := subbase gen_base. Lemma base_free : row_free base. Proof. rewrite /base /gen_base /nA; case: pickP => //; case: ex_maxnP => nA_max. by case/existsP=> B Bfree _ no_free; rewrite no_free in Bfree. Qed. Lemma base_full : row_full base. Proof. rewrite /row_full (eqnP base_free) /nA; case: ex_maxnP => nA. case/existsP=> /= B /eqnP Bfree nA_max; rewrite -Bfree eqn_leq rank_leq_col. rewrite -{1}(mxrank1 F n) mxrankS //; apply/row_subP=> j; set u := row _ _. move/implyP: {nA_max}(nA_max nA.+1); rewrite ltnn implybF. apply: contraR => nBj; apply/existsP. exists (row_mx (const_mx j : 'M_1) B); rewrite -row_leq_rank. pose Bj := Ad *m lin1_mx (mulmx u \o vec_mx). have rBj: \rank Bj = d. apply/eqP; rewrite eqn_leq rank_leq_row -subn_eq0 -mxrank_ker mxrank_eq0 /=. apply/rowV0P=> v /sub_kermxP; rewrite mulmxA mul_rV_lin1 /=. rewrite -horner_rVpoly; pose x := inFA v; rewrite -/(mxval x). have [[] // | nzx /(congr1 (mulmx^~ (mxval x^-1)))] := eqVneq x 0. rewrite mul0mx /= -mulmxA -mxvalM divff // mxval1 mulmx1. by move/rowP/(_ j)/eqP; rewrite !mxE !eqxx oner_eq0. rewrite {1}mulSn -Bfree -{1}rBj {rBj} -mxrank_disjoint_sum. rewrite mxrankS // addsmx_sub -[nA.+1]/(1 + nA)%N; apply/andP; split. apply/row_subP=> k; rewrite row_mul mul_rV_lin1 /=. apply: eq_row_sub (mxvec_index (lshift _ 0) k) _. by rewrite !rowK mxvecK mxvecE mxE row_mxEl mxE -row_mul mul1mx. apply/row_subP; case/mxvec_indexP=> i k. apply: eq_row_sub (mxvec_index (rshift 1 i) k) _. by rewrite !rowK !mxvecE 2!mxE row_mxEr. apply/eqP/rowV0P=> v; rewrite sub_capmx => /andP[/submxP[w]]. set x := inFA w; rewrite {Bj}mulmxA mul_rV_lin1 /= -horner_rVpoly -/(mxval x). have [-> | nzx ->] := eqVneq x 0; first by rewrite mxval0 mulmx0. move/(submxMr (mxval x^-1)); rewrite -mulmxA -mxvalM divff {nzx}//. rewrite mxval1 mulmx1 => Bx'j; rewrite (submx_trans Bx'j) in nBj => {Bx'j} //. apply/row_subP; case/mxvec_indexP=> i k. rewrite row_mul rowK mxvecE mxE rowE -mulmxA. have ->: A ^+ k *m mxval x^-1 = mxval (groot ^+ k / x). by rewrite mxvalM rmorphXn /= mxval_groot. rewrite [mxval _]horner_rVpoly; move: {k u x}(val _) => u. rewrite (mulmx_sum_row u) !linear_sum summx_sub //= => k _. rewrite 2!linearZ scalemx_sub //= rowK mxvecK -rowE. by apply: eq_row_sub (mxvec_index i k) _; rewrite rowK mxvecE mxE. Qed. Lemma gen_dim_factor : (nA * d)%N = n. Proof. by rewrite -(eqnP base_free) (eqnP base_full). Qed. Lemma gen_dim_gt0 : nA > 0. Proof. by case: posnP gen_dim_factor => // ->. Qed. Section Bijection. Variable m : nat. Definition in_gen (W : 'M[F]_(m, n)) : 'M[FA]_(m, nA) := \matrix_(i, j) inFA (row j (vec_mx (row i W *m pinvmx base))). Definition val_gen (W : 'M[FA]_(m, nA)) : 'M[F]_(m, n) := \matrix_i (mxvec (\matrix_j val (W i j)) *m base). Lemma in_genK : cancel in_gen val_gen. Proof. move=> W; apply/row_matrixP=> i; rewrite rowK; set w := row i W. have b_w: (w <= base)%MS by rewrite submx_full ?base_full. rewrite -{b_w}(mulmxKpV b_w); congr (_ *m _). by apply/rowP; case/mxvec_indexP=> j k; rewrite mxvecE !mxE. Qed. Lemma val_genK : cancel val_gen in_gen. Proof. move=> W; apply/matrixP=> i j; apply: val_inj; rewrite mxE /= rowK. case/row_freeP: base_free => B' BB'; rewrite -[_ *m _]mulmx1 -BB' mulmxA. by rewrite mulmxKpV ?submxMl // -mulmxA BB' mulmx1 mxvecK rowK. Qed. Lemma in_gen0 : in_gen 0 = 0. Proof. by apply/matrixP=> i j; rewrite !mxE !(mul0mx, linear0). Qed. Lemma val_gen0 : val_gen 0 = 0. Proof. by apply: (canLR in_genK); rewrite in_gen0. Qed. Lemma in_genD : {morph in_gen : U V / U + V}. Proof. by move=> U V; apply/matrixP=> i j; rewrite !mxE 4!(mulmxDl, linearD). Qed. Lemma val_genD : {morph val_gen : U V / U + V}. Proof. by move=> U V; apply: (canLR in_genK); rewrite in_genD !val_genK. Qed. Lemma in_genN : {morph in_gen : W / - W}. Proof. by move=> W; apply/esym/addr0_eq; rewrite -in_genD subrr in_gen0. Qed. Lemma val_genN : {morph val_gen : W / - W}. Proof. by move=> W; apply: (canLR in_genK); rewrite in_genN val_genK. Qed. Definition in_gen_sum := big_morph in_gen in_genD in_gen0. Definition val_gen_sum := big_morph val_gen val_genD val_gen0. Lemma in_genZ a : {morph in_gen : W / a *: W >-> gen a *: W}. Proof. move=> W; apply/matrixP=> i j; apply: mxval_inj. rewrite !mxE mxvalM genK ![mxval _]horner_rVpoly /=. by rewrite mul_scalar_mx !(I, scalemxAl, linearZ). Qed. End Bijection. Prenex Implicits val_genK in_genK. Lemma val_gen_rV (w : 'rV_nA) : val_gen w = mxvec (\matrix_j val (w 0 j)) *m base. Proof. by apply/rowP=> j /[1!mxE]. Qed. Section Bijection2. Variable m : nat. Lemma val_gen_row W (i : 'I_m) : val_gen (row i W) = row i (val_gen W). Proof. rewrite val_gen_rV rowK; congr (mxvec _ *m _). by apply/matrixP=> j k /[!mxE]. Qed. Lemma in_gen_row W (i : 'I_m) : in_gen (row i W) = row i (in_gen W). Proof. by apply: (canLR val_genK); rewrite val_gen_row in_genK. Qed. Lemma row_gen_sum_mxval W (i : 'I_m) : row i (val_gen W) = \sum_j row (gen_base 0 j) (mxval (W i j)). Proof. rewrite -val_gen_row [row i W]row_sum_delta val_gen_sum. apply: eq_bigr => /= j _ /[1!mxE]; move: {W i}(W i j) => x. have ->: x = \sum_k gen (val x 0 k) * inFA (delta_mx 0 k). case: x => u; apply: mxval_inj; rewrite {1}[u]row_sum_delta. rewrite mxval_sum [mxval _]horner_rVpoly mulmx_suml linear_sum /=. apply: eq_bigr => k _; rewrite mxvalM genK [mxval _]horner_rVpoly /=. by rewrite mul_scalar_mx -scalemxAl linearZ. rewrite scaler_suml val_gen_sum mxval_sum linear_sum; apply: eq_bigr => k _. rewrite mxvalM genK mul_scalar_mx linearZ [mxval _]horner_rVpoly /=. rewrite -scalerA; apply: (canLR in_genK); rewrite in_genZ; congr (_ *: _). apply: (canRL val_genK); transitivity (row (mxvec_index j k) base); last first. by rewrite -rowE rowK mxvecE mxE rowK mxvecK. rewrite rowE -mxvec_delta -[val_gen _](row_id 0) rowK /=; congr (mxvec _ *m _). apply/row_matrixP=> j'; rewrite rowK !mxE mulr_natr rowE mul_delta_mx_cond. by rewrite !mulrb (fun_if rVval). Qed. Lemma val_genZ x : {morph @val_gen m : W / x *: W >-> W *m mxval x}. Proof. move=> W; apply/row_matrixP=> i; rewrite row_mul !row_gen_sum_mxval. by rewrite mulmx_suml; apply: eq_bigr => j _; rewrite mxE mulrC mxvalM row_mul. Qed. End Bijection2. Lemma submx_in_gen m1 m2 (U : 'M_(m1, n)) (V : 'M_(m2, n)) : (U <= V -> in_gen U <= in_gen V)%MS. Proof. move=> sUV; apply/row_subP=> i; rewrite -in_gen_row. case/submxP: (row_subP sUV i) => u ->{i}. rewrite mulmx_sum_row in_gen_sum summx_sub // => j _. by rewrite in_genZ in_gen_row scalemx_sub ?row_sub. Qed. Lemma submx_in_gen_eq m1 m2 (U : 'M_(m1, n)) (V : 'M_(m2, n)) : (V *m A <= V -> (in_gen U <= in_gen V) = (U <= V))%MS. Proof. move=> sVA_V; apply/idP/idP=> siUV; last exact: submx_in_gen. apply/row_subP=> i; rewrite -[row i U]in_genK in_gen_row. case/submxP: (row_subP siUV i) => u ->{i U siUV}. rewrite mulmx_sum_row val_gen_sum summx_sub // => j _. rewrite val_genZ val_gen_row in_genK rowE -mulmxA mulmx_sub //. rewrite [mxval _]horner_poly mulmx_sumr summx_sub // => [[k _]] _ /=. rewrite mulmxA mul_mx_scalar -scalemxAl scalemx_sub {u j}//. elim: k => [|k IHk]; first by rewrite mulmx1. by rewrite exprSr mulmxA (submx_trans (submxMr A IHk)). Qed. Definition gen_mx g := \matrix_i in_gen (row (gen_base 0 i) (rG g)). Let val_genJmx m : {in G, forall g, {morph @val_gen m : W / W *m gen_mx g >-> W *m rG g}}. Proof. move=> g Gg /= W; apply/row_matrixP=> i; rewrite -val_gen_row !row_mul. rewrite mulmx_sum_row val_gen_sum row_gen_sum_mxval mulmx_suml. apply: eq_bigr => /= j _; rewrite val_genZ rowK in_genK mxE -!row_mul. by rewrite (centgmxP (mxval_centg _)). Qed. Lemma gen_mx_repr : mx_repr G gen_mx. Proof. split=> [|g h Gg Gh]; apply: (can_inj val_genK). by rewrite -[gen_mx 1]mul1mx val_genJmx // repr_mx1 mulmx1. rewrite {1}[val_gen]lock -[gen_mx g]mul1mx !val_genJmx // -mulmxA -repr_mxM //. by rewrite -val_genJmx ?groupM ?mul1mx -?lock. Qed. Canonical gen_repr := MxRepresentation gen_mx_repr. Local Notation rGA := gen_repr. Lemma val_genJ m : {in G, forall g, {morph @val_gen m : W / W *m rGA g >-> W *m rG g}}. Proof. exact: val_genJmx. Qed. Lemma in_genJ m : {in G, forall g, {morph @in_gen m : v / v *m rG g >-> v *m rGA g}}. Proof. by move=> g Gg /= v; apply: (canLR val_genK); rewrite val_genJ ?in_genK. Qed. Lemma rfix_gen (H : {set gT}) : H \subset G -> (rfix_mx rGA H :=: in_gen (rfix_mx rG H))%MS. Proof. move/subsetP=> sHG; apply/eqmxP/andP; split; last first. by apply/rfix_mxP=> g Hg; rewrite -in_genJ ?sHG ?rfix_mx_id. rewrite -[rfix_mx rGA H]val_genK; apply: submx_in_gen. by apply/rfix_mxP=> g Hg; rewrite -val_genJ ?rfix_mx_id ?sHG. Qed. Definition rowval_gen m U := <<\matrix_ik mxvec (\matrix_(i < m, k < d) (row i (val_gen U) *m A ^+ k)) 0 ik>>%MS. Lemma submx_rowval_gen m1 m2 (U : 'M_(m1, n)) (V : 'M_(m2, nA)) : (U <= rowval_gen V)%MS = (in_gen U <= V)%MS. Proof. rewrite genmxE; apply/idP/idP=> sUV. apply: submx_trans (submx_in_gen sUV) _. apply/row_subP; case/mxvec_indexP=> i k; rewrite -in_gen_row rowK mxvecE mxE. rewrite -mxval_grootXn -val_gen_row -val_genZ val_genK scalemx_sub //. exact: row_sub. rewrite -[U]in_genK; case/submxP: sUV => u ->{U}. apply/row_subP=> i0; rewrite -val_gen_row row_mul; move: {i0 u}(row _ u) => u. rewrite mulmx_sum_row val_gen_sum summx_sub // => i _. rewrite val_genZ [mxval _]horner_rVpoly [_ *m Ad]mulmx_sum_row. rewrite !linear_sum summx_sub // => k _. rewrite 2!linearZ scalemx_sub {u}//= rowK mxvecK val_gen_row. by apply: (eq_row_sub (mxvec_index i k)); rewrite rowK mxvecE mxE. Qed. Lemma rowval_genK m (U : 'M_(m, nA)) : (in_gen (rowval_gen U) :=: U)%MS. Proof. apply/eqmxP; rewrite -submx_rowval_gen submx_refl /=. by rewrite -{1}[U]val_genK submx_in_gen // submx_rowval_gen val_genK. Qed. Lemma rowval_gen_stable m (U : 'M_(m, nA)) : (rowval_gen U *m A <= rowval_gen U)%MS. Proof. rewrite -[A]mxval_groot -{1}[_ U]in_genK -val_genZ. by rewrite submx_rowval_gen val_genK scalemx_sub // rowval_genK. Qed. Lemma rstab_in_gen m (U : 'M_(m, n)) : rstab rGA (in_gen U) = rstab rG U. Proof. apply/setP=> x /[!inE]; case Gx: (x \in G) => //=. by rewrite -in_genJ // (inj_eq (can_inj in_genK)). Qed. Lemma rstabs_in_gen m (U : 'M_(m, n)) : rstabs rG U \subset rstabs rGA (in_gen U). Proof. by apply/subsetP=> x /[!inE] /andP[Gx nUx]; rewrite -in_genJ Gx // submx_in_gen. Qed. Lemma rstabs_rowval_gen m (U : 'M_(m, nA)) : rstabs rG (rowval_gen U) = rstabs rGA U. Proof. apply/setP=> x /[!inE]; case Gx: (x \in G) => //=. by rewrite submx_rowval_gen in_genJ // (eqmxMr _ (rowval_genK U)). Qed. Lemma mxmodule_rowval_gen m (U : 'M_(m, nA)) : mxmodule rG (rowval_gen U) = mxmodule rGA U. Proof. by rewrite /mxmodule rstabs_rowval_gen. Qed. Lemma gen_mx_irr : mx_irreducible rGA. Proof. apply/mx_irrP; split=> [|U Umod nzU]; first exact: gen_dim_gt0. rewrite -sub1mx -rowval_genK -submx_rowval_gen submx_full //. case/mx_irrP: irrG => _; apply; first by rewrite mxmodule_rowval_gen. rewrite -(inj_eq (can_inj in_genK)) in_gen0. by rewrite -mxrank_eq0 rowval_genK mxrank_eq0. Qed. Lemma rker_gen : rker rGA = rker rG. Proof. apply/setP=> g; rewrite !inE !mul1mx; case Gg: (g \in G) => //=. apply/eqP/eqP=> g1; apply/row_matrixP=> i. by apply: (can_inj in_genK); rewrite rowE in_genJ //= g1 mulmx1 row1. by apply: (can_inj val_genK); rewrite rowE val_genJ //= g1 mulmx1 row1. Qed. Lemma gen_mx_faithful : mx_faithful rGA = mx_faithful rG. Proof. by rewrite /mx_faithful rker_gen. Qed. End GenField. Section DecideGenField. Import MatrixFormula. Variable F : decFieldType. Local Notation False := GRing.False. Local Notation True := GRing.True. Local Notation Bool b := (GRing.Bool b%bool). Local Notation term := (GRing.term F). Local Notation form := (GRing.formula F). Local Notation morphAnd f := ((big_morph f) true andb). Variables (gT : finGroupType) (G : {group gT}) (n' : nat). Local Notation n := n'.+1. Variables (rG : mx_representation F G n) (A : 'M[F]_n). Hypotheses (irrG : mx_irreducible rG) (cGA : centgmx rG A). Local Notation FA := (gen_of irrG cGA). Local Notation inFA := (Gen irrG cGA). Local Notation d := (degree_mxminpoly A). Let d_gt0 : d > 0 := mxminpoly_nonconstant A. Local Notation Ad := (powers_mx A d). Let mxT (u : 'rV_d) := vec_mx (mulmx_term u (mx_term Ad)). Let eval_mxT e u : eval_mx e (mxT u) = mxval (inFA (eval_mx e u)). Proof. by rewrite eval_vec_mx eval_mulmx eval_mx_term [mxval _]horner_rVpoly. Qed. Let Ad'T := mx_term (pinvmx Ad). Let mulT (u v : 'rV_d) := mulmx_term (mxvec (mulmx_term (mxT u) (mxT v))) Ad'T. Lemma eval_mulT e u v : eval_mx e (mulT u v) = val (inFA (eval_mx e u) * inFA (eval_mx e v)). Proof. rewrite !(eval_mulmx, eval_mxvec) !eval_mxT eval_mx_term. by apply: (can_inj rVpolyK); rewrite -mxvalM [rVpoly _]horner_rVpolyK. Qed. Fixpoint gen_term t := match t with | 'X_k => row_var _ d k | x%:T => mx_term (val (x : FA)) | n1%:R => mx_term (val (n1%:R : FA))%R | t1 + t2 => \row_i (gen_term t1 0%R i + gen_term t2 0%R i) | - t1 => \row_i (- gen_term t1 0%R i) | t1 *+ n1 => mulmx_term (mx_term n1%:R%:M)%R (gen_term t1) | t1 * t2 => mulT (gen_term t1) (gen_term t2) | t1^-1 => gen_term t1 | t1 ^+ n1 => iter n1 (mulT (gen_term t1)) (mx_term (val (1%R : FA))) end%T. Definition gen_env (e : seq FA) := row_env (map val e). Lemma nth_map_rVval (e : seq FA) j : (map val e)`_j = val e`_j. Proof. case: (ltnP j (size e)) => [| leej]; first exact: (nth_map 0 0). by rewrite !nth_default ?size_map. Qed. Lemma set_nth_map_rVval (e : seq FA) j v : set_nth 0 (map val e) j v = map val (set_nth 0 e j (inFA v)). Proof. apply: (@eq_from_nth _ 0) => [|k _]; first by rewrite !(size_set_nth, size_map). by rewrite !(nth_map_rVval, nth_set_nth) /= nth_map_rVval [rVval _]fun_if. Qed. Lemma eval_gen_term e t : GRing.rterm t -> eval_mx (gen_env e) (gen_term t) = val (GRing.eval e t). Proof. elim: t => //=. - by move=> k _; apply/rowP=> i; rewrite !mxE /= nth_row_env nth_map_rVval. - by move=> x _; rewrite eval_mx_term. - by move=> x _; rewrite eval_mx_term. - by move=> t1 + t2 + /andP[rt1 rt2] => <-// <-//; apply/rowP => k /[!mxE]. - by move=> t1 + rt1 => <-//; apply/rowP=> k /[!mxE]. - move=> t1 IH1 n1 rt1; rewrite eval_mulmx eval_mx_term mul_scalar_mx. by rewrite scaler_nat {}IH1 //; elim: n1 => //= n1 IHn1; rewrite !mulrS IHn1. - by move=> t1 IH1 t2 IH2 /andP[rt1 rt2]; rewrite eval_mulT IH1 ?IH2. move=> t1 + n1 => /[apply] IH1. elim: n1 => [|n1 IHn1] /=; first by rewrite eval_mx_term. by rewrite eval_mulT exprS IH1 IHn1. Qed. Fixpoint gen_form f := match f with | Bool b => Bool b | t1 == t2 => mxrank_form 0 (gen_term (t1 - t2)) | GRing.Unit t1 => mxrank_form 1 (gen_term t1) | f1 /\ f2 => gen_form f1 /\ gen_form f2 | f1 \/ f2 => gen_form f1 \/ gen_form f2 | f1 ==> f2 => gen_form f1 ==> gen_form f2 | ~ f1 => ~ gen_form f1 | ('exists 'X_k, f1) => Exists_row_form d k (gen_form f1) | ('forall 'X_k, f1) => ~ Exists_row_form d k (~ (gen_form f1)) end%T. Lemma sat_gen_form e f : GRing.rformula f -> reflect (GRing.holds e f) (GRing.sat (gen_env e) (gen_form f)). Proof. have ExP := Exists_rowP; have set_val := set_nth_map_rVval. elim: f e => //. - by move=> b e _; apply: (iffP satP). - rewrite /gen_form => t1 t2 e rt_t; set t := (_ - _)%T. have:= GRing.qf_evalP (gen_env e) (mxrank_form_qf 0 (gen_term t)). rewrite eval_mxrank mxrank_eq0 eval_gen_term // => tP. by rewrite (sameP satP tP) /= subr_eq0 val_eqE; apply: eqP. - move=> f1 IH1 f2 IH2 s /= /andP[/(IH1 s)f1P /(IH2 s)f2P]. by apply: (iffP satP) => [[/satP/f1P ? /satP/f2P] | [/f1P/satP ? /f2P/satP]]. - move=> f1 IH1 f2 IH2 s /= /andP[/(IH1 s)f1P /(IH2 s)f2P]. by apply: (iffP satP) => /= [] []; try move/satP; do [move/f1P | move/f2P]; try move/satP; auto. - move=> f1 IH1 f2 IH2 s /= /andP[/(IH1 s)f1P /(IH2 s)f2P]. by apply: (iffP satP) => /= implP; try move/satP; move/f1P; try move/satP; move/implP; try move/satP; move/f2P; try move/satP. - move=> f1 IH1 s /= /(IH1 s) f1P. by apply: (iffP satP) => /= notP; try move/satP; move/f1P; try move/satP. - move=> k f1 IHf1 s /IHf1 f1P; apply: (iffP satP) => /= [|[[v f1v]]]. by case/ExP=> // x /satP; rewrite set_val => /f1P; exists (inFA x). by apply/ExP=> //; exists v; rewrite set_val; apply/satP/f1P. move=> i f1 IHf1 s /IHf1 f1P; apply: (iffP satP) => /= allf1 => [[v]|]. apply/f1P; case: satP => // notf1x; case: allf1; apply/ExP=> //. by exists v; rewrite set_val. by case/ExP=> //= v []; apply/satP; rewrite set_val; apply/f1P. Qed. Definition gen_sat e f := GRing.sat (gen_env e) (gen_form (GRing.to_rform f)). (* FIXME : why this MathCompCompatDecidableField *) Lemma gen_satP : GRing.MathCompCompatDecidableField.DecidableField.axiom gen_sat. Proof. move=> e f; have [tor rto] := GRing.to_rformP e f. exact: (iffP (sat_gen_form e (GRing.to_rform_rformula f))). Qed. #[export] HB.instance Definition _ := GRing.Field_isDecField.Build FA gen_satP. End DecideGenField. Section FiniteGenField. Variables (F : finFieldType) (gT : finGroupType) (G : {group gT}) (n' : nat). Local Notation n := n'.+1. Variables (rG : mx_representation F G n) (A : 'M[F]_n). Hypotheses (irrG : mx_irreducible rG) (cGA : centgmx rG A). Notation FA := (gen_of irrG cGA). #[export] HB.instance Definition _ := [Finite of FA by <:]. #[export] HB.instance Definition _ := [finGroupMixin of FA for +%R]. Lemma card_gen : #|{:FA}| = (#|F| ^ degree_mxminpoly A)%N. Proof. by rewrite card_sub card_mx mul1n. Qed. End FiniteGenField. End MatrixGenField. Module MatrixGenFieldExports. HB.reexport. End MatrixGenFieldExports. Export MatrixGenFieldExports. Bind Scope ring_scope with gen_of. Arguments rVval {F gT G%_G n'%_N rG A%_R irrG cGA} x%_R : rename. Prenex Implicits gen_of Gen rVval pval mxval gen groot. Arguments subbase {F n'} A {nA}. Prenex Implicits gen_dim gen_base base val_gen gen_mx rowval_gen. Arguments in_gen {F gT G n' rG A} irrG cGA {m} W. Arguments in_genK {F gT G n' rG A} irrG cGA {m} W : rename. Arguments val_genK {F gT G n' rG A irrG cGA m} W : rename. Prenex Implicits gen_env gen_term gen_form gen_sat. (* Classical splitting and closure field constructions provide convenient *) (* packaging for the pointwise construction. *) Section BuildSplittingField. Implicit Type gT : finGroupType. Implicit Type F : fieldType. Lemma group_splitting_field_exists gT (G : {group gT}) F : classically {Fs : fieldType & {rmorphism F -> Fs} & group_splitting_field Fs G}. Proof. move: F => F0 [] // nosplit; pose nG := #|G|; pose aG F := regular_repr F G. pose m := nG.+1; pose F := F0; pose U : seq 'M[F]_nG := [::]. suffices: size U + m <= nG by rewrite ltnn. have: mx_subseries (aG F) U /\ path ltmx 0 U by []. pose f : {rmorphism F0 -> F} := idfun. elim: m F U f => [|m IHm] F U f [modU ltU]. by rewrite addn0 (leq_trans (max_size_mx_series ltU)) ?rank_leq_row. rewrite addnS ltnNge -implybF; apply/implyP=> le_nG_Um; apply: nosplit. exists F => //; case=> [|n] rG irrG; first by case/mx_irrP: irrG. apply/idPn=> nabsG; pose cG := ('C(enveloping_algebra_mx rG))%MS. have{nabsG} [A]: exists2 A, (A \in cG)%MS & ~~ is_scalar_mx A. apply/has_non_scalar_mxP; rewrite ?scalar_mx_cent // ltnNge. by apply: contra nabsG; apply: cent_mx_scalar_abs_irr. rewrite {cG}memmx_cent_envelop -mxminpoly_linear_is_scalar -ltnNge => cGA. move/(non_linear_gen_reducible irrG cGA). (* FIXME: _ matches a generated constant *) set F' := _ irrG cGA; set rG' := @map_repr _ F' _ _ _ _ rG. move: F' (gen _ _ : {rmorphism F -> F'}) => F' f' in rG' * => irrG'. pose U' := [seq map_mx f' Ui | Ui <- U]. have modU': mx_subseries (aG F') U'. apply: etrans modU; rewrite /mx_subseries all_map; apply: eq_all => Ui. rewrite -(mxmodule_map f'); apply: eq_subset_r => x. by rewrite !inE map_regular_repr. case: notF; apply: (mx_Schreier modU ltU) => [[V [compV lastV sUV]]]. have{lastV} [] := rsim_regular_series irrG compV lastV. have{sUV} defV: V = U. apply/eqP; rewrite eq_sym -(geq_leqif (size_subseq_leqif sUV)). rewrite -(leq_add2r m); apply: leq_trans le_nG_Um. by apply: IHm f _; rewrite (mx_series_lt compV); case: compV. rewrite {V}defV in compV * => i rsimVi. apply: (mx_Schreier modU') => [|[V' [compV' _ sUV']]]. rewrite {modU' compV modU i le_nG_Um rsimVi}/U' -(map_mx0 f'). by apply: etrans ltU; elim: U 0 => //= Ui U IHU Ui'; rewrite IHU map_ltmx. have{sUV'} defV': V' = U'; last rewrite {V'}defV' in compV'. apply/eqP; rewrite eq_sym -(geq_leqif (size_subseq_leqif sUV')) size_map. rewrite -(leq_add2r m); apply: leq_trans le_nG_Um. apply: IHm (f' \o f) _. by rewrite (mx_series_lt compV'); case: compV'. suffices{irrG'}: mx_irreducible rG' by case/mxsimpleP=> _ _ []. have ltiU': i < size U' by rewrite size_map. apply: mx_rsim_irr (mx_rsim_sym _ ) (mx_series_repr_irr compV' ltiU'). by apply: mx_rsim_trans (mx_rsim_map f' rsimVi) _; apply: map_regular_subseries. Qed. Lemma group_closure_field_exists gT F : classically {Fs : fieldType & {rmorphism F -> Fs} & group_closure_field Fs gT}. Proof. set n := #|{group gT}|. suffices: classically {Fs : fieldType & {rmorphism F -> Fs} & forall G : {group gT}, enum_rank G < n -> group_splitting_field Fs G}. - apply: classic_bind => [[Fs f splitFs]] _ -> //. by exists Fs => // G; apply: splitFs. elim: (n) => [|i IHi]; first by move=> _ -> //; exists F => //; exists id. apply: classic_bind IHi => [[F' f splitF']]. have [le_n_i _ -> // | lt_i_n] := leqP n i. by exists F' => // G _; apply: splitF'; apply: leq_trans le_n_i. have:= @group_splitting_field_exists _ (enum_val (Ordinal lt_i_n)) F'. apply: classic_bind => [[Fs f' splitFs]] _ -> //. exists Fs => [|G]; first exact: (f' \o f). rewrite ltnS leq_eqVlt -{1}[i]/(val (Ordinal lt_i_n)) val_eqE. case/predU1P=> [defG | ltGi]; first by rewrite -[G]enum_rankK defG. by apply: (extend_group_splitting_field f'); apply: splitF'. Qed. Lemma group_closure_closed_field (F : closedFieldType) gT : group_closure_field F gT. Proof. move=> G [|n] rG irrG; first by case/mx_irrP: irrG. apply: cent_mx_scalar_abs_irr => //; rewrite leqNgt. apply/(has_non_scalar_mxP (scalar_mx_cent _ _)) => [[A cGA nscalA]]. have [a]: exists a, eigenvalue A a. pose P := mxminpoly A; pose d := degree_mxminpoly A. have Pd1: P`_d = 1. by rewrite -(eqP (mxminpoly_monic A)) /lead_coef size_mxminpoly. have d_gt0: d > 0 := mxminpoly_nonconstant A. have [a def_ad] := solve_monicpoly (nth 0 (- P)) d_gt0. exists a; rewrite eigenvalue_root_min -/P /root -oppr_eq0 -hornerN. rewrite horner_coef size_polyN size_mxminpoly -/d big_ord_recr -def_ad. by rewrite coefN Pd1 mulN1r /= subrr. case/negP; rewrite kermx_eq0 row_free_unit (mx_Schur irrG) ?subr_eq0 //. by rewrite -memmx_cent_envelop -raddfN linearD addmx_sub ?scalar_mx_cent. by apply: contraNneq nscalA => ->; exact: scalar_mx_is_scalar. Qed. End BuildSplittingField.
Equiv.lean
/- Copyright (c) 2024 Amelia Livingston. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Amelia Livingston -/ import Mathlib.RingTheory.Coalgebra.Equiv import Mathlib.RingTheory.Bialgebra.Hom /-! # Isomorphisms of `R`-bialgebras This file defines bundled isomorphisms of `R`-bialgebras. We simply mimic the early parts of `Mathlib/Algebra/Algebra/Equiv.lean`. ## Main definitions * `BialgEquiv R A B`: the type of `R`-bialgebra isomorphisms between `A` and `B`. ## Notations * `A ≃ₐc[R] B` : `R`-bialgebra equivalence from `A` to `B`. -/ universe u v w u₁ variable {R : Type u} {A : Type v} {B : Type w} {C : Type u₁} open TensorProduct Coalgebra Bialgebra Function /-- An equivalence of bialgebras is an invertible bialgebra homomorphism. -/ structure BialgEquiv (R : Type u) [CommSemiring R] (A : Type v) (B : Type w) [Semiring A] [Semiring B] [Algebra R A] [Algebra R B] [CoalgebraStruct R A] [CoalgebraStruct R B] extends A ≃ₗc[R] B, A ≃* B where attribute [nolint docBlame] BialgEquiv.toMulEquiv attribute [nolint docBlame] BialgEquiv.toCoalgEquiv @[inherit_doc BialgEquiv] notation:50 A " ≃ₐc[" R "] " B => BialgEquiv R A B /-- `BialgEquivClass F R A B` asserts `F` is a type of bundled bialgebra equivalences from `A` to `B`. -/ class BialgEquivClass (F : Type*) (R A B : outParam Type*) [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B] [CoalgebraStruct R A] [CoalgebraStruct R B] [EquivLike F A B] : Prop extends CoalgEquivClass F R A B, MulEquivClass F A B namespace BialgEquivClass variable {F R A B : Type*} [CommSemiring R] [Semiring A] [Semiring B] [Algebra R A] [Algebra R B] [CoalgebraStruct R A] [CoalgebraStruct R B] [EquivLike F A B] [BialgEquivClass F R A B] instance (priority := 100) toBialgHomClass : BialgHomClass F R A B where map_add := map_add map_smulₛₗ := map_smul counit_comp := CoalgHomClass.counit_comp map_comp_comul := CoalgHomClass.map_comp_comul map_mul := map_mul map_one := map_one /-- Reinterpret an element of a type of bialgebra equivalences as a bialgebra equivalence. -/ @[coe] def toBialgEquiv (f : F) : A ≃ₐc[R] B := { (f : A ≃ₗc[R] B), (f : A →ₐc[R] B) with } /-- Reinterpret an element of a type of bialgebra equivalences as a bialgebra equivalence. -/ instance instCoeToBialgEquiv : CoeHead F (A ≃ₐc[R] B) where coe f := toBialgEquiv f instance (priority := 100) toAlgEquivClass : AlgEquivClass F R A B where map_mul := map_mul map_add := map_add commutes := AlgHomClass.commutes end BialgEquivClass namespace BialgEquiv variable [CommSemiring R] section variable [Semiring A] [Semiring B] [Algebra R A] [Algebra R B] [CoalgebraStruct R A] [CoalgebraStruct R B] /-- The bialgebra morphism underlying a bialgebra equivalence. -/ def toBialgHom (f : A ≃ₐc[R] B) : A →ₐc[R] B := { f.toCoalgEquiv with map_one' := map_one f.toMulEquiv map_mul' := map_mul f.toMulEquiv } /-- The algebra equivalence underlying a bialgebra equivalence. -/ def toAlgEquiv (f : A ≃ₐc[R] B) : A ≃ₐ[R] B := { f.toCoalgEquiv with map_mul' := map_mul f.toMulEquiv map_add' := map_add f.toCoalgEquiv commutes' := AlgHomClass.commutes f.toBialgHom } /-- The equivalence of types underlying a bialgebra equivalence. -/ def toEquiv : (A ≃ₐc[R] B) → A ≃ B := fun f => f.toCoalgEquiv.toEquiv theorem toEquiv_injective : Function.Injective (toEquiv : (A ≃ₐc[R] B) → A ≃ B) := fun ⟨_, _⟩ ⟨_, _⟩ h => (BialgEquiv.mk.injEq _ _ _ _).mpr (CoalgEquiv.toEquiv_injective h) @[simp] theorem toEquiv_inj {e₁ e₂ : A ≃ₐc[R] B} : e₁.toEquiv = e₂.toEquiv ↔ e₁ = e₂ := toEquiv_injective.eq_iff theorem toBialgHom_injective : Function.Injective (toBialgHom : (A ≃ₐc[R] B) → A →ₐc[R] B) := fun _ _ H => toEquiv_injective <| Equiv.ext <| BialgHom.congr_fun H instance : EquivLike (A ≃ₐc[R] B) A B where coe f := f.toFun inv := fun f => f.invFun coe_injective' _ _ h _ := toBialgHom_injective (DFunLike.coe_injective h) left_inv := fun f => f.left_inv right_inv := fun f => f.right_inv instance : FunLike (A ≃ₐc[R] B) A B where coe := DFunLike.coe coe_injective' := DFunLike.coe_injective instance : BialgEquivClass (A ≃ₐc[R] B) R A B where map_add := (·.map_add') map_smulₛₗ := (·.map_smul') counit_comp := (·.counit_comp) map_comp_comul := (·.map_comp_comul) map_mul := (·.map_mul') @[simp, norm_cast] theorem toBialgHom_inj {e₁ e₂ : A ≃ₐc[R] B} : (↑e₁ : A →ₐc[R] B) = e₂ ↔ e₁ = e₂ := toBialgHom_injective.eq_iff @[simp] lemma coe_mk (e : A ≃ₗc[R] B) (h) : mk e h = e := rfl end section variable [Semiring A] [Semiring B] [Semiring C] [Algebra R A] [Algebra R B] [Algebra R C] [CoalgebraStruct R A] [CoalgebraStruct R B] [CoalgebraStruct R C] variable (e e' : A ≃ₐc[R] B) @[simp, norm_cast] theorem coe_coe : ⇑(e : A →ₐc[R] B) = e := rfl @[simp] theorem toCoalgEquiv_eq_coe (f : A ≃ₐc[R] B) : f.toCoalgEquiv = f := rfl @[simp] theorem toBialgHom_eq_coe (f : A ≃ₐc[R] B) : f.toBialgHom = f := rfl @[simp] theorem toAlgEquiv_eq_coe (f : A ≃ₐc[R] B) : f.toAlgEquiv = f := rfl @[simp] theorem coe_toCoalgEquiv : ⇑(e : A ≃ₐ[R] B) = e := rfl @[simp] theorem coe_toBialgHom : ⇑(e : A →ₐc[R] B) = e := rfl @[simp] theorem coe_toAlgEquiv : ⇑(e : A ≃ₐ[R] B) = e := rfl theorem toCoalgEquiv_toCoalgHom : ((e : A ≃ₐc[R] B) : A →ₗc[R] B) = (e : A →ₐc[R] B) := rfl theorem toBialgHom_toAlgHom : ((e : A →ₐc[R] B) : A →ₐ[R] B) = e := rfl section variable {e e'} @[ext] theorem ext (h : ∀ x, e x = e' x) : e = e' := DFunLike.ext _ _ h protected theorem congr_arg {x x'} : x = x' → e x = e x' := DFunLike.congr_arg e protected theorem congr_fun (h : e = e') (x : A) : e x = e' x := DFunLike.congr_fun h x end /-- See Note [custom simps projection] -/ def Simps.apply {R : Type u} [CommSemiring R] {α : Type v} {β : Type w} [Semiring α] [Semiring β] [Algebra R α] [Algebra R β] [CoalgebraStruct R α] [CoalgebraStruct R β] (f : α ≃ₐc[R] β) : α → β := f /-- See Note [custom simps projection] -/ def Simps.symm_apply {R : Type*} [CommSemiring R] {A : Type*} {B : Type*} [Semiring A] [Semiring B] [Algebra R A] [Algebra R B] [CoalgebraStruct R A] [CoalgebraStruct R B] (e : A ≃ₐc[R] B) : B → A := e.symm initialize_simps_projections BialgEquiv (toFun → apply, invFun → symm_apply) variable (A R) in /-- The identity map is a bialgebra equivalence. -/ @[refl, simps!] def refl : A ≃ₐc[R] A := { CoalgEquiv.refl R A, BialgHom.id R A with } @[simp] theorem refl_toCoalgEquiv : refl R A = CoalgEquiv.refl R A := rfl @[simp] theorem refl_toBialgHom : refl R A = BialgHom.id R A := rfl /-- Bialgebra equivalences are symmetric. -/ @[symm] def symm (e : A ≃ₐc[R] B) : B ≃ₐc[R] A := { (e : A ≃ₗc[R] B).symm, (e : A ≃* B).symm with } @[simp] theorem symm_toCoalgEquiv (e : A ≃ₐc[R] B) : e.symm = (e : A ≃ₗc[R] B).symm := rfl theorem invFun_eq_symm : e.invFun = e.symm := rfl theorem coe_toEquiv_symm : e.toEquiv.symm = e.symm := rfl @[simp] theorem toEquiv_symm : e.symm.toEquiv = e.toEquiv.symm := rfl @[simp] theorem coe_toEquiv : ⇑e.toEquiv = e := rfl @[simp] theorem coe_symm_toEquiv : ⇑e.toEquiv.symm = e.symm := rfl variable {e₁₂ : A ≃ₐc[R] B} {e₂₃ : B ≃ₐc[R] C} /-- Bialgebra equivalences are transitive. -/ @[trans, simps!] def trans (e₁₂ : A ≃ₐc[R] B) (e₂₃ : B ≃ₐc[R] C) : A ≃ₐc[R] C := { (e₁₂ : A ≃ₗc[R] B).trans (e₂₃ : B ≃ₗc[R] C), (e₁₂ : A ≃* B).trans (e₂₃ : B ≃* C) with } @[simp] theorem trans_toCoalgEquiv : (e₁₂.trans e₂₃ : A ≃ₗc[R] C) = (e₁₂ : A ≃ₗc[R] B).trans (e₂₃ : B ≃ₗc[R] C) := rfl @[simp] theorem trans_toBialgHom : (e₁₂.trans e₂₃ : A →ₐc[R] C) = (e₂₃ : B →ₐc[R] C).comp e₁₂ := rfl @[simp] theorem coe_toEquiv_trans : (e₁₂ : A ≃ B).trans e₂₃ = (e₁₂.trans e₂₃ : A ≃ C) := rfl @[simp] lemma apply_symm_apply (e : A ≃ₐc[R] B) : ∀ x, e (e.symm x) = x := e.toEquiv.apply_symm_apply @[simp] lemma symm_apply_apply (e : A ≃ₐc[R] B) : ∀ x, e.symm (e x) = x := e.toEquiv.symm_apply_apply @[simp] lemma comp_symm (e : A ≃ₐc[R] B) : (e : A →ₐc[R] B).comp e.symm = .id R B := BialgHom.coe_algHom_injective e.toAlgEquiv.comp_symm @[simp] lemma symm_comp (e : A ≃ₐc[R] B) : (e.symm : B →ₐc[R] A).comp e = .id R A := BialgHom.coe_algHom_injective e.toAlgEquiv.symm_comp @[simp] lemma toRingEquiv_toRingHom (e : A ≃ₐc[R] B) : ((e : A ≃+* B) : A →+* B) = e := rfl @[simp] lemma toAlgEquiv_toRingHom (e : A ≃ₐc[R] B) : ((e : A ≃ₐ[R] B) : A →+* B) = e := rfl /-- If an coalgebra morphism has an inverse, it is an coalgebra isomorphism. -/ def ofBialgHom (f : A →ₐc[R] B) (g : B →ₐc[R] A) (h₁ : f.comp g = BialgHom.id R B) (h₂ : g.comp f = BialgHom.id R A) : A ≃ₐc[R] B where __ := f toFun := f invFun := g left_inv := BialgHom.ext_iff.1 h₂ right_inv := BialgHom.ext_iff.1 h₁ @[simp] theorem coe_ofBialgHom (f : A →ₐc[R] B) (g : B →ₐc[R] A) (h₁ h₂) : ofBialgHom f g h₁ h₂ = f := rfl theorem ofBialgHom_symm (f : A →ₐc[R] B) (g : B →ₐc[R] A) (h₁ h₂) : (ofBialgHom f g h₁ h₂).symm = ofBialgHom g f h₂ h₁ := rfl /-- Construct a bialgebra equiv from an algebra equiv respecting counit and comultiplication. -/ @[simps apply] def ofAlgEquiv (f : A ≃ₐ[R] B) (counit_comp : counit ∘ₗ f.toLinearMap = counit) (map_comp_comul : map f.toLinearMap f.toLinearMap ∘ₗ comul = comul ∘ₗ f.toLinearMap) : A ≃ₐc[R] B where __ := f map_smul' := map_smul f counit_comp := counit_comp map_comp_comul := map_comp_comul @[simp] lemma toLinearMap_ofAlgEquiv (f : A ≃ₐ[R] B) (counit_comp map_comp_comul) : (ofAlgEquiv f counit_comp map_comp_comul : A →ₗ[R] B) = f := rfl /-- Promotes a bijective bialgebra homomorphism to a bialgebra equivalence. -/ @[simps! apply] noncomputable def ofBijective (f : A →ₐc[R] B) (hf : Bijective f) : A ≃ₐc[R] B := .ofAlgEquiv (.ofBijective (f : A →ₐ[R] B) hf) (by ext; simp) (by ext; simp) @[simp] lemma coe_ofBijective (f : A →ₐc[R] B) (hf : Bijective f) : (ofBijective f hf : A → B) = f := rfl end end BialgEquiv
fingraph.v
(* (c) Copyright 2006-2016 Microsoft Corporation and Inria. *) (* Distributed under the terms of CeCILL-B. *) From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat. From mathcomp Require Import seq path fintype. (******************************************************************************) (* This file develops the theory of finite graphs represented by an "edge" *) (* relation over a finType T; this mainly amounts to the theory of the *) (* transitive closure of such relations. *) (* For g : T -> seq T, e : rel T and f : T -> T we define: *) (* grel g == the adjacency relation y \in g x of the graph g. *) (* rgraph e == the graph (x |-> enum (e x)) of the relation e. *) (* dfs g n v x == the list of points traversed by a depth-first search of *) (* the g, at depth n, starting from x, and avoiding v. *) (* dfs_path g v x y <-> there is a path from x to y in g \ v. *) (* connect e == the reflexive transitive closure of e (computed by dfs). *) (* connect_sym e <-> connect e is symmetric, hence an equivalence relation. *) (* root e x == a representative of connect e x, which is the component *) (* of x in the transitive closure of e. *) (* roots e == the codomain predicate of root e. *) (* n_comp e a == the number of e-connected components of a, when a is *) (* e-closed and connect e is symmetric. *) (* equivalence classes of connect e if connect_sym e holds. *) (* closed e a == the collective predicate a is e-invariant. *) (* closure e a == the e-closure of a (the image of a under connect e). *) (* rel_adjunction h e e' a <-> in the e-closed domain a, h is the left part *) (* of an adjunction from e to another relation e'. *) (* fconnect f == connect (frel f), i.e., "connected under f iteration". *) (* froot f x == root (frel f) x, the root of the orbit of x under f. *) (* froots f == roots (frel f) == orbit representatives for f. *) (* orbit f x == lists the f-orbit of x. *) (* findex f x y == index of y in the f-orbit of x. *) (* order f x == size (cardinal) of the f-orbit of x. *) (* order_set f n == elements of f-order n. *) (* finv f == the inverse of f, if f is injective. *) (* := finv f x := iter (order x).-1 f x. *) (* fcard f a == number of orbits of f in a, provided a is f-invariant *) (* f is one-to-one. *) (* fclosed f a == the collective predicate a is f-invariant. *) (* fclosure f a == the closure of a under f iteration. *) (* fun_adjunction == rel_adjunction (frel f). *) (******************************************************************************) Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. Definition grel (T : eqType) (g : T -> seq T) := [rel x y | y \in g x]. (* Decidable connectivity in finite types. *) Section Connect. Variable T : finType. Section Dfs. Variable g : T -> seq T. Implicit Type v w a : seq T. Fixpoint dfs n v x := if x \in v then v else if n is n'.+1 then foldl (dfs n') (x :: v) (g x) else v. Lemma subset_dfs n v a : v \subset foldl (dfs n) v a. Proof. elim: n a v => [|n IHn]; first by elim=> //= *; rewrite if_same. elim=> //= x a IHa v; apply: subset_trans {IHa}(IHa _); case: ifP => // _. by apply: subset_trans (IHn _ _); apply/subsetP=> y; apply: predU1r. Qed. Inductive dfs_path v x y : Prop := DfsPath p of path (grel g) x p & y = last x p & [disjoint x :: p & v]. Lemma dfs_pathP n x y v : #|T| <= #|v| + n -> y \notin v -> reflect (dfs_path v x y) (y \in dfs n v x). Proof. have dfs_id w z: z \notin w -> dfs_path w z z. by exists [::]; rewrite ?disjoint_has //= orbF. elim: n => [|n IHn] /= in x y v * => le_v'_n not_vy. rewrite addn0 (geq_leqif (subset_leqif_card (subset_predT _))) in le_v'_n. by rewrite predT_subset in not_vy. have [v_x | not_vx] := ifPn. by rewrite (negPf not_vy); right=> [] [p _ _]; rewrite disjoint_has /= v_x. set v1 := x :: v; set a := g x; have sub_dfs := subsetP (subset_dfs n _ _). have [-> | neq_yx] := eqVneq y x. by rewrite sub_dfs ?mem_head //; left; apply: dfs_id. apply: (@equivP (exists2 x1, x1 \in a & dfs_path v1 x1 y)); last first. split=> {IHn} [[x1 a_x1 [p g_p p_y]] | [p /shortenP[]]]. rewrite disjoint_has has_sym /= has_sym /= => /norP[_ not_pv]. by exists (x1 :: p); rewrite /= ?a_x1 // disjoint_has negb_or not_vx. case=> [_ _ _ eq_yx | x1 p1 /=]; first by case/eqP: neq_yx. case/andP=> a_x1 g_p1 /andP[not_p1x _] /subsetP p_p1 p1y not_pv. exists x1 => //; exists p1 => //. rewrite disjoint_sym disjoint_cons not_p1x disjoint_sym. by move: not_pv; rewrite disjoint_cons => /andP[_ /disjointWl->]. have{neq_yx not_vy}: y \notin v1 by apply/norP. have{le_v'_n not_vx}: #|T| <= #|v1| + n by rewrite cardU1 not_vx addSnnS. elim: {x v}a v1 => [|x a IHa] v /= le_v'_n not_vy. by rewrite (negPf not_vy); right=> [] []. set v2 := dfs n v x; have v2v: v \subset v2 := subset_dfs n v [:: x]. have [v2y | not_v2y] := boolP (y \in v2). by rewrite sub_dfs //; left; exists x; [apply: mem_head | apply: IHn]. apply: {IHa}(equivP (IHa _ _ not_v2y)). by rewrite (leq_trans le_v'_n) // leq_add2r subset_leq_card. split=> [] [x1 a_x1 [p g_p p_y not_pv]]. exists x1; [exact: predU1r | exists p => //]. by rewrite disjoint_sym (disjointWl v2v) // disjoint_sym. suffices not_p1v2: [disjoint x1 :: p & v2]. case/predU1P: a_x1 => [def_x1 | ]; last by exists x1; last exists p. case/pred0Pn: not_p1v2; exists x; rewrite /= def_x1 mem_head /=. suffices not_vx: x \notin v by apply/IHn; last apply: dfs_id. by move: not_pv; rewrite disjoint_cons def_x1 => /andP[]. apply: contraR not_v2y => /pred0Pn[x2 /andP[/= p_x2 v2x2]]. case/splitPl: p_x2 p_y g_p not_pv => p0 p2 p0x2. rewrite last_cat cat_path -cat_cons lastI cat_rcons {}p0x2 => p2y /andP[_ g_p2]. rewrite disjoint_cat disjoint_cons => /and3P[{p0}_ not_vx2 not_p2v]. have{not_vx2 v2x2} [p1 g_p1 p1_x2 not_p1v] := IHn _ _ v le_v'_n not_vx2 v2x2. apply/IHn=> //; exists (p1 ++ p2); rewrite ?cat_path ?last_cat -?p1_x2 ?g_p1 //. by rewrite -cat_cons disjoint_cat not_p1v. Qed. Lemma dfsP x y : reflect (exists2 p, path (grel g) x p & y = last x p) (y \in dfs #|T| [::] x). Proof. apply: (iffP (dfs_pathP _ _ _)); rewrite ?card0 // => [] [p]; exists p => //. by rewrite disjoint_sym disjoint0. Qed. End Dfs. Variable e : rel T. Definition rgraph x := enum (e x). Lemma rgraphK : grel rgraph =2 e. Proof. by move=> x y; rewrite /= mem_enum. Qed. Definition connect : rel T := [rel x y | y \in dfs rgraph #|T| [::] x]. Canonical connect_app_pred x := ApplicativePred (connect x). Lemma connectP x y : reflect (exists2 p, path e x p & y = last x p) (connect x y). Proof. apply: (equivP (dfsP _ x y)). by split=> [] [p e_p ->]; exists p => //; rewrite (eq_path rgraphK) in e_p *. Qed. Lemma connect_trans : transitive connect. Proof. move=> x y z /connectP[p e_p ->] /connectP[q e_q ->]; apply/connectP. by exists (p ++ q); rewrite ?cat_path ?e_p ?last_cat. Qed. Lemma connect0 x : connect x x. Proof. by apply/connectP; exists [::]. Qed. Lemma eq_connect0 x y : x = y -> connect x y. Proof. by move->; apply: connect0. Qed. Lemma connect1 x y : e x y -> connect x y. Proof. by move=> e_xy; apply/connectP; exists [:: y]; rewrite /= ?e_xy. Qed. Lemma path_connect x p : path e x p -> subpred [in x :: p] (connect x). Proof. move=> e_p y p_y; case/splitPl: p / p_y e_p => p q <-. by rewrite cat_path => /andP[e_p _]; apply/connectP; exists p. Qed. Lemma connect_cycle p : cycle e p -> {in p &, forall x y, connect x y}. Proof. move=> e_p x y /rot_to[i q rip]; rewrite -(mem_rot i) rip => yqx. have /= : cycle e (x :: q) by rewrite -rip rot_cycle. case/splitPl: yqx => r s lxr; rewrite rcons_cat cat_path => /andP[xr _]. by apply/connectP; exists r. Qed. Definition root x := odflt x (pick (connect x)). Definition roots : pred T := fun x => root x == x. Canonical roots_pred := ApplicativePred roots. Definition n_comp_mem (m_a : mem_pred T) := #|predI roots m_a|. Lemma connect_root x : connect x (root x). Proof. by rewrite /root; case: pickP; rewrite ?connect0. Qed. Definition connect_sym := symmetric connect. Hypothesis sym_e : connect_sym. Lemma same_connect : left_transitive connect. Proof. exact: sym_left_transitive connect_trans. Qed. Lemma same_connect_r : right_transitive connect. Proof. exact: sym_right_transitive connect_trans. Qed. Lemma same_connect1 x y : e x y -> connect x =1 connect y. Proof. by move/connect1; apply: same_connect. Qed. Lemma same_connect1r x y : e x y -> connect^~ x =1 connect^~ y. Proof. by move/connect1; apply: same_connect_r. Qed. Lemma rootP x y : reflect (root x = root y) (connect x y). Proof. apply: (iffP idP) => e_xy. by rewrite /root -(eq_pick (same_connect e_xy)); case: pickP e_xy => // ->. by apply: (connect_trans (connect_root x)); rewrite e_xy sym_e connect_root. Qed. Lemma root_root x : root (root x) = root x. Proof. exact/esym/rootP/connect_root. Qed. Lemma roots_root x : roots (root x). Proof. exact/eqP/root_root. Qed. Lemma root_connect x y : (root x == root y) = connect x y. Proof. exact: sameP eqP (rootP x y). Qed. Definition closed_mem m_a := forall x y, e x y -> in_mem x m_a = in_mem y m_a. Definition closure_mem m_a : pred T := fun x => ~~ disjoint (mem (connect x)) m_a. End Connect. Arguments rgraphK [T]. #[global] Hint Resolve connect0 : core. Notation n_comp e a := (n_comp_mem e (mem a)). Notation closed e a := (closed_mem e (mem a)). Notation closure e a := (closure_mem e (mem a)). Prenex Implicits connect root roots. Arguments dfsP {T g x y}. Arguments connectP {T e x y}. Arguments rootP [T e] _ {x y}. Notation fconnect f := (connect (coerced_frel f)). Notation froot f := (root (coerced_frel f)). Notation froots f := (roots (coerced_frel f)). Notation fcard_mem f := (n_comp_mem (coerced_frel f)). Notation fcard f a := (fcard_mem f (mem a)). Notation fclosed f a := (closed (coerced_frel f) a). Notation fclosure f a := (closure (coerced_frel f) a). Section EqConnect. Variable T : finType. Implicit Types (e : rel T) (a : {pred T}). Lemma connect_sub e e' : subrel e (connect e') -> subrel (connect e) (connect e'). Proof. move=> e'e x _ /connectP[p e_p ->]; elim: p x e_p => //= y p IHp x /andP[exy]. by move/IHp; apply: connect_trans; apply: e'e. Qed. Lemma relU_sym e e' : connect_sym e -> connect_sym e' -> connect_sym (relU e e'). Proof. move=> sym_e sym_e'; apply: symmetric_from_pre => x _ /connectP[p e_p ->]. elim: p x e_p => //= y p IHp x /andP[e_xy /IHp{IHp}/connect_trans]; apply. case/orP: e_xy => /connect1; rewrite (sym_e, sym_e'); by apply: connect_sub y x => x y e_xy; rewrite connect1 //= e_xy ?orbT. Qed. Lemma eq_connect e e' : e =2 e' -> connect e =2 connect e'. Proof. move=> eq_e x y; apply/connectP/connectP=> [] [p e_p ->]; by exists p; rewrite // (eq_path eq_e) in e_p *. Qed. Arguments eq_connect [e e']. Lemma eq_n_comp e e' : connect e =2 connect e' -> n_comp_mem e =1 n_comp_mem e'. Proof. move=> eq_e [a]; apply: eq_card => x /=. by rewrite !inE /= /roots /root /= (eq_pick (eq_e x)). Qed. Lemma eq_n_comp_r {e} a a' : a =i a' -> n_comp e a = n_comp e a'. Proof. by move=> eq_a; apply: eq_card => x; rewrite inE /= eq_a. Qed. Lemma n_compC a e : n_comp e T = n_comp e a + n_comp e [predC a]. Proof. rewrite /n_comp_mem (eq_card (fun _ => andbT _)) -(cardID a); congr (_ + _). by apply: eq_card => x; rewrite !inE andbC. Qed. Lemma eq_root e e' : e =2 e' -> root e =1 root e'. Proof. by move=> eq_e x; rewrite /root (eq_pick (eq_connect eq_e x)). Qed. Lemma eq_roots e e' : e =2 e' -> roots e =1 roots e'. Proof. by move=> eq_e x; rewrite /roots (eq_root eq_e). Qed. Lemma connect_rev e : connect [rel x y | e y x] =2 [rel x y | connect e y x]. Proof. suff crev e': subrel (connect [rel x y | e' y x]) [rel x y | connect e' y x]. by move=> x y; apply/idP/idP; apply: crev. move=> x y /connectP[p e_p p_y]; apply/connectP. exists (rev (belast x p)); first by rewrite p_y rev_path. by rewrite -(last_cons x) -rev_rcons p_y -lastI rev_cons last_rcons. Qed. Lemma sym_connect_sym e : symmetric e -> connect_sym e. Proof. by move=> sym_e x y; rewrite (eq_connect sym_e) connect_rev. Qed. End EqConnect. Arguments eq_connect [T e e']. Arguments connect_rev [T]. Section Closure. Variables (T : finType) (e : rel T). Hypothesis sym_e : connect_sym e. Implicit Type a : {pred T}. Lemma same_connect_rev : connect e =2 connect [rel x y | e y x]. Proof. by move=> x y; rewrite sym_e connect_rev. Qed. Lemma intro_closed a : (forall x y, e x y -> x \in a -> y \in a) -> closed e a. Proof. move=> cl_a x y e_xy; apply/idP/idP=> [|a_y]; first exact: cl_a. have{x e_xy} /connectP[p e_p ->]: connect e y x by rewrite sym_e connect1. by elim: p y a_y e_p => //= y p IHp x a_x /andP[/cl_a/(_ a_x)]; apply: IHp. Qed. Lemma closed_connect a : closed e a -> forall x y, connect e x y -> (x \in a) = (y \in a). Proof. move=> cl_a x _ /connectP[p e_p ->]. by elim: p x e_p => //= y p IHp x /andP[/cl_a->]; apply: IHp. Qed. Lemma connect_closed x : closed e (connect e x). Proof. by move=> y z /connect1/same_connect_r; apply. Qed. Lemma predC_closed a : closed e a -> closed e [predC a]. Proof. by move=> cl_a x y /cl_a /[!inE] ->. Qed. Lemma closure_closed a : closed e (closure e a). Proof. apply: intro_closed => x y /connect1 e_xy; congr (~~ _). by apply: eq_disjoint; apply: same_connect. Qed. Lemma mem_closure a : {subset a <= closure e a}. Proof. by move=> x a_x; apply/existsP; exists x; rewrite !inE connect0. Qed. Lemma subset_closure a : a \subset closure e a. Proof. by apply/subsetP; apply: mem_closure. Qed. Lemma n_comp_closure2 x y : n_comp e (closure e (pred2 x y)) = (~~ connect e x y).+1. Proof. rewrite -(root_connect sym_e) -card2; apply: eq_card => z. apply/idP/idP=> [/andP[/eqP {2}<- /pred0Pn[t /andP[/= ezt exyt]]] |]. by case/pred2P: exyt => <-; rewrite (rootP sym_e ezt) !inE eqxx ?orbT. by case/pred2P=> ->; rewrite !inE roots_root //; apply/existsP; [exists x | exists y]; rewrite !inE eqxx ?orbT sym_e connect_root. Qed. Lemma n_comp_connect x : n_comp e (connect e x) = 1. Proof. rewrite -(card1 (root e x)); apply: eq_card => y. apply/andP/eqP => [[/eqP r_y /rootP-> //] | ->] /=. by rewrite inE connect_root roots_root. Qed. End Closure. Arguments same_connect_rev [T e]. Section Orbit. Variables (T : finType) (f : T -> T). Definition order x := #|fconnect f x|. Definition orbit x := traject f x (order x). Definition findex x y := index y (orbit x). Definition finv x := iter (order x).-1 f x. Lemma fconnect_iter n x : fconnect f x (iter n f x). Proof. apply/connectP. by exists (traject f (f x) n); [apply: fpath_traject | rewrite last_traject]. Qed. Lemma fconnect1 x : fconnect f x (f x). Proof. exact: (fconnect_iter 1). Qed. Lemma fconnect_finv x : fconnect f x (finv x). Proof. exact: fconnect_iter. Qed. Lemma orderSpred x : (order x).-1.+1 = order x. Proof. by rewrite /order (cardD1 x) [_ x _]connect0. Qed. Lemma size_orbit x : size (orbit x) = order x. Proof. exact: size_traject. Qed. Lemma looping_order x : looping f x (order x). Proof. apply: contraFT (ltnn (order x)); rewrite -looping_uniq => /card_uniqP. rewrite size_traject => <-; apply: subset_leq_card. by apply/subsetP=> _ /trajectP[i _ ->]; apply: fconnect_iter. Qed. Lemma fconnect_orbit x y : fconnect f x y = (y \in orbit x). Proof. apply/idP/idP=> [/connectP[_ /fpathP[m ->] ->] | /trajectP[i _ ->]]. by rewrite last_traject; apply/loopingP/looping_order. exact: fconnect_iter. Qed. Lemma in_orbit x : x \in orbit x. Proof. by rewrite -fconnect_orbit. Qed. Hint Resolve in_orbit : core. Lemma order_gt0 x : order x > 0. Proof. by rewrite -orderSpred. Qed. Hint Resolve order_gt0 : core. Lemma orbit_uniq x : uniq (orbit x). Proof. rewrite /orbit -orderSpred looping_uniq; set n := (order x).-1. apply: contraFN (ltnn n) => /trajectP[i lt_i_n eq_fnx_fix]. rewrite orderSpred -(size_traject f x n). apply: (leq_trans (subset_leq_card _) (card_size _)); apply/subsetP=> z. rewrite inE fconnect_orbit => /trajectP[j le_jn ->{z}]. rewrite -orderSpred -/n ltnS leq_eqVlt in le_jn. by apply/trajectP; case/predU1P: le_jn => [->|]; [exists i | exists j]. Qed. Lemma findex_max x y : fconnect f x y -> findex x y < order x. Proof. by rewrite [_ y]fconnect_orbit -index_mem size_orbit. Qed. Lemma findex_iter x i : i < order x -> findex x (iter i f x) = i. Proof. move=> lt_ix; rewrite -(nth_traject f lt_ix) /findex index_uniq ?orbit_uniq //. by rewrite size_orbit. Qed. Lemma iter_findex x y : fconnect f x y -> iter (findex x y) f x = y. Proof. rewrite [_ y]fconnect_orbit => fxy; pose i := index y (orbit x). have lt_ix: i < order x by rewrite -size_orbit index_mem. by rewrite -(nth_traject f lt_ix) nth_index. Qed. Lemma findex0 x : findex x x = 0. Proof. by rewrite /findex /orbit -orderSpred /= eqxx. Qed. Lemma findex_eq0 x y : (findex x y == 0) = (x == y). Proof. by rewrite /findex /orbit -orderSpred /=; case: (x == y). Qed. Lemma fconnect_invariant (T' : eqType) (k : T -> T') : invariant f k =1 xpredT -> forall x y, fconnect f x y -> k x = k y. Proof. move=> eq_k_f x y /iter_findex <-; elim: {y}(findex x y) => //= n ->. by rewrite (eqP (eq_k_f _)). Qed. Lemma mem_orbit x : {homo f : y / y \in orbit x}. Proof. by move=> y; rewrite -!fconnect_orbit => /connect_trans->//; apply: fconnect1. Qed. Lemma image_orbit x : {subset image f (orbit x) <= orbit x}. Proof. by move=> _ /mapP[y yin ->]; apply: mem_orbit; rewrite ?mem_enum in yin. Qed. Section orbit_in. Variable S : {pred T}. Hypothesis f_in : {homo f : x / x \in S}. Hypothesis injf : {in S &, injective f}. Lemma finv_in : {homo finv : x / x \in S}. Proof. by move=> x xS; rewrite iter_in. Qed. Lemma f_finv_in : {in S, cancel finv f}. Proof. move=> x xS; move: (looping_order x) (orbit_uniq x). rewrite /looping /orbit -orderSpred looping_uniq /= /looping; set n := _.-1. case/predU1P=> // /trajectP[i lt_i_n]; rewrite -iterSr. by move=> /injf ->; rewrite ?(iter_in _ f_in) //; case/trajectP; exists i. Qed. Lemma finv_f_in : {in S, cancel f finv}. Proof. by move=> x xS; apply/injf; rewrite ?iter_in ?f_finv_in ?f_in. Qed. Lemma finv_inj_in : {in S &, injective finv}. Proof. by move=> x y xS yS q; rewrite -(f_finv_in xS) q f_finv_in. Qed. Lemma fconnect_sym_in : {in S &, forall x y, fconnect f x y = fconnect f y x}. Proof. suff Sf : {in S &, forall x y, fconnect f x y -> fconnect f y x}. by move=> *; apply/idP/idP=> /Sf->. move=> x _ xS _ /connectP [p f_p ->]; elim: p => //= y p IHp in x xS f_p *. case/andP: f_p => /eqP <- /(IHp _ (f_in xS)) /connect_trans -> //. by apply: (connect_trans (fconnect_finv _)); rewrite finv_f_in. Qed. Lemma iter_order_in : {in S, forall x, iter (order x) f x = x}. Proof. by move=> x xS; rewrite -orderSpred iterS; apply: f_finv_in. Qed. Lemma iter_finv_in n : {in S, forall x, n <= order x -> iter n finv x = iter (order x - n) f x}. Proof. move=> x xS; rewrite -[x in LHS]iter_order_in => // /subnKC {1}<-. move: (_ - n) => m; rewrite iterD; elim: n => // n {2}<-. by rewrite iterSr /= finv_f_in // -iterD iter_in. Qed. Lemma cycle_orbit_in : {in S, forall x, (fcycle f) (orbit x)}. Proof. move=> x xS; rewrite /orbit -orderSpred (cycle_path x) /= last_traject. by rewrite -/(finv x) fpath_traject f_finv_in ?eqxx. Qed. Lemma fpath_finv_in p x : (x \in S) && (fpath finv x p) = (last x p \in S) && (fpath f (last x p) (rev (belast x p))). Proof. elim: p x => //= y p IHp x; rewrite rev_cons rcons_path. transitivity [&& y \in S, f y == x & fpath finv y p]. apply/and3P/and3P => -[xS /eqP<- fxp]; split; by rewrite ?f_finv_in ?finv_f_in ?finv_in ?f_in. rewrite andbCA {}IHp !andbA [RHS]andbC -andbA; congr [&& _, _ & _]. by case: p => //= z p; rewrite rev_cons last_rcons. Qed. Lemma fpath_finv_f_in p : {in S, forall x, fpath finv x p -> fpath f (last x p) (rev (belast x p))}. Proof. by move=> x xS /(conj xS)/andP; rewrite fpath_finv_in => /andP[]. Qed. Lemma fpath_f_finv_in p x : last x p \in S -> fpath f (last x p) (rev (belast x p)) -> fpath finv x p. Proof. by move=> lS /(conj lS)/andP; rewrite -fpath_finv_in => /andP[]. Qed. End orbit_in. Lemma injectivePcycle x : reflect {in orbit x &, injective f} (fcycle f (orbit x)). Proof. apply: (iffP idP) => [/inj_cycle//|/cycle_orbit_in]. by apply; [apply: mem_orbit|apply: in_orbit]. Qed. Section orbit_inj. Hypothesis injf : injective f. Lemma f_finv : cancel finv f. Proof. exact: (in1T (f_finv_in _ (in2W _))). Qed. Lemma finv_f : cancel f finv. Proof. exact: (in1T (finv_f_in _ (in2W _))). Qed. Lemma finv_bij : bijective finv. Proof. by exists f; [apply: f_finv|apply: finv_f]. Qed. Lemma finv_inj : injective finv. Proof. exact: (can_inj f_finv). Qed. Lemma fconnect_sym x y : fconnect f x y = fconnect f y x. Proof. exact: (in2T (fconnect_sym_in _ (in2W _))). Qed. Let symf := fconnect_sym. Lemma iter_order x : iter (order x) f x = x. Proof. exact: (in1T (iter_order_in _ (in2W _))). Qed. Lemma iter_finv n x : n <= order x -> iter n finv x = iter (order x - n) f x. Proof. exact: (in1T (@iter_finv_in _ _ (in2W _) _)). Qed. Lemma cycle_orbit x : fcycle f (orbit x). Proof. exact: (in1T (cycle_orbit_in _ (in2W _))). Qed. Lemma fpath_finv x p : fpath finv x p = fpath f (last x p) (rev (belast x p)). Proof. exact: (@fpath_finv_in T _ (in2W _)). Qed. Lemma same_fconnect_finv : fconnect finv =2 fconnect f. Proof. move=> x y; rewrite (same_connect_rev symf); apply: {x y}eq_connect => x y /=. by rewrite (canF_eq finv_f) eq_sym. Qed. Lemma fcard_finv : fcard_mem finv =1 fcard_mem f. Proof. exact: eq_n_comp same_fconnect_finv. Qed. Definition order_set n : pred T := [pred x | order x == n]. Lemma fcard_order_set n (a : {pred T}) : a \subset order_set n -> fclosed f a -> fcard f a * n = #|a|. Proof. move=> a_n cl_a; rewrite /n_comp_mem; set b := [predI froots f & a]. suff <-: #|preim (froot f) b| = #|b| * n. apply: eq_card => x; rewrite !inE (roots_root fconnect_sym). exact/esym/(closed_connect cl_a)/connect_root. have{cl_a a_n} (x): b x -> froot f x = x /\ order x = n. by case/andP=> /eqP-> /(subsetP a_n)/eqnP->. elim: {a b}#|b| {1 3 4}b (eqxx #|b|) => [|m IHm] b def_m f_b. by rewrite eq_card0 // => x; apply: (pred0P def_m). have [x b_x | b0] := pickP b; last by rewrite (eq_card0 b0) in def_m. have [r_x ox_n] := f_b x b_x; rewrite (cardD1 x) [x \in b]b_x eqSS in def_m. rewrite mulSn -{1}ox_n -(IHm _ def_m) => [|_ /andP[_ /f_b //]]. rewrite -(cardID (fconnect f x)); congr (_ + _); apply: eq_card => y. by apply: andb_idl => /= fxy; rewrite !inE -(rootP symf fxy) r_x. by congr (~~ _ && _); rewrite /= /in_mem /= symf -(root_connect symf) r_x. Qed. Lemma fclosed1 (a : {pred T}) : fclosed f a -> forall x, (x \in a) = (f x \in a). Proof. by move=> cl_a x; apply: cl_a (eqxx _). Qed. Lemma same_fconnect1 x : fconnect f x =1 fconnect f (f x). Proof. by apply: same_connect1 => /=. Qed. Lemma same_fconnect1_r x y : fconnect f x y = fconnect f x (f y). Proof. by apply: same_connect1r x => /=. Qed. Lemma fcard_gt0P (a : {pred T}) : fclosed f a -> reflect (exists x, x \in a) (0 < fcard f a). Proof. move=> clfA; apply: (iffP card_gt0P) => [[x /andP[]]|[x xA]]; first by exists x. exists (froot f x); rewrite inE roots_root /=; last exact: fconnect_sym. by rewrite -(closed_connect clfA (connect_root _ x)). Qed. Lemma fcard_gt1P (A : {pred T}) : fclosed f A -> reflect (exists2 x, x \in A & exists2 y, y \in A & ~~ fconnect f x y) (1 < fcard f A). Proof. move=> clAf; apply: (iffP card_gt1P) => [|[x xA [y yA not_xfy]]]. move=> [x [y [/andP [/= rfx xA] /andP[/= rfy yA] xDy]]]. by exists x; try exists y; rewrite // -root_connect // (eqP rfx) (eqP rfy). exists (froot f x), (froot f y); rewrite !inE !roots_root ?root_connect //=. by split => //; rewrite -(closed_connect clAf (connect_root _ _)). Qed. End orbit_inj. Hint Resolve orbit_uniq : core. Section fcycle_p. Variables (p : seq T) (f_p : fcycle f p). Section mem_cycle. Variable (Up : uniq p) (x : T) (p_x : x \in p). (* fconnect_cycle does not dependent on Up *) Lemma fconnect_cycle y : fconnect f x y = (y \in p). Proof. have [i q def_p] := rot_to p_x; rewrite -(mem_rot i p) def_p. have{i def_p} /andP[/eqP q_x f_q]: (f (last x q) == x) && fpath f x q. by have:= f_p; rewrite -(rot_cycle i) def_p (cycle_path x). apply/idP/idP=> [/connectP[_ /fpathP[j ->] ->] | ]; last exact: path_connect. case/fpathP: f_q q_x => n ->; rewrite !last_traject -iterS => def_x. by apply: (@loopingP _ f x n.+1); rewrite /looping def_x /= mem_head. Qed. (* order_le_cycle does not dependent on Up *) Lemma order_le_cycle : order x <= size p. Proof. apply: leq_trans (card_size _); apply/subset_leq_card/subsetP=> y. by rewrite !(fconnect_cycle, inE) ?eqxx. Qed. Lemma order_cycle : order x = size p. Proof. by rewrite -(card_uniqP Up); apply: (eq_card fconnect_cycle). Qed. Lemma orbitE : orbit x = rot (index x p) p. Proof. set i := index _ _; rewrite /orbit order_cycle -(size_rot i) rot_index// -/i. set q := _ ++ _; suffices /fpathP[j ->]: fpath f x q by rewrite /= size_traject. by move: f_p; rewrite -(rot_cycle i) rot_index// (cycle_path x); case/andP. Qed. Lemma orbit_rot_cycle : {i : nat | orbit x = rot i p}. Proof. by rewrite orbitE; exists (index x p). Qed. End mem_cycle. Let f_inj := inj_cycle f_p. Let homo_f := mem_fcycle f_p. Lemma finv_cycle : {homo finv : x / x \in p}. Proof. exact: finv_in. Qed. Lemma f_finv_cycle : {in p, cancel finv f}. Proof. exact: f_finv_in. Qed. Lemma finv_f_cycle : {in p, cancel f finv}. Proof. exact: finv_f_in. Qed. Lemma finv_inj_cycle : {in p &, injective finv}. Proof. exact: finv_inj_in. Qed. Lemma iter_finv_cycle n : {in p, forall x, n <= order x -> iter n finv x = iter (order x - n) f x}. Proof. exact: iter_finv_in. Qed. Lemma cycle_orbit_cycle : {in p, forall x, fcycle f (orbit x)}. Proof. exact: cycle_orbit_in. Qed. Lemma fpath_finv_cycle q x : (x \in p) && (fpath finv x q) = (last x q \in p) && fpath f (last x q) (rev (belast x q)). Proof. exact: fpath_finv_in. Qed. Lemma fpath_finv_f_cycle q : {in p, forall x, fpath finv x q -> fpath f (last x q) (rev (belast x q))}. Proof. exact: fpath_finv_f_in. Qed. Lemma fpath_f_finv_cycle q x : last x q \in p -> fpath f (last x q) (rev (belast x q)) -> fpath finv x q. Proof. exact: fpath_f_finv_in. Qed. Lemma prevE x : x \in p -> prev p x = finv x. Proof. move=> x_p; have /eqP/(congr1 finv) := prev_cycle f_p x_p. by rewrite finv_f_cycle// mem_prev. Qed. End fcycle_p. Section fcycle_cons. Variables (x : T) (p : seq T) (f_p : fcycle f (x :: p)). Lemma fcycle_rconsE : rcons (x :: p) x = traject f x (size p).+2. Proof. by rewrite rcons_cons; have /fpathE-> := f_p; rewrite size_rcons. Qed. Lemma fcycle_consE : x :: p = traject f x (size p).+1. Proof. by have := fcycle_rconsE; rewrite trajectSr => /rcons_inj[/= <-]. Qed. Lemma fcycle_consEflatten : exists k, x :: p = flatten (nseq k.+1 (orbit x)). Proof. move: f_p; rewrite fcycle_consE; elim/ltn_ind: (size p) => n IHn t_cycle. have := order_le_cycle t_cycle (mem_head _ _); rewrite size_traject. case: ltngtP => [||<-] //; last by exists 0; rewrite /= cats0. rewrite ltnS => n_ge _; have := t_cycle. rewrite -(subnKC n_ge) -addnS trajectD. rewrite (iter_order_in (mem_fcycle f_p) (inj_cycle f_p)) ?mem_head//. set m := (_ - _) => cycle_cat. have [||k->] := IHn m; last by exists k.+1. by rewrite ltn_subrL (leq_trans _ n_ge) ?order_gt0. move: cycle_cat; rewrite -orderSpred/= rcons_cat rcons_cons -cat_rcons. by rewrite cat_path last_rcons => /andP[]. Qed. Lemma undup_cycle_cons : undup (x :: p) = orbit x. Proof. by have [n {1}->] := fcycle_consEflatten; rewrite undup_flatten_nseq ?undup_id. Qed. End fcycle_cons. Section fcycle_undup. Variable (p : seq T) (f_p : fcycle f p). Lemma fcycleEflatten : exists k, p = flatten (nseq k (undup p)). Proof. case: p f_p => [//|x q] f_q; first by exists 0. have [k {1}->] := @fcycle_consEflatten x q f_q. by exists k.+1; rewrite undup_cycle_cons. Qed. Lemma fcycle_undup : fcycle f (undup p). Proof. case: p f_p => [//|x q] f_q; rewrite undup_cycle_cons//. by rewrite (cycle_orbit_in (mem_fcycle f_q) (inj_cycle f_q)) ?mem_head. Qed. Let p_undup_uniq := undup_uniq p. Let f_inj := inj_cycle f_p. Let homo_f := mem_fcycle f_p. Lemma in_orbit_cycle : {in p &, forall x, orbit x =i p}. Proof. by move=> x y xp yp; rewrite (orbitE fcycle_undup)// ?mem_rot ?mem_undup. Qed. Lemma eq_order_cycle : {in p &, forall x y, order y = order x}. Proof. by move=> x y xp yp; rewrite !(order_cycle fcycle_undup) ?mem_undup. Qed. Lemma iter_order_cycle : {in p &, forall x y, iter (order x) f y = y}. Proof. by move=> x y xp yp; rewrite (eq_order_cycle yp) ?(iter_order_in homo_f f_inj). Qed. End fcycle_undup. Section fconnect. Lemma fconnect_eqVf x y : fconnect f x y = (x == y) || fconnect f (f x) y. Proof. apply/idP/idP => [/iter_findex <-|/predU1P [<-|] //]; last first. exact/connect_trans/fconnect1. by case: findex => [|i]; rewrite ?eqxx// iterSr fconnect_iter orbT. Qed. (*****************************************************************************) (* Lemma orbitPcycle is of type "The Following Are Equivalent", which means *) (* all four statements are equivalent to each other. In order to use it, one *) (* has to apply it to the natural numbers corresponding to the line, e.g. *) (* `orbitPcycle 0 2 : fcycle f (orbit x) <-> exists k, iter k.+1 f x = x`. *) (* examples of this are in order_id_cycle and fconnnect_f. *) (* One may also use lemma all_iffLR to get a one sided implication, as in *) (* orderPcycle. *) (*****************************************************************************) Lemma orbitPcycle {x} : [<-> (* 0 *) fcycle f (orbit x); (* 1 *) order (f x) = order x; (* 2 *) x \in fconnect f (f x); (* 3 *) exists k, iter k.+1 f x = x; (* 4 *) iter (order x) f x = x; (* 5 *) {in orbit x &, injective f}]. Proof. tfae=> [xorbit_cycle|||[k fkx]|fx y z|/injectivePcycle//]. - by apply: eq_order_cycle xorbit_cycle _ _ _ _; rewrite ?mem_orbit. - move=> /subset_cardP/(_ _)->; rewrite ?inE//; apply/subsetP=> y. by apply: connect_trans; apply: fconnect1. - by exists (findex (f x) x); rewrite // iterSr iter_findex. - apply: (@iter_order_cycle (traject f x k.+1)); rewrite /= ?mem_head//. by apply/fpathP; exists k.+1; rewrite trajectSr -iterSr fkx. - rewrite -!fconnect_orbit => /iter_findex <- /iter_findex <-. move/(congr1 (iter (order x).-1 f)). by rewrite -!iterSr !orderSpred -!iterD ![order _ + _]addnC !iterD fx. Qed. Lemma order_id_cycle x : fcycle f (orbit x) -> order (f x) = order x. Proof. by move/(orbitPcycle 0 1). Qed. Inductive order_spec_cycle x : bool -> Type := | OrderStepCycle of fcycle f (orbit x) & order x = order (f x) : order_spec_cycle x true | OrderStepNoCycle of ~~ fcycle f (orbit x) & order x = (order (f x)).+1 : order_spec_cycle x false. Lemma orderPcycle x : order_spec_cycle x (fcycle f (orbit x)). Proof. have [xcycle|Ncycle] := boolP (fcycle f (orbit x)); constructor => //. by rewrite order_id_cycle. rewrite /order (eq_card (_ : _ =1 [predU1 x & fconnect f (f x)])). by rewrite cardU1 inE (contraNN (all_iffLR orbitPcycle 2 0)). by move=> y; rewrite !inE fconnect_eqVf eq_sym. Qed. Lemma fconnect_f x : fconnect f (f x) x = fcycle f (orbit x). Proof. by apply/idP/idP => /(orbitPcycle 0 2). Qed. Lemma fconnect_findex x y : fconnect f x y -> y != x -> findex x y = (findex (f x) y).+1. Proof. rewrite /findex fconnect_orbit /orbit -orderSpred /= inE => /orP [-> //|]. rewrite eq_sym; move=> yin /negPf->; have [_ eq_o|_ ->//] := orderPcycle x. by rewrite -(orderSpred (f x)) trajectSr -cats1 index_cat -eq_o yin. Qed. End fconnect. End Orbit. #[global] Hint Resolve in_orbit mem_orbit order_gt0 orbit_uniq : core. Prenex Implicits order orbit findex finv order_set. Arguments orbitPcycle {T f x}. Arguments same_fconnect_finv [T f]. Section FconnectId. Variable T : finType. Lemma fconnect_id (x : T) : fconnect id x =1 xpred1 x. Proof. by move=> y; rewrite (@fconnect_cycle _ _ [:: x]) //= ?inE ?eqxx. Qed. Lemma order_id (x : T) : order id x = 1. Proof. by rewrite /order (eq_card (fconnect_id x)) card1. Qed. Lemma orbit_id (x : T) : orbit id x = [:: x]. Proof. by rewrite /orbit order_id. Qed. Lemma froots_id (x : T) : froots id x. Proof. by rewrite /roots -fconnect_id connect_root. Qed. Lemma froot_id (x : T) : froot id x = x. Proof. by apply/eqP; apply: froots_id. Qed. Lemma fcard_id (a : {pred T}) : fcard id a = #|a|. Proof. by apply: eq_card => x; rewrite inE froots_id. Qed. End FconnectId. Section FconnectEq. Variables (T : finType) (f f' : T -> T). Lemma finv_eq_can : cancel f f' -> finv f =1 f'. Proof. move=> fK; have inj_f := can_inj fK. by apply: bij_can_eq fK; [apply: injF_bij | apply: finv_f]. Qed. Hypothesis eq_f : f =1 f'. Let eq_rf := eq_frel eq_f. Lemma eq_fconnect : fconnect f =2 fconnect f'. Proof. exact: eq_connect eq_rf. Qed. Lemma eq_fcard : fcard_mem f =1 fcard_mem f'. Proof. exact: eq_n_comp eq_fconnect. Qed. Lemma eq_finv : finv f =1 finv f'. Proof. by move=> x; rewrite /finv /order (eq_card (@eq_fconnect x)) (eq_iter eq_f). Qed. Lemma eq_froot : froot f =1 froot f'. Proof. exact: eq_root eq_rf. Qed. Lemma eq_froots : froots f =1 froots f'. Proof. exact: eq_roots eq_rf. Qed. End FconnectEq. Arguments eq_fconnect [T f f']. Section FinvEq. Variables (T : finType) (f : T -> T). Hypothesis injf : injective f. Lemma finv_inv : finv (finv f) =1 f. Proof. exact: (finv_eq_can (f_finv injf)). Qed. Lemma order_finv : order (finv f) =1 order f. Proof. by move=> x; apply: eq_card (@same_fconnect_finv _ _ injf x). Qed. Lemma order_set_finv n : order_set (finv f) n =i order_set f n. Proof. by move=> x; rewrite !inE order_finv. Qed. End FinvEq. Section RelAdjunction. Variables (T T' : finType) (h : T' -> T) (e : rel T) (e' : rel T'). Hypotheses (sym_e : connect_sym e) (sym_e' : connect_sym e'). Record rel_adjunction_mem m_a := RelAdjunction { rel_unit x : in_mem x m_a -> {x' : T' | connect e x (h x')}; rel_functor x' y' : in_mem (h x') m_a -> connect e' x' y' = connect e (h x') (h y') }. Variable a : {pred T}. Hypothesis cl_a : closed e a. Local Notation rel_adjunction := (rel_adjunction_mem (mem a)). Lemma intro_adjunction (h' : forall x, x \in a -> T') : (forall x a_x, [/\ connect e x (h (h' x a_x)) & forall y a_y, e x y -> connect e' (h' x a_x) (h' y a_y)]) -> (forall x' a_x, [/\ connect e' x' (h' (h x') a_x) & forall y', e' x' y' -> connect e (h x') (h y')]) -> rel_adjunction. Proof. move=> Aee' Ae'e; split=> [y a_y | x' z' a_x]. by exists (h' y a_y); case/Aee': (a_y). apply/idP/idP=> [/connectP[p e'p ->{z'}] | /connectP[p e_p p_z']]. elim: p x' a_x e'p => //= y' p IHp x' a_x. case: (Ae'e x' a_x) => _ Ae'x /andP[/Ae'x e_xy /IHp e_yz] {Ae'x}. by apply: connect_trans (e_yz _); rewrite // -(closed_connect cl_a e_xy). case: (Ae'e x' a_x) => /connect_trans-> //. elim: p {x'}(h x') p_z' a_x e_p => /= [|y p IHp] x p_z' a_x. by rewrite -p_z' in a_x *; case: (Ae'e _ a_x); rewrite sym_e'. case/andP=> e_xy /(IHp _ p_z') e'yz; have a_y: y \in a by rewrite -(cl_a e_xy). by apply: connect_trans (e'yz a_y); case: (Aee' _ a_x) => _ ->. Qed. Lemma strict_adjunction : injective h -> a \subset codom h -> rel_base h e e' [predC a] -> rel_adjunction. Proof. move=> /= injh h_a a_ee'; pose h' x Hx := iinv (subsetP h_a x Hx). apply: (@intro_adjunction h') => [x a_x | x' a_x]. rewrite f_iinv connect0; split=> // y a_y e_xy. by rewrite connect1 // -a_ee' !f_iinv ?negbK. rewrite [h' _ _]iinv_f //; split=> // y' e'xy. by rewrite connect1 // a_ee' ?negbK. Qed. Let ccl_a := closed_connect cl_a. Lemma adjunction_closed : rel_adjunction -> closed e' [preim h of a]. Proof. case=> _ Ae'e; apply: intro_closed => // x' y' /connect1 e'xy a_x. by rewrite Ae'e // in e'xy; rewrite !inE -(ccl_a e'xy). Qed. Lemma adjunction_n_comp : rel_adjunction -> n_comp e a = n_comp e' [preim h of a]. Proof. case=> Aee' Ae'e. have inj_h: {in predI (roots e') [preim h of a] &, injective (root e \o h)}. move=> x' y' /andP[/eqP r_x' /= a_x'] /andP[/eqP r_y' _] /(rootP sym_e). by rewrite -Ae'e // => /(rootP sym_e'); rewrite r_x' r_y'. rewrite /n_comp_mem -(card_in_image inj_h); apply: eq_card => x. apply/andP/imageP=> [[/eqP rx a_x] | [x' /andP[/eqP r_x' a_x'] ->]]; last first. by rewrite /= -(ccl_a (connect_root _ _)) roots_root. have [y' e_xy]:= Aee' x a_x; pose x' := root e' y'. have ay': h y' \in a by rewrite -(ccl_a e_xy). have e_yx: connect e (h y') (h x') by rewrite -Ae'e ?connect_root. exists x'; first by rewrite inE /= -(ccl_a e_yx) ?roots_root. by rewrite /= -(rootP sym_e e_yx) -(rootP sym_e e_xy). Qed. End RelAdjunction. Notation rel_adjunction h e e' a := (rel_adjunction_mem h e e' (mem a)). Notation "@ 'rel_adjunction' T T' h e e' a" := (@rel_adjunction_mem T T' h e e' (mem a)) (at level 10, T, T', h, e, e', a at level 8, only parsing) : type_scope. Notation fun_adjunction h f f' a := (rel_adjunction h (frel f) (frel f') a). Notation "@ 'fun_adjunction' T T' h f f' a" := (@rel_adjunction T T' h (frel f) (frel f') a) (at level 10, T, T', h, f, f', a at level 8, only parsing) : type_scope. Arguments intro_adjunction [T T' h e e'] _ [a]. Arguments adjunction_n_comp [T T'] h [e e'] _ _ [a]. Unset Implicit Arguments.
Lemmas.lean
/- Copyright (c) 2025 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.Lie.LieTheorem import Mathlib.Algebra.Lie.Semisimple.Basic /-! # Lemmas about semisimple Lie algebras This file is a home for lemmas about semisimple and reductive Lie algebras. ## Main definitions / results: * `LieAlgebra.hasCentralRadical_and_of_isIrreducible_of_isFaithful`: a finite-dimensional Lie algebra with a irreducible faithful finite-dimensional representation is reductive. * `LieAlgebra.hasTrivialRadical_of_isIrreducible_of_isFaithful`: a finite-dimensional Lie algebra with a irreducible faithful finite-dimensional trace-free representation is semisimple. ## TODO * Introduce a `Prop`-valued typeclass `LieModule.IsTracefree` stating `(toEnd R L M).range ≤ LieAlgebra.derivedSeries R (Module.End R M) 1`, prove `f ∈ LieAlgebra.derivedSeries k (Module.End k V) 1 ↔ LinearMap.trace k _ f = 0`, and restate `LieAlgebra.hasTrivialRadical_of_isIrreducible_of_isFaithful` using `LieModule.IsTracefree`. -/ namespace LieAlgebra open LieModule LieSubmodule Module Set variable (k L M : Type*) [Field k] [CharZero k] [LieRing L] [LieAlgebra k L] [Module.Finite k L] [AddCommGroup M] [Module k M] [LieRingModule L M] [LieModule k L M] [Module.Finite k M] [IsIrreducible k L M] [IsFaithful k L M] [IsTriangularizable k L M] lemma hasCentralRadical_and_of_isIrreducible_of_isFaithful : HasCentralRadical k L ∧ (∀ x, x ∈ center k L ↔ toEnd k L M x ∈ k ∙ LinearMap.id) := by have _i := nontrivial_of_isIrreducible k L M obtain ⟨χ, hχ⟩ : ∃ χ : Module.Dual k (radical k L), Nontrivial (weightSpace M χ) := exists_nontrivial_weightSpace_of_isSolvable k (radical k L) M let N : LieSubmodule k L M := weightSpaceOfIsLieTower k M χ replace hχ : Nontrivial N := hχ replace hχ : N = ⊤ := N.eq_top_of_isIrreducible k L M replace hχ (x : L) (hx : x ∈ radical k L) : toEnd k _ M x = χ ⟨x, hx⟩ • LinearMap.id := by ext m have hm : ∀ (y : L) (hy : y ∈ radical k L), ⁅y, m⁆ = χ ⟨y, hy⟩ • m := by simpa [N, weightSpaceOfIsLieTower, mem_weightSpace] using (hχ ▸ mem_top _ : m ∈ N) simpa using hm x hx have aux : radical k L = center k L := by refine le_antisymm (fun x hx ↦ (mem_maxTrivSubmodule k L L x).mpr ?_) (center_le_radical k L) intro y simp [← toEnd_eq_zero_iff (R := k) (L := L) (M := M), LieHom.map_lie, hχ _ hx, lie_smul, (toEnd k L M y).commute_id_right.lie_eq] refine ⟨⟨aux⟩, fun x ↦ ⟨fun hx ↦ ?_, fun hx ↦ (mem_maxTrivSubmodule k L L x).mpr fun y ↦ ?_⟩⟩ · rw [← aux] at hx exact Submodule.mem_span_singleton.mpr ⟨χ ⟨x, hx⟩, (hχ x hx).symm⟩ · obtain ⟨t, ht⟩ := Submodule.mem_span_singleton.mp hx simp [← toEnd_eq_zero_iff (R := k) (L := L) (M := M), LieHom.map_lie, ← ht, lie_smul, (toEnd k L M y).commute_id_right.lie_eq] theorem hasTrivialRadical_of_isIrreducible_of_isFaithful (h : ∀ x, LinearMap.trace k _ (toEnd k L M x) = 0) : HasTrivialRadical k L := by have : finrank k M ≠ 0 := ((finrank_pos_iff).mpr <| nontrivial_of_isIrreducible k L M).ne' obtain ⟨_i, h'⟩ := hasCentralRadical_and_of_isIrreducible_of_isFaithful k L M rw [hasTrivialRadical_iff, (hasCentralRadical_iff k L).mp inferInstance, LieSubmodule.eq_bot_iff] intro x hx specialize h x rw [h' x] at hx obtain ⟨t, ht⟩ := Submodule.mem_span_singleton.mp hx suffices t = 0 by simp [← toEnd_eq_zero_iff (R := k) (L := L) (M := M), ← ht, this] simpa [this, ← ht] using h variable {k L M} variable {R : Type*} [CommRing R] [LieAlgebra R L] [Module R M] [LieModule R L M] open LinearMap in lemma trace_toEnd_eq_zero {s : Set L} (hs : ∀ x ∈ s, LinearMap.trace R _ (toEnd R _ M x) = 0) {x : L} (hx : x ∈ LieSubalgebra.lieSpan R L s) : trace R _ (toEnd R _ M x) = 0 := by induction hx using LieSubalgebra.lieSpan_induction with | mem u hu => simpa using hs u hu | zero => simp | add u v _ _ hu hv => simp [hu, hv] | smul t u _ hu => simp [hu] | lie u v _ _ _ _ => simp end LieAlgebra
EffectiveEpi.lean
/- Copyright (c) 2024 Dagur Asgeirsson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Adam Topaz, Dagur Asgeirsson -/ import Mathlib.CategoryTheory.Sites.Coherent.Comparison import Mathlib.Topology.Category.CompHausLike.Limits /-! # Effective epimorphisms in `CompHausLike` In any category of compact Hausdorff spaces, continuous surjections are effective epimorphisms. We deduce that if the converse holds and explicit pullbacks exist, then `CompHausLike P` is preregular. If furthermore explicit finite coproducts exist, then `CompHausLike P` is precoherent. -/ universe u open CategoryTheory Limits Topology namespace CompHausLike variable {P : TopCat.{u} → Prop} /-- If `π` is a surjective morphism in `CompHausLike P`, then it is an effective epi. -/ noncomputable def effectiveEpiStruct {B X : CompHausLike P} (π : X ⟶ B) (hπ : Function.Surjective π) : EffectiveEpiStruct π where desc e h := ofHom _ ((IsQuotientMap.of_surjective_continuous hπ π.hom.continuous).lift e.hom fun a b hab ↦ CategoryTheory.congr_fun (h (ofHom _ ⟨fun _ ↦ a, continuous_const⟩) (ofHom _ ⟨fun _ ↦ b, continuous_const⟩) (by ext; exact hab)) a) fac e h := TopCat.hom_ext ((IsQuotientMap.of_surjective_continuous hπ π.hom.continuous).lift_comp e.hom fun a b hab ↦ CategoryTheory.congr_fun (h (ofHom _ ⟨fun _ ↦ a, continuous_const⟩) (ofHom _ ⟨fun _ ↦ b, continuous_const⟩) (by ext; exact hab)) a) uniq e h g hm := by suffices g = ofHom _ ((IsQuotientMap.of_surjective_continuous hπ π.hom.continuous).liftEquiv ⟨e.hom, fun a b hab ↦ CategoryTheory.congr_fun (h (ofHom _ ⟨fun _ ↦ a, continuous_const⟩) (ofHom _ ⟨fun _ ↦ b, continuous_const⟩) (by ext; exact hab)) a⟩) by assumption apply ConcreteCategory.ext rw [hom_ofHom, ← Equiv.symm_apply_eq (IsQuotientMap.of_surjective_continuous hπ π.hom.continuous).liftEquiv] ext simp only [IsQuotientMap.liftEquiv_symm_apply_coe, ContinuousMap.comp_apply, ← hm] rfl theorem preregular [HasExplicitPullbacks P] (hs : ∀ ⦃X Y : CompHausLike P⦄ (f : X ⟶ Y), EffectiveEpi f → Function.Surjective f) : Preregular (CompHausLike P) where exists_fac := by intro X Y Z f π hπ refine ⟨pullback f π, pullback.fst f π, ⟨⟨effectiveEpiStruct _ ?_⟩⟩, pullback.snd f π, (pullback.condition _ _).symm⟩ intro y obtain ⟨z, hz⟩ := hs π hπ (f y) exact ⟨⟨(y, z), hz.symm⟩, rfl⟩ theorem precoherent [HasExplicitPullbacks P] [HasExplicitFiniteCoproducts.{0} P] (hs : ∀ ⦃X Y : CompHausLike P⦄ (f : X ⟶ Y), EffectiveEpi f → Function.Surjective f) : Precoherent (CompHausLike P) := by have : Preregular (CompHausLike P) := preregular hs infer_instance end CompHausLike
IntPolynomial.lean
/- Copyright (c) 2024 María Inés de Frutos-Fernández, Filippo A. E. Nuccio. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: María Inés de Frutos-Fernández, Filippo A. E. Nuccio -/ import Mathlib.Algebra.Polynomial.AlgebraMap /-! # Polynomials over subrings. Given a field `K` with a subring `R`, in this file we construct a map from polynomials in `K[X]` with coefficients in `R` to `R[X]`. We provide several lemmas to deal with coefficients, degree, and evaluation of `Polynomial.int`. This is useful when dealing with integral elements in an extension of fields. # Main Definitions * `Polynomial.int` : given a polynomial `P` in `K[X]` whose coefficients all belong to a subring `R` of the field `K`, `P.int R` is the corresponding polynomial in `R[X]`. -/ variable {K : Type*} [Field K] (R : Subring K) open scoped Polynomial /-- Given a polynomial in `K[X]` such that all coefficients belong to the subring `R`, `Polynomial.int` is the corresponding polynomial in `R[X]`. -/ def Polynomial.int (P : K[X]) (hP : ∀ n : ℕ, P.coeff n ∈ R) : R[X] where toFinsupp := { support := P.support toFun := fun n => ⟨P.coeff n, hP n⟩ mem_support_toFun := fun n => by rw [ne_eq, ← Subring.coe_eq_zero_iff, mem_support_iff] } namespace Polynomial variable (P : K[X]) (hP : ∀ n : ℕ, P.coeff n ∈ R) @[simp] theorem int_coeff_eq (n : ℕ) : ↑((P.int R hP).coeff n) = P.coeff n := rfl @[simp] theorem int_leadingCoeff_eq : ↑(P.int R hP).leadingCoeff = P.leadingCoeff := rfl @[simp] theorem int_monic_iff : (P.int R hP).Monic ↔ P.Monic := by rw [Monic, Monic, ← int_leadingCoeff_eq, OneMemClass.coe_eq_one] @[simp] theorem int_natDegree : (P.int R hP).natDegree = P.natDegree := rfl variable {L : Type*} [Field L] [Algebra K L] @[simp] theorem int_eval₂_eq (x : L) : eval₂ (algebraMap R L) x (P.int R hP) = aeval x P := by rw [aeval_eq_sum_range, eval₂_eq_sum_range] exact Finset.sum_congr rfl (fun n _ => by rw [Algebra.smul_def]; rfl) end Polynomial
Locale.lean
/- Copyright (c) 2022 Yaël Dillies. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yaël Dillies -/ import Mathlib.Order.Category.Frm import Mathlib.Topology.Category.CompHaus.Frm /-! # The category of locales This file defines `Locale`, the category of locales. This is the opposite of the category of frames. -/ universe u open CategoryTheory Opposite Order TopologicalSpace /-- The category of locales. -/ def Locale := Frmᵒᵖ deriving LargeCategory namespace Locale instance : CoeSort Locale Type* := ⟨fun X => X.unop⟩ instance (X : Locale) : Frame X := X.unop.str /-- Construct a bundled `Locale` from a `Frame`. -/ def of (α : Type*) [Frame α] : Locale := op <| Frm.of α @[simp] theorem coe_of (α : Type*) [Frame α] : ↥(of α) = α := rfl instance : Inhabited Locale := ⟨of PUnit⟩ end Locale /-- The forgetful functor from `Top` to `Locale` which forgets that the space has "enough points". -/ @[simps!] def topToLocale : TopCat ⥤ Locale := topCatOpToFrm.rightOp -- Note, `CompHaus` is too strong. We only need `T0Space`. instance CompHausToLocale.faithful : (compHausToTop ⋙ topToLocale.{u}).Faithful := ⟨fun h => by dsimp at h exact ConcreteCategory.ext (Opens.comap_injective (congr_arg Frm.Hom.hom (Quiver.Hom.op_inj h)))⟩
PureCoherence.lean
/- Copyright (c) 2024 Yuma Mizuno. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yuma Mizuno -/ import Lean.Meta.Tactic.Apply import Mathlib.Tactic.CategoryTheory.Coherence.Datatypes /-! # Coherence tactic This file provides a meta framework for the coherence tactic, which solves goals of the form `η = θ`, where `η` and `θ` are 2-morphism in a bicategory or morphisms in a monoidal category made up only of associators, unitors, and identities. The function defined here is a meta reimplementation of the formalized coherence theorems provided in the following files: - Mathlib.CategoryTheory.Monoidal.Free.Coherence - Mathlib.CategoryTheory.Bicategory.Coherence See these files for a mathematical explanation of the proof of the coherence theorem. The actual tactics that users will use are given in - `Mathlib/Tactic/CategoryTheory/Monoidal/PureCoherence.lean` - `Mathlib/Tactic/CategoryTheory/Bicategory/PureCoherence.lean` -/ open Lean Meta namespace Mathlib.Tactic namespace BicategoryLike /-- The result of normalizing a 1-morphism. -/ structure Normalize.Result where /-- The normalized 1-morphism. -/ normalizedHom : NormalizedHom /-- The 2-morphism from the original 1-morphism to the normalized 1-morphism. -/ toNormalize : Mor₂Iso deriving Inhabited open Mor₂Iso MonadMor₂Iso variable {ρ : Type} [Context ρ] [MonadMor₁ (CoherenceM ρ)] [MonadMor₂Iso (CoherenceM ρ)] /-- Meta version of `CategoryTheory.FreeBicategory.normalizeIso`. -/ def normalize (p : NormalizedHom) (f : Mor₁) : CoherenceM ρ Normalize.Result := do match f with | .id _ _ => return ⟨p, ← rightUnitorM' p.e⟩ | .comp _ f g => let ⟨pf, η_f⟩ ← normalize p f let η_f' ← whiskerRightM η_f g let ⟨pfg, η_g⟩ ← normalize pf g let η ← comp₂M η_f' η_g let α ← symmM (← associatorM' p.e f g) let η' ← comp₂M α η return ⟨pfg, η'⟩ | .of f => let pf ← NormalizedHom.consM p f let α ← id₂M' pf.e return ⟨pf, α⟩ /-- Lemmas to prove the meta version of `CategoryTheory.FreeBicategory.normalize_naturality`. -/ class MonadNormalizeNaturality (m : Type → Type) where /-- The naturality for the associator. -/ mkNaturalityAssociator (p pf pfg pfgh : NormalizedHom) (f g h : Mor₁) (η_f η_g η_h : Mor₂Iso) : m Expr /-- The naturality for the left unitor. -/ mkNaturalityLeftUnitor (p pf : NormalizedHom) (f : Mor₁) (η_f : Mor₂Iso) : m Expr /-- The naturality for the right unitor. -/ mkNaturalityRightUnitor (p pf : NormalizedHom) (f : Mor₁) (η_f : Mor₂Iso) : m Expr /-- The naturality for the identity. -/ mkNaturalityId (p pf : NormalizedHom) (f : Mor₁) (η_f : Mor₂Iso) : m Expr /-- The naturality for the composition. -/ mkNaturalityComp (p pf : NormalizedHom) (f g h : Mor₁) (η θ η_f η_g η_h : Mor₂Iso) (ih_η ih_θ : Expr) : m Expr /-- The naturality for the left whiskering. -/ mkNaturalityWhiskerLeft (p pf pfg : NormalizedHom) (f g h : Mor₁) (η η_f η_fg η_fh : Mor₂Iso) (ih_η : Expr) : m Expr /-- The naturality for the right whiskering. -/ mkNaturalityWhiskerRight (p pf pfh : NormalizedHom) (f g h : Mor₁) (η η_f η_g η_fh : Mor₂Iso) (ih_η : Expr) : m Expr /-- The naturality for the horizontal composition. -/ mkNaturalityHorizontalComp (p pf₁ pf₁f₂ : NormalizedHom) (f₁ g₁ f₂ g₂ : Mor₁) (η θ η_f₁ η_g₁ η_f₂ η_g₂ : Mor₂Iso) (ih_η ih_θ : Expr) : m Expr /-- The naturality for the inverse. -/ mkNaturalityInv (p pf : NormalizedHom) (f g : Mor₁) (η η_f η_g : Mor₂Iso) (ih_η : Expr) : m Expr open MonadNormalizeNaturality variable [MonadCoherehnceHom (CoherenceM ρ)] [MonadNormalizeNaturality (CoherenceM ρ)] /-- Meta version of `CategoryTheory.FreeBicategory.normalize_naturality`. -/ partial def naturality (nm : Name) (p : NormalizedHom) (η : Mor₂Iso) : CoherenceM ρ Expr := do let result ← match η with | .of _ => throwError m!"could not find a structural isomorphism, but {η.e}" | .coherenceComp _ _ _ _ _ α η θ => withTraceNode nm (fun _ => return m!"monoidalComp") do let α ← MonadCoherehnceHom.unfoldM α let αθ ← comp₂M α θ let ηαθ ← comp₂M η αθ naturality nm p ηαθ | .structuralAtom η => match η with | .coherenceHom α => withTraceNode nm (fun _ => return m!"coherenceHom") do let α ← MonadCoherehnceHom.unfoldM α naturality nm p α | .associator _ f g h => withTraceNode nm (fun _ => return m!"associator") do let ⟨pf, η_f⟩ ← normalize p f let ⟨pfg, η_g⟩ ← normalize pf g let ⟨pfgh, η_h⟩ ← normalize pfg h mkNaturalityAssociator p pf pfg pfgh f g h η_f η_g η_h | .leftUnitor _ f => withTraceNode nm (fun _ => return m!"leftUnitor") do let ⟨pf, η_f⟩ ← normalize p f mkNaturalityLeftUnitor p pf f η_f | .rightUnitor _ f => withTraceNode nm (fun _ => return m!"rightUnitor") do let ⟨pf, η_f⟩ ← normalize p f mkNaturalityRightUnitor p pf f η_f | .id _ f => withTraceNode nm (fun _ => return m!"id") do let ⟨pf, η_f⟩ ← normalize p f mkNaturalityId p pf f η_f | .comp _ f g h η θ => withTraceNode nm (fun _ => return m!"comp") do let ⟨pf, η_f⟩ ← normalize p f let ⟨_, η_g⟩ ← normalize p g let ⟨_, η_h⟩ ← normalize p h let ih_η ← naturality nm p η let ih_θ ← naturality nm p θ mkNaturalityComp p pf f g h η θ η_f η_g η_h ih_η ih_θ | .whiskerLeft _ f g h η => withTraceNode nm (fun _ => return m!"whiskerLeft") do let ⟨pf, η_f⟩ ← normalize p f let ⟨pfg, η_fg⟩ ← normalize pf g let ⟨_, η_fh⟩ ← normalize pf h let ih ← naturality nm pf η mkNaturalityWhiskerLeft p pf pfg f g h η η_f η_fg η_fh ih | .whiskerRight _ f g η h => withTraceNode nm (fun _ => return m!"whiskerRight") do let ⟨pf, η_f⟩ ← normalize p f let ⟨_, η_g⟩ ← normalize p g let ⟨pfh, η_fh⟩ ← normalize pf h let ih ← naturality nm p η mkNaturalityWhiskerRight p pf pfh f g h η η_f η_g η_fh ih | .horizontalComp _ f₁ g₁ f₂ g₂ η θ => withTraceNode nm (fun _ => return m!"hComp") do let ⟨pf₁, η_f₁⟩ ← normalize p f₁ let ⟨_, η_g₁⟩ ← normalize p g₁ let ⟨pf₁f₂, η_f₂⟩ ← normalize pf₁ f₂ let ⟨_, η_g₂⟩ ← normalize pf₁ g₂ let ih_η ← naturality nm p η let ih_θ ← naturality nm pf₁ θ mkNaturalityHorizontalComp p pf₁ pf₁f₂ f₁ g₁ f₂ g₂ η θ η_f₁ η_g₁ η_f₂ η_g₂ ih_η ih_θ | .inv _ f g η => withTraceNode nm (fun _ => return m!"inv") do let ⟨pf, η_f⟩ ← normalize p f let ⟨_, η_g⟩ ← normalize p g let ih_η ← naturality nm p η mkNaturalityInv p pf f g η η_f η_g ih_η withTraceNode nm (fun _ => return m!"{checkEmoji} {← inferType result}") do if ← isTracingEnabledFor nm then addTrace nm m!"proof: {result}" return result /-- Prove the equality between structural isomorphisms using the naturality of `normalize`. -/ class MkEqOfNaturality (m : Type → Type) where /-- Auxiliary function for `pureCoherence`. -/ mkEqOfNaturality (η θ : Expr) (η' θ' : IsoLift) (η_f η_g : Mor₂Iso) (Hη Hθ : Expr) : m Expr export MkEqOfNaturality (mkEqOfNaturality) /-- Close the goal of the form `η = θ`, where `η` and `θ` are 2-isomorphisms made up only of associators, unitors, and identities. -/ def pureCoherence (ρ : Type) [Context ρ] [MkMor₂ (CoherenceM ρ)] [MonadMor₁ (CoherenceM ρ)] [MonadMor₂Iso (CoherenceM ρ)] [MonadCoherehnceHom (CoherenceM ρ)] [MonadNormalizeNaturality (CoherenceM ρ)] [MkEqOfNaturality (CoherenceM ρ)] (nm : Name) (mvarId : MVarId) : MetaM (List MVarId) := mvarId.withContext do withTraceNode nm (fun ex => match ex with | .ok _ => return m!"{checkEmoji} coherence equality: {← mvarId.getType}" | .error err => return m!"{crossEmoji} {err.toMessageData}") do let e ← instantiateMVars <| ← mvarId.getType let some (_, η, θ) := (← whnfR e).eq? | throwError "coherence requires an equality goal" let ctx : ρ ← mkContext η CoherenceM.run (ctx := ctx) do let .some ηIso := (← MkMor₂.ofExpr η).isoLift? | throwError "could not find a structural isomorphism, but {η}" let .some θIso := (← MkMor₂.ofExpr θ).isoLift? | throwError "could not find a structural isomorphism, but {θ}" let f ← ηIso.e.srcM let g ← ηIso.e.tgtM let a := f.src let nil ← normalizedHom.nilM a let ⟨_, η_f⟩ ← normalize nil f let ⟨_, η_g⟩ ← normalize nil g let Hη ← withTraceNode nm (fun ex => do return m!"{exceptEmoji ex} LHS") do naturality nm nil ηIso.e let Hθ ← withTraceNode nm (fun ex => do return m!"{exceptEmoji ex} RHS") do naturality nm nil θIso.e let H ← mkEqOfNaturality η θ ηIso θIso η_f η_g Hη Hθ mvarId.apply H end Mathlib.Tactic.BicategoryLike
polyXY.v
(* (c) Copyright 2006-2016 Microsoft Corporation and Inria. *) (* Distributed under the terms of CeCILL-B. *) From HB Require Import structures. From mathcomp Require Import ssreflect ssrfun ssrbool eqtype choice ssrnat seq. From mathcomp Require Import fintype tuple finfun bigop fingroup perm div. From mathcomp Require Import ssralg zmodp matrix mxalgebra. From mathcomp Require Import poly polydiv mxpoly binomial. (******************************************************************************) (* This file provides additional primitives and theory for bivariate *) (* polynomials (polynomials of two variables), represented as polynomials *) (* with (univariate) polynomial coefficients : *) (* 'Y == the (generic) second variable (:= 'X%:P). *) (* p^:P == the bivariate polynomial p['X], for p univariate. *) (* := map_poly polyC p (this notation is defined in poly.v). *) (* u.[x, y] == the bivariate polynomial u evaluated at 'X = x, 'Y = y. *) (* := u.[x%:P].[y]. *) (* sizeY u == the size of u in 'Y (1 + the 'Y-degree of u, if u != 0). *) (* := \max_(i < size u) size u`_i. *) (* swapXY u == the bivariate polynomial u['Y, 'X], for u bivariate. *) (* poly_XaY p == the bivariate polynomial p['X + 'Y], for p univariate. *) (* := p^:P \Po ('X + 'Y). *) (* poly_XmY p == the bivariate polynomial p['X * 'Y], for p univariate. *) (* := P^:P \Po ('X * 'Y). *) (* sub_annihilant p q == for univariate p, q != 0, a nonzero polynomial whose *) (* roots include all the differences of roots of p and q, in *) (* all field extensions (:= resultant (poly_XaY p) q^:P). *) (* div_annihilant p q == for polynomials p != 0, q with q.[0] != 0, a nonzero *) (* polynomial whose roots include all the quotients of roots *) (* of p by roots of q, in all field extensions *) (* (:= resultant (poly_XmY p) q^:P). *) (* The latter two "annhilants" provide uniform witnesses for an alternative *) (* proof of the closure of the algebraicOver predicate (see mxpoly.v). The *) (* fact that the annhilant does not depend on the particular choice of roots *) (* of p and q is crucial for the proof of the Primitive Element Theorem (file *) (* separable.v). *) (******************************************************************************) Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. Local Open Scope ring_scope. Import GRing.Theory. Local Notation "p ^ f" := (map_poly f p) : ring_scope. Local Notation eval := horner_eval. Notation "'Y" := 'X%:P : ring_scope. Notation "p ^:P" := (p ^ polyC) (format "p ^:P") : ring_scope. Notation "p .[ x , y ]" := (p.[x%:P].[y]) (left associativity, format "p .[ x , y ]") : ring_scope. Section PolyXY_NzRing. Variable R : nzRingType. Implicit Types (u : {poly {poly R}}) (p q : {poly R}) (x : R). Fact swapXY_key : unit. Proof. by []. Qed. Definition swapXY_def u : {poly {poly R}} := (u ^ map_poly polyC).['Y]. Definition swapXY := locked_with swapXY_key swapXY_def. Canonical swapXY_unlockable := [unlockable fun swapXY]. Definition sizeY u : nat := \max_(i < size u) (size u`_i). Definition poly_XaY p : {poly {poly R}} := p^:P \Po ('X + 'Y). Definition poly_XmY p : {poly {poly R}} := p^:P \Po ('X * 'Y). Definition sub_annihilant p q := resultant (poly_XaY p) q^:P. Definition div_annihilant p q := resultant (poly_XmY p) q^:P. Lemma swapXY_polyC p : swapXY p%:P = p^:P. Proof. by rewrite unlock map_polyC hornerC. Qed. Lemma swapXY_X : swapXY 'X = 'Y. Proof. by rewrite unlock map_polyX hornerX. Qed. Lemma swapXY_Y : swapXY 'Y = 'X. Proof. by rewrite swapXY_polyC map_polyX. Qed. Lemma swapXY_is_zmod_morphism : zmod_morphism swapXY. Proof. by move=> u v; rewrite unlock rmorphB !hornerE. Qed. #[warning="-deprecated-since-mathcomp-2.5.0", deprecated(since="mathcomp 2.5.0", note="use `swapXY_is_zmod_morphism` instead")] Definition swapXY_is_additive := swapXY_is_zmod_morphism. HB.instance Definition _ := GRing.isZmodMorphism.Build {poly {poly R}} {poly {poly R}} swapXY swapXY_is_zmod_morphism. Lemma coef_swapXY u i j : (swapXY u)`_i`_j = u`_j`_i. Proof. elim/poly_ind: u => [|u p IHu] in i j *; first by rewrite raddf0 !coef0. rewrite raddfD !coefD /= swapXY_polyC coef_map /= !coefC coefMX. rewrite !(fun_if (fun q : {poly R} => q`_i)) coef0 -IHu; congr (_ + _). by rewrite unlock rmorphM /= map_polyX hornerMX coefMC coefMX. Qed. Lemma swapXYK : involutive swapXY. Proof. by move=> u; apply/polyP=> i; apply/polyP=> j; rewrite !coef_swapXY. Qed. Lemma swapXY_map_polyC p : swapXY p^:P = p%:P. Proof. by rewrite -swapXY_polyC swapXYK. Qed. Lemma swapXY_eq0 u : (swapXY u == 0) = (u == 0). Proof. by rewrite (inv_eq swapXYK) raddf0. Qed. Lemma swapXY_is_monoid_morphism : monoid_morphism swapXY. Proof. split=> [|u v]; first by rewrite swapXY_polyC map_polyC. apply/polyP=> i; apply/polyP=> j; rewrite coef_swapXY !coefM !coef_sum. rewrite (eq_bigr _ (fun _ _ => coefM _ _ _)) exchange_big /=. apply: eq_bigr => j1 _; rewrite coefM; apply: eq_bigr=> i1 _. by rewrite !coef_swapXY. Qed. #[warning="-deprecated-since-mathcomp-2.5.0", deprecated(since="mathcomp 2.5.0", note="use `swapXY_is_monoid_morphism` instead")] Definition swapXY_is_multiplicative := (fun g => (g.2,g.1)) swapXY_is_monoid_morphism. HB.instance Definition _ := GRing.isMonoidMorphism.Build {poly {poly R}} {poly {poly R}} swapXY swapXY_is_monoid_morphism. Lemma swapXY_is_scalable : scalable_for (map_poly polyC \; *%R) swapXY. Proof. by move=> p u /=; rewrite -mul_polyC rmorphM /= swapXY_polyC. Qed. HB.instance Definition _ := GRing.isScalable.Build {poly R} {poly {poly R}} {poly {poly R}} (map_poly polyC \; *%R) swapXY swapXY_is_scalable. Lemma swapXY_comp_poly p u : swapXY (p^:P \Po u) = p^:P \Po swapXY u. Proof. rewrite -horner_map; congr _.[_]; rewrite -!map_poly_comp /=. by apply: eq_map_poly => x; rewrite /= swapXY_polyC map_polyC. Qed. Lemma max_size_coefXY u i : size u`_i <= sizeY u. Proof. have [ltiu | /(nth_default 0)->] := ltnP i (size u); last by rewrite size_poly0. exact: (bigmax_sup (Ordinal ltiu)). Qed. Lemma max_size_lead_coefXY u : size (lead_coef u) <= sizeY u. Proof. by rewrite lead_coefE max_size_coefXY. Qed. Lemma max_size_evalX u : size u.['X] <= sizeY u + (size u).-1. Proof. rewrite horner_coef (leq_trans (size_sum _ _ _)) //; apply/bigmax_leqP=> i _. rewrite (leq_trans (size_polyMleq _ _)) // size_polyXn addnS. by rewrite leq_add ?max_size_coefXY //= -ltnS (leq_trans _ (leqSpred _)). Qed. Lemma max_size_evalC u x : size u.[x%:P] <= sizeY u. Proof. rewrite horner_coef (leq_trans (size_sum _ _ _)) //; apply/bigmax_leqP=> i _. rewrite (leq_trans (size_polyMleq _ _)) // -polyC_exp size_polyC addnC -subn1. by rewrite (leq_trans _ (max_size_coefXY _ i)) // leq_subLR leq_add2r leq_b1. Qed. Lemma sizeYE u : sizeY u = size (swapXY u). Proof. apply/eqP; rewrite eqn_leq; apply/andP; split. apply/bigmax_leqP=> /= i _; apply/leq_sizeP => j /(nth_default 0) u_j_0. by rewrite -coef_swapXY u_j_0 coef0. apply/leq_sizeP=> j le_uY_j; apply/polyP=> i; rewrite coef_swapXY coef0. by rewrite nth_default // (leq_trans _ le_uY_j) ?max_size_coefXY. Qed. Lemma sizeY_eq0 u : (sizeY u == 0) = (u == 0). Proof. by rewrite sizeYE size_poly_eq0 swapXY_eq0. Qed. Lemma sizeY_mulX u : sizeY (u * 'X) = sizeY u. Proof. rewrite !sizeYE rmorphM /= swapXY_X rreg_size //. by have /monic_comreg[_ /rreg_lead] := monicX R. Qed. Lemma swapXY_poly_XaY p : swapXY (poly_XaY p) = poly_XaY p. Proof. by rewrite swapXY_comp_poly rmorphD /= swapXY_X swapXY_Y addrC. Qed. Lemma swapXY_poly_XmY p : swapXY (poly_XmY p) = poly_XmY p. Proof. by rewrite swapXY_comp_poly rmorphM /= swapXY_X swapXY_Y commr_polyX. Qed. Lemma poly_XaY0 : poly_XaY 0 = 0. Proof. by rewrite /poly_XaY rmorph0 comp_poly0. Qed. Lemma poly_XmY0 : poly_XmY 0 = 0. Proof. by rewrite /poly_XmY rmorph0 comp_poly0. Qed. End PolyXY_NzRing. Prenex Implicits swapXY sizeY poly_XaY poly_XmY sub_annihilant div_annihilant. Prenex Implicits swapXYK. Lemma swapXY_map (R S : nzRingType) (f : {additive R -> S}) u : swapXY (u ^ map_poly f) = swapXY u ^ map_poly f. Proof. by apply/polyP=> i; apply/polyP=> j; rewrite !(coef_map, coef_swapXY). Qed. Section PolyXY_ComNzRing. Variable R : comNzRingType. Implicit Types (u : {poly {poly R}}) (p : {poly R}) (x y : R). Lemma horner_swapXY u x : (swapXY u).[x%:P] = u ^ eval x. Proof. apply/polyP=> i /=; rewrite coef_map /= /eval horner_coef coef_sum -sizeYE. rewrite (horner_coef_wide _ (max_size_coefXY u i)); apply: eq_bigr=> j _. by rewrite -polyC_exp coefMC coef_swapXY. Qed. Lemma horner_polyC u x : u.[x%:P] = swapXY u ^ eval x. Proof. by rewrite -horner_swapXY swapXYK. Qed. Lemma horner2_swapXY u x y : (swapXY u).[x, y] = u.[y, x]. Proof. by rewrite horner_swapXY -{1}(hornerC y x) horner_map. Qed. Lemma horner_poly_XaY p v : (poly_XaY p).[v] = p \Po (v + 'X). Proof. by rewrite horner_comp !hornerE. Qed. Lemma horner_poly_XmY p v : (poly_XmY p).[v] = p \Po (v * 'X). Proof. by rewrite horner_comp !hornerE. Qed. End PolyXY_ComNzRing. Section PolyXY_Idomain. Variable R : idomainType. Implicit Types (p q : {poly R}) (x y : R). Lemma size_poly_XaY p : size (poly_XaY p) = size p. Proof. by rewrite size_comp_poly2 ?size_XaddC // size_map_polyC. Qed. Lemma poly_XaY_eq0 p : (poly_XaY p == 0) = (p == 0). Proof. by rewrite -!size_poly_eq0 size_poly_XaY. Qed. Lemma size_poly_XmY p : size (poly_XmY p) = size p. Proof. by rewrite size_comp_poly2 ?size_XmulC ?polyX_eq0 ?size_map_polyC. Qed. Lemma poly_XmY_eq0 p : (poly_XmY p == 0) = (p == 0). Proof. by rewrite -!size_poly_eq0 size_poly_XmY. Qed. Lemma lead_coef_poly_XaY p : lead_coef (poly_XaY p) = (lead_coef p)%:P. Proof. rewrite lead_coef_comp ?size_XaddC // -['Y]opprK -polyCN lead_coefXsubC. by rewrite expr1n mulr1 lead_coef_map_inj //; apply: polyC_inj. Qed. Lemma sub_annihilant_in_ideal p q : 1 < size p -> 1 < size q -> {uv : {poly {poly R}} * {poly {poly R}} | size uv.1 < size q /\ size uv.2 < size p & forall x y, (sub_annihilant p q).[y] = uv.1.[x, y] * p.[x + y] + uv.2.[x, y] * q.[x]}. Proof. rewrite -size_poly_XaY -(size_map_polyC q) => p1_gt1 q1_gt1. have [uv /= [ub_u ub_v Dr]] := resultant_in_ideal p1_gt1 q1_gt1. exists uv => // x y; rewrite -[r in r.[y]](hornerC _ x%:P) Dr. by rewrite !(hornerE, horner_comp). Qed. Lemma sub_annihilantP p q x y : p != 0 -> q != 0 -> p.[x] = 0 -> q.[y] = 0 -> (sub_annihilant p q).[x - y] = 0. Proof. move=> nz_p nz_q px0 qy0. have p_gt1: size p > 1 by have /rootP/root_size_gt1-> := px0. have q_gt1: size q > 1 by have /rootP/root_size_gt1-> := qy0. have [uv /= _ /(_ y)->] := sub_annihilant_in_ideal p_gt1 q_gt1. by rewrite (addrC y) subrK px0 qy0 !mulr0 addr0. Qed. Lemma sub_annihilant_neq0 p q : p != 0 -> q != 0 -> sub_annihilant p q != 0. Proof. rewrite resultant_eq0; set p1 := poly_XaY p => nz_p nz_q. have [nz_p1 nz_q1]: p1 != 0 /\ q^:P != 0 by rewrite poly_XaY_eq0 map_polyC_eq0. rewrite -leqNgt eq_leq //; apply/eqP/Bezout_coprimepPn=> // [[[u v]]] /=. rewrite !size_poly_gt0 -andbA => /and4P[nz_u ltuq nz_v _] Duv. have /eqP/= := congr1 (size \o (lead_coef \o swapXY)) Duv. rewrite ltn_eqF // !rmorphM !lead_coefM (leq_trans (leq_ltn_trans _ ltuq)) //=. rewrite -{2}[u]swapXYK -sizeYE swapXY_poly_XaY lead_coef_poly_XaY. by rewrite mulrC mul_polyC size_scale ?max_size_lead_coefXY ?lead_coef_eq0. rewrite swapXY_map_polyC lead_coefC size_map_polyC. set v1 := lead_coef _; have nz_v1: v1 != 0 by rewrite lead_coef_eq0 swapXY_eq0. rewrite [leqRHS]polySpred ?mulf_neq0 // size_mul //. by rewrite (polySpred nz_v1) addnC addnS polySpred // ltnS leq_addr. Qed. Lemma div_annihilant_in_ideal p q : 1 < size p -> 1 < size q -> {uv : {poly {poly R}} * {poly {poly R}} | size uv.1 < size q /\ size uv.2 < size p & forall x y, (div_annihilant p q).[y] = uv.1.[x, y] * p.[x * y] + uv.2.[x, y] * q.[x]}. Proof. rewrite -size_poly_XmY -(size_map_polyC q) => p1_gt1 q1_gt1. have [uv /= [ub_u ub_v Dr]] := resultant_in_ideal p1_gt1 q1_gt1. exists uv => // x y; rewrite -[r in r.[y]](hornerC _ x%:P) Dr. by rewrite !(hornerE, horner_comp). Qed. Lemma div_annihilant_neq0 p q : p != 0 -> q.[0] != 0 -> div_annihilant p q != 0. Proof. have factorX u: u != 0 -> root u 0 -> exists2 v, v != 0 & u = v * 'X. move=> nz_u /factor_theorem[v]; rewrite subr0 => Du; exists v => //. by apply: contraNneq nz_u => v0; rewrite Du v0 mul0r. have nzX: 'X != 0 := monic_neq0 (monicX _); have rootC0 := root_polyC _ 0. rewrite resultant_eq0 -leqNgt -rootE // => nz_p nz_q0; apply/eq_leq/eqP. have nz_q: q != 0 by apply: contraNneq nz_q0 => ->; rewrite root0. apply/Bezout_coprimepPn; rewrite ?map_polyC_eq0 ?poly_XmY_eq0 // => [[uv]]. rewrite !size_poly_gt0 -andbA ltnNge => /and4P[nz_u /negP ltuq nz_v _] Duv. pose u := swapXY uv.1; pose v := swapXY uv.2. suffices{ltuq}: size q <= sizeY u by rewrite sizeYE swapXYK -size_map_polyC. have{nz_u nz_v} [nz_u nz_v Dvu]: [/\ u != 0, v != 0 & q *: v = u * poly_XmY p]. rewrite !swapXY_eq0; split=> //; apply: (can_inj swapXYK). by rewrite linearZ rmorphM /= !swapXYK swapXY_poly_XmY Duv mulrC. have{Duv} [n ltvn]: {n | size v < n} by exists (size v).+1. elim: n {uv} => // n IHn in p (v) (u) nz_u nz_v Dvu nz_p ltvn *. have Dp0: root (poly_XmY p) 0 = root p 0 by rewrite root_comp !hornerE rootC0. have Dv0: root u 0 || root p 0 = root v 0 by rewrite -Dp0 -rootM -Dvu rootZ. have [v0_0 | nz_v0] := boolP (root v 0); last first. have nz_p0: ~~ root p 0 by apply: contra nz_v0; rewrite -Dv0 orbC => ->. apply: (@leq_trans (size (q * v.[0]))). by rewrite size_mul // (polySpred nz_v0) addnS leq_addr. rewrite -hornerZ Dvu !(horner_comp, hornerE) horner_map mulrC size_Cmul //. by rewrite horner_coef0 max_size_coefXY. have [v1 nz_v1 Dv] := factorX _ _ nz_v v0_0; rewrite Dv size_mulX // in ltvn. have /orP[/factorX[//|u1 nz_u1 Du] | p0_0]: root u 0 || root p 0 by rewrite Dv0. rewrite Du sizeY_mulX; apply: IHn nz_u1 nz_v1 _ nz_p ltvn. by apply: (mulIf (nzX _)); rewrite mulrAC -scalerAl -Du -Dv. have /factorX[|v2 nz_v2 Dv1]: root (swapXY v1) 0; rewrite ?swapXY_eq0 //. suffices: root (swapXY v1 * 'Y) 0 by rewrite mulrC mul_polyC rootZ ?polyX_eq0. have: root (swapXY (q *: v)) 0. by rewrite Dvu rmorphM rootM /= swapXY_poly_XmY Dp0 p0_0 orbT. by rewrite linearZ /= rootM rootC0 (negPf nz_q0) /= Dv rmorphM /= swapXY_X. rewrite ltnS (canRL swapXYK Dv1) -sizeYE sizeY_mulX sizeYE in ltvn. have [p1 nz_p1 Dp] := factorX _ _ nz_p p0_0. apply: IHn nz_u _ _ nz_p1 ltvn; first by rewrite swapXY_eq0. have: 'X * 'Y != 0 :> {poly {poly R}} by rewrite mulf_neq0 ?polyC_eq0 ?nzX. move/mulIf; apply. rewrite -scalerAl mulrA mulrAC -{1}swapXY_X -rmorphM /= -Dv1 swapXYK -Dv Dvu. by rewrite /poly_XmY Dp rmorphM /= map_polyX comp_polyM comp_polyX mulrA. Qed. End PolyXY_Idomain. Section PolyXY_Field. Variables (F E : fieldType) (FtoE : {rmorphism F -> E}). Local Notation pFtoE := (map_poly (GRing.RMorphism.sort FtoE)). Lemma div_annihilantP (p q : {poly E}) (x y : E) : p != 0 -> q != 0 -> y != 0 -> p.[x] = 0 -> q.[y] = 0 -> (div_annihilant p q).[x / y] = 0. Proof. move=> nz_p nz_q nz_y px0 qy0. have p_gt1: size p > 1 by have /rootP/root_size_gt1-> := px0. have q_gt1: size q > 1 by have /rootP/root_size_gt1-> := qy0. have [uv /= _ /(_ y)->] := div_annihilant_in_ideal p_gt1 q_gt1. by rewrite (mulrC y) divfK // px0 qy0 !mulr0 addr0. Qed. Lemma map_sub_annihilantP (p q : {poly F}) (x y : E) : p != 0 -> q != 0 ->(p ^ FtoE).[x] = 0 -> (q ^ FtoE).[y] = 0 -> (sub_annihilant p q ^ FtoE).[x - y] = 0. Proof. move=> nz_p nz_q px0 qy0; have pFto0 := map_poly_eq0 FtoE. rewrite map_resultant ?pFto0 ?lead_coef_eq0 ?map_poly_eq0 ?poly_XaY_eq0 //. rewrite map_comp_poly rmorphD /= map_polyC /= !map_polyX -!map_poly_comp /=. by rewrite !(eq_map_poly (map_polyC _)) !map_poly_comp sub_annihilantP ?pFto0. Qed. Lemma map_div_annihilantP (p q : {poly F}) (x y : E) : p != 0 -> q != 0 -> y != 0 -> (p ^ FtoE).[x] = 0 -> (q ^ FtoE).[y] = 0 -> (div_annihilant p q ^ FtoE).[x / y] = 0. Proof. move=> nz_p nz_q nz_y px0 qy0; have pFto0 := map_poly_eq0 FtoE. rewrite map_resultant ?pFto0 ?lead_coef_eq0 ?map_poly_eq0 ?poly_XmY_eq0 //. rewrite map_comp_poly rmorphM /= map_polyC /= !map_polyX -!map_poly_comp /=. by rewrite !(eq_map_poly (map_polyC _)) !map_poly_comp div_annihilantP ?pFto0. Qed. Lemma root_annihilant x p (pEx := (p ^ pFtoE).[x%:P]) : pEx != 0 -> algebraicOver FtoE x -> exists2 r : {poly F}, r != 0 & forall y, root pEx y -> root (r ^ FtoE) y. Proof. move=> nz_px [q nz_q qx0]. have [/size1_polyC Dp | p_gt1] := leqP (size p) 1. by rewrite {}/pEx Dp map_polyC hornerC map_poly_eq0 in nz_px *; exists p`_0. have nz_p: p != 0 by rewrite -size_poly_gt0 ltnW. have [m le_qm] := ubnP (size q); elim: m => // m IHm in q le_qm nz_q qx0 *. have nz_q1: q^:P != 0 by rewrite map_poly_eq0. have sz_q1: size q^:P = size q by rewrite size_map_polyC. have q1_gt1: size q^:P > 1. by rewrite sz_q1 -(size_map_poly FtoE) (root_size_gt1 _ qx0) ?map_poly_eq0. have [uv _ Dr] := resultant_in_ideal p_gt1 q1_gt1; set r := resultant p _ in Dr. have /eqP q1x0: (q^:P ^ pFtoE).[x%:P] == 0. by rewrite -swapXY_polyC -swapXY_map horner_swapXY !map_polyC polyC_eq0. have [|r_nz] := boolP (r == 0); last first. exists r => // y pxy0; rewrite -[r ^ _](hornerC _ x%:P) -map_polyC Dr. by rewrite rmorphD !rmorphM !hornerE q1x0 mulr0 addr0 rootM pxy0 orbT. rewrite resultant_eq0 => /gtn_eqF/Bezout_coprimepPn[]// [q2 p1] /=. rewrite size_poly_gt0 sz_q1 => /andP[/andP[nz_q2 ltq2] _] Dq. pose n := (size (lead_coef q2)).-1; pose q3 := map_poly (coefp n) q2. have nz_q3: q3 != 0 by rewrite map_poly_eq0_id0 ?lead_coef_eq0. apply: (IHm q3); rewrite ?(leq_ltn_trans (size_poly _ _)) ?(leq_trans ltq2) //. have /polyP/(_ n)/eqP: (q2 ^ pFtoE).[x%:P] = 0. apply: (mulIf nz_px); rewrite -hornerM -rmorphM Dq rmorphM hornerM /= q1x0. by rewrite mul0r mulr0. rewrite coef0; congr (_ == 0); rewrite !horner_coef coef_sum. rewrite size_map_poly !size_map_poly_id0 ?map_poly_eq0 ?lead_coef_eq0 //. by apply: eq_bigr => i _; rewrite -rmorphXn coefMC !coef_map. Qed. Lemma algebraic_root_polyXY x y : (let pEx p := (p ^ map_poly FtoE).[x%:P] in exists2 p, pEx p != 0 & root (pEx p) y) -> algebraicOver FtoE x -> algebraicOver FtoE y. Proof. by case=> p nz_px pxy0 /(root_annihilant nz_px)[r]; exists r; auto. Qed. End PolyXY_Field.
test_regular_conv.v
From mathcomp Require Import all_boot all_order all_algebra all_field. Section regular. Import GRing. Goal forall R : ringType, [the lalgType R of R^o] = R :> ringType. Proof. by move=> [? []]. Qed. Goal forall R : comRingType, [the algType R of R^o] = R :> ringType. Proof. by move=> [? []]. Qed. Goal forall R : comRingType, [the comAlgType R of R^o] = R :> ringType. Proof. by move=> [? []]. Qed. Goal forall R : comUnitRingType, [the unitAlgType R of R^o] = R :> unitRingType. Proof. by move=> [? []]. Qed. Goal forall R : comUnitRingType, [the comUnitAlgType R of R^o] = R :> comUnitRingType. Proof. by move=> [? []]. Qed. Goal forall R : comUnitRingType, [the falgType R of R^o] = R :> unitRingType. Proof. by move=> [? []]. Qed. Goal forall K : fieldType, [the fieldExtType K of K^o] = K :> fieldType. Proof. by move=> [? []]. Qed. End regular.
cyclic.v
(* (c) Copyright 2006-2016 Microsoft Corporation and Inria. *) (* Distributed under the terms of CeCILL-B. *) From HB Require Import structures. From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice. From mathcomp Require Import div fintype bigop prime finset fingroup morphism. From mathcomp Require Import perm automorphism quotient gproduct ssralg. From mathcomp Require Import finalg zmodp poly. (******************************************************************************) (* Properties of cyclic groups. *) (* Definitions: *) (* Defined in fingroup.v: *) (* <[x]> == the cycle (cyclic group) generated by x. *) (* #[x] == the order of x, i.e., the cardinal of <[x]>. *) (* Defined in prime.v: *) (* totient n == Euler's totient function *) (* Definitions in this file: *) (* cyclic G <=> G is a cyclic group. *) (* metacyclic G <=> G is a metacyclic group (i.e., a cyclic extension of a *) (* cyclic group). *) (* generator G x <=> x is a generator of the (cyclic) group G. *) (* Zpm x == the isomorphism mapping the additive group of integers *) (* mod #[x] to the cyclic group <[x]>. *) (* cyclem x n == the endomorphism y |-> y ^+ n of <[x]>. *) (* Zp_unitm x == the isomorphism mapping the multiplicative group of the *) (* units of the ring of integers mod #[x] to the group of *) (* automorphisms of <[x]> (i.e., Aut <[x]>). *) (* Zp_unitm x maps u to cyclem x u. *) (* eltm dvd_y_x == the smallest morphism (with domain <[x]>) mapping x to *) (* y, given a proof dvd_y_x : #[y] %| #[x]. *) (* expg_invn G k == if coprime #|G| k, the inverse of exponent k in G. *) (* Basic results for these notions, plus the classical result that any finite *) (* group isomorphic to a subgroup of a field is cyclic, hence that Aut G is *) (* cyclic when G is of prime order. *) (******************************************************************************) Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. Import GroupScope GRing.Theory. (***********************************************************************) (* Cyclic groups. *) (***********************************************************************) Section Cyclic. Variable gT : finGroupType. Implicit Types (a x y : gT) (A B : {set gT}) (G K H : {group gT}). Definition cyclic A := [exists x, A == <[x]>]. Lemma cyclicP A : reflect (exists x, A = <[x]>) (cyclic A). Proof. exact: exists_eqP. Qed. Lemma cycle_cyclic x : cyclic <[x]>. Proof. by apply/cyclicP; exists x. Qed. Lemma cyclic1 : cyclic [1 gT]. Proof. by rewrite -cycle1 cycle_cyclic. Qed. (***********************************************************************) (* Isomorphism with the additive group *) (***********************************************************************) Section Zpm. Variable a : gT. Definition Zpm (i : 'Z_#[a]) := a ^+ i. Lemma ZpmM : {in Zp #[a] &, {morph Zpm : x y / x * y}}. Proof. rewrite /Zpm; case: (eqVneq a 1) => [-> | nta] i j _ _. by rewrite !expg1n ?mulg1. by rewrite /= {3}Zp_cast ?order_gt1 // expg_mod_order expgD. Qed. Canonical Zpm_morphism := Morphism ZpmM. Lemma im_Zpm : Zpm @* Zp #[a] = <[a]>. Proof. apply/eqP; rewrite eq_sym eqEcard cycle_subG /= andbC morphimEdom. rewrite (leq_trans (leq_imset_card _ _)) ?card_Zp //= /Zp order_gt1. case: eqP => /= [a1 | _]; first by rewrite imset_set1 morph1 a1 set11. by apply/imsetP; exists 1%R; rewrite ?expg1 ?inE. Qed. Lemma injm_Zpm : 'injm Zpm. Proof. apply/injmP/dinjectiveP/card_uniqP. rewrite size_map -cardE card_Zp //= {7}/order -im_Zpm morphimEdom /=. by apply: eq_card => x; apply/imageP/imsetP=> [] [i Zp_i ->]; exists i. Qed. Lemma eq_expg_mod_order m n : (a ^+ m == a ^+ n) = (m == n %[mod #[a]]). Proof. have [->|] := eqVneq a 1; first by rewrite order1 !modn1 !expg1n eqxx. rewrite -order_gt1 => lt1a; have ZpT: Zp #[a] = setT by rewrite /Zp lt1a. have: injective Zpm by move=> i j; apply (injmP injm_Zpm); rewrite /= ZpT inE. move/inj_eq=> eqZ; symmetry; rewrite -(Zp_cast lt1a). by rewrite -[_ == _](eqZ (inZp m) (inZp n)) /Zpm /= Zp_cast ?expg_mod_order. Qed. Lemma eq_expg_ord d (m n : 'I_d) : d <= #[a]%g -> (a ^+ m == a ^+ n) = (m == n). Proof. by move=> d_leq; rewrite eq_expg_mod_order !modn_small// (leq_trans _ d_leq). Qed. Lemma expgD_Zp d (n m : 'Z_d) : (d > 0)%N -> #[a]%g %| d -> a ^+ (n + m)%R = a ^+ n * a ^+ m. Proof. move=> d_gt0 xdvd; apply/eqP; rewrite -expgD eq_expg_mod_order/= modn_dvdm//. by case: d d_gt0 {m n} xdvd => [|[|[]]]//= _; rewrite dvdn1 => /eqP->. Qed. Lemma Zp_isom : isom (Zp #[a]) <[a]> Zpm. Proof. by apply/isomP; rewrite injm_Zpm im_Zpm. Qed. Lemma Zp_isog : isog (Zp #[a]) <[a]>. Proof. exact: isom_isog Zp_isom. Qed. End Zpm. (***********************************************************************) (* Central and direct product of cycles *) (***********************************************************************) Lemma cyclic_abelian A : cyclic A -> abelian A. Proof. by case/cyclicP=> a ->; apply: cycle_abelian. Qed. Lemma cycleMsub a b : commute a b -> coprime #[a] #[b] -> <[a]> \subset <[a * b]>. Proof. move=> cab co_ab; apply/subsetP=> _ /cycleP[k ->]. apply/cycleP; exists (chinese #[a] #[b] k 0); symmetry. rewrite expgMn // -expg_mod_order chinese_modl // expg_mod_order. by rewrite /chinese addn0 -mulnA mulnCA expgM expg_order expg1n mulg1. Qed. Lemma cycleM a b : commute a b -> coprime #[a] #[b] -> <[a * b]> = <[a]> * <[b]>. Proof. move=> cab co_ab; apply/eqP; rewrite eqEsubset -(cent_joinEl (cents_cycle cab)). rewrite join_subG {3}cab !cycleMsub // 1?coprime_sym //. by rewrite -genM_join cycle_subG mem_gen // imset2_f ?cycle_id. Qed. Lemma cyclicM A B : cyclic A -> cyclic B -> B \subset 'C(A) -> coprime #|A| #|B| -> cyclic (A * B). Proof. move=> /cyclicP[a ->] /cyclicP[b ->]; rewrite cent_cycle cycle_subG => cab coab. by rewrite -cycleM ?cycle_cyclic //; apply/esym/cent1P. Qed. Lemma cyclicY K H : cyclic K -> cyclic H -> H \subset 'C(K) -> coprime #|K| #|H| -> cyclic (K <*> H). Proof. by move=> cycK cycH cKH coKH; rewrite cent_joinEr // cyclicM. Qed. (***********************************************************************) (* Order properties *) (***********************************************************************) Lemma order_dvdn a n : #[a] %| n = (a ^+ n == 1). Proof. by rewrite (eq_expg_mod_order a n 0) mod0n. Qed. Lemma order_inf a n : a ^+ n.+1 == 1 -> #[a] <= n.+1. Proof. by rewrite -order_dvdn; apply: dvdn_leq. Qed. Lemma order_dvdG G a : a \in G -> #[a] %| #|G|. Proof. by move=> Ga; apply: cardSg; rewrite cycle_subG. Qed. Lemma expg_cardG G a : a \in G -> a ^+ #|G| = 1. Proof. by move=> Ga; apply/eqP; rewrite -order_dvdn order_dvdG. Qed. Lemma expg_znat G x k : x \in G -> x ^+ (k%:R : 'Z_(#|G|))%R = x ^+ k. Proof. case: (eqsVneq G 1) => [-> /set1P-> | ntG Gx]; first by rewrite !expg1n. apply/eqP; rewrite val_Zp_nat ?cardG_gt1 // eq_expg_mod_order. by rewrite modn_dvdm ?order_dvdG. Qed. Lemma expg_zneg G x (k : 'Z_(#|G|)) : x \in G -> x ^+ (- k)%R = x ^- k. Proof. move=> Gx; apply/eqP; rewrite eq_sym eq_invg_mul -expgD. by rewrite -(expg_znat _ Gx) natrD natr_Zp natr_negZp subrr. Qed. Lemma nt_gen_prime G x : prime #|G| -> x \in G^# -> G :=: <[x]>. Proof. move=> Gpr /setD1P[]; rewrite -cycle_subG -cycle_eq1 => ntX sXG. apply/eqP; rewrite eqEsubset sXG andbT. by apply: contraR ntX => /(prime_TIg Gpr); rewrite (setIidPr sXG) => ->. Qed. Lemma nt_prime_order p x : prime p -> x ^+ p = 1 -> x != 1 -> #[x] = p. Proof. move=> p_pr xp ntx; apply/prime_nt_dvdP; rewrite ?order_eq1 //. by rewrite order_dvdn xp. Qed. Lemma orderXdvd a n : #[a ^+ n] %| #[a]. Proof. by apply: order_dvdG; apply: mem_cycle. Qed. Lemma orderXgcd a n : #[a ^+ n] = #[a] %/ gcdn #[a] n. Proof. apply/eqP; rewrite eqn_dvd; apply/andP; split. rewrite order_dvdn -expgM -muln_divCA_gcd //. by rewrite expgM expg_order expg1n. have [-> | n_gt0] := posnP n; first by rewrite gcdn0 divnn order_gt0 dvd1n. rewrite -(dvdn_pmul2r n_gt0) divn_mulAC ?dvdn_gcdl // dvdn_lcm. by rewrite order_dvdn mulnC expgM expg_order eqxx dvdn_mulr. Qed. Lemma orderXdiv a n : n %| #[a] -> #[a ^+ n] = #[a] %/ n. Proof. by case/dvdnP=> q defq; rewrite orderXgcd {2}defq gcdnC gcdnMl. Qed. Lemma orderXexp p m n x : #[x] = (p ^ n)%N -> #[x ^+ (p ^ m)] = (p ^ (n - m))%N. Proof. move=> ox; have [n_le_m | m_lt_n] := leqP n m. rewrite -(subnKC n_le_m) subnDA subnn expnD expgM -ox. by rewrite expg_order expg1n order1. rewrite orderXdiv ox ?dvdn_exp2l ?expnB ?(ltnW m_lt_n) //. by have:= order_gt0 x; rewrite ox expn_gt0 orbC -(ltn_predK m_lt_n). Qed. Lemma orderXpfactor p k n x : #[x ^+ (p ^ k)] = n -> prime p -> p %| n -> #[x] = (p ^ k * n)%N. Proof. move=> oxp p_pr dv_p_n. suffices pk_x: p ^ k %| #[x] by rewrite -oxp orderXdiv // mulnC divnK. rewrite pfactor_dvdn // leqNgt; apply: contraL dv_p_n => lt_x_k. rewrite -oxp -p'natE // -(subnKC (ltnW lt_x_k)) expnD expgM. rewrite (pnat_dvd (orderXdvd _ _)) // -p_part // orderXdiv ?dvdn_part //. by rewrite -{1}[#[x]](partnC p) // mulKn // part_pnat. Qed. Lemma orderXprime p n x : #[x ^+ p] = n -> prime p -> p %| n -> #[x] = (p * n)%N. Proof. exact: (@orderXpfactor p 1). Qed. Lemma orderXpnat m n x : #[x ^+ m] = n -> \pi(n).-nat m -> #[x] = (m * n)%N. Proof. move=> oxm n_m; have [m_gt0 _] := andP n_m. suffices m_x: m %| #[x] by rewrite -oxm orderXdiv // mulnC divnK. apply/dvdn_partP=> // p; rewrite mem_primes => /and3P[p_pr _ p_m]. have n_p: p \in \pi(n) by apply: (pnatP _ _ n_m). have p_oxm: p %| #[x ^+ (p ^ logn p m)]. apply: dvdn_trans (orderXdvd _ m`_p^'); rewrite -expgM -p_part ?partnC //. by rewrite oxm; rewrite mem_primes in n_p; case/and3P: n_p. by rewrite (orderXpfactor (erefl _) p_pr p_oxm) p_part // dvdn_mulr. Qed. Lemma orderM a b : commute a b -> coprime #[a] #[b] -> #[a * b] = (#[a] * #[b])%N. Proof. by move=> cab co_ab; rewrite -coprime_cardMg -?cycleM. Qed. Definition expg_invn A k := (egcdn k #|A|).1. Lemma expgK G k : coprime #|G| k -> {in G, cancel (expgn^~ k) (expgn^~ (expg_invn G k))}. Proof. move=> coGk x /order_dvdG Gx; apply/eqP. rewrite -expgM (eq_expg_mod_order _ _ 1) -(modn_dvdm 1 Gx). by rewrite -(chinese_modl coGk 1 0) /chinese mul1n addn0 modn_dvdm. Qed. Lemma cyclic_dprod K H G : K \x H = G -> cyclic K -> cyclic H -> cyclic G = coprime #|K| #|H| . Proof. case/dprodP=> _ defKH cKH tiKH cycK cycH; pose m := lcmn #|K| #|H|. apply/idP/idP=> [/cyclicP[x defG] | coKH]; last by rewrite -defKH cyclicM. rewrite /coprime -dvdn1 -(@dvdn_pmul2l m) ?lcmn_gt0 ?cardG_gt0 //. rewrite muln_lcm_gcd muln1 -TI_cardMg // defKH defG order_dvdn. have /mulsgP[y z Ky Hz ->]: x \in K * H by rewrite defKH defG cycle_id. rewrite -[1]mulg1 expgMn; last exact/commute_sym/(centsP cKH). apply/eqP; congr (_ * _); apply/eqP; rewrite -order_dvdn. exact: dvdn_trans (order_dvdG Ky) (dvdn_lcml _ _). exact: dvdn_trans (order_dvdG Hz) (dvdn_lcmr _ _). Qed. (***********************************************************************) (* Generator *) (***********************************************************************) Definition generator (A : {set gT}) a := A == <[a]>. Lemma generator_cycle a : generator <[a]> a. Proof. exact: eqxx. Qed. Lemma cycle_generator a x : generator <[a]> x -> x \in <[a]>. Proof. by move/(<[a]> =P _)->; apply: cycle_id. Qed. Lemma generator_order a b : generator <[a]> b -> #[a] = #[b]. Proof. by rewrite /order => /(<[a]> =P _)->. Qed. End Cyclic. Arguments cyclic {gT} A%_g. Arguments generator {gT} A%_g a%_g. Arguments expg_invn {gT} A%_g k%_N. Arguments cyclicP {gT A}. Prenex Implicits cyclic Zpm. (* Euler's theorem *) Theorem Euler_exp_totient a n : coprime a n -> a ^ totient n = 1 %[mod n]. Proof. (case: n => [|[|n']] //; [by rewrite !modn1 | set n := n'.+2]) => co_a_n. have{co_a_n} Ua: coprime n (inZp a : 'I_n) by rewrite coprime_sym coprime_modl. have: FinRing.unit 'Z_n Ua ^+ totient n == 1. by rewrite -card_units_Zp // -order_dvdn order_dvdG ?inE. by rewrite -2!val_eqE unit_Zp_expg /= -/n modnXm => /eqP. Qed. Section Eltm. Variables (aT rT : finGroupType) (x : aT) (y : rT). Definition eltm of #[y] %| #[x] := fun x_i => y ^+ invm (injm_Zpm x) x_i. Hypothesis dvd_y_x : #[y] %| #[x]. Lemma eltmE i : eltm dvd_y_x (x ^+ i) = y ^+ i. Proof. apply/eqP; rewrite eq_expg_mod_order. have [x_le1 | x_gt1] := leqP #[x] 1. suffices: #[y] %| 1 by rewrite dvdn1 => /eqP->; rewrite !modn1. by rewrite (dvdn_trans dvd_y_x) // dvdn1 order_eq1 -cycle_eq1 trivg_card_le1. rewrite -(expg_znat i (cycle_id x)) invmE /=; last by rewrite /Zp x_gt1 inE. by rewrite val_Zp_nat // modn_dvdm. Qed. Lemma eltm_id : eltm dvd_y_x x = y. Proof. exact: (eltmE 1). Qed. Lemma eltmM : {in <[x]> &, {morph eltm dvd_y_x : x_i x_j / x_i * x_j}}. Proof. move=> _ _ /cycleP[i ->] /cycleP[j ->]. by apply/eqP; rewrite -expgD !eltmE expgD. Qed. Canonical eltm_morphism := Morphism eltmM. Lemma im_eltm : eltm dvd_y_x @* <[x]> = <[y]>. Proof. by rewrite morphim_cycle ?cycle_id //= eltm_id. Qed. Lemma ker_eltm : 'ker (eltm dvd_y_x) = <[x ^+ #[y]]>. Proof. apply/eqP; rewrite eq_sym eqEcard cycle_subG 3!inE mem_cycle /= eltmE. rewrite expg_order eqxx (orderE y) -im_eltm card_morphim setIid -orderE. by rewrite orderXdiv ?dvdn_indexg //= leq_divRL ?indexg_gt0 ?Lagrange ?subsetIl. Qed. Lemma injm_eltm : 'injm (eltm dvd_y_x) = (#[x] %| #[y]). Proof. by rewrite ker_eltm subG1 cycle_eq1 -order_dvdn. Qed. End Eltm. Section CycleSubGroup. Variable gT : finGroupType. (* Gorenstein, 1.3.1 (i) *) Lemma cycle_sub_group (a : gT) m : m %| #[a] -> [set H : {group gT} | H \subset <[a]> & #|H| == m] = [set <[a ^+ (#[a] %/ m)]>%G]. Proof. move=> m_dv_a; have m_gt0: 0 < m by apply: dvdn_gt0 m_dv_a. have oam: #|<[a ^+ (#[a] %/ m)]>| = m. apply/eqP; rewrite [#|_|]orderXgcd -(divnMr m_gt0) muln_gcdl divnK //. by rewrite gcdnC gcdnMr mulKn. apply/eqP; rewrite eqEsubset sub1set inE /= cycleX oam eqxx !andbT. apply/subsetP=> X; rewrite in_set1 inE -val_eqE /= eqEcard oam. case/andP=> sXa /eqP oX; rewrite oX leqnn andbT. apply/subsetP=> x Xx; case/cycleP: (subsetP sXa _ Xx) => k def_x. have: (x ^+ m == 1)%g by rewrite -oX -order_dvdn cardSg // gen_subG sub1set. rewrite {x Xx}def_x -expgM -order_dvdn -[#[a]](Lagrange sXa) -oX mulnC. rewrite dvdn_pmul2r // mulnK // => /dvdnP[i ->]. by rewrite mulnC expgM groupX // cycle_id. Qed. Lemma cycle_subgroup_char a (H : {group gT}) : H \subset <[a]> -> H \char <[a]>. Proof. move=> sHa; apply: lone_subgroup_char => // J sJa isoJH. have dvHa: #|H| %| #[a] by apply: cardSg. have{dvHa} /setP Huniq := esym (cycle_sub_group dvHa). move: (Huniq H) (Huniq J); rewrite !inE /=. by rewrite sHa sJa (card_isog isoJH) eqxx => /eqP<- /eqP<-. Qed. End CycleSubGroup. (***********************************************************************) (* Reflected boolean property and morphic image, injection, bijection *) (***********************************************************************) Section MorphicImage. Variables aT rT : finGroupType. Variables (D : {group aT}) (f : {morphism D >-> rT}) (x : aT). Hypothesis Dx : x \in D. Lemma morph_order : #[f x] %| #[x]. Proof. by rewrite order_dvdn -morphX // expg_order morph1. Qed. Lemma morph_generator A : generator A x -> generator (f @* A) (f x). Proof. by move/(A =P _)->; rewrite /generator morphim_cycle. Qed. End MorphicImage. Section CyclicProps. Variables gT : finGroupType. Implicit Types (aT rT : finGroupType) (G H K : {group gT}). Lemma cyclicS G H : H \subset G -> cyclic G -> cyclic H. Proof. move=> sHG /cyclicP[x defG]; apply/cyclicP. exists (x ^+ (#[x] %/ #|H|)); apply/congr_group/set1P. by rewrite -cycle_sub_group /order -defG ?cardSg // inE sHG eqxx. Qed. Lemma cyclicJ G x : cyclic (G :^ x) = cyclic G. Proof. apply/cyclicP/cyclicP=> [[y /(canRL (conjsgK x))] | [y ->]]. by rewrite -cycleJ; exists (y ^ x^-1). by exists (y ^ x); rewrite cycleJ. Qed. Lemma eq_subG_cyclic G H K : cyclic G -> H \subset G -> K \subset G -> (H :==: K) = (#|H| == #|K|). Proof. case/cyclicP=> x -> sHx sKx; apply/eqP/eqP=> [-> //| eqHK]. have def_GHx := cycle_sub_group (cardSg sHx); set GHx := [set _] in def_GHx. have []: H \in GHx /\ K \in GHx by rewrite -def_GHx !inE sHx sKx eqHK /=. by do 2!move/set1P->. Qed. Lemma cardSg_cyclic G H K : cyclic G -> H \subset G -> K \subset G -> (#|H| %| #|K|) = (H \subset K). Proof. move=> cycG sHG sKG; apply/idP/idP; last exact: cardSg. case/cyclicP: (cyclicS sKG cycG) => x defK; rewrite {K}defK in sKG *. case/dvdnP=> k ox; suffices ->: H :=: <[x ^+ k]> by apply: cycleX. apply/eqP; rewrite (eq_subG_cyclic cycG) ?(subset_trans (cycleX _ _)) //. rewrite -orderE orderXdiv orderE ox ?dvdn_mulr ?mulKn //. by have:= order_gt0 x; rewrite orderE ox; case k. Qed. Lemma sub_cyclic_char G H : cyclic G -> (H \char G) = (H \subset G). Proof. case/cyclicP=> x ->; apply/idP/idP => [/andP[] //|]. exact: cycle_subgroup_char. Qed. Lemma morphim_cyclic rT G H (f : {morphism G >-> rT}) : cyclic H -> cyclic (f @* H). Proof. move=> cycH; wlog sHG: H cycH / H \subset G. by rewrite -morphimIdom; apply; rewrite (cyclicS _ cycH, subsetIl) ?subsetIr. case/cyclicP: cycH sHG => x ->; rewrite gen_subG sub1set => Gx. by apply/cyclicP; exists (f x); rewrite morphim_cycle. Qed. Lemma quotient_cycle x H : x \in 'N(H) -> <[x]> / H = <[coset H x]>. Proof. exact: morphim_cycle. Qed. Lemma quotient_cyclic G H : cyclic G -> cyclic (G / H). Proof. exact: morphim_cyclic. Qed. Lemma quotient_generator x G H : x \in 'N(H) -> generator G x -> generator (G / H) (coset H x). Proof. by move=> Nx; apply: morph_generator. Qed. Lemma prime_cyclic G : prime #|G| -> cyclic G. Proof. case/primeP; rewrite ltnNge -trivg_card_le1. case/trivgPn=> x Gx ntx /(_ _ (order_dvdG Gx)). rewrite order_eq1 (negbTE ntx) => /eqnP oxG; apply/cyclicP. by exists x; apply/eqP; rewrite eq_sym eqEcard -oxG cycle_subG Gx leqnn. Qed. Lemma dvdn_prime_cyclic G p : prime p -> #|G| %| p -> cyclic G. Proof. move=> p_pr pG; case: (eqsVneq G 1) => [-> | ntG]; first exact: cyclic1. by rewrite prime_cyclic // (prime_nt_dvdP p_pr _ pG) -?trivg_card1. Qed. Lemma cyclic_small G : #|G| <= 3 -> cyclic G. Proof. rewrite 4!(ltnS, leq_eqVlt) -trivg_card_le1 orbA orbC. case/predU1P=> [-> | oG]; first exact: cyclic1. by apply: prime_cyclic; case/pred2P: oG => ->. Qed. End CyclicProps. Section IsoCyclic. Variables gT rT : finGroupType. Implicit Types (G H : {group gT}) (M : {group rT}). Lemma injm_cyclic G H (f : {morphism G >-> rT}) : 'injm f -> H \subset G -> cyclic (f @* H) = cyclic H. Proof. move=> injf sHG; apply/idP/idP; last exact: morphim_cyclic. by rewrite -{2}(morphim_invm injf sHG); apply: morphim_cyclic. Qed. Lemma isog_cyclic G M : G \isog M -> cyclic G = cyclic M. Proof. by case/isogP=> f injf <-; rewrite injm_cyclic. Qed. Lemma isog_cyclic_card G M : cyclic G -> isog G M = cyclic M && (#|M| == #|G|). Proof. move=> cycG; apply/idP/idP=> [isoGM | ]. by rewrite (card_isog isoGM) -(isog_cyclic isoGM) cycG /=. case/cyclicP: cycG => x ->{G} /andP[/cyclicP[y ->] /eqP oy]. by apply: isog_trans (isog_symr _) (Zp_isog y); rewrite /order oy Zp_isog. Qed. Lemma injm_generator G H (f : {morphism G >-> rT}) x : 'injm f -> x \in G -> H \subset G -> generator (f @* H) (f x) = generator H x. Proof. move=> injf Gx sHG; apply/idP/idP; last exact: morph_generator. rewrite -{2}(morphim_invm injf sHG) -{2}(invmE injf Gx). by apply: morph_generator; apply: mem_morphim. Qed. End IsoCyclic. (* Metacyclic groups. *) Section Metacyclic. Variable gT : finGroupType. Implicit Types (A : {set gT}) (G H : {group gT}). Definition metacyclic A := [exists H : {group gT}, [&& cyclic H, H <| A & cyclic (A / H)]]. Lemma metacyclicP A : reflect (exists H : {group gT}, [/\ cyclic H, H <| A & cyclic (A / H)]) (metacyclic A). Proof. exact: 'exists_and3P. Qed. Lemma metacyclic1 : metacyclic 1. Proof. by apply/existsP; exists 1%G; rewrite normal1 trivg_quotient !cyclic1. Qed. Lemma cyclic_metacyclic A : cyclic A -> metacyclic A. Proof. case/cyclicP=> x ->; apply/existsP; exists (<[x]>)%G. by rewrite normal_refl cycle_cyclic trivg_quotient cyclic1. Qed. Lemma metacyclicS G H : H \subset G -> metacyclic G -> metacyclic H. Proof. move=> sHG /metacyclicP[K [cycK nsKG cycGq]]; apply/metacyclicP. exists (H :&: K)%G; rewrite (cyclicS (subsetIr H K)) ?(normalGI sHG) //=. rewrite setIC (isog_cyclic (second_isog _)) ?(cyclicS _ cycGq) ?quotientS //. by rewrite (subset_trans sHG) ?normal_norm. Qed. End Metacyclic. Arguments metacyclic {gT} A%_g. Arguments metacyclicP {gT A}. (* Automorphisms of cyclic groups. *) Section CyclicAutomorphism. Variable gT : finGroupType. Section CycleAutomorphism. Variable a : gT. Section CycleMorphism. Variable n : nat. Definition cyclem of gT := fun x : gT => x ^+ n. Lemma cyclemM : {in <[a]> & , {morph cyclem a : x y / x * y}}. Proof. by move=> x y ax ay; apply: expgMn; apply: (centsP (cycle_abelian a)). Qed. Canonical cyclem_morphism := Morphism cyclemM. End CycleMorphism. Section ZpUnitMorphism. Variable u : {unit 'Z_#[a]}. Lemma injm_cyclem : 'injm (cyclem (val u) a). Proof. apply/subsetP=> x /setIdP[ax]; rewrite !inE -order_dvdn. have [a1 | nta] := eqVneq a 1; first by rewrite a1 cycle1 inE in ax. rewrite -order_eq1 -dvdn1; move/eqnP: (valP u) => /= <-. by rewrite dvdn_gcd [in X in X && _]Zp_cast ?order_gt1 // order_dvdG. Qed. Lemma im_cyclem : cyclem (val u) a @* <[a]> = <[a]>. Proof. apply/morphim_fixP=> //; first exact: injm_cyclem. by rewrite morphim_cycle ?cycle_id ?cycleX. Qed. Definition Zp_unitm := aut injm_cyclem im_cyclem. End ZpUnitMorphism. Lemma Zp_unitmM : {in units_Zp #[a] &, {morph Zp_unitm : u v / u * v}}. Proof. move=> u v _ _; apply: (eq_Aut (Aut_aut _ _)) => [|x a_x]. by rewrite groupM ?Aut_aut. rewrite permM !autE ?groupX //= /cyclem -expgM. rewrite -expg_mod_order modn_dvdm ?expg_mod_order //. case: (leqP #[a] 1) => [lea1 | lt1a]; last by rewrite Zp_cast ?order_dvdG. by rewrite card_le1_trivg // in a_x; rewrite (set1P a_x) order1 dvd1n. Qed. Canonical Zp_unit_morphism := Morphism Zp_unitmM. Lemma injm_Zp_unitm : 'injm Zp_unitm. Proof. have [a1 | nta] := eqVneq a 1. by rewrite subIset //= card_le1_trivg ?subxx // card_units_Zp a1 order1. apply/subsetP=> /= u /morphpreP[_ /set1P/= um1]. have{um1}: Zp_unitm u a == Zp_unitm 1 a by rewrite um1 morph1. rewrite !autE ?cycle_id // eq_expg_mod_order. by rewrite -[n in _ == _ %[mod n]]Zp_cast ?order_gt1 // !modZp inE. Qed. Lemma generator_coprime m : generator <[a]> (a ^+ m) = coprime #[a] m. Proof. rewrite /generator eq_sym eqEcard cycleX -/#[a] [#|_|]orderXgcd /=. apply/idP/idP=> [le_a_am|co_am]; last by rewrite (eqnP co_am) divn1. have am_gt0: 0 < gcdn #[a] m by rewrite gcdn_gt0 order_gt0. by rewrite /coprime eqn_leq am_gt0 andbT -(@leq_pmul2l #[a]) ?muln1 -?leq_divRL. Qed. Lemma im_Zp_unitm : Zp_unitm @* units_Zp #[a] = Aut <[a]>. Proof. rewrite morphimEdom; apply/setP=> f; pose n := invm (injm_Zpm a) (f a). apply/imsetP/idP=> [[u _ ->] | Af]; first exact: Aut_aut. have [a1 | nta] := eqVneq a 1. by rewrite a1 cycle1 Aut1 in Af; exists 1; rewrite // morph1 (set1P Af). have a_fa: <[a]> = <[f a]>. by rewrite -(autmE Af) -morphim_cycle ?im_autm ?cycle_id. have def_n: a ^+ n = f a. by rewrite -/(Zpm n) invmK // im_Zpm a_fa cycle_id. have co_a_n: coprime #[a].-2.+2 n. by rewrite {1}Zp_cast ?order_gt1 // -generator_coprime def_n; apply/eqP. exists (FinRing.unit 'Z_#[a] co_a_n); rewrite ?inE //. apply: eq_Aut (Af) (Aut_aut _ _) _ => x ax. rewrite autE //= /cyclem; case/cycleP: ax => k ->{x}. by rewrite -(autmE Af) morphX ?cycle_id //= autmE -def_n -!expgM mulnC. Qed. Lemma Zp_unit_isom : isom (units_Zp #[a]) (Aut <[a]>) Zp_unitm. Proof. by apply/isomP; rewrite ?injm_Zp_unitm ?im_Zp_unitm. Qed. Lemma Zp_unit_isog : isog (units_Zp #[a]) (Aut <[a]>). Proof. exact: isom_isog Zp_unit_isom. Qed. Lemma card_Aut_cycle : #|Aut <[a]>| = totient #[a]. Proof. by rewrite -(card_isog Zp_unit_isog) card_units_Zp. Qed. Lemma totient_gen : totient #[a] = #|[set x | generator <[a]> x]|. Proof. have [lea1 | lt1a] := leqP #[a] 1. rewrite /order card_le1_trivg // cards1 (@eq_card1 _ 1) // => x. by rewrite !inE -cycle_eq1 eq_sym. rewrite -(card_injm (injm_invm (injm_Zpm a))) /= ?im_Zpm; last first. by apply/subsetP=> x /[1!inE]; apply: cycle_generator. rewrite -card_units_Zp // cardsE card_sub morphim_invmE; apply: eq_card => /= d. by rewrite !inE /= qualifE /= /Zp lt1a inE /= generator_coprime {1}Zp_cast. Qed. Lemma Aut_cycle_abelian : abelian (Aut <[a]>). Proof. by rewrite -im_Zp_unitm morphim_abelian ?units_Zp_abelian. Qed. End CycleAutomorphism. Variable G : {group gT}. Lemma Aut_cyclic_abelian : cyclic G -> abelian (Aut G). Proof. by case/cyclicP=> x ->; apply: Aut_cycle_abelian. Qed. Lemma card_Aut_cyclic : cyclic G -> #|Aut G| = totient #|G|. Proof. by case/cyclicP=> x ->; apply: card_Aut_cycle. Qed. Lemma sum_ncycle_totient : \sum_(d < #|G|.+1) #|[set <[x]> | x in G & #[x] == d]| * totient d = #|G|. Proof. pose h (x : gT) : 'I_#|G|.+1 := inord #[x]. symmetry; rewrite -{1}sum1_card (partition_big h xpredT) //=. apply: eq_bigr => d _; set Gd := finset _. rewrite -sum_nat_const sum1dep_card -sum1_card (_ : finset _ = Gd); last first. apply/setP=> x /[!inE]; apply: andb_id2l => Gx. by rewrite /eq_op /= inordK // ltnS subset_leq_card ?cycle_subG. rewrite (partition_big_imset cycle) {}/Gd; apply: eq_bigr => C /=. case/imsetP=> x /setIdP[Gx /eqP <-] -> {C d}. rewrite sum1dep_card totient_gen; apply: eq_card => y; rewrite !inE /generator. move: Gx; rewrite andbC eq_sym -!cycle_subG /order. by case: eqP => // -> ->; rewrite eqxx. Qed. End CyclicAutomorphism. Lemma sum_totient_dvd n : \sum_(d < n.+1 | d %| n) totient d = n. Proof. case: n => [|[|n']]; try by rewrite big_mkcond !big_ord_recl big_ord0. set n := n'.+2; pose x1 : 'Z_n := 1%R. have ox1: #[x1] = n by rewrite /order -Zp_cycle card_Zp. rewrite -[rhs in _ = rhs]ox1 -[#[_]]sum_ncycle_totient [#|_|]ox1 big_mkcond /=. apply: eq_bigr => d _; rewrite -{2}ox1; case: ifP => [|ndv_dG]; last first. rewrite eq_card0 // => C; apply/imsetP=> [[x /setIdP[Gx oxd] _{C}]]. by rewrite -(eqP oxd) order_dvdG in ndv_dG. move/cycle_sub_group; set Gd := [set _] => def_Gd. rewrite (_ : _ @: _ = @gval _ @: Gd); first by rewrite imset_set1 cards1 mul1n. apply/setP=> C; apply/idP/imsetP=> [| [gC GdC ->{C}]]. case/imsetP=> x /setIdP[_ oxd] ->; exists <[x]>%G => //. by rewrite -def_Gd inE -Zp_cycle subsetT. have:= GdC; rewrite -def_Gd => /setIdP[_ /eqP <-]. by rewrite (set1P GdC) /= imset_f // inE eqxx (mem_cycle x1). Qed. Section FieldMulCyclic. (***********************************************************************) (* A classic application to finite multiplicative subgroups of fields. *) (***********************************************************************) Import GRing.Theory. Variables (gT : finGroupType) (G : {group gT}). Lemma order_inj_cyclic : {in G &, forall x y, #[x] = #[y] -> <[x]> = <[y]>} -> cyclic G. Proof. move=> ucG; apply: negbNE (contra _ (negbT (ltnn #|G|))) => ncG. rewrite -{2}[#|G|]sum_totient_dvd big_mkcond (bigD1 ord_max) ?dvdnn //=. rewrite -{1}[#|G|]sum_ncycle_totient (bigD1 ord_max) //= -addSn leq_add //. rewrite eq_card0 ?totient_gt0 ?cardG_gt0 // => C. apply/imsetP=> [[x /setIdP[Gx /eqP oxG]]]; case/cyclicP: ncG. by exists x; apply/eqP; rewrite eq_sym eqEcard cycle_subG Gx -oxG /=. elim/big_ind2: _ => // [m1 n1 m2 n2 | d _]; first exact: leq_add. set Gd := _ @: _; case: (set_0Vmem Gd) => [-> | [C]]; first by rewrite cards0. rewrite {}/Gd => /imsetP[x /setIdP[Gx /eqP <-] _ {C d}]. rewrite order_dvdG // (@eq_card1 _ <[x]>) ?mul1n // => C. apply/idP/eqP=> [|-> {C}]; last by rewrite imset_f // inE Gx eqxx. by case/imsetP=> y /setIdP[Gy /eqP/ucG->]. Qed. Lemma div_ring_mul_group_cyclic (R : unitRingType) (f : gT -> R) : f 1 = 1%R -> {in G &, {morph f : u v / u * v >-> (u * v)%R}} -> {in G^#, forall x, f x - 1 \in GRing.unit}%R -> abelian G -> cyclic G. Proof. move=> f1 fM f1P abelG. have fX n: {in G, {morph f : u / u ^+ n >-> (u ^+ n)%R}}. by case: n => // n x Gx; elim: n => //= n IHn; rewrite expgS fM ?groupX ?IHn. have fU x: x \in G -> f x \in GRing.unit. by move=> Gx; apply/unitrP; exists (f x^-1); rewrite -!fM ?groupV ?gsimp. apply: order_inj_cyclic => x y Gx Gy; set n := #[x] => yn. apply/eqP; rewrite eq_sym eqEcard -[#|_|]/n yn leqnn andbT cycle_subG /=. suff{y Gy yn} ->: <[x]> = G :&: [set z | #[z] %| n] by rewrite !inE Gy yn /=. apply/eqP; rewrite eqEcard subsetI cycle_subG {}Gx /= cardE; set rs := enum _. apply/andP; split; first by apply/subsetP=> y xy; rewrite inE order_dvdG. pose P : {poly R} := ('X^n - 1)%R; have n_gt0: n > 0 by apply: order_gt0. have szP : size P = n.+1. by rewrite size_polyDl size_polyXn ?size_polyN ?size_poly1. rewrite -ltnS -szP -(size_map f) max_ring_poly_roots -?size_poly_eq0 ?{}szP //. apply/allP=> fy /mapP[y]; rewrite mem_enum !inE order_dvdn => /andP[Gy]. move/eqP=> yn1 ->{fy}; apply/eqP. by rewrite !(hornerE, hornerXn) -fX // yn1 f1 subrr. have: uniq rs by apply: enum_uniq. have: all [in G] rs by apply/allP=> y; rewrite mem_enum; case/setIP. elim: rs => //= y rs IHrs /andP[Gy Grs] /andP[y_rs]; rewrite andbC. move/IHrs=> -> {IHrs}//; apply/allP=> _ /mapP[z rs_z ->]. have{Grs} Gz := allP Grs z rs_z; rewrite /diff_roots -!fM // (centsP abelG) //. rewrite eqxx -[f y]mul1r -(mulgKV y z) fM ?groupM ?groupV //=. rewrite -mulNr -mulrDl unitrMl ?fU ?f1P // !inE. by rewrite groupM ?groupV // andbT -eq_mulgV1; apply: contra y_rs; move/eqP <-. Qed. Lemma field_mul_group_cyclic (F : fieldType) (f : gT -> F) : {in G &, {morph f : u v / u * v >-> (u * v)%R}} -> {in G, forall x, f x = 1%R <-> x = 1} -> cyclic G. Proof. move=> fM f1P; have f1 : f 1 = 1%R by apply/f1P. apply: (div_ring_mul_group_cyclic f1 fM) => [x|]. case/setD1P=> x1 Gx; rewrite unitfE; apply: contra x1. by rewrite subr_eq0 => /eqP/f1P->. apply/centsP=> x Gx y Gy; apply/commgP/eqP. apply/f1P; rewrite ?fM ?groupM ?groupV //. by rewrite mulrCA -!fM ?groupM ?groupV // mulKg mulVg. Qed. End FieldMulCyclic. Lemma field_unit_group_cyclic (F : finFieldType) (G : {group {unit F}}) : cyclic G. Proof. apply: field_mul_group_cyclic FinRing.uval _ _ => // u _. by split=> /eqP ?; apply/eqP. Qed. Lemma units_Zp_cyclic p : prime p -> cyclic (units_Zp p). Proof. by move/pdiv_id <-; exact: field_unit_group_cyclic. Qed. Section PrimitiveRoots. Open Scope ring_scope. Import GRing.Theory. (* This subproof has been extracted out of [has_prim_root] for performance reasons. See github PR #1059 for further documentation and investigation on this problem. *) Lemma has_prim_root_subproof (F : fieldType) (n : nat) (rs : seq F) (n_gt0 : n > 0) (rsn1 : all n.-unity_root rs) (Urs : uniq rs) (sz_rs : size rs = n) (r := fun s => val (s : seq_sub rs)) (rn1 : forall x : seq_sub rs, r x ^+ n = 1) (prim_r : forall z : F, z ^+ n = 1 -> z \in rs) (r' := (fun s (e : s ^+ n = 1) => {| ssval := s; ssvalP := prim_r s e |}) : forall s : F, s ^+ n = 1 -> seq_sub rs) (sG_1 := r' 1 (expr1n F n) : seq_sub rs) (sG_VP : forall s : seq_sub rs, r s ^+ n.-1 ^+ n = 1) (sG_MP : forall s s0 : seq_sub rs, (r s * r s0) ^+ n = 1) (sG_V := (fun s : seq_sub rs => r' (r s ^+ n.-1) (sG_VP s)) : seq_sub rs -> seq_sub rs) (sG_M := (fun s s0 : seq_sub rs => r' (r s * r s0) (sG_MP s s0)) : seq_sub rs -> seq_sub rs -> seq_sub rs) (sG_Ag : associative sG_M) (sG_1g : left_id sG_1 sG_M) (sG_Vg : left_inverse sG_1 sG_V sG_M) : has n.-primitive_root rs. Proof. pose ssMG : isMulGroup (seq_sub rs) := isMulGroup.Build (seq_sub rs) sG_Ag sG_1g sG_Vg. pose gT : finGroupType := HB.pack (seq_sub rs) ssMG. have /cyclicP[x gen_x]: @cyclic gT setT. apply: (@field_mul_group_cyclic gT [set: _] F r) => // x _. by split=> [ri1 | ->]; first apply: val_inj. apply/hasP; exists (r x); first exact: (valP x). have [m prim_x dvdmn] := prim_order_exists n_gt0 (rn1 x). rewrite -((m =P n) _) // eqn_dvd {}dvdmn -sz_rs -(card_seq_sub Urs) -cardsT. rewrite gen_x (@order_dvdn gT) /(_ == _) /= -{prim_x}(prim_expr_order prim_x). by apply/eqP; elim: m => //= m IHm; rewrite exprS expgS /= -IHm. Qed. Lemma has_prim_root (F : fieldType) (n : nat) (rs : seq F) : n > 0 -> all n.-unity_root rs -> uniq rs -> size rs >= n -> has n.-primitive_root rs. Proof. move=> n_gt0 rsn1 Urs; rewrite leq_eqVlt ltnNge max_unity_roots // orbF eq_sym. move/eqP=> sz_rs; pose r := val (_ : seq_sub rs). have rn1 x: r x ^+ n = 1. by apply/eqP; rewrite -unity_rootE (allP rsn1) ?(valP x). have prim_r z: z ^+ n = 1 -> z \in rs. by move/eqP; rewrite -unity_rootE -(mem_unity_roots n_gt0). pose r' := SeqSub (prim_r _ _); pose sG_1 := r' _ (expr1n _ _). have sG_VP: r _ ^+ n.-1 ^+ n = 1. by move=> x; rewrite -exprM mulnC exprM rn1 expr1n. have sG_MP: (r _ * r _) ^+ n = 1 by move=> x y; rewrite exprMn !rn1 mul1r. pose sG_V := r' _ (sG_VP _); pose sG_M := r' _ (sG_MP _ _). have sG_Ag: associative sG_M by move=> x y z; apply: val_inj; rewrite /= mulrA. have sG_1g: left_id sG_1 sG_M by move=> x; apply: val_inj; rewrite /= mul1r. have sG_Vg: left_inverse sG_1 sG_V sG_M. by move=> x; apply: val_inj; rewrite /= -exprSr prednK ?rn1. exact: has_prim_root_subproof. Qed. End PrimitiveRoots. (***********************************************************************) (* Cycles of prime order *) (***********************************************************************) Section AutPrime. Variable gT : finGroupType. Lemma Aut_prime_cycle_cyclic (a : gT) : prime #[a] -> cyclic (Aut <[a]>). Proof. move=> pr_a; have inj_um := injm_Zp_unitm a. have /eq_S/eq_S eq_a := Fp_Zcast pr_a. pose fm := cast_ord (esym eq_a) \o val \o invm inj_um. apply: (@field_mul_group_cyclic _ _ _ fm) => [f g Af Ag | f Af] /=. by apply: val_inj; rewrite /= morphM ?im_Zp_unitm //= eq_a. split=> [/= fm1 |->]; last by apply: val_inj; rewrite /= morph1. apply: (injm1 (injm_invm inj_um)); first by rewrite /= im_Zp_unitm. by do 2!apply: val_inj; move/(congr1 val): fm1. Qed. Lemma Aut_prime_cyclic (G : {group gT}) : prime #|G| -> cyclic (Aut G). Proof. move=> pr_G; case/cyclicP: (prime_cyclic pr_G) (pr_G) => x ->. exact: Aut_prime_cycle_cyclic. Qed. End AutPrime.
Subobject.lean
/- Copyright (c) 2021 Markus Himmel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Markus Himmel -/ import Mathlib.Algebra.Category.Grp.ZModuleEquivalence import Mathlib.Algebra.Category.ModuleCat.Subobject /-! # The category of abelian groups is well-powered -/ open CategoryTheory universe u namespace AddCommGrp instance wellPowered_addCommGrp : WellPowered.{u} AddCommGrp.{u} := wellPowered_of_equiv (forget₂ (ModuleCat.{u} ℤ) AddCommGrp.{u}).asEquivalence end AddCommGrp
Cofinality.lean
/- Copyright (c) 2017 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro, Floris van Doorn, Violeta Hernández Palacios -/ import Mathlib.SetTheory.Cardinal.Arithmetic import Mathlib.SetTheory.Ordinal.FixedPoint /-! # Cofinality This file contains the definition of cofinality of an order and an ordinal number. ## Main Definitions * `Order.cof r` is the cofinality of a reflexive order. This is the smallest cardinality of a subset `s` that is *cofinal*, i.e. `∀ x, ∃ y ∈ s, r x y`. * `Ordinal.cof o` is the cofinality of the ordinal `o` when viewed as a linear order. ## Main Statements * `Cardinal.lt_power_cof`: A consequence of König's theorem stating that `c < c ^ c.ord.cof` for `c ≥ ℵ₀`. ## Implementation Notes * The cofinality is defined for ordinals. If `c` is a cardinal number, its cofinality is `c.ord.cof`. -/ noncomputable section open Function Cardinal Set Order open scoped Ordinal universe u v w variable {α : Type u} {β : Type v} {r : α → α → Prop} {s : β → β → Prop} /-! ### Cofinality of orders -/ attribute [local instance] IsRefl.swap namespace Order /-- Cofinality of a reflexive order `≼`. This is the smallest cardinality of a subset `S : Set α` such that `∀ a, ∃ b ∈ S, a ≼ b`. -/ def cof (r : α → α → Prop) : Cardinal := sInf { c | ∃ S : Set α, (∀ a, ∃ b ∈ S, r a b) ∧ #S = c } /-- The set in the definition of `Order.cof` is nonempty. -/ private theorem cof_nonempty (r : α → α → Prop) [IsRefl α r] : { c | ∃ S : Set α, (∀ a, ∃ b ∈ S, r a b) ∧ #S = c }.Nonempty := ⟨_, Set.univ, fun a => ⟨a, ⟨⟩, refl _⟩, rfl⟩ theorem cof_le (r : α → α → Prop) {S : Set α} (h : ∀ a, ∃ b ∈ S, r a b) : cof r ≤ #S := csInf_le' ⟨S, h, rfl⟩ theorem le_cof [IsRefl α r] (c : Cardinal) : c ≤ cof r ↔ ∀ {S : Set α}, (∀ a, ∃ b ∈ S, r a b) → c ≤ #S := by rw [cof, le_csInf_iff'' (cof_nonempty r)] use fun H S h => H _ ⟨S, h, rfl⟩ rintro H d ⟨S, h, rfl⟩ exact H h end Order namespace RelIso private theorem cof_le_lift [IsRefl β s] (f : r ≃r s) : Cardinal.lift.{v} (Order.cof r) ≤ Cardinal.lift.{u} (Order.cof s) := by rw [Order.cof, Order.cof, lift_sInf, lift_sInf, le_csInf_iff'' ((Order.cof_nonempty s).image _)] rintro - ⟨-, ⟨u, H, rfl⟩, rfl⟩ apply csInf_le' refine ⟨_, ⟨f.symm '' u, fun a => ?_, rfl⟩, lift_mk_eq'.2 ⟨(f.symm.toEquiv.image u).symm⟩⟩ rcases H (f a) with ⟨b, hb, hb'⟩ refine ⟨f.symm b, mem_image_of_mem _ hb, f.map_rel_iff.1 ?_⟩ rwa [RelIso.apply_symm_apply] theorem cof_eq_lift [IsRefl β s] (f : r ≃r s) : Cardinal.lift.{v} (Order.cof r) = Cardinal.lift.{u} (Order.cof s) := have := f.toRelEmbedding.isRefl (f.cof_le_lift).antisymm (f.symm.cof_le_lift) theorem cof_eq {α β : Type u} {r : α → α → Prop} {s} [IsRefl β s] (f : r ≃r s) : Order.cof r = Order.cof s := lift_inj.1 (f.cof_eq_lift) end RelIso /-! ### Cofinality of ordinals -/ namespace Ordinal /-- Cofinality of an ordinal. This is the smallest cardinal of a subset `S` of the ordinal which is unbounded, in the sense `∀ a, ∃ b ∈ S, a ≤ b`. In particular, `cof 0 = 0` and `cof (succ o) = 1`. -/ def cof (o : Ordinal.{u}) : Cardinal.{u} := o.liftOn (fun a ↦ Order.cof (swap a.rᶜ)) fun _ _ ⟨f⟩ ↦ f.compl.swap.cof_eq theorem cof_type (r : α → α → Prop) [IsWellOrder α r] : (type r).cof = Order.cof (swap rᶜ) := rfl theorem cof_type_lt [LinearOrder α] [IsWellOrder α (· < ·)] : (@type α (· < ·) _).cof = @Order.cof α (· ≤ ·) := by rw [cof_type, compl_lt, swap_ge] theorem cof_eq_cof_toType (o : Ordinal) : o.cof = @Order.cof o.toType (· ≤ ·) := by conv_lhs => rw [← type_toType o, cof_type_lt] theorem le_cof_type [IsWellOrder α r] {c} : c ≤ cof (type r) ↔ ∀ S, Unbounded r S → c ≤ #S := (le_csInf_iff'' (Order.cof_nonempty _)).trans ⟨fun H S h => H _ ⟨S, h, rfl⟩, by rintro H d ⟨S, h, rfl⟩ exact H _ h⟩ theorem cof_type_le [IsWellOrder α r] {S : Set α} (h : Unbounded r S) : cof (type r) ≤ #S := le_cof_type.1 le_rfl S h theorem lt_cof_type [IsWellOrder α r] {S : Set α} : #S < cof (type r) → Bounded r S := by simpa using not_imp_not.2 cof_type_le theorem cof_eq (r : α → α → Prop) [IsWellOrder α r] : ∃ S, Unbounded r S ∧ #S = cof (type r) := csInf_mem (Order.cof_nonempty (swap rᶜ)) theorem ord_cof_eq (r : α → α → Prop) [IsWellOrder α r] : ∃ S, Unbounded r S ∧ type (Subrel r (· ∈ S)) = (cof (type r)).ord := by let ⟨S, hS, e⟩ := cof_eq r let ⟨s, _, e'⟩ := Cardinal.ord_eq S let T : Set α := { a | ∃ aS : a ∈ S, ∀ b : S, s b ⟨_, aS⟩ → r b a } suffices Unbounded r T by refine ⟨T, this, le_antisymm ?_ (Cardinal.ord_le.2 <| cof_type_le this)⟩ rw [← e, e'] refine (RelEmbedding.ofMonotone (fun a : T => (⟨a, let ⟨aS, _⟩ := a.2 aS⟩ : S)) fun a b h => ?_).ordinal_type_le rcases a with ⟨a, aS, ha⟩ rcases b with ⟨b, bS, hb⟩ change s ⟨a, _⟩ ⟨b, _⟩ refine ((trichotomous_of s _ _).resolve_left fun hn => ?_).resolve_left ?_ · exact asymm h (ha _ hn) · intro e injection e with e subst b exact irrefl _ h intro a have : { b : S | ¬r b a }.Nonempty := let ⟨b, bS, ba⟩ := hS a ⟨⟨b, bS⟩, ba⟩ let b := (IsWellFounded.wf : WellFounded s).min _ this have ba : ¬r b a := IsWellFounded.wf.min_mem _ this refine ⟨b, ⟨b.2, fun c => not_imp_not.1 fun h => ?_⟩, ba⟩ rw [show ∀ b : S, (⟨b, b.2⟩ : S) = b by intro b; cases b; rfl] exact IsWellFounded.wf.not_lt_min _ this (IsOrderConnected.neg_trans h ba) /-! ### Cofinality of suprema and least strict upper bounds -/ private theorem card_mem_cof {o} : ∃ (ι : _) (f : ι → Ordinal), lsub.{u, u} f = o ∧ #ι = o.card := ⟨_, _, lsub_typein o, mk_toType o⟩ /-- The set in the `lsub` characterization of `cof` is nonempty. -/ theorem cof_lsub_def_nonempty (o) : { a : Cardinal | ∃ (ι : _) (f : ι → Ordinal), lsub.{u, u} f = o ∧ #ι = a }.Nonempty := ⟨_, card_mem_cof⟩ theorem cof_eq_sInf_lsub (o : Ordinal.{u}) : cof o = sInf { a : Cardinal | ∃ (ι : Type u) (f : ι → Ordinal), lsub.{u, u} f = o ∧ #ι = a } := by refine le_antisymm (le_csInf (cof_lsub_def_nonempty o) ?_) (csInf_le' ?_) · rintro a ⟨ι, f, hf, rfl⟩ rw [← type_toType o] refine (cof_type_le fun a => ?_).trans (@mk_le_of_injective _ _ (fun s : typein ((· < ·) : o.toType → o.toType → Prop) ⁻¹' Set.range f => Classical.choose s.prop) fun s t hst => by let H := congr_arg f hst rwa [Classical.choose_spec s.prop, Classical.choose_spec t.prop, typein_inj, Subtype.coe_inj] at H) have := typein_lt_self a simp_rw [← hf, lt_lsub_iff] at this obtain ⟨i, hi⟩ := this refine ⟨enum (α := o.toType) (· < ·) ⟨f i, ?_⟩, ?_, ?_⟩ · rw [type_toType, ← hf] apply lt_lsub · rw [mem_preimage, typein_enum] exact mem_range_self i · rwa [← typein_le_typein, typein_enum] · rcases cof_eq (α := o.toType) (· < ·) with ⟨S, hS, hS'⟩ let f : S → Ordinal := fun s => typein LT.lt s.val refine ⟨S, f, le_antisymm (lsub_le fun i => typein_lt_self (o := o) i) (le_of_forall_lt fun a ha => ?_), by rwa [type_toType o] at hS'⟩ rw [← type_toType o] at ha rcases hS (enum (· < ·) ⟨a, ha⟩) with ⟨b, hb, hb'⟩ rw [← typein_le_typein, typein_enum] at hb' exact hb'.trans_lt (lt_lsub.{u, u} f ⟨b, hb⟩) @[simp] theorem lift_cof (o) : Cardinal.lift.{u, v} (cof o) = cof (Ordinal.lift.{u, v} o) := by refine inductionOn o fun α r _ ↦ ?_ rw [← type_uLift, cof_type, cof_type, ← Cardinal.lift_id'.{v, u} (Order.cof _), ← Cardinal.lift_umax] apply RelIso.cof_eq_lift ⟨Equiv.ulift.symm, _⟩ simp [swap] theorem cof_le_card (o) : cof o ≤ card o := by rw [cof_eq_sInf_lsub] exact csInf_le' card_mem_cof theorem cof_ord_le (c : Cardinal) : c.ord.cof ≤ c := by simpa using cof_le_card c.ord theorem ord_cof_le (o : Ordinal.{u}) : o.cof.ord ≤ o := (ord_le_ord.2 (cof_le_card o)).trans (ord_card_le o) theorem exists_lsub_cof (o : Ordinal) : ∃ (ι : _) (f : ι → Ordinal), lsub.{u, u} f = o ∧ #ι = cof o := by rw [cof_eq_sInf_lsub] exact csInf_mem (cof_lsub_def_nonempty o) theorem cof_lsub_le {ι} (f : ι → Ordinal) : cof (lsub.{u, u} f) ≤ #ι := by rw [cof_eq_sInf_lsub] exact csInf_le' ⟨ι, f, rfl, rfl⟩ theorem cof_lsub_le_lift {ι} (f : ι → Ordinal) : cof (lsub.{u, v} f) ≤ Cardinal.lift.{v, u} #ι := by rw [← mk_uLift.{u, v}] convert cof_lsub_le.{max u v} fun i : ULift.{v, u} ι => f i.down exact lsub_eq_of_range_eq.{u, max u v, max u v} (Set.ext fun x => ⟨fun ⟨i, hi⟩ => ⟨ULift.up.{v, u} i, hi⟩, fun ⟨i, hi⟩ => ⟨_, hi⟩⟩) theorem le_cof_iff_lsub {o : Ordinal} {a : Cardinal} : a ≤ cof o ↔ ∀ {ι} (f : ι → Ordinal), lsub.{u, u} f = o → a ≤ #ι := by rw [cof_eq_sInf_lsub] exact (le_csInf_iff'' (cof_lsub_def_nonempty o)).trans ⟨fun H ι f hf => H _ ⟨ι, f, hf, rfl⟩, fun H b ⟨ι, f, hf, hb⟩ => by rw [← hb] exact H _ hf⟩ theorem lsub_lt_ord_lift {ι} {f : ι → Ordinal} {c : Ordinal} (hι : Cardinal.lift.{v, u} #ι < c.cof) (hf : ∀ i, f i < c) : lsub.{u, v} f < c := lt_of_le_of_ne (lsub_le hf) fun h => by subst h exact (cof_lsub_le_lift.{u, v} f).not_gt hι theorem lsub_lt_ord {ι} {f : ι → Ordinal} {c : Ordinal} (hι : #ι < c.cof) : (∀ i, f i < c) → lsub.{u, u} f < c := lsub_lt_ord_lift (by rwa [(#ι).lift_id]) theorem cof_iSup_le_lift {ι} {f : ι → Ordinal} (H : ∀ i, f i < iSup f) : cof (iSup f) ≤ Cardinal.lift.{v, u} #ι := by rw [← Ordinal.sup] at * rw [← sup_eq_lsub_iff_lt_sup.{u, v}] at H rw [H] exact cof_lsub_le_lift f theorem cof_iSup_le {ι} {f : ι → Ordinal} (H : ∀ i, f i < iSup f) : cof (iSup f) ≤ #ι := by rw [← (#ι).lift_id] exact cof_iSup_le_lift H theorem iSup_lt_ord_lift {ι} {f : ι → Ordinal} {c : Ordinal} (hι : Cardinal.lift.{v, u} #ι < c.cof) (hf : ∀ i, f i < c) : iSup f < c := (sup_le_lsub.{u, v} f).trans_lt (lsub_lt_ord_lift hι hf) theorem iSup_lt_ord {ι} {f : ι → Ordinal} {c : Ordinal} (hι : #ι < c.cof) : (∀ i, f i < c) → iSup f < c := iSup_lt_ord_lift (by rwa [(#ι).lift_id]) theorem iSup_lt_lift {ι} {f : ι → Cardinal} {c : Cardinal} (hι : Cardinal.lift.{v, u} #ι < c.ord.cof) (hf : ∀ i, f i < c) : iSup f < c := by rw [← ord_lt_ord, iSup_ord (Cardinal.bddAbove_range _)] refine iSup_lt_ord_lift hι fun i => ?_ rw [ord_lt_ord] apply hf theorem iSup_lt {ι} {f : ι → Cardinal} {c : Cardinal} (hι : #ι < c.ord.cof) : (∀ i, f i < c) → iSup f < c := iSup_lt_lift (by rwa [(#ι).lift_id]) theorem nfpFamily_lt_ord_lift {ι} {f : ι → Ordinal → Ordinal} {c} (hc : ℵ₀ < cof c) (hc' : Cardinal.lift.{v, u} #ι < cof c) (hf : ∀ (i), ∀ b < c, f i b < c) {a} (ha : a < c) : nfpFamily f a < c := by refine iSup_lt_ord_lift ((Cardinal.lift_le.2 (mk_list_le_max ι)).trans_lt ?_) fun l => ?_ · rw [lift_max] apply max_lt _ hc' rwa [Cardinal.lift_aleph0] · induction l with | nil => exact ha | cons i l H => exact hf _ _ H theorem nfpFamily_lt_ord {ι} {f : ι → Ordinal → Ordinal} {c} (hc : ℵ₀ < cof c) (hc' : #ι < cof c) (hf : ∀ (i), ∀ b < c, f i b < c) {a} : a < c → nfpFamily.{u, u} f a < c := nfpFamily_lt_ord_lift hc (by rwa [(#ι).lift_id]) hf theorem nfp_lt_ord {f : Ordinal → Ordinal} {c} (hc : ℵ₀ < cof c) (hf : ∀ i < c, f i < c) {a} : a < c → nfp f a < c := nfpFamily_lt_ord_lift hc (by simpa using Cardinal.one_lt_aleph0.trans hc) fun _ => hf theorem exists_blsub_cof (o : Ordinal) : ∃ f : ∀ a < (cof o).ord, Ordinal, blsub.{u, u} _ f = o := by rcases exists_lsub_cof o with ⟨ι, f, hf, hι⟩ rcases Cardinal.ord_eq ι with ⟨r, hr, hι'⟩ rw [← @blsub_eq_lsub' ι r hr] at hf rw [← hι, hι'] exact ⟨_, hf⟩ theorem le_cof_iff_blsub {b : Ordinal} {a : Cardinal} : a ≤ cof b ↔ ∀ {o} (f : ∀ a < o, Ordinal), blsub.{u, u} o f = b → a ≤ o.card := le_cof_iff_lsub.trans ⟨fun H o f hf => by simpa using H _ hf, fun H ι f hf => by rcases Cardinal.ord_eq ι with ⟨r, hr, hι'⟩ rw [← @blsub_eq_lsub' ι r hr] at hf simpa using H _ hf⟩ theorem cof_blsub_le_lift {o} (f : ∀ a < o, Ordinal) : cof (blsub.{u, v} o f) ≤ Cardinal.lift.{v, u} o.card := by rw [← mk_toType o] exact cof_lsub_le_lift _ theorem cof_blsub_le {o} (f : ∀ a < o, Ordinal) : cof (blsub.{u, u} o f) ≤ o.card := by rw [← o.card.lift_id] exact cof_blsub_le_lift f theorem blsub_lt_ord_lift {o : Ordinal.{u}} {f : ∀ a < o, Ordinal} {c : Ordinal} (ho : Cardinal.lift.{v, u} o.card < c.cof) (hf : ∀ i hi, f i hi < c) : blsub.{u, v} o f < c := lt_of_le_of_ne (blsub_le hf) fun h => ho.not_ge (by simpa [← iSup_ord, hf, h] using cof_blsub_le_lift.{u, v} f) theorem blsub_lt_ord {o : Ordinal} {f : ∀ a < o, Ordinal} {c : Ordinal} (ho : o.card < c.cof) (hf : ∀ i hi, f i hi < c) : blsub.{u, u} o f < c := blsub_lt_ord_lift (by rwa [o.card.lift_id]) hf theorem cof_bsup_le_lift {o : Ordinal} {f : ∀ a < o, Ordinal} (H : ∀ i h, f i h < bsup.{u, v} o f) : cof (bsup.{u, v} o f) ≤ Cardinal.lift.{v, u} o.card := by rw [← bsup_eq_blsub_iff_lt_bsup.{u, v}] at H rw [H] exact cof_blsub_le_lift.{u, v} f theorem cof_bsup_le {o : Ordinal} {f : ∀ a < o, Ordinal} : (∀ i h, f i h < bsup.{u, u} o f) → cof (bsup.{u, u} o f) ≤ o.card := by rw [← o.card.lift_id] exact cof_bsup_le_lift theorem bsup_lt_ord_lift {o : Ordinal} {f : ∀ a < o, Ordinal} {c : Ordinal} (ho : Cardinal.lift.{v, u} o.card < c.cof) (hf : ∀ i hi, f i hi < c) : bsup.{u, v} o f < c := (bsup_le_blsub f).trans_lt (blsub_lt_ord_lift ho hf) theorem bsup_lt_ord {o : Ordinal} {f : ∀ a < o, Ordinal} {c : Ordinal} (ho : o.card < c.cof) : (∀ i hi, f i hi < c) → bsup.{u, u} o f < c := bsup_lt_ord_lift (by rwa [o.card.lift_id]) /-! ### Basic results -/ @[simp] theorem cof_zero : cof 0 = 0 := by refine LE.le.antisymm ?_ (Cardinal.zero_le _) rw [← card_zero] exact cof_le_card 0 @[simp] theorem cof_eq_zero {o} : cof o = 0 ↔ o = 0 := ⟨inductionOn o fun _ r _ z => let ⟨_, hl, e⟩ := cof_eq r type_eq_zero_iff_isEmpty.2 <| ⟨fun a => let ⟨_, h, _⟩ := hl a (mk_eq_zero_iff.1 (e.trans z)).elim' ⟨_, h⟩⟩, fun e => by simp [e]⟩ theorem cof_ne_zero {o} : cof o ≠ 0 ↔ o ≠ 0 := cof_eq_zero.not @[simp] theorem cof_succ (o) : cof (succ o) = 1 := by apply le_antisymm · refine inductionOn o fun α r _ => ?_ change cof (type _) ≤ _ rw [← (_ : #_ = 1)] · apply cof_type_le refine fun a => ⟨Sum.inr PUnit.unit, Set.mem_singleton _, ?_⟩ rcases a with (a | ⟨⟨⟨⟩⟩⟩) <;> simp [EmptyRelation] · rw [Cardinal.mk_fintype, Set.card_singleton] simp · rw [← Cardinal.succ_zero, succ_le_iff] simpa [lt_iff_le_and_ne, Cardinal.zero_le] using fun h => succ_ne_zero o (cof_eq_zero.1 (Eq.symm h)) @[simp] theorem cof_eq_one_iff_is_succ {o} : cof.{u} o = 1 ↔ ∃ a, o = succ a := ⟨inductionOn o fun α r _ z => by rcases cof_eq r with ⟨S, hl, e⟩; rw [z] at e obtain ⟨a⟩ := mk_ne_zero_iff.1 (by rw [e]; exact one_ne_zero) refine ⟨typein r a, Eq.symm <| Quotient.sound ⟨RelIso.ofSurjective (RelEmbedding.ofMonotone ?_ fun x y => ?_) fun x => ?_⟩⟩ · apply Sum.rec <;> [exact Subtype.val; exact fun _ => a] · rcases x with (x | ⟨⟨⟨⟩⟩⟩) <;> rcases y with (y | ⟨⟨⟨⟩⟩⟩) <;> simp [Subrel, Order.Preimage, EmptyRelation] exact x.2 · suffices r x a ∨ ∃ _ : PUnit.{u}, ↑a = x by convert this dsimp [RelEmbedding.ofMonotone]; simp rcases trichotomous_of r x a with (h | h | h) · exact Or.inl h · exact Or.inr ⟨PUnit.unit, h.symm⟩ · rcases hl x with ⟨a', aS, hn⟩ refine absurd h ?_ convert hn change (a : α) = ↑(⟨a', aS⟩ : S) have := le_one_iff_subsingleton.1 (le_of_eq e) congr!, fun ⟨a, e⟩ => by simp [e]⟩ /-! ### Fundamental sequences -/ -- TODO: move stuff about fundamental sequences to their own file. /-- A fundamental sequence for `a` is an increasing sequence of length `o = cof a` that converges at `a`. We provide `o` explicitly in order to avoid type rewrites. -/ def IsFundamentalSequence (a o : Ordinal.{u}) (f : ∀ b < o, Ordinal.{u}) : Prop := o ≤ a.cof.ord ∧ (∀ {i j} (hi hj), i < j → f i hi < f j hj) ∧ blsub.{u, u} o f = a namespace IsFundamentalSequence variable {a o : Ordinal.{u}} {f : ∀ b < o, Ordinal.{u}} protected theorem cof_eq (hf : IsFundamentalSequence a o f) : a.cof.ord = o := hf.1.antisymm' <| by rw [← hf.2.2] exact (ord_le_ord.2 (cof_blsub_le f)).trans (ord_card_le o) protected theorem strict_mono (hf : IsFundamentalSequence a o f) {i j} : ∀ hi hj, i < j → f i hi < f j hj := hf.2.1 theorem blsub_eq (hf : IsFundamentalSequence a o f) : blsub.{u, u} o f = a := hf.2.2 theorem ord_cof (hf : IsFundamentalSequence a o f) : IsFundamentalSequence a a.cof.ord fun i hi => f i (hi.trans_le (by rw [hf.cof_eq])) := by have H := hf.cof_eq subst H exact hf theorem id_of_le_cof (h : o ≤ o.cof.ord) : IsFundamentalSequence o o fun a _ => a := ⟨h, @fun _ _ _ _ => id, blsub_id o⟩ protected theorem zero {f : ∀ b < (0 : Ordinal), Ordinal} : IsFundamentalSequence 0 0 f := ⟨by rw [cof_zero, ord_zero], @fun i _ hi => (Ordinal.not_lt_zero i hi).elim, blsub_zero f⟩ protected theorem succ : IsFundamentalSequence (succ o) 1 fun _ _ => o := by refine ⟨?_, @fun i j hi hj h => ?_, blsub_const Ordinal.one_ne_zero o⟩ · rw [cof_succ, ord_one] · rw [lt_one_iff_zero] at hi hj rw [hi, hj] at h exact h.false.elim protected theorem monotone (hf : IsFundamentalSequence a o f) {i j : Ordinal} (hi : i < o) (hj : j < o) (hij : i ≤ j) : f i hi ≤ f j hj := by rcases lt_or_eq_of_le hij with (hij | rfl) · exact (hf.2.1 hi hj hij).le · rfl theorem trans {a o o' : Ordinal.{u}} {f : ∀ b < o, Ordinal.{u}} (hf : IsFundamentalSequence a o f) {g : ∀ b < o', Ordinal.{u}} (hg : IsFundamentalSequence o o' g) : IsFundamentalSequence a o' fun i hi => f (g i hi) (by rw [← hg.2.2]; apply lt_blsub) := by refine ⟨?_, @fun i j _ _ h => hf.2.1 _ _ (hg.2.1 _ _ h), ?_⟩ · rw [hf.cof_eq] exact hg.1.trans (ord_cof_le o) · rw [@blsub_comp.{u, u, u} o _ f (@IsFundamentalSequence.monotone _ _ f hf)] · exact hf.2.2 · exact hg.2.2 protected theorem lt {a o : Ordinal} {s : Π p < o, Ordinal} (h : IsFundamentalSequence a o s) {p : Ordinal} (hp : p < o) : s p hp < a := h.blsub_eq ▸ lt_blsub s p hp end IsFundamentalSequence /-- Every ordinal has a fundamental sequence. -/ theorem exists_fundamental_sequence (a : Ordinal.{u}) : ∃ f, IsFundamentalSequence a a.cof.ord f := by suffices h : ∃ o f, IsFundamentalSequence a o f by rcases h with ⟨o, f, hf⟩ exact ⟨_, hf.ord_cof⟩ rcases exists_lsub_cof a with ⟨ι, f, hf, hι⟩ rcases ord_eq ι with ⟨r, wo, hr⟩ let r' := Subrel r fun i ↦ ∀ j, r j i → f j < f i let hrr' : r' ↪r r := Subrel.relEmbedding _ _ haveI := hrr'.isWellOrder refine ⟨_, _, hrr'.ordinal_type_le.trans ?_, @fun i j _ h _ => (enum r' ⟨j, h⟩).prop _ ?_, le_antisymm (blsub_le fun i hi => lsub_le_iff.1 hf.le _) ?_⟩ · rw [← hι, hr] · change r (hrr'.1 _) (hrr'.1 _) rwa [hrr'.2, @enum_lt_enum _ r'] · rw [← hf, lsub_le_iff] intro i suffices h : ∃ i' hi', f i ≤ bfamilyOfFamily' r' (fun i => f i) i' hi' by rcases h with ⟨i', hi', hfg⟩ exact hfg.trans_lt (lt_blsub _ _ _) by_cases h : ∀ j, r j i → f j < f i · refine ⟨typein r' ⟨i, h⟩, typein_lt_type _ _, ?_⟩ rw [bfamilyOfFamily'_typein] · push_neg at h obtain ⟨hji, hij⟩ := wo.wf.min_mem _ h refine ⟨typein r' ⟨_, fun k hkj => lt_of_lt_of_le ?_ hij⟩, typein_lt_type _ _, ?_⟩ · by_contra! H exact (wo.wf.not_lt_min _ h ⟨IsTrans.trans _ _ _ hkj hji, H⟩) hkj · rwa [bfamilyOfFamily'_typein] @[simp] theorem cof_cof (a : Ordinal.{u}) : cof (cof a).ord = cof a := by obtain ⟨f, hf⟩ := exists_fundamental_sequence a obtain ⟨g, hg⟩ := exists_fundamental_sequence a.cof.ord exact ord_injective (hf.trans hg).cof_eq.symm protected theorem IsNormal.isFundamentalSequence {f : Ordinal.{u} → Ordinal.{u}} (hf : IsNormal f) {a o} (ha : IsSuccLimit a) {g} (hg : IsFundamentalSequence a o g) : IsFundamentalSequence (f a) o fun b hb => f (g b hb) := by refine ⟨?_, @fun i j _ _ h => hf.strictMono (hg.2.1 _ _ h), ?_⟩ · rcases exists_lsub_cof (f a) with ⟨ι, f', hf', hι⟩ rw [← hg.cof_eq, ord_le_ord, ← hι] suffices (lsub.{u, u} fun i => sInf { b : Ordinal | f' i ≤ f b }) = a by rw [← this] apply cof_lsub_le have H : ∀ i, ∃ b < a, f' i ≤ f b := fun i => by have := lt_lsub.{u, u} f' i rw [hf', ← IsNormal.blsub_eq.{u, u} hf ha, lt_blsub_iff] at this simpa using this refine (lsub_le fun i => ?_).antisymm (le_of_forall_lt fun b hb => ?_) · rcases H i with ⟨b, hb, hb'⟩ exact lt_of_le_of_lt (csInf_le' hb') hb · have := hf.strictMono hb rw [← hf', lt_lsub_iff] at this obtain ⟨i, hi⟩ := this rcases H i with ⟨b, _, hb⟩ exact ((le_csInf_iff'' ⟨b, by exact hb⟩).2 fun c hc => hf.strictMono.le_iff_le.1 (hi.trans hc)).trans_lt (lt_lsub _ i) · rw [@blsub_comp.{u, u, u} a _ (fun b _ => f b) (@fun i j _ _ h => hf.strictMono.monotone h) g hg.2.2] exact IsNormal.blsub_eq.{u, u} hf ha theorem IsNormal.cof_eq {f} (hf : IsNormal f) {a} (ha : IsSuccLimit a) : cof (f a) = cof a := let ⟨_, hg⟩ := exists_fundamental_sequence a ord_injective (hf.isFundamentalSequence ha hg).cof_eq theorem IsNormal.cof_le {f} (hf : IsNormal f) (a) : cof a ≤ cof (f a) := by rcases zero_or_succ_or_isSuccLimit a with (rfl | ⟨b, rfl⟩ | ha) · rw [cof_zero] exact zero_le _ · rw [cof_succ, Cardinal.one_le_iff_ne_zero, cof_ne_zero, ← Ordinal.pos_iff_ne_zero] exact (Ordinal.zero_le (f b)).trans_lt (hf.strictMono (lt_succ b)) · rw [hf.cof_eq ha] @[simp] theorem cof_add (a b : Ordinal) : b ≠ 0 → cof (a + b) = cof b := fun h => by rcases zero_or_succ_or_isSuccLimit b with (rfl | ⟨c, rfl⟩ | hb) · contradiction · rw [add_succ, cof_succ, cof_succ] · exact (isNormal_add_right a).cof_eq hb theorem aleph0_le_cof {o} : ℵ₀ ≤ cof o ↔ IsSuccLimit o := by rcases zero_or_succ_or_isSuccLimit o with (rfl | ⟨o, rfl⟩ | l) · simp [Cardinal.aleph0_ne_zero] · simp [Cardinal.one_lt_aleph0] · simp only [l, iff_true] refine le_of_not_gt fun h => ?_ obtain ⟨n, e⟩ := Cardinal.lt_aleph0.1 h have := cof_cof o rw [e, ord_nat] at this cases n · apply l.ne_bot simpa using e · rw [natCast_succ, cof_succ] at this rw [← this, cof_eq_one_iff_is_succ] at e rcases e with ⟨a, rfl⟩ exact not_isSuccLimit_succ _ l @[simp] theorem cof_preOmega {o : Ordinal} (ho : IsSuccPrelimit o) : (preOmega o).cof = o.cof := by by_cases h : IsMin o · simp [h.eq_bot] · exact isNormal_preOmega.cof_eq ⟨h, ho⟩ @[simp] theorem cof_omega {o : Ordinal} (ho : IsSuccLimit o) : (ω_ o).cof = o.cof := isNormal_omega.cof_eq ho @[simp] theorem cof_omega0 : cof ω = ℵ₀ := (aleph0_le_cof.2 isSuccLimit_omega0).antisymm' <| by rw [← card_omega0] apply cof_le_card theorem cof_eq' (r : α → α → Prop) [IsWellOrder α r] (h : IsSuccLimit (type r)) : ∃ S : Set α, (∀ a, ∃ b ∈ S, r a b) ∧ #S = cof (type r) := let ⟨S, H, e⟩ := cof_eq r ⟨S, fun a => let a' := enum r ⟨_, h.succ_lt (typein_lt_type r a)⟩ let ⟨b, h, ab⟩ := H a' ⟨b, h, (IsOrderConnected.conn a b a' <| (typein_lt_typein r).1 (by rw [typein_enum] exact lt_succ (typein _ _))).resolve_right ab⟩, e⟩ @[simp] theorem cof_univ : cof univ.{u, v} = Cardinal.univ.{u, v} := le_antisymm (cof_le_card _) (by refine le_of_forall_lt fun c h => ?_ rcases lt_univ'.1 h with ⟨c, rfl⟩ rcases @cof_eq Ordinal.{u} (· < ·) _ with ⟨S, H, Se⟩ rw [univ, ← lift_cof, ← Cardinal.lift_lift.{u+1, v, u}, Cardinal.lift_lt, ← Se] refine lt_of_not_ge fun h => ?_ obtain ⟨a, e⟩ := Cardinal.mem_range_lift_of_le h refine Quotient.inductionOn a (fun α e => ?_) e obtain ⟨f⟩ := Quotient.exact e have f := Equiv.ulift.symm.trans f let g a := (f a).1 let o := succ (iSup g) rcases H o with ⟨b, h, l⟩ refine l (lt_succ_iff.2 ?_) rw [← show g (f.symm ⟨b, h⟩) = b by simp [g]] apply Ordinal.le_iSup) end Ordinal namespace Cardinal open Ordinal /-! ### Results on sets -/ theorem mk_bounded_subset {α : Type*} (h : ∀ x < #α, 2 ^ x < #α) {r : α → α → Prop} [IsWellOrder α r] (hr : (#α).ord = type r) : #{ s : Set α // Bounded r s } = #α := by rcases eq_or_ne #α 0 with (ha | ha) · rw [ha] haveI := mk_eq_zero_iff.1 ha rw [mk_eq_zero_iff] constructor rintro ⟨s, hs⟩ exact (not_unbounded_iff s).2 hs (unbounded_of_isEmpty s) have h' : IsStrongLimit #α := ⟨ha, @h⟩ have ha := h'.aleph0_le apply le_antisymm · have : { s : Set α | Bounded r s } = ⋃ i, 𝒫{ j | r j i } := setOf_exists _ rw [← coe_setOf, this] refine mk_iUnion_le_sum_mk.trans ((sum_le_iSup (fun i => #(𝒫{ j | r j i }))).trans ((mul_le_max_of_aleph0_le_left ha).trans ?_)) rw [max_eq_left] apply ciSup_le' _ intro i rw [mk_powerset] apply (h'.two_power_lt _).le rw [coe_setOf, card_typein, ← lt_ord, hr] apply typein_lt_type · refine @mk_le_of_injective α _ (fun x => Subtype.mk {x} ?_) ?_ · apply bounded_singleton rw [← hr] apply isSuccLimit_ord ha · intro a b hab simpa [singleton_eq_singleton_iff] using hab theorem mk_subset_mk_lt_cof {α : Type*} (h : ∀ x < #α, 2 ^ x < #α) : #{ s : Set α // #s < cof (#α).ord } = #α := by rcases eq_or_ne #α 0 with (ha | ha) · simp [ha] have h' : IsStrongLimit #α := ⟨ha, @h⟩ rcases ord_eq α with ⟨r, wo, hr⟩ haveI := wo apply le_antisymm · conv_rhs => rw [← mk_bounded_subset h hr] apply mk_le_mk_of_subset intro s hs rw [hr] at hs exact lt_cof_type hs · refine @mk_le_of_injective α _ (fun x => Subtype.mk {x} ?_) ?_ · rw [mk_singleton] exact one_lt_aleph0.trans_le (aleph0_le_cof.2 (isSuccLimit_ord h'.aleph0_le)) · intro a b hab simpa [singleton_eq_singleton_iff] using hab /-- If the union of s is unbounded and s is smaller than the cofinality, then s has an unbounded member -/ theorem unbounded_of_unbounded_sUnion (r : α → α → Prop) [wo : IsWellOrder α r] {s : Set (Set α)} (h₁ : Unbounded r <| ⋃₀ s) (h₂ : #s < Order.cof (swap rᶜ)) : ∃ x ∈ s, Unbounded r x := by by_contra! h simp_rw [not_unbounded_iff] at h let f : s → α := fun x : s => wo.wf.sup x (h x.1 x.2) refine h₂.not_ge (le_trans (csInf_le' ⟨range f, fun x => ?_, rfl⟩) mk_range_le) rcases h₁ x with ⟨y, ⟨c, hc, hy⟩, hxy⟩ exact ⟨f ⟨c, hc⟩, mem_range_self _, fun hxz => hxy (Trans.trans (wo.wf.lt_sup _ hy) hxz)⟩ /-- If the union of s is unbounded and s is smaller than the cofinality, then s has an unbounded member -/ theorem unbounded_of_unbounded_iUnion {α β : Type u} (r : α → α → Prop) [wo : IsWellOrder α r] (s : β → Set α) (h₁ : Unbounded r <| ⋃ x, s x) (h₂ : #β < Order.cof (swap rᶜ)) : ∃ x : β, Unbounded r (s x) := by rw [← sUnion_range] at h₁ rcases unbounded_of_unbounded_sUnion r h₁ (mk_range_le.trans_lt h₂) with ⟨_, ⟨x, rfl⟩, u⟩ exact ⟨x, u⟩ /-! ### Consequences of König's lemma -/ theorem lt_power_cof {c : Cardinal.{u}} : ℵ₀ ≤ c → c < c ^ c.ord.cof := Cardinal.inductionOn c fun α h => by rcases ord_eq α with ⟨r, wo, re⟩ have := isSuccLimit_ord h rw [re] at this ⊢ rcases cof_eq' r this with ⟨S, H, Se⟩ have := sum_lt_prod (fun a : S => #{ x // r x a }) (fun _ => #α) fun i => ?_ · simp only [Cardinal.prod_const, Cardinal.lift_id, ← Se, ← mk_sigma, power_def] at this ⊢ refine lt_of_le_of_lt ?_ this refine ⟨Embedding.ofSurjective ?_ ?_⟩ · exact fun x => x.2.1 · exact fun a => let ⟨b, h, ab⟩ := H a ⟨⟨⟨_, h⟩, _, ab⟩, rfl⟩ · have := typein_lt_type r i rwa [← re, lt_ord] at this theorem lt_cof_power {a b : Cardinal} (ha : ℵ₀ ≤ a) (b1 : 1 < b) : a < (b ^ a).ord.cof := by have b0 : b ≠ 0 := (zero_lt_one.trans b1).ne' apply lt_imp_lt_of_le_imp_le (power_le_power_left <| power_ne_zero a b0) rw [← power_mul, mul_eq_self ha] exact lt_power_cof (ha.trans <| (cantor' _ b1).le) end Cardinal
interval_inference.v
(* mathcomp analysis (c) 2017 Inria and AIST. License: CeCILL-C. *) From HB Require Import structures. From mathcomp Require Import ssreflect ssrfun ssrbool ssrnat eqtype choice. From mathcomp Require Import order ssralg ssrnum ssrint interval. (**md**************************************************************************) (* # Numbers within an interval *) (* *) (* This file develops tools to make the manipulation of numbers within *) (* a known interval easier, thanks to canonical structures. This adds types *) (* like {itv R & `[a, b]}, a notation e%:itv that infers an enclosing *) (* interval for expression e according to existing canonical instances and *) (* %:num to cast back from type {itv R & i} to R. *) (* For instance, for x : {i01 R}, we have (1 - x%:num)%:itv : {i01 R} *) (* automatically inferred. *) (* *) (* ## types for values within known interval *) (* *) (* ``` *) (* {itv R & i} == generic type of values in interval i : interval int *) (* See interval.v for notations that can be used for i. *) (* R must have a numDomainType structure. This type is shown *) (* to be a porderType. *) (* {i01 R} := {itv R & `[0, 1]} *) (* Allows to solve automatically goals of the form x >= 0 *) (* and x <= 1 when x is canonically a {i01 R}. *) (* {i01 R} is canonically stable by common operations. *) (* {posnum R} := {itv R & `]0, +oo[) *) (* {nonneg R} := {itv R & `[0, +oo[) *) (* ``` *) (* *) (* ## casts from/to values within known interval *) (* *) (* Explicit casts of x to some {itv R & i} according to existing canonical *) (* instances: *) (* ``` *) (* x%:itv == cast to the most precisely known {itv R & i} *) (* x%:i01 == cast to {i01 R}, or fail *) (* x%:pos == cast to {posnum R}, or fail *) (* x%:nng == cast to {nonneg R}, or fail *) (* ``` *) (* *) (* Explicit casts of x from some {itv R & i} to R: *) (* ``` *) (* x%:num == cast from {itv R & i} *) (* x%:posnum == cast from {posnum R} *) (* x%:nngnum == cast from {nonneg R} *) (* ``` *) (* *) (* ## sign proofs *) (* *) (* ``` *) (* [itv of x] == proof that x is in the interval inferred by x%:itv *) (* [gt0 of x] == proof that x > 0 *) (* [lt0 of x] == proof that x < 0 *) (* [ge0 of x] == proof that x >= 0 *) (* [le0 of x] == proof that x <= 0 *) (* [cmp0 of x] == proof that 0 >=< x *) (* [neq0 of x] == proof that x != 0 *) (* ``` *) (* *) (* ## constructors *) (* *) (* ``` *) (* ItvNum xr lx xu == builds a {itv R & i} from proofs xr : x \in Num.real, *) (* lx : map_itv_bound (Itv.num_sem R) l <= BLeft x *) (* xu : BRight x <= map_itv_bound (Itv.num_sem R) u *) (* where x : R with R : numDomainType *) (* and l u : itv_bound int *) (* ItvReal lx xu == builds a {itv R & i} from proofs *) (* lx : map_itv_bound (Itv.num_sem R) l <= BLeft x *) (* xu : BRight x <= map_itv_bound (Itv.num_sem R) u *) (* where x : R with R : realDomainType *) (* and l u : itv_bound int *) (* Itv01 x0 x1 == builds a {i01 R} from proofs x0 : 0 <= x and x1 : x <= 1*) (* where x : R with R : numDomainType *) (* PosNum x0 == builds a {posnum R} from a proof x0 : x > 0 where x : R *) (* NngNum x0 == builds a {posnum R} from a proof x0 : x >= 0 where x : R*) (* ``` *) (* *) (* A number of canonical instances are provided for common operations, if *) (* your favorite operator is missing, look below for examples on how to add *) (* the appropriate Canonical. *) (* Also note that all provided instances aren't necessarily optimal, *) (* improvements welcome! *) (* Canonical instances are also provided according to types, as a *) (* fallback when no known operator appears in the expression. Look to top_typ *) (* below for an example on how to add your favorite type. *) (* *) (******************************************************************************) Reserved Notation "{ 'itv' R & i }" (R at level 200, i at level 200, format "{ 'itv' R & i }"). Reserved Notation "{ 'i01' R }" (R at level 200, format "{ 'i01' R }"). Reserved Notation "{ 'posnum' R }" (format "{ 'posnum' R }"). Reserved Notation "{ 'nonneg' R }" (format "{ 'nonneg' R }"). Reserved Notation "x %:itv" (format "x %:itv"). Reserved Notation "x %:i01" (format "x %:i01"). Reserved Notation "x %:pos" (format "x %:pos"). Reserved Notation "x %:nng" (format "x %:nng"). Reserved Notation "x %:inum" (format "x %:inum"). Reserved Notation "x %:num" (format "x %:num"). Reserved Notation "x %:posnum" (format "x %:posnum"). Reserved Notation "x %:nngnum" (format "x %:nngnum"). Reserved Notation "[ 'itv' 'of' x ]" (format "[ 'itv' 'of' x ]"). Reserved Notation "[ 'gt0' 'of' x ]" (format "[ 'gt0' 'of' x ]"). Reserved Notation "[ 'lt0' 'of' x ]" (format "[ 'lt0' 'of' x ]"). Reserved Notation "[ 'ge0' 'of' x ]" (format "[ 'ge0' 'of' x ]"). Reserved Notation "[ 'le0' 'of' x ]" (format "[ 'le0' 'of' x ]"). Reserved Notation "[ 'cmp0' 'of' x ]" (format "[ 'cmp0' 'of' x ]"). Reserved Notation "[ 'neq0' 'of' x ]" (format "[ 'neq0' 'of' x ]"). Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. Import Order.TTheory Order.Syntax. Import GRing.Theory Num.Theory. Local Open Scope ring_scope. Local Open Scope order_scope. Definition map_itv_bound S T (f : S -> T) (b : itv_bound S) : itv_bound T := match b with | BSide b x => BSide b (f x) | BInfty b => BInfty _ b end. Lemma map_itv_bound_comp S T U (f : T -> S) (g : U -> T) (b : itv_bound U) : map_itv_bound (f \o g) b = map_itv_bound f (map_itv_bound g b). Proof. by case: b. Qed. Definition map_itv S T (f : S -> T) (i : interval S) : interval T := let 'Interval l u := i in Interval (map_itv_bound f l) (map_itv_bound f u). Lemma map_itv_comp S T U (f : T -> S) (g : U -> T) (i : interval U) : map_itv (f \o g) i = map_itv f (map_itv g i). Proof. by case: i => l u /=; rewrite -!map_itv_bound_comp. Qed. (* First, the interval arithmetic operations we will later use *) Module IntItv. Implicit Types (b : itv_bound int) (i j : interval int). Definition opp_bound b := match b with | BSide b x => BSide (~~ b) (intZmod.oppz x) | BInfty b => BInfty _ (~~ b) end. Lemma opp_bound_ge0 b : (BLeft 0%R <= opp_bound b)%O = (b <= BRight 0%R)%O. Proof. by case: b => [[] b | []//]; rewrite /= !bnd_simp oppr_ge0. Qed. Lemma opp_bound_gt0 b : (BRight 0%R <= opp_bound b)%O = (b <= BLeft 0%R)%O. Proof. by case: b => [[] b | []//]; rewrite /= !bnd_simp ?oppr_ge0 ?oppr_gt0. Qed. Definition opp i := let: Interval l u := i in Interval (opp_bound u) (opp_bound l). Arguments opp /. Definition add_boundl b1 b2 := match b1, b2 with | BSide b1 x1, BSide b2 x2 => BSide (b1 && b2) (intZmod.addz x1 x2) | _, _ => BInfty _ true end. Definition add_boundr b1 b2 := match b1, b2 with | BSide b1 x1, BSide b2 x2 => BSide (b1 || b2) (intZmod.addz x1 x2) | _, _ => BInfty _ false end. Definition add i1 i2 := let: Interval l1 u1 := i1 in let: Interval l2 u2 := i2 in Interval (add_boundl l1 l2) (add_boundr u1 u2). Arguments add /. Variant signb := EqZero | NonNeg | NonPos. Definition sign_boundl b := let: b0 := BLeft 0%Z in if b == b0 then EqZero else if (b <= b0)%O then NonPos else NonNeg. Definition sign_boundr b := let: b0 := BRight 0%Z in if b == b0 then EqZero else if (b <= b0)%O then NonPos else NonNeg. Variant signi := Known of signb | Unknown | Empty. Definition sign i : signi := let: Interval l u := i in match sign_boundl l, sign_boundr u with | EqZero, NonPos | NonNeg, EqZero | NonNeg, NonPos => Empty | EqZero, EqZero => Known EqZero | NonPos, EqZero | NonPos, NonPos => Known NonPos | EqZero, NonNeg | NonNeg, NonNeg => Known NonNeg | NonPos, NonNeg => Unknown end. Definition mul_boundl b1 b2 := match b1, b2 with | BInfty _, _ | _, BInfty _ | BLeft 0%Z, _ | _, BLeft 0%Z => BLeft 0%Z | BSide b1 x1, BSide b2 x2 => BSide (b1 && b2) (intRing.mulz x1 x2) end. Definition mul_boundr b1 b2 := match b1, b2 with | BLeft 0%Z, _ | _, BLeft 0%Z => BLeft 0%Z | BRight 0%Z, _ | _, BRight 0%Z => BRight 0%Z | BSide b1 x1, BSide b2 x2 => BSide (b1 || b2) (intRing.mulz x1 x2) | _, BInfty _ | BInfty _, _ => +oo%O end. Lemma mul_boundrC b1 b2 : mul_boundr b1 b2 = mul_boundr b2 b1. Proof. by move: b1 b2 => [[] [[|?]|?] | []] [[] [[|?]|?] | []] //=; rewrite mulnC. Qed. Lemma mul_boundr_gt0 b1 b2 : (BRight 0%Z <= b1 -> BRight 0%Z <= b2 -> BRight 0%Z <= mul_boundr b1 b2)%O. Proof. case: b1 b2 => [b1b b1 | []] [b2b b2 | []]//=. - by case: b1b b2b => -[]; case: b1 b2 => [[|b1] | b1] [[|b2] | b2]. - by case: b1b b1 => -[[] |]. - by case: b2b b2 => -[[] |]. Qed. Definition mul i1 i2 := let: Interval l1 u1 := i1 in let: Interval l2 u2 := i2 in let: opp := opp_bound in let: mull := mul_boundl in let: mulr := mul_boundr in match sign i1, sign i2 with | Empty, _ | _, Empty => `[1, 0] | Known EqZero, _ | _, Known EqZero => `[0, 0] | Known NonNeg, Known NonNeg => Interval (mull l1 l2) (mulr u1 u2) | Known NonPos, Known NonPos => Interval (mull (opp u1) (opp u2)) (mulr (opp l1) (opp l2)) | Known NonNeg, Known NonPos => Interval (opp (mulr u1 (opp l2))) (opp (mull l1 (opp u2))) | Known NonPos, Known NonNeg => Interval (opp (mulr (opp l1) u2)) (opp (mull (opp u1) l2)) | Known NonNeg, Unknown => Interval (opp (mulr u1 (opp l2))) (mulr u1 u2) | Known NonPos, Unknown => Interval (opp (mulr (opp l1) u2)) (mulr (opp l1) (opp l2)) | Unknown, Known NonNeg => Interval (opp (mulr (opp l1) u2)) (mulr u1 u2) | Unknown, Known NonPos => Interval (opp (mulr u1 (opp l2))) (mulr (opp l1) (opp l2)) | Unknown, Unknown => Interval (Order.min (opp (mulr (opp l1) u2)) (opp (mulr u1 (opp l2)))) (Order.max (mulr (opp l1) (opp l2)) (mulr u1 u2)) end. Arguments mul /. Definition min i j := let: Interval li ui := i in let: Interval lj uj := j in Interval (Order.min li lj) (Order.min ui uj). Arguments min /. Definition max i j := let: Interval li ui := i in let: Interval lj uj := j in Interval (Order.max li lj) (Order.max ui uj). Arguments max /. Definition keep_nonneg_bound b := match b with | BSide _ (Posz _) => BLeft 0%Z | BSide _ (Negz _) => -oo%O | BInfty _ => -oo%O end. Arguments keep_nonneg_bound /. Definition keep_pos_bound b := match b with | BSide b 0%Z => BSide b 0%Z | BSide _ (Posz (S _)) => BRight 0%Z | BSide _ (Negz _) => -oo | BInfty _ => -oo end. Arguments keep_pos_bound /. Definition keep_nonpos_bound b := match b with | BSide _ (Negz _) | BSide _ (Posz 0) => BRight 0%Z | BSide _ (Posz (S _)) => +oo%O | BInfty _ => +oo%O end. Arguments keep_nonpos_bound /. Definition keep_neg_bound b := match b with | BSide b 0%Z => BSide b 0%Z | BSide _ (Negz _) => BLeft 0%Z | BSide _ (Posz _) => +oo | BInfty _ => +oo end. Arguments keep_neg_bound /. Definition inv i := let: Interval l u := i in Interval (keep_pos_bound l) (keep_neg_bound u). Arguments inv /. Definition exprn_le1_bound b1 b2 := if b2 isn't BSide _ 1%Z then +oo else if (BLeft (-1)%Z <= b1)%O then BRight 1%Z else +oo. Arguments exprn_le1_bound /. Definition exprn i := let: Interval l u := i in Interval (keep_pos_bound l) (exprn_le1_bound l u). Arguments exprn /. Definition exprz i1 i2 := let: Interval l2 _ := i2 in if l2 is BSide _ (Posz _) then exprn i1 else let: Interval l u := i1 in Interval (keep_pos_bound l) +oo. Arguments exprz /. Definition keep_sign i := let: Interval l u := i in Interval (keep_nonneg_bound l) (keep_nonpos_bound u). (* used in ereal.v *) Definition keep_nonpos i := let 'Interval l u := i in Interval -oo%O (keep_nonpos_bound u). Arguments keep_nonpos /. (* used in ereal.v *) Definition keep_nonneg i := let 'Interval l u := i in Interval (keep_nonneg_bound l) +oo%O. Arguments keep_nonneg /. End IntItv. Module Itv. Variant t := Top | Real of interval int. Definition sub (x y : t) := match x, y with | _, Top => true | Top, Real _ => false | Real xi, Real yi => subitv xi yi end. Section Itv. Context T (sem : interval int -> T -> bool). Definition spec (i : t) (x : T) := if i is Real i then sem i x else true. Record def (i : t) := Def { r : T; #[canonical=no] P : spec i r }. End Itv. Record typ i := Typ { sort : Type; #[canonical=no] sort_sem : interval int -> sort -> bool; #[canonical=no] allP : forall x : sort, spec sort_sem i x }. Definition mk {T f} i x P : @def T f i := @Def T f i x P. Definition from {T f i} {x : @def T f i} (phx : phantom T (r x)) := x. Definition fromP {T f i} {x : @def T f i} (phx : phantom T (r x)) := P x. Definition num_sem (R : numDomainType) (i : interval int) (x : R) : bool := (x \in Num.real) && (x \in map_itv intr i). Definition nat_sem (i : interval int) (x : nat) : bool := Posz x \in i. Definition posnum (R : numDomainType) of phant R := def (@num_sem R) (Real `]0, +oo[). Definition nonneg (R : numDomainType) of phant R := def (@num_sem R) (Real `[0, +oo[). (* a few lifting helper functions *) Definition real1 (op1 : interval int -> interval int) (x : Itv.t) : Itv.t := match x with Itv.Top => Itv.Top | Itv.Real x => Itv.Real (op1 x) end. Definition real2 (op2 : interval int -> interval int -> interval int) (x y : Itv.t) : Itv.t := match x, y with | Itv.Top, _ | _, Itv.Top => Itv.Top | Itv.Real x, Itv.Real y => Itv.Real (op2 x y) end. Lemma spec_real1 T f (op1 : T -> T) (op1i : interval int -> interval int) : forall (x : T), (forall xi, f xi x = true -> f (op1i xi) (op1 x) = true) -> forall xi, spec f xi x -> spec f (real1 op1i xi) (op1 x). Proof. by move=> x + [//| xi]; apply. Qed. Lemma spec_real2 T f (op2 : T -> T -> T) (op2i : interval int -> interval int -> interval int) (x y : T) : (forall xi yi, f xi x = true -> f yi y = true -> f (op2i xi yi) (op2 x y) = true) -> forall xi yi, spec f xi x -> spec f yi y -> spec f (real2 op2i xi yi) (op2 x y). Proof. by move=> + [//| xi] [//| yi]; apply. Qed. Module Exports. Arguments r {T sem i}. Notation "{ 'itv' R & i }" := (def (@num_sem R) (Itv.Real i%Z)) : type_scope. Notation "{ 'i01' R }" := {itv R & `[0, 1]} : type_scope. Notation "{ 'posnum' R }" := (@posnum _ (Phant R)) : ring_scope. Notation "{ 'nonneg' R }" := (@nonneg _ (Phant R)) : ring_scope. Notation "x %:itv" := (from (Phantom _ x)) : ring_scope. Notation "[ 'itv' 'of' x ]" := (fromP (Phantom _ x)) : ring_scope. Notation num := r. Notation "x %:inum" := (r x) (only parsing) : ring_scope. Notation "x %:num" := (r x) : ring_scope. Notation "x %:posnum" := (@r _ _ (Real `]0%Z, +oo[) x) : ring_scope. Notation "x %:nngnum" := (@r _ _ (Real `[0%Z, +oo[) x) : ring_scope. End Exports. End Itv. Export Itv.Exports. Local Notation num_spec := (Itv.spec (@Itv.num_sem _)). Local Notation num_def R := (Itv.def (@Itv.num_sem R)). Local Notation num_itv_bound R := (@map_itv_bound _ R intr). Local Notation nat_spec := (Itv.spec Itv.nat_sem). Local Notation nat_def := (Itv.def Itv.nat_sem). Section POrder. Context d (T : porderType d) (f : interval int -> T -> bool) (i : Itv.t). Local Notation itv := (Itv.def f i). HB.instance Definition _ := [isSub for @Itv.r T f i]. HB.instance Definition _ : Order.POrder d itv := [POrder of itv by <:]. End POrder. Section Order. Variables (R : numDomainType) (i : interval int). Local Notation nR := (num_def R (Itv.Real i)). Lemma itv_le_total_subproof : total (<=%O : rel nR). Proof. move=> x y; apply: real_comparable. - by case: x => [x /=/andP[]]. - by case: y => [y /=/andP[]]. Qed. HB.instance Definition _ := Order.POrder_isTotal.Build ring_display nR itv_le_total_subproof. End Order. Module TypInstances. Lemma top_typ_spec T f (x : T) : Itv.spec f Itv.Top x. Proof. by []. Qed. Canonical top_typ T f := Itv.Typ (@top_typ_spec T f). Lemma real_domain_typ_spec (R : realDomainType) (x : R) : num_spec (Itv.Real `]-oo, +oo[) x. Proof. by rewrite /Itv.num_sem/= num_real. Qed. Canonical real_domain_typ (R : realDomainType) := Itv.Typ (@real_domain_typ_spec R). Lemma real_field_typ_spec (R : realFieldType) (x : R) : num_spec (Itv.Real `]-oo, +oo[) x. Proof. exact: real_domain_typ_spec. Qed. Canonical real_field_typ (R : realFieldType) := Itv.Typ (@real_field_typ_spec R). Lemma nat_typ_spec (x : nat) : nat_spec (Itv.Real `[0, +oo[) x. Proof. by []. Qed. Canonical nat_typ := Itv.Typ nat_typ_spec. Lemma typ_inum_spec (i : Itv.t) (xt : Itv.typ i) (x : Itv.sort xt) : Itv.spec (@Itv.sort_sem _ xt) i x. Proof. by move: xt x => []. Qed. (* This adds _ <- Itv.r ( typ_inum ) to canonical projections (c.f., Print Canonical Projections Itv.r) meaning that if no other canonical instance (with a registered head symbol) is found, a canonical instance of Itv.typ, like the ones above, will be looked for. *) Canonical typ_inum (i : Itv.t) (xt : Itv.typ i) (x : Itv.sort xt) := Itv.mk (typ_inum_spec x). End TypInstances. Export (canonicals) TypInstances. Class unify {T} f (x y : T) := Unify : f x y = true. #[export] Hint Mode unify + + + + : typeclass_instances. Class unify' {T} f (x y : T) := Unify' : f x y = true. #[export] Instance unify'P {T} f (x y : T) : unify' f x y -> unify f x y := id. #[export] Hint Extern 0 (unify' _ _ _) => vm_compute; reflexivity : typeclass_instances. Notation unify_itv ix iy := (unify Itv.sub ix iy). #[export] Instance top_wider_anything i : unify_itv i Itv.Top. Proof. by case: i. Qed. #[export] Instance real_wider_anyreal i : unify_itv (Itv.Real i) (Itv.Real `]-oo, +oo[). Proof. by case: i => [l u]; apply/andP; rewrite !bnd_simp. Qed. Section NumDomainTheory. Context {R : numDomainType} {i : Itv.t}. Implicit Type x : num_def R i. Lemma le_num_itv_bound (x y : itv_bound int) : (num_itv_bound R x <= num_itv_bound R y)%O = (x <= y)%O. Proof. by case: x y => [[] x | x] [[] y | y]//=; rewrite !bnd_simp ?ler_int ?ltr_int. Qed. Lemma num_itv_bound_le_BLeft (x : itv_bound int) (y : int) : (num_itv_bound R x <= BLeft (y%:~R : R))%O = (x <= BLeft y)%O. Proof. rewrite -[BLeft y%:~R]/(map_itv_bound intr (BLeft y)). by rewrite le_num_itv_bound. Qed. Lemma BRight_le_num_itv_bound (x : int) (y : itv_bound int) : (BRight (x%:~R : R) <= num_itv_bound R y)%O = (BRight x <= y)%O. Proof. rewrite -[BRight x%:~R]/(map_itv_bound intr (BRight x)). by rewrite le_num_itv_bound. Qed. Lemma num_spec_sub (x y : Itv.t) : Itv.sub x y -> forall z : R, num_spec x z -> num_spec y z. Proof. case: x y => [| x] [| y] //= x_sub_y z /andP[rz]; rewrite /Itv.num_sem rz/=. move: x y x_sub_y => [lx ux] [ly uy] /andP[lel leu] /=. move=> /andP[lxz zux]; apply/andP; split. - by apply: le_trans lxz; rewrite le_num_itv_bound. - by apply: le_trans zux _; rewrite le_num_itv_bound. Qed. Definition empty_itv := Itv.Real `[1, 0]%Z. Lemma bottom x : ~ unify_itv i empty_itv. Proof. case: x => x /= /[swap] /num_spec_sub /[apply] /andP[_] /=. by rewrite in_itv/= => /andP[] /le_trans /[apply]; rewrite ler10. Qed. Lemma gt0 x : unify_itv i (Itv.Real `]0%Z, +oo[) -> 0 < x%:num :> R. Proof. case: x => x /= /[swap] /num_spec_sub /[apply] /andP[_]. by rewrite /= in_itv/= andbT. Qed. Lemma le0F x : unify_itv i (Itv.Real `]0%Z, +oo[) -> x%:num <= 0 :> R = false. Proof. case: x => x /= /[swap] /num_spec_sub /[apply] /andP[_] /=. by rewrite in_itv/= andbT => /lt_geF. Qed. Lemma lt0 x : unify_itv i (Itv.Real `]-oo, 0%Z[) -> x%:num < 0 :> R. Proof. by case: x => x /= /[swap] /num_spec_sub /[apply] /andP[_] /=; rewrite in_itv. Qed. Lemma ge0F x : unify_itv i (Itv.Real `]-oo, 0%Z[) -> 0 <= x%:num :> R = false. Proof. case: x => x /= /[swap] /num_spec_sub /[apply] /andP[_] /=. by rewrite in_itv/= => /lt_geF. Qed. Lemma ge0 x : unify_itv i (Itv.Real `[0%Z, +oo[) -> 0 <= x%:num :> R. Proof. case: x => x /= /[swap] /num_spec_sub /[apply] /andP[_] /=. by rewrite in_itv/= andbT. Qed. Lemma lt0F x : unify_itv i (Itv.Real `[0%Z, +oo[) -> x%:num < 0 :> R = false. Proof. case: x => x /= /[swap] /num_spec_sub /[apply] /andP[_] /=. by rewrite in_itv/= andbT => /le_gtF. Qed. Lemma le0 x : unify_itv i (Itv.Real `]-oo, 0%Z]) -> x%:num <= 0 :> R. Proof. by case: x => x /= /[swap] /num_spec_sub /[apply] /andP[_] /=; rewrite in_itv. Qed. Lemma gt0F x : unify_itv i (Itv.Real `]-oo, 0%Z]) -> 0 < x%:num :> R = false. Proof. case: x => x /= /[swap] /num_spec_sub /[apply] /andP[_] /=. by rewrite in_itv/= => /le_gtF. Qed. Lemma cmp0 x : unify_itv i (Itv.Real `]-oo, +oo[) -> 0 >=< x%:num. Proof. by case: i x => [//| i' [x /=/andP[]]]. Qed. Lemma neq0 x : unify (fun ix iy => ~~ Itv.sub ix iy) (Itv.Real `[0%Z, 0%Z]) i -> x%:num != 0 :> R. Proof. case: i x => [//| [l u] [x /= Px]]; apply: contra => /eqP x0 /=. move: Px; rewrite x0 => /and3P[_ /= l0 u0]; apply/andP; split. - by case: l l0 => [[] l /= |//]; rewrite !bnd_simp ?lerz0 ?ltrz0. - by case: u u0 => [[] u /= |//]; rewrite !bnd_simp ?ler0z ?ltr0z. Qed. Lemma eq0F x : unify (fun ix iy => ~~ Itv.sub ix iy) (Itv.Real `[0%Z, 0%Z]) i -> x%:num == 0 :> R = false. Proof. by move=> u; apply/negbTE/neq0. Qed. Lemma lt1 x : unify_itv i (Itv.Real `]-oo, 1%Z[) -> x%:num < 1 :> R. Proof. by case: x => x /= /[swap] /num_spec_sub /[apply] /andP[_] /=; rewrite in_itv. Qed. Lemma ge1F x : unify_itv i (Itv.Real `]-oo, 1%Z[) -> 1 <= x%:num :> R = false. Proof. case: x => x /= /[swap] /num_spec_sub /[apply] /andP[_] /=. by rewrite in_itv/= => /lt_geF. Qed. Lemma le1 x : unify_itv i (Itv.Real `]-oo, 1%Z]) -> x%:num <= 1 :> R. Proof. by case: x => x /= /[swap] /num_spec_sub /[apply] /andP[_] /=; rewrite in_itv. Qed. Lemma gt1F x : unify_itv i (Itv.Real `]-oo, 1%Z]) -> 1 < x%:num :> R = false. Proof. case: x => x /= /[swap] /num_spec_sub /[apply] /andP[_] /=. by rewrite in_itv/= => /le_gtF. Qed. Lemma widen_itv_subproof x i' : Itv.sub i i' -> num_spec i' x%:num. Proof. by case: x => x /= /[swap] /num_spec_sub; apply. Qed. Definition widen_itv x i' (uni : unify_itv i i') := Itv.mk (widen_itv_subproof x uni). Lemma widen_itvE x (uni : unify_itv i i) : @widen_itv x i uni = x. Proof. exact/val_inj. Qed. Lemma posE x (uni : unify_itv i (Itv.Real `]0%Z, +oo[)) : (widen_itv x%:num%:itv uni)%:num = x%:num. Proof. by []. Qed. Lemma nngE x (uni : unify_itv i (Itv.Real `[0%Z, +oo[)) : (widen_itv x%:num%:itv uni)%:num = x%:num. Proof. by []. Qed. End NumDomainTheory. Arguments bottom {R i} _ {_}. Arguments gt0 {R i} _ {_}. Arguments le0F {R i} _ {_}. Arguments lt0 {R i} _ {_}. Arguments ge0F {R i} _ {_}. Arguments ge0 {R i} _ {_}. Arguments lt0F {R i} _ {_}. Arguments le0 {R i} _ {_}. Arguments gt0F {R i} _ {_}. Arguments cmp0 {R i} _ {_}. Arguments neq0 {R i} _ {_}. Arguments eq0F {R i} _ {_}. Arguments lt1 {R i} _ {_}. Arguments ge1F {R i} _ {_}. Arguments le1 {R i} _ {_}. Arguments gt1F {R i} _ {_}. Arguments widen_itv {R i} _ {_ _}. Arguments widen_itvE {R i} _ {_}. Arguments posE {R i} _ {_}. Arguments nngE {R i} _ {_}. Notation "[ 'gt0' 'of' x ]" := (ltac:(refine (gt0 x%:itv))) (only parsing). Notation "[ 'lt0' 'of' x ]" := (ltac:(refine (lt0 x%:itv))) (only parsing). Notation "[ 'ge0' 'of' x ]" := (ltac:(refine (ge0 x%:itv))) (only parsing). Notation "[ 'le0' 'of' x ]" := (ltac:(refine (le0 x%:itv))) (only parsing). Notation "[ 'cmp0' 'of' x ]" := (ltac:(refine (cmp0 x%:itv))) (only parsing). Notation "[ 'neq0' 'of' x ]" := (ltac:(refine (neq0 x%:itv))) (only parsing). #[export] Hint Extern 0 (is_true (0%R < _)%R) => solve [apply: gt0] : core. #[export] Hint Extern 0 (is_true (_ < 0%R)%R) => solve [apply: lt0] : core. #[export] Hint Extern 0 (is_true (0%R <= _)%R) => solve [apply: ge0] : core. #[export] Hint Extern 0 (is_true (_ <= 0%R)%R) => solve [apply: le0] : core. #[export] Hint Extern 0 (is_true (_ \is Num.real)) => solve [apply: cmp0] : core. #[export] Hint Extern 0 (is_true (0%R >=< _)%R) => solve [apply: cmp0] : core. #[export] Hint Extern 0 (is_true (_ != 0%R)) => solve [apply: neq0] : core. #[export] Hint Extern 0 (is_true (_ < 1%R)%R) => solve [apply: lt1] : core. #[export] Hint Extern 0 (is_true (_ <= 1%R)%R) => solve [apply: le1] : core. Notation "x %:i01" := (widen_itv x%:itv : {i01 _}) (only parsing) : ring_scope. Notation "x %:i01" := (@widen_itv _ _ (@Itv.from _ _ _ (Phantom _ x)) (Itv.Real `[0, 1]%Z) _) (only printing) : ring_scope. Notation "x %:pos" := (widen_itv x%:itv : {posnum _}) (only parsing) : ring_scope. Notation "x %:pos" := (@widen_itv _ _ (@Itv.from _ _ _ (Phantom _ x)) (Itv.Real `]0%Z, +oo[) _) (only printing) : ring_scope. Notation "x %:nng" := (widen_itv x%:itv : {nonneg _}) (only parsing) : ring_scope. Notation "x %:nng" := (@widen_itv _ _ (@Itv.from _ _ _ (Phantom _ x)) (Itv.Real `[0%Z, +oo[) _) (only printing) : ring_scope. Local Open Scope ring_scope. Module Instances. Import IntItv. Section NumDomainInstances. Context {R : numDomainType}. Lemma num_spec_zero : num_spec (Itv.Real `[0, 0]) (0 : R). Proof. by apply/andP; split; [exact: real0 | rewrite /= in_itv/= lexx]. Qed. Canonical zero_inum := Itv.mk num_spec_zero. Lemma num_spec_one : num_spec (Itv.Real `[1, 1]) (1 : R). Proof. by apply/andP; split; [exact: real1 | rewrite /= in_itv/= lexx]. Qed. Canonical one_inum := Itv.mk num_spec_one. Lemma opp_boundr (x : R) b : (BRight (- x)%R <= num_itv_bound R (opp_bound b))%O = (num_itv_bound R b <= BLeft x)%O. Proof. by case: b => [[] b | []//]; rewrite /= !bnd_simp mulrNz ?lerN2 // ltrN2. Qed. Lemma opp_boundl (x : R) b : (num_itv_bound R (opp_bound b) <= BLeft (- x)%R)%O = (BRight x <= num_itv_bound R b)%O. Proof. by case: b => [[] b | []//]; rewrite /= !bnd_simp mulrNz ?lerN2 // ltrN2. Qed. Lemma num_spec_opp (i : Itv.t) (x : num_def R i) (r := Itv.real1 opp i) : num_spec r (- x%:num). Proof. apply: Itv.spec_real1 (Itv.P x). case: x => x /= _ [l u] /and3P[xr lx xu]. rewrite /Itv.num_sem/= realN xr/=; apply/andP. by rewrite opp_boundl opp_boundr. Qed. Canonical opp_inum (i : Itv.t) (x : num_def R i) := Itv.mk (num_spec_opp x). Lemma num_itv_add_boundl (x1 x2 : R) b1 b2 : (num_itv_bound R b1 <= BLeft x1)%O -> (num_itv_bound R b2 <= BLeft x2)%O -> (num_itv_bound R (add_boundl b1 b2) <= BLeft (x1 + x2)%R)%O. Proof. case: b1 b2 => [bb1 b1 |//] [bb2 b2 |//]. case: bb1; case: bb2; rewrite /= !bnd_simp mulrzDr. - exact: lerD. - exact: ler_ltD. - exact: ltr_leD. - exact: ltrD. Qed. Lemma num_itv_add_boundr (x1 x2 : R) b1 b2 : (BRight x1 <= num_itv_bound R b1)%O -> (BRight x2 <= num_itv_bound R b2)%O -> (BRight (x1 + x2)%R <= num_itv_bound R (add_boundr b1 b2))%O. Proof. case: b1 b2 => [bb1 b1 |//] [bb2 b2 |//]. case: bb1; case: bb2; rewrite /= !bnd_simp mulrzDr. - exact: ltrD. - exact: ltr_leD. - exact: ler_ltD. - exact: lerD. Qed. Lemma num_spec_add (xi yi : Itv.t) (x : num_def R xi) (y : num_def R yi) (r := Itv.real2 add xi yi) : num_spec r (x%:num + y%:num). Proof. apply: Itv.spec_real2 (Itv.P x) (Itv.P y). case: x y => [x /= _] [y /= _] => {xi yi r} -[lx ux] [ly uy]/=. move=> /andP[xr /=/andP[lxx xux]] /andP[yr /=/andP[lyy yuy]]. rewrite /Itv.num_sem realD//=; apply/andP. by rewrite num_itv_add_boundl ?num_itv_add_boundr. Qed. Canonical add_inum (xi yi : Itv.t) (x : num_def R xi) (y : num_def R yi) := Itv.mk (num_spec_add x y). Variant sign_spec (l u : itv_bound int) (x : R) : signi -> Set := | ISignEqZero : l = BLeft 0 -> u = BRight 0 -> x = 0 -> sign_spec l u x (Known EqZero) | ISignNonNeg : (BLeft 0%:Z <= l)%O -> (BRight 0%:Z < u)%O -> 0 <= x -> sign_spec l u x (Known NonNeg) | ISignNonPos : (l < BLeft 0%:Z)%O -> (u <= BRight 0%:Z)%O -> x <= 0 -> sign_spec l u x (Known NonPos) | ISignBoth : (l < BLeft 0%:Z)%O -> (BRight 0%:Z < u)%O -> x \in Num.real -> sign_spec l u x Unknown. Lemma signP (l u : itv_bound int) (x : R) : (num_itv_bound R l <= BLeft x)%O -> (BRight x <= num_itv_bound R u)%O -> x \in Num.real -> sign_spec l u x (sign (Interval l u)). Proof. move=> + + xr; rewrite /sign/sign_boundl/sign_boundr. have [lneg|lpos|->] := ltgtP l; have [uneg|upos|->] := ltgtP u => lx xu. - apply: ISignNonPos => //; first exact: ltW. have:= le_trans xu (eqbRL (le_num_itv_bound _ _) (ltW uneg)). by rewrite bnd_simp. - exact: ISignBoth. - exact: ISignNonPos. - have:= @ltxx _ _ (num_itv_bound R l). rewrite (le_lt_trans lx) -?leBRight_ltBLeft ?(le_trans xu)//. by rewrite le_num_itv_bound (le_trans (ltW uneg)). - apply: ISignNonNeg => //; first exact: ltW. have:= le_trans (eqbRL (le_num_itv_bound _ _) (ltW lpos)) lx. by rewrite bnd_simp. - have:= @ltxx _ _ (num_itv_bound R l). rewrite (le_lt_trans lx) -?leBRight_ltBLeft ?(le_trans xu)//. by rewrite le_num_itv_bound ?leBRight_ltBLeft. - have:= @ltxx _ _ (num_itv_bound R (BLeft 0%Z)). rewrite (le_lt_trans lx) -?leBRight_ltBLeft ?(le_trans xu)//. by rewrite le_num_itv_bound -?ltBRight_leBLeft. - exact: ISignNonNeg. - apply: ISignEqZero => //. by apply/le_anti/andP; move: lx xu; rewrite !bnd_simp. Qed. Lemma num_itv_mul_boundl b1 b2 (x1 x2 : R) : (BLeft 0%:Z <= b1 -> BLeft 0%:Z <= b2 -> num_itv_bound R b1 <= BLeft x1 -> num_itv_bound R b2 <= BLeft x2 -> num_itv_bound R (mul_boundl b1 b2) <= BLeft (x1 * x2))%O. Proof. move: b1 b2 => [[] b1 | []//] [[] b2 | []//] /=; rewrite 4!bnd_simp. - set bl := match b1 with 0%Z => _ | _ => _ end. have -> : bl = BLeft (b1 * b2). rewrite {}/bl; move: b1 b2 => [[|p1]|p1] [[|p2]|p2]; congr BLeft. by rewrite mulr0. by rewrite bnd_simp intrM -2!(ler0z R); apply: ler_pM. - case: b1 => [[|b1] | b1]; rewrite !bnd_simp// => b1p b2p sx1 sx2. + by rewrite mulr_ge0 ?(le_trans _ (ltW sx2)) ?ler0z. + rewrite intrM (@lt_le_trans _ _ (b1.+1%:~R * x2)) ?ltr_pM2l//. by rewrite ler_pM2r// (le_lt_trans _ sx2) ?ler0z. - case: b2 => [[|b2] | b2]; rewrite !bnd_simp// => b1p b2p sx1 sx2. + by rewrite mulr_ge0 ?(le_trans _ (ltW sx1)) ?ler0z. + rewrite intrM (@le_lt_trans _ _ (b1%:~R * x2)) ?ler_wpM2l ?ler0z//. by rewrite ltr_pM2r ?(lt_le_trans _ sx2). - by rewrite -2!(ler0z R) bnd_simp intrM; apply: ltr_pM. Qed. Lemma num_itv_mul_boundr b1 b2 (x1 x2 : R) : (0 <= x1 -> 0 <= x2 -> BRight x1 <= num_itv_bound R b1 -> BRight x2 <= num_itv_bound R b2 -> BRight (x1 * x2) <= num_itv_bound R (mul_boundr b1 b2))%O. Proof. case: b1 b2 => [b1b b1 | []] [b2b b2 | []] //= x1p x2p; last first. - case: b2b b2 => -[[|//] | //] _ x20. + have:= @ltxx _ (itv_bound R) (BLeft 0%:~R). by rewrite (lt_le_trans _ x20). + have -> : x2 = 0 by apply/le_anti/andP. by rewrite mulr0. - case: b1b b1 => -[[|//] |//] x10 _. + have:= @ltxx _ (itv_bound R) (BLeft 0%Z%:~R). by rewrite (lt_le_trans _ x10). + by have -> : x1 = 0; [apply/le_anti/andP | rewrite mul0r]. case: b1b b2b => -[]; rewrite -[intRing.mulz]/GRing.mul. - case: b1 => [[|b1] | b1]; rewrite !bnd_simp => x1b x2b. + by have:= @ltxx _ R 0; rewrite (le_lt_trans x1p x1b). + case: b2 x2b => [[| b2] | b2] => x2b; rewrite bnd_simp. * by have:= @ltxx _ R 0; rewrite (le_lt_trans x2p x2b). * by rewrite intrM ltr_pM. * have:= @ltxx _ R 0; rewrite (le_lt_trans x2p)//. by rewrite (lt_le_trans x2b) ?lerz0. + have:= @ltxx _ R 0; rewrite (le_lt_trans x1p)//. by rewrite (lt_le_trans x1b) ?lerz0. - case: b1 => [[|b1] | b1]; rewrite !bnd_simp => x1b x2b. + by have:= @ltxx _ R 0; rewrite (le_lt_trans x1p x1b). + case: b2 x2b => [[| b2] | b2] x2b; rewrite bnd_simp. * exact: mulr_ge0_le0. * by rewrite intrM (le_lt_trans (ler_wpM2l x1p x2b)) ?ltr_pM2r. * have:= @ltxx _ _ x2. by rewrite (le_lt_trans x2b) ?(lt_le_trans _ x2p) ?ltrz0. + have:= @ltxx _ _ x1. by rewrite (lt_le_trans x1b) ?(le_trans _ x1p) ?lerz0. - case: b1 => [[|b1] | b1]; rewrite !bnd_simp => x1b x2b. + case: b2 x2b => [[|b2] | b2] x2b; rewrite bnd_simp. * by have:= @ltxx _ _ x2; rewrite (lt_le_trans x2b). * by have -> : x1 = 0; [apply/le_anti/andP | rewrite mul0r]. * have:= @ltxx _ _ x2. by rewrite (lt_le_trans x2b) ?(le_trans _ x2p) ?lerz0. + case: b2 x2b => [[|b2] | b2] x2b; rewrite bnd_simp. * by have:= @ltxx _ _ x2; rewrite (lt_le_trans x2b). * by rewrite intrM (le_lt_trans (ler_wpM2r x2p x1b)) ?ltr_pM2l. * have:= @ltxx _ _ x2. by rewrite (lt_le_trans x2b) ?(le_trans _ x2p) ?lerz0. + have:= @ltxx _ _ x1. by rewrite (le_lt_trans x1b) ?(lt_le_trans _ x1p) ?ltrz0. - case: b1 => [[|b1] | b1]; rewrite !bnd_simp => x1b x2b. + by have -> : x1 = 0; [apply/le_anti/andP | rewrite mul0r]. + case: b2 x2b => [[| b2] | b2] x2b; rewrite bnd_simp. * by have -> : x2 = 0; [apply/le_anti/andP | rewrite mulr0]. * by rewrite intrM ler_pM. * have:= @ltxx _ _ x2. by rewrite (le_lt_trans x2b) ?(lt_le_trans _ x2p) ?ltrz0. + have:= @ltxx _ _ x1. by rewrite (le_lt_trans x1b) ?(lt_le_trans _ x1p) ?ltrz0. Qed. Lemma BRight_le_mul_boundr b1 b2 (x1 x2 : R) : (0 <= x1 -> x2 \in Num.real -> BRight 0%Z <= b2 -> BRight x1 <= num_itv_bound R b1 -> BRight x2 <= num_itv_bound R b2 -> BRight (x1 * x2) <= num_itv_bound R (mul_boundr b1 b2))%O. Proof. move=> x1ge0 x2r b2ge0 lex1b1 lex2b2. have /orP[x2ge0 | x2le0] := x2r; first exact: num_itv_mul_boundr. have lem0 : (BRight (x1 * x2) <= BRight 0%R)%O. by rewrite bnd_simp mulr_ge0_le0 // ltW. apply: le_trans lem0 _. rewrite -(mulr0z 1) BRight_le_num_itv_bound. apply: mul_boundr_gt0 => //. by rewrite -(@BRight_le_num_itv_bound R) (le_trans _ lex1b1). Qed. Lemma comparable_num_itv_bound (x y : itv_bound int) : (num_itv_bound R x >=< num_itv_bound R y)%O. Proof. by case: x y => [[] x | []] [[] y | []]//; apply/orP; rewrite !bnd_simp ?ler_int ?ltr_int; case: leP => xy; apply/orP => //; rewrite ltW ?orbT. Qed. Lemma num_itv_bound_min (x y : itv_bound int) : num_itv_bound R (Order.min x y) = Order.min (num_itv_bound R x) (num_itv_bound R y). Proof. have [lexy | ltyx] := leP x y; [by rewrite !minEle le_num_itv_bound lexy|]. rewrite minElt -if_neg -comparable_leNgt ?le_num_itv_bound ?ltW//. exact: comparable_num_itv_bound. Qed. Lemma num_itv_bound_max (x y : itv_bound int) : num_itv_bound R (Order.max x y) = Order.max (num_itv_bound R x) (num_itv_bound R y). Proof. have [lexy | ltyx] := leP x y; [by rewrite !maxEle le_num_itv_bound lexy|]. rewrite maxElt -if_neg -comparable_leNgt ?le_num_itv_bound ?ltW//. exact: comparable_num_itv_bound. Qed. Lemma num_spec_mul (xi yi : Itv.t) (x : num_def R xi) (y : num_def R yi) (r := Itv.real2 mul xi yi) : num_spec r (x%:num * y%:num). Proof. rewrite {}/r; case: xi yi x y => [//| [xl xu]] [//| [yl yu]]. case=> [x /=/and3P[xr /= xlx xxu]] [y /=/and3P[yr /= yly yyu]]. rewrite -/(sign (Interval xl xu)) -/(sign (Interval yl yu)). have ns000 : @Itv.num_sem R `[0, 0] 0 by apply/and3P. have xyr : x * y \in Num.real by exact: realM. case: (signP xlx xxu xr) => xlb xub xs. - by rewrite xs mul0r; case: (signP yly yyu yr). - case: (signP yly yyu yr) => ylb yub ys. + by rewrite ys mulr0. + apply/and3P; split=> //=. * exact: num_itv_mul_boundl xlx yly. * exact: num_itv_mul_boundr xxu yyu. + apply/and3P; split=> //=; rewrite -[x * y]opprK -mulrN. * by rewrite opp_boundl num_itv_mul_boundr ?oppr_ge0// opp_boundr. * by rewrite opp_boundr num_itv_mul_boundl ?opp_boundl// opp_bound_ge0. + apply/and3P; split=> //=. * rewrite -[x * y]opprK -mulrN opp_boundl. by rewrite BRight_le_mul_boundr ?realN ?opp_boundr// opp_bound_gt0 ltW. * by rewrite BRight_le_mul_boundr// ltW. - case: (signP yly yyu yr) => ylb yub ys. + by rewrite ys mulr0. + apply/and3P; split=> //=; rewrite -[x * y]opprK -mulNr. * rewrite opp_boundl. by rewrite num_itv_mul_boundr ?oppr_ge0 ?opp_boundr. * by rewrite opp_boundr num_itv_mul_boundl ?opp_boundl// opp_bound_ge0. + apply/and3P; split=> //=; rewrite -mulrNN. * by rewrite num_itv_mul_boundl ?opp_bound_ge0 ?opp_boundl. * by rewrite num_itv_mul_boundr ?oppr_ge0 ?opp_boundr. + apply/and3P; split=> //=; rewrite -[x * y]opprK. * rewrite -mulNr opp_boundl BRight_le_mul_boundr ?oppr_ge0 ?opp_boundr//. exact: ltW. * rewrite opprK -mulrNN. by rewrite BRight_le_mul_boundr ?opp_boundr ?oppr_ge0 ?realN ?opp_bound_gt0// ltW. - case: (signP yly yyu yr) => ylb yub ys. + by rewrite ys mulr0. + apply/and3P; split=> //=; rewrite mulrC mul_boundrC. * rewrite -[y * x]opprK -mulrN opp_boundl. rewrite BRight_le_mul_boundr ?oppr_ge0 ?realN ?opp_boundr//. by rewrite opp_bound_gt0 ltW. * by rewrite BRight_le_mul_boundr// ltW. + apply/and3P; split=> //=; rewrite mulrC mul_boundrC. * rewrite -[y * x]opprK -mulNr opp_boundl. by rewrite BRight_le_mul_boundr ?oppr_ge0 ?opp_boundr// ltW. * rewrite -mulrNN BRight_le_mul_boundr ?oppr_ge0 ?realN ?opp_boundr//. by rewrite opp_bound_gt0 ltW. apply/and3P; rewrite xyr/= num_itv_bound_min num_itv_bound_max. rewrite (comparable_ge_min _ (comparable_num_itv_bound _ _)). rewrite (comparable_le_max _ (comparable_num_itv_bound _ _)). case: (comparable_leP xr) => [x0 | /ltW x0]; split=> //. - apply/orP; right; rewrite -[x * y]opprK -mulrN opp_boundl. by rewrite BRight_le_mul_boundr ?realN ?opp_boundr// opp_bound_gt0 ltW. - by apply/orP; right; rewrite BRight_le_mul_boundr// ltW. - apply/orP; left; rewrite -[x * y]opprK -mulNr opp_boundl. by rewrite BRight_le_mul_boundr ?oppr_ge0 ?opp_boundr// ltW. - apply/orP; left; rewrite -mulrNN. rewrite BRight_le_mul_boundr ?oppr_ge0 ?realN ?opp_boundr//. by rewrite opp_bound_gt0 ltW. Qed. Canonical mul_inum (xi yi : Itv.t) (x : num_def R xi) (y : num_def R yi) := Itv.mk (num_spec_mul x y). Lemma num_spec_min (xi yi : Itv.t) (x : num_def R xi) (y : num_def R yi) (r := Itv.real2 min xi yi) : num_spec r (Order.min x%:num y%:num). Proof. apply: Itv.spec_real2 (Itv.P x) (Itv.P y). case: x y => [x /= _] [y /= _] => {xi yi r} -[lx ux] [ly uy]/=. move=> /andP[xr /=/andP[lxx xux]] /andP[yr /=/andP[lyy yuy]]. apply/and3P; split; rewrite ?min_real//= num_itv_bound_min real_BSide_min//. - apply: (comparable_le_min2 (comparable_num_itv_bound _ _)) => //. exact: real_comparable. - apply: (comparable_le_min2 _ (comparable_num_itv_bound _ _)) => //. exact: real_comparable. Qed. Lemma num_spec_max (xi yi : Itv.t) (x : num_def R xi) (y : num_def R yi) (r := Itv.real2 max xi yi) : num_spec r (Order.max x%:num y%:num). Proof. apply: Itv.spec_real2 (Itv.P x) (Itv.P y). case: x y => [x /= _] [y /= _] => {xi yi r} -[lx ux] [ly uy]/=. move=> /andP[xr /=/andP[lxx xux]] /andP[yr /=/andP[lyy yuy]]. apply/and3P; split; rewrite ?max_real//= num_itv_bound_max real_BSide_max//. - apply: (comparable_le_max2 (comparable_num_itv_bound _ _)) => //. exact: real_comparable. - apply: (comparable_le_max2 _ (comparable_num_itv_bound _ _)) => //. exact: real_comparable. Qed. (* We can't directly put an instance on Order.min for R : numDomainType since we may want instances for other porderType (typically \bar R or even nat). So we resort on this additional canonical structure. *) Record min_max_typ d := MinMaxTyp { min_max_sort : porderType d; #[canonical=no] min_max_sem : interval int -> min_max_sort -> bool; #[canonical=no] min_max_minP : forall (xi yi : Itv.t) (x : Itv.def min_max_sem xi) (y : Itv.def min_max_sem yi), let: r := Itv.real2 min xi yi in Itv.spec min_max_sem r (Order.min x%:num y%:num); #[canonical=no] min_max_maxP : forall (xi yi : Itv.t) (x : Itv.def min_max_sem xi) (y : Itv.def min_max_sem yi), let: r := Itv.real2 max xi yi in Itv.spec min_max_sem r (Order.max x%:num y%:num); }. (* The default instances on porderType, for min... *) Canonical min_typ_inum d (t : min_max_typ d) (xi yi : Itv.t) (x : Itv.def (@min_max_sem d t) xi) (y : Itv.def (@min_max_sem d t) yi) (r := Itv.real2 min xi yi) := Itv.mk (min_max_minP x y). (* ...and for max *) Canonical max_typ_inum d (t : min_max_typ d) (xi yi : Itv.t) (x : Itv.def (@min_max_sem d t) xi) (y : Itv.def (@min_max_sem d t) yi) (r := Itv.real2 min xi yi) := Itv.mk (min_max_maxP x y). (* Instance of the above structure for numDomainType *) Canonical num_min_max_typ := MinMaxTyp num_spec_min num_spec_max. Lemma nat_num_spec (i : Itv.t) (n : nat) : nat_spec i n = num_spec i (n%:R : R). Proof. case: i => [//| [l u]]; rewrite /= /Itv.num_sem realn/=; congr (_ && _). - by case: l => [[] l |//]; rewrite !bnd_simp ?pmulrn ?ler_int ?ltr_int. - by case: u => [[] u |//]; rewrite !bnd_simp ?pmulrn ?ler_int ?ltr_int. Qed. Definition natmul_itv (i1 i2 : Itv.t) : Itv.t := match i1, i2 with | Itv.Top, _ => Itv.Top | _, Itv.Top => Itv.Real `]-oo, +oo[ | Itv.Real i1, Itv.Real i2 => Itv.Real (mul i1 i2) end. Arguments natmul_itv /. Lemma num_spec_natmul (xi ni : Itv.t) (x : num_def R xi) (n : nat_def ni) (r := natmul_itv xi ni) : num_spec r (x%:num *+ n%:num). Proof. rewrite {}/r; case: xi x ni n => [//| xi] x [| ni] n. by apply/and3P; case: n%:num => [|?]; rewrite ?mulr0n ?realrMn. have Pn : num_spec (Itv.Real ni) (n%:num%:R : R). by case: n => /= n; rewrite [Itv.nat_sem ni n](nat_num_spec (Itv.Real ni)). rewrite -mulr_natr -[n%:num%:R]/((Itv.Def Pn)%:num). by rewrite (@num_spec_mul (Itv.Real xi) (Itv.Real ni)). Qed. Canonical natmul_inum (xi ni : Itv.t) (x : num_def R xi) (n : nat_def ni) := Itv.mk (num_spec_natmul x n). Lemma num_spec_int (i : Itv.t) (n : int) : num_spec i n = num_spec i (n%:~R : R). Proof. case: i => [//| [l u]]; rewrite /= /Itv.num_sem num_real realz/=. congr (andb _ _). - by case: l => [[] l |//]; rewrite !bnd_simp intz ?ler_int ?ltr_int. - by case: u => [[] u |//]; rewrite !bnd_simp intz ?ler_int ?ltr_int. Qed. Lemma num_spec_intmul (xi ii : Itv.t) (x : num_def R xi) (i : num_def int ii) (r := natmul_itv xi ii) : num_spec r (x%:num *~ i%:num). Proof. rewrite {}/r; case: xi x ii i => [//| xi] x [| ii] i. by apply/and3P; case: i%:inum => [[|n] | n]; rewrite ?mulr0z ?realN ?realrMn. have Pi : num_spec (Itv.Real ii) (i%:num%:~R : R). by case: i => /= i; rewrite [Itv.num_sem ii i](num_spec_int (Itv.Real ii)). rewrite -mulrzr -[i%:num%:~R]/((Itv.Def Pi)%:num). by rewrite (@num_spec_mul (Itv.Real xi) (Itv.Real ii)). Qed. Canonical intmul_inum (xi ni : Itv.t) (x : num_def R xi) (n : num_def int ni) := Itv.mk (num_spec_intmul x n). Lemma num_itv_bound_keep_pos (op : R -> R) (x : R) b : {homo op : x / 0 <= x} -> {homo op : x / 0 < x} -> (num_itv_bound R b <= BLeft x)%O -> (num_itv_bound R (keep_pos_bound b) <= BLeft (op x))%O. Proof. case: b => [[] [] [| b] // | []//] hle hlt; rewrite !bnd_simp. - exact: hle. - by move=> blex; apply: le_lt_trans (hlt _ _) => //; apply: lt_le_trans blex. - exact: hlt. - by move=> bltx; apply: le_lt_trans (hlt _ _) => //; apply: le_lt_trans bltx. Qed. Lemma num_itv_bound_keep_neg (op : R -> R) (x : R) b : {homo op : x / x <= 0} -> {homo op : x / x < 0} -> (BRight x <= num_itv_bound R b)%O -> (BRight (op x) <= num_itv_bound R (keep_neg_bound b))%O. Proof. case: b => [[] [[|//] | b] | []//] hge hgt; rewrite !bnd_simp. - exact: hgt. - by move=> xltb; apply: hgt; apply: lt_le_trans xltb _; rewrite lerz0. - exact: hge. - by move=> xleb; apply: hgt; apply: le_lt_trans xleb _; rewrite ltrz0. Qed. Lemma num_spec_inv (i : Itv.t) (x : num_def R i) (r := Itv.real1 inv i) : num_spec r (x%:num^-1). Proof. apply: Itv.spec_real1 (Itv.P x). case: x => x /= _ [l u] /and3P[xr /= lx xu]. rewrite /Itv.num_sem/= realV xr/=; apply/andP; split. - apply: num_itv_bound_keep_pos lx. + by move=> ?; rewrite invr_ge0. + by move=> ?; rewrite invr_gt0. - apply: num_itv_bound_keep_neg xu. + by move=> ?; rewrite invr_le0. + by move=> ?; rewrite invr_lt0. Qed. Canonical inv_inum (i : Itv.t) (x : num_def R i) := Itv.mk (num_spec_inv x). Lemma num_itv_bound_exprn_le1 (x : R) n l u : (num_itv_bound R l <= BLeft x)%O -> (BRight x <= num_itv_bound R u)%O -> (BRight (x ^+ n) <= num_itv_bound R (exprn_le1_bound l u))%O. Proof. case: u => [bu [[//|[|//]] |//] | []//]. rewrite /exprn_le1_bound; case: (leP _ l) => [lge1 /= |//] lx xu. rewrite bnd_simp; case: n => [| n]; rewrite ?expr0//. have xN1 : -1 <= x. case: l lge1 lx => [[] l | []//]; rewrite !bnd_simp -(@ler_int R). - exact: le_trans. - by move=> + /ltW; apply: le_trans. have x1 : x <= 1 by case: bu xu; rewrite bnd_simp// => /ltW. have xr : x \is Num.real by exact: ler1_real. case: (real_ge0P xr) => x0; first by rewrite expr_le1. rewrite -[x]opprK exprNn; apply: le_trans (ler_piMl _ _) _. - by rewrite exprn_ge0 ?oppr_ge0 1?ltW. - suff: -1 <= (-1) ^+ n.+1 :> R /\ (-1) ^+ n.+1 <= 1 :> R => [[]//|]. elim: n => [|n [IHn1 IHn2]]; rewrite ?expr1// ![_ ^+ n.+2]exprS !mulN1r. by rewrite lerNl opprK lerNl. - by rewrite expr_le1 ?oppr_ge0 1?lerNl// ltW. Qed. Lemma num_spec_exprn (i : Itv.t) (x : num_def R i) n (r := Itv.real1 exprn i) : num_spec r (x%:num ^+ n). Proof. apply: (@Itv.spec_real1 _ _ (fun x => x^+n) _ _ _ _ (Itv.P x)). case: x => x /= _ [l u] /and3P[xr /= lx xu]. rewrite /Itv.num_sem realX//=; apply/andP; split. - apply: (@num_itv_bound_keep_pos (fun x => x^+n)) lx. + exact: exprn_ge0. + exact: exprn_gt0. - exact: num_itv_bound_exprn_le1 lx xu. Qed. Canonical exprn_inum (i : Itv.t) (x : num_def R i) n := Itv.mk (num_spec_exprn x n). Lemma num_spec_exprz (xi ki : Itv.t) (x : num_def R xi) (k : num_def int ki) (r := Itv.real2 exprz xi ki) : num_spec r (x%:num ^ k%:num). Proof. rewrite {}/r; case: ki k => [|[lk uk]] k; first by case: xi x. case: xi x => [//|xi x]; rewrite /Itv.real2. have P : Itv.num_sem (let 'Interval l _ := xi in Interval (keep_pos_bound l) +oo) (x%:num ^ k%:num). case: xi x => lx ux x; apply/and3P; split=> [||//]. have xr : x%:num \is Num.real by case: x => x /=/andP[]. by case: k%:num => n; rewrite ?realV realX. apply: (@num_itv_bound_keep_pos (fun x => x ^ k%:num)); [exact: exprz_ge0 | exact: exprz_gt0 |]. by case: x => x /=/and3P[]. case: lk k P => [slk [lk | lk] | slk] k P; [|exact: P..]. case: k P => -[k | k] /= => [_ _|]; rewrite -/(exprn xi); last first. by move=> /and3P[_ /=]; case: slk; rewrite bnd_simp -pmulrn natz. exact: (@num_spec_exprn (Itv.Real xi)). Qed. Canonical exprz_inum (xi ki : Itv.t) (x : num_def R xi) (k : num_def int ki) := Itv.mk (num_spec_exprz x k). Lemma num_spec_norm {V : normedZmodType R} (x : V) : num_spec (Itv.Real `[0, +oo[) `|x|. Proof. by apply/and3P; split; rewrite //= ?normr_real ?bnd_simp ?normr_ge0. Qed. Canonical norm_inum {V : normedZmodType R} (x : V) := Itv.mk (num_spec_norm x). End NumDomainInstances. Section RcfInstances. Context {R : rcfType}. Definition sqrt_itv (i : Itv.t) : Itv.t := match i with | Itv.Top => Itv.Real `[0%Z, +oo[ | Itv.Real (Interval l u) => match l with | BSide b 0%Z => Itv.Real (Interval (BSide b 0%Z) +oo) | BSide b (Posz (S _)) => Itv.Real `]0%Z, +oo[ | _ => Itv.Real `[0, +oo[ end end. Arguments sqrt_itv /. Lemma num_spec_sqrt (i : Itv.t) (x : num_def R i) (r := sqrt_itv i) : num_spec r (Num.sqrt x%:num). Proof. have: Itv.num_sem `[0%Z, +oo[ (Num.sqrt x%:num). by apply/and3P; rewrite /= num_real !bnd_simp sqrtr_ge0. rewrite {}/r; case: i x => [//| [[bl [l |//] |//] u]] [x /= +] _. case: bl l => -[| l] /and3P[xr /= bx _]; apply/and3P; split=> //=; move: bx; rewrite !bnd_simp ?sqrtr_ge0// sqrtr_gt0; [exact: lt_le_trans | exact: le_lt_trans..]. Qed. Canonical sqrt_inum (i : Itv.t) (x : num_def R i) := Itv.mk (num_spec_sqrt x). End RcfInstances. Section NumClosedFieldInstances. Context {R : numClosedFieldType}. Definition sqrtC_itv (i : Itv.t) : Itv.t := match i with | Itv.Top => Itv.Top | Itv.Real (Interval l u) => match l with | BSide b (Posz _) => Itv.Real (Interval (BSide b 0%Z) +oo) | _ => Itv.Top end end. Arguments sqrtC_itv /. Lemma num_spec_sqrtC (i : Itv.t) (x : num_def R i) (r := sqrtC_itv i) : num_spec r (sqrtC x%:num). Proof. rewrite {}/r; case: i x => [//| [l u] [x /=/and3P[xr /= lx xu]]]. case: l lx => [bl [l |//] |[]//] lx; apply/and3P; split=> //=. by apply: sqrtC_real; case: bl lx => /[!bnd_simp] [|/ltW]; apply: le_trans. case: bl lx => /[!bnd_simp] lx. - by rewrite sqrtC_ge0; apply: le_trans lx. - by rewrite sqrtC_gt0; apply: le_lt_trans lx. Qed. Canonical sqrtC_inum (i : Itv.t) (x : num_def R i) := Itv.mk (num_spec_sqrtC x). End NumClosedFieldInstances. Section NatInstances. Local Open Scope nat_scope. Implicit Type (n : nat). Lemma nat_spec_zero : nat_spec (Itv.Real `[0, 0]%Z) 0. Proof. by []. Qed. Canonical zeron_inum := Itv.mk nat_spec_zero. Lemma nat_spec_add (xi yi : Itv.t) (x : nat_def xi) (y : nat_def yi) (r := Itv.real2 add xi yi) : nat_spec r (x%:num + y%:num). Proof. have Px : num_spec xi (x%:num%:R : int). by case: x => /= x; rewrite (@nat_num_spec int). have Py : num_spec yi (y%:num%:R : int). by case: y => /= y; rewrite (@nat_num_spec int). rewrite (@nat_num_spec int) natrD. rewrite -[x%:num%:R]/((Itv.Def Px)%:num) -[y%:num%:R]/((Itv.Def Py)%:num). exact: num_spec_add. Qed. Canonical addn_inum (xi yi : Itv.t) (x : nat_def xi) (y : nat_def yi) := Itv.mk (nat_spec_add x y). Lemma nat_spec_succ (i : Itv.t) (n : nat_def i) (r := Itv.real2 add i (Itv.Real `[1, 1]%Z)) : nat_spec r (S n%:num). Proof. pose i1 := Itv.Real `[1, 1]%Z; have P1 : nat_spec i1 1 by []. by rewrite -addn1 -[1%N]/((Itv.Def P1)%:num); apply: nat_spec_add. Qed. Canonical succn_inum (i : Itv.t) (n : nat_def i) := Itv.mk (nat_spec_succ n). Lemma nat_spec_double (i : Itv.t) (n : nat_def i) (r := Itv.real2 add i i) : nat_spec r (n%:num.*2). Proof. by rewrite -addnn nat_spec_add. Qed. Canonical double_inum (i : Itv.t) (x : nat_def i) := Itv.mk (nat_spec_double x). Lemma nat_spec_mul (xi yi : Itv.t) (x : nat_def xi) (y : nat_def yi) (r := Itv.real2 mul xi yi) : nat_spec r (x%:num * y%:num). Proof. have Px : num_spec xi (x%:num%:R : int). by case: x => /= x; rewrite (@nat_num_spec int). have Py : num_spec yi (y%:num%:R : int). by case: y => /= y; rewrite (@nat_num_spec int). rewrite (@nat_num_spec int) natrM. rewrite -[x%:num%:R]/((Itv.Def Px)%:num) -[y%:num%:R]/((Itv.Def Py)%:num). exact: num_spec_mul. Qed. Canonical muln_inum (xi yi : Itv.t) (x : nat_def xi) (y : nat_def yi) := Itv.mk (nat_spec_mul x y). Lemma nat_spec_exp (i : Itv.t) (x : nat_def i) n (r := Itv.real1 exprn i) : nat_spec r (x%:num ^ n). Proof. have Px : num_spec i (x%:num%:R : int). by case: x => /= x; rewrite (@nat_num_spec int). rewrite (@nat_num_spec int) natrX -[x%:num%:R]/((Itv.Def Px)%:num). exact: num_spec_exprn. Qed. Canonical expn_inum (i : Itv.t) (x : nat_def i) n := Itv.mk (nat_spec_exp x n). Lemma nat_spec_min (xi yi : Itv.t) (x : nat_def xi) (y : nat_def yi) (r := Itv.real2 min xi yi) : nat_spec r (minn x%:num y%:num). Proof. have Px : num_spec xi (x%:num%:R : int). by case: x => /= x; rewrite (@nat_num_spec int). have Py : num_spec yi (y%:num%:R : int). by case: y => /= y; rewrite (@nat_num_spec int). rewrite (@nat_num_spec int) -minEnat natr_min. rewrite -[x%:num%:R]/((Itv.Def Px)%:num) -[y%:num%:R]/((Itv.Def Py)%:num). exact: num_spec_min. Qed. Canonical minn_inum (xi yi : Itv.t) (x : nat_def xi) (y : nat_def yi) := Itv.mk (nat_spec_min x y). Lemma nat_spec_max (xi yi : Itv.t) (x : nat_def xi) (y : nat_def yi) (r := Itv.real2 max xi yi) : nat_spec r (maxn x%:num y%:num). Proof. have Px : num_spec xi (x%:num%:R : int). by case: x => /= x; rewrite (@nat_num_spec int). have Py : num_spec yi (y%:num%:R : int). by case: y => /= y; rewrite (@nat_num_spec int). rewrite (@nat_num_spec int) -maxEnat natr_max. rewrite -[x%:num%:R]/((Itv.Def Px)%:num) -[y%:num%:R]/((Itv.Def Py)%:num). exact: num_spec_max. Qed. Canonical maxn_inum (xi yi : Itv.t) (x : nat_def xi) (y : nat_def yi) := Itv.mk (nat_spec_max x y). Canonical nat_min_max_typ := MinMaxTyp nat_spec_min nat_spec_max. Lemma nat_spec_factorial (n : nat) : nat_spec (Itv.Real `[1%Z, +oo[) n`!. Proof. by apply/andP; rewrite bnd_simp lez_nat fact_gt0. Qed. Canonical factorial_inum n := Itv.mk (nat_spec_factorial n). End NatInstances. Section IntInstances. Lemma num_spec_Posz n : num_spec (Itv.Real `[0, +oo[) (Posz n). Proof. by apply/and3P; rewrite /= num_real !bnd_simp. Qed. Canonical Posz_inum n := Itv.mk (num_spec_Posz n). Lemma num_spec_Negz n : num_spec (Itv.Real `]-oo, (-1)]) (Negz n). Proof. by apply/and3P; rewrite /= num_real !bnd_simp. Qed. Canonical Negz_inum n := Itv.mk (num_spec_Negz n). End IntInstances. End Instances. Export (canonicals) Instances. Section Morph. Context {R : numDomainType} {i : Itv.t}. Local Notation nR := (num_def R i). Implicit Types x y : nR. Local Notation num := (@num R (@Itv.num_sem R) i). Lemma num_eq : {mono num : x y / x == y}. Proof. by []. Qed. Lemma num_le : {mono num : x y / (x <= y)%O}. Proof. by []. Qed. Lemma num_lt : {mono num : x y / (x < y)%O}. Proof. by []. Qed. Lemma num_min : {morph num : x y / Order.min x y}. Proof. by move=> x y; rewrite !minEle num_le -fun_if. Qed. Lemma num_max : {morph num : x y / Order.max x y}. Proof. by move=> x y; rewrite !maxEle num_le -fun_if. Qed. End Morph. Section MorphNum. Context {R : numDomainType}. Lemma num_abs_eq0 (a : R) : (`|a|%:nng == 0%:nng) = (a == 0). Proof. by rewrite -normr_eq0. Qed. End MorphNum. Section MorphReal. Context {R : numDomainType} {i : interval int}. Local Notation nR := (num_def R (Itv.Real i)). Implicit Type x y : nR. Local Notation num := (@num R (@Itv.num_sem R) i). Lemma num_le_max a x y : a <= Num.max x%:num y%:num = (a <= x%:num) || (a <= y%:num). Proof. by rewrite -comparable_le_max// real_comparable. Qed. Lemma num_ge_max a x y : Num.max x%:num y%:num <= a = (x%:num <= a) && (y%:num <= a). Proof. by rewrite -comparable_ge_max// real_comparable. Qed. Lemma num_le_min a x y : a <= Num.min x%:num y%:num = (a <= x%:num) && (a <= y%:num). Proof. by rewrite -comparable_le_min// real_comparable. Qed. Lemma num_ge_min a x y : Num.min x%:num y%:num <= a = (x%:num <= a) || (y%:num <= a). Proof. by rewrite -comparable_ge_min// real_comparable. Qed. Lemma num_lt_max a x y : a < Num.max x%:num y%:num = (a < x%:num) || (a < y%:num). Proof. by rewrite -comparable_lt_max// real_comparable. Qed. Lemma num_gt_max a x y : Num.max x%:num y%:num < a = (x%:num < a) && (y%:num < a). Proof. by rewrite -comparable_gt_max// real_comparable. Qed. Lemma num_lt_min a x y : a < Num.min x%:num y%:num = (a < x%:num) && (a < y%:num). Proof. by rewrite -comparable_lt_min// real_comparable. Qed. Lemma num_gt_min a x y : Num.min x%:num y%:num < a = (x%:num < a) || (y%:num < a). Proof. by rewrite -comparable_gt_min// real_comparable. Qed. End MorphReal. Section MorphGe0. Context {R : numDomainType}. Local Notation nR := (num_def R (Itv.Real `[0%Z, +oo[)). Implicit Type x y : nR. Local Notation num := (@num R (@Itv.num_sem R) (Itv.Real `[0%Z, +oo[)). Lemma num_abs_le a x : 0 <= a -> (`|a|%:nng <= x) = (a <= x%:num). Proof. by move=> a0; rewrite -num_le//= ger0_norm. Qed. Lemma num_abs_lt a x : 0 <= a -> (`|a|%:nng < x) = (a < x%:num). Proof. by move=> a0; rewrite -num_lt/= ger0_norm. Qed. End MorphGe0. Section ItvNum. Context (R : numDomainType). Context (x : R) (l u : itv_bound int). Context (x_real : x \in Num.real). Context (l_le_x : (num_itv_bound R l <= BLeft x)%O). Context (x_le_u : (BRight x <= num_itv_bound R u)%O). Lemma itvnum_subdef : num_spec (Itv.Real (Interval l u)) x. Proof. by apply/and3P. Qed. Definition ItvNum : num_def R (Itv.Real (Interval l u)) := Itv.mk itvnum_subdef. End ItvNum. Section ItvReal. Context (R : realDomainType). Context (x : R) (l u : itv_bound int). Context (l_le_x : (num_itv_bound R l <= BLeft x)%O). Context (x_le_u : (BRight x <= num_itv_bound R u)%O). Lemma itvreal_subdef : num_spec (Itv.Real (Interval l u)) x. Proof. by apply/and3P; split; first exact: num_real. Qed. Definition ItvReal : num_def R (Itv.Real (Interval l u)) := Itv.mk itvreal_subdef. End ItvReal. Section Itv01. Context (R : numDomainType). Context (x : R) (x_ge0 : 0 <= x) (x_le1 : x <= 1). Lemma itv01_subdef : num_spec (Itv.Real `[0%Z, 1%Z]) x. Proof. by apply/and3P; split; rewrite ?bnd_simp// ger0_real. Qed. Definition Itv01 : num_def R (Itv.Real `[0%Z, 1%Z]) := Itv.mk itv01_subdef. End Itv01. Section Posnum. Context (R : numDomainType) (x : R) (x_gt0 : 0 < x). Lemma posnum_subdef : num_spec (Itv.Real `]0, +oo[) x. Proof. by apply/and3P; rewrite /= gtr0_real. Qed. Definition PosNum : {posnum R} := Itv.mk posnum_subdef. End Posnum. Section Nngnum. Context (R : numDomainType) (x : R) (x_ge0 : 0 <= x). Lemma nngnum_subdef : num_spec (Itv.Real `[0, +oo[) x. Proof. by apply/and3P; rewrite /= ger0_real. Qed. Definition NngNum : {nonneg R} := Itv.mk nngnum_subdef. End Nngnum. Variant posnum_spec (R : numDomainType) (x : R) : R -> bool -> bool -> bool -> Type := | IsPosnum (p : {posnum R}) : posnum_spec x (p%:num) false true true. Lemma posnumP (R : numDomainType) (x : R) : 0 < x -> posnum_spec x x (x == 0) (0 <= x) (0 < x). Proof. move=> x_gt0; case: real_ltgt0P (x_gt0) => []; rewrite ?gtr0_real // => _ _. by rewrite -[x]/(PosNum x_gt0)%:num; constructor. Qed. Variant nonneg_spec (R : numDomainType) (x : R) : R -> bool -> Type := | IsNonneg (p : {nonneg R}) : nonneg_spec x (p%:num) true. Lemma nonnegP (R : numDomainType) (x : R) : 0 <= x -> nonneg_spec x x (0 <= x). Proof. by move=> xge0; rewrite xge0 -[x]/(NngNum xge0)%:num; constructor. Qed. Section Test1. Variable R : numDomainType. Variable x : {i01 R}. Goal 0%:i01 = 1%:i01 :> {i01 R}. Proof. Abort. Goal (- x%:num)%:itv = (- x%:num)%:itv :> {itv R & `[-1, 0]}. Proof. Abort. Goal (1 - x%:num)%:i01 = x. Proof. Abort. End Test1. Section Test2. Variable R : realDomainType. Variable x y : {i01 R}. Goal (x%:num * y%:num)%:i01 = x%:num%:i01. Proof. Abort. End Test2. Module Test3. Section Test3. Variable R : realDomainType. Definition s_of_pq (p q : {i01 R}) : {i01 R} := (1 - ((1 - p%:num)%:i01%:num * (1 - q%:num)%:i01%:num))%:i01. Lemma s_of_p0 (p : {i01 R}) : s_of_pq p 0%:i01 = p. Proof. by apply/val_inj; rewrite /= subr0 mulr1 subKr. Qed. End Test3. End Test3.
HomotopyCofiber.lean
/- Copyright (c) 2023 Joël Riou. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joël Riou -/ import Mathlib.Algebra.Homology.HomologicalComplexBiprod import Mathlib.Algebra.Homology.Homotopy import Mathlib.CategoryTheory.MorphismProperty.IsInvertedBy /-! The homotopy cofiber of a morphism of homological complexes In this file, we construct the homotopy cofiber of a morphism `φ : F ⟶ G` between homological complexes in `HomologicalComplex C c`. In degree `i`, it is isomorphic to `(F.X j) ⊞ (G.X i)` if there is a `j` such that `c.Rel i j`, and `G.X i` otherwise. (This is also known as the mapping cone of `φ`. Under the name `CochainComplex.mappingCone`, a specific API shall be developed for the case of cochain complexes indexed by `ℤ`.) When we assume `hc : ∀ j, ∃ i, c.Rel i j` (which holds in the case of chain complexes, or cochain complexes indexed by `ℤ`), then for any homological complex `K`, there is a bijection `HomologicalComplex.homotopyCofiber.descEquiv φ K hc` between `homotopyCofiber φ ⟶ K` and the tuples `(α, hα)` with `α : G ⟶ K` and `hα : Homotopy (φ ≫ α) 0`. We shall also study the cylinder of a homological complex `K`: this is the homotopy cofiber of the morphism `biprod.lift (𝟙 K) (-𝟙 K) : K ⟶ K ⊞ K`. Then, a morphism `K.cylinder ⟶ M` is determined by the data of two morphisms `φ₀ φ₁ : K ⟶ M` and a homotopy `h : Homotopy φ₀ φ₁`, see `cylinder.desc`. There is also a homotopy equivalence `cylinder.homotopyEquiv K : HomotopyEquiv K.cylinder K`. From the construction of the cylinder, we deduce the lemma `Homotopy.map_eq_of_inverts_homotopyEquivalences` which assert that if a functor inverts homotopy equivalences, then the image of two homotopic maps are equal. -/ open CategoryTheory Category Limits Preadditive variable {C : Type*} [Category C] [Preadditive C] namespace HomologicalComplex variable {ι : Type*} {c : ComplexShape ι} {F G K : HomologicalComplex C c} (φ : F ⟶ G) /-- A morphism of homological complexes `φ : F ⟶ G` has a homotopy cofiber if for all indices `i` and `j` such that `c.Rel i j`, the binary biproduct `F.X j ⊞ G.X i` exists. -/ class HasHomotopyCofiber (φ : F ⟶ G) : Prop where hasBinaryBiproduct (i j : ι) (hij : c.Rel i j) : HasBinaryBiproduct (F.X j) (G.X i) instance [HasBinaryBiproducts C] : HasHomotopyCofiber φ where hasBinaryBiproduct _ _ _ := inferInstance variable [HasHomotopyCofiber φ] [DecidableRel c.Rel] namespace homotopyCofiber /-- The `X` field of the homological complex `homotopyCofiber φ`. -/ noncomputable def X (i : ι) : C := if hi : c.Rel i (c.next i) then haveI := HasHomotopyCofiber.hasBinaryBiproduct φ _ _ hi (F.X (c.next i)) ⊞ (G.X i) else G.X i /-- The canonical isomorphism `(homotopyCofiber φ).X i ≅ F.X j ⊞ G.X i` when `c.Rel i j`. -/ noncomputable def XIsoBiprod (i j : ι) (hij : c.Rel i j) [HasBinaryBiproduct (F.X j) (G.X i)] : X φ i ≅ F.X j ⊞ G.X i := eqToIso (by obtain rfl := c.next_eq' hij apply dif_pos hij) /-- The canonical isomorphism `(homotopyCofiber φ).X i ≅ G.X i` when `¬ c.Rel i (c.next i)`. -/ noncomputable def XIso (i : ι) (hi : ¬ c.Rel i (c.next i)) : X φ i ≅ G.X i := eqToIso (dif_neg hi) /-- The second projection `(homotopyCofiber φ).X i ⟶ G.X i`. -/ noncomputable def sndX (i : ι) : X φ i ⟶ G.X i := if hi : c.Rel i (c.next i) then haveI := HasHomotopyCofiber.hasBinaryBiproduct φ _ _ hi (XIsoBiprod φ _ _ hi).hom ≫ biprod.snd else (XIso φ i hi).hom /-- The right inclusion `G.X i ⟶ (homotopyCofiber φ).X i`. -/ noncomputable def inrX (i : ι) : G.X i ⟶ X φ i := if hi : c.Rel i (c.next i) then haveI := HasHomotopyCofiber.hasBinaryBiproduct φ _ _ hi biprod.inr ≫ (XIsoBiprod φ _ _ hi).inv else (XIso φ i hi).inv @[reassoc (attr := simp)] lemma inrX_sndX (i : ι) : inrX φ i ≫ sndX φ i = 𝟙 _ := by dsimp [sndX, inrX] split_ifs with hi <;> simp @[reassoc] lemma sndX_inrX (i : ι) (hi : ¬ c.Rel i (c.next i)) : sndX φ i ≫ inrX φ i = 𝟙 _ := by dsimp [sndX, inrX] simp only [dif_neg hi, Iso.hom_inv_id] /-- The first projection `(homotopyCofiber φ).X i ⟶ F.X j` when `c.Rel i j`. -/ noncomputable def fstX (i j : ι) (hij : c.Rel i j) : X φ i ⟶ F.X j := haveI := HasHomotopyCofiber.hasBinaryBiproduct φ _ _ hij (XIsoBiprod φ i j hij).hom ≫ biprod.fst /-- The left inclusion `F.X i ⟶ (homotopyCofiber φ).X j` when `c.Rel j i`. -/ noncomputable def inlX (i j : ι) (hij : c.Rel j i) : F.X i ⟶ X φ j := haveI := HasHomotopyCofiber.hasBinaryBiproduct φ _ _ hij biprod.inl ≫ (XIsoBiprod φ j i hij).inv @[reassoc (attr := simp)] lemma inlX_fstX (i j : ι) (hij : c.Rel j i) : inlX φ i j hij ≫ fstX φ j i hij = 𝟙 _ := by simp [inlX, fstX] @[reassoc (attr := simp)] lemma inlX_sndX (i j : ι) (hij : c.Rel j i) : inlX φ i j hij ≫ sndX φ j = 0 := by obtain rfl := c.next_eq' hij simp [inlX, sndX, dif_pos hij] @[reassoc (attr := simp)] lemma inrX_fstX (i j : ι) (hij : c.Rel i j) : inrX φ i ≫ fstX φ i j hij = 0 := by obtain rfl := c.next_eq' hij simp [inrX, fstX, dif_pos hij] /-- The `d` field of the homological complex `homotopyCofiber φ`. -/ noncomputable def d (i j : ι) : X φ i ⟶ X φ j := if hij : c.Rel i j then (if hj : c.Rel j (c.next j) then -fstX φ i j hij ≫ F.d _ _ ≫ inlX φ _ _ hj else 0) + fstX φ i j hij ≫ φ.f j ≫ inrX φ j + sndX φ i ≫ G.d i j ≫ inrX φ j else 0 lemma ext_to_X (i j : ι) (hij : c.Rel i j) {A : C} {f g : A ⟶ X φ i} (h₁ : f ≫ fstX φ i j hij = g ≫ fstX φ i j hij) (h₂ : f ≫ sndX φ i = g ≫ sndX φ i) : f = g := by haveI := HasHomotopyCofiber.hasBinaryBiproduct φ _ _ hij rw [← cancel_mono (XIsoBiprod φ i j hij).hom] apply biprod.hom_ext · simpa using h₁ · obtain rfl := c.next_eq' hij simpa [sndX, dif_pos hij] using h₂ lemma ext_to_X' (i : ι) (hi : ¬ c.Rel i (c.next i)) {A : C} {f g : A ⟶ X φ i} (h : f ≫ sndX φ i = g ≫ sndX φ i) : f = g := by rw [← cancel_mono (XIso φ i hi).hom] simpa only [sndX, dif_neg hi] using h lemma ext_from_X (i j : ι) (hij : c.Rel j i) {A : C} {f g : X φ j ⟶ A} (h₁ : inlX φ i j hij ≫ f = inlX φ i j hij ≫ g) (h₂ : inrX φ j ≫ f = inrX φ j ≫ g) : f = g := by haveI := HasHomotopyCofiber.hasBinaryBiproduct φ _ _ hij rw [← cancel_epi (XIsoBiprod φ j i hij).inv] apply biprod.hom_ext' · simpa [inlX] using h₁ · obtain rfl := c.next_eq' hij simpa [inrX, dif_pos hij] using h₂ lemma ext_from_X' (i : ι) (hi : ¬ c.Rel i (c.next i)) {A : C} {f g : X φ i ⟶ A} (h : inrX φ i ≫ f = inrX φ i ≫ g) : f = g := by rw [← cancel_epi (XIso φ i hi).inv] simpa only [inrX, dif_neg hi] using h @[reassoc] lemma d_fstX (i j k : ι) (hij : c.Rel i j) (hjk : c.Rel j k) : d φ i j ≫ fstX φ j k hjk = -fstX φ i j hij ≫ F.d j k := by obtain rfl := c.next_eq' hjk simp [d, dif_pos hij, dif_pos hjk] @[reassoc] lemma d_sndX (i j : ι) (hij : c.Rel i j) : d φ i j ≫ sndX φ j = fstX φ i j hij ≫ φ.f j + sndX φ i ≫ G.d i j := by dsimp [d] split_ifs with hij <;> simp @[reassoc] lemma inlX_d (i j k : ι) (hij : c.Rel i j) (hjk : c.Rel j k) : inlX φ j i hij ≫ d φ i j = -F.d j k ≫ inlX φ k j hjk + φ.f j ≫ inrX φ j := by apply ext_to_X φ j k hjk · simp [d_fstX φ _ _ _ hij hjk] · simp [d_sndX φ _ _ hij] @[reassoc] lemma inlX_d' (i j : ι) (hij : c.Rel i j) (hj : ¬ c.Rel j (c.next j)) : inlX φ j i hij ≫ d φ i j = φ.f j ≫ inrX φ j := by apply ext_to_X' _ _ hj simp [d_sndX φ i j hij] lemma shape (i j : ι) (hij : ¬ c.Rel i j) : d φ i j = 0 := dif_neg hij @[reassoc (attr := simp)] lemma inrX_d (i j : ι) : inrX φ i ≫ d φ i j = G.d i j ≫ inrX φ j := by by_cases hij : c.Rel i j · by_cases hj : c.Rel j (c.next j) · apply ext_to_X _ _ _ hj · simp [d_fstX φ _ _ _ hij] · simp [d_sndX φ _ _ hij] · apply ext_to_X' _ _ hj simp [d_sndX φ _ _ hij] · rw [shape φ _ _ hij, G.shape _ _ hij, zero_comp, comp_zero] end homotopyCofiber /-- The homotopy cofiber of a morphism of homological complexes, also known as the mapping cone. -/ @[simps] noncomputable def homotopyCofiber : HomologicalComplex C c where X i := homotopyCofiber.X φ i d i j := homotopyCofiber.d φ i j shape i j hij := homotopyCofiber.shape φ i j hij d_comp_d' i j k hij hjk := by apply homotopyCofiber.ext_from_X φ j i hij · dsimp simp only [comp_zero, homotopyCofiber.inlX_d_assoc φ i j k hij hjk, add_comp, assoc, homotopyCofiber.inrX_d, Hom.comm_assoc, neg_comp] by_cases hk : c.Rel k (c.next k) · simp [homotopyCofiber.inlX_d φ j k _ hjk hk] · simp [homotopyCofiber.inlX_d' φ j k hjk hk] · simp namespace homotopyCofiber /-- The right inclusion `G ⟶ homotopyCofiber φ`. -/ @[simps!] noncomputable def inr : G ⟶ homotopyCofiber φ where f i := inrX φ i section /-- The composition `φ ≫ mappingCone.inr φ` is homotopic to `0`. -/ noncomputable def inrCompHomotopy (hc : ∀ j, ∃ i, c.Rel i j) : Homotopy (φ ≫ inr φ) 0 where hom i j := if hij : c.Rel j i then inlX φ i j hij else 0 zero _ _ hij := dif_neg hij comm j := by obtain ⟨i, hij⟩ := hc j rw [prevD_eq _ hij, dif_pos hij] by_cases hj : c.Rel j (c.next j) · simp only [comp_f, homotopyCofiber_d, zero_f, add_zero, inlX_d φ i j _ hij hj, dNext_eq _ hj, dif_pos hj, add_neg_cancel_left, inr_f] · rw [dNext_eq_zero _ _ hj, zero_add, zero_f, add_zero, homotopyCofiber_d, inlX_d' _ _ _ _ hj, comp_f, inr_f] variable (hc : ∀ j, ∃ i, c.Rel i j) lemma inrCompHomotopy_hom (i j : ι) (hij : c.Rel j i) : (inrCompHomotopy φ hc).hom i j = inlX φ i j hij := dif_pos hij lemma inrCompHomotopy_hom_eq_zero (i j : ι) (hij : ¬ c.Rel j i) : (inrCompHomotopy φ hc).hom i j = 0 := dif_neg hij end section variable (α : G ⟶ K) (hα : Homotopy (φ ≫ α) 0) /-- The morphism `homotopyCofiber φ ⟶ K` that is induced by a morphism `α : G ⟶ K` and a homotopy `hα : Homotopy (φ ≫ α) 0`. -/ noncomputable def desc : homotopyCofiber φ ⟶ K where f j := if hj : c.Rel j (c.next j) then fstX φ j _ hj ≫ hα.hom _ j + sndX φ j ≫ α.f j else sndX φ j ≫ α.f j comm' j k hjk := by obtain rfl := c.next_eq' hjk simp [dif_pos hjk] have H := hα.comm (c.next j) simp only [comp_f, zero_f, add_zero, prevD_eq _ hjk] at H split_ifs with hj · simp only [comp_add, d_sndX_assoc _ _ _ hjk, add_comp, assoc, H, d_fstX_assoc _ _ _ _ hjk, neg_comp, dNext, AddMonoidHom.mk'_apply] abel · simp only [d_sndX_assoc _ _ _ hjk, add_comp, assoc, H, dNext_eq_zero _ _ hj, zero_add] lemma desc_f (j k : ι) (hjk : c.Rel j k) : (desc φ α hα).f j = fstX φ j _ hjk ≫ hα.hom _ j + sndX φ j ≫ α.f j := by obtain rfl := c.next_eq' hjk apply dif_pos hjk lemma desc_f' (j : ι) (hj : ¬ c.Rel j (c.next j)) : (desc φ α hα).f j = sndX φ j ≫ α.f j := by apply dif_neg hj @[reassoc (attr := simp)] lemma inlX_desc_f (i j : ι) (hjk : c.Rel j i) : inlX φ i j hjk ≫ (desc φ α hα).f j = hα.hom i j := by obtain rfl := c.next_eq' hjk dsimp [desc] rw [dif_pos hjk, comp_add, inlX_fstX_assoc, inlX_sndX_assoc, zero_comp, add_zero] @[reassoc (attr := simp)] lemma inrX_desc_f (i : ι) : inrX φ i ≫ (desc φ α hα).f i = α.f i := by dsimp [desc] split_ifs <;> simp @[reassoc (attr := simp)] lemma inr_desc : inr φ ≫ desc φ α hα = α := by cat_disch @[reassoc (attr := simp)] lemma inrCompHomotopy_hom_desc_hom (hc : ∀ j, ∃ i, c.Rel i j) (i j : ι) : (inrCompHomotopy φ hc).hom i j ≫ (desc φ α hα).f j = hα.hom i j := by by_cases hij : c.Rel j i · dsimp simp only [inrCompHomotopy_hom φ hc i j hij, desc_f φ α hα _ _ hij, comp_add, inlX_fstX_assoc, inlX_sndX_assoc, zero_comp, add_zero] · simp only [Homotopy.zero _ _ _ hij, zero_comp] lemma eq_desc (f : homotopyCofiber φ ⟶ K) (hc : ∀ j, ∃ i, c.Rel i j) : f = desc φ (inr φ ≫ f) (Homotopy.trans (Homotopy.ofEq (by simp)) (((inrCompHomotopy φ hc).compRight f).trans (Homotopy.ofEq (by simp)))) := by ext j by_cases hj : c.Rel j (c.next j) · apply ext_from_X φ _ _ hj · simp [inrCompHomotopy_hom _ _ _ _ hj] · simp · apply ext_from_X' φ _ hj simp end lemma descSigma_ext_iff {φ : F ⟶ G} {K : HomologicalComplex C c} (x y : Σ (α : G ⟶ K), Homotopy (φ ≫ α) 0) : x = y ↔ x.1 = y.1 ∧ (∀ (i j : ι) (_ : c.Rel j i), x.2.hom i j = y.2.hom i j) := by constructor · rintro rfl tauto · obtain ⟨x₁, x₂⟩ := x obtain ⟨y₁, y₂⟩ := y rintro ⟨rfl, h⟩ simp only [Sigma.mk.inj_iff, heq_eq_eq, true_and] ext i j by_cases hij : c.Rel j i · exact h _ _ hij · simp only [Homotopy.zero _ _ _ hij] /-- Morphisms `homotopyCofiber φ ⟶ K` are uniquely determined by a morphism `α : G ⟶ K` and a homotopy from `φ ≫ α` to `0`. -/ noncomputable def descEquiv (K : HomologicalComplex C c) (hc : ∀ j, ∃ i, c.Rel i j) : (Σ (α : G ⟶ K), Homotopy (φ ≫ α) 0) ≃ (homotopyCofiber φ ⟶ K) where toFun := fun ⟨α, hα⟩ => desc φ α hα invFun f := ⟨inr φ ≫ f, Homotopy.trans (Homotopy.ofEq (by simp)) (((inrCompHomotopy φ hc).compRight f).trans (Homotopy.ofEq (by simp)))⟩ right_inv f := (eq_desc φ f hc).symm left_inv := fun ⟨α, hα⟩ => by rw [descSigma_ext_iff] cat_disch end homotopyCofiber section variable (K) variable [∀ i, HasBinaryBiproduct (K.X i) (K.X i)] [HasHomotopyCofiber (biprod.lift (𝟙 K) (-𝟙 K))] /-- The cylinder object of a homological complex `K` is the homotopy cofiber of the morphism `biprod.lift (𝟙 K) (-𝟙 K) : K ⟶ K ⊞ K`. -/ noncomputable abbrev cylinder := homotopyCofiber (biprod.lift (𝟙 K) (-𝟙 K)) namespace cylinder /-- The left inclusion `K ⟶ K.cylinder`. -/ noncomputable def ι₀ : K ⟶ K.cylinder := biprod.inl ≫ homotopyCofiber.inr _ /-- The right inclusion `K ⟶ K.cylinder`. -/ noncomputable def ι₁ : K ⟶ K.cylinder := biprod.inr ≫ homotopyCofiber.inr _ variable {K} section variable (φ₀ φ₁ : K ⟶ F) (h : Homotopy φ₀ φ₁) /-- The morphism `K.cylinder ⟶ F` that is induced by two morphisms `φ₀ φ₁ : K ⟶ F` and a homotopy `h : Homotopy φ₀ φ₁`. -/ noncomputable def desc : K.cylinder ⟶ F := homotopyCofiber.desc _ (biprod.desc φ₀ φ₁) (Homotopy.trans (Homotopy.ofEq (by simp only [biprod.lift_desc, id_comp, neg_comp, sub_eq_add_neg])) ((Homotopy.equivSubZero h))) @[reassoc (attr := simp)] lemma ι₀_desc : ι₀ K ≫ desc φ₀ φ₁ h = φ₀ := by simp [ι₀, desc] @[reassoc (attr := simp)] lemma ι₁_desc : ι₁ K ≫ desc φ₀ φ₁ h = φ₁ := by simp [ι₁, desc] end variable (K) /-- The projection `π : K.cylinder ⟶ K`. -/ noncomputable def π : K.cylinder ⟶ K := desc (𝟙 K) (𝟙 K) (Homotopy.refl _) @[reassoc (attr := simp)] lemma ι₀_π : ι₀ K ≫ π K = 𝟙 K := by simp [π] @[reassoc (attr := simp)] lemma ι₁_π : ι₁ K ≫ π K = 𝟙 K := by simp [π] /-- The left inclusion `K.X i ⟶ K.cylinder.X j` when `c.Rel j i`. -/ noncomputable abbrev inlX (i j : ι) (hij : c.Rel j i) : K.X i ⟶ K.cylinder.X j := homotopyCofiber.inlX (biprod.lift (𝟙 K) (-𝟙 K)) i j hij /-- The right inclusion `(K ⊞ K).X i ⟶ K.cylinder.X i`. -/ noncomputable abbrev inrX (i : ι) : (K ⊞ K).X i ⟶ K.cylinder.X i := homotopyCofiber.inrX (biprod.lift (𝟙 K) (-𝟙 K)) i @[reassoc (attr := simp)] lemma inlX_π (i j : ι) (hij : c.Rel j i) : inlX K i j hij ≫ (π K).f j = 0 := by erw [homotopyCofiber.inlX_desc_f] simp [Homotopy.equivSubZero] @[reassoc (attr := simp)] lemma inrX_π (i : ι) : inrX K i ≫ (π K).f i = (biprod.desc (𝟙 _) (𝟙 K)).f i := homotopyCofiber.inrX_desc_f _ _ _ _ section variable (hc : ∀ j, ∃ i, c.Rel i j) namespace πCompι₀Homotopy /-- A null homotopic map `K.cylinder ⟶ K.cylinder` which identifies to `π K ≫ ι₀ K - 𝟙 _`, see `nullHomotopicMap_eq`. -/ noncomputable def nullHomotopicMap : K.cylinder ⟶ K.cylinder := Homotopy.nullHomotopicMap' (fun i j hij => homotopyCofiber.sndX (biprod.lift (𝟙 K) (-𝟙 K)) i ≫ (biprod.snd : K ⊞ K ⟶ K).f i ≫ inlX K i j hij) /-- The obvious homotopy from `nullHomotopicMap K` to zero. -/ noncomputable def nullHomotopy : Homotopy (nullHomotopicMap K) 0 := Homotopy.nullHomotopy' _ lemma inlX_nullHomotopy_f (i j : ι) (hij : c.Rel j i) : inlX K i j hij ≫ (nullHomotopicMap K).f j = inlX K i j hij ≫ (π K ≫ ι₀ K - 𝟙 _).f j := by dsimp [nullHomotopicMap] by_cases hj : ∃ (k : ι), c.Rel k j · obtain ⟨k, hjk⟩ := hj simp only [assoc, Homotopy.nullHomotopicMap'_f hjk hij, homotopyCofiber_X, homotopyCofiber_d, homotopyCofiber.d_sndX_assoc _ _ _ hij, add_comp, comp_add, homotopyCofiber.inlX_fstX_assoc, homotopyCofiber.inlX_sndX_assoc, zero_comp, add_zero, comp_sub, inlX_π_assoc, comp_id, zero_sub, ← HomologicalComplex.comp_f_assoc, biprod.lift_snd, neg_f_apply, id_f, neg_comp, id_comp] · simp only [not_exists] at hj simp only [Homotopy.nullHomotopicMap'_f_of_not_rel_right hij hj, homotopyCofiber_X, homotopyCofiber_d, assoc, comp_sub, comp_id, homotopyCofiber.d_sndX_assoc _ _ _ hij, add_comp, comp_add, zero_comp, add_zero, homotopyCofiber.inlX_fstX_assoc, homotopyCofiber.inlX_sndX_assoc, ← HomologicalComplex.comp_f_assoc, biprod.lift_snd, neg_f_apply, id_f, neg_comp, id_comp, inlX_π_assoc, zero_sub] include hc lemma inrX_nullHomotopy_f (j : ι) : inrX K j ≫ (nullHomotopicMap K).f j = inrX K j ≫ (π K ≫ ι₀ K - 𝟙 _).f j := by have : biprod.lift (𝟙 K) (-𝟙 K) = biprod.inl - biprod.inr := biprod.hom_ext _ _ (by simp) (by simp) obtain ⟨i, hij⟩ := hc j dsimp [nullHomotopicMap] by_cases hj : ∃ (k : ι), c.Rel j k · obtain ⟨k, hjk⟩ := hj simp only [Homotopy.nullHomotopicMap'_f hij hjk, homotopyCofiber_X, homotopyCofiber_d, assoc, comp_add, homotopyCofiber.inrX_d_assoc, homotopyCofiber.inrX_sndX_assoc, comp_sub, inrX_π_assoc, comp_id, ← Hom.comm_assoc, homotopyCofiber.inlX_d _ _ _ _ _ hjk, comp_neg, add_neg_cancel_left] rw [← cancel_epi (biprodXIso K K j).inv] ext · simp [ι₀] · dsimp simp only [inr_biprodXIso_inv_assoc, biprod_inr_snd_f_assoc, comp_sub, biprod_inr_desc_f_assoc, id_f, id_comp, ι₀, comp_f, this, sub_f_apply, sub_comp, homotopyCofiber_X, homotopyCofiber.inr_f] · simp only [not_exists] at hj simp only [assoc, Homotopy.nullHomotopicMap'_f_of_not_rel_left hij hj, homotopyCofiber_X, homotopyCofiber_d, homotopyCofiber.inlX_d' _ _ _ _ (hj _), homotopyCofiber.inrX_sndX_assoc, comp_sub, inrX_π_assoc, comp_id, ι₀, comp_f, homotopyCofiber.inr_f] rw [← cancel_epi (biprodXIso K K j).inv] ext · simp · simp [this] lemma nullHomotopicMap_eq : nullHomotopicMap K = π K ≫ ι₀ K - 𝟙 _ := by ext i by_cases hi : c.Rel i (c.next i) · exact homotopyCofiber.ext_from_X (biprod.lift (𝟙 K) (-𝟙 K)) (c.next i) i hi (inlX_nullHomotopy_f _ _ _ _) (inrX_nullHomotopy_f _ hc _) · exact homotopyCofiber.ext_from_X' (biprod.lift (𝟙 K) (-𝟙 K)) _ hi (inrX_nullHomotopy_f _ hc _) end πCompι₀Homotopy /-- The homotopy between `π K ≫ ι₀ K` and `𝟙 K.cylinder`. -/ noncomputable def πCompι₀Homotopy : Homotopy (π K ≫ ι₀ K) (𝟙 K.cylinder) := Homotopy.equivSubZero.symm ((Homotopy.ofEq (πCompι₀Homotopy.nullHomotopicMap_eq K hc).symm).trans (πCompι₀Homotopy.nullHomotopy K)) /-- The homotopy equivalence between `K.cylinder` and `K`. -/ noncomputable def homotopyEquiv : HomotopyEquiv K.cylinder K where hom := π K inv := ι₀ K homotopyHomInvId := πCompι₀Homotopy K hc homotopyInvHomId := Homotopy.ofEq (by simp) /-- The homotopy between `cylinder.ι₀ K` and `cylinder.ι₁ K`. -/ noncomputable def homotopy₀₁ : Homotopy (ι₀ K) (ι₁ K) := (Homotopy.ofEq (by simp)).trans (((πCompι₀Homotopy K hc).compLeft (ι₁ K)).trans (Homotopy.ofEq (by simp))) include hc in lemma map_ι₀_eq_map_ι₁ {D : Type*} [Category D] (H : HomologicalComplex C c ⥤ D) (hH : (homotopyEquivalences C c).IsInvertedBy H) : H.map (ι₀ K) = H.map (ι₁ K) := by have : IsIso (H.map (cylinder.π K)) := hH _ ⟨homotopyEquiv K hc, rfl⟩ simp only [← cancel_mono (H.map (cylinder.π K)), ← H.map_comp, ι₀_π, H.map_id, ι₁_π] end end cylinder /-- If a functor inverts homotopy equivalences, it sends homotopic maps to the same map. -/ lemma _root_.Homotopy.map_eq_of_inverts_homotopyEquivalences {φ₀ φ₁ : F ⟶ G} (h : Homotopy φ₀ φ₁) (hc : ∀ j, ∃ i, c.Rel i j) [∀ i, HasBinaryBiproduct (F.X i) (F.X i)] [HasHomotopyCofiber (biprod.lift (𝟙 F) (-𝟙 F))] {D : Type*} [Category D] (H : HomologicalComplex C c ⥤ D) (hH : (homotopyEquivalences C c).IsInvertedBy H) : H.map φ₀ = H.map φ₁ := by simp only [← cylinder.ι₀_desc _ _ h, ← cylinder.ι₁_desc _ _ h, H.map_comp, cylinder.map_ι₀_eq_map_ι₁ _ hc _ hH] end end HomologicalComplex
LConvolution.lean
/- Copyright (c) 2025 David Ledvinka. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: David Ledvinka -/ import Mathlib.MeasureTheory.Group.Prod import Mathlib.MeasureTheory.Group.LIntegral /-! # Convolution of functions using the Lebesgue integral In this file we define and prove properties about the convolution of two functions using the Lebesgue integral. ## Design Decisions We define the convolution of two functions using the Lebesgue integral (in the additive case) by the formula `(f ⋆ₗ[μ] g) x = ∫⁻ y, (f y) * (g (-y + x)) ∂μ`. This does not agree with the formula used by `MeasureTheory.convolution` for convolution of two functions, however it does agree when the domain of `f` and `g` is a commutative group. The main reason for this is so that (under sufficient conditions) if `{μ ν π : Measure G} {f g : G → ℝ≥0∞}` are such that `μ = π.withDensity f`, `ν = π.withDensity g` where `π` is left-invariant then `(μ ∗ ν) = π.withDensity (f ⋆ₗ[π] g)`. If the formula in `MeasureTheory.convolution` was used the order of the densities would be flipped. ## Main Definitions * `MeasureTheory.mlconvolution f g μ x = (f ⋆ₘₗ[μ] g) x = ∫⁻ y, (f y) * (g (y⁻¹ * x)) ∂μ` is the multiplicative convolution of `f` and `g` w.r.t. the measure `μ`. * `MeasureTheory.lconvolution f g μ x = (f ⋆ₗ[μ] g) x = ∫⁻ y, (f y) * (g (-y + x)) ∂μ` is the additive convolution of `f` and `g` w.r.t. the measure `μ`. -/ namespace MeasureTheory open Measure open scoped ENNReal variable {G : Type*} {mG : MeasurableSpace G} section NoGroup variable [Mul G] [Inv G] /-- Multiplicative convolution of functions. -/ @[to_additive /-- Additive convolution of functions -/] noncomputable def mlconvolution (f g : G → ℝ≥0∞) (μ : Measure G) : G → ℝ≥0∞ := fun x ↦ ∫⁻ y, (f y) * (g (y⁻¹ * x)) ∂μ /-- Scoped notation for the multiplicative convolution of functions with respect to a measure `μ`. -/ scoped[MeasureTheory] notation:67 f " ⋆ₘₗ["μ:67"] " g:66 => MeasureTheory.mlconvolution f g μ /-- Scoped notation for the multiplicative convolution of functions with respect to `volume`. -/ scoped[MeasureTheory] notation:67 f " ⋆ₘₗ " g:66 => MeasureTheory.mlconvolution f g volume /-- Scoped notation for the additive convolution of functions with respect to a measure `μ`. -/ scoped[MeasureTheory] notation:67 f " ⋆ₗ["μ:67"] " g:66 => MeasureTheory.lconvolution f g μ /-- Scoped notation for the additive convolution of functions with respect to `volume`. -/ scoped[MeasureTheory] notation:67 f " ⋆ₗ " g:66 => MeasureTheory.lconvolution f g volume /- The definition of multiplicative convolution of functions. -/ @[to_additive /-- The definition of additive convolution of functions. -/] theorem mlconvolution_def {f g : G → ℝ≥0∞} {μ : Measure G} {x : G} : (f ⋆ₘₗ[μ] g) x = ∫⁻ y, (f y) * (g (y⁻¹ * x)) ∂μ := rfl /-- Convolution of the zero function with a function returns the zero function. -/ @[to_additive (attr := simp) /-- Convolution of the zero function with a function returns the zero function. -/] theorem zero_mlconvolution (f : G → ℝ≥0∞) (μ : Measure G) : 0 ⋆ₘₗ[μ] f = 0 := by ext; simp [mlconvolution] /-- Convolution of a function with the zero function returns the zero function. -/ @[to_additive (attr := simp) /-- Convolution of a function with the zero function returns the zero function. -/] theorem mlconvolution_zero (f : G → ℝ≥0∞) (μ : Measure G) : f ⋆ₘₗ[μ] 0 = 0 := by ext; simp [mlconvolution] section Measurable variable [MeasurableMul₂ G] [MeasurableInv G] /-- The convolution of measurable functions is measurable. -/ @[to_additive (attr := measurability, fun_prop) /-- The convolution of measurable functions is measurable. -/] theorem measurable_mlconvolution {f g : G → ℝ≥0∞} (μ : Measure G) [SFinite μ] (hf : Measurable f) (hg : Measurable g) : Measurable (f ⋆ₘₗ[μ] g) := by unfold mlconvolution fun_prop end Measurable end NoGroup section Group variable [Group G] [MeasurableMul₂ G] [MeasurableInv G] variable {μ : Measure G} [IsMulLeftInvariant μ] [SFinite μ] /-- The convolution of `AEMeasurable` functions is `AEMeasurable`. -/ @[to_additive (attr := measurability, fun_prop) /-- The convolution of `AEMeasurable` functions is `AEMeasurable`. -/] theorem aemeasurable_mlconvolution {f g : G → ℝ≥0∞} (hf : AEMeasurable f μ) (hg : AEMeasurable g μ) : AEMeasurable (f ⋆ₘₗ[μ] g) μ := by unfold mlconvolution fun_prop @[to_additive] theorem mlconvolution_assoc₀ {f g k : G → ℝ≥0∞} (hf : AEMeasurable f μ) (hg : AEMeasurable g μ) (hk : AEMeasurable k μ) : f ⋆ₘₗ[μ] g ⋆ₘₗ[μ] k = (f ⋆ₘₗ[μ] g) ⋆ₘₗ[μ] k := by ext x simp only [mlconvolution_def] conv in f _ * (∫⁻ _ , _ ∂μ) => rw [← lintegral_const_mul'' _ (by fun_prop), ← lintegral_mul_left_eq_self _ y⁻¹] conv in (∫⁻ _ , _ ∂μ) * k _ => rw [← lintegral_mul_const'' _ (by fun_prop)] rw [lintegral_lintegral_swap] · simp [mul_assoc] simpa [mul_assoc] using by fun_prop /- Convolution is associative. -/ @[to_additive /-- Convolution is associative. -/] theorem mlconvolution_assoc {f g k : G → ℝ≥0∞} (hf : Measurable f) (hg : Measurable g) (hk : Measurable k) : f ⋆ₘₗ[μ] g ⋆ₘₗ[μ] k = (f ⋆ₘₗ[μ] g) ⋆ₘₗ[μ] k := mlconvolution_assoc₀ hf.aemeasurable hg.aemeasurable hk.aemeasurable end Group section CommGroup variable [CommGroup G] [MeasurableMul₂ G] [MeasurableInv G] {μ : Measure G} /-- Convolution is commutative when the group is commutative. -/ @[to_additive /-- Convolution is commutative when the group is commutative. -/] theorem mlconvolution_comm [IsMulLeftInvariant μ] [IsInvInvariant μ] {f g : G → ℝ≥0∞} : (f ⋆ₘₗ[μ] g) = (g ⋆ₘₗ[μ] f) := by ext x simp only [mlconvolution_def] rw [← lintegral_mul_left_eq_self _ x, ← lintegral_inv_eq_self] simp [mul_comm] end CommGroup end MeasureTheory
IrreducibleRing.lean
/- Copyright (c) 2024 Jz Pan. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jz Pan -/ import Mathlib.Algebra.Polynomial.Eval.Irreducible import Mathlib.RingTheory.Polynomial.Nilpotent /-! # Polynomials over an irreducible ring This file contains results about the polynomials over an irreducible ring (i.e. a ring with only one minimal prime ideal, equivalently, whose spectrum is an irreducible topological space). ## Main results - `Polynomial.Monic.irreducible_of_irreducible_map_of_isPrime_nilradical`: a monic polynomial over an irreducible ring is irreducible if it is irreducible after mapping into an integral domain. A generalization to `Polynomial.Monic.irreducible_of_irreducible_map`. ## Tags polynomial, irreducible ring, nilradical, prime ideal -/ open Polynomial noncomputable section /-- A polynomial over an irreducible ring `R` is irreducible if it is monic and irreducible after mapping into an integral domain `S` (https://math.stackexchange.com/a/4843432/235999). A generalization to `Polynomial.Monic.irreducible_of_irreducible_map`. -/ theorem Polynomial.Monic.irreducible_of_irreducible_map_of_isPrime_nilradical {R S : Type*} [CommRing R] [(nilradical R).IsPrime] [CommRing S] [IsDomain S] (φ : R →+* S) (f : R[X]) (hm : f.Monic) (hi : Irreducible (f.map φ)) : Irreducible f := by let R' := R ⧸ nilradical R let ψ : R' →+* S := Ideal.Quotient.lift (nilradical R) φ (haveI := RingHom.ker_isPrime φ; nilradical_le_prime (RingHom.ker φ)) let ι := algebraMap R R' rw [show φ = ψ.comp ι from rfl, ← map_map] at hi replace hi := hm.map ι |>.irreducible_of_irreducible_map _ _ hi refine ⟨fun h ↦ hi.1 <| (mapRingHom ι).isUnit_map h, fun a b h ↦ ?_⟩ wlog hb : IsUnit (b.map ι) generalizing a b · exact (this b a (mul_comm a b ▸ h) (hi.2 (by rw [h, Polynomial.map_mul]) |>.resolve_right hb)).symm have hn (i : ℕ) (hi : i ≠ 0) : IsNilpotent (b.coeff i) := by obtain ⟨_, _, h⟩ := Polynomial.isUnit_iff.1 hb simpa only [coeff_map, coeff_C, hi, ite_false, ← RingHom.mem_ker, show RingHom.ker ι = nilradical R from Ideal.mk_ker] using congr(coeff $(h.symm) i) refine .inr <| isUnit_of_coeff_isUnit_isNilpotent (isUnit_of_mul_isUnit_right (x := a.coeff f.natDegree) <| (IsUnit.neg_iff _).1 ?_) hn have hc : f.leadingCoeff = _ := congr(coeff $h f.natDegree) rw [hm, coeff_mul, Finset.Nat.sum_antidiagonal_eq_sum_range_succ fun i j ↦ a.coeff i * b.coeff j, Finset.sum_range_succ, ← sub_eq_iff_eq_add, Nat.sub_self] at hc rw [← add_sub_cancel_left 1 (-(_ * _)), ← sub_eq_add_neg, hc] exact IsNilpotent.isUnit_sub_one <| show _ ∈ nilradical R from sum_mem fun i hi ↦ Ideal.mul_mem_left _ _ <| hn _ <| Nat.sub_ne_zero_of_lt (List.mem_range.1 hi)
primitive_action.v
(* (c) Copyright 2006-2016 Microsoft Corporation and Inria. *) (* Distributed under the terms of CeCILL-B. *) From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat. From mathcomp Require Import div seq fintype tuple finset. From mathcomp Require Import fingroup action gseries. (******************************************************************************) (* n-transitive and primitive actions: *) (* [primitive A, on S | to] <=> *) (* A acts on S in a primitive manner, i.e., A is transitive on S and *) (* A does not act on any nontrivial partition of S. *) (* imprimitivity_system A to S Q <=> *) (* Q is a non-trivial primitivity system for the action of A on S via *) (* to, i.e., Q is a non-trivial partition of S on which A acts. *) (* to * n == in the %act scope, the total action induced by the total *) (* action to on n.-tuples. via n_act to n. *) (* n.-dtuple S == the set of n-tuples with distinct values in S. *) (* [transitive^n A, on S | to] <=> *) (* A is n-transitive on S, i.e., A is transitive on n.-dtuple S *) (* == the set of n-tuples with distinct values in S. *) (******************************************************************************) Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. Import GroupScope. Section PrimitiveDef. Variables (aT : finGroupType) (sT : finType). Variables (A : {set aT}) (S : {set sT}) (to : {action aT &-> sT}). Definition imprimitivity_system Q := [&& partition Q S, [acts A, on Q | to^*] & 1 < #|Q| < #|S|]. Definition primitive := [transitive A, on S | to] && ~~ [exists Q, imprimitivity_system Q]. End PrimitiveDef. Arguments imprimitivity_system {aT sT} A%_g S%_g to%_act Q%_g. Arguments primitive {aT sT} A%_g S%_g to%_act. Notation "[ 'primitive' A , 'on' S | to ]" := (primitive A S to) (format "[ 'primitive' A , 'on' S | to ]") : form_scope. Section Primitive. Variables (aT : finGroupType) (sT : finType). Variables (G : {group aT}) (to : {action aT &-> sT}) (S : {set sT}). Lemma trans_prim_astab x : x \in S -> [transitive G, on S | to] -> [primitive G, on S | to] = maximal_eq 'C_G[x | to] G. Proof. move=> Sx trG; rewrite /primitive trG negb_exists. apply/forallP/maximal_eqP=> /= [primG | [_ maxCx] Q]. split=> [|H sCH sHG]; first exact: subsetIl. pose X := orbit to H x; pose Q := orbit (to^*)%act G X. have Xx: x \in X by apply: orbit_refl. have defH: 'N_(G)(X | to) = H. have trH: [transitive H, on X | to] by apply/imsetP; exists x. have sHN: H \subset 'N_G(X | to) by rewrite subsetI sHG atrans_acts. move/(subgroup_transitiveP Xx sHN): (trH) => /= <-. by rewrite mulSGid //= setIAC subIset ?sCH. apply/imsetP; exists x => //; apply/eqP. by rewrite eqEsubset imsetS // acts_sub_orbit ?subsetIr. have [|/proper_card oCH] := eqVproper sCH; [by left | right]. apply/eqP; rewrite eqEcard sHG leqNgt. apply: contra {primG}(primG Q) => oHG; apply/and3P; split; last first. - rewrite card_orbit astab1_set defH -(@ltn_pmul2l #|H|) ?Lagrange // muln1. rewrite oHG -(@ltn_pmul2l #|H|) ?Lagrange // -(card_orbit_stab to G x). by rewrite -(atransP trG x Sx) mulnC card_orbit ltn_pmul2r. - by apply/actsP=> a Ga Y; apply/orbit_transl/mem_orbit. apply/and3P; split; last 1 first. - rewrite orbit_sym; apply/imsetP=> [[a _]] /= defX. by rewrite defX /setact imset0 inE in Xx. - apply/eqP/setP=> y; apply/bigcupP/idP=> [[_ /imsetP[a Ga ->]] | Sy]. case/imsetP=> _ /imsetP[b Hb ->] ->. by rewrite !(actsP (atrans_acts trG)) //; apply: subsetP Hb. case: (atransP2 trG Sx Sy) => a Ga ->. by exists ((to^*)%act X a); apply: imset_f; rewrite // orbit_refl. apply/trivIsetP=> _ _ /imsetP[a Ga ->] /imsetP[b Gb ->]. apply: contraR => /exists_inP[_ /imsetP[_ /imsetP[a1 Ha1 ->] ->]]. case/imsetP=> _ /imsetP[b1 Hb1 ->] /(canLR (actK _ _)) /(canLR (actK _ _)). rewrite -(canF_eq (actKV _ _)) -!actM (sameP eqP astab1P) => /astab1P Cab. rewrite astab1_set (subsetP (subsetIr G _)) //= defH. rewrite -(groupMr _ (groupVr Hb1)) -mulgA -(groupMl _ Ha1). by rewrite (subsetP sCH) // inE Cab !groupM ?groupV // (subsetP sHG). apply/and3P=> [[/and3P[/eqP defS tIQ ntQ]]]; set sto := (to^*)%act => actQ. rewrite !ltnNge -negb_or => /orP[]. pose X := pblock Q x; have Xx: x \in X by rewrite mem_pblock defS. have QX: X \in Q by rewrite pblock_mem ?defS. have toX Y a: Y \in Q -> a \in G -> to x a \in Y -> sto X a = Y. move=> QY Ga Yxa; rewrite -(contraNeq (trivIsetP tIQ Y (sto X a) _ _)) //. by rewrite (actsP actQ). by apply/existsP; exists (to x a); rewrite /= Yxa; apply: imset_f. have defQ: Q = orbit (to^*)%act G X. apply/eqP; rewrite eqEsubset andbC acts_sub_orbit // QX. apply/subsetP=> Y QY. have /set0Pn[y Yy]: Y != set0 by apply: contraNneq ntQ => <-. have Sy: y \in S by rewrite -defS; apply/bigcupP; exists Y. have [a Ga def_y] := atransP2 trG Sx Sy. by apply/imsetP; exists a; rewrite // (toX Y) // -def_y. rewrite defQ card_orbit; case: (maxCx 'C_G[X | sto]%G) => /= [||->|->]. - apply/subsetP=> a /setIP[Ga cxa]; rewrite inE Ga /=. by apply/astab1P; rewrite (toX X) // (astab1P cxa). - exact: subsetIl. - by right; rewrite -card_orbit (atransP trG). by left; rewrite indexgg. Qed. Lemma prim_trans_norm (H : {group aT}) : [primitive G, on S | to] -> H <| G -> H \subset 'C_G(S | to) \/ [transitive H, on S | to]. Proof. move=> primG /andP[sHG nHG]; rewrite subsetI sHG. have [trG _] := andP primG; have [x Sx defS] := imsetP trG. move: primG; rewrite (trans_prim_astab Sx) // => /maximal_eqP[_]. case/(_ ('C_G[x | to] <*> H)%G) => /= [||cxH|]; first exact: joing_subl. - by rewrite join_subG subsetIl. - have{} cxH: H \subset 'C_G[x | to] by rewrite -cxH joing_subr. rewrite subsetI sHG /= in cxH; left; apply/subsetP=> a Ha. apply/astabP=> y Sy; have [b Gb ->] := atransP2 trG Sx Sy. rewrite actCJV [to x (a ^ _)](astab1P _) ?(subsetP cxH) //. by rewrite -mem_conjg (normsP nHG). rewrite norm_joinEl 1?subIset ?nHG //. by move/(subgroup_transitiveP Sx sHG trG); right. Qed. End Primitive. Section NactionDef. Variables (gT : finGroupType) (sT : finType). Variables (to : {action gT &-> sT}) (n : nat). Definition n_act (t : n.-tuple sT) a := [tuple of map (to^~ a) t]. Fact n_act_is_action : is_action setT n_act. Proof. by apply: is_total_action => [t|t a b]; apply: eq_from_tnth => i; rewrite !tnth_map ?act1 ?actM. Qed. Canonical n_act_action := Action n_act_is_action. End NactionDef. Notation "to * n" := (n_act_action to n) : action_scope. Section NTransitive. Variables (gT : finGroupType) (sT : finType). Variables (n : nat) (A : {set gT}) (S : {set sT}) (to : {action gT &-> sT}). Definition dtuple_on := [set t : n.-tuple sT | uniq t & t \subset S]. Definition ntransitive := [transitive A, on dtuple_on | to * n]. Lemma dtuple_onP t : reflect (injective (tnth t) /\ forall i, tnth t i \in S) (t \in dtuple_on). Proof. rewrite inE subset_all -forallb_tnth -[in uniq t]map_tnth_enum /=. by apply: (iffP andP) => -[/injectiveP-f_inj /forallP]. Qed. Lemma n_act_dtuple t a : a \in 'N(S | to) -> t \in dtuple_on -> n_act to t a \in dtuple_on. Proof. move/astabsP=> toSa /dtuple_onP[t_inj St]; apply/dtuple_onP. split=> [i j | i]; rewrite !tnth_map ?[_ \in S]toSa //. by move/act_inj; apply: t_inj. Qed. End NTransitive. Arguments dtuple_on {sT} n%_N S%_g. Arguments ntransitive {gT sT} n%_N A%_g S%_g to%_act. Arguments n_act {gT sT} to {n} t a. Notation "n .-dtuple ( S )" := (dtuple_on n S) (format "n .-dtuple ( S )") : set_scope. Notation "[ 'transitive' ^ n A , 'on' S | to ]" := (ntransitive n A S to) (n at level 8, format "[ 'transitive' ^ n A , 'on' S | to ]") : form_scope. Section NTransitveProp. Variables (gT : finGroupType) (sT : finType). Variables (to : {action gT &-> sT}) (G : {group gT}) (S : {set sT}). Lemma card_uniq_tuple n (t : n.-tuple sT) : uniq t -> #|t| = n. Proof. by move/card_uniqP->; apply: size_tuple. Qed. Lemma n_act0 (t : 0.-tuple sT) a : n_act to t a = [tuple]. Proof. exact: tuple0. Qed. Lemma dtuple_on_add n x (t : n.-tuple sT) : ([tuple of x :: t] \in n.+1.-dtuple(S)) = [&& x \in S, x \notin t & t \in n.-dtuple(S)]. Proof. by rewrite !inE memtE !subset_all -!andbA; do !bool_congr. Qed. Lemma dtuple_on_add_D1 n x (t : n.-tuple sT) : ([tuple of x :: t] \in n.+1.-dtuple(S)) = (x \in S) && (t \in n.-dtuple(S :\ x)). Proof. rewrite dtuple_on_add !inE (andbCA (~~ _)); do 2!congr (_ && _). rewrite -!(eq_subset (in_set [in t])) setDE setIC subsetI; congr (_ && _). by rewrite -setCS setCK sub1set !inE. Qed. Lemma dtuple_on_subset n (S1 S2 : {set sT}) t : S1 \subset S2 -> t \in n.-dtuple(S1) -> t \in n.-dtuple(S2). Proof. by move=> sS12 /[!inE] /andP[-> /subset_trans]; apply. Qed. Lemma n_act_add n x (t : n.-tuple sT) a : n_act to [tuple of x :: t] a = [tuple of to x a :: n_act to t a]. Proof. exact: val_inj. Qed. Lemma ntransitive0 : [transitive^0 G, on S | to]. Proof. have dt0: [tuple] \in 0.-dtuple(S) by rewrite inE memtE subset_all. apply/imsetP; exists [tuple of Nil sT] => //. by apply/setP=> x; rewrite [x]tuple0 orbit_refl. Qed. Lemma ntransitive_weak k m : k <= m -> [transitive^m G, on S | to] -> [transitive^k G, on S | to]. Proof. move/subnKC <-; rewrite addnC; elim: {m}(m - k) => // m IHm. rewrite addSn => tr_m1; apply: IHm; move: {m k}(m + k) tr_m1 => m tr_m1. have ext_t t: t \in dtuple_on m S -> exists x, [tuple of x :: t] \in m.+1.-dtuple(S). - move=> dt. have [sSt | /subsetPn[x Sx ntx]] := boolP (S \subset t); last first. by exists x; rewrite dtuple_on_add andbA /= Sx ntx. case/imsetP: tr_m1 dt => t1 /[!inE] /andP[Ut1 St1] _ /andP[Ut _]. have /subset_leq_card := subset_trans St1 sSt. by rewrite !card_uniq_tuple // ltnn. case/imsetP: (tr_m1); case/tupleP=> [x t]; rewrite dtuple_on_add. case/and3P=> Sx ntx dt; set xt := [tuple of _] => tr_xt. apply/imsetP; exists t => //. apply/setP=> u; apply/idP/imsetP=> [du | [a Ga ->{u}]]. case: (ext_t u du) => y; rewrite tr_xt. by case/imsetP=> a Ga [_ def_u]; exists a => //; apply: val_inj. have: n_act to xt a \in dtuple_on _ S by rewrite tr_xt imset_f. by rewrite n_act_add dtuple_on_add; case/and3P. Qed. Lemma ntransitive1 m : 0 < m -> [transitive^m G, on S | to] -> [transitive G, on S | to]. Proof. have trdom1 x: ([tuple x] \in 1.-dtuple(S)) = (x \in S). by rewrite dtuple_on_add !inE memtE subset_all andbT. move=> m_gt0 /(ntransitive_weak m_gt0) {m m_gt0}. case/imsetP; case/tupleP=> x t0; rewrite {t0}(tuple0 t0) trdom1 => Sx trx. apply/imsetP; exists x => //; apply/setP=> y; rewrite -trdom1 trx. by apply/imsetP/imsetP=> [[a ? [->]]|[a ? ->]]; exists a => //; apply: val_inj. Qed. Lemma ntransitive_primitive m : 1 < m -> [transitive^m G, on S | to] -> [primitive G, on S | to]. Proof. move=> lt1m /(ntransitive_weak lt1m) {m lt1m}tr2G. have trG: [transitive G, on S | to] by apply: ntransitive1 tr2G. have [x Sx _]:= imsetP trG; rewrite (trans_prim_astab Sx trG). apply/maximal_eqP; split=> [|H]; first exact: subsetIl; rewrite subEproper. case/predU1P; first by [left]; case/andP=> sCH /subsetPn[a Ha nCa] sHG. right; rewrite -(subgroup_transitiveP Sx sHG trG _) ?mulSGid //. have actH := subset_trans sHG (atrans_acts trG). pose y := to x a; have Sy: y \in S by rewrite (actsP actH). have{nCa} yx: y != x by rewrite inE (sameP astab1P eqP) (subsetP sHG) in nCa. apply/imsetP; exists y => //; apply/eqP. rewrite eqEsubset acts_sub_orbit // Sy andbT; apply/subsetP=> z Sz. have [-> | zx] := eqVneq z x; first by rewrite orbit_sym mem_orbit. pose ty := [tuple y; x]; pose tz := [tuple z; x]. have [Sty Stz]: ty \in 2.-dtuple(S) /\ tz \in 2.-dtuple(S). by rewrite !inE !memtE !subset_all /= !mem_seq1 !andbT; split; apply/and3P. case: (atransP2 tr2G Sty Stz) => b Gb [->] /esym/astab1P cxb. by rewrite mem_orbit // (subsetP sCH) // inE Gb. Qed. End NTransitveProp. Section NTransitveProp1. Variables (gT : finGroupType) (sT : finType). Variables (to : {action gT &-> sT}) (G : {group gT}) (S : {set sT}). (* This is the forward implication of Aschbacher (15.12).1 *) Theorem stab_ntransitive m x : 0 < m -> x \in S -> [transitive^m.+1 G, on S | to] -> [transitive^m 'C_G[x | to], on S :\ x | to]. Proof. move=> m_gt0 Sx Gtr; have sSxS: S :\ x \subset S by rewrite subsetDl. case: (imsetP Gtr); case/tupleP=> x1 t1; rewrite dtuple_on_add. case/and3P=> Sx1 nt1x1 dt1 trt1; have Gtr1 := ntransitive1 (ltn0Sn _) Gtr. case: (atransP2 Gtr1 Sx1 Sx) => // a Ga x1ax. pose t := n_act to t1 a. have dxt: [tuple of x :: t] \in m.+1.-dtuple(S). by rewrite trt1 x1ax; apply/imsetP; exists a => //; apply: val_inj. apply/imsetP; exists t; first by rewrite dtuple_on_add_D1 Sx in dxt. apply/setP=> t2; apply/idP/imsetP => [dt2|[b]]. have: [tuple of x :: t2] \in dtuple_on _ S by rewrite dtuple_on_add_D1 Sx. case/(atransP2 Gtr dxt)=> b Gb [xbx tbt2]. by exists b; [rewrite inE Gb; apply/astab1P | apply: val_inj]. case/setIP=> Gb /astab1P xbx ->{t2}. rewrite n_act_dtuple //; last by rewrite dtuple_on_add_D1 Sx in dxt. apply/astabsP=> y; rewrite !inE -{1}xbx (inj_eq (act_inj _ _)). by rewrite (actsP (atrans_acts Gtr1)). Qed. (* This is the converse implication of Aschbacher (15.12).1 *) Theorem stab_ntransitiveI m x : x \in S -> [transitive G, on S | to] -> [transitive^m 'C_G[x | to], on S :\ x | to] -> [transitive^m.+1 G, on S | to]. Proof. move=> Sx Gtr Gntr. have t_to_x t: t \in m.+1.-dtuple(S) -> exists2 a, a \in G & exists2 t', t' \in m.-dtuple(S :\ x) & t = n_act to [tuple of x :: t'] a. - case/tupleP: t => y t St. have Sy: y \in S by rewrite dtuple_on_add_D1 in St; case/andP: St. rewrite -(atransP Gtr _ Sy) in Sx; case/imsetP: Sx => a Ga toya. exists a^-1; first exact: groupVr. exists (n_act to t a); last by rewrite n_act_add toya !actK. move/(n_act_dtuple (subsetP (atrans_acts Gtr) a Ga)): St. by rewrite n_act_add -toya dtuple_on_add_D1 => /andP[]. case: (imsetP Gntr) => t dt S_tG; pose xt := [tuple of x :: t]. have dxt: xt \in m.+1.-dtuple(S) by rewrite dtuple_on_add_D1 Sx. apply/imsetP; exists xt => //; apply/setP=> t2. apply/esym; apply/imsetP/idP=> [[a Ga ->] | ]. by apply: n_act_dtuple; rewrite // (subsetP (atrans_acts Gtr)). case/t_to_x=> a2 Ga2 [t2']; rewrite S_tG. case/imsetP=> a /setIP[Ga /astab1P toxa] -> -> {t2 t2'}. by exists (a * a2); rewrite (groupM, actM) //= !n_act_add toxa. Qed. End NTransitveProp1.
Submodule.lean
/- Copyright (c) 2019 Zhouhang Zhou. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Zhouhang Zhou, Frédéric Dupuis, Heather Macbeth -/ import Mathlib.Analysis.InnerProductSpace.Projection.Basic /-! # Subspaces associated with orthogonal projections Here, the orthogonal projection is used to prove a series of more subtle lemmas about the orthogonal complement of subspaces of `E` (the orthogonal complement itself was defined in `Mathlib/Analysis/InnerProductSpace/Orthogonal.lean`) such that they admit orthogonal projections; the lemma `Submodule.sup_orthogonal_of_hasOrthogonalProjection`, stating that for a subspace `K` of `E` such that `K` admits an orthogonal projection we have `K ⊔ Kᗮ = ⊤`, is a typical example. -/ variable {𝕜 E F : Type*} [RCLike 𝕜] variable [NormedAddCommGroup E] [NormedAddCommGroup F] variable [InnerProductSpace 𝕜 E] [InnerProductSpace ℝ F] local notation "⟪" x ", " y "⟫" => inner 𝕜 x y variable (K : Submodule 𝕜 E) namespace Submodule /-- If `K₁` admits an orthogonal projection and is contained in `K₂`, then `K₁` and `K₁ᗮ ⊓ K₂` span `K₂`. -/ theorem sup_orthogonal_inf_of_hasOrthogonalProjection {K₁ K₂ : Submodule 𝕜 E} (h : K₁ ≤ K₂) [K₁.HasOrthogonalProjection] : K₁ ⊔ K₁ᗮ ⊓ K₂ = K₂ := by ext x rw [Submodule.mem_sup] let v : K₁ := orthogonalProjection K₁ x have hvm : x - v ∈ K₁ᗮ := sub_starProjection_mem_orthogonal x constructor · rintro ⟨y, hy, z, hz, rfl⟩ exact K₂.add_mem (h hy) hz.2 · exact fun hx => ⟨v, v.prop, x - v, ⟨hvm, K₂.sub_mem hx (h v.prop)⟩, add_sub_cancel _ _⟩ @[deprecated (since := "2025-07-27")] alias sup_orthogonal_inf_of_completeSpace := sup_orthogonal_inf_of_hasOrthogonalProjection variable {K} in /-- If `K` admits an orthogonal projection, then `K` and `Kᗮ` span the whole space. -/ theorem sup_orthogonal_of_hasOrthogonalProjection [K.HasOrthogonalProjection] : K ⊔ Kᗮ = ⊤ := by convert Submodule.sup_orthogonal_inf_of_hasOrthogonalProjection (le_top : K ≤ ⊤) using 2 simp @[deprecated (since := "2025-07-27")] alias sup_orthogonal_of_completeSpace := sup_orthogonal_of_hasOrthogonalProjection /-- If `K` admits an orthogonal projection, then the orthogonal complement of its orthogonal complement is itself. -/ @[simp] theorem orthogonal_orthogonal [K.HasOrthogonalProjection] : Kᗮᗮ = K := by ext v constructor · obtain ⟨y, hy, z, hz, rfl⟩ := K.exists_add_mem_mem_orthogonal v intro hv have hz' : z = 0 := by have hyz : ⟪z, y⟫ = 0 := by simp [hz y hy, inner_eq_zero_symm] simpa [inner_add_right, hyz] using hv z hz simp [hy, hz'] · intro hv w hw rw [inner_eq_zero_symm] exact hw v hv lemma orthogonal_le_orthogonal_iff {K₀ K₁ : Submodule 𝕜 E} [K₀.HasOrthogonalProjection] [K₁.HasOrthogonalProjection] : K₀ᗮ ≤ K₁ᗮ ↔ K₁ ≤ K₀ := ⟨fun h ↦ by simpa using orthogonal_le h, orthogonal_le⟩ lemma orthogonal_le_iff_orthogonal_le {K₀ K₁ : Submodule 𝕜 E} [K₀.HasOrthogonalProjection] [K₁.HasOrthogonalProjection] : K₀ᗮ ≤ K₁ ↔ K₁ᗮ ≤ K₀ := by rw [← orthogonal_le_orthogonal_iff, orthogonal_orthogonal] lemma le_orthogonal_iff_le_orthogonal {K₀ K₁ : Submodule 𝕜 E} [K₀.HasOrthogonalProjection] [K₁.HasOrthogonalProjection] : K₀ ≤ K₁ᗮ ↔ K₁ ≤ K₀ᗮ := by rw [← orthogonal_le_orthogonal_iff, orthogonal_orthogonal] /-- In a Hilbert space, the orthogonal complement of the orthogonal complement of a subspace `K` is the topological closure of `K`. Note that the completeness assumption is necessary. Let `E` be the space `ℕ →₀ ℝ` with inner space structure inherited from `PiLp 2 (fun _ : ℕ ↦ ℝ)`. Let `K` be the subspace of sequences with the sum of all elements equal to zero. Then `Kᗮ = ⊥`, `Kᗮᗮ = ⊤`. -/ theorem orthogonal_orthogonal_eq_closure [CompleteSpace E] : Kᗮᗮ = K.topologicalClosure := by refine le_antisymm ?_ ?_ · convert Submodule.orthogonal_orthogonal_monotone K.le_topologicalClosure using 1 rw [K.topologicalClosure.orthogonal_orthogonal] · exact K.topologicalClosure_minimal K.le_orthogonal_orthogonal Kᗮ.isClosed_orthogonal variable {K} /-- If `K` admits an orthogonal projection, `K` and `Kᗮ` are complements of each other. -/ theorem isCompl_orthogonal_of_hasOrthogonalProjection [K.HasOrthogonalProjection] : IsCompl K Kᗮ := ⟨K.orthogonal_disjoint, codisjoint_iff.2 Submodule.sup_orthogonal_of_hasOrthogonalProjection⟩ @[deprecated (since := "2025-07-27")] alias isCompl_orthogonal_of_completeSpace := isCompl_orthogonal_of_hasOrthogonalProjection @[simp] theorem orthogonalComplement_eq_orthogonalComplement {L : Submodule 𝕜 E} [K.HasOrthogonalProjection] [L.HasOrthogonalProjection] : Kᗮ = Lᗮ ↔ K = L := ⟨fun h ↦ by simpa using congr(Submodule.orthogonal $(h)), fun h ↦ congr(Submodule.orthogonal $(h))⟩ @[simp] theorem orthogonal_eq_bot_iff [K.HasOrthogonalProjection] : Kᗮ = ⊥ ↔ K = ⊤ := by refine ⟨?_, fun h => by rw [h, Submodule.top_orthogonal_eq_bot]⟩ intro h have : K ⊔ Kᗮ = ⊤ := Submodule.sup_orthogonal_of_hasOrthogonalProjection rwa [h, sup_comm, bot_sup_eq] at this open Topology Finsupp RCLike Real Filter /-- Given a monotone family `U` of complete submodules of `E` and a fixed `x : E`, the orthogonal projection of `x` on `U i` tends to the orthogonal projection of `x` on `(⨆ i, U i).topologicalClosure` along `atTop`. -/ theorem starProjection_tendsto_closure_iSup {ι : Type*} [Preorder ι] (U : ι → Submodule 𝕜 E) [∀ i, (U i).HasOrthogonalProjection] [(⨆ i, U i).topologicalClosure.HasOrthogonalProjection] (hU : Monotone U) (x : E) : Filter.Tendsto (fun i => (U i).starProjection x) atTop (𝓝 ((⨆ i, U i).topologicalClosure.starProjection x)) := by refine .of_neBot_imp fun h ↦ ?_ cases atTop_neBot_iff.mp h let y := (⨆ i, U i).topologicalClosure.starProjection x have proj_x : ∀ i, (U i).orthogonalProjection x = (U i).orthogonalProjection y := fun i => (orthogonalProjection_starProjection_of_le ((le_iSup U i).trans (iSup U).le_topologicalClosure) _).symm suffices ∀ ε > 0, ∃ I, ∀ i ≥ I, ‖(U i).starProjection y - y‖ < ε by simpa only [starProjection_apply, proj_x, NormedAddCommGroup.tendsto_atTop] using this intro ε hε obtain ⟨a, ha, hay⟩ : ∃ a ∈ ⨆ i, U i, dist y a < ε := by have y_mem : y ∈ (⨆ i, U i).topologicalClosure := Submodule.coe_mem _ rw [← SetLike.mem_coe, Submodule.topologicalClosure_coe, Metric.mem_closure_iff] at y_mem exact y_mem ε hε rw [dist_eq_norm] at hay obtain ⟨I, hI⟩ : ∃ I, a ∈ U I := by rwa [Submodule.mem_iSup_of_directed _ hU.directed_le] at ha refine ⟨I, fun i (hi : I ≤ i) => ?_⟩ rw [norm_sub_rev, starProjection_minimal] refine lt_of_le_of_lt ?_ hay change _ ≤ ‖y - (⟨a, hU hi hI⟩ : U i)‖ exact ciInf_le ⟨0, Set.forall_mem_range.mpr fun _ => norm_nonneg _⟩ _ @[deprecated (since := "2025-07-07")] alias orthogonalProjection_tendsto_closure_iSup := starProjection_tendsto_closure_iSup /-- Given a monotone family `U` of complete submodules of `E` with dense span supremum, and a fixed `x : E`, the orthogonal projection of `x` on `U i` tends to `x` along `at_top`. -/ theorem starProjection_tendsto_self {ι : Type*} [Preorder ι] (U : ι → Submodule 𝕜 E) [∀ t, (U t).HasOrthogonalProjection] (hU : Monotone U) (x : E) (hU' : ⊤ ≤ (⨆ t, U t).topologicalClosure) : Filter.Tendsto (fun t => (U t).starProjection x) atTop (𝓝 x) := by have : (⨆ i, U i).topologicalClosure.HasOrthogonalProjection := by rw [top_unique hU'] infer_instance convert starProjection_tendsto_closure_iSup U hU x rw [eq_comm, starProjection_eq_self_iff, top_unique hU'] trivial @[deprecated (since := "2025-07-07")] alias orthogonalProjection_tendsto_self := starProjection_tendsto_self /-- The orthogonal complement satisfies `Kᗮᗮᗮ = Kᗮ`. -/ theorem triorthogonal_eq_orthogonal [CompleteSpace E] : Kᗮᗮᗮ = Kᗮ := by rw [Kᗮ.orthogonal_orthogonal_eq_closure] exact K.isClosed_orthogonal.submodule_topologicalClosure_eq /-- The closure of `K` is the full space iff `Kᗮ` is trivial. -/ theorem topologicalClosure_eq_top_iff [CompleteSpace E] : K.topologicalClosure = ⊤ ↔ Kᗮ = ⊥ := by rw [← K.orthogonal_orthogonal_eq_closure] constructor <;> intro h · rw [← Submodule.triorthogonal_eq_orthogonal, h, Submodule.top_orthogonal_eq_bot] · rw [h, Submodule.bot_orthogonal_eq_top] theorem orthogonalProjection_eq_linearProjOfIsCompl [K.HasOrthogonalProjection] (x : E) : K.orthogonalProjection x = K.linearProjOfIsCompl _ Submodule.isCompl_orthogonal_of_hasOrthogonalProjection x := by have : IsCompl K Kᗮ := Submodule.isCompl_orthogonal_of_hasOrthogonalProjection conv_lhs => rw [← Submodule.linearProjOfIsCompl_add_linearProjOfIsCompl_eq_self this x] rw [map_add, orthogonalProjection_mem_subspace_eq_self, orthogonalProjection_mem_subspace_orthogonalComplement_eq_zero (Submodule.coe_mem _), add_zero] @[deprecated (since := "2025-07-11")] alias orthogonalProjection_eq_linear_proj := orthogonalProjection_eq_linearProjOfIsCompl theorem orthogonalProjection_coe_eq_linearProjOfIsCompl [K.HasOrthogonalProjection] : (K.orthogonalProjection : E →ₗ[𝕜] K) = K.linearProjOfIsCompl _ Submodule.isCompl_orthogonal_of_hasOrthogonalProjection := LinearMap.ext <| orthogonalProjection_eq_linearProjOfIsCompl @[deprecated (since := "2025-07-11")] alias orthogonalProjection_coe_linearMap_eq_linearProj := orthogonalProjection_coe_eq_linearProjOfIsCompl open Submodule in theorem starProjection_coe_eq_isCompl_projection [K.HasOrthogonalProjection] : K.starProjection.toLinearMap = K.isCompl_orthogonal_of_hasOrthogonalProjection.projection := by simp [starProjection, orthogonalProjection_coe_eq_linearProjOfIsCompl, IsCompl.projection] end Submodule namespace Dense open Submodule variable {K} {x y : E} theorem eq_zero_of_inner_left (hK : Dense (K : Set E)) (h : ∀ v : K, ⟪x, v⟫ = 0) : x = 0 := by have : (⟪x, ·⟫) = 0 := (continuous_const.inner continuous_id).ext_on hK continuous_const (Subtype.forall.1 h) simpa using congr_fun this x theorem eq_zero_of_mem_orthogonal (hK : Dense (K : Set E)) (h : x ∈ Kᗮ) : x = 0 := eq_zero_of_inner_left hK fun v ↦ (mem_orthogonal' _ _).1 h _ v.2 /-- If `S` is dense and `x - y ∈ Kᗮ`, then `x = y`. -/ theorem eq_of_sub_mem_orthogonal (hK : Dense (K : Set E)) (h : x - y ∈ Kᗮ) : x = y := sub_eq_zero.1 <| eq_zero_of_mem_orthogonal hK h theorem eq_of_inner_left (hK : Dense (K : Set E)) (h : ∀ v : K, ⟪x, v⟫ = ⟪y, v⟫) : x = y := hK.eq_of_sub_mem_orthogonal (Submodule.sub_mem_orthogonal_of_inner_left h) theorem eq_of_inner_right (hK : Dense (K : Set E)) (h : ∀ v : K, ⟪(v : E), x⟫ = ⟪(v : E), y⟫) : x = y := hK.eq_of_sub_mem_orthogonal (Submodule.sub_mem_orthogonal_of_inner_right h) theorem eq_zero_of_inner_right (hK : Dense (K : Set E)) (h : ∀ v : K, ⟪(v : E), x⟫ = 0) : x = 0 := hK.eq_of_inner_right fun v => by rw [inner_zero_right, h v] end Dense
l2Space.lean
/- Copyright (c) 2022 Heather Macbeth. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Heather Macbeth -/ import Mathlib.Analysis.InnerProductSpace.Projection.Basic import Mathlib.Analysis.Normed.Lp.lpSpace import Mathlib.Analysis.InnerProductSpace.PiL2 /-! # Hilbert sum of a family of inner product spaces Given a family `(G : ι → Type*) [Π i, InnerProductSpace 𝕜 (G i)]` of inner product spaces, this file equips `lp G 2` with an inner product space structure, where `lp G 2` consists of those dependent functions `f : Π i, G i` for which `∑' i, ‖f i‖ ^ 2`, the sum of the norms-squared, is summable. This construction is sometimes called the *Hilbert sum* of the family `G`. By choosing `G` to be `ι → 𝕜`, the Hilbert space `ℓ²(ι, 𝕜)` may be seen as a special case of this construction. We also define a *predicate* `IsHilbertSum 𝕜 G V`, where `V : Π i, G i →ₗᵢ[𝕜] E`, expressing that `V` is an `OrthogonalFamily` and that the associated map `lp G 2 →ₗᵢ[𝕜] E` is surjective. ## Main definitions * `OrthogonalFamily.linearIsometry`: Given a Hilbert space `E`, a family `G` of inner product spaces and a family `V : Π i, G i →ₗᵢ[𝕜] E` of isometric embeddings of the `G i` into `E` with mutually-orthogonal images, there is an induced isometric embedding of the Hilbert sum of `G` into `E`. * `IsHilbertSum`: Given a Hilbert space `E`, a family `G` of inner product spaces and a family `V : Π i, G i →ₗᵢ[𝕜] E` of isometric embeddings of the `G i` into `E`, `IsHilbertSum 𝕜 G V` means that `V` is an `OrthogonalFamily` and that the above linear isometry is surjective. * `IsHilbertSum.linearIsometryEquiv`: If a Hilbert space `E` is a Hilbert sum of the inner product spaces `G i` with respect to the family `V : Π i, G i →ₗᵢ[𝕜] E`, then the corresponding `OrthogonalFamily.linearIsometry` can be upgraded to a `LinearIsometryEquiv`. * `HilbertBasis`: We define a *Hilbert basis* of a Hilbert space `E` to be a structure whose single field `HilbertBasis.repr` is an isometric isomorphism of `E` with `ℓ²(ι, 𝕜)` (i.e., the Hilbert sum of `ι` copies of `𝕜`). This parallels the definition of `Basis`, in `LinearAlgebra.Basis`, as an isomorphism of an `R`-module with `ι →₀ R`. * `HilbertBasis.instCoeFun`: More conventionally a Hilbert basis is thought of as a family `ι → E` of vectors in `E` satisfying certain properties (orthonormality, completeness). We obtain this interpretation of a Hilbert basis `b` by defining `⇑b`, of type `ι → E`, to be the image under `b.repr` of `lp.single 2 i (1:𝕜)`. This parallels the definition `Basis.coeFun` in `LinearAlgebra.Basis`. * `HilbertBasis.mk`: Make a Hilbert basis of `E` from an orthonormal family `v : ι → E` of vectors in `E` whose span is dense. This parallels the definition `Basis.mk` in `LinearAlgebra.Basis`. * `HilbertBasis.mkOfOrthogonalEqBot`: Make a Hilbert basis of `E` from an orthonormal family `v : ι → E` of vectors in `E` whose span has trivial orthogonal complement. ## Main results * `lp.instInnerProductSpace`: Construction of the inner product space instance on the Hilbert sum `lp G 2`. Note that from the file `Analysis.Normed.Lp.lpSpace`, the space `lp G 2` already held a normed space instance (`lp.normedSpace`), and if each `G i` is a Hilbert space (i.e., complete), then `lp G 2` was already known to be complete (`lp.completeSpace`). So the work here is to define the inner product and show it is compatible. * `OrthogonalFamily.range_linearIsometry`: Given a family `G` of inner product spaces and a family `V : Π i, G i →ₗᵢ[𝕜] E` of isometric embeddings of the `G i` into `E` with mutually-orthogonal images, the image of the embedding `OrthogonalFamily.linearIsometry` of the Hilbert sum of `G` into `E` is the closure of the span of the images of the `G i`. * `HilbertBasis.repr_apply_apply`: Given a Hilbert basis `b` of `E`, the entry `b.repr x i` of `x`'s representation in `ℓ²(ι, 𝕜)` is the inner product `⟪b i, x⟫`. * `HilbertBasis.hasSum_repr`: Given a Hilbert basis `b` of `E`, a vector `x` in `E` can be expressed as the "infinite linear combination" `∑' i, b.repr x i • b i` of the basis vectors `b i`, with coefficients given by the entries `b.repr x i` of `x`'s representation in `ℓ²(ι, 𝕜)`. * `exists_hilbertBasis`: A Hilbert space admits a Hilbert basis. ## Keywords Hilbert space, Hilbert sum, l2, Hilbert basis, unitary equivalence, isometric isomorphism -/ open RCLike Submodule Filter open scoped NNReal ENNReal ComplexConjugate Topology noncomputable section variable {ι 𝕜 : Type*} [RCLike 𝕜] {E : Type*} variable [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] variable {G : ι → Type*} [∀ i, NormedAddCommGroup (G i)] [∀ i, InnerProductSpace 𝕜 (G i)] local notation "⟪" x ", " y "⟫" => inner 𝕜 x y /-- `ℓ²(ι, 𝕜)` is the Hilbert space of square-summable functions `ι → 𝕜`, herein implemented as `lp (fun i : ι => 𝕜) 2`. -/ notation "ℓ²(" ι ", " 𝕜 ")" => lp (fun i : ι => 𝕜) 2 /-! ### Inner product space structure on `lp G 2` -/ namespace lp theorem summable_inner (f g : lp G 2) : Summable fun i => ⟪f i, g i⟫ := by -- Apply the Direct Comparison Test, comparing with ∑' i, ‖f i‖ * ‖g i‖ (summable by Hölder) refine .of_norm_bounded (lp.summable_mul ?_ f g) ?_ · rw [Real.holderConjugate_iff]; norm_num intro i -- Then apply Cauchy-Schwarz pointwise exact norm_inner_le_norm (𝕜 := 𝕜) _ _ instance instInnerProductSpace : InnerProductSpace 𝕜 (lp G 2) := { lp.normedAddCommGroup (E := G) (p := 2) with inner := fun f g => ∑' i, ⟪f i, g i⟫ norm_sq_eq_re_inner := fun f => by calc ‖f‖ ^ 2 = ‖f‖ ^ (2 : ℝ≥0∞).toReal := by norm_cast _ = ∑' i, ‖f i‖ ^ (2 : ℝ≥0∞).toReal := lp.norm_rpow_eq_tsum ?_ f _ = ∑' i, ‖f i‖ ^ (2 : ℕ) := by norm_cast _ = ∑' i, re ⟪f i, f i⟫ := by simp [norm_sq_eq_re_inner (𝕜 := 𝕜)] _ = re (∑' i, ⟪f i, f i⟫) := (RCLike.reCLM.map_tsum ?_).symm · norm_num · exact summable_inner f f conj_inner_symm := fun f g => by calc conj _ = conj (∑' i, ⟪g i, f i⟫) := by congr _ = ∑' i, conj ⟪g i, f i⟫ := RCLike.conjCLE.map_tsum _ = ∑' i, ⟪f i, g i⟫ := by simp only [inner_conj_symm] _ = _ := by congr add_left := fun f₁ f₂ g => by calc _ = ∑' i, ⟪(f₁ + f₂) i, g i⟫ := ?_ _ = ∑' i, (⟪f₁ i, g i⟫ + ⟪f₂ i, g i⟫) := by simp only [inner_add_left, Pi.add_apply, coeFn_add] _ = (∑' i, ⟪f₁ i, g i⟫) + ∑' i, ⟪f₂ i, g i⟫ := Summable.tsum_add ?_ ?_ _ = _ := by congr · congr · exact summable_inner f₁ g · exact summable_inner f₂ g smul_left := fun f g c => by calc _ = ∑' i, ⟪c • f i, g i⟫ := ?_ _ = ∑' i, conj c * ⟪f i, g i⟫ := by simp only [inner_smul_left] _ = conj c * ∑' i, ⟪f i, g i⟫ := tsum_mul_left _ = _ := ?_ · simp only [coeFn_smul, Pi.smul_apply] · congr } theorem inner_eq_tsum (f g : lp G 2) : ⟪f, g⟫ = ∑' i, ⟪f i, g i⟫ := rfl theorem hasSum_inner (f g : lp G 2) : HasSum (fun i => ⟪f i, g i⟫) ⟪f, g⟫ := (summable_inner f g).hasSum theorem inner_single_left [DecidableEq ι] (i : ι) (a : G i) (f : lp G 2) : ⟪lp.single 2 i a, f⟫ = ⟪a, f i⟫ := by refine (hasSum_inner (lp.single 2 i a) f).unique ?_ simp_rw [lp.coeFn_single] convert hasSum_ite_eq i ⟪a, f i⟫ using 1 ext j split_ifs with h · subst h; rw [Pi.single_eq_same] · simp [Pi.single_eq_of_ne h] theorem inner_single_right [DecidableEq ι] (i : ι) (a : G i) (f : lp G 2) : ⟪f, lp.single 2 i a⟫ = ⟪f i, a⟫ := by simpa [inner_conj_symm] using congr_arg conj (inner_single_left (𝕜 := 𝕜) i a f) end lp /-! ### Identification of a general Hilbert space `E` with a Hilbert sum -/ namespace OrthogonalFamily variable [CompleteSpace E] {V : ∀ i, G i →ₗᵢ[𝕜] E} (hV : OrthogonalFamily 𝕜 G V) include hV protected theorem summable_of_lp (f : lp G 2) : Summable fun i => V i (f i) := by rw [hV.summable_iff_norm_sq_summable] convert (lp.memℓp f).summable _ · norm_cast · norm_num /-- A mutually orthogonal family of subspaces of `E` induce a linear isometry from `lp 2` of the subspaces into `E`. -/ protected def linearIsometry (hV : OrthogonalFamily 𝕜 G V) : lp G 2 →ₗᵢ[𝕜] E where toFun f := ∑' i, V i (f i) map_add' f g := by simp only [(hV.summable_of_lp f).tsum_add (hV.summable_of_lp g), lp.coeFn_add, Pi.add_apply, LinearIsometry.map_add] map_smul' c f := by simpa only [LinearIsometry.map_smul, Pi.smul_apply, lp.coeFn_smul] using (hV.summable_of_lp f).tsum_const_smul c norm_map' f := by classical -- needed for lattice instance on `Finset ι`, for `Filter.atTop_neBot` have H : 0 < (2 : ℝ≥0∞).toReal := by simp suffices ‖∑' i : ι, V i (f i)‖ ^ (2 : ℝ≥0∞).toReal = ‖f‖ ^ (2 : ℝ≥0∞).toReal by exact Real.rpow_left_injOn H.ne' (norm_nonneg _) (norm_nonneg _) this refine tendsto_nhds_unique ?_ (lp.hasSum_norm H f) convert (hV.summable_of_lp f).hasSum.norm.rpow_const (Or.inr H.le) using 1 ext s exact mod_cast (hV.norm_sum f s).symm protected theorem linearIsometry_apply (f : lp G 2) : hV.linearIsometry f = ∑' i, V i (f i) := rfl protected theorem hasSum_linearIsometry (f : lp G 2) : HasSum (fun i => V i (f i)) (hV.linearIsometry f) := (hV.summable_of_lp f).hasSum @[simp] protected theorem linearIsometry_apply_single [DecidableEq ι] {i : ι} (x : G i) : hV.linearIsometry (lp.single 2 i x) = V i x := by rw [hV.linearIsometry_apply, ← tsum_ite_eq i (V i x)] congr ext j rw [lp.single_apply] split_ifs with h · subst h; simp · simp [h] protected theorem linearIsometry_apply_dfinsupp_sum_single [DecidableEq ι] [∀ i, DecidableEq (G i)] (W₀ : Π₀ i : ι, G i) : hV.linearIsometry (W₀.sum (lp.single 2)) = W₀.sum fun i => V i := by simp /-- The canonical linear isometry from the `lp 2` of a mutually orthogonal family of subspaces of `E` into E, has range the closure of the span of the subspaces. -/ protected theorem range_linearIsometry [∀ i, CompleteSpace (G i)] : LinearMap.range hV.linearIsometry.toLinearMap = (⨆ i, LinearMap.range (V i).toLinearMap).topologicalClosure := by classical refine le_antisymm ?_ ?_ · rintro x ⟨f, rfl⟩ refine mem_closure_of_tendsto (hV.hasSum_linearIsometry f) (Eventually.of_forall ?_) intro s rw [SetLike.mem_coe] refine sum_mem ?_ intro i _ refine mem_iSup_of_mem i ?_ exact LinearMap.mem_range_self _ (f i) · apply topologicalClosure_minimal · refine iSup_le ?_ rintro i x ⟨x, rfl⟩ use lp.single 2 i x exact hV.linearIsometry_apply_single x exact hV.linearIsometry.isometry.isUniformInducing.isComplete_range.isClosed end OrthogonalFamily section IsHilbertSum variable (𝕜 G) variable [CompleteSpace E] (V : ∀ i, G i →ₗᵢ[𝕜] E) (F : ι → Submodule 𝕜 E) /-- Given a family of Hilbert spaces `G : ι → Type*`, a Hilbert sum of `G` consists of a Hilbert space `E` and an orthogonal family `V : Π i, G i →ₗᵢ[𝕜] E` such that the induced isometry `Φ : lp G 2 → E` is surjective. Keeping in mind that `lp G 2` is "the" external Hilbert sum of `G : ι → Type*`, this is analogous to `DirectSum.IsInternal`, except that we don't express it in terms of actual submodules. -/ structure IsHilbertSum : Prop where ofSurjective :: /-- The orthogonal family constituting the summands in the Hilbert sum. -/ protected OrthogonalFamily : OrthogonalFamily 𝕜 G V /-- The isometry `lp G 2 → E` induced by the orthogonal family is surjective. -/ protected surjective_isometry : Function.Surjective OrthogonalFamily.linearIsometry variable {𝕜 G V} /-- If `V : Π i, G i →ₗᵢ[𝕜] E` is an orthogonal family such that the supremum of the ranges of `V i` is dense, then `(E, V)` is a Hilbert sum of `G`. -/ theorem IsHilbertSum.mk [∀ i, CompleteSpace <| G i] (hVortho : OrthogonalFamily 𝕜 G V) (hVtotal : ⊤ ≤ (⨆ i, LinearMap.range (V i).toLinearMap).topologicalClosure) : IsHilbertSum 𝕜 G V := { OrthogonalFamily := hVortho surjective_isometry := by rw [← LinearIsometry.coe_toLinearMap] exact LinearMap.range_eq_top.mp (eq_top_iff.mpr <| hVtotal.trans_eq hVortho.range_linearIsometry.symm) } /-- This is `Orthonormal.isHilbertSum` in the case of actual inclusions from subspaces. -/ theorem IsHilbertSum.mkInternal [∀ i, CompleteSpace <| F i] (hFortho : OrthogonalFamily 𝕜 (fun i => F i) fun i => (F i).subtypeₗᵢ) (hFtotal : ⊤ ≤ (⨆ i, F i).topologicalClosure) : IsHilbertSum 𝕜 (fun i => F i) fun i => (F i).subtypeₗᵢ := IsHilbertSum.mk hFortho (by simpa [subtypeₗᵢ_toLinearMap, range_subtype] using hFtotal) /-- *A* Hilbert sum `(E, V)` of `G` is canonically isomorphic to *the* Hilbert sum of `G`, i.e `lp G 2`. Note that this goes in the opposite direction from `OrthogonalFamily.linearIsometry`. -/ noncomputable def IsHilbertSum.linearIsometryEquiv (hV : IsHilbertSum 𝕜 G V) : E ≃ₗᵢ[𝕜] lp G 2 := LinearIsometryEquiv.symm <| LinearIsometryEquiv.ofSurjective hV.OrthogonalFamily.linearIsometry hV.surjective_isometry /-- In the canonical isometric isomorphism between a Hilbert sum `E` of `G` and `lp G 2`, a vector `w : lp G 2` is the image of the infinite sum of the associated elements in `E`. -/ protected theorem IsHilbertSum.linearIsometryEquiv_symm_apply (hV : IsHilbertSum 𝕜 G V) (w : lp G 2) : hV.linearIsometryEquiv.symm w = ∑' i, V i (w i) := by simp [IsHilbertSum.linearIsometryEquiv, OrthogonalFamily.linearIsometry_apply] /-- In the canonical isometric isomorphism between a Hilbert sum `E` of `G` and `lp G 2`, a vector `w : lp G 2` is the image of the infinite sum of the associated elements in `E`, and this sum indeed converges. -/ protected theorem IsHilbertSum.hasSum_linearIsometryEquiv_symm (hV : IsHilbertSum 𝕜 G V) (w : lp G 2) : HasSum (fun i => V i (w i)) (hV.linearIsometryEquiv.symm w) := by simp [IsHilbertSum.linearIsometryEquiv, OrthogonalFamily.hasSum_linearIsometry] /-- In the canonical isometric isomorphism between a Hilbert sum `E` of `G : ι → Type*` and `lp G 2`, an "elementary basis vector" in `lp G 2` supported at `i : ι` is the image of the associated element in `E`. -/ @[simp] protected theorem IsHilbertSum.linearIsometryEquiv_symm_apply_single [DecidableEq ι] (hV : IsHilbertSum 𝕜 G V) {i : ι} (x : G i) : hV.linearIsometryEquiv.symm (lp.single 2 i x) = V i x := by simp [IsHilbertSum.linearIsometryEquiv, OrthogonalFamily.linearIsometry_apply_single] /-- In the canonical isometric isomorphism between a Hilbert sum `E` of `G : ι → Type*` and `lp G 2`, a finitely-supported vector in `lp G 2` is the image of the associated finite sum of elements of `E`. -/ protected theorem IsHilbertSum.linearIsometryEquiv_symm_apply_dfinsupp_sum_single [DecidableEq ι] [∀ i, DecidableEq (G i)] (hV : IsHilbertSum 𝕜 G V) (W₀ : Π₀ i : ι, G i) : hV.linearIsometryEquiv.symm (W₀.sum (lp.single 2)) = W₀.sum fun i => V i := by simp only [map_dfinsuppSum, IsHilbertSum.linearIsometryEquiv_symm_apply_single] /-- In the canonical isometric isomorphism between a Hilbert sum `E` of `G : ι → Type*` and `lp G 2`, a finitely-supported vector in `lp G 2` is the image of the associated finite sum of elements of `E`. -/ @[simp] protected theorem IsHilbertSum.linearIsometryEquiv_apply_dfinsupp_sum_single [DecidableEq ι] [∀ i, DecidableEq (G i)] (hV : IsHilbertSum 𝕜 G V) (W₀ : Π₀ i : ι, G i) : ((W₀.sum (γ := lp G 2) fun a b ↦ hV.linearIsometryEquiv (V a b)) : ∀ i, G i) = W₀ := by rw [← map_dfinsuppSum] rw [← hV.linearIsometryEquiv_symm_apply_dfinsupp_sum_single] rw [LinearIsometryEquiv.apply_symm_apply] ext i simp +contextual [DFinsupp.sum, lp.single_apply] /-- Given a total orthonormal family `v : ι → E`, `E` is a Hilbert sum of `fun i : ι => 𝕜` relative to the family of linear isometries `fun i k => k • v i`. -/ theorem Orthonormal.isHilbertSum {v : ι → E} (hv : Orthonormal 𝕜 v) (hsp : ⊤ ≤ (span 𝕜 (Set.range v)).topologicalClosure) : IsHilbertSum 𝕜 (fun _ : ι => 𝕜) fun i => LinearIsometry.toSpanSingleton 𝕜 E (hv.1 i) := IsHilbertSum.mk hv.orthogonalFamily (by convert hsp simp [← LinearMap.span_singleton_eq_range, ← Submodule.span_iUnion]) theorem Submodule.isHilbertSumOrthogonal (K : Submodule 𝕜 E) [hK : CompleteSpace K] : IsHilbertSum 𝕜 (fun b => ↥(cond b K Kᗮ)) fun b => (cond b K Kᗮ).subtypeₗᵢ := by have : ∀ b, CompleteSpace (↥(cond b K Kᗮ)) := by intro b cases b <;> first | exact instOrthogonalCompleteSpace K | assumption refine IsHilbertSum.mkInternal _ K.orthogonalFamily_self ?_ refine le_trans ?_ (Submodule.le_topologicalClosure _) rw [iSup_bool_eq, cond, cond] refine Codisjoint.top_le ?_ exact Submodule.isCompl_orthogonal_of_hasOrthogonalProjection.codisjoint end IsHilbertSum /-! ### Hilbert bases -/ section variable (ι) (𝕜) (E) /-- A Hilbert basis on `ι` for an inner product space `E` is an identification of `E` with the `lp` space `ℓ²(ι, 𝕜)`. -/ structure HilbertBasis where ofRepr :: /-- The linear isometric equivalence implementing identifying the Hilbert space with `ℓ²`. -/ repr : E ≃ₗᵢ[𝕜] ℓ²(ι, 𝕜) end namespace HilbertBasis instance {ι : Type*} : Inhabited (HilbertBasis ι 𝕜 ℓ²(ι, 𝕜)) := ⟨ofRepr (LinearIsometryEquiv.refl 𝕜 _)⟩ open Classical in /-- `b i` is the `i`th basis vector. -/ instance instFunLike : FunLike (HilbertBasis ι 𝕜 E) ι E where coe b i := b.repr.symm (lp.single 2 i (1 : 𝕜)) coe_injective' | ⟨b₁⟩, ⟨b₂⟩, h => by congr apply LinearIsometryEquiv.symm_bijective.injective apply LinearIsometryEquiv.toContinuousLinearEquiv_injective apply ContinuousLinearEquiv.coe_injective refine lp.ext_continuousLinearMap ( ENNReal.ofNat_ne_top (n := nat_lit 2)) fun i => ?_ ext exact congr_fun h i @[simp] protected theorem repr_symm_single [DecidableEq ι] (b : HilbertBasis ι 𝕜 E) (i : ι) : b.repr.symm (lp.single 2 i (1 : 𝕜)) = b i := by dsimp [instFunLike] convert rfl protected theorem repr_self [DecidableEq ι] (b : HilbertBasis ι 𝕜 E) (i : ι) : b.repr (b i) = lp.single 2 i (1 : 𝕜) := by simp only [LinearIsometryEquiv.apply_symm_apply, ← b.repr_symm_single] protected theorem repr_apply_apply (b : HilbertBasis ι 𝕜 E) (v : E) (i : ι) : b.repr v i = ⟪b i, v⟫ := by classical rw [← b.repr.inner_map_map (b i) v, b.repr_self, lp.inner_single_left] simp @[simp] protected theorem orthonormal (b : HilbertBasis ι 𝕜 E) : Orthonormal 𝕜 b := by classical rw [orthonormal_iff_ite] intro i j rw [← b.repr.inner_map_map (b i) (b j), b.repr_self, b.repr_self, lp.inner_single_left, lp.single_apply, Pi.single_apply] simp protected theorem hasSum_repr_symm (b : HilbertBasis ι 𝕜 E) (f : ℓ²(ι, 𝕜)) : HasSum (fun i => f i • b i) (b.repr.symm f) := by classical suffices H : (fun i : ι => f i • b i) = fun b_1 : ι => b.repr.symm.toContinuousLinearEquiv <| (fun i : ι => lp.single 2 i (f i) (E := (fun _ : ι => 𝕜))) b_1 by rw [H] have : HasSum (fun i : ι => lp.single 2 i (f i)) f := lp.hasSum_single ENNReal.ofNat_ne_top f exact (↑b.repr.symm.toContinuousLinearEquiv : ℓ²(ι, 𝕜) →L[𝕜] E).hasSum this ext i apply b.repr.injective letI : NormedSpace 𝕜 (lp (fun _i : ι => 𝕜) 2) := by infer_instance have : lp.single (E := (fun _ : ι => 𝕜)) 2 i (f i * 1) = f i • lp.single 2 i 1 := lp.single_smul (E := (fun _ : ι => 𝕜)) 2 i (f i) (1 : 𝕜) rw [mul_one] at this rw [LinearIsometryEquiv.map_smul, b.repr_self, ← this, LinearIsometryEquiv.coe_toContinuousLinearEquiv] exact (b.repr.apply_symm_apply (lp.single 2 i (f i))).symm protected theorem hasSum_repr (b : HilbertBasis ι 𝕜 E) (x : E) : HasSum (fun i => b.repr x i • b i) x := by simpa using b.hasSum_repr_symm (b.repr x) @[simp] protected theorem dense_span (b : HilbertBasis ι 𝕜 E) : (span 𝕜 (Set.range b)).topologicalClosure = ⊤ := by classical rw [eq_top_iff] rintro x - refine mem_closure_of_tendsto (b.hasSum_repr x) (Eventually.of_forall ?_) intro s simp only [SetLike.mem_coe] refine sum_mem ?_ rintro i - refine smul_mem _ _ ?_ exact subset_span ⟨i, rfl⟩ protected theorem hasSum_inner_mul_inner (b : HilbertBasis ι 𝕜 E) (x y : E) : HasSum (fun i => ⟪x, b i⟫ * ⟪b i, y⟫) ⟪x, y⟫ := by convert (b.hasSum_repr y).mapL (innerSL 𝕜 x) using 1 ext i rw [innerSL_apply, b.repr_apply_apply, inner_smul_right, mul_comm] protected theorem summable_inner_mul_inner (b : HilbertBasis ι 𝕜 E) (x y : E) : Summable fun i => ⟪x, b i⟫ * ⟪b i, y⟫ := (b.hasSum_inner_mul_inner x y).summable protected theorem tsum_inner_mul_inner (b : HilbertBasis ι 𝕜 E) (x y : E) : ∑' i, ⟪x, b i⟫ * ⟪b i, y⟫ = ⟪x, y⟫ := (b.hasSum_inner_mul_inner x y).tsum_eq -- Note: this should be `b.repr` composed with an identification of `lp (fun i : ι => 𝕜) p` with -- `PiLp p (fun i : ι => 𝕜)` (in this case with `p = 2`), but we don't have this yet (July 2022). /-- A finite Hilbert basis is an orthonormal basis. -/ protected def toOrthonormalBasis [Fintype ι] (b : HilbertBasis ι 𝕜 E) : OrthonormalBasis ι 𝕜 E := OrthonormalBasis.mk b.orthonormal (by refine Eq.ge ?_ classical have := (span 𝕜 (Finset.univ.image b : Set E)).closed_of_finiteDimensional simpa only [Finset.coe_image, Finset.coe_univ, Set.image_univ, HilbertBasis.dense_span] using this.submodule_topologicalClosure_eq.symm) @[simp] theorem coe_toOrthonormalBasis [Fintype ι] (b : HilbertBasis ι 𝕜 E) : (b.toOrthonormalBasis : ι → E) = b := OrthonormalBasis.coe_mk _ _ protected theorem hasSum_orthogonalProjection {U : Submodule 𝕜 E} [CompleteSpace U] (b : HilbertBasis ι 𝕜 U) (x : E) : HasSum (fun i => ⟪(b i : E), x⟫ • b i) (U.orthogonalProjection x) := by simpa only [b.repr_apply_apply, inner_orthogonalProjection_eq_of_mem_left] using b.hasSum_repr (U.orthogonalProjection x) theorem finite_spans_dense [DecidableEq E] (b : HilbertBasis ι 𝕜 E) : (⨆ J : Finset ι, span 𝕜 (J.image b : Set E)).topologicalClosure = ⊤ := eq_top_iff.mpr <| b.dense_span.ge.trans (by simp_rw [← Submodule.span_iUnion] exact topologicalClosure_mono (span_mono <| Set.range_subset_iff.mpr fun i => Set.mem_iUnion_of_mem {i} <| Finset.mem_coe.mpr <| Finset.mem_image_of_mem _ <| Finset.mem_singleton_self i)) variable [CompleteSpace E] section variable {v : ι → E} (hv : Orthonormal 𝕜 v) include hv /-- An orthonormal family of vectors whose span is dense in the whole module is a Hilbert basis. -/ protected def mk (hsp : ⊤ ≤ (span 𝕜 (Set.range v)).topologicalClosure) : HilbertBasis ι 𝕜 E := HilbertBasis.ofRepr <| (hv.isHilbertSum hsp).linearIsometryEquiv theorem _root_.Orthonormal.linearIsometryEquiv_symm_apply_single_one [DecidableEq ι] (h i) : (hv.isHilbertSum h).linearIsometryEquiv.symm (lp.single 2 i 1) = v i := by rw [IsHilbertSum.linearIsometryEquiv_symm_apply_single, LinearIsometry.toSpanSingleton_apply, one_smul] @[simp] protected theorem coe_mk (hsp : ⊤ ≤ (span 𝕜 (Set.range v)).topologicalClosure) : ⇑(HilbertBasis.mk hv hsp) = v := by classical apply funext <| Orthonormal.linearIsometryEquiv_symm_apply_single_one hv hsp /-- An orthonormal family of vectors whose span has trivial orthogonal complement is a Hilbert basis. -/ protected def mkOfOrthogonalEqBot (hsp : (span 𝕜 (Set.range v))ᗮ = ⊥) : HilbertBasis ι 𝕜 E := HilbertBasis.mk hv (by rw [← orthogonal_orthogonal_eq_closure, ← eq_top_iff, orthogonal_eq_top_iff, hsp]) @[simp] protected theorem coe_mkOfOrthogonalEqBot (hsp : (span 𝕜 (Set.range v))ᗮ = ⊥) : ⇑(HilbertBasis.mkOfOrthogonalEqBot hv hsp) = v := HilbertBasis.coe_mk hv _ -- Note : this should be `b.repr` composed with an identification of `lp (fun i : ι => 𝕜) p` with -- `PiLp p (fun i : ι => 𝕜)` (in this case with `p = 2`), but we don't have this yet (July 2022). /-- An orthonormal basis is a Hilbert basis. -/ protected def _root_.OrthonormalBasis.toHilbertBasis [Fintype ι] (b : OrthonormalBasis ι 𝕜 E) : HilbertBasis ι 𝕜 E := HilbertBasis.mk b.orthonormal <| by simpa only [← OrthonormalBasis.coe_toBasis, b.toBasis.span_eq, eq_top_iff] using @subset_closure E _ _ end @[simp] theorem _root_.OrthonormalBasis.coe_toHilbertBasis [Fintype ι] (b : OrthonormalBasis ι 𝕜 E) : (b.toHilbertBasis : ι → E) = b := HilbertBasis.coe_mk _ _ /-- A Hilbert space admits a Hilbert basis extending a given orthonormal subset. -/ theorem _root_.Orthonormal.exists_hilbertBasis_extension {s : Set E} (hs : Orthonormal 𝕜 ((↑) : s → E)) : ∃ (w : Set E) (b : HilbertBasis w 𝕜 E), s ⊆ w ∧ ⇑b = ((↑) : w → E) := let ⟨w, hws, hw_ortho, hw_max⟩ := exists_maximal_orthonormal hs ⟨w, HilbertBasis.mkOfOrthogonalEqBot hw_ortho (by simpa only [Subtype.range_coe_subtype, Set.setOf_mem_eq, maximal_orthonormal_iff_orthogonalComplement_eq_bot hw_ortho] using hw_max), hws, HilbertBasis.coe_mkOfOrthogonalEqBot _ _⟩ variable (𝕜 E) /-- A Hilbert space admits a Hilbert basis. -/ theorem _root_.exists_hilbertBasis : ∃ (w : Set E) (b : HilbertBasis w 𝕜 E), ⇑b = ((↑) : w → E) := let ⟨w, hw, _, hw''⟩ := (orthonormal_empty 𝕜 E).exists_hilbertBasis_extension ⟨w, hw, hw''⟩ end HilbertBasis
IsPrincipalPowQuotient.lean
/- Copyright (c) 2024 Yakov Pechersky. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yakov Pechersky -/ import Mathlib.LinearAlgebra.Isomorphisms import Mathlib.RingTheory.Ideal.Operations import Mathlib.RingTheory.Ideal.Quotient.Defs /-! # Quotients of powers of principal ideals This file deals with taking quotients of powers of principal ideals. ## Main definitions and results * `Ideal.quotEquivPowQuotPowSucc`: for a principal ideal `I`, `R ⧸ I ≃ₗ[R] I ^ n ⧸ I ^ (n + 1)` ## Implementation details At site of usage, calling `LinearEquiv.toEquiv` can cause timeouts in the search for a complex synthesis like `Module 𝒪[K] 𝓀[k]`, so the plain equiv versions are provided. These equivs are defined here as opposed to in the quotients file since they cannot be formed as ring equivs. -/ namespace Ideal section IsPrincipal variable {R : Type*} [CommRing R] [IsDomain R] {I : Ideal R} /-- For a principal ideal `I`, `R ⧸ I ≃ₗ[R] I ^ n ⧸ I ^ (n + 1)`. To convert into a form that uses the ideal of `R ⧸ I ^ (n + 1)`, compose with `Ideal.powQuotPowSuccLinearEquivMapMkPowSuccPow`. -/ noncomputable def quotEquivPowQuotPowSucc (h : I.IsPrincipal) (h' : I ≠ ⊥) (n : ℕ) : (R ⧸ I) ≃ₗ[R] (I ^ n : Ideal R) ⧸ (I • ⊤ : Submodule R (I ^ n : Ideal R)) := by let f : (I ^ n : Ideal R) →ₗ[R] (I ^ n : Ideal R) ⧸ (I • ⊤ : Submodule R (I ^ n : Ideal R)) := Submodule.mkQ _ let ϖ := h.principal.choose have hI : I = Ideal.span {ϖ} := h.principal.choose_spec have hϖ : ϖ ^ n ∈ I ^ n := hI ▸ (Ideal.pow_mem_pow (Ideal.mem_span_singleton_self _) n) let g : R →ₗ[R] (I ^ n : Ideal R) := (LinearMap.mulRight R ϖ^n).codRestrict _ fun x ↦ by simp only [LinearMap.pow_mulRight, LinearMap.mulRight_apply] -- TODO: change argument of Ideal.pow_mem_of_mem exact Ideal.mul_mem_left _ _ hϖ have : I = LinearMap.ker (f.comp g) := by ext x simp only [LinearMap.codRestrict, LinearMap.pow_mulRight, LinearMap.mulRight_apply, LinearMap.mem_ker, LinearMap.coe_comp, LinearMap.coe_mk, AddHom.coe_mk, Function.comp_apply, Submodule.mkQ_apply, Submodule.Quotient.mk_eq_zero, Submodule.mem_smul_top_iff, smul_eq_mul, f, g] constructor <;> intro hx · exact Submodule.mul_mem_mul hx hϖ · rw [← pow_succ', hI, Ideal.span_singleton_pow, Ideal.mem_span_singleton] at hx obtain ⟨y, hy⟩ := hx rw [mul_comm, pow_succ, mul_assoc, mul_right_inj' (pow_ne_zero _ _)] at hy · rw [hI, Ideal.mem_span_singleton] exact ⟨y, hy⟩ · contrapose! h' rw [hI, h', Ideal.span_singleton_eq_bot] let e : (R ⧸ I) ≃ₗ[R] R ⧸ (LinearMap.ker (f.comp g)) := Submodule.quotEquivOfEq I (LinearMap.ker (f ∘ₗ g)) this refine e.trans ((f.comp g).quotKerEquivOfSurjective ?_) refine (Submodule.mkQ_surjective _).comp ?_ rintro ⟨x, hx⟩ rw [hI, Ideal.span_singleton_pow, Ideal.mem_span_singleton] at hx refine hx.imp ?_ simp [g, LinearMap.codRestrict, eq_comm, mul_comm] /-- For a principal ideal `I`, `R ⧸ I ≃ I ^ n ⧸ I ^ (n + 1)`. Supplied as a plain equiv to bypass typeclass synthesis issues on complex `Module` goals. To convert into a form that uses the ideal of `R ⧸ I ^ (n + 1)`, compose with `Ideal.powQuotPowSuccEquivMapMkPowSuccPow`. -/ noncomputable def quotEquivPowQuotPowSuccEquiv (h : I.IsPrincipal) (h' : I ≠ ⊥) (n : ℕ) : (R ⧸ I) ≃ (I ^ n : Ideal R) ⧸ (I • ⊤ : Submodule R (I ^ n : Ideal R)) := quotEquivPowQuotPowSucc h h' n end IsPrincipal end Ideal
character.v
(* (c) Copyright 2006-2016 Microsoft Corporation and Inria. *) (* Distributed under the terms of CeCILL-B. *) From HB Require Import structures. From mathcomp Require Import ssreflect ssrbool ssrfun eqtype choice ssrnat seq. From mathcomp Require Import path div fintype tuple finfun bigop prime order. From mathcomp Require Import ssralg poly finset gproduct fingroup morphism. From mathcomp Require Import perm automorphism quotient finalg action zmodp. From mathcomp Require Import commutator cyclic center pgroup nilpotent sylow. From mathcomp Require Import abelian matrix mxalgebra mxpoly mxrepresentation. From mathcomp Require Import vector ssrnum algC classfun archimedean. (******************************************************************************) (* This file contains the basic notions of character theory, based on Isaacs. *) (* irr G == tuple of the elements of 'CF(G) that are irreducible *) (* characters of G. *) (* Nirr G == number of irreducible characters of G. *) (* Iirr G == index type for the irreducible characters of G. *) (* := 'I_(Nirr G). *) (* 'chi_i == the i-th element of irr G, for i : Iirr G. *) (* 'chi[G]_i Note that 'chi_0 = 1, the principal character of G. *) (* 'Chi_i == an irreducible representation that affords 'chi_i. *) (* socle_of_Iirr i == the Wedderburn component of the regular representation *) (* of G, corresponding to 'Chi_i. *) (* Iirr_of_socle == the inverse of socle_of_Iirr (which is one-to-one). *) (* phi.[A]%CF == the image of A \in group_ring G under phi : 'CF(G). *) (* cfRepr rG == the character afforded by the representation rG of G. *) (* cfReg G == the regular character, afforded by the regular *) (* representation of G. *) (* detRepr rG == the linear character afforded by the determinant of rG. *) (* cfDet phi == the linear character afforded by the determinant of a *) (* representation affording phi. *) (* 'o(phi) == the "determinential order" of phi (the multiplicative *) (* order of cfDet phi. *) (* phi \is a character <=> phi : 'CF(G) is a character of G or 0. *) (* i \in irr_constt phi <=> 'chi_i is an irreducible constituent of phi: phi *) (* has a non-zero coordinate on 'chi_i over the basis irr G. *) (* xi \is a linear_char xi <=> xi : 'CF(G) is a linear character of G. *) (* 'Z(chi)%CF == the center of chi when chi is a character of G, i.e., *) (* rcenter rG where rG is a representation that affords phi. *) (* If phi is not a character then 'Z(chi)%CF = cfker phi. *) (* aut_Iirr u i == the index of cfAut u 'chi_i in irr G. *) (* conjC_Iirr i == the index of 'chi_i^*%CF in irr G. *) (* morph_Iirr i == the index of cfMorph 'chi[f @* G]_i in irr G. *) (* isom_Iirr isoG i == the index of cfIsom isoG 'chi[G]_i in irr R. *) (* mod_Iirr i == the index of ('chi[G / H]_i %% H)%CF in irr G. *) (* quo_Iirr i == the index of ('chi[G]_i / H)%CF in irr (G / H). *) (* Ind_Iirr G i == the index of 'Ind[G, H] 'chi_i, provided it is an *) (* irreducible character (such as when if H is the inertia *) (* group of 'chi_i). *) (* Res_Iirr H i == the index of 'Res[H, G] 'chi_i, provided it is an *) (* irreducible character (such as when 'chi_i is linear). *) (* sdprod_Iirr defG i == the index of cfSdprod defG 'chi_i in irr G, given *) (* defG : K ><| H = G. *) (* And, for KxK : K \x H = G. *) (* dprodl_Iirr KxH i == the index of cfDprodl KxH 'chi[K]_i in irr G. *) (* dprodr_Iirr KxH j == the index of cfDprodr KxH 'chi[H]_j in irr G. *) (* dprod_Iirr KxH (i, j) == the index of cfDprod KxH 'chi[K]_i 'chi[H]_j. *) (* inv_dprod_Iirr KxH == the inverse of dprod_Iirr KxH. *) (* The following are used to define and exploit the character table: *) (* character_table G == the character table of G, whose i-th row lists the *) (* values taken by 'chi_i on the conjugacy classes *) (* of G; this is a square Nirr G x NirrG matrix. *) (* irr_class i == the conjugacy class of G with index i : Iirr G. *) (* class_Iirr xG == the index of xG \in classes G, in Iirr G. *) (******************************************************************************) Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. Import Order.TTheory GroupScope GRing.Theory Num.Theory. Local Open Scope ring_scope. Section AlgC. Variable (gT : finGroupType). Lemma groupC : group_closure_field algC gT. Proof. exact: group_closure_closed_field. Qed. End AlgC. Section Tensor. Variable (F : fieldType). Fixpoint trow (n1 : nat) : forall (A : 'rV[F]_n1) m2 n2 (B : 'M[F]_(m2,n2)), 'M[F]_(m2,n1 * n2) := if n1 is n'1.+1 then fun (A : 'M[F]_(1,(1 + n'1))) m2 n2 (B : 'M[F]_(m2,n2)) => (row_mx (lsubmx A 0 0 *: B) (trow (rsubmx A) B)) else (fun _ _ _ _ => 0). Lemma trow0 n1 m2 n2 B : @trow n1 0 m2 n2 B = 0. Proof. elim: n1=> //= n1 IH. rewrite !mxE scale0r linear0. rewrite IH //; apply/matrixP=> i j; rewrite !mxE. by case: split=> *; rewrite mxE. Qed. Definition trowb n1 m2 n2 B A := @trow n1 A m2 n2 B. Lemma trowbE n1 m2 n2 A B : trowb B A = @trow n1 A m2 n2 B. Proof. by []. Qed. Lemma trowb_is_linear n1 m2 n2 (B : 'M_(m2,n2)) : linear (@trowb n1 m2 n2 B). Proof. elim: n1=> [|n1 IH] //= k A1 A2 /=; first by rewrite scaler0 add0r. rewrite !linearD /= !linearZ /= IH 2!mxE. by rewrite scalerDl -scalerA -add_row_mx -scale_row_mx. Qed. HB.instance Definition _ n1 m2 n2 B := GRing.isSemilinear.Build _ _ _ _ (trowb B) (GRing.semilinear_linear (@trowb_is_linear n1 m2 n2 B)). Lemma trow_is_linear n1 m2 n2 (A : 'rV_n1) : linear (@trow n1 A m2 n2). Proof. elim: n1 A => [|n1 IH] //= A k A1 A2 /=; first by rewrite scaler0 add0r. rewrite linearP /=; apply/matrixP=> i j; rewrite !mxE. by case: split=> a; rewrite ?IH !mxE. Qed. HB.instance Definition _ n1 m2 n2 A := GRing.isSemilinear.Build _ _ _ _ (@trow n1 A m2 n2) (GRing.semilinear_linear (@trow_is_linear n1 m2 n2 A)). Fixpoint tprod (m1 : nat) : forall n1 (A : 'M[F]_(m1,n1)) m2 n2 (B : 'M[F]_(m2,n2)), 'M[F]_(m1 * m2,n1 * n2) := if m1 is m'1.+1 return forall n1 (A : 'M[F]_(m1,n1)) m2 n2 (B : 'M[F]_(m2,n2)), 'M[F]_(m1 * m2,n1 * n2) then fun n1 (A : 'M[F]_(1 + m'1,n1)) m2 n2 B => (col_mx (trow (usubmx A) B) (tprod (dsubmx A) B)) else (fun _ _ _ _ _ => 0). Lemma dsumx_mul m1 m2 n p A B : dsubmx ((A *m B) : 'M[F]_(m1 + m2, n)) = dsubmx (A : 'M_(m1 + m2, p)) *m B. Proof. apply/matrixP=> i j /[!mxE]; apply: eq_bigr=> k _. by rewrite !mxE. Qed. Lemma usumx_mul m1 m2 n p A B : usubmx ((A *m B) : 'M[F]_(m1 + m2, n)) = usubmx (A : 'M_(m1 + m2, p)) *m B. Proof. by apply/matrixP=> i j /[!mxE]; apply: eq_bigr=> k _ /[!mxE]. Qed. Let trow_mul (m1 m2 n2 p2 : nat) (A : 'rV_m1) (B1: 'M[F]_(m2,n2)) (B2 :'M[F]_(n2,p2)) : trow A (B1 *m B2) = B1 *m trow A B2. Proof. elim: m1 A => [|m1 IH] A /=; first by rewrite mulmx0. by rewrite IH mul_mx_row -scalemxAr. Qed. Lemma tprodE m1 n1 p1 (A1 :'M[F]_(m1,n1)) (A2 :'M[F]_(n1,p1)) m2 n2 p2 (B1 :'M[F]_(m2,n2)) (B2 :'M[F]_(n2,p2)) : tprod (A1 *m A2) (B1 *m B2) = (tprod A1 B1) *m (tprod A2 B2). Proof. elim: m1 n1 p1 A1 A2 m2 n2 p2 B1 B2 => /= [|m1 IH]. by move=> *; rewrite mul0mx. move=> n1 p1 A1 A2 m2 n2 p2 B1 B2. rewrite mul_col_mx -IH. congr col_mx; last by rewrite dsumx_mul. rewrite usumx_mul. elim: n1 {A1}(usubmx (A1: 'M_(1 + m1, n1))) p1 A2=> //= [u p1 A2|]. by rewrite [A2](flatmx0) !mulmx0 -trowbE linear0. move=> n1 IH1 A p1 A2 //=. set Al := lsubmx _; set Ar := rsubmx _. set Su := usubmx _; set Sd := dsubmx _. rewrite mul_row_col -IH1. rewrite -{1}(@hsubmxK F 1 1 n1 A). rewrite -{1}(@vsubmxK F 1 n1 p1 A2). rewrite (@mul_row_col F 1 1 n1 p1). rewrite -trowbE linearD /= trowbE -/Al. congr (_ + _). rewrite {1}[Al]mx11_scalar mul_scalar_mx. by rewrite -trowbE linearZ /= trowbE -/Su trow_mul scalemxAl. Qed. Let tprod_tr m1 n1 (A :'M[F]_(m1, 1 + n1)) m2 n2 (B :'M[F]_(m2, n2)) : tprod A B = row_mx (trow (lsubmx A)^T B^T)^T (tprod (rsubmx A) B). Proof. elim: m1 n1 A m2 n2 B=> [|m1 IH] n1 A m2 n2 B //=. by rewrite trmx0 row_mx0. rewrite !IH. pose A1 := A : 'M_(1 + m1, 1 + n1). have F1: dsubmx (rsubmx A1) = rsubmx (dsubmx A1). by apply/matrixP=> i j; rewrite !mxE. have F2: rsubmx (usubmx A1) = usubmx (rsubmx A1). by apply/matrixP=> i j; rewrite !mxE. have F3: lsubmx (dsubmx A1) = dsubmx (lsubmx A1). by apply/matrixP=> i j; rewrite !mxE. rewrite tr_row_mx -block_mxEv -block_mxEh !(F1,F2,F3); congr block_mx. - by rewrite !mxE linearZ /= trmxK. by rewrite -trmx_dsub. Qed. Lemma tprod1 m n : tprod (1%:M : 'M[F]_(m,m)) (1%:M : 'M[F]_(n,n)) = 1%:M. Proof. elim: m n => [|m IH] n //=; first by rewrite [1%:M]flatmx0. rewrite tprod_tr. set u := rsubmx _; have->: u = 0. apply/matrixP=> i j; rewrite !mxE. by case: i; case: j=> /= j Hj; case. set v := lsubmx (dsubmx _); have->: v = 0. apply/matrixP=> i j; rewrite !mxE. by case: i; case: j; case. set w := rsubmx _; have->: w = 1%:M. apply/matrixP=> i j; rewrite !mxE. by case: i; case: j; case. rewrite IH -!trowbE !linear0. rewrite -block_mxEv. set z := (lsubmx _) 0 0; have->: z = 1. by rewrite /z !mxE eqxx. by rewrite scale1r scalar_mx_block. Qed. Lemma mxtrace_prod m n (A :'M[F]_(m)) (B :'M[F]_(n)) : \tr (tprod A B) = \tr A * \tr B. Proof. elim: m n A B => [|m IH] n A B //=. by rewrite [A]flatmx0 mxtrace0 mul0r. rewrite tprod_tr -block_mxEv mxtrace_block IH. rewrite linearZ/= -mulrDl -trace_mx11; congr (_ * _). pose A1 := A : 'M_(1 + m). rewrite -[A in RHS](@submxK _ 1 m 1 m A1). by rewrite (@mxtrace_block _ _ _ (ulsubmx A1)). Qed. End Tensor. (* Representation sigma type and standard representations. *) Section StandardRepresentation. Variables (R : fieldType) (gT : finGroupType) (G : {group gT}). Local Notation reprG := (mx_representation R G). Record representation := Representation {rdegree; mx_repr_of_repr :> reprG rdegree}. Lemma mx_repr0 : mx_repr G (fun _ : gT => 1%:M : 'M[R]_0). Proof. by split=> // g h Hg Hx; rewrite mulmx1. Qed. Definition grepr0 := Representation (MxRepresentation mx_repr0). Lemma add_mx_repr (rG1 rG2 : representation) : mx_repr G (fun g => block_mx (rG1 g) 0 0 (rG2 g)). Proof. split=> [|x y Hx Hy]; first by rewrite !repr_mx1 -scalar_mx_block. by rewrite mulmx_block !(mulmx0, mul0mx, addr0, add0r, repr_mxM). Qed. Definition dadd_grepr rG1 rG2 := Representation (MxRepresentation (add_mx_repr rG1 rG2)). Section DsumRepr. Variables (n : nat) (rG : reprG n). Lemma mx_rsim_dadd (U V W : 'M_n) (rU rV : representation) (modU : mxmodule rG U) (modV : mxmodule rG V) (modW : mxmodule rG W) : (U + V :=: W)%MS -> mxdirect (U + V) -> mx_rsim (submod_repr modU) rU -> mx_rsim (submod_repr modV) rV -> mx_rsim (submod_repr modW) (dadd_grepr rU rV). Proof. case: rU; case: rV=> nV rV nU rU defW dxUV /=. have tiUV := mxdirect_addsP dxUV. move=> [fU def_nU]; rewrite -{nU}def_nU in rU fU * => inv_fU hom_fU. move=> [fV def_nV]; rewrite -{nV}def_nV in rV fV * => inv_fV hom_fV. pose pU := in_submod U (proj_mx U V) *m fU. pose pV := in_submod V (proj_mx V U) *m fV. exists (val_submod 1%:M *m row_mx pU pV) => [||g Gg]. - by rewrite -defW (mxdirectP dxUV). - apply/row_freeP. pose pU' := invmx fU *m val_submod 1%:M. pose pV' := invmx fV *m val_submod 1%:M. exists (in_submod _ (col_mx pU' pV')). rewrite in_submodE mulmxA -in_submodE -mulmxA mul_row_col mulmxDr. rewrite -[pU *m _]mulmxA -[pV *m _]mulmxA !mulKVmx -?row_free_unit //. rewrite addrC (in_submodE V) 2![val_submod 1%:M *m _]mulmxA -in_submodE. rewrite addrC (in_submodE U) 2![val_submod 1%:M *m _ in X in X + _]mulmxA. rewrite -in_submodE -!val_submodE !in_submodK ?proj_mx_sub //. by rewrite add_proj_mx ?val_submodK // val_submod1 defW. rewrite mulmxA -val_submodE -[submod_repr _ g]mul1mx val_submodJ //. rewrite -(mulmxA _ (rG g)) mul_mx_row -[in RHS]mulmxA mul_row_block. rewrite !mulmx0 addr0 add0r !mul_mx_row. set W' := val_submod 1%:M; congr (row_mx _ _). rewrite 3!mulmxA in_submodE mulmxA. have hom_pU: (W' <= dom_hom_mx rG (proj_mx U V))%MS. by rewrite val_submod1 -defW proj_mx_hom. rewrite (hom_mxP hom_pU) // -in_submodE (in_submodJ modU) ?proj_mx_sub //. rewrite -(mulmxA _ _ fU) hom_fU // in_submodE -2!(mulmxA W') -in_submodE. by rewrite -mulmxA (mulmxA _ fU). rewrite 3!mulmxA in_submodE mulmxA. have hom_pV: (W' <= dom_hom_mx rG (proj_mx V U))%MS. by rewrite val_submod1 -defW addsmxC proj_mx_hom // capmxC. rewrite (hom_mxP hom_pV) // -in_submodE (in_submodJ modV) ?proj_mx_sub //. rewrite -(mulmxA _ _ fV) hom_fV // in_submodE -2!(mulmxA W') -in_submodE. by rewrite -mulmxA (mulmxA _ fV). Qed. Lemma mx_rsim_dsum (I : finType) (P : pred I) U rU (W : 'M_n) (modU : forall i, mxmodule rG (U i)) (modW : mxmodule rG W) : let S := (\sum_(i | P i) U i)%MS in (S :=: W)%MS -> mxdirect S -> (forall i, mx_rsim (submod_repr (modU i)) (rU i : representation)) -> mx_rsim (submod_repr modW) (\big[dadd_grepr/grepr0]_(i | P i) rU i). Proof. move=> /= defW dxW rsimU. rewrite mxdirectE /= -!(big_filter _ P) in dxW defW *. elim: {P}(filter P _) => [|i e IHe] in W modW dxW defW *. rewrite !big_nil /= in defW *. by exists 0 => [||? _]; rewrite ?mul0mx ?mulmx0 // /row_free -defW !mxrank0. rewrite !big_cons /= in dxW defW *. rewrite 2!(big_nth i) !big_mkord /= in IHe dxW defW. set Wi := (\sum_i _)%MS in defW dxW IHe. rewrite -mxdirectE mxdirect_addsE !mxdirectE eqxx /= -/Wi in dxW. have modWi: mxmodule rG Wi by apply: sumsmx_module. case/andP: dxW; move/(IHe Wi modWi) {IHe}; move/(_ (eqmx_refl _))=> rsimWi. by move/eqP; move/mxdirect_addsP=> dxUiWi; apply: mx_rsim_dadd (rsimU i) rsimWi. Qed. Definition muln_grepr rW k := \big[dadd_grepr/grepr0]_(i < k) rW. Lemma mx_rsim_socle (sG : socleType rG) (W : sG) (rW : representation) : let modW : mxmodule rG W := component_mx_module rG (socle_base W) in mx_rsim (socle_repr W) rW -> mx_rsim (submod_repr modW) (muln_grepr rW (socle_mult W)). Proof. set M := socle_base W => modW rsimM. have simM: mxsimple rG M := socle_simple W. have rankM_gt0: (\rank M > 0)%N by rewrite lt0n mxrank_eq0; case: simM. have [I /= U_I simU]: mxsemisimple rG W by apply: component_mx_semisimple. pose U (i : 'I_#|I|) := U_I (enum_val i). have reindexI := reindex _ (onW_bij I (enum_val_bij I)). rewrite mxdirectE /= !reindexI -mxdirectE /= => defW dxW. have isoU: forall i, mx_iso rG M (U i). move=> i; have sUiW: (U i <= W)%MS by rewrite -defW (sumsmx_sup i). exact: component_mx_iso (simU _) sUiW. have ->: socle_mult W = #|I|. rewrite -(mulnK #|I| rankM_gt0); congr (_ %/ _)%N. rewrite -defW (mxdirectP dxW) /= -sum_nat_const reindexI /=. by apply: eq_bigr => i _; rewrite -(mxrank_iso (isoU i)). have modU: mxmodule rG (U _) := mxsimple_module (simU _). suff: mx_rsim (submod_repr (modU _)) rW by apply: mx_rsim_dsum defW dxW. by move=> i; apply: mx_rsim_trans (mx_rsim_sym _) rsimM; apply/mx_rsim_iso. Qed. End DsumRepr. Section ProdRepr. Variables (n1 n2 : nat) (rG1 : reprG n1) (rG2 : reprG n2). Lemma prod_mx_repr : mx_repr G (fun g => tprod (rG1 g) (rG2 g)). Proof. split=>[|i j InG JnG]; first by rewrite !repr_mx1 tprod1. by rewrite !repr_mxM // tprodE. Qed. Definition prod_repr := MxRepresentation prod_mx_repr. End ProdRepr. Lemma prod_repr_lin n2 (rG1 : reprG 1) (rG2 : reprG n2) : {in G, forall x, let cast_n2 := esym (mul1n n2) in prod_repr rG1 rG2 x = castmx (cast_n2, cast_n2) (rG1 x 0 0 *: rG2 x)}. Proof. move=> x Gx /=; set cast_n2 := esym _; rewrite /prod_repr /= !mxE !lshift0. apply/matrixP=> i j; rewrite castmxE /=. do 2![rewrite mxE; case: splitP => [? ? | []//]]. by congr ((_ *: rG2 x) _ _); apply: val_inj. Qed. End StandardRepresentation. Arguments grepr0 {R gT G}. Prenex Implicits dadd_grepr. Section Char. Variables (gT : finGroupType) (G : {group gT}). Fact cfRepr_subproof n (rG : mx_representation algC G n) : is_class_fun <<G>> [ffun x => \tr (rG x) *+ (x \in G)]. Proof. rewrite genGid; apply: intro_class_fun => [x y Gx Gy | _ /negbTE-> //]. by rewrite groupJr // !repr_mxM ?groupM ?groupV // mxtrace_mulC repr_mxK. Qed. Definition cfRepr n rG := Cfun 0 (@cfRepr_subproof n rG). Lemma cfRepr1 n rG : @cfRepr n rG 1%g = n%:R. Proof. by rewrite cfunE group1 repr_mx1 mxtrace1. Qed. Lemma cfRepr_sim n1 n2 rG1 rG2 : mx_rsim rG1 rG2 -> @cfRepr n1 rG1 = @cfRepr n2 rG2. Proof. case/mx_rsim_def=> f12 [f21] fK def_rG1; apply/cfun_inP=> x Gx. by rewrite !cfunE def_rG1 // mxtrace_mulC mulmxA fK mul1mx. Qed. Lemma cfRepr0 : cfRepr grepr0 = 0. Proof. by apply/cfun_inP=> x Gx; rewrite !cfunE Gx mxtrace1. Qed. Lemma cfRepr_dadd rG1 rG2 : cfRepr (dadd_grepr rG1 rG2) = cfRepr rG1 + cfRepr rG2. Proof. by apply/cfun_inP=> x Gx; rewrite !cfunE Gx mxtrace_block. Qed. Lemma cfRepr_dsum I r (P : pred I) rG : cfRepr (\big[dadd_grepr/grepr0]_(i <- r | P i) rG i) = \sum_(i <- r | P i) cfRepr (rG i). Proof. exact: (big_morph _ cfRepr_dadd cfRepr0). Qed. Lemma cfRepr_muln rG k : cfRepr (muln_grepr rG k) = cfRepr rG *+ k. Proof. by rewrite cfRepr_dsum /= sumr_const card_ord. Qed. Section StandardRepr. Variables (n : nat) (rG : mx_representation algC G n). Let sG := DecSocleType rG. Let iG : irrType algC G := DecSocleType _. Definition standard_irr (W : sG) := irr_comp iG (socle_repr W). Definition standard_socle i := pick [pred W | standard_irr W == i]. Local Notation soc := standard_socle. Definition standard_irr_coef i := oapp (fun W => socle_mult W) 0 (soc i). Definition standard_grepr := \big[dadd_grepr/grepr0]_i muln_grepr (Representation (socle_repr i)) (standard_irr_coef i). Lemma mx_rsim_standard : mx_rsim rG standard_grepr. Proof. pose W i := oapp val 0 (soc i); pose S := (\sum_i W i)%MS. have C'G: [pchar algC]^'.-group G := algC'G_pchar G. have [defS dxS]: (S :=: 1%:M)%MS /\ mxdirect S. rewrite /S mxdirectE /= !(bigID soc xpredT) /=. rewrite addsmxC big1 => [|i]; last by rewrite /W; case (soc i). rewrite adds0mx_id addnC (@big1 nat) ?add0n => [|i]; last first. by rewrite /W; case: (soc i); rewrite ?mxrank0. have <-: Socle sG = 1%:M := reducible_Socle1 sG (mx_Maschke_pchar rG C'G). have [W0 _ | noW] := pickP sG; last first. suff no_i: (soc : pred iG) =1 xpred0 by rewrite /Socle !big_pred0 ?mxrank0. by move=> i; rewrite /soc; case: pickP => // W0; have:= noW W0. have irrK Wi: soc (standard_irr Wi) = Some Wi. rewrite /soc; case: pickP => [W' | /(_ Wi)] /= /eqP // eqWi. apply/eqP/socle_rsimP. apply: mx_rsim_trans (rsim_irr_comp_pchar iG C'G (socle_irr _)) (mx_rsim_sym _). by rewrite [irr_comp _ _]eqWi; apply: rsim_irr_comp_pchar (socle_irr _). have bij_irr: {on [pred i | soc i], bijective standard_irr}. exists (odflt W0 \o soc) => [Wi _ | i]; first by rewrite /= irrK. by rewrite inE /soc /=; case: pickP => //= Wi; move/eqP. rewrite !(reindex standard_irr) {bij_irr}//=. have all_soc Wi: soc (standard_irr Wi) by rewrite irrK. rewrite (eq_bigr val) => [|Wi _]; last by rewrite /W irrK. rewrite !(eq_bigl _ _ all_soc); split=> //. rewrite (eq_bigr (mxrank \o val)) => [|Wi _]; last by rewrite /W irrK. by rewrite -mxdirectE /= Socle_direct. pose modW i : mxmodule rG (W i) := if soc i is Some Wi as oWi return mxmodule rG (oapp val 0 oWi) then component_mx_module rG (socle_base Wi) else mxmodule0 rG n. apply: mx_rsim_trans (mx_rsim_sym (rsim_submod1 (mxmodule1 rG) _)) _ => //. apply: mx_rsim_dsum (modW) _ defS dxS _ => i. rewrite /W /standard_irr_coef /modW /soc; case: pickP => [Wi|_] /=; last first. rewrite /muln_grepr big_ord0. by exists 0 => [||x _]; rewrite /row_free ?mxrank0 ?mulmx0 ?mul0mx. move/eqP=> <-; apply: mx_rsim_socle. exact: rsim_irr_comp_pchar (socle_irr Wi). Qed. End StandardRepr. Definition cfReg (B : {set gT}) : 'CF(B) := #|B|%:R *: '1_[1]. Lemma cfRegE x : @cfReg G x = #|G|%:R *+ (x == 1%g). Proof. by rewrite cfunE cfuniE ?normal1 // inE mulr_natr. Qed. (* This is Isaacs, Lemma (2.10). *) Lemma cfReprReg : cfRepr (regular_repr algC G) = cfReg G. Proof. apply/cfun_inP=> x Gx; rewrite cfRegE. have [-> | ntx] := eqVneq x 1%g; first by rewrite cfRepr1. rewrite cfunE Gx [\tr _]big1 // => i _; rewrite 2!mxE /=. rewrite -(inj_eq enum_val_inj) gring_indexK ?groupM ?enum_valP //. by rewrite eq_mulVg1 mulKg (negbTE ntx). Qed. Definition xcfun (chi : 'CF(G)) A := (gring_row A *m (\col_(i < #|G|) chi (enum_val i))) 0 0. Lemma xcfun_is_zmod_morphism phi : zmod_morphism (xcfun phi). Proof. by move=> A B; rewrite /xcfun [gring_row _]linearB mulmxBl !mxE. Qed. #[warning="-deprecated-since-mathcomp-2.5.0", deprecated(since="mathcomp 2.5.0", note="use `xcfun_is_zmod_morphism` instead")] Definition xcfun_is_additive := xcfun_is_zmod_morphism. HB.instance Definition _ phi := GRing.isZmodMorphism.Build 'M_(gcard G) _ (xcfun phi) (xcfun_is_zmod_morphism phi). Lemma xcfunZr a phi A : xcfun phi (a *: A) = a * xcfun phi A. Proof. by rewrite /xcfun linearZ -scalemxAl mxE. Qed. (* In order to add a second canonical structure on xcfun *) Definition xcfun_r A phi := xcfun phi A. Arguments xcfun_r A phi /. Lemma xcfun_rE A chi : xcfun_r A chi = xcfun chi A. Proof. by []. Qed. Fact xcfun_r_is_zmod_morphism A : zmod_morphism (xcfun_r A). Proof. move=> phi psi; rewrite /= /xcfun !mxE -sumrB; apply: eq_bigr => i _. by rewrite !mxE !cfunE mulrBr. Qed. #[warning="-deprecated-since-mathcomp-2.5.0", deprecated(since="mathcomp 2.5.0", note="use `xcfun_r_is_zmod_morphism` instead")] Definition xcfun_r_is_additive := xcfun_r_is_zmod_morphism. HB.instance Definition _ A := GRing.isZmodMorphism.Build _ _ (xcfun_r A) (xcfun_r_is_zmod_morphism A). Lemma xcfunZl a phi A : xcfun (a *: phi) A = a * xcfun phi A. Proof. rewrite /xcfun !mxE big_distrr; apply: eq_bigr => i _ /=. by rewrite !mxE cfunE mulrCA. Qed. Lemma xcfun_repr n rG A : xcfun (@cfRepr n rG) A = \tr (gring_op rG A). Proof. rewrite gring_opE [gring_row A]row_sum_delta !linear_sum /xcfun !mxE. apply: eq_bigr => i _; rewrite !mxE /= !linearZ cfunE enum_valP /=. by congr (_ * \tr _); rewrite {A}/gring_mx /= -rowE rowK mxvecK. Qed. End Char. Arguments xcfun_r {_ _} A phi /. Notation "phi .[ A ]" := (xcfun phi A) : cfun_scope. Definition pred_Nirr gT B := #|@classes gT B|.-1. Arguments pred_Nirr {gT} B%_g. Notation Nirr G := (pred_Nirr G).+1. Notation Iirr G := 'I_(Nirr G). Section IrrClassDef. Variables (gT : finGroupType) (G : {group gT}). Let sG := DecSocleType (regular_repr algC G). Lemma NirrE : Nirr G = #|classes G|. Proof. by rewrite /pred_Nirr (cardD1 [1]) classes1. Qed. Fact Iirr_cast : Nirr G = #|sG|. Proof. by rewrite NirrE ?card_irr_pchar ?algC'G_pchar //; apply: groupC. Qed. Let offset := cast_ord (esym Iirr_cast) (enum_rank [1 sG]%irr). Definition socle_of_Iirr (i : Iirr G) : sG := enum_val (cast_ord Iirr_cast (i + offset)). Definition irr_of_socle (Wi : sG) : Iirr G := cast_ord (esym Iirr_cast) (enum_rank Wi) - offset. Local Notation W := socle_of_Iirr. Lemma socle_Iirr0 : W 0 = [1 sG]%irr. Proof. by rewrite /W add0r cast_ordKV enum_rankK. Qed. Lemma socle_of_IirrK : cancel W irr_of_socle. Proof. by move=> i; rewrite /irr_of_socle enum_valK cast_ordK addrK. Qed. Lemma irr_of_socleK : cancel irr_of_socle W. Proof. by move=> Wi; rewrite /W subrK cast_ordKV enum_rankK. Qed. Hint Resolve socle_of_IirrK irr_of_socleK : core. Lemma irr_of_socle_bij (A : {pred (Iirr G)}) : {on A, bijective irr_of_socle}. Proof. by apply: onW_bij; exists W. Qed. Lemma socle_of_Iirr_bij (A : {pred sG}) : {on A, bijective W}. Proof. by apply: onW_bij; exists irr_of_socle. Qed. End IrrClassDef. Prenex Implicits socle_of_IirrK irr_of_socleK. Arguments socle_of_Iirr {gT G%_G} i%_R. Notation "''Chi_' i" := (irr_repr (socle_of_Iirr i)) (at level 8, i at level 2, format "''Chi_' i"). HB.lock Definition irr gT B : (Nirr B).-tuple 'CF(B) := let irr_of i := 'Res[B, <<B>>] (@cfRepr gT _ _ 'Chi_(inord i)) in [tuple of mkseq irr_of (Nirr B)]. Arguments irr {gT} B%_g. Notation "''chi_' i" := (tnth (irr _) i%R) (at level 8, i at level 2, format "''chi_' i") : ring_scope. Notation "''chi[' G ]_ i" := (tnth (irr G) i%R) (at level 8, i at level 2, only parsing) : ring_scope. Section IrrClass. Variable (gT : finGroupType) (G : {group gT}). Implicit Types (i : Iirr G) (B : {set gT}). Open Scope group_ring_scope. Lemma congr_irr i1 i2 : i1 = i2 -> 'chi_i1 = 'chi_i2. Proof. by move->. Qed. Lemma Iirr1_neq0 : G :!=: 1%g -> inord 1 != 0 :> Iirr G. Proof. by rewrite -classes_gt1 -NirrE -val_eqE /= => /inordK->. Qed. Lemma has_nonprincipal_irr : G :!=: 1%g -> {i : Iirr G | i != 0}. Proof. by move/Iirr1_neq0; exists (inord 1). Qed. Lemma irrRepr i : cfRepr 'Chi_i = 'chi_i. Proof. rewrite irr.unlock (tnth_nth 0) nth_mkseq // -[<<G>>]/(gval _) genGidG. by rewrite cfRes_id inord_val. Qed. Lemma irr0 : 'chi[G]_0 = 1. Proof. apply/cfun_inP=> x Gx; rewrite -irrRepr cfun1E cfunE Gx. by rewrite socle_Iirr0 irr1_repr // mxtrace1 degree_irr1. Qed. Lemma cfun1_irr : 1 \in irr G. Proof. by rewrite -irr0 mem_tnth. Qed. Lemma mem_irr i : 'chi_i \in irr G. Proof. exact: mem_tnth. Qed. Lemma irrP xi : reflect (exists i, xi = 'chi_i) (xi \in irr G). Proof. apply: (iffP idP) => [/(nthP 0)[i] | [i ->]]; last exact: mem_irr. rewrite size_tuple => lt_i_G <-. by exists (Ordinal lt_i_G); rewrite (tnth_nth 0). Qed. Let sG := DecSocleType (regular_repr algC G). Let C'G := algC'G_pchar G. Let closG := @groupC _ G. Local Notation W i := (@socle_of_Iirr _ G i). Local Notation "''n_' i" := 'n_(W i). Local Notation "''R_' i" := 'R_(W i). Local Notation "''e_' i" := 'e_(W i). Lemma irr1_degree i : 'chi_i 1%g = ('n_i)%:R. Proof. by rewrite -irrRepr cfRepr1. Qed. Lemma Cnat_irr1 i : 'chi_i 1%g \in Num.nat. Proof. by rewrite irr1_degree rpred_nat. Qed. Lemma irr1_gt0 i : 0 < 'chi_i 1%g. Proof. by rewrite irr1_degree ltr0n irr_degree_gt0. Qed. Lemma irr1_neq0 i : 'chi_i 1%g != 0. Proof. by rewrite eq_le lt_geF ?irr1_gt0. Qed. Lemma irr_neq0 i : 'chi_i != 0. Proof. by apply: contraNneq (irr1_neq0 i) => ->; rewrite cfunE. Qed. Local Remark cfIirr_key : unit. Proof. by []. Qed. Definition cfIirr : forall B, 'CF(B) -> Iirr B := locked_with cfIirr_key (fun B chi => inord (index chi (irr B))). Lemma cfIirrE chi : chi \in irr G -> 'chi_(cfIirr chi) = chi. Proof. move=> chi_irr; rewrite (tnth_nth 0) [cfIirr]unlock inordK ?nth_index //. by rewrite -index_mem size_tuple in chi_irr. Qed. Lemma cfIirrPE J (f : J -> 'CF(G)) (P : pred J) : (forall j, P j -> f j \in irr G) -> forall j, P j -> 'chi_(cfIirr (f j)) = f j. Proof. by move=> irr_f j /irr_f; apply: cfIirrE. Qed. (* This is Isaacs, Corollary (2.7). *) Corollary irr_sum_square : \sum_i ('chi[G]_i 1%g) ^+ 2 = #|G|%:R. Proof. rewrite -(sum_irr_degree_pchar sG) // natr_sum. rewrite (reindex _ (socle_of_Iirr_bij _)) /=. by apply: eq_bigr => i _; rewrite irr1_degree natrX. Qed. (* This is Isaacs, Lemma (2.11). *) Lemma cfReg_sum : cfReg G = \sum_i 'chi_i 1%g *: 'chi_i. Proof. apply/cfun_inP=> x Gx. rewrite -cfReprReg cfunE Gx (mxtrace_regular_pchar sG) //=. rewrite sum_cfunE (reindex _ (socle_of_Iirr_bij _)); apply: eq_bigr => i _. by rewrite -irrRepr cfRepr1 !cfunE Gx mulr_natl. Qed. Let aG := regular_repr algC G. Let R_G := group_ring algC G. Lemma xcfun_annihilate i j A : i != j -> (A \in 'R_j)%MS -> ('chi_i).[A]%CF = 0. Proof. move=> neq_ij RjA; rewrite -irrRepr xcfun_repr. rewrite (irr_repr'_op0_pchar _ _ RjA) ?raddf0 //. by rewrite eq_sym (can_eq socle_of_IirrK). Qed. Lemma xcfunG phi x : x \in G -> phi.[aG x]%CF = phi x. Proof. by move=> Gx; rewrite /xcfun /gring_row rowK -rowE !mxE !(gring_indexK, mul1g). Qed. Lemma xcfun_mul_id i A : (A \in R_G)%MS -> ('chi_i).['e_i *m A]%CF = ('chi_i).[A]%CF. Proof. move=> RG_A; rewrite -irrRepr !xcfun_repr gring_opM //. by rewrite op_Wedderburn_id_pchar ?mul1mx. Qed. Lemma xcfun_id i j : ('chi_i).['e_j]%CF = 'chi_i 1%g *+ (i == j). Proof. have [<-{j} | /xcfun_annihilate->//] := eqVneq; last exact: Wedderburn_id_mem. by rewrite -xcfunG // repr_mx1 -(xcfun_mul_id _ (envelop_mx1 _)) mulmx1. Qed. Lemma irr_free : free (irr G). Proof. apply/freeP=> s s0 i; apply: (mulIf (irr1_neq0 i)). rewrite mul0r -(raddf0 (xcfun_r 'e_i)) -{}s0 raddf_sum /=. rewrite (bigD1 i)//= -tnth_nth xcfunZl xcfun_id eqxx big1 ?addr0 // => j ne_ji. by rewrite -tnth_nth xcfunZl xcfun_id (negbTE ne_ji) mulr0. Qed. Lemma irr_inj : injective (tnth (irr G)). Proof. by apply/injectiveP/free_uniq; rewrite map_tnth_enum irr_free. Qed. Lemma irrK : cancel (tnth (irr G)) (@cfIirr G). Proof. by move=> i; apply: irr_inj; rewrite cfIirrE ?mem_irr. Qed. Lemma irr_eq1 i : ('chi_i == 1) = (i == 0). Proof. by rewrite -irr0 (inj_eq irr_inj). Qed. Lemma cforder_irr_eq1 i : (#['chi_i]%CF == 1) = (i == 0). Proof. by rewrite -dvdn1 dvdn_cforder irr_eq1. Qed. Lemma irr_basis : basis_of 'CF(G)%VS (irr G). Proof. rewrite /basis_of irr_free andbT -dimv_leqif_eq ?subvf //. by rewrite dim_cfun (eqnP irr_free) size_tuple NirrE. Qed. Lemma eq_sum_nth_irr a : \sum_i a i *: 'chi[G]_i = \sum_i a i *: (irr G)`_i. Proof. by apply: eq_bigr => i; rewrite -tnth_nth. Qed. (* This is Isaacs, Theorem (2.8). *) Theorem cfun_irr_sum phi : {a | phi = \sum_i a i *: 'chi[G]_i}. Proof. rewrite (coord_basis irr_basis (memvf phi)) -eq_sum_nth_irr. by exists ((coord (irr G))^~ phi). Qed. Lemma cfRepr_standard n (rG : mx_representation algC G n) : cfRepr (standard_grepr rG) = \sum_i (standard_irr_coef rG (W i))%:R *: 'chi_i. Proof. rewrite cfRepr_dsum (reindex _ (socle_of_Iirr_bij _)). by apply: eq_bigr => i _; rewrite scaler_nat cfRepr_muln irrRepr. Qed. Lemma cfRepr_inj n1 n2 rG1 rG2 : @cfRepr _ G n1 rG1 = @cfRepr _ G n2 rG2 -> mx_rsim rG1 rG2. Proof. move=> eq_repr12; pose c i : algC := (standard_irr_coef _ (W i))%:R. have [rsim1 rsim2] := (mx_rsim_standard rG1, mx_rsim_standard rG2). apply: mx_rsim_trans (rsim1) (mx_rsim_sym _). suffices ->: standard_grepr rG1 = standard_grepr rG2 by []. apply: eq_bigr => Wi _; congr (muln_grepr _ _); apply/eqP; rewrite -eqC_nat. rewrite -[Wi]irr_of_socleK -!/(c _ _ _) -!(coord_sum_free (c _ _) _ irr_free). rewrite -!eq_sum_nth_irr -!cfRepr_standard. by rewrite -(cfRepr_sim rsim1) -(cfRepr_sim rsim2) eq_repr12. Qed. Lemma cfRepr_rsimP n1 n2 rG1 rG2 : reflect (mx_rsim rG1 rG2) (@cfRepr _ G n1 rG1 == @cfRepr _ G n2 rG2). Proof. by apply: (iffP eqP) => [/cfRepr_inj | /cfRepr_sim]. Qed. Lemma irr_reprP xi : reflect (exists2 rG : representation _ G, mx_irreducible rG & xi = cfRepr rG) (xi \in irr G). Proof. apply: (iffP (irrP xi)) => [[i ->] | [[n rG] irr_rG ->]]. by exists (Representation 'Chi_i); [apply: socle_irr | rewrite irrRepr]. exists (irr_of_socle (irr_comp sG rG)); rewrite -irrRepr irr_of_socleK /=. exact/cfRepr_sim/rsim_irr_comp_pchar. Qed. (* This is Isaacs, Theorem (2.12). *) Lemma Wedderburn_id_expansion i : 'e_i = #|G|%:R^-1 *: (\sum_(x in G) 'chi_i 1%g * 'chi_i x^-1%g *: aG x). Proof. have Rei: ('e_i \in 'R_i)%MS by apply: Wedderburn_id_mem. have /envelop_mxP[a def_e]: ('e_i \in R_G)%MS; last rewrite -/aG in def_e. by move: Rei; rewrite genmxE mem_sub_gring => /andP[]. apply: canRL (scalerK (neq0CG _)) _; rewrite def_e linear_sum /=. apply: eq_bigr => x Gx; have Gx' := groupVr Gx; rewrite scalerA; congr (_ *: _). transitivity (cfReg G).['e_i *m aG x^-1%g]%CF. rewrite def_e mulmx_suml raddf_sum (bigD1 x) //= -scalemxAl xcfunZr. rewrite -repr_mxM // mulgV xcfunG // cfRegE eqxx mulrC big1 ?addr0 //. move=> y /andP[Gy /negbTE neq_xy]; rewrite -scalemxAl xcfunZr -repr_mxM //. by rewrite xcfunG ?groupM // cfRegE -eq_mulgV1 neq_xy mulr0. rewrite cfReg_sum -xcfun_rE raddf_sum /= (bigD1 i) //= xcfunZl. rewrite xcfun_mul_id ?envelop_mx_id ?xcfunG ?groupV ?big1 ?addr0 // => j ne_ji. rewrite xcfunZl (xcfun_annihilate ne_ji) ?mulr0 //. have /andP[_ /(submx_trans _)-> //] := Wedderburn_ideal (W i). by rewrite mem_mulsmx // envelop_mx_id ?groupV. Qed. End IrrClass. Arguments cfReg {gT} B%_g. Prenex Implicits cfIirr irrK. Arguments irrP {gT G xi}. Arguments irr_reprP {gT G xi}. Arguments irr_inj {gT G} [x1 x2]. Section IsChar. Variable gT : finGroupType. Definition character_pred {G : {set gT}} := fun phi : 'CF(G) => [forall i, coord (irr G) i phi \in Num.nat]. Arguments character_pred _ _ /. Definition character {G : {set gT}} := [qualify a phi | @character_pred G phi]. Variable G : {group gT}. Implicit Types (phi chi xi : 'CF(G)) (i : Iirr G). Lemma irr_char i : 'chi_i \is a character. Proof. by apply/forallP=> j; rewrite (tnth_nth 0) coord_free ?irr_free. Qed. Lemma cfun1_char : (1 : 'CF(G)) \is a character. Proof. by rewrite -irr0 irr_char. Qed. Lemma cfun0_char : (0 : 'CF(G)) \is a character. Proof. by apply/forallP=> i; rewrite linear0 rpred0. Qed. Fact add_char : addr_closed (@character G). Proof. split=> [|chi xi /forallP-Nchi /forallP-Nxi]; first exact: cfun0_char. by apply/forallP=> i; rewrite linearD rpredD /=. Qed. HB.instance Definition _ := GRing.isAddClosed.Build (classfun G) character_pred add_char. Lemma char_sum_irrP {phi} : reflect (exists n, phi = \sum_i (n i)%:R *: 'chi_i) (phi \is a character). Proof. apply: (iffP idP)=> [/forallP-Nphi | [n ->]]; last first. by apply: rpred_sum => i _; rewrite scaler_nat rpredMn // irr_char. do [have [a ->] := cfun_irr_sum phi] in Nphi *; exists (Num.truncn \o a). apply: eq_bigr => i _; congr (_ *: _); have:= eqP (Nphi i). by rewrite eq_sum_nth_irr coord_sum_free ?irr_free. Qed. Lemma char_sum_irr chi : chi \is a character -> {r | chi = \sum_(i <- r) 'chi_i}. Proof. move=> Nchi; apply: sig_eqW; case/char_sum_irrP: Nchi => n {chi}->. elim/big_rec: _ => [|i _ _ [r ->]]; first by exists nil; rewrite big_nil. exists (ncons (n i) i r); rewrite scaler_nat. by elim: {n}(n i) => [|n IHn]; rewrite ?add0r //= big_cons mulrS -addrA IHn. Qed. Lemma Cnat_char1 chi : chi \is a character -> chi 1%g \in Num.nat. Proof. case/char_sum_irr=> r ->{chi}. by elim/big_rec: _ => [|i chi _ Nchi1]; rewrite cfunE ?rpredD // Cnat_irr1. Qed. Lemma char1_ge0 chi : chi \is a character -> 0 <= chi 1%g. Proof. by move/Cnat_char1/natr_ge0. Qed. Lemma char1_eq0 chi : chi \is a character -> (chi 1%g == 0) = (chi == 0). Proof. case/char_sum_irr=> r ->; apply/idP/idP=> [|/eqP->]; last by rewrite cfunE. case: r => [|i r]; rewrite ?big_nil // sum_cfunE big_cons. rewrite paddr_eq0 ?sumr_ge0 => // [||j _]; rewrite 1?ltW ?irr1_gt0 //. by rewrite (negbTE (irr1_neq0 i)). Qed. Lemma char1_gt0 chi : chi \is a character -> (0 < chi 1%g) = (chi != 0). Proof. by move=> Nchi; rewrite -char1_eq0 // natr_gt0 ?Cnat_char1. Qed. Lemma char_reprP phi : reflect (exists rG : representation algC G, phi = cfRepr rG) (phi \is a character). Proof. apply: (iffP char_sum_irrP) => [[n ->] | [[n rG] ->]]; last first. exists (fun i => standard_irr_coef rG (socle_of_Iirr i)). by rewrite -cfRepr_standard (cfRepr_sim (mx_rsim_standard rG)). exists (\big[dadd_grepr/grepr0]_i muln_grepr (Representation 'Chi_i) (n i)). rewrite cfRepr_dsum; apply: eq_bigr => i _. by rewrite cfRepr_muln irrRepr scaler_nat. Qed. Local Notation reprG := (mx_representation algC G). Lemma cfRepr_char n (rG : reprG n) : cfRepr rG \is a character. Proof. by apply/char_reprP; exists (Representation rG). Qed. Lemma cfReg_char : cfReg G \is a character. Proof. by rewrite -cfReprReg cfRepr_char. Qed. Lemma cfRepr_prod n1 n2 (rG1 : reprG n1) (rG2 : reprG n2) : cfRepr rG1 * cfRepr rG2 = cfRepr (prod_repr rG1 rG2). Proof. by apply/cfun_inP=> x Gx; rewrite !cfunE /= Gx mxtrace_prod. Qed. Lemma mul_char : mulr_closed (@character G). Proof. split=> [|_ _ /char_reprP[rG1 ->] /char_reprP[rG2 ->]]; first exact: cfun1_char. apply/char_reprP; exists (Representation (prod_repr rG1 rG2)). by rewrite cfRepr_prod. Qed. HB.instance Definition _ := GRing.isMulClosed.Build (classfun G) character_pred mul_char. End IsChar. Prenex Implicits character. Arguments character_pred _ _ _ /. Arguments char_reprP {gT G phi}. Section AutChar. Variables (gT : finGroupType) (G : {group gT}). Implicit Type u : {rmorphism algC -> algC}. Implicit Type chi : 'CF(G). Lemma cfRepr_map u n (rG : mx_representation algC G n) : cfRepr (map_repr u rG) = cfAut u (cfRepr rG). Proof. by apply/cfun_inP=> x Gx; rewrite !cfunE Gx map_reprE trace_map_mx. Qed. Lemma cfAut_char u chi : (cfAut u chi \is a character) = (chi \is a character). Proof. without loss /char_reprP[rG ->]: u chi / chi \is a character. by move=> IHu; apply/idP/idP=> ?; first rewrite -(cfAutK u chi); rewrite IHu. rewrite cfRepr_char; apply/char_reprP. by exists (Representation (map_repr u rG)); rewrite cfRepr_map. Qed. Lemma cfConjC_char chi : (chi^*%CF \is a character) = (chi \is a character). Proof. exact: cfAut_char. Qed. Lemma cfAut_char1 u (chi : 'CF(G)) : chi \is a character -> cfAut u chi 1%g = chi 1%g. Proof. by move/Cnat_char1=> Nchi1; rewrite cfunE /= aut_natr. Qed. Lemma cfAut_irr1 u i : (cfAut u 'chi[G]_i) 1%g = 'chi_i 1%g. Proof. exact: cfAut_char1 (irr_char i). Qed. Lemma cfConjC_char1 (chi : 'CF(G)) : chi \is a character -> chi^*%CF 1%g = chi 1%g. Proof. exact: cfAut_char1. Qed. Lemma cfConjC_irr1 u i : ('chi[G]_i)^*%CF 1%g = 'chi_i 1%g. Proof. exact: cfAut_irr1. Qed. End AutChar. Section Linear. Variables (gT : finGroupType) (G : {group gT}). Definition linear_char_pred {B : {set gT}} := fun phi : 'CF(B) => (phi \is a character) && (phi 1%g == 1). Arguments linear_char_pred _ _ /. Definition linear_char {B : {set gT}} := [qualify a phi | @linear_char_pred B phi]. Section OneChar. Variable xi : 'CF(G). Hypothesis CFxi : xi \is a linear_char. Lemma lin_char1: xi 1%g = 1. Proof. by case/andP: CFxi => _ /eqP. Qed. Lemma lin_charW : xi \is a character. Proof. by case/andP: CFxi. Qed. Lemma cfun1_lin_char : (1 : 'CF(G)) \is a linear_char. Proof. by rewrite qualifE/= cfun1_char /= cfun11. Qed. Lemma lin_charM : {in G &, {morph xi : x y / (x * y)%g >-> x * y}}. Proof. move=> x y Gx Gy; case/andP: CFxi => /char_reprP[[n rG] -> /=]. rewrite cfRepr1 pnatr_eq1 => /eqP n1; rewrite {n}n1 in rG *. rewrite !cfunE Gx Gy groupM //= !mulr1n repr_mxM //. by rewrite [rG x]mx11_scalar [rG y]mx11_scalar -scalar_mxM !mxtrace_scalar. Qed. Lemma lin_char_prod I r (P : pred I) (x : I -> gT) : (forall i, P i -> x i \in G) -> xi (\prod_(i <- r | P i) x i)%g = \prod_(i <- r | P i) xi (x i). Proof. move=> Gx; elim/(big_load (fun y => y \in G)): _. elim/big_rec2: _ => [|i a y Pi [Gy <-]]; first by rewrite lin_char1. by rewrite groupM ?lin_charM ?Gx. Qed. Let xiMV x : x \in G -> xi x * xi (x^-1)%g = 1. Proof. by move=> Gx; rewrite -lin_charM ?groupV // mulgV lin_char1. Qed. Lemma lin_char_neq0 x : x \in G -> xi x != 0. Proof. by move/xiMV/(congr1 (predC1 0)); rewrite /= oner_eq0 mulf_eq0 => /norP[]. Qed. Lemma lin_charV x : x \in G -> xi x^-1%g = (xi x)^-1. Proof. by move=> Gx; rewrite -[_^-1]mulr1 -(xiMV Gx) mulKf ?lin_char_neq0. Qed. Lemma lin_charX x n : x \in G -> xi (x ^+ n)%g = xi x ^+ n. Proof. move=> Gx; elim: n => [|n IHn]; first exact: lin_char1. by rewrite expgS exprS lin_charM ?groupX ?IHn. Qed. Lemma lin_char_unity_root x : x \in G -> xi x ^+ #[x] = 1. Proof. by move=> Gx; rewrite -lin_charX // expg_order lin_char1. Qed. Lemma normC_lin_char x : x \in G -> `|xi x| = 1. Proof. move=> Gx; apply/eqP; rewrite -(@pexpr_eq1 _ _ #[x]) //. by rewrite -normrX // lin_char_unity_root ?normr1. Qed. Lemma lin_charV_conj x : x \in G -> xi x^-1%g = (xi x)^*. Proof. move=> Gx; rewrite lin_charV // invC_norm mulrC normC_lin_char //. by rewrite expr1n divr1. Qed. Lemma lin_char_irr : xi \in irr G. Proof. case/andP: CFxi => /char_reprP[rG ->]; rewrite cfRepr1 pnatr_eq1 => /eqP n1. by apply/irr_reprP; exists rG => //; apply/mx_abs_irrW/linear_mx_abs_irr. Qed. Lemma mul_conjC_lin_char : xi * xi^*%CF = 1. Proof. apply/cfun_inP=> x Gx. by rewrite !cfunE cfun1E Gx -normCK normC_lin_char ?expr1n. Qed. Lemma lin_char_unitr : xi \in GRing.unit. Proof. by apply/unitrPr; exists xi^*%CF; apply: mul_conjC_lin_char. Qed. Lemma invr_lin_char : xi^-1 = xi^*%CF. Proof. by rewrite -[_^-1]mulr1 -mul_conjC_lin_char mulKr ?lin_char_unitr. Qed. Lemma fful_lin_char_inj : cfaithful xi -> {in G &, injective xi}. Proof. move=> fful_phi x y Gx Gy xi_xy; apply/eqP; rewrite eq_mulgV1 -in_set1. rewrite (subsetP fful_phi) // inE groupM ?groupV //=; apply/forallP=> z. have [Gz | G'z] := boolP (z \in G); last by rewrite !cfun0 ?groupMl ?groupV. by rewrite -mulgA lin_charM ?xi_xy -?lin_charM ?groupM ?groupV // mulKVg. Qed. End OneChar. Lemma cfAut_lin_char u (xi : 'CF(G)) : (cfAut u xi \is a linear_char) = (xi \is a linear_char). Proof. by rewrite qualifE/= cfAut_char; apply/andb_id2l=> /cfAut_char1->. Qed. Lemma cfConjC_lin_char (xi : 'CF(G)) : (xi^*%CF \is a linear_char) = (xi \is a linear_char). Proof. exact: cfAut_lin_char. Qed. Lemma card_Iirr_abelian : abelian G -> #|Iirr G| = #|G|. Proof. by rewrite card_ord NirrE card_classes_abelian => /eqP. Qed. Lemma card_Iirr_cyclic : cyclic G -> #|Iirr G| = #|G|. Proof. by move/cyclic_abelian/card_Iirr_abelian. Qed. Lemma char_abelianP : reflect (forall i : Iirr G, 'chi_i \is a linear_char) (abelian G). Proof. apply: (iffP idP) => [cGG i | CF_G]. rewrite qualifE/= irr_char /= irr1_degree. by rewrite irr_degree_abelian //; last apply: groupC. rewrite card_classes_abelian -NirrE -eqC_nat -irr_sum_square //. rewrite -{1}[Nirr G]card_ord -sumr_const; apply/eqP/eq_bigr=> i _. by rewrite lin_char1 ?expr1n ?CF_G. Qed. Lemma irr_repr_lin_char (i : Iirr G) x : x \in G -> 'chi_i \is a linear_char -> irr_repr (socle_of_Iirr i) x = ('chi_i x)%:M. Proof. move=> Gx CFi; rewrite -irrRepr cfunE Gx. move: (_ x); rewrite -[irr_degree _](@natrK algC) -irr1_degree lin_char1 //. by rewrite (natrK 1) => A; rewrite trace_mx11 -mx11_scalar. Qed. Fact linear_char_divr : divr_closed (@linear_char G). Proof. split=> [|chi xi Lchi Lxi]; first exact: cfun1_lin_char. rewrite invr_lin_char // qualifE/= cfunE. by rewrite rpredM ?lin_char1 ?mulr1 ?lin_charW //= cfConjC_lin_char. Qed. HB.instance Definition _ := GRing.isDivClosed.Build (classfun G) linear_char_pred linear_char_divr. Lemma irr_cyclic_lin i : cyclic G -> 'chi[G]_i \is a linear_char. Proof. by move/cyclic_abelian/char_abelianP. Qed. Lemma irr_prime_lin i : prime #|G| -> 'chi[G]_i \is a linear_char. Proof. by move/prime_cyclic/irr_cyclic_lin. Qed. End Linear. Prenex Implicits linear_char. Arguments linear_char_pred _ _ _ /. Section OrthogonalityRelations. Variables aT gT : finGroupType. (* This is Isaacs, Lemma (2.15) *) Lemma repr_rsim_diag (G : {group gT}) f (rG : mx_representation algC G f) x : x \in G -> let chi := cfRepr rG in exists e, [/\ (*a*) exists2 B, B \in unitmx & rG x = invmx B *m diag_mx e *m B, (*b*) (forall i, e 0 i ^+ #[x] = 1) /\ (forall i, `|e 0 i| = 1), (*c*) chi x = \sum_i e 0 i /\ `|chi x| <= chi 1%g & (*d*) chi x^-1%g = (chi x)^*]. Proof. move=> Gx; without loss cGG: G rG Gx / abelian G. have sXG: <[x]> \subset G by rewrite cycle_subG. move/(_ _ (subg_repr rG sXG) (cycle_id x) (cycle_abelian x)). by rewrite /= !cfunE !groupV Gx (cycle_id x) !group1. have [I U W simU W1 dxW]: mxsemisimple rG 1%:M. rewrite -(reducible_Socle1 (DecSocleType rG) (mx_Maschke_pchar _ (algC'G_pchar G))). exact: Socle_semisimple. have linU i: \rank (U i) = 1. by apply: mxsimple_abelian_linear cGG (simU i); apply: groupC. have castI: f = #|I|. by rewrite -(mxrank1 algC f) -W1 (eqnP dxW) /= -sum1_card; apply/eq_bigr. pose B := \matrix_j nz_row (U (enum_val (cast_ord castI j))). have rowU i: (nz_row (U i) :=: U i)%MS. apply/eqmxP; rewrite -(geq_leqif (mxrank_leqif_eq (nz_row_sub _))) linU. by rewrite lt0n mxrank_eq0 (nz_row_mxsimple (simU i)). have unitB: B \in unitmx. rewrite -row_full_unit -sub1mx -W1; apply/sumsmx_subP=> i _. pose j := cast_ord (esym castI) (enum_rank i). by rewrite (submx_trans _ (row_sub j B)) // rowK cast_ordKV enum_rankK rowU. pose e := \row_j row j (B *m rG x *m invmx B) 0 j. have rGx: rG x = invmx B *m diag_mx e *m B. rewrite -mulmxA; apply: canRL (mulKmx unitB) _. apply/row_matrixP=> j; rewrite 2!row_mul; set u := row j B. have /sub_rVP[a def_ux]: (u *m rG x <= u)%MS. rewrite /u rowK rowU (eqmxMr _ (rowU _)). exact: (mxmoduleP (mxsimple_module (simU _))). rewrite def_ux [u]rowE scalemxAl; congr (_ *m _). apply/rowP=> k; rewrite 5!mxE !row_mul def_ux [u]rowE scalemxAl mulmxK //. by rewrite !mxE !eqxx !mulr_natr eq_sym. have exp_e j: e 0 j ^+ #[x] = 1. suffices: (diag_mx e j j) ^+ #[x] = (B *m rG (x ^+ #[x])%g *m invmx B) j j. by rewrite expg_order repr_mx1 mulmx1 mulmxV // [e]lock !mxE eqxx. elim: #[x] => [|n IHn]; first by rewrite repr_mx1 mulmx1 mulmxV // !mxE eqxx. rewrite expgS repr_mxM ?groupX // {1}rGx -!mulmxA mulKVmx //. by rewrite mul_diag_mx mulmxA [M in _ = M]mxE -IHn exprS {1}mxE eqxx. have norm1_e j: `|e 0 j| = 1. by apply/eqP; rewrite -(@pexpr_eq1 _ _ #[x]) // -normrX exp_e normr1. exists e; split=> //; first by exists B. rewrite cfRepr1 !cfunE Gx rGx mxtrace_mulC mulKVmx // mxtrace_diag. split=> //=; apply: (le_trans (ler_norm_sum _ _ _)). by rewrite (eq_bigr _ (in1W norm1_e)) sumr_const card_ord lexx. rewrite !cfunE groupV !mulrb Gx rGx mxtrace_mulC mulKVmx //. rewrite -trace_map_mx map_diag_mx; set d' := diag_mx _. rewrite -[d'](mulKVmx unitB) mxtrace_mulC -[_ *m _](repr_mxK rG Gx) rGx. rewrite -!mulmxA mulKVmx // (mulmxA d'). suffices->: d' *m diag_mx e = 1%:M by rewrite mul1mx mulKmx. rewrite mulmx_diag -diag_const_mx; congr diag_mx; apply/rowP=> j. by rewrite [e]lock !mxE mulrC -normCK -lock norm1_e expr1n. Qed. Variables (A : {group aT}) (G : {group gT}). (* This is Isaacs, Lemma (2.15) (d). *) Lemma char_inv (chi : 'CF(G)) x : chi \is a character -> chi x^-1%g = (chi x)^*. Proof. case Gx: (x \in G); last by rewrite !cfun0 ?rmorph0 ?groupV ?Gx. by case/char_reprP=> rG ->; have [e [_ _ _]] := repr_rsim_diag rG Gx. Qed. Lemma irr_inv i x : 'chi[G]_i x^-1%g = ('chi_i x)^*. Proof. exact/char_inv/irr_char. Qed. (* This is Isaacs, Theorem (2.13). *) Theorem generalized_orthogonality_relation y (i j : Iirr G) : #|G|%:R^-1 * (\sum_(x in G) 'chi_i (x * y)%g * 'chi_j x^-1%g) = (i == j)%:R * ('chi_i y / 'chi_i 1%g). Proof. pose W := @socle_of_Iirr _ G; pose e k := Wedderburn_id (W k). pose aG := regular_repr algC G. have [Gy | notGy] := boolP (y \in G); last first. rewrite cfun0 // mul0r big1 ?mulr0 // => x Gx. by rewrite cfun0 ?groupMl ?mul0r. transitivity (('chi_i).[e j *m aG y]%CF / 'chi_j 1%g). rewrite [e j]Wedderburn_id_expansion -scalemxAl xcfunZr -mulrA; congr (_ * _). rewrite mulmx_suml raddf_sum big_distrl; apply: eq_bigr => x Gx /=. rewrite -scalemxAl xcfunZr -repr_mxM // xcfunG ?groupM // mulrAC mulrC. by congr (_ * _); rewrite mulrC mulKf ?irr1_neq0. rewrite mulr_natl mulrb; have [<-{j} | neq_ij] := eqVneq. by congr (_ / _); rewrite xcfun_mul_id ?envelop_mx_id ?xcfunG. rewrite (xcfun_annihilate neq_ij) ?mul0r //. case/andP: (Wedderburn_ideal (W j)) => _; apply: submx_trans. by rewrite mem_mulsmx ?Wedderburn_id_mem ?envelop_mx_id. Qed. (* This is Isaacs, Corollary (2.14). *) Corollary first_orthogonality_relation (i j : Iirr G) : #|G|%:R^-1 * (\sum_(x in G) 'chi_i x * 'chi_j x^-1%g) = (i == j)%:R. Proof. have:= generalized_orthogonality_relation 1 i j. rewrite mulrA mulfK ?irr1_neq0 // => <-; congr (_ * _). by apply: eq_bigr => x; rewrite mulg1. Qed. (* The character table. *) Definition irr_class i := enum_val (cast_ord (NirrE G) i). Definition class_Iirr xG := cast_ord (esym (NirrE G)) (enum_rank_in (classes1 G) xG). Local Notation c := irr_class. Local Notation g i := (repr (c i)). Local Notation iC := class_Iirr. Definition character_table := \matrix_(i, j) 'chi[G]_i (g j). Local Notation X := character_table. Lemma irr_classP i : c i \in classes G. Proof. exact: enum_valP. Qed. Lemma repr_irr_classK i : g i ^: G = c i. Proof. by case/repr_classesP: (irr_classP i). Qed. Lemma irr_classK : cancel c iC. Proof. by move=> i; rewrite /iC enum_valK_in cast_ordK. Qed. Lemma class_IirrK : {in classes G, cancel iC c}. Proof. by move=> xG GxG; rewrite /c cast_ordKV enum_rankK_in. Qed. Lemma reindex_irr_class R idx (op : @Monoid.com_law R idx) F : \big[op/idx]_(xG in classes G) F xG = \big[op/idx]_i F (c i). Proof. rewrite (reindex c); first by apply: eq_bigl => i; apply: enum_valP. by exists iC; [apply: in1W; apply: irr_classK | apply: class_IirrK]. Qed. (* The explicit value of the inverse is needed for the proof of the second *) (* orthogonality relation. *) Let X' := \matrix_(i, j) (#|'C_G[g i]|%:R^-1 * ('chi[G]_j (g i))^*). Let XX'_1: X *m X' = 1%:M. Proof. apply/matrixP=> i j; rewrite !mxE -first_orthogonality_relation mulr_sumr. rewrite sum_by_classes => [|u v Gu Gv]; last by rewrite -conjVg !cfunJ. rewrite reindex_irr_class /=; apply/esym/eq_bigr=> k _. rewrite !mxE irr_inv // -/(g k) -divg_index -indexgI /=. rewrite (pchar0_natf_div Cpchar) ?dvdn_indexg // index_cent1 invfM invrK. by rewrite repr_irr_classK mulrCA mulrA mulrCA. Qed. Lemma character_table_unit : X \in unitmx. Proof. by case/mulmx1_unit: XX'_1. Qed. Let uX := character_table_unit. (* This is Isaacs, Theorem (2.18). *) Theorem second_orthogonality_relation x y : y \in G -> \sum_i 'chi[G]_i x * ('chi_i y)^* = #|'C_G[x]|%:R *+ (x \in y ^: G). Proof. move=> Gy; pose i_x := iC (x ^: G); pose i_y := iC (y ^: G). have [Gx | notGx] := boolP (x \in G); last first. rewrite (contraNF (subsetP _ x) notGx) ?class_subG ?big1 // => i _. by rewrite cfun0 ?mul0r. transitivity ((#|'C_G[repr (y ^: G)]|%:R *: (X' *m X)) i_y i_x). rewrite scalemxAl !mxE; apply: eq_bigr => k _; rewrite !mxE mulrC -!mulrA. by rewrite !class_IirrK ?mem_classes // !cfun_repr mulVKf ?neq0CG. rewrite mulmx1C // !mxE -!divg_index; do 2!rewrite -indexgI index_cent1. rewrite (class_eqP (mem_repr y _)) ?class_refl // mulr_natr. rewrite (can_in_eq class_IirrK) ?mem_classes //. have [-> | not_yGx] := eqVneq; first by rewrite class_refl. by rewrite [x \in _](contraNF _ not_yGx) // => /class_eqP->. Qed. Lemma eq_irr_mem_classP x y : y \in G -> reflect (forall i, 'chi[G]_i x = 'chi_i y) (x \in y ^: G). Proof. move=> Gy; apply: (iffP idP) => [/imsetP[z Gz ->] i | xGy]; first exact: cfunJ. have Gx: x \in G. congr is_true: Gy; apply/eqP; rewrite -(can_eq oddb) -eqC_nat -!cfun1E. by rewrite -irr0 xGy. congr is_true: (class_refl G x); apply/eqP; rewrite -(can_eq oddb). rewrite -(eqn_pmul2l (cardG_gt0 'C_G[x])) -eqC_nat !mulrnA; apply/eqP. by rewrite -!second_orthogonality_relation //; apply/eq_bigr=> i _; rewrite xGy. Qed. (* This is Isaacs, Theorem (6.32) (due to Brauer). *) Lemma card_afix_irr_classes (ito : action A (Iirr G)) (cto : action A _) a : a \in A -> [acts A, on classes G | cto] -> (forall i x y, x \in G -> y \in cto (x ^: G) a -> 'chi_i x = 'chi_(ito i a) y) -> #|'Fix_ito[a]| = #|'Fix_(classes G | cto)[a]|. Proof. move=> Aa actsAG stabAchi; apply/eqP; rewrite -eqC_nat; apply/eqP. have [[cP cK] iCK] := (irr_classP, irr_classK, class_IirrK). pose icto b i := iC (cto (c i) b). have Gca i: cto (c i) a \in classes G by rewrite (acts_act actsAG). have inj_qa: injective (icto a). by apply: can_inj (icto a^-1%g) _ => i; rewrite /icto iCK ?actKin ?cK. pose Pa : 'M[algC]_(Nirr G) := perm_mx (actperm ito a). pose qa := perm inj_qa; pose Qa : 'M[algC]_(Nirr G) := perm_mx qa^-1^-1%g. transitivity (\tr Pa). rewrite -sumr_const big_mkcond; apply: eq_bigr => i _. by rewrite !mxE permE inE sub1set inE; case: ifP. symmetry; transitivity (\tr Qa). rewrite cardsE -sumr_const -big_filter_cond big_mkcond big_filter /=. rewrite reindex_irr_class; apply: eq_bigr => i _; rewrite !mxE invgK permE. by rewrite inE sub1set inE -(can_eq cK) iCK //; case: ifP. rewrite -[Pa](mulmxK uX) -[Qa](mulKmx uX) mxtrace_mulC; congr (\tr(_ *m _)). rewrite -row_permE -col_permE; apply/matrixP=> i j; rewrite !mxE. rewrite -{2}[j](permKV qa); move: {j}(_ j) => j; rewrite !permE iCK //. apply: stabAchi; first by case/repr_classesP: (cP j). by rewrite repr_irr_classK (mem_repr_classes (Gca _)). Qed. End OrthogonalityRelations. Prenex Implicits irr_class class_Iirr irr_classK. Arguments class_IirrK {gT G%_G} [xG%_g] GxG : rename. Arguments character_table {gT} G%_g. Section InnerProduct. Variable (gT : finGroupType) (G : {group gT}). Lemma cfdot_irr i j : '['chi_i, 'chi_j]_G = (i == j)%:R. Proof. rewrite -first_orthogonality_relation; congr (_ * _). by apply: eq_bigr => x Gx; rewrite irr_inv. Qed. Lemma cfnorm_irr i : '['chi[G]_i] = 1. Proof. by rewrite cfdot_irr eqxx. Qed. Lemma irr_orthonormal : orthonormal (irr G). Proof. apply/orthonormalP; split; first exact: free_uniq (irr_free G). move=> _ _ /irrP[i ->] /irrP[j ->]. by rewrite cfdot_irr (inj_eq irr_inj). Qed. Lemma coord_cfdot phi i : coord (irr G) i phi = '[phi, 'chi_i]. Proof. rewrite {2}(coord_basis (irr_basis G) (memvf phi)). rewrite cfdot_suml (bigD1 i) // cfdotZl /= -tnth_nth cfdot_irr eqxx mulr1. rewrite big1 ?addr0 // => j neq_ji; rewrite cfdotZl /= -tnth_nth cfdot_irr. by rewrite (negbTE neq_ji) mulr0. Qed. Lemma cfun_sum_cfdot phi : phi = \sum_i '[phi, 'chi_i]_G *: 'chi_i. Proof. rewrite {1}(coord_basis (irr_basis G) (memvf phi)). by apply: eq_bigr => i _; rewrite coord_cfdot -tnth_nth. Qed. Lemma cfdot_sum_irr phi psi : '[phi, psi]_G = \sum_i '[phi, 'chi_i] * '[psi, 'chi_i]^*. Proof. rewrite {1}[phi]cfun_sum_cfdot cfdot_suml; apply: eq_bigr => i _. by rewrite cfdotZl -cfdotC. Qed. Lemma Cnat_cfdot_char_irr i phi : phi \is a character -> '[phi, 'chi_i]_G \in Num.nat. Proof. by move/forallP/(_ i); rewrite coord_cfdot. Qed. Lemma cfdot_char_r phi chi : chi \is a character -> '[phi, chi]_G = \sum_i '[phi, 'chi_i] * '[chi, 'chi_i]. Proof. move=> Nchi; rewrite cfdot_sum_irr; apply: eq_bigr => i _; congr (_ * _). by rewrite conj_natr ?Cnat_cfdot_char_irr. Qed. Lemma Cnat_cfdot_char chi xi : chi \is a character -> xi \is a character -> '[chi, xi]_G \in Num.nat. Proof. move=> Nchi Nxi; rewrite cfdot_char_r ?rpred_sum // => i _. by rewrite rpredM ?Cnat_cfdot_char_irr. Qed. Lemma cfdotC_char chi xi : chi \is a character-> xi \is a character -> '[chi, xi]_G = '[xi, chi]. Proof. by move=> Nchi Nxi; rewrite cfdotC conj_natr ?Cnat_cfdot_char. Qed. Lemma irrEchar chi : (chi \in irr G) = (chi \is a character) && ('[chi] == 1). Proof. apply/irrP/andP=> [[i ->] | [Nchi]]; first by rewrite irr_char cfnorm_irr. rewrite cfdot_sum_irr => /eqP/natr_sum_eq1[i _| i [_ ci1 cj0]]. by rewrite rpredM // ?conj_natr ?Cnat_cfdot_char_irr. exists i; rewrite [chi]cfun_sum_cfdot (bigD1 i) //=. rewrite -(normr_idP (natr_ge0 (Cnat_cfdot_char_irr i Nchi))). rewrite normC_def {}ci1 sqrtC1 scale1r big1 ?addr0 // => j neq_ji. by rewrite (('[_] =P 0) _) ?scale0r // -normr_eq0 normC_def cj0 ?sqrtC0. Qed. Lemma irrWchar chi : chi \in irr G -> chi \is a character. Proof. by rewrite irrEchar => /andP[]. Qed. Lemma irrWnorm chi : chi \in irr G -> '[chi] = 1. Proof. by rewrite irrEchar => /andP[_ /eqP]. Qed. Lemma mul_lin_irr xi chi : xi \is a linear_char -> chi \in irr G -> xi * chi \in irr G. Proof. move=> Lxi; rewrite !irrEchar => /andP[Nphi /eqP <-]. rewrite rpredM // ?lin_charW //=; apply/eqP; congr (_ * _). apply: eq_bigr=> x Gx; rewrite !cfunE rmorphM/= mulrACA -(lin_charV_conj Lxi)//. by rewrite -lin_charM ?groupV // mulgV lin_char1 ?mul1r. Qed. Lemma eq_scaled_irr a b i j : (a *: 'chi[G]_i == b *: 'chi_j) = (a == b) && ((a == 0) || (i == j)). Proof. apply/eqP/andP=> [|[/eqP-> /pred2P[]-> //]]; last by rewrite !scale0r. move/(congr1 (cfdotr 'chi__)) => /= eq_ai_bj. move: {eq_ai_bj}(eq_ai_bj i) (esym (eq_ai_bj j)); rewrite !cfdotZl !cfdot_irr. by rewrite !mulr_natr !mulrb !eqxx eq_sym orbC; case: ifP => _ -> //= ->. Qed. Lemma eq_signed_irr (s t : bool) i j : ((-1) ^+ s *: 'chi[G]_i == (-1) ^+ t *: 'chi_j) = (s == t) && (i == j). Proof. by rewrite eq_scaled_irr signr_eq0 (inj_eq signr_inj). Qed. Lemma eq_scale_irr a (i j : Iirr G) : (a *: 'chi_i == a *: 'chi_j) = (a == 0) || (i == j). Proof. by rewrite eq_scaled_irr eqxx. Qed. Lemma eq_addZ_irr a b (i j r t : Iirr G) : (a *: 'chi_i + b *: 'chi_j == a *: 'chi_r + b *: 'chi_t) = [|| [&& (a == 0) || (i == r) & (b == 0) || (j == t)], [&& i == t, j == r & a == b] | [&& i == j, r == t & a == - b]]. Proof. rewrite -!eq_scale_irr; apply/eqP/idP; last first. case/orP; first by case/andP=> /eqP-> /eqP->. case/orP=> /and3P[/eqP-> /eqP-> /eqP->]; first by rewrite addrC. by rewrite !scaleNr !addNr. have [-> /addrI/eqP-> // | /=] := eqVneq. rewrite eq_scale_irr => /norP[/negP nz_a /negPf neq_ir]. move/(congr1 (cfdotr 'chi__))/esym/eqP => /= eq_cfdot. move: {eq_cfdot}(eq_cfdot i) (eq_cfdot r); rewrite eq_sym !cfdotDl !cfdotZl. rewrite !cfdot_irr !mulr_natr !mulrb !eqxx -!(eq_sym i) neq_ir !add0r. have [<- _ | _] := i =P t; first by rewrite neq_ir addr0; case: ifP => // _ ->. rewrite 2!fun_if if_arg addr0 addr_eq0; case: eqP => //= <- ->. by rewrite neq_ir 2!fun_if if_arg eq_sym addr0; case: ifP. Qed. Lemma eq_subZnat_irr (a b : nat) (i j r t : Iirr G) : (a%:R *: 'chi_i - b%:R *: 'chi_j == a%:R *: 'chi_r - b%:R *: 'chi_t) = [|| a == 0 | i == r] && [|| b == 0 | j == t] || [&& i == j, r == t & a == b]. Proof. rewrite -!scaleNr eq_addZ_irr oppr_eq0 opprK -addr_eq0 -natrD eqr_nat. by rewrite !pnatr_eq0 addn_eq0; case: a b => [|a] [|b]; rewrite ?andbF. Qed. End InnerProduct. Section IrrConstt. Variable (gT : finGroupType) (G H : {group gT}). Lemma char1_ge_norm (chi : 'CF(G)) x : chi \is a character -> `|chi x| <= chi 1%g. Proof. case/char_reprP=> rG ->; case Gx: (x \in G); last first. by rewrite cfunE cfRepr1 Gx normr0 ler0n. by have [e [_ _ []]] := repr_rsim_diag rG Gx. Qed. Lemma max_cfRepr_norm_scalar n (rG : mx_representation algC G n) x : x \in G -> `|cfRepr rG x| = cfRepr rG 1%g -> exists2 c, `|c| = 1 & rG x = c%:M. Proof. move=> Gx; have [e [[B uB def_x] [_ e1] [-> _] _]] := repr_rsim_diag rG Gx. rewrite cfRepr1 -[n in n%:R]card_ord -sumr_const -(eq_bigr _ (in1W e1)). case/normC_sum_eq1=> [i _ | c /eqP norm_c_1 def_e]; first by rewrite e1. have{} def_e: e = const_mx c by apply/rowP=> i; rewrite mxE def_e ?andbT. by exists c => //; rewrite def_x def_e diag_const_mx scalar_mxC mulmxKV. Qed. Lemma max_cfRepr_mx1 n (rG : mx_representation algC G n) x : x \in G -> cfRepr rG x = cfRepr rG 1%g -> rG x = 1%:M. Proof. move=> Gx kerGx; have [|c _ def_x] := @max_cfRepr_norm_scalar n rG x Gx. by rewrite kerGx cfRepr1 normr_nat. move/eqP: kerGx; rewrite cfRepr1 cfunE Gx {rG}def_x mxtrace_scalar. case: n => [_|n]; first by rewrite ![_%:M]flatmx0. rewrite mulrb -subr_eq0 -mulrnBl -mulr_natl mulf_eq0 pnatr_eq0 /=. by rewrite subr_eq0 => /eqP->. Qed. Definition irr_constt (B : {set gT}) phi := [pred i | '[phi, 'chi_i]_B != 0]. Lemma irr_consttE i phi : (i \in irr_constt phi) = ('[phi, 'chi_i]_G != 0). Proof. by []. Qed. Lemma constt_charP (i : Iirr G) chi : chi \is a character -> reflect (exists2 chi', chi' \is a character & chi = 'chi_i + chi') (i \in irr_constt chi). Proof. move=> Nchi; apply: (iffP idP) => [i_in_chi| [chi' Nchi' ->]]; last first. rewrite inE /= cfdotDl cfdot_irr eqxx -(eqP (Cnat_cfdot_char_irr i Nchi')). by rewrite -natrD pnatr_eq0. exists (chi - 'chi_i); last by rewrite addrC subrK. apply/forallP=> j; rewrite coord_cfdot cfdotBl cfdot_irr. have [<- | _] := eqP; last by rewrite subr0 Cnat_cfdot_char_irr. move: i_in_chi; rewrite inE; case/natrP: (Cnat_cfdot_char_irr i Nchi) => n ->. by rewrite pnatr_eq0 -lt0n => /natrB <-; apply: rpred_nat. Qed. Lemma cfun_sum_constt (phi : 'CF(G)) : phi = \sum_(i in irr_constt phi) '[phi, 'chi_i] *: 'chi_i. Proof. rewrite {1}[phi]cfun_sum_cfdot (bigID [pred i | '[phi, 'chi_i] == 0]) /=. by rewrite big1 ?add0r // => i /eqP->; rewrite scale0r. Qed. Lemma neq0_has_constt (phi : 'CF(G)) : phi != 0 -> exists i, i \in irr_constt phi. Proof. move=> nz_phi; apply/existsP; apply: contra nz_phi => /pred0P phi0. by rewrite [phi]cfun_sum_constt big_pred0. Qed. Lemma constt_irr i : irr_constt 'chi[G]_i =i pred1 i. Proof. by move=> j; rewrite !inE cfdot_irr pnatr_eq0 (eq_sym j); case: (i == j). Qed. Lemma char1_ge_constt (i : Iirr G) chi : chi \is a character -> i \in irr_constt chi -> 'chi_i 1%g <= chi 1%g. Proof. move=> {chi} _ /constt_charP[// | chi Nchi ->]. by rewrite cfunE addrC -subr_ge0 addrK char1_ge0. Qed. Lemma constt_ortho_char (phi psi : 'CF(G)) i j : phi \is a character -> psi \is a character -> i \in irr_constt phi -> j \in irr_constt psi -> '[phi, psi] = 0 -> '['chi_i, 'chi_j] = 0. Proof. move=> _ _ /constt_charP[//|phi1 Nphi1 ->] /constt_charP[//|psi1 Npsi1 ->]. rewrite cfdot_irr; case: eqP => // -> /eqP/idPn[]. rewrite cfdotDl !cfdotDr cfnorm_irr -addrA gt_eqF ?ltr_wpDr ?ltr01 //. by rewrite natr_ge0 ?rpredD ?Cnat_cfdot_char ?irr_char. Qed. End IrrConstt. Arguments irr_constt {gT B%_g} phi%_CF. Section Kernel. Variable (gT : finGroupType) (G : {group gT}). Implicit Types (phi chi xi : 'CF(G)) (H : {group gT}). Lemma cfker_repr n (rG : mx_representation algC G n) : cfker (cfRepr rG) = rker rG. Proof. apply/esym/setP=> x; rewrite inE mul1mx /=. case Gx: (x \in G); last by rewrite inE Gx. apply/eqP/idP=> Kx; last by rewrite max_cfRepr_mx1 // cfker1. rewrite inE Gx; apply/forallP=> y; rewrite !cfunE !mulrb groupMl //. by case: ifP => // Gy; rewrite repr_mxM // Kx mul1mx. Qed. Lemma cfkerEchar chi : chi \is a character -> cfker chi = [set x in G | chi x == chi 1%g]. Proof. move=> Nchi; apply/setP=> x; apply/idP/setIdP=> [Kx | [Gx /eqP chi_x]]. by rewrite (subsetP (cfker_sub chi)) // cfker1. case/char_reprP: Nchi => rG -> in chi_x *; rewrite inE Gx; apply/forallP=> y. rewrite !cfunE groupMl // !mulrb; case: ifP => // Gy. by rewrite repr_mxM // max_cfRepr_mx1 ?mul1mx. Qed. Lemma cfker_nzcharE chi : chi \is a character -> chi != 0 -> cfker chi = [set x | chi x == chi 1%g]. Proof. move=> Nchi nzchi; apply/setP=> x; rewrite cfkerEchar // !inE andb_idl //. by apply: contraLR => /cfun0-> //; rewrite eq_sym char1_eq0. Qed. Lemma cfkerEirr i : cfker 'chi[G]_i = [set x | 'chi_i x == 'chi_i 1%g]. Proof. by rewrite cfker_nzcharE ?irr_char ?irr_neq0. Qed. Lemma cfker_irr0 : cfker 'chi[G]_0 = G. Proof. by rewrite irr0 cfker_cfun1. Qed. Lemma cfaithful_reg : cfaithful (cfReg G). Proof. apply/subsetP=> x; rewrite cfkerEchar ?cfReg_char // !inE !cfRegE eqxx. by case/andP=> _; apply: contraLR => /negbTE->; rewrite eq_sym neq0CG. Qed. Lemma cfkerE chi : chi \is a character -> cfker chi = G :&: \bigcap_(i in irr_constt chi) cfker 'chi_i. Proof. move=> Nchi; rewrite cfkerEchar //; apply/setP=> x; rewrite !inE. apply: andb_id2l => Gx; rewrite {1 2}[chi]cfun_sum_constt !sum_cfunE. apply/eqP/bigcapP=> [Kx i Ci | Kx]; last first. by apply: eq_bigr => i /Kx Kx_i; rewrite !cfunE cfker1. rewrite cfkerEirr inE /= -(inj_eq (mulfI Ci)). have:= (normC_sum_upper _ Kx) i; rewrite !cfunE => -> // {Ci}i _. have chi_i_ge0: 0 <= '[chi, 'chi_i]. by rewrite natr_ge0 ?Cnat_cfdot_char_irr. by rewrite !cfunE normrM (normr_idP _) ?ler_wpM2l ?char1_ge_norm ?irr_char. Qed. Lemma TI_cfker_irr : \bigcap_i cfker 'chi[G]_i = [1]. Proof. apply/trivgP; apply: subset_trans cfaithful_reg; rewrite cfkerE ?cfReg_char //. rewrite subsetI (bigcap_min 0) //=; last by rewrite cfker_irr0. by apply/bigcapsP=> i _; rewrite bigcap_inf. Qed. Lemma cfker_constt i chi : chi \is a character -> i \in irr_constt chi -> cfker chi \subset cfker 'chi[G]_i. Proof. by move=> Nchi Ci; rewrite cfkerE ?subIset ?(bigcap_min i) ?orbT. Qed. Section KerLin. Variable xi : 'CF(G). Hypothesis lin_xi : xi \is a linear_char. Let Nxi: xi \is a character. Proof. by have [] := andP lin_xi. Qed. Lemma lin_char_der1 : G^`(1)%g \subset cfker xi. Proof. rewrite gen_subG /=; apply/subsetP=> _ /imset2P[x y Gx Gy ->]. rewrite cfkerEchar // inE groupR //= !lin_charM ?lin_charV ?in_group //. by rewrite mulrCA mulKf ?mulVf ?lin_char_neq0 // lin_char1. Qed. Lemma cforder_lin_char : #[xi]%CF = exponent (G / cfker xi)%g. Proof. apply/eqP; rewrite eqn_dvd; apply/andP; split. apply/dvdn_cforderP=> x Gx; rewrite -lin_charX // -cfQuoEker ?groupX //. rewrite morphX ?(subsetP (cfker_norm xi)) //= expg_exponent ?mem_quotient //. by rewrite cfQuo1 ?cfker_normal ?lin_char1. have abGbar: abelian (G / cfker xi) := sub_der1_abelian lin_char_der1. have [_ /morphimP[x Nx Gx ->] ->] := exponent_witness (abelian_nil abGbar). rewrite order_dvdn -morphX //= coset_id cfkerEchar // !inE groupX //=. by rewrite lin_charX ?lin_char1 // (dvdn_cforderP _ _ _). Qed. Lemma cforder_lin_char_dvdG : #[xi]%CF %| #|G|. Proof. by rewrite cforder_lin_char (dvdn_trans (exponent_dvdn _)) ?dvdn_morphim. Qed. Lemma cforder_lin_char_gt0 : (0 < #[xi]%CF)%N. Proof. by rewrite cforder_lin_char exponent_gt0. Qed. End KerLin. End Kernel. Section Restrict. Variable (gT : finGroupType) (G H : {group gT}). Lemma cfRepr_sub n (rG : mx_representation algC G n) (sHG : H \subset G) : cfRepr (subg_repr rG sHG) = 'Res[H] (cfRepr rG). Proof. by apply/cfun_inP => x Hx; rewrite cfResE // !cfunE Hx (subsetP sHG). Qed. Lemma cfRes_char chi : chi \is a character -> 'Res[H, G] chi \is a character. Proof. have [sHG | not_sHG] := boolP (H \subset G). by case/char_reprP=> rG ->; rewrite -(cfRepr_sub rG sHG) cfRepr_char. by move/Cnat_char1=> Nchi1; rewrite cfResEout // rpredZ_nat ?rpred1. Qed. Lemma cfRes_eq0 phi : phi \is a character -> ('Res[H, G] phi == 0) = (phi == 0). Proof. by move=> Nchi; rewrite -!char1_eq0 ?cfRes_char // cfRes1. Qed. Lemma cfRes_lin_char chi : chi \is a linear_char -> 'Res[H, G] chi \is a linear_char. Proof. by case/andP=> Nchi; rewrite qualifE/= cfRes_char ?cfRes1. Qed. Lemma Res_irr_neq0 i : 'Res[H, G] 'chi_i != 0. Proof. by rewrite cfRes_eq0 ?irr_neq0 ?irr_char. Qed. Lemma cfRes_lin_lin (chi : 'CF(G)) : chi \is a character -> 'Res[H] chi \is a linear_char -> chi \is a linear_char. Proof. by rewrite !qualifE/= !qualifE/= cfRes1 => -> /andP[]. Qed. Lemma cfRes_irr_irr chi : chi \is a character -> 'Res[H] chi \in irr H -> chi \in irr G. Proof. have [sHG /char_reprP[rG ->] | not_sHG Nchi] := boolP (H \subset G). rewrite -(cfRepr_sub _ sHG) => /irr_reprP[rH irrH def_rH]; apply/irr_reprP. suffices /subg_mx_irr: mx_irreducible (subg_repr rG sHG) by exists rG. by apply: mx_rsim_irr irrH; apply/cfRepr_rsimP/eqP. rewrite cfResEout // => /irrP[j Dchi_j]; apply/lin_char_irr/cfRes_lin_lin=> //. suffices j0: j = 0 by rewrite cfResEout // Dchi_j j0 irr0 rpred1. apply: contraNeq (irr1_neq0 j) => nz_j. have:= xcfun_id j 0; rewrite -Dchi_j cfunE xcfunZl -irr0 xcfun_id eqxx => ->. by rewrite (negPf nz_j). Qed. Definition Res_Iirr (A B : {set gT}) i := cfIirr ('Res[B, A] 'chi_i). Lemma Res_Iirr0 : Res_Iirr H (0 : Iirr G) = 0. Proof. by rewrite /Res_Iirr irr0 rmorph1 -irr0 irrK. Qed. Lemma lin_Res_IirrE i : 'chi[G]_i 1%g = 1 -> 'chi_(Res_Iirr H i) = 'Res 'chi_i. Proof. move=> chi1; rewrite cfIirrE ?lin_char_irr ?cfRes_lin_char //. by rewrite qualifE/= irr_char /= chi1. Qed. End Restrict. Arguments Res_Iirr {gT A%_g} B%_g i%_R. Section MoreConstt. Variables (gT : finGroupType) (G H : {group gT}). Lemma constt_Ind_Res i j : i \in irr_constt ('Ind[G] 'chi_j) = (j \in irr_constt ('Res[H] 'chi_i)). Proof. by rewrite !irr_consttE cfdotC conjC_eq0 -cfdot_Res_l. Qed. Lemma cfdot_Res_ge_constt i j psi : psi \is a character -> j \in irr_constt psi -> '['Res[H, G] 'chi_j, 'chi_i] <= '['Res[H] psi, 'chi_i]. Proof. move=> {psi} _ /constt_charP[// | psi Npsi ->]. rewrite linearD cfdotDl addrC -subr_ge0 addrK natr_ge0 //=. by rewrite Cnat_cfdot_char_irr // cfRes_char. Qed. Lemma constt_Res_trans j psi : psi \is a character -> j \in irr_constt psi -> {subset irr_constt ('Res[H, G] 'chi_j) <= irr_constt ('Res[H] psi)}. Proof. move=> Npsi Cj i; apply: contraNneq; rewrite eq_le => {1}<-. rewrite cfdot_Res_ge_constt ?natr_ge0 ?Cnat_cfdot_char_irr //. by rewrite cfRes_char ?irr_char. Qed. End MoreConstt. Section Morphim. Variables (aT rT : finGroupType) (G D : {group aT}) (f : {morphism D >-> rT}). Implicit Type chi : 'CF(f @* G). Lemma cfRepr_morphim n (rfG : mx_representation algC (f @* G) n) sGD : cfRepr (morphim_repr rfG sGD) = cfMorph (cfRepr rfG). Proof. apply/cfun_inP=> x Gx; have Dx: x \in D := subsetP sGD x Gx. by rewrite cfMorphE // !cfunE ?mem_morphim ?Gx. Qed. Lemma cfMorph_char chi : chi \is a character -> cfMorph chi \is a character. Proof. have [sGD /char_reprP[rfG ->] | outGD Nchi] := boolP (G \subset D); last first. by rewrite cfMorphEout // rpredZ_nat ?rpred1 ?Cnat_char1. apply/char_reprP; exists (Representation (morphim_repr rfG sGD)). by rewrite cfRepr_morphim. Qed. Lemma cfMorph_lin_char chi : chi \is a linear_char -> cfMorph chi \is a linear_char. Proof. by case/andP=> Nchi; rewrite qualifE/= cfMorph1 cfMorph_char. Qed. Lemma cfMorph_charE chi : G \subset D -> (cfMorph chi \is a character) = (chi \is a character). Proof. move=> sGD; apply/idP/idP=> [/char_reprP[[n rG] /=Dfchi] | /cfMorph_char//]. pose H := 'ker_G f; have kerH: H \subset rker rG. by rewrite -cfker_repr -Dfchi cfker_morph // setIS // ker_sub_pre. have nHG: G \subset 'N(H) by rewrite normsI // (subset_trans sGD) ?ker_norm. have [h injh im_h] := first_isom_loc f sGD; rewrite -/H in h injh im_h. have DfG: invm injh @*^-1 (G / H) == (f @* G)%g by rewrite morphpre_invm im_h. pose rfG := eqg_repr (morphpre_repr _ (quo_repr kerH nHG)) DfG. apply/char_reprP; exists (Representation rfG). apply/cfun_inP=> _ /morphimP[x Dx Gx ->]; rewrite -cfMorphE // Dfchi !cfunE Gx. pose xH := coset H x; have GxH: xH \in (G / H)%g by apply: mem_quotient. suffices Dfx: f x = h xH by rewrite mem_morphim //= Dfx invmE ?quo_repr_coset. by apply/set1_inj; rewrite -?morphim_set1 ?im_h ?(subsetP nHG) ?sub1set. Qed. Lemma cfMorph_lin_charE chi : G \subset D -> (cfMorph chi \is a linear_char) = (chi \is a linear_char). Proof. by rewrite qualifE/= cfMorph1 => /cfMorph_charE->. Qed. Lemma cfMorph_irr chi : G \subset D -> (cfMorph chi \in irr G) = (chi \in irr (f @* G)). Proof. by move=> sGD; rewrite !irrEchar cfMorph_charE // cfMorph_iso. Qed. Definition morph_Iirr i := cfIirr (cfMorph 'chi[f @* G]_i). Lemma morph_Iirr0 : morph_Iirr 0 = 0. Proof. by rewrite /morph_Iirr irr0 rmorph1 -irr0 irrK. Qed. Hypothesis sGD : G \subset D. Lemma morph_IirrE i : 'chi_(morph_Iirr i) = cfMorph 'chi_i. Proof. by rewrite cfIirrE ?cfMorph_irr ?mem_irr. Qed. Lemma morph_Iirr_inj : injective morph_Iirr. Proof. by move=> i j eq_ij; apply/irr_inj/cfMorph_inj; rewrite // -!morph_IirrE eq_ij. Qed. Lemma morph_Iirr_eq0 i : (morph_Iirr i == 0) = (i == 0). Proof. by rewrite -!irr_eq1 morph_IirrE cfMorph_eq1. Qed. End Morphim. Section Isom. Variables (aT rT : finGroupType) (G : {group aT}) (f : {morphism G >-> rT}). Variables (R : {group rT}) (isoGR : isom G R f). Implicit Type chi : 'CF(G). Lemma cfIsom_char chi : (cfIsom isoGR chi \is a character) = (chi \is a character). Proof. rewrite [cfIsom _]locked_withE cfMorph_charE //. by rewrite (isom_im (isom_sym _)) cfRes_id. Qed. Lemma cfIsom_lin_char chi : (cfIsom isoGR chi \is a linear_char) = (chi \is a linear_char). Proof. by rewrite qualifE/= cfIsom_char cfIsom1. Qed. Lemma cfIsom_irr chi : (cfIsom isoGR chi \in irr R) = (chi \in irr G). Proof. by rewrite !irrEchar cfIsom_char cfIsom_iso. Qed. Definition isom_Iirr i := cfIirr (cfIsom isoGR 'chi_i). Lemma isom_IirrE i : 'chi_(isom_Iirr i) = cfIsom isoGR 'chi_i. Proof. by rewrite cfIirrE ?cfIsom_irr ?mem_irr. Qed. Lemma isom_Iirr_inj : injective isom_Iirr. Proof. by move=> i j eqij; apply/irr_inj/(cfIsom_inj isoGR); rewrite -!isom_IirrE eqij. Qed. Lemma isom_Iirr_eq0 i : (isom_Iirr i == 0) = (i == 0). Proof. by rewrite -!irr_eq1 isom_IirrE cfIsom_eq1. Qed. Lemma isom_Iirr0 : isom_Iirr 0 = 0. Proof. by apply/eqP; rewrite isom_Iirr_eq0. Qed. End Isom. Arguments isom_Iirr_inj {aT rT G f R} isoGR [i1 i2] : rename. Section IsomInv. Variables (aT rT : finGroupType) (G : {group aT}) (f : {morphism G >-> rT}). Variables (R : {group rT}) (isoGR : isom G R f). Lemma isom_IirrK : cancel (isom_Iirr isoGR) (isom_Iirr (isom_sym isoGR)). Proof. by move=> i; apply: irr_inj; rewrite !isom_IirrE cfIsomK. Qed. Lemma isom_IirrKV : cancel (isom_Iirr (isom_sym isoGR)) (isom_Iirr isoGR). Proof. by move=> i; apply: irr_inj; rewrite !isom_IirrE cfIsomKV. Qed. End IsomInv. Section Sdprod. Variables (gT : finGroupType) (K H G : {group gT}). Hypothesis defG : K ><| H = G. Let nKG: G \subset 'N(K). Proof. by have [/andP[]] := sdprod_context defG. Qed. Lemma cfSdprod_char chi : (cfSdprod defG chi \is a character) = (chi \is a character). Proof. by rewrite unlock cfMorph_charE // cfIsom_char. Qed. Lemma cfSdprod_lin_char chi : (cfSdprod defG chi \is a linear_char) = (chi \is a linear_char). Proof. by rewrite qualifE/= cfSdprod_char cfSdprod1. Qed. Lemma cfSdprod_irr chi : (cfSdprod defG chi \in irr G) = (chi \in irr H). Proof. by rewrite !irrEchar cfSdprod_char cfSdprod_iso. Qed. Definition sdprod_Iirr j := cfIirr (cfSdprod defG 'chi_j). Lemma sdprod_IirrE j : 'chi_(sdprod_Iirr j) = cfSdprod defG 'chi_j. Proof. by rewrite cfIirrE ?cfSdprod_irr ?mem_irr. Qed. Lemma sdprod_IirrK : cancel sdprod_Iirr (Res_Iirr H). Proof. by move=> j; rewrite /Res_Iirr sdprod_IirrE cfSdprodK irrK. Qed. Lemma sdprod_Iirr_inj : injective sdprod_Iirr. Proof. exact: can_inj sdprod_IirrK. Qed. Lemma sdprod_Iirr_eq0 i : (sdprod_Iirr i == 0) = (i == 0). Proof. by rewrite -!irr_eq1 sdprod_IirrE cfSdprod_eq1. Qed. Lemma sdprod_Iirr0 : sdprod_Iirr 0 = 0. Proof. by apply/eqP; rewrite sdprod_Iirr_eq0. Qed. Lemma Res_sdprod_irr phi : K \subset cfker phi -> phi \in irr G -> 'Res phi \in irr H. Proof. move=> kerK /irrP[i Dphi]; rewrite irrEchar -(cfSdprod_iso defG). by rewrite cfRes_sdprodK // Dphi cfnorm_irr cfRes_char ?irr_char /=. Qed. Lemma sdprod_Res_IirrE i : K \subset cfker 'chi[G]_i -> 'chi_(Res_Iirr H i) = 'Res 'chi_i. Proof. by move=> kerK; rewrite cfIirrE ?Res_sdprod_irr ?mem_irr. Qed. Lemma sdprod_Res_IirrK i : K \subset cfker 'chi_i -> sdprod_Iirr (Res_Iirr H i) = i. Proof. by move=> kerK; rewrite /sdprod_Iirr sdprod_Res_IirrE ?cfRes_sdprodK ?irrK. Qed. End Sdprod. Arguments sdprod_Iirr_inj {gT K H G} defG [i1 i2] : rename. Section DProd. Variables (gT : finGroupType) (G K H : {group gT}). Hypothesis KxH : K \x H = G. Lemma cfDprodKl_abelian j : abelian H -> cancel ((cfDprod KxH)^~ 'chi_j) 'Res. Proof. by move=> cHH; apply: cfDprodKl; apply/lin_char1/char_abelianP. Qed. Lemma cfDprodKr_abelian i : abelian K -> cancel (cfDprod KxH 'chi_i) 'Res. Proof. by move=> cKK; apply: cfDprodKr; apply/lin_char1/char_abelianP. Qed. Lemma cfDprodl_char phi : (cfDprodl KxH phi \is a character) = (phi \is a character). Proof. exact: cfSdprod_char. Qed. Lemma cfDprodr_char psi : (cfDprodr KxH psi \is a character) = (psi \is a character). Proof. exact: cfSdprod_char. Qed. Lemma cfDprod_char phi psi : phi \is a character -> psi \is a character -> cfDprod KxH phi psi \is a character. Proof. by move=> Nphi Npsi; rewrite rpredM ?cfDprodl_char ?cfDprodr_char. Qed. Lemma cfDprod_eq1 phi psi : phi \is a character -> psi \is a character -> (cfDprod KxH phi psi == 1) = (phi == 1) && (psi == 1). Proof. move=> /Cnat_char1 Nphi /Cnat_char1 Npsi. apply/eqP/andP=> [phi_psi_1 | [/eqP-> /eqP->]]; last by rewrite cfDprod_cfun1. have /andP[/eqP phi1 /eqP psi1]: (phi 1%g == 1) && (psi 1%g == 1). by rewrite -natr_mul_eq1 // -(cfDprod1 KxH) phi_psi_1 cfun11. rewrite -[phi](cfDprodKl KxH psi1) -{2}[psi](cfDprodKr KxH phi1) phi_psi_1. by rewrite !rmorph1. Qed. Lemma cfDprodl_lin_char phi : (cfDprodl KxH phi \is a linear_char) = (phi \is a linear_char). Proof. exact: cfSdprod_lin_char. Qed. Lemma cfDprodr_lin_char psi : (cfDprodr KxH psi \is a linear_char) = (psi \is a linear_char). Proof. exact: cfSdprod_lin_char. Qed. Lemma cfDprod_lin_char phi psi : phi \is a linear_char -> psi \is a linear_char -> cfDprod KxH phi psi \is a linear_char. Proof. by move=> Nphi Npsi; rewrite rpredM ?cfSdprod_lin_char. Qed. Lemma cfDprodl_irr chi : (cfDprodl KxH chi \in irr G) = (chi \in irr K). Proof. exact: cfSdprod_irr. Qed. Lemma cfDprodr_irr chi : (cfDprodr KxH chi \in irr G) = (chi \in irr H). Proof. exact: cfSdprod_irr. Qed. Definition dprodl_Iirr i := cfIirr (cfDprodl KxH 'chi_i). Lemma dprodl_IirrE i : 'chi_(dprodl_Iirr i) = cfDprodl KxH 'chi_i. Proof. exact: sdprod_IirrE. Qed. Lemma dprodl_IirrK : cancel dprodl_Iirr (Res_Iirr K). Proof. exact: sdprod_IirrK. Qed. Lemma dprodl_Iirr_eq0 i : (dprodl_Iirr i == 0) = (i == 0). Proof. exact: sdprod_Iirr_eq0. Qed. Lemma dprodl_Iirr0 : dprodl_Iirr 0 = 0. Proof. exact: sdprod_Iirr0. Qed. Definition dprodr_Iirr j := cfIirr (cfDprodr KxH 'chi_j). Lemma dprodr_IirrE j : 'chi_(dprodr_Iirr j) = cfDprodr KxH 'chi_j. Proof. exact: sdprod_IirrE. Qed. Lemma dprodr_IirrK : cancel dprodr_Iirr (Res_Iirr H). Proof. exact: sdprod_IirrK. Qed. Lemma dprodr_Iirr_eq0 j : (dprodr_Iirr j == 0) = (j == 0). Proof. exact: sdprod_Iirr_eq0. Qed. Lemma dprodr_Iirr0 : dprodr_Iirr 0 = 0. Proof. exact: sdprod_Iirr0. Qed. Lemma cfDprod_irr i j : cfDprod KxH 'chi_i 'chi_j \in irr G. Proof. rewrite irrEchar cfDprod_char ?irr_char //=. by rewrite cfdot_dprod !cfdot_irr !eqxx mul1r. Qed. Definition dprod_Iirr ij := cfIirr (cfDprod KxH 'chi_ij.1 'chi_ij.2). Lemma dprod_IirrE i j : 'chi_(dprod_Iirr (i, j)) = cfDprod KxH 'chi_i 'chi_j. Proof. by rewrite cfIirrE ?cfDprod_irr. Qed. Lemma dprod_IirrEl i : 'chi_(dprod_Iirr (i, 0)) = cfDprodl KxH 'chi_i. Proof. by rewrite dprod_IirrE /cfDprod irr0 rmorph1 mulr1. Qed. Lemma dprod_IirrEr j : 'chi_(dprod_Iirr (0, j)) = cfDprodr KxH 'chi_j. Proof. by rewrite dprod_IirrE /cfDprod irr0 rmorph1 mul1r. Qed. Lemma dprod_Iirr_inj : injective dprod_Iirr. Proof. move=> [i1 j1] [i2 j2] /eqP; rewrite -[_ == _]oddb -(@natrK algC (_ == _)). rewrite -cfdot_irr !dprod_IirrE cfdot_dprod !cfdot_irr -natrM mulnb. by rewrite natrK oddb -xpair_eqE => /eqP. Qed. Lemma dprod_Iirr0 : dprod_Iirr (0, 0) = 0. Proof. by apply/irr_inj; rewrite dprod_IirrE !irr0 cfDprod_cfun1. Qed. Lemma dprod_Iirr0l j : dprod_Iirr (0, j) = dprodr_Iirr j. Proof. by apply/irr_inj; rewrite dprod_IirrE irr0 dprodr_IirrE cfDprod_cfun1l. Qed. Lemma dprod_Iirr0r i : dprod_Iirr (i, 0) = dprodl_Iirr i. Proof. by apply/irr_inj; rewrite dprod_IirrE irr0 dprodl_IirrE cfDprod_cfun1r. Qed. Lemma dprod_Iirr_eq0 i j : (dprod_Iirr (i, j) == 0) = (i == 0) && (j == 0). Proof. by rewrite -xpair_eqE -(inj_eq dprod_Iirr_inj) dprod_Iirr0. Qed. Lemma cfdot_dprod_irr i1 i2 j1 j2 : '['chi_(dprod_Iirr (i1, j1)), 'chi_(dprod_Iirr (i2, j2))] = ((i1 == i2) && (j1 == j2))%:R. Proof. by rewrite cfdot_irr (inj_eq dprod_Iirr_inj). Qed. Lemma dprod_Iirr_onto k : k \in codom dprod_Iirr. Proof. set D := codom _; have Df: dprod_Iirr _ \in D := codom_f dprod_Iirr _. have: 'chi_k 1%g ^+ 2 != 0 by rewrite mulf_neq0 ?irr1_neq0. apply: contraR => notDk; move/eqP: (irr_sum_square G). rewrite (bigID [in D]) (reindex _ (bij_on_codom dprod_Iirr_inj (0, 0))) /=. have ->: #|G|%:R = \sum_i \sum_j 'chi_(dprod_Iirr (i, j)) 1%g ^+ 2. rewrite -(dprod_card KxH) natrM. do 2![rewrite -irr_sum_square (mulr_suml, mulr_sumr); apply: eq_bigr => ? _]. by rewrite dprod_IirrE -exprMn -{3}(mulg1 1%g) cfDprodE. rewrite (eq_bigl _ _ Df) pair_bigA addrC -subr_eq0 addrK. by move/eqP/psumr_eq0P=> -> //= i _; rewrite irr1_degree -natrX ler0n. Qed. Definition inv_dprod_Iirr i := iinv (dprod_Iirr_onto i). Lemma dprod_IirrK : cancel dprod_Iirr inv_dprod_Iirr. Proof. by move=> p; apply: (iinv_f dprod_Iirr_inj). Qed. Lemma inv_dprod_IirrK : cancel inv_dprod_Iirr dprod_Iirr. Proof. by move=> i; apply: f_iinv. Qed. Lemma inv_dprod_Iirr0 : inv_dprod_Iirr 0 = (0, 0). Proof. by apply/(canLR dprod_IirrK); rewrite dprod_Iirr0. Qed. End DProd. Arguments dprod_Iirr_inj {gT G K H} KxH [i1 i2] : rename. Lemma dprod_IirrC (gT : finGroupType) (G K H : {group gT}) (KxH : K \x H = G) (HxK : H \x K = G) i j : dprod_Iirr KxH (i, j) = dprod_Iirr HxK (j, i). Proof. by apply: irr_inj; rewrite !dprod_IirrE; apply: cfDprodC. Qed. Section BigDprod. Variables (gT : finGroupType) (I : finType) (P : pred I). Variables (A : I -> {group gT}) (G : {group gT}). Hypothesis defG : \big[dprod/1%g]_(i | P i) A i = G. Let sAG i : P i -> A i \subset G. Proof. by move=> Pi; rewrite -(bigdprodWY defG) (bigD1 i) ?joing_subl. Qed. Lemma cfBigdprodi_char i (phi : 'CF(A i)) : phi \is a character -> cfBigdprodi defG phi \is a character. Proof. by move=> Nphi; rewrite cfDprodl_char cfRes_char. Qed. Lemma cfBigdprodi_charE i (phi : 'CF(A i)) : P i -> (cfBigdprodi defG phi \is a character) = (phi \is a character). Proof. by move=> Pi; rewrite cfDprodl_char Pi cfRes_id. Qed. Lemma cfBigdprod_char phi : (forall i, P i -> phi i \is a character) -> cfBigdprod defG phi \is a character. Proof. by move=> Nphi; apply: rpred_prod => i /Nphi; apply: cfBigdprodi_char. Qed. Lemma cfBigdprodi_lin_char i (phi : 'CF(A i)) : phi \is a linear_char -> cfBigdprodi defG phi \is a linear_char. Proof. by move=> Lphi; rewrite cfDprodl_lin_char ?cfRes_lin_char. Qed. Lemma cfBigdprodi_lin_charE i (phi : 'CF(A i)) : P i -> (cfBigdprodi defG phi \is a linear_char) = (phi \is a linear_char). Proof. by move=> Pi; rewrite qualifE/= cfBigdprodi_charE // cfBigdprodi1. Qed. Lemma cfBigdprod_lin_char phi : (forall i, P i -> phi i \is a linear_char) -> cfBigdprod defG phi \is a linear_char. Proof. by move=> Lphi; apply/rpred_prod=> i /Lphi; apply: cfBigdprodi_lin_char. Qed. Lemma cfBigdprodi_irr i chi : P i -> (cfBigdprodi defG chi \in irr G) = (chi \in irr (A i)). Proof. by move=> Pi; rewrite !irrEchar cfBigdprodi_charE ?cfBigdprodi_iso. Qed. Lemma cfBigdprod_irr chi : (forall i, P i -> chi i \in irr (A i)) -> cfBigdprod defG chi \in irr G. Proof. move=> Nchi; rewrite irrEchar cfBigdprod_char => [|i /Nchi/irrWchar] //=. by rewrite cfdot_bigdprod big1 // => i /Nchi/irrWnorm. Qed. Lemma cfBigdprod_eq1 phi : (forall i, P i -> phi i \is a character) -> (cfBigdprod defG phi == 1) = [forall (i | P i), phi i == 1]. Proof. move=> Nphi; set Phi := cfBigdprod defG phi. apply/eqP/eqfun_inP=> [Phi1 i Pi | phi1]; last first. by apply: big1 => i /phi1->; rewrite rmorph1. have Phi1_1: Phi 1%g = 1 by rewrite Phi1 cfun1E group1. have nz_Phi1: Phi 1%g != 0 by rewrite Phi1_1 oner_eq0. have [_ <-] := cfBigdprodK nz_Phi1 Pi. rewrite Phi1_1 divr1 -/Phi Phi1 rmorph1. rewrite prod_cfunE // in Phi1_1; have := natr_prod_eq1 _ Phi1_1 Pi. rewrite -(cfRes1 (A i)) cfBigdprodiK // => ->; first by rewrite scale1r. by move=> {i Pi} j /Nphi Nphi_j; rewrite Cnat_char1 ?cfBigdprodi_char. Qed. Lemma cfBigdprod_Res_lin chi : chi \is a linear_char -> cfBigdprod defG (fun i => 'Res[A i] chi) = chi. Proof. move=> Lchi; apply/cfun_inP=> _ /(mem_bigdprod defG)[x [Ax -> _]]. rewrite (lin_char_prod Lchi) ?cfBigdprodE // => [|i Pi]; last first. by rewrite (subsetP (sAG Pi)) ?Ax. by apply/eq_bigr=> i Pi; rewrite cfResE ?sAG ?Ax. Qed. Lemma cfBigdprodKlin phi : (forall i, P i -> phi i \is a linear_char) -> forall i, P i -> 'Res (cfBigdprod defG phi) = phi i. Proof. move=> Lphi i Pi; have Lpsi := cfBigdprod_lin_char Lphi. have [_ <-] := cfBigdprodK (lin_char_neq0 Lpsi (group1 G)) Pi. by rewrite !lin_char1 ?Lphi // divr1 scale1r. Qed. Lemma cfBigdprodKabelian Iphi (phi := fun i => 'chi_(Iphi i)) : abelian G -> forall i, P i -> 'Res (cfBigdprod defG phi) = 'chi_(Iphi i). Proof. move=> /(abelianS _) cGG. by apply: cfBigdprodKlin => i /sAG/cGG/char_abelianP->. Qed. End BigDprod. Section Aut. Variables (gT : finGroupType) (G : {group gT}). Implicit Type u : {rmorphism algC -> algC}. Lemma conjC_charAut u (chi : 'CF(G)) x : chi \is a character -> (u (chi x))^* = u (chi x)^*. Proof. have [Gx | /cfun0->] := boolP (x \in G); last by rewrite !rmorph0. case/char_reprP=> rG ->; have [e [_ [en1 _] [-> _] _]] := repr_rsim_diag rG Gx. by rewrite !rmorph_sum; apply: eq_bigr => i _; apply: aut_unity_rootC (en1 i). Qed. Lemma conjC_irrAut u i x : (u ('chi[G]_i x))^* = u ('chi_i x)^*. Proof. exact: conjC_charAut (irr_char i). Qed. Lemma cfdot_aut_char u (phi chi : 'CF(G)) : chi \is a character -> '[cfAut u phi, cfAut u chi] = u '[phi, chi]. Proof. by move/conjC_charAut=> Nchi; apply: cfdot_cfAut => _ /mapP[x _ ->]. Qed. Lemma cfdot_aut_irr u phi i : '[cfAut u phi, cfAut u 'chi[G]_i] = u '[phi, 'chi_i]. Proof. exact: cfdot_aut_char (irr_char i). Qed. Lemma cfAut_irr u chi : (cfAut u chi \in irr G) = (chi \in irr G). Proof. rewrite !irrEchar cfAut_char; apply/andb_id2l=> /cfdot_aut_char->. exact: fmorph_eq1. Qed. Lemma cfConjC_irr i : (('chi_i)^*)%CF \in irr G. Proof. by rewrite cfAut_irr mem_irr. Qed. Lemma irr_aut_closed u : cfAut_closed u (irr G). Proof. by move=> chi; rewrite /= cfAut_irr. Qed. Definition aut_Iirr u i := cfIirr (cfAut u 'chi[G]_i). Lemma aut_IirrE u i : 'chi_(aut_Iirr u i) = cfAut u 'chi_i. Proof. by rewrite cfIirrE ?cfAut_irr ?mem_irr. Qed. Definition conjC_Iirr := aut_Iirr conjC. Lemma conjC_IirrE i : 'chi[G]_(conjC_Iirr i) = ('chi_i)^*%CF. Proof. exact: aut_IirrE. Qed. Lemma conjC_IirrK : involutive conjC_Iirr. Proof. by move=> i; apply: irr_inj; rewrite !conjC_IirrE cfConjCK. Qed. Lemma aut_Iirr0 u : aut_Iirr u 0 = 0 :> Iirr G. Proof. by apply/irr_inj; rewrite aut_IirrE irr0 cfAut_cfun1. Qed. Lemma conjC_Iirr0 : conjC_Iirr 0 = 0 :> Iirr G. Proof. exact: aut_Iirr0. Qed. Lemma aut_Iirr_eq0 u i : (aut_Iirr u i == 0) = (i == 0). Proof. by rewrite -!irr_eq1 aut_IirrE cfAut_eq1. Qed. Lemma conjC_Iirr_eq0 i : (conjC_Iirr i == 0 :> Iirr G) = (i == 0). Proof. exact: aut_Iirr_eq0. Qed. Lemma aut_Iirr_inj u : injective (aut_Iirr u). Proof. by move=> i j eq_ij; apply/irr_inj/(cfAut_inj u); rewrite -!aut_IirrE eq_ij. Qed. End Aut. Arguments aut_Iirr_inj {gT G} u [i1 i2] : rename. Arguments conjC_IirrK {gT G} i : rename. Section Coset. Variable (gT : finGroupType). Implicit Types G H : {group gT}. Lemma cfQuo_char G H (chi : 'CF(G)) : chi \is a character -> (chi / H)%CF \is a character. Proof. move=> Nchi; without loss kerH: / H \subset cfker chi. move/contraNF=> IHchi; apply/wlog_neg=> N'chiH. suffices ->: (chi / H)%CF = (chi 1%g)%:A. by rewrite rpredZ_nat ?Cnat_char1 ?rpred1. by apply/cfunP=> x; rewrite cfunE cfun1E mulr_natr cfunElock IHchi. without loss nsHG: G chi Nchi kerH / H <| G. move=> IHchi; have nsHN := normalSG (subset_trans kerH (cfker_sub chi)). rewrite cfQuoInorm//; apply/cfRes_char/IHchi => //; first exact: cfRes_char. by apply: sub_cfker_Res => //; apply: normal_sub. have [rG Dchi] := char_reprP Nchi; rewrite Dchi cfker_repr in kerH. apply/char_reprP; exists (Representation (quo_repr kerH (normal_norm nsHG))). apply/cfun_inP=> _ /morphimP[x nHx Gx ->]; rewrite Dchi cfQuoE ?cfker_repr //=. by rewrite !cfunE Gx quo_repr_coset ?mem_quotient. Qed. Lemma cfQuo_lin_char G H (chi : 'CF(G)) : chi \is a linear_char -> (chi / H)%CF \is a linear_char. Proof. by case/andP=> Nchi; rewrite qualifE/= cfQuo_char ?cfQuo1. Qed. Lemma cfMod_char G H (chi : 'CF(G / H)) : chi \is a character -> (chi %% H)%CF \is a character. Proof. exact: cfMorph_char. Qed. Lemma cfMod_lin_char G H (chi : 'CF(G / H)) : chi \is a linear_char -> (chi %% H)%CF \is a linear_char. Proof. exact: cfMorph_lin_char. Qed. Lemma cfMod_charE G H (chi : 'CF(G / H)) : H <| G -> (chi %% H \is a character)%CF = (chi \is a character). Proof. by case/andP=> _; apply: cfMorph_charE. Qed. Lemma cfMod_lin_charE G H (chi : 'CF(G / H)) : H <| G -> (chi %% H \is a linear_char)%CF = (chi \is a linear_char). Proof. by case/andP=> _; apply: cfMorph_lin_charE. Qed. Lemma cfQuo_charE G H (chi : 'CF(G)) : H <| G -> H \subset cfker chi -> (chi / H \is a character)%CF = (chi \is a character). Proof. by move=> nsHG kerH; rewrite -cfMod_charE ?cfQuoK. Qed. Lemma cfQuo_lin_charE G H (chi : 'CF(G)) : H <| G -> H \subset cfker chi -> (chi / H \is a linear_char)%CF = (chi \is a linear_char). Proof. by move=> nsHG kerH; rewrite -cfMod_lin_charE ?cfQuoK. Qed. Lemma cfMod_irr G H chi : H <| G -> (chi %% H \in irr G)%CF = (chi \in irr (G / H)). Proof. by case/andP=> _; apply: cfMorph_irr. Qed. Definition mod_Iirr G H i := cfIirr ('chi[G / H]_i %% H)%CF. Lemma mod_Iirr0 G H : mod_Iirr (0 : Iirr (G / H)) = 0. Proof. exact: morph_Iirr0. Qed. Lemma mod_IirrE G H i : H <| G -> 'chi_(mod_Iirr i) = ('chi[G / H]_i %% H)%CF. Proof. by move=> nsHG; rewrite cfIirrE ?cfMod_irr ?mem_irr. Qed. Lemma mod_Iirr_eq0 G H i : H <| G -> (mod_Iirr i == 0) = (i == 0 :> Iirr (G / H)). Proof. by case/andP=> _ /morph_Iirr_eq0->. Qed. Lemma cfQuo_irr G H chi : H <| G -> H \subset cfker chi -> ((chi / H)%CF \in irr (G / H)) = (chi \in irr G). Proof. by move=> nsHG kerH; rewrite -cfMod_irr ?cfQuoK. Qed. Definition quo_Iirr G H i := cfIirr ('chi[G]_i / H)%CF. Lemma quo_Iirr0 G H : quo_Iirr H (0 : Iirr G) = 0. Proof. by rewrite /quo_Iirr irr0 cfQuo_cfun1 -irr0 irrK. Qed. Lemma quo_IirrE G H i : H <| G -> H \subset cfker 'chi[G]_i -> 'chi_(quo_Iirr H i) = ('chi_i / H)%CF. Proof. by move=> nsHG kerH; rewrite cfIirrE ?cfQuo_irr ?mem_irr. Qed. Lemma quo_Iirr_eq0 G H i : H <| G -> H \subset cfker 'chi[G]_i -> (quo_Iirr H i == 0) = (i == 0). Proof. by move=> nsHG kerH; rewrite -!irr_eq1 quo_IirrE ?cfQuo_eq1. Qed. Lemma mod_IirrK G H : H <| G -> cancel (@mod_Iirr G H) (@quo_Iirr G H). Proof. move=> nsHG i; apply: irr_inj. by rewrite quo_IirrE ?mod_IirrE ?cfker_mod // cfModK. Qed. Lemma quo_IirrK G H i : H <| G -> H \subset cfker 'chi[G]_i -> mod_Iirr (quo_Iirr H i) = i. Proof. by move=> nsHG kerH; apply: irr_inj; rewrite mod_IirrE ?quo_IirrE ?cfQuoK. Qed. Lemma quo_IirrKeq G H : H <| G -> forall i, (mod_Iirr (quo_Iirr H i) == i) = (H \subset cfker 'chi[G]_i). Proof. move=> nsHG i; apply/eqP/idP=> [<- | ]; last exact: quo_IirrK. by rewrite mod_IirrE ?cfker_mod. Qed. Lemma mod_Iirr_bij H G : H <| G -> {on [pred i | H \subset cfker 'chi_i], bijective (@mod_Iirr G H)}. Proof. by exists (quo_Iirr H) => [i _ | i]; [apply: mod_IirrK | apply: quo_IirrK]. Qed. Lemma sum_norm_irr_quo H G x : x \in G -> H <| G -> \sum_i `|'chi[G / H]_i (coset H x)| ^+ 2 = \sum_(i | H \subset cfker 'chi_i) `|'chi[G]_i x| ^+ 2. Proof. move=> Gx nsHG; rewrite (reindex _ (mod_Iirr_bij nsHG)) /=. by apply/esym/eq_big=> [i | i _]; rewrite mod_IirrE ?cfker_mod ?cfModE. Qed. Lemma cap_cfker_normal G H : H <| G -> \bigcap_(i | H \subset cfker 'chi[G]_i) (cfker 'chi_i) = H. Proof. move=> nsHG; have [sHG nHG] := andP nsHG; set lhs := \bigcap_(i | _) _. have nHlhs: lhs \subset 'N(H) by rewrite (bigcap_min 0) ?cfker_irr0. apply/esym/eqP; rewrite eqEsubset (introT bigcapsP) //= -quotient_sub1 //. rewrite -(TI_cfker_irr (G / H)); apply/bigcapsP=> i _. rewrite sub_quotient_pre // (bigcap_min (mod_Iirr i)) ?mod_IirrE ?cfker_mod //. by rewrite cfker_morph ?subsetIr. Qed. Lemma cfker_reg_quo G H : H <| G -> cfker (cfReg (G / H)%g %% H) = H. Proof. move=> nsHG; have [sHG nHG] := andP nsHG. apply/setP=> x; rewrite cfkerEchar ?cfMod_char ?cfReg_char //. rewrite -[in RHS in _ = RHS](setIidPr sHG) !inE; apply: andb_id2l => Gx. rewrite !cfModE // !cfRegE // morph1 eqxx. rewrite (sameP eqP (kerP _ (subsetP nHG x Gx))) ker_coset. by rewrite -!mulrnA eqr_nat eqn_pmul2l ?cardG_gt0 // (can_eq oddb) eqb_id. Qed. End Coset. Section DerivedGroup. Variable gT : finGroupType. Implicit Types G H : {group gT}. Lemma lin_irr_der1 G i : ('chi_i \is a linear_char) = (G^`(1)%g \subset cfker 'chi[G]_i). Proof. apply/idP/idP=> [|sG'K]; first exact: lin_char_der1. have nsG'G: G^`(1) <| G := der_normal 1 G. rewrite qualifE/= irr_char -[i](quo_IirrK nsG'G) // mod_IirrE //=. by rewrite cfModE // morph1 lin_char1 //; apply/char_abelianP/der_abelian. Qed. Lemma subGcfker G i : (G \subset cfker 'chi[G]_i) = (i == 0). Proof. rewrite -irr_eq1; apply/idP/eqP=> [chiG1 | ->]; last by rewrite cfker_cfun1. apply/cfun_inP=> x Gx; rewrite cfun1E Gx cfker1 ?(subsetP chiG1) ?lin_char1 //. by rewrite lin_irr_der1 (subset_trans (der_sub 1 G)). Qed. Lemma irr_prime_injP G i : prime #|G| -> reflect {in G &, injective 'chi[G]_i} (i != 0). Proof. move=> pr_G; apply: (iffP idP) => [nz_i | inj_chi]. apply: fful_lin_char_inj (irr_prime_lin i pr_G) _. by rewrite cfaithfulE -(setIidPr (cfker_sub _)) prime_TIg // subGcfker. have /trivgPn[x Gx ntx]: G :!=: 1%g by rewrite -cardG_gt1 prime_gt1. apply: contraNneq ntx => i0; apply/eqP/inj_chi=> //. by rewrite i0 irr0 !cfun1E Gx group1. Qed. (* This is Isaacs (2.23)(a). *) Lemma cap_cfker_lin_irr G : \bigcap_(i | 'chi[G]_i \is a linear_char) (cfker 'chi_i) = G^`(1)%g. Proof. rewrite -(cap_cfker_normal (der_normal 1 G)). by apply: eq_bigl => i; rewrite lin_irr_der1. Qed. (* This is Isaacs (2.23)(b) *) Lemma card_lin_irr G : #|[pred i | 'chi[G]_i \is a linear_char]| = #|G : G^`(1)%g|. Proof. have nsG'G := der_normal 1 G; rewrite (eq_card (@lin_irr_der1 G)). rewrite -(on_card_preimset (mod_Iirr_bij nsG'G)). rewrite -card_quotient ?normal_norm //. move: (der_abelian 0 G); rewrite card_classes_abelian; move/eqP<-. rewrite -NirrE -[RHS]card_ord. by apply: eq_card => i; rewrite !inE mod_IirrE ?cfker_mod. (* Alternative: use the equivalent result in modular representation theory transitivity #|@socle_of_Iirr _ G @^-1: linear_irr _|; last first. rewrite (on_card_preimset (socle_of_Iirr_bij _)). by rewrite card_linear_irr ?algC'G; last apply: groupC. by apply: eq_card => i; rewrite !inE /lin_char irr_char irr1_degree -eqC_nat. *) Qed. (* A non-trivial solvable group has a nonprincipal linear character. *) Lemma solvable_has_lin_char G : G :!=: 1%g -> solvable G -> exists2 i, 'chi[G]_i \is a linear_char & 'chi_i != 1. Proof. move=> ntG solG. suff /subsetPn[i]: ~~ ([pred i | 'chi[G]_i \is a linear_char] \subset pred1 0). by rewrite !inE -(inj_eq irr_inj) irr0; exists i. rewrite (contra (@subset_leq_card _ _ _)) // -ltnNge card1 card_lin_irr. by rewrite indexg_gt1 proper_subn // (sol_der1_proper solG). Qed. (* A combinatorial group isommorphic to the linear characters. *) Lemma lin_char_group G : {linG : finGroupType & {cF : linG -> 'CF(G) | [/\ injective cF, #|linG| = #|G : G^`(1)|, forall u, cF u \is a linear_char & forall phi, phi \is a linear_char -> exists u, phi = cF u] & [/\ cF 1%g = 1%R, {morph cF : u v / (u * v)%g >-> (u * v)%R}, forall k, {morph cF : u / (u^+ k)%g >-> u ^+ k}, {morph cF: u / u^-1%g >-> u^-1%CF} & {mono cF: u / #[u]%g >-> #[u]%CF} ]}}. Proof. pose linT := {i : Iirr G | 'chi_i \is a linear_char}. pose cF (u : linT) := 'chi_(sval u). have cFlin u: cF u \is a linear_char := svalP u. have cFinj: injective cF := inj_comp irr_inj val_inj. have inT xi : xi \is a linear_char -> {u | cF u = xi}. move=> lin_xi; have /irrP/sig_eqW[i Dxi] := lin_char_irr lin_xi. by apply: (exist _ (Sub i _)) => //; rewrite -Dxi. have [one cFone] := inT 1 (rpred1 _). pose inv u := sval (inT _ (rpredVr (cFlin u))). pose mul u v := sval (inT _ (rpredM (cFlin u) (cFlin v))). have cFmul u v: cF (mul u v) = cF u * cF v := svalP (inT _ _). have cFinv u: cF (inv u) = (cF u)^-1 := svalP (inT _ _). have mulA: associative mul by move=> u v w; apply: cFinj; rewrite !cFmul mulrA. have mul1: left_id one mul by move=> u; apply: cFinj; rewrite cFmul cFone mul1r. have mulV: left_inverse one inv mul. by move=> u; apply: cFinj; rewrite cFmul cFinv cFone mulVr ?lin_char_unitr. pose imA := isMulGroup.Build linT mulA mul1 mulV. pose linG : finGroupType := HB.pack linT imA. have cFexp k: {morph cF : u / ((u : linG) ^+ k)%g >-> u ^+ k}. by move=> u; elim: k => // k IHk; rewrite expgS exprS cFmul IHk. do [exists linG, cF; split=> //] => [|xi /inT[u <-]|u]; first 2 [by exists u]. have inj_cFI: injective (cfIirr \o cF). apply: can_inj (insubd one) _ => u; apply: val_inj. by rewrite insubdK /= ?irrK //; apply: cFlin. rewrite -(card_image inj_cFI) -card_lin_irr. apply/eq_card=> i /[1!inE]; apply/codomP/idP=> [[u ->] | /inT[u Du]]. by rewrite /= irrK; apply: cFlin. by exists u; apply: irr_inj; rewrite /= irrK. apply/eqP; rewrite eqn_dvd; apply/andP; split. by rewrite dvdn_cforder; rewrite -cFexp expg_order cFone. by rewrite order_dvdn -(inj_eq cFinj) cFone cFexp exp_cforder. Qed. Lemma cfExp_prime_transitive G (i j : Iirr G) : prime #|G| -> i != 0 -> j != 0 -> exists2 k, coprime k #['chi_i]%CF & 'chi_j = 'chi_i ^+ k. Proof. set p := #|G| => pr_p nz_i nz_j; have cycG := prime_cyclic pr_p. have [L [h [injh oL Lh h_ontoL]] [h1 hM hX _ o_h]] := lin_char_group G. rewrite (derG1P (cyclic_abelian cycG)) indexg1 -/p in oL. have /fin_all_exists[h' h'K] := h_ontoL _ (irr_cyclic_lin _ cycG). have o_h' k: k != 0 -> #[h' k] = p. rewrite -cforder_irr_eq1 h'K -o_h => nt_h'k. by apply/prime_nt_dvdP=> //; rewrite cforder_lin_char_dvdG. have{oL} genL k: k != 0 -> generator [set: L] (h' k). move=> /o_h' o_h'k; rewrite /generator eq_sym eqEcard subsetT /=. by rewrite cardsT oL -o_h'k. have [/(_ =P <[_]>)-> gen_j] := (genL i nz_i, genL j nz_j). have /cycleP[k Dj] := cycle_generator gen_j. by rewrite !h'K Dj o_h hX generator_coprime coprime_sym in gen_j *; exists k. Qed. (* This is Isaacs (2.24). *) Lemma card_subcent1_coset G H x : x \in G -> H <| G -> (#|'C_(G / H)[coset H x]| <= #|'C_G[x]|)%N. Proof. move=> Gx nsHG; rewrite -leC_nat. move: (second_orthogonality_relation x Gx); rewrite mulrb class_refl => <-. have GHx: coset H x \in (G / H)%g by apply: mem_quotient. move: (second_orthogonality_relation (coset H x) GHx). rewrite mulrb class_refl => <-. rewrite -2!(eq_bigr _ (fun _ _ => normCK _)) sum_norm_irr_quo // -subr_ge0. rewrite (bigID (fun i => H \subset cfker 'chi[G]_i)) //= [X in X + _]addrC addrK. by apply: sumr_ge0 => i _; rewrite normCK mul_conjC_ge0. Qed. End DerivedGroup. Arguments irr_prime_injP {gT G i}. (* Determinant characters and determinential order. *) Section DetRepr. Variables (gT : finGroupType) (G : {group gT}). Variables (n : nat) (rG : mx_representation algC G n). Definition det_repr_mx x : 'M_1 := (\det (rG x))%:M. Fact det_is_repr : mx_repr G det_repr_mx. Proof. split=> [|g h Gg Gh]; first by rewrite /det_repr_mx repr_mx1 det1. by rewrite /det_repr_mx repr_mxM // det_mulmx !mulmxE scalar_mxM. Qed. Canonical det_repr := MxRepresentation det_is_repr. Definition detRepr := cfRepr det_repr. Lemma detRepr_lin_char : detRepr \is a linear_char. Proof. by rewrite qualifE/= cfRepr_char cfunE group1 repr_mx1 mxtrace1 mulr1n /=. Qed. End DetRepr. HB.lock Definition cfDet (gT : finGroupType) (G : {group gT}) phi := \prod_i detRepr 'Chi_i ^+ Num.truncn '[phi, 'chi[G]_i]. Canonical cfDet_unlockable := Unlockable cfDet.unlock. Section DetOrder. Variables (gT : finGroupType) (G : {group gT}). Local Notation cfDet := (@cfDet gT G). Lemma cfDet_lin_char phi : cfDet phi \is a linear_char. Proof. rewrite unlock; apply: rpred_prod => i _; apply: rpredX. exact: detRepr_lin_char. Qed. Lemma cfDetD : {in character &, {morph cfDet : phi psi / phi + psi >-> phi * psi}}. Proof. move=> phi psi Nphi Npsi; rewrite unlock /= -big_split; apply: eq_bigr => i _ /=. by rewrite -exprD cfdotDl truncnD ?nnegrE ?natr_ge0 // Cnat_cfdot_char_irr. Qed. Lemma cfDet0 : cfDet 0 = 1. Proof. by rewrite unlock big1 // => i _; rewrite cfdot0l truncn0. Qed. Lemma cfDetMn k : {in character, {morph cfDet : phi / phi *+ k >-> phi ^+ k}}. Proof. move=> phi Nphi; elim: k => [|k IHk]; rewrite ?cfDet0 // mulrS exprS -{}IHk. by rewrite cfDetD ?rpredMn. Qed. Lemma cfDetRepr n rG : cfDet (cfRepr rG) = @detRepr _ _ n rG. Proof. transitivity (\prod_W detRepr (socle_repr W) ^+ standard_irr_coef rG W). rewrite (reindex _ (socle_of_Iirr_bij _)) unlock /=. apply: eq_bigr => i _; congr (_ ^+ _). rewrite (cfRepr_sim (mx_rsim_standard rG)) cfRepr_standard. rewrite cfdot_suml (bigD1 i) ?big1 //= => [|j i'j]; last first. by rewrite cfdotZl cfdot_irr (negPf i'j) mulr0. by rewrite cfdotZl cfnorm_irr mulr1 addr0 natrK. apply/cfun_inP=> x Gx; rewrite prod_cfunE //. transitivity (detRepr (standard_grepr rG) x); last first. rewrite !cfunE Gx !trace_mx11 !mxE eqxx !mulrb. case: (standard_grepr rG) (mx_rsim_standard rG) => /= n1 rG1 [B Dn1]. rewrite -{n1}Dn1 in rG1 B *; rewrite row_free_unit => uB rG_B. by rewrite -[rG x](mulmxK uB) rG_B // !det_mulmx mulrC -!det_mulmx mulKmx. rewrite /standard_grepr; elim/big_rec2: _ => [|W y _ _ ->]. by rewrite cfunE trace_mx11 mxE Gx det1. rewrite !cfunE Gx /= !{1}trace_mx11 !{1}mxE det_ublock; congr (_ * _). rewrite exp_cfunE //; elim: (standard_irr_coef rG W) => /= [|k IHk]. by rewrite /muln_grepr big_ord0 det1. rewrite exprS /muln_grepr big_ord_recl det_ublock -IHk; congr (_ * _). by rewrite cfunE trace_mx11 mxE Gx. Qed. Lemma cfDet_id xi : xi \is a linear_char -> cfDet xi = xi. Proof. move=> lin_xi; have /irrP[i Dxi] := lin_char_irr lin_xi. apply/cfun_inP=> x Gx; rewrite Dxi -irrRepr cfDetRepr !cfunE trace_mx11 mxE. move: lin_xi (_ x) => /andP[_]; rewrite Dxi irr1_degree pnatr_eq1 => /eqP-> X. by rewrite {1}[X]mx11_scalar det_scalar1 trace_mx11. Qed. Definition cfDet_order phi := #[cfDet phi]%CF. Definition cfDet_order_lin xi : xi \is a linear_char -> cfDet_order xi = #[xi]%CF. Proof. by rewrite /cfDet_order => /cfDet_id->. Qed. Definition cfDet_order_dvdG phi : cfDet_order phi %| #|G|. Proof. by rewrite cforder_lin_char_dvdG ?cfDet_lin_char. Qed. End DetOrder. Notation "''o' ( phi )" := (cfDet_order phi) (format "''o' ( phi )") : cfun_scope. Section CfDetOps. Implicit Types gT aT rT : finGroupType. Lemma cfDetRes gT (G H : {group gT}) phi : phi \is a character -> cfDet ('Res[H, G] phi) = 'Res (cfDet phi). Proof. move=> Nphi; have [sGH | not_sHG] := boolP (H \subset G); last first. have /natrP[n Dphi1] := Cnat_char1 Nphi. rewrite !cfResEout // Dphi1 lin_char1 ?cfDet_lin_char // scale1r. by rewrite scaler_nat cfDetMn ?cfDet_id ?rpred1 // expr1n. have [rG ->] := char_reprP Nphi; rewrite !(=^~ cfRepr_sub, cfDetRepr) //. apply: cfRepr_sim; exists 1%:M; rewrite ?row_free_unit ?unitmx1 // => x Hx. by rewrite mulmx1 mul1mx. Qed. Lemma cfDetMorph aT rT (D G : {group aT}) (f : {morphism D >-> rT}) (phi : 'CF(f @* G)) : phi \is a character -> cfDet (cfMorph phi) = cfMorph (cfDet phi). Proof. move=> Nphi; have [sGD | not_sGD] := boolP (G \subset D); last first. have /natrP[n Dphi1] := Cnat_char1 Nphi. rewrite !cfMorphEout // Dphi1 lin_char1 ?cfDet_lin_char // scale1r. by rewrite scaler_nat cfDetMn ?cfDet_id ?rpred1 // expr1n. have [rG ->] := char_reprP Nphi; rewrite !(=^~ cfRepr_morphim, cfDetRepr) //. apply: cfRepr_sim; exists 1%:M; rewrite ?row_free_unit ?unitmx1 // => x Hx. by rewrite mulmx1 mul1mx. Qed. Lemma cfDetIsom aT rT (G : {group aT}) (R : {group rT}) (f : {morphism G >-> rT}) (isoGR : isom G R f) phi : cfDet (cfIsom isoGR phi) = cfIsom isoGR (cfDet phi). Proof. rewrite unlock rmorph_prod (reindex (isom_Iirr isoGR)); last first. by exists (isom_Iirr (isom_sym isoGR)) => i; rewrite ?isom_IirrK ?isom_IirrKV. apply: eq_bigr=> i; rewrite -!cfDetRepr !irrRepr isom_IirrE rmorphXn cfIsom_iso. by rewrite /= ![in cfIsom _]unlock cfDetMorph ?cfRes_char ?cfDetRes ?irr_char. Qed. Lemma cfDet_mul_lin gT (G : {group gT}) (lambda phi : 'CF(G)) : lambda \is a linear_char -> phi \is a character -> cfDet (lambda * phi) = lambda ^+ Num.truncn (phi 1%g) * cfDet phi. Proof. case/andP=> /char_reprP[[n1 rG1] ->] /= n1_1 /char_reprP[[n2 rG2] ->] /=. do [rewrite !cfRepr1 pnatr_eq1 natrK; move/eqP] in n1_1 *. rewrite {n1}n1_1 in rG1 *; rewrite cfRepr_prod cfDetRepr. apply/cfun_inP=> x Gx; rewrite !cfunE cfDetRepr cfunE Gx !mulrb !trace_mx11. rewrite !mxE prod_repr_lin ?mulrb //=; case: _ / (esym _); rewrite detZ. congr (_ * _); case: {rG2}n2 => [|n2]; first by rewrite cfun1E Gx. by rewrite expS_cfunE //= cfunE Gx trace_mx11. Qed. End CfDetOps. Definition cfcenter (gT : finGroupType) (G : {set gT}) (phi : 'CF(G)) := if phi \is a character then [set g in G | `|phi g| == phi 1%g] else cfker phi. Notation "''Z' ( phi )" := (cfcenter phi) : cfun_scope. Section Center. Variable (gT : finGroupType) (G : {group gT}). Implicit Types (phi chi : 'CF(G)) (H : {group gT}). (* This is Isaacs (2.27)(a). *) Lemma cfcenter_repr n (rG : mx_representation algC G n) : 'Z(cfRepr rG)%CF = rcenter rG. Proof. rewrite /cfcenter /rcenter cfRepr_char /=. apply/setP=> x /[!inE]; apply/andb_id2l=> Gx. apply/eqP/is_scalar_mxP=> [|[c rG_c]]. by case/max_cfRepr_norm_scalar=> // c; exists c. rewrite -(sqrCK (char1_ge0 (cfRepr_char rG))) normC_def; congr (sqrtC _). rewrite expr2 -{2}(mulgV x) -char_inv ?cfRepr_char ?cfunE ?groupM ?groupV //. rewrite Gx group1 repr_mx1 repr_mxM ?repr_mxV ?groupV // !mulrb rG_c. by rewrite invmx_scalar -scalar_mxM !mxtrace_scalar mulrnAr mulrnAl mulr_natl. Qed. (* This is part of Isaacs (2.27)(b). *) Fact cfcenter_group_set phi : group_set ('Z(phi))%CF. Proof. have [[rG ->] | /negbTE notNphi] := altP (@char_reprP _ G phi). by rewrite cfcenter_repr groupP. by rewrite /cfcenter notNphi groupP. Qed. Canonical cfcenter_group f := Group (cfcenter_group_set f). Lemma char_cfcenterE chi x : chi \is a character -> x \in G -> (x \in ('Z(chi))%CF) = (`|chi x| == chi 1%g). Proof. by move=> Nchi Gx; rewrite /cfcenter Nchi inE Gx. Qed. Lemma irr_cfcenterE i x : x \in G -> (x \in 'Z('chi[G]_i)%CF) = (`|'chi_i x| == 'chi_i 1%g). Proof. by move/char_cfcenterE->; rewrite ?irr_char. Qed. (* This is also Isaacs (2.27)(b). *) Lemma cfcenter_sub phi : ('Z(phi))%CF \subset G. Proof. by rewrite /cfcenter /cfker !setIdE -fun_if subsetIl. Qed. Lemma cfker_center_normal phi : cfker phi <| 'Z(phi)%CF. Proof. apply: normalS (cfcenter_sub phi) (cfker_normal phi). rewrite /= /cfcenter; case: ifP => // Hphi; rewrite cfkerEchar //. apply/subsetP=> x /[!inE] /andP[-> /eqP->] /=. by rewrite ger0_norm ?char1_ge0. Qed. Lemma cfcenter_normal phi : 'Z(phi)%CF <| G. Proof. have [[rG ->] | /negbTE notNphi] := altP (@char_reprP _ _ phi). by rewrite cfcenter_repr rcenter_normal. by rewrite /cfcenter notNphi cfker_normal. Qed. (* This is Isaacs (2.27)(c). *) Lemma cfcenter_Res chi : exists2 chi1, chi1 \is a linear_char & 'Res['Z(chi)%CF] chi = chi 1%g *: chi1. Proof. have [[rG ->] | /negbTE notNphi] := altP (@char_reprP _ _ chi); last first. exists 1; first exact: cfun1_lin_char. rewrite /cfcenter notNphi; apply/cfun_inP=> x Kx. by rewrite cfunE cfun1E Kx mulr1 cfResE ?cfker_sub // cfker1. rewrite cfcenter_repr -(cfRepr_sub _ (normal_sub (rcenter_normal _))). case: rG => [[|n] rG] /=; rewrite cfRepr1. exists 1; first exact: cfun1_lin_char. by apply/cfun_inP=> x Zx; rewrite scale0r !cfunE flatmx0 raddf0 Zx. pose rZmx x := ((rG x 0 0)%:M : 'M_(1,1)). have rZmxP: mx_repr [group of rcenter rG] rZmx. split=> [|x y]; first by rewrite /rZmx repr_mx1 mxE eqxx. move=> /setIdP[Gx /is_scalar_mxP[a rGx]] /setIdP[Gy /is_scalar_mxP[b rGy]]. by rewrite /rZmx repr_mxM // rGx rGy -!scalar_mxM !mxE. exists (cfRepr (MxRepresentation rZmxP)). by rewrite qualifE/= cfRepr_char cfRepr1 eqxx. apply/cfun_inP=> x Zx; rewrite !cfunE Zx /= /rZmx mulr_natl. by case/setIdP: Zx => Gx /is_scalar_mxP[a ->]; rewrite mxE !mxtrace_scalar. Qed. (* This is Isaacs (2.27)(d). *) Lemma cfcenter_cyclic chi : cyclic ('Z(chi)%CF / cfker chi)%g. Proof. case Nchi: (chi \is a character); last first. by rewrite /cfcenter Nchi trivg_quotient cyclic1. have [-> | nz_chi] := eqVneq chi 0. rewrite quotientS1 ?cyclic1 //= /cfcenter cfkerEchar ?cfun0_char //. by apply/subsetP=> x /setIdP[Gx _]; rewrite inE Gx /= !cfunE. have [xi Lxi def_chi] := cfcenter_Res chi. set Z := ('Z(_))%CF in xi Lxi def_chi *. have sZG: Z \subset G by apply: cfcenter_sub. have ->: cfker chi = cfker xi. rewrite -(setIidPr (normal_sub (cfker_center_normal _))) -/Z. rewrite !cfkerEchar // ?lin_charW //= -/Z. apply/setP=> x /[!inE]; apply: andb_id2l => Zx. rewrite (subsetP sZG) //= -!(cfResE chi sZG) ?group1 // def_chi !cfunE. by rewrite (inj_eq (mulfI _)) ?char1_eq0. have: abelian (Z / cfker xi) by rewrite sub_der1_abelian ?lin_char_der1. have /irr_reprP[rG irrG ->] := lin_char_irr Lxi; rewrite cfker_repr. apply: mx_faithful_irr_abelian_cyclic (kquo_mx_faithful rG) _. exact/quo_mx_irr. Qed. (* This is Isaacs (2.27)(e). *) Lemma cfcenter_subset_center chi : ('Z(chi)%CF / cfker chi)%g \subset 'Z(G / cfker chi)%g. Proof. case Nchi: (chi \is a character); last first. by rewrite /cfcenter Nchi trivg_quotient sub1G. rewrite subsetI quotientS ?cfcenter_sub // quotient_cents2r //=. case/char_reprP: Nchi => rG ->{chi}; rewrite cfker_repr cfcenter_repr gen_subG. apply/subsetP=> _ /imset2P[x y /setIdP[Gx /is_scalar_mxP[c rGx]] Gy ->]. rewrite inE groupR //= !repr_mxM ?groupM ?groupV // rGx -(scalar_mxC c) -rGx. by rewrite !mulmxA !repr_mxKV. Qed. (* This is Isaacs (2.27)(f). *) Lemma cfcenter_eq_center (i : Iirr G) : ('Z('chi_i)%CF / cfker 'chi_i)%g = 'Z(G / cfker 'chi_i)%g. Proof. apply/eqP; rewrite eqEsubset; rewrite cfcenter_subset_center ?irr_char //. apply/subsetP=> _ /setIP[/morphimP[x /= _ Gx ->] cGx]; rewrite mem_quotient //=. rewrite -irrRepr cfker_repr cfcenter_repr inE Gx in cGx *. apply: mx_abs_irr_cent_scalar 'Chi_i _ _ _; first exact/groupC/socle_irr. have nKG: G \subset 'N(rker 'Chi_i) by apply: rker_norm. (* GG -- locking here is critical to prevent Coq kernel divergence. *) apply/centgmxP=> y Gy; rewrite [eq]lock -2?(quo_repr_coset (subxx _) nKG) //. move: (quo_repr _ _) => rG; rewrite -2?repr_mxM ?mem_quotient // -lock. by rewrite (centP cGx) // mem_quotient. Qed. (* This is Isaacs (2.28). *) Lemma cap_cfcenter_irr : \bigcap_i 'Z('chi[G]_i)%CF = 'Z(G). Proof. apply/esym/eqP; rewrite eqEsubset (introT bigcapsP) /= => [|i _]; last first. rewrite -(quotientSGK _ (normal_sub (cfker_center_normal _))). by rewrite cfcenter_eq_center morphim_center. by rewrite subIset // normal_norm // cfker_normal. set Z := \bigcap_i _. have sZG: Z \subset G by rewrite (bigcap_min 0) ?cfcenter_sub. rewrite subsetI sZG (sameP commG1P trivgP) -(TI_cfker_irr G). apply/bigcapsP=> i _; have nKiG := normal_norm (cfker_normal 'chi_i). rewrite -quotient_cents2 ?(subset_trans sZG) //. rewrite (subset_trans (quotientS _ (bigcap_inf i _))) //. by rewrite cfcenter_eq_center subsetIr. Qed. (* This is Isaacs (2.29). *) Lemma cfnorm_Res_leif H phi : H \subset G -> '['Res[H] phi] <= #|G : H|%:R * '[phi] ?= iff (phi \in 'CF(G, H)). Proof. move=> sHG; rewrite cfun_onE mulrCA natf_indexg // -mulrA mulKf ?neq0CG //. rewrite (big_setID H) (setIidPr sHG) /= addrC. rewrite (mono_leif (ler_pM2l _)) ?invr_gt0 ?gt0CG // -leifBLR -sumrB. rewrite big1 => [|x Hx]; last by rewrite !cfResE ?subrr. have ->: (support phi \subset H) = (G :\: H \subset [set x | phi x == 0]). rewrite subDset setUC -subDset; apply: eq_subset => x. by rewrite !inE (andb_idr (contraR _)) // => /cfun0->. rewrite (sameP subsetP forall_inP); apply: leif_0_sum => x _. by rewrite !inE /<?=%R mul_conjC_ge0 eq_sym mul_conjC_eq0. Qed. (* This is Isaacs (2.30). *) Lemma irr1_bound (i : Iirr G) : ('chi_i 1%g) ^+ 2 <= #|G : 'Z('chi_i)%CF|%:R ?= iff ('chi_i \in 'CF(G, 'Z('chi_i)%CF)). Proof. congr (_ <= _ ?= iff _): (cfnorm_Res_leif 'chi_i (cfcenter_sub 'chi_i)). have [xi Lxi ->] := cfcenter_Res 'chi_i. have /irrP[j ->] := lin_char_irr Lxi; rewrite cfdotZl cfdotZr cfdot_irr eqxx. by rewrite mulr1 irr1_degree conjC_nat. by rewrite cfdot_irr eqxx mulr1. Qed. (* This is Isaacs (2.31). *) Lemma irr1_abelian_bound (i : Iirr G) : abelian (G / 'Z('chi_i)%CF) -> ('chi_i 1%g) ^+ 2 = #|G : 'Z('chi_i)%CF|%:R. Proof. move=> AbGc; apply/eqP; rewrite irr1_bound cfun_onE; apply/subsetP=> x nz_chi_x. have Gx: x \in G by apply: contraR nz_chi_x => /cfun0->. have nKx := subsetP (normal_norm (cfker_normal 'chi_i)) _ Gx. rewrite -(quotientGK (cfker_center_normal _)) inE nKx inE /=. rewrite cfcenter_eq_center inE mem_quotient //=. apply/centP=> _ /morphimP[y nKy Gy ->]; apply/commgP; rewrite -morphR //=. set z := [~ x, y]; rewrite coset_id //. have: z \in 'Z('chi_i)%CF. apply: subsetP (mem_commg Gx Gy). by rewrite der1_min // normal_norm ?cfcenter_normal. rewrite -irrRepr cfker_repr cfcenter_repr !inE in nz_chi_x *. case/andP=> Gz /is_scalar_mxP[c Chi_z]; rewrite Gz Chi_z mul1mx /=. apply/eqP; congr _%:M; apply: (mulIf nz_chi_x); rewrite mul1r. rewrite -{2}(cfunJ _ x Gy) conjg_mulR -/z !cfunE Gx groupM // !{1}mulrb. by rewrite repr_mxM // Chi_z mul_mx_scalar mxtraceZ. Qed. (* This is Isaacs (2.32)(a). *) Lemma irr_faithful_center i : cfaithful 'chi[G]_i -> cyclic 'Z(G). Proof. rewrite (isog_cyclic (isog_center (quotient1_isog G))) /=. by move/trivgP <-; rewrite -cfcenter_eq_center cfcenter_cyclic. Qed. Lemma cfcenter_fful_irr i : cfaithful 'chi[G]_i -> 'Z('chi_i)%CF = 'Z(G). Proof. move/trivgP=> Ki1; have:= cfcenter_eq_center i; rewrite {}Ki1. have inj1: 'injm (@coset gT 1%g) by rewrite ker_coset. by rewrite -injm_center; first apply: injm_morphim_inj; rewrite ?norms1. Qed. (* This is Isaacs (2.32)(b). *) Lemma pgroup_cyclic_faithful (p : nat) : p.-group G -> cyclic 'Z(G) -> exists i, cfaithful 'chi[G]_i. Proof. pose Z := 'Ohm_1('Z(G)) => pG cycZG; have nilG := pgroup_nil pG. have [-> | ntG] := eqsVneq G [1]; first by exists 0; apply: cfker_sub. have{pG} [[p_pr _ _] pZ] := (pgroup_pdiv pG ntG, pgroupS (center_sub G) pG). have ntZ: 'Z(G) != [1] by rewrite center_nil_eq1. have{pZ} oZ: #|Z| = p by apply: Ohm1_cyclic_pgroup_prime. apply/existsP; apply: contraR ntZ => /existsPn-not_ffulG. rewrite -Ohm1_eq1 -subG1 /= -/Z -(TI_cfker_irr G); apply/bigcapsP=> i _. rewrite prime_meetG ?oZ // setIC meet_Ohm1 // meet_center_nil ?cfker_normal //. by rewrite -subG1 not_ffulG. Qed. End Center. Section Induced. Variables (gT : finGroupType) (G H : {group gT}). Implicit Types (phi : 'CF(G)) (chi : 'CF(H)). Lemma cfInd_char chi : chi \is a character -> 'Ind[G] chi \is a character. Proof. move=> Nchi; apply/forallP=> i; rewrite coord_cfdot -Frobenius_reciprocity //. by rewrite Cnat_cfdot_char ?cfRes_char ?irr_char. Qed. Lemma cfInd_eq0 chi : H \subset G -> chi \is a character -> ('Ind[G] chi == 0) = (chi == 0). Proof. move=> sHG Nchi; rewrite -!(char1_eq0) ?cfInd_char // cfInd1 //. by rewrite (mulrI_eq0 _ (mulfI _)) ?neq0CiG. Qed. Lemma Ind_irr_neq0 i : H \subset G -> 'Ind[G, H] 'chi_i != 0. Proof. by move/cfInd_eq0->; rewrite ?irr_neq0 ?irr_char. Qed. Definition Ind_Iirr (A B : {set gT}) i := cfIirr ('Ind[B, A] 'chi_i). Lemma constt_cfRes_irr i : {j | j \in irr_constt ('Res[H, G] 'chi_i)}. Proof. apply/sigW/neq0_has_constt/Res_irr_neq0. Qed. Lemma constt_cfInd_irr i : H \subset G -> {j | j \in irr_constt ('Ind[G, H] 'chi_i)}. Proof. by move=> sHG; apply/sigW/neq0_has_constt/Ind_irr_neq0. Qed. Lemma cfker_Res phi : H \subset G -> phi \is a character -> cfker ('Res[H] phi) = H :&: cfker phi. Proof. move=> sHG Nphi; apply/setP=> x; rewrite !cfkerEchar ?cfRes_char // !inE. by apply/andb_id2l=> Hx; rewrite (subsetP sHG) ?cfResE. Qed. (* This is Isaacs Lemma (5.11). *) Lemma cfker_Ind chi : H \subset G -> chi \is a character -> chi != 0 -> cfker ('Ind[G, H] chi) = gcore (cfker chi) G. Proof. move=> sHG Nchi nzchi; rewrite !cfker_nzcharE ?cfInd_char ?cfInd_eq0 //. apply/setP=> x; rewrite inE cfIndE // (can2_eq (mulVKf _) (mulKf _)) ?neq0CG //. rewrite cfInd1 // mulrA -natrM Lagrange // mulr_natl -sumr_const. apply/eqP/bigcapP=> [/normC_sum_upper ker_chiG_x y Gy | ker_chiG_x]. by rewrite mem_conjg inE ker_chiG_x ?groupV // => z _; apply: char1_ge_norm. by apply: eq_bigr => y /groupVr/ker_chiG_x; rewrite mem_conjgV inE => /eqP. Qed. Lemma cfker_Ind_irr i : H \subset G -> cfker ('Ind[G, H] 'chi_i) = gcore (cfker 'chi_i) G. Proof. by move/cfker_Ind->; rewrite ?irr_neq0 ?irr_char. Qed. End Induced. Arguments Ind_Iirr {gT A%_g} B%_g i%_R.
Defs.lean
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Patrick Massot -/ import Mathlib.Topology.Algebra.Monoid.Defs /-! # Definitions about topological groups In this file we define mixin classes `ContinuousInv`, `IsTopologicalGroup`, and `ContinuousDiv`, as well as their additive versions. These classes say that the corresponding operations are continuous: - `ContinuousInv G` says that `(·⁻¹)` is continuous on `G`; - `IsTopologicalGroup G` says that `(· * ·)` is continuous on `G × G` and `(·⁻¹)` is continuous on `G`; - `ContinuousDiv G` says that `(· / ·)` is continuous on `G`. For groups, `ContinuousDiv G` is equivalent to `IsTopologicalGroup G`, but we use the additive version `ContinuousSub` for types like `NNReal`, where subtraction is not given by `a - b = a + (-b)`. We also provide convenience dot notation lemmas like `ContinuousAt.neg`. -/ open scoped Topology universe u variable {G α X : Type*} [TopologicalSpace X] /-- Basic hypothesis to talk about a topological additive group. A topological additive group over `M`, for example, is obtained by requiring the instances `AddGroup M` and `ContinuousAdd M` and `ContinuousNeg M`. -/ class ContinuousNeg (G : Type u) [TopologicalSpace G] [Neg G] : Prop where continuous_neg : Continuous fun a : G => -a attribute [continuity, fun_prop] ContinuousNeg.continuous_neg /-- Basic hypothesis to talk about a topological group. A topological group over `M`, for example, is obtained by requiring the instances `Group M` and `ContinuousMul M` and `ContinuousInv M`. -/ @[to_additive (attr := continuity)] class ContinuousInv (G : Type u) [TopologicalSpace G] [Inv G] : Prop where continuous_inv : Continuous fun a : G => a⁻¹ attribute [continuity, fun_prop] ContinuousInv.continuous_inv export ContinuousInv (continuous_inv) export ContinuousNeg (continuous_neg) section ContinuousInv variable [TopologicalSpace G] [Inv G] [ContinuousInv G] /-- If a function converges to a value in a multiplicative topological group, then its inverse converges to the inverse of this value. For the version in topological groups with zero (including topological fields) assuming additionally that the limit is nonzero, use `Filter.Tendsto.inv₀`. -/ @[to_additive /-- If a function converges to a value in an additive topological group, then its negation converges to the negation of this value. -/] theorem Filter.Tendsto.inv {f : α → G} {l : Filter α} {y : G} (h : Tendsto f l (𝓝 y)) : Tendsto (fun x => (f x)⁻¹) l (𝓝 y⁻¹) := (continuous_inv.tendsto y).comp h variable {f : X → G} {s : Set X} {x : X} @[to_additive (attr := continuity, fun_prop)] theorem Continuous.inv (hf : Continuous f) : Continuous fun x => (f x)⁻¹ := continuous_inv.comp hf @[to_additive] nonrec theorem ContinuousWithinAt.inv (hf : ContinuousWithinAt f s x) : ContinuousWithinAt (fun x => (f x)⁻¹) s x := hf.inv @[to_additive (attr := fun_prop)] nonrec theorem ContinuousAt.inv (hf : ContinuousAt f x) : ContinuousAt (fun x => (f x)⁻¹) x := hf.inv @[to_additive (attr := fun_prop)] theorem ContinuousOn.inv (hf : ContinuousOn f s) : ContinuousOn (fun x => (f x)⁻¹) s := fun x hx ↦ (hf x hx).inv end ContinuousInv /-- A topological (additive) group is a group in which the addition and negation operations are continuous. When you declare an instance that does not already have a `UniformSpace` instance, you should also provide an instance of `UniformSpace` and `IsUniformAddGroup` using `IsTopologicalAddGroup.toUniformSpace` and `isUniformAddGroup_of_addCommGroup`. -/ class IsTopologicalAddGroup (G : Type u) [TopologicalSpace G] [AddGroup G] : Prop extends ContinuousAdd G, ContinuousNeg G @[deprecated (since := "2025-02-14")] alias TopologicalAddGroup := IsTopologicalAddGroup /-- A topological group is a group in which the multiplication and inversion operations are continuous. When you declare an instance that does not already have a `UniformSpace` instance, you should also provide an instance of `UniformSpace` and `IsUniformGroup` using `IsTopologicalGroup.toUniformSpace` and `isUniformGroup_of_commGroup`. -/ @[to_additive] class IsTopologicalGroup (G : Type*) [TopologicalSpace G] [Group G] : Prop extends ContinuousMul G, ContinuousInv G @[deprecated (since := "2025-02-14")] alias TopologicalGroup := IsTopologicalGroup /-- A typeclass saying that `p : G × G ↦ p.1 - p.2` is a continuous function. This property automatically holds for topological additive groups but it also holds, e.g., for `ℝ≥0`. -/ class ContinuousSub (G : Type*) [TopologicalSpace G] [Sub G] : Prop where continuous_sub : Continuous fun p : G × G => p.1 - p.2 /-- A typeclass saying that `p : G × G ↦ p.1 / p.2` is a continuous function. This property automatically holds for topological groups. Lemmas using this class have primes. The unprimed version is for `GroupWithZero`. -/ @[to_additive existing] class ContinuousDiv (G : Type*) [TopologicalSpace G] [Div G] : Prop where continuous_div' : Continuous fun p : G × G => p.1 / p.2 -- see Note [lower instance priority] @[to_additive] instance (priority := 100) IsTopologicalGroup.to_continuousDiv {G : Type u} [TopologicalSpace G] [Group G] [IsTopologicalGroup G] : ContinuousDiv G where continuous_div' := by simp only [div_eq_mul_inv] exact continuous_mul.comp₂ continuous_fst <| continuous_inv.comp continuous_snd export ContinuousSub (continuous_sub) export ContinuousDiv (continuous_div') section ContinuousDiv variable [TopologicalSpace G] [Div G] [ContinuousDiv G] @[to_additive sub] theorem Filter.Tendsto.div' {f g : α → G} {l : Filter α} {a b : G} (hf : Tendsto f l (𝓝 a)) (hg : Tendsto g l (𝓝 b)) : Tendsto (fun x => f x / g x) l (𝓝 (a / b)) := (continuous_div'.tendsto (a, b)).comp (hf.prodMk_nhds hg) variable {f g : X → G} {s : Set X} {x : X} @[to_additive (attr := fun_prop) sub] nonrec theorem ContinuousAt.div' (hf : ContinuousAt f x) (hg : ContinuousAt g x) : ContinuousAt (fun x => f x / g x) x := hf.div' hg @[to_additive sub] theorem ContinuousWithinAt.div' (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) : ContinuousWithinAt (fun x => f x / g x) s x := Filter.Tendsto.div' hf hg @[to_additive (attr := fun_prop) sub] theorem ContinuousOn.div' (hf : ContinuousOn f s) (hg : ContinuousOn g s) : ContinuousOn (fun x => f x / g x) s := fun x hx => (hf x hx).div' (hg x hx) @[to_additive (attr := continuity, fun_prop) sub] theorem Continuous.div' (hf : Continuous f) (hg : Continuous g) : Continuous fun x => f x / g x := continuous_div'.comp₂ hf hg end ContinuousDiv
Linear.lean
/- Copyright (c) 2023 Oliver Nash. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Oliver Nash -/ import Mathlib.Algebra.Lie.Weights.Basic import Mathlib.LinearAlgebra.Trace import Mathlib.LinearAlgebra.FreeModule.PID /-! # Lie modules with linear weights Given a Lie module `M` over a nilpotent Lie algebra `L` with coefficients in `R`, one frequently studies `M` via its weights. These are functions `χ : L → R` whose corresponding weight space `LieModule.genWeightSpace M χ`, is non-trivial. If `L` is Abelian or if `R` has characteristic zero (and `M` is finite-dimensional) then such `χ` are necessarily `R`-linear. However in general non-linear weights do exist. For example if we take: * `R`: the field with two elements (or indeed any perfect field of characteristic two), * `L`: `sl₂` (this is nilpotent in characteristic two), * `M`: the natural two-dimensional representation of `L`, then there is a single weight and it is non-linear. (See remark following Proposition 9 of chapter VII, §1.3 in [N. Bourbaki, Chapters 7--9](bourbaki1975b).) We thus introduce a typeclass `LieModule.LinearWeights` to encode the fact that a Lie module does have linear weights and provide typeclass instances in the two important cases that `L` is Abelian or `R` has characteristic zero. ## Main definitions * `LieModule.LinearWeights`: a typeclass encoding the fact that a given Lie module has linear weights, and furthermore that the weights vanish on the derived ideal. * `LieModule.instLinearWeightsOfCharZero`: a typeclass instance encoding the fact that for an Abelian Lie algebra, the weights of any Lie module are linear. * `LieModule.instLinearWeightsOfIsLieAbelian`: a typeclass instance encoding the fact that in characteristic zero, the weights of any finite-dimensional Lie module are linear. * `LieModule.exists_forall_lie_eq_smul`: existence of simultaneous eigenvectors from existence of simultaneous generalized eigenvectors for Noetherian Lie modules with linear weights. -/ open Set variable (k R L M : Type*) [CommRing R] [LieRing L] [LieAlgebra R L] [AddCommGroup M] [Module R M] [LieRingModule L M] [LieModule R L M] namespace LieModule /-- A typeclass encoding the fact that a given Lie module has linear weights, vanishing on the derived ideal. -/ class LinearWeights [LieRing.IsNilpotent L] : Prop where map_add : ∀ χ : L → R, genWeightSpace M χ ≠ ⊥ → ∀ x y, χ (x + y) = χ x + χ y map_smul : ∀ χ : L → R, genWeightSpace M χ ≠ ⊥ → ∀ (t : R) x, χ (t • x) = t • χ x map_lie : ∀ χ : L → R, genWeightSpace M χ ≠ ⊥ → ∀ x y : L, χ ⁅x, y⁆ = 0 namespace Weight variable [LieRing.IsNilpotent L] [LinearWeights R L M] (χ : Weight R L M) /-- A weight of a Lie module, bundled as a linear map. -/ @[simps] def toLinear : L →ₗ[R] R where toFun := χ map_add' := LinearWeights.map_add χ χ.genWeightSpace_ne_bot map_smul' := LinearWeights.map_smul χ χ.genWeightSpace_ne_bot instance instCoeLinearMap : CoeOut (Weight R L M) (L →ₗ[R] R) where coe := Weight.toLinear R L M instance instLinearMapClass : LinearMapClass (Weight R L M) R L R where map_add χ := LinearWeights.map_add χ χ.genWeightSpace_ne_bot map_smulₛₗ χ := LinearWeights.map_smul χ χ.genWeightSpace_ne_bot variable {R L M χ} @[simp] lemma apply_lie (x y : L) : χ ⁅x, y⁆ = 0 := LinearWeights.map_lie χ χ.genWeightSpace_ne_bot x y @[simp] lemma coe_coe : (↑(χ : L →ₗ[R] R) : L → R) = (χ : L → R) := rfl @[simp] lemma coe_toLinear_eq_zero_iff : (χ : L →ₗ[R] R) = 0 ↔ χ.IsZero := ⟨fun h ↦ funext fun x ↦ LinearMap.congr_fun h x, fun h ↦ by ext; simp [h.eq]⟩ lemma coe_toLinear_ne_zero_iff : (χ : L →ₗ[R] R) ≠ 0 ↔ χ.IsNonZero := by simp /-- The kernel of a weight of a Lie module with linear weights. -/ abbrev ker := LinearMap.ker (χ : L →ₗ[R] R) end Weight /-- For an Abelian Lie algebra, the weights of any Lie module are linear. -/ instance instLinearWeightsOfIsLieAbelian [IsLieAbelian L] [NoZeroSMulDivisors R M] : LinearWeights R L M := have aux : ∀ (χ : L → R), genWeightSpace M χ ≠ ⊥ → ∀ (x y : L), χ (x + y) = χ x + χ y := by have h : ∀ x y, Commute (toEnd R L M x) (toEnd R L M y) := fun x y ↦ by rw [commute_iff_lie_eq, ← LieHom.map_lie, trivial_lie_zero, LieHom.map_zero] intro χ hχ x y simp_rw [Ne, ← LieSubmodule.toSubmodule_inj, genWeightSpace, genWeightSpaceOf, LieSubmodule.iInf_toSubmodule, LieSubmodule.bot_toSubmodule] at hχ exact Module.End.map_add_of_iInf_genEigenspace_ne_bot_of_commute (toEnd R L M).toLinearMap χ _ hχ h x y { map_add := aux map_smul := fun χ hχ t x ↦ by simp_rw [Ne, ← LieSubmodule.toSubmodule_inj, genWeightSpace, genWeightSpaceOf, LieSubmodule.iInf_toSubmodule, LieSubmodule.bot_toSubmodule] at hχ exact Module.End.map_smul_of_iInf_genEigenspace_ne_bot (toEnd R L M).toLinearMap χ _ hχ t x map_lie := fun χ hχ t x ↦ by rw [trivial_lie_zero, ← add_left_inj (χ 0), ← aux χ hχ, zero_add, zero_add] } section FiniteDimensional open Module variable [IsDomain R] [IsPrincipalIdealRing R] [Module.Free R M] [Module.Finite R M] [LieRing.IsNilpotent L] lemma trace_comp_toEnd_genWeightSpace_eq (χ : L → R) : LinearMap.trace R _ ∘ₗ (toEnd R L (genWeightSpace M χ)).toLinearMap = finrank R (genWeightSpace M χ) • χ := by ext x simp variable {R L M} in lemma zero_lt_finrank_genWeightSpace {χ : L → R} (hχ : genWeightSpace M χ ≠ ⊥) : 0 < finrank R (genWeightSpace M χ) := by rwa [← LieSubmodule.nontrivial_iff_ne_bot, ← rank_pos_iff_nontrivial (R := R), ← finrank_eq_rank, Nat.cast_pos] at hχ /-- In characteristic zero, the weights of any finite-dimensional Lie module are linear and vanish on the derived ideal. -/ instance instLinearWeightsOfCharZero [CharZero R] : LinearWeights R L M where map_add χ hχ x y := by rw [← smul_right_inj (zero_lt_finrank_genWeightSpace hχ).ne', smul_add, ← Pi.smul_apply, ← Pi.smul_apply, ← Pi.smul_apply, ← trace_comp_toEnd_genWeightSpace_eq, map_add] map_smul χ hχ t x := by rw [← smul_right_inj (zero_lt_finrank_genWeightSpace hχ).ne', smul_comm, ← Pi.smul_apply, ← Pi.smul_apply (finrank R _), ← trace_comp_toEnd_genWeightSpace_eq, map_smul] map_lie χ hχ x y := by rw [← smul_right_inj (zero_lt_finrank_genWeightSpace hχ).ne', nsmul_zero, ← Pi.smul_apply, ← trace_comp_toEnd_genWeightSpace_eq, LinearMap.comp_apply, LieHom.coe_toLinearMap, LieHom.map_lie, Ring.lie_def, map_sub, LinearMap.trace_mul_comm, sub_self] end FiniteDimensional variable [LieRing.IsNilpotent L] (χ : L → R) /-- A type synonym for the `χ`-weight space but with the action of `x : L` on `m : genWeightSpace M χ`, shifted to act as `⁅x, m⁆ - χ x • m`. -/ def shiftedGenWeightSpace := genWeightSpace M χ namespace shiftedGenWeightSpace private lemma aux [h : Nontrivial (shiftedGenWeightSpace R L M χ)] : genWeightSpace M χ ≠ ⊥ := (LieSubmodule.nontrivial_iff_ne_bot _ _ _).mp h variable [LinearWeights R L M] instance : LieRingModule L (shiftedGenWeightSpace R L M χ) where bracket x m := ⁅x, m⁆ - χ x • m add_lie x y m := by nontriviality shiftedGenWeightSpace R L M χ simp only [add_lie, LinearWeights.map_add χ (aux R L M χ), add_smul] abel lie_add x m n := by nontriviality shiftedGenWeightSpace R L M χ simp only [lie_add, smul_add] abel leibniz_lie x y m := by nontriviality shiftedGenWeightSpace R L M χ simp only [lie_sub, lie_smul, lie_lie, LinearWeights.map_lie χ (aux R L M χ), zero_smul, sub_zero, smul_sub, smul_comm (χ x)] abel @[simp] lemma coe_lie_shiftedGenWeightSpace_apply (x : L) (m : shiftedGenWeightSpace R L M χ) : letI : Bracket L (shiftedGenWeightSpace R L M χ) := LieRingModule.toBracket ⁅x, m⁆ = ⁅x, (m : M)⁆ - χ x • m := rfl instance : LieModule R L (shiftedGenWeightSpace R L M χ) where smul_lie t x m := by nontriviality shiftedGenWeightSpace R L M χ apply Subtype.ext rw [coe_lie_shiftedGenWeightSpace_apply] simp only [smul_lie, LinearWeights.map_smul χ (aux R L M χ), smul_assoc t, SetLike.val_smul] rw [← smul_sub] congr lie_smul t x m := by nontriviality shiftedGenWeightSpace R L M χ apply Subtype.ext rw [coe_lie_shiftedGenWeightSpace_apply] simp only [SetLike.val_smul, lie_smul] rw [smul_comm (χ x), ← smul_sub] congr /-- Forgetting the action of `L`, the spaces `genWeightSpace M χ` and `shiftedGenWeightSpace R L M χ` are equivalent. -/ @[simps!] def shift : genWeightSpace M χ ≃ₗ[R] shiftedGenWeightSpace R L M χ := LinearEquiv.refl R _ lemma toEnd_eq (x : L) : toEnd R L (shiftedGenWeightSpace R L M χ) x = (shift R L M χ).conj (toEnd R L (genWeightSpace M χ) x - χ x • LinearMap.id) := by tauto /-- By Engel's theorem, if `M` is Noetherian, the shifted action `⁅x, m⁆ - χ x • m` makes the `χ`-weight space into a nilpotent Lie module. -/ instance [IsNoetherian R M] : IsNilpotent L (shiftedGenWeightSpace R L M χ) := LieModule.isNilpotent_iff_forall'.mpr fun x ↦ isNilpotent_toEnd_sub_algebraMap M χ x end shiftedGenWeightSpace open shiftedGenWeightSpace in /-- Given a Lie module `M` of a nilpotent Lie algebra `L` with coefficients in `R`, if a function `χ : L → R` has a simultaneous generalized eigenvector for the action of `L` then it has a simultaneous true eigenvector, provided `M` is Noetherian and has linear weights. -/ lemma exists_forall_lie_eq_smul [LinearWeights R L M] [IsNoetherian R M] (χ : Weight R L M) : ∃ m : M, m ≠ 0 ∧ ∀ x : L, ⁅x, m⁆ = χ x • m := by replace hχ : Nontrivial (shiftedGenWeightSpace R L M χ) := (LieSubmodule.nontrivial_iff_ne_bot R L M).mpr χ.genWeightSpace_ne_bot obtain ⟨⟨⟨m, _⟩, hm₁⟩, hm₂⟩ := @exists_ne _ (nontrivial_max_triv_of_isNilpotent R L (shiftedGenWeightSpace R L M χ)) 0 simp_rw [mem_maxTrivSubmodule, Subtype.ext_iff, ZeroMemClass.coe_zero] at hm₁ refine ⟨m, by simpa [LieSubmodule.mk_eq_zero] using hm₂, ?_⟩ intro x have := hm₁ x rwa [coe_lie_shiftedGenWeightSpace_apply, sub_eq_zero] at this /-- See `LieModule.exists_nontrivial_weightSpace_of_isSolvable` for the variant that only assumes that `L` is solvable but additionally requires `k` to be of characteristic zero. -/ lemma exists_nontrivial_weightSpace_of_isNilpotent [Field k] [LieAlgebra k L] [Module k M] [Module.Finite k M] [LieModule k L M] [LinearWeights k L M] [IsTriangularizable k L M] [Nontrivial M] : ∃ χ : Module.Dual k L, Nontrivial (weightSpace M χ) := by obtain ⟨χ⟩ : Nonempty (Weight k L M) := by by_contra contra rw [not_nonempty_iff] at contra simpa only [iSup_of_empty, bot_ne_top] using LieModule.iSup_genWeightSpace_eq_top' k L M obtain ⟨m, hm₀, hm⟩ := exists_forall_lie_eq_smul k L M χ simp only [LieSubmodule.nontrivial_iff_ne_bot, LieSubmodule.eq_bot_iff, ne_eq, not_forall] exact ⟨χ.toLinear, m, by simpa [mem_weightSpace], hm₀⟩ end LieModule
Fubini.lean
/- Copyright (c) 2020 Kim Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kim Morrison -/ import Mathlib.CategoryTheory.Limits.HasLimits import Mathlib.CategoryTheory.Products.Basic import Mathlib.CategoryTheory.Functor.Currying import Mathlib.CategoryTheory.Products.Bifunctor /-! # A Fubini theorem for categorical (co)limits We prove that $lim_{J × K} G = lim_J (lim_K G(j, -))$ for a functor `G : J × K ⥤ C`, when all the appropriate limits exist. We begin working with a functor `F : J ⥤ K ⥤ C`. We'll write `G : J × K ⥤ C` for the associated "uncurried" functor. In the first part, given a coherent family `D` of limit cones over the functors `F.obj j`, and a cone `c` over `G`, we construct a cone over the cone points of `D`. We then show that if `c` is a limit cone, the constructed cone is also a limit cone. In the second part, we state the Fubini theorem in the setting where limits are provided by suitable `HasLimit` classes. We construct `limitUncurryIsoLimitCompLim F : limit (uncurry.obj F) ≅ limit (F ⋙ lim)` and give simp lemmas characterising it. For convenience, we also provide `limitIsoLimitCurryCompLim G : limit G ≅ limit ((curry.obj G) ⋙ lim)` in terms of the uncurried functor. All statements have their counterpart for colimits. -/ open CategoryTheory Functor namespace CategoryTheory.Limits variable {J K : Type*} [Category J] [Category K] variable {C : Type*} [Category C] variable (F : J ⥤ K ⥤ C) (G : J × K ⥤ C) -- We could try introducing a "dependent functor type" to handle this? /-- A structure carrying a diagram of cones over the functors `F.obj j`. -/ structure DiagramOfCones where /-- For each object, a cone. -/ obj : ∀ j : J, Cone (F.obj j) /-- For each map, a map of cones. -/ map : ∀ {j j' : J} (f : j ⟶ j'), (Cones.postcompose (F.map f)).obj (obj j) ⟶ obj j' id : ∀ j : J, (map (𝟙 j)).hom = 𝟙 _ := by cat_disch comp : ∀ {j₁ j₂ j₃ : J} (f : j₁ ⟶ j₂) (g : j₂ ⟶ j₃), (map (f ≫ g)).hom = (map f).hom ≫ (map g).hom := by cat_disch /-- A structure carrying a diagram of cocones over the functors `F.obj j`. -/ structure DiagramOfCocones where /-- For each object, a cocone. -/ obj : ∀ j : J, Cocone (F.obj j) /-- For each map, a map of cocones. -/ map : ∀ {j j' : J} (f : j ⟶ j'), (obj j) ⟶ (Cocones.precompose (F.map f)).obj (obj j') id : ∀ j : J, (map (𝟙 j)).hom = 𝟙 _ := by cat_disch comp : ∀ {j₁ j₂ j₃ : J} (f : j₁ ⟶ j₂) (g : j₂ ⟶ j₃), (map (f ≫ g)).hom = (map f).hom ≫ (map g).hom := by cat_disch variable {F} /-- Extract the functor `J ⥤ C` consisting of the cone points and the maps between them, from a `DiagramOfCones`. -/ @[simps] def DiagramOfCones.conePoints (D : DiagramOfCones F) : J ⥤ C where obj j := (D.obj j).pt map f := (D.map f).hom map_id j := D.id j map_comp f g := D.comp f g /-- Extract the functor `J ⥤ C` consisting of the cocone points and the maps between them, from a `DiagramOfCocones`. -/ @[simps] def DiagramOfCocones.coconePoints (D : DiagramOfCocones F) : J ⥤ C where obj j := (D.obj j).pt map f := (D.map f).hom map_id j := D.id j map_comp f g := D.comp f g /-- Given a diagram `D` of limit cones over the `F.obj j`, and a cone over `uncurry.obj F`, we can construct a cone over the diagram consisting of the cone points from `D`. -/ @[simps] def coneOfConeUncurry {D : DiagramOfCones F} (Q : ∀ j, IsLimit (D.obj j)) (c : Cone (uncurry.obj F)) : Cone D.conePoints where pt := c.pt π := { app := fun j => (Q j).lift { pt := c.pt π := { app := fun k => c.π.app (j, k) naturality := fun k k' f => by dsimp; simp only [Category.id_comp] have := @NatTrans.naturality _ _ _ _ _ _ c.π (j, k) (j, k') (𝟙 j, f) dsimp at this simp? at this says simp only [Category.id_comp, Functor.map_id, NatTrans.id_app] at this exact this } } naturality := fun j j' f => (Q j').hom_ext (by dsimp intro k simp only [Limits.ConeMorphism.w, Limits.Cones.postcompose_obj_π, Limits.IsLimit.fac_assoc, Limits.IsLimit.fac, NatTrans.comp_app, Category.id_comp, Category.assoc] have := @NatTrans.naturality _ _ _ _ _ _ c.π (j, k) (j', k) (f, 𝟙 k) dsimp at this simp only [Category.id_comp, Category.comp_id, CategoryTheory.Functor.map_id] at this exact this) } /-- Given a diagram `D` of limit cones over the `curry.obj G j`, and a cone over `G`, we can construct a cone over the diagram consisting of the cone points from `D`. -/ @[simps] def coneOfConeCurry {D : DiagramOfCones (curry.obj G)} (Q : ∀ j, IsLimit (D.obj j)) (c : Cone G) : Cone D.conePoints where pt := c.pt π := { app j := (Q j).lift { pt := c.pt π := { app k := c.π.app (j, k) } } naturality {_ j'} _ := (Q j').hom_ext (by simp) } open scoped Prod in /-- Given a diagram `D` of colimit cocones over the `F.obj j`, and a cocone over `uncurry.obj F`, we can construct a cocone over the diagram consisting of the cocone points from `D`. -/ @[simps] def coconeOfCoconeUncurry {D : DiagramOfCocones F} (Q : ∀ j, IsColimit (D.obj j)) (c : Cocone (uncurry.obj F)) : Cocone D.coconePoints where pt := c.pt ι := { app := fun j => (Q j).desc { pt := c.pt ι := { app := fun k => c.ι.app (j, k) naturality := fun k k' f => by dsimp; simp only [Category.comp_id] conv_lhs => arg 1; equals (F.map (𝟙 _)).app _ ≫ (F.obj j).map f => simp conv_lhs => arg 1; rw [← uncurry_obj_map F (𝟙 j ×ₘ f)] rw [c.w] } } naturality := fun j j' f => (Q j).hom_ext (by dsimp intro k simp only [Limits.CoconeMorphism.w_assoc, Limits.Cocones.precompose_obj_ι, Limits.IsColimit.fac, NatTrans.comp_app, Category.comp_id, Category.assoc] have := @NatTrans.naturality _ _ _ _ _ _ c.ι (j, k) (j', k) (f, 𝟙 k) dsimp at this simp only [Category.comp_id, CategoryTheory.Functor.map_id] at this exact this) } /-- Given a diagram `D` of colimit cocones under the `curry.obj G j`, and a cocone under `G`, we can construct a cocone under the diagram consisting of the cocone points from `D`. -/ @[simps] def coconeOfCoconeCurry {D : DiagramOfCocones (curry.obj G)} (Q : ∀ j, IsColimit (D.obj j)) (c : Cocone G) : Cocone D.coconePoints where pt := c.pt ι := { app j := (Q j).desc { pt := c.pt ι := { app k := c.ι.app (j, k) } } naturality {j _} _ := (Q j).hom_ext (by simp) } /-- `coneOfConeUncurry Q c` is a limit cone when `c` is a limit cone. -/ def coneOfConeUncurryIsLimit {D : DiagramOfCones F} (Q : ∀ j, IsLimit (D.obj j)) {c : Cone (uncurry.obj F)} (P : IsLimit c) : IsLimit (coneOfConeUncurry Q c) where lift s := P.lift { pt := s.pt π := { app := fun p => s.π.app p.1 ≫ (D.obj p.1).π.app p.2 naturality := fun p p' f => by dsimp; simp only [Category.id_comp, Category.assoc] rcases p with ⟨j, k⟩ rcases p' with ⟨j', k'⟩ rcases f with ⟨fj, fk⟩ dsimp slice_rhs 3 4 => rw [← NatTrans.naturality] slice_rhs 2 3 => rw [← (D.obj j).π.naturality] simp only [Functor.const_obj_map, Category.id_comp, Category.assoc] have w := (D.map fj).w k' dsimp at w rw [← w] have n := s.π.naturality fj dsimp at n simp only [Category.id_comp] at n rw [n] simp } } fac s j := by apply (Q j).hom_ext intro k simp uniq s m w := by refine P.uniq { pt := s.pt π := _ } m ?_ rintro ⟨j, k⟩ dsimp rw [← w j] simp /-- If `coneOfConeUncurry Q c` is a limit cone then `c` is in fact a limit cone. -/ def IsLimit.ofConeOfConeUncurry {D : DiagramOfCones F} (Q : ∀ j, IsLimit (D.obj j)) {c : Cone (uncurry.obj F)} (P : IsLimit (coneOfConeUncurry Q c)) : IsLimit c := -- These constructions are used in various fields of the proof so we abstract them here. letI E (j : J) : Prod.sectR j K ⋙ uncurry.obj F ≅ F.obj j := NatIso.ofComponents (fun _ ↦ Iso.refl _) letI S (s : Cone (uncurry.obj F)) : Cone D.conePoints := { pt := s.pt π := { app j := (Q j).lift <| (Cones.postcompose (E j).hom).obj <| s.whisker (Prod.sectR j K) naturality {j' j} f := (Q j).hom_ext <| fun k ↦ by simpa [E] using s.π.naturality ((Prod.sectL J k).map f) } } { lift s := P.lift (S s) fac s p := by have h1 := (Q p.1).fac ((Cones.postcompose (E p.1).hom).obj <| s.whisker (Prod.sectR p.1 K)) p.2 simp only [Functor.comp_obj, Prod.sectR_obj, uncurry_obj_obj, Cones.postcompose_obj_pt, Cone.whisker_pt, Cones.postcompose_obj_π, Cone.whisker_π, NatTrans.comp_app, Functor.const_obj_obj, whiskerLeft_app, NatIso.ofComponents_hom_app, Iso.refl_hom, Category.comp_id, E] at h1 have h2 := (P.fac (S s) p.1) dsimp only [Functor.comp_obj, Prod.sectR_obj, uncurry_obj_obj, NatTrans.id_app, Functor.const_obj_obj, DiagramOfCones.conePoints_obj, DiagramOfCones.conePoints_map, Functor.const_obj_map, id_eq, Cones.postcompose_obj_pt, Cone.whisker_pt, Cones.postcompose_obj_π, Cone.whisker_π, NatTrans.comp_app, whiskerLeft_app, NatIso.ofComponents_hom_app, Iso.refl_hom, Prod.sectL_obj, Prod.sectL_map, eq_mp_eq_cast, eq_mpr_eq_cast, coneOfConeUncurry_pt, coneOfConeUncurry_π_app, S, E] at h2 ⊢ simp [← h1, ← h2] uniq s f hf := P.uniq (s := S s) _ <| fun j ↦ (Q j).hom_ext <| fun k ↦ by simpa [S, E] using hf (j, k) } /-- `coconeOfCoconeUncurry Q c` is a colimit cocone when `c` is a colimit cocone. -/ def coconeOfCoconeUncurryIsColimit {D : DiagramOfCocones F} (Q : ∀ j, IsColimit (D.obj j)) {c : Cocone (uncurry.obj F)} (P : IsColimit c) : IsColimit (coconeOfCoconeUncurry Q c) where desc s := P.desc { pt := s.pt ι := { app := fun p => (D.obj p.1).ι.app p.2 ≫ s.ι.app p.1 naturality := fun p p' f => by dsimp; simp only [Category.assoc] rcases p with ⟨j, k⟩ rcases p' with ⟨j', k'⟩ rcases f with ⟨fj, fk⟩ dsimp slice_lhs 2 3 => rw [(D.obj j').ι.naturality] simp only [Functor.const_obj_map, Category.assoc] have w := (D.map fj).w k dsimp at w slice_lhs 1 2 => rw [← w] have n := s.ι.naturality fj dsimp at n simp only [Category.comp_id] at n rw [← n] simp } } fac s j := by apply (Q j).hom_ext intro k simp uniq s m w := by refine P.uniq { pt := s.pt ι := _ } m ?_ rintro ⟨j, k⟩ dsimp rw [← w j] simp /-- If `coconeOfCoconeUncurry Q c` is a colimit cocone then `c` is in fact a colimit cocone. -/ def IsColimit.ofCoconeUncurry {D : DiagramOfCocones F} (Q : ∀ j, IsColimit (D.obj j)) {c : Cocone (uncurry.obj F)} (P : IsColimit (coconeOfCoconeUncurry Q c)) : IsColimit c := -- These constructions are used in various fields of the proof so we abstract them here. letI E (j : J) : (Prod.sectR j K ⋙ uncurry.obj F ≅ F.obj j) := NatIso.ofComponents (fun _ ↦ Iso.refl _) letI S (s : Cocone (uncurry.obj F)) : Cocone D.coconePoints := { pt := s.pt ι := { app j := (Q j).desc <| (Cocones.precompose (E j).inv).obj <| s.whisker (Prod.sectR j K) naturality {j j'} f := (Q j).hom_ext <| fun k ↦ by simpa [E] using s.ι.naturality ((Prod.sectL J k).map f) } } { desc s := P.desc (S s) fac s p := by have h1 := (Q p.1).fac ((Cocones.precompose (E p.1).inv).obj <| s.whisker (Prod.sectR p.1 K)) p.2 simp only [Functor.comp_obj, Prod.sectR_obj, uncurry_obj_obj, Cocones.precompose_obj_pt, Cocone.whisker_pt, Functor.const_obj_obj, Cocones.precompose_obj_ι, Cocone.whisker_ι, NatTrans.comp_app, NatIso.ofComponents_inv_app, Iso.refl_inv, whiskerLeft_app, Category.id_comp, E] at h1 have h2 := (P.fac (S s) p.1) dsimp only [DiagramOfCocones.coconePoints_obj, Functor.comp_obj, Prod.sectR_obj, uncurry_obj_obj, NatTrans.id_app, Functor.const_obj_obj, DiagramOfCocones.coconePoints_map, Functor.const_obj_map, id_eq, Cocones.precompose_obj_pt, Cocone.whisker_pt, Cocones.precompose_obj_ι, Cocone.whisker_ι, NatTrans.comp_app, NatIso.ofComponents_inv_app, Iso.refl_inv, whiskerLeft_app, Prod.sectL_obj, Prod.sectL_map, eq_mp_eq_cast, eq_mpr_eq_cast, coconeOfCoconeUncurry_pt, coconeOfCoconeUncurry_ι_app, S, E] at h2 ⊢ simp [← h1, ← h2] uniq s f hf := P.uniq (s := S s) _ <| fun j ↦ (Q j).hom_ext <| fun k ↦ by simpa [S, E] using hf (j, k) } section variable (F) variable [HasLimitsOfShape K C] /-- Given a functor `F : J ⥤ K ⥤ C`, with all needed limits, we can construct a diagram consisting of the limit cone over each functor `F.obj j`, and the universal cone morphisms between these. -/ @[simps] noncomputable def DiagramOfCones.mkOfHasLimits : DiagramOfCones F where obj j := limit.cone (F.obj j) map f := { hom := lim.map (F.map f) } -- Satisfying the inhabited linter. noncomputable instance diagramOfConesInhabited : Inhabited (DiagramOfCones F) := ⟨DiagramOfCones.mkOfHasLimits F⟩ @[simp] theorem DiagramOfCones.mkOfHasLimits_conePoints : (DiagramOfCones.mkOfHasLimits F).conePoints = F ⋙ lim := rfl section variable [HasLimit (curry.obj G ⋙ lim)] /-- Given a functor `G : J × K ⥤ C` such that `(curry.obj G ⋙ lim)` makes sense and has a limit, we can construct a cone over `G` with `limit (curry.obj G ⋙ lim)` as a cone point -/ noncomputable def coneOfHasLimitCurryCompLim : Cone G := let Q : DiagramOfCones (curry.obj G) := .mkOfHasLimits _ { pt := limit (curry.obj G ⋙ lim), π := { app x := limit.π (curry.obj G ⋙ lim) x.fst ≫ (Q.obj x.fst).π.app x.snd naturality {x y} := fun ⟨f₁, f₂⟩ ↦ by have := (Q.obj x.1).w f₂ dsimp [Q] at this ⊢ rw [← limit.w (F := curry.obj G ⋙ lim) (f := f₁)] dsimp simp only [Category.assoc, Category.id_comp, Prod.fac (f₁, f₂), G.map_comp, limMap_π, curry_obj_map_app, reassoc_of% this] } } /-- The cone `coneOfHasLimitCurryCompLim` is in fact a limit cone. -/ noncomputable def isLimitConeOfHasLimitCurryCompLim : IsLimit (coneOfHasLimitCurryCompLim G) := let Q : DiagramOfCones (curry.obj G) := .mkOfHasLimits _ let Q' : ∀ j, IsLimit (Q.obj j) := fun j => limit.isLimit _ { lift c' := limit.lift (F := curry.obj G ⋙ lim) (coneOfConeCurry G Q' c') fac c' f := by simp [coneOfHasLimitCurryCompLim, Q, Q'] uniq c' f h := by dsimp [coneOfHasLimitCurryCompLim] at f h ⊢ refine limit.hom_ext (F := curry.obj G ⋙ lim) (fun j ↦ limit.hom_ext (fun k ↦ ?_)) simp [h ⟨j, k⟩, Q'] } /-- The functor `G` has a limit if `C` has `K`-shaped limits and `(curry.obj G ⋙ lim)` has a limit. -/ instance : HasLimit G where exists_limit := ⟨ { cone := coneOfHasLimitCurryCompLim G isLimit := isLimitConeOfHasLimitCurryCompLim G }⟩ end variable [HasLimit (uncurry.obj F)] [HasLimit (F ⋙ lim)] /-- The Fubini theorem for a functor `F : J ⥤ K ⥤ C`, showing that the limit of `uncurry.obj F` can be computed as the limit of the limits of the functors `F.obj j`. -/ noncomputable def limitUncurryIsoLimitCompLim : limit (uncurry.obj F) ≅ limit (F ⋙ lim) := by let c := limit.cone (uncurry.obj F) let P : IsLimit c := limit.isLimit _ let G := DiagramOfCones.mkOfHasLimits F let Q : ∀ j, IsLimit (G.obj j) := fun j => limit.isLimit _ have Q' := coneOfConeUncurryIsLimit Q P have Q'' := limit.isLimit (F ⋙ lim) exact IsLimit.conePointUniqueUpToIso Q' Q'' @[simp, reassoc] theorem limitUncurryIsoLimitCompLim_hom_π_π {j} {k} : (limitUncurryIsoLimitCompLim F).hom ≫ limit.π _ j ≫ limit.π _ k = limit.π _ (j, k) := by dsimp [limitUncurryIsoLimitCompLim, IsLimit.conePointUniqueUpToIso, IsLimit.uniqueUpToIso] simp @[simp, reassoc] theorem limitUncurryIsoLimitCompLim_inv_π {j} {k} : (limitUncurryIsoLimitCompLim F).inv ≫ limit.π _ (j, k) = (limit.π _ j ≫ limit.π _ k) := by rw [← cancel_epi (limitUncurryIsoLimitCompLim F).hom] simp end section variable (F) variable [HasColimitsOfShape K C] /-- Given a functor `F : J ⥤ K ⥤ C`, with all needed colimits, we can construct a diagram consisting of the colimit cocone over each functor `F.obj j`, and the universal cocone morphisms between these. -/ @[simps] noncomputable def DiagramOfCocones.mkOfHasColimits : DiagramOfCocones F where obj j := colimit.cocone (F.obj j) map f := { hom := colim.map (F.map f) } -- Satisfying the inhabited linter. noncomputable instance diagramOfCoconesInhabited : Inhabited (DiagramOfCocones F) := ⟨DiagramOfCocones.mkOfHasColimits F⟩ @[simp] theorem DiagramOfCocones.mkOfHasColimits_coconePoints : (DiagramOfCocones.mkOfHasColimits F).coconePoints = F ⋙ colim := rfl section variable [HasColimit (curry.obj G ⋙ colim)] /-- Given a functor `G : J × K ⥤ C` such that `(curry.obj G ⋙ colim)` makes sense and has a colimit, we can construct a cocone under `G` with `colimit (curry.obj G ⋙ colim)` as a cocone point -/ noncomputable def coconeOfHasColimitCurryCompColim : Cocone G := let Q : DiagramOfCocones (curry.obj G) := .mkOfHasColimits _ { pt := colimit (curry.obj G ⋙ colim), ι := { app x := (Q.obj x.fst).ι.app x.snd ≫ colimit.ι (curry.obj G ⋙ colim) x.fst naturality {x y} := fun ⟨f₁, f₂⟩ ↦ by have := (Q.obj y.1).w f₂ dsimp [Q] at this ⊢ rw [← colimit.w (F := curry.obj G ⋙ colim) (f := f₁), Category.assoc, Category.comp_id, Prod.fac' (f₁, f₂), G.map_comp_assoc, ← curry_obj_map_app, ← curry_obj_obj_map] dsimp simp [ι_colimMap_assoc, curry_obj_map_app, reassoc_of% this]} } /-- The cocone `coconeOfHasColimitCurryCompColim` is in fact a limit cocone. -/ noncomputable def isColimitCoconeOfHasColimitCurryCompColim : IsColimit (coconeOfHasColimitCurryCompColim G) := let Q : DiagramOfCocones (curry.obj G) := .mkOfHasColimits _ let Q' : ∀ j, IsColimit (Q.obj j) := fun j => colimit.isColimit _ { desc c' := colimit.desc (F := curry.obj G ⋙ colim) (coconeOfCoconeCurry G Q' c') fac c' f := by simp [coconeOfHasColimitCurryCompColim, Q, Q'] uniq c' f h := by dsimp [coconeOfHasColimitCurryCompColim] at f h ⊢ refine colimit.hom_ext (F := curry.obj G ⋙ colim) (fun j ↦ colimit.hom_ext (fun k ↦ ?_)) simp [← h ⟨j, k⟩, Q'] } /-- The functor `G` has a colimit if `C` has `K`-shaped colimits and `(curry.obj G ⋙ colim)` has a colimit. -/ instance : HasColimit G where exists_colimit := ⟨ { cocone := coconeOfHasColimitCurryCompColim G isColimit := isColimitCoconeOfHasColimitCurryCompColim G }⟩ end variable [HasColimit (uncurry.obj F)] [HasColimit (F ⋙ colim)] /-- The Fubini theorem for a functor `F : J ⥤ K ⥤ C`, showing that the colimit of `uncurry.obj F` can be computed as the colimit of the colimits of the functors `F.obj j`. -/ noncomputable def colimitUncurryIsoColimitCompColim : colimit (uncurry.obj F) ≅ colimit (F ⋙ colim) := by let c := colimit.cocone (uncurry.obj F) let P : IsColimit c := colimit.isColimit _ let G := DiagramOfCocones.mkOfHasColimits F let Q : ∀ j, IsColimit (G.obj j) := fun j => colimit.isColimit _ have Q' := coconeOfCoconeUncurryIsColimit Q P have Q'' := colimit.isColimit (F ⋙ colim) exact IsColimit.coconePointUniqueUpToIso Q' Q'' @[simp, reassoc] theorem colimitUncurryIsoColimitCompColim_ι_ι_inv {j} {k} : colimit.ι (F.obj j) k ≫ colimit.ι (F ⋙ colim) j ≫ (colimitUncurryIsoColimitCompColim F).inv = colimit.ι (uncurry.obj F) (j, k) := by dsimp [colimitUncurryIsoColimitCompColim, IsColimit.coconePointUniqueUpToIso, IsColimit.uniqueUpToIso] simp @[simp, reassoc] theorem colimitUncurryIsoColimitCompColim_ι_hom {j} {k} : colimit.ι _ (j, k) ≫ (colimitUncurryIsoColimitCompColim F).hom = (colimit.ι _ k ≫ colimit.ι (F ⋙ colim) j : _ ⟶ (colimit (F ⋙ colim))) := by rw [← cancel_mono (colimitUncurryIsoColimitCompColim F).inv] simp end section variable (F) [HasLimitsOfShape J C] [HasLimitsOfShape K C] /-- The limit of `F.flip ⋙ lim` is isomorphic to the limit of `F ⋙ lim`. -/ noncomputable def limitFlipCompLimIsoLimitCompLim : limit (F.flip ⋙ lim) ≅ limit (F ⋙ lim) := (limitUncurryIsoLimitCompLim _).symm ≪≫ HasLimit.isoOfNatIso (uncurryObjFlip _) ≪≫ HasLimit.isoOfEquivalence (Prod.braiding _ _) (NatIso.ofComponents fun _ => by rfl) ≪≫ limitUncurryIsoLimitCompLim _ @[simp, reassoc] theorem limitFlipCompLimIsoLimitCompLim_hom_π_π (j) (k) : (limitFlipCompLimIsoLimitCompLim F).hom ≫ limit.π _ j ≫ limit.π _ k = (limit.π _ k ≫ limit.π _ j) := by dsimp [limitFlipCompLimIsoLimitCompLim] simp [Equivalence.counit] @[simp, reassoc] theorem limitFlipCompLimIsoLimitCompLim_inv_π_π (k) (j) : (limitFlipCompLimIsoLimitCompLim F).inv ≫ limit.π _ k ≫ limit.π _ j = (limit.π _ j ≫ limit.π _ k) := by simp [limitFlipCompLimIsoLimitCompLim] end section variable (F) [HasColimitsOfShape J C] [HasColimitsOfShape K C] /-- The colimit of `F.flip ⋙ colim` is isomorphic to the colimit of `F ⋙ colim`. -/ noncomputable def colimitFlipCompColimIsoColimitCompColim : colimit (F.flip ⋙ colim) ≅ colimit (F ⋙ colim) := (colimitUncurryIsoColimitCompColim _).symm ≪≫ HasColimit.isoOfNatIso (uncurryObjFlip _) ≪≫ HasColimit.isoOfEquivalence (Prod.braiding _ _) (NatIso.ofComponents fun _ => by rfl) ≪≫ colimitUncurryIsoColimitCompColim _ @[simp, reassoc] theorem colimitFlipCompColimIsoColimitCompColim_ι_ι_hom (j) (k) : colimit.ι (F.flip.obj k) j ≫ colimit.ι (F.flip ⋙ colim) k ≫ (colimitFlipCompColimIsoColimitCompColim F).hom = (colimit.ι _ k ≫ colimit.ι (F ⋙ colim) j : _ ⟶ colimit (F⋙ colim)) := by dsimp [colimitFlipCompColimIsoColimitCompColim] slice_lhs 1 3 => simp only [] simp [Equivalence.unit] @[simp, reassoc] theorem colimitFlipCompColimIsoColimitCompColim_ι_ι_inv (k) (j) : colimit.ι (F.obj j) k ≫ colimit.ι (F ⋙ colim) j ≫ (colimitFlipCompColimIsoColimitCompColim F).inv = (colimit.ι _ j ≫ colimit.ι (F.flip ⋙ colim) k : _ ⟶ colimit (F.flip ⋙ colim)) := by dsimp [colimitFlipCompColimIsoColimitCompColim] slice_lhs 1 3 => simp only [] simp [Equivalence.counitInv] end section variable [HasLimitsOfShape K C] [HasLimit (curry.obj G ⋙ lim)] /-- The Fubini theorem for a functor `G : J × K ⥤ C`, showing that the limit of `G` can be computed as the limit of the limits of the functors `G.obj (j, _)`. -/ noncomputable def limitIsoLimitCurryCompLim : limit G ≅ limit (curry.obj G ⋙ lim) := by have i : G ≅ uncurry.obj ((@curry J _ K _ C _).obj G) := currying.symm.unitIso.app G haveI : Limits.HasLimit (uncurry.obj ((@curry J _ K _ C _).obj G)) := hasLimit_of_iso i trans limit (uncurry.obj ((@curry J _ K _ C _).obj G)) · apply HasLimit.isoOfNatIso i · exact limitUncurryIsoLimitCompLim ((@curry J _ K _ C _).obj G) @[simp, reassoc] theorem limitIsoLimitCurryCompLim_hom_π_π {j} {k} : (limitIsoLimitCurryCompLim G).hom ≫ limit.π _ j ≫ limit.π _ k = limit.π _ (j, k) := by simp [limitIsoLimitCurryCompLim, Trans.simple] @[simp, reassoc] theorem limitIsoLimitCurryCompLim_inv_π {j} {k} : (limitIsoLimitCurryCompLim G).inv ≫ limit.π _ (j, k) = (limit.π _ j ≫ limit.π _ k) := by rw [← cancel_epi (limitIsoLimitCurryCompLim G).hom] simp end section variable [HasColimitsOfShape K C] [HasColimit (curry.obj G ⋙ colim)] /-- The Fubini theorem for a functor `G : J × K ⥤ C`, showing that the colimit of `G` can be computed as the colimit of the colimits of the functors `G.obj (j, _)`. -/ noncomputable def colimitIsoColimitCurryCompColim : colimit G ≅ colimit (curry.obj G ⋙ colim) := by have i : G ≅ uncurry.obj ((@curry J _ K _ C _).obj G) := currying.symm.unitIso.app G haveI : Limits.HasColimit (uncurry.obj ((@curry J _ K _ C _).obj G)) := hasColimit_of_iso i.symm trans colimit (uncurry.obj ((@curry J _ K _ C _).obj G)) · apply HasColimit.isoOfNatIso i · exact colimitUncurryIsoColimitCompColim ((@curry J _ K _ C _).obj G) @[simp, reassoc] theorem colimitIsoColimitCurryCompColim_ι_ι_inv {j} {k} : colimit.ι ((curry.obj G).obj j) k ≫ colimit.ι (curry.obj G ⋙ colim) j ≫ (colimitIsoColimitCurryCompColim G).inv = colimit.ι _ (j, k) := by simp [colimitIsoColimitCurryCompColim, Trans.simple, colimitUncurryIsoColimitCompColim] @[simp, reassoc] theorem colimitIsoColimitCurryCompColim_ι_hom {j} {k} : colimit.ι _ (j, k) ≫ (colimitIsoColimitCurryCompColim G).hom = (colimit.ι (_) k ≫ colimit.ι (curry.obj G ⋙ colim) j : _ ⟶ colimit (_ ⋙ colim)) := by rw [← cancel_mono (colimitIsoColimitCurryCompColim G).inv] simp end section variable [HasLimitsOfShape K C] [HasLimitsOfShape J C] [HasLimit (curry.obj G ⋙ lim)] open CategoryTheory.prod /-- A variant of the Fubini theorem for a functor `G : J × K ⥤ C`, showing that $\lim_k \lim_j G(j,k) ≅ \lim_j \lim_k G(j,k)$. -/ noncomputable def limitCurrySwapCompLimIsoLimitCurryCompLim : limit (curry.obj (Prod.swap K J ⋙ G) ⋙ lim) ≅ limit (curry.obj G ⋙ lim) := calc limit (curry.obj (Prod.swap K J ⋙ G) ⋙ lim) ≅ limit (Prod.swap K J ⋙ G) := (limitIsoLimitCurryCompLim _).symm _ ≅ limit G := HasLimit.isoOfEquivalence (Prod.braiding K J) (Iso.refl _) _ ≅ limit (curry.obj G ⋙ lim) := limitIsoLimitCurryCompLim _ @[simp] theorem limitCurrySwapCompLimIsoLimitCurryCompLim_hom_π_π {j} {k} : (limitCurrySwapCompLimIsoLimitCurryCompLim G).hom ≫ limit.π _ j ≫ limit.π _ k = (limit.π _ k ≫ limit.π _ j) := by dsimp [limitCurrySwapCompLimIsoLimitCurryCompLim, Equivalence.counit] rw [Category.assoc, Category.assoc, limitIsoLimitCurryCompLim_hom_π_π, HasLimit.isoOfEquivalence_hom_π] dsimp [Equivalence.counit] rw [← prod_id, G.map_id] simp @[simp] theorem limitCurrySwapCompLimIsoLimitCurryCompLim_inv_π_π {j} {k} : (limitCurrySwapCompLimIsoLimitCurryCompLim G).inv ≫ limit.π _ k ≫ limit.π _ j = (limit.π _ j ≫ limit.π _ k) := by simp [limitCurrySwapCompLimIsoLimitCurryCompLim] end section variable [HasColimitsOfShape K C] [HasColimitsOfShape J C] [HasColimit (curry.obj G ⋙ colim)] open CategoryTheory.prod /-- A variant of the Fubini theorem for a functor `G : J × K ⥤ C`, showing that $\colim_k \colim_j G(j,k) ≅ \colim_j \colim_k G(j,k)$. -/ noncomputable def colimitCurrySwapCompColimIsoColimitCurryCompColim : colimit (curry.obj (Prod.swap K J ⋙ G) ⋙ colim) ≅ colimit (curry.obj G ⋙ colim) := calc colimit (curry.obj (Prod.swap K J ⋙ G) ⋙ colim) ≅ colimit (Prod.swap K J ⋙ G) := (colimitIsoColimitCurryCompColim _).symm _ ≅ colimit G := HasColimit.isoOfEquivalence (Prod.braiding K J) (Iso.refl _) _ ≅ colimit (curry.obj G ⋙ colim) := colimitIsoColimitCurryCompColim _ @[simp] theorem colimitCurrySwapCompColimIsoColimitCurryCompColim_ι_ι_hom {j} {k} : colimit.ι _ j ≫ colimit.ι (curry.obj (Prod.swap K J ⋙ G) ⋙ colim) k ≫ (colimitCurrySwapCompColimIsoColimitCurryCompColim G).hom = (colimit.ι _ k ≫ colimit.ι (curry.obj G ⋙ colim) j : _ ⟶ colimit (curry.obj G⋙ colim)) := by dsimp [colimitCurrySwapCompColimIsoColimitCurryCompColim] slice_lhs 1 3 => simp only [] simp @[simp] theorem colimitCurrySwapCompColimIsoColimitCurryCompColim_ι_ι_inv {j} {k} : colimit.ι _ k ≫ colimit.ι (curry.obj G ⋙ colim) j ≫ (colimitCurrySwapCompColimIsoColimitCurryCompColim G).inv = (colimit.ι _ j ≫ colimit.ι (curry.obj _ ⋙ colim) k : _ ⟶ colimit (curry.obj (Prod.swap K J ⋙ G) ⋙ colim)) := by dsimp [colimitCurrySwapCompColimIsoColimitCurryCompColim] slice_lhs 1 3 => simp only [] rw [colimitIsoColimitCurryCompColim_ι_ι_inv, HasColimit.isoOfEquivalence_inv_π] dsimp [Equivalence.counitInv] rw [CategoryTheory.Bifunctor.map_id] simp end end CategoryTheory.Limits
State.lean
/- Copyright (c) 2019 Kim Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kim Morrison -/ import Mathlib.SetTheory.Game.Short import Mathlib.Tactic.Linter.DeprecatedModule deprecated_module "This module is now at `CombinatorialGames.Game.ConcreteGame` in the CGT repo <https://github.com/vihdzp/combinatorial-games>" (since := "2025-08-06") /-! # Games described via "the state of the board". We provide a simple mechanism for constructing combinatorial (pre-)games, by describing "the state of the board", and providing an upper bound on the number of turns remaining. ## Implementation notes We're very careful to produce a computable definition, so small games can be evaluated using `decide`. To achieve this, I've had to rely solely on induction on natural numbers: relying on general well-foundedness seems to be poisonous to computation? See `SetTheory/Game/Domineering` for an example using this construction. -/ universe u namespace SetTheory namespace PGame /-- `SetTheory.PGame.State S` describes how to interpret `s : S` as a state of a combinatorial game. Use `SetTheory.PGame.ofState s` or `SetTheory.Game.ofState s` to construct the game. `SetTheory.PGame.State.l : S → Finset S` and `SetTheory.PGame.State.r : S → Finset S` describe the states reachable by a move by Left or Right. `SetTheory.PGame.State.turnBound : S → ℕ` gives an upper bound on the number of possible turns remaining from this state. -/ class State (S : Type u) where /-- Upper bound on the number of possible turns remaining from this state -/ turnBound : S → ℕ /-- States reachable by a Left move -/ l : S → Finset S /-- States reachable by a Right move -/ r : S → Finset S left_bound : ∀ {s t : S}, t ∈ l s → turnBound t < turnBound s right_bound : ∀ {s t : S}, t ∈ r s → turnBound t < turnBound s open State variable {S : Type u} [State S] theorem turnBound_ne_zero_of_left_move {s t : S} (m : t ∈ l s) : turnBound s ≠ 0 := by intro h have t := left_bound m rw [h] at t exact Nat.not_succ_le_zero _ t theorem turnBound_ne_zero_of_right_move {s t : S} (m : t ∈ r s) : turnBound s ≠ 0 := by intro h have t := right_bound m omega theorem turnBound_of_left {s t : S} (m : t ∈ l s) (n : ℕ) (h : turnBound s ≤ n + 1) : turnBound t ≤ n := Nat.le_of_lt_succ (Nat.lt_of_lt_of_le (left_bound m) h) theorem turnBound_of_right {s t : S} (m : t ∈ r s) (n : ℕ) (h : turnBound s ≤ n + 1) : turnBound t ≤ n := Nat.le_of_lt_succ (Nat.lt_of_lt_of_le (right_bound m) h) /-- Construct a `PGame` from a state and a (not necessarily optimal) bound on the number of turns remaining. -/ def ofStateAux : ∀ (n : ℕ) (s : S), turnBound s ≤ n → PGame | 0, s, h => PGame.mk { t // t ∈ l s } { t // t ∈ r s } (fun t => by exfalso; exact turnBound_ne_zero_of_left_move t.2 (nonpos_iff_eq_zero.mp h)) fun t => by exfalso; exact turnBound_ne_zero_of_right_move t.2 (nonpos_iff_eq_zero.mp h) | n + 1, s, h => PGame.mk { t // t ∈ l s } { t // t ∈ r s } (fun t => ofStateAux n t (turnBound_of_left t.2 n h)) fun t => ofStateAux n t (turnBound_of_right t.2 n h) /-- Two different (valid) turn bounds give equivalent games. -/ def ofStateAuxRelabelling : ∀ (s : S) (n m : ℕ) (hn : turnBound s ≤ n) (hm : turnBound s ≤ m), Relabelling (ofStateAux n s hn) (ofStateAux m s hm) | s, 0, 0, hn, hm => by dsimp [PGame.ofStateAux] fconstructor · rfl · rfl · intro i; dsimp at i; exfalso exact turnBound_ne_zero_of_left_move i.2 (nonpos_iff_eq_zero.mp hn) · intro j; dsimp at j; exfalso exact turnBound_ne_zero_of_right_move j.2 (nonpos_iff_eq_zero.mp hm) | s, 0, m + 1, hn, hm => by dsimp [PGame.ofStateAux] fconstructor · rfl · rfl · intro i; dsimp at i; exfalso exact turnBound_ne_zero_of_left_move i.2 (nonpos_iff_eq_zero.mp hn) · intro j; dsimp at j; exfalso exact turnBound_ne_zero_of_right_move j.2 (nonpos_iff_eq_zero.mp hn) | s, n + 1, 0, hn, hm => by dsimp [PGame.ofStateAux] fconstructor · rfl · rfl · intro i; dsimp at i; exfalso exact turnBound_ne_zero_of_left_move i.2 (nonpos_iff_eq_zero.mp hm) · intro j; dsimp at j; exfalso exact turnBound_ne_zero_of_right_move j.2 (nonpos_iff_eq_zero.mp hm) | s, n + 1, m + 1, hn, hm => by dsimp [PGame.ofStateAux] fconstructor · rfl · rfl · intro i apply ofStateAuxRelabelling · intro j apply ofStateAuxRelabelling /-- Construct a combinatorial `PGame` from a state. -/ def ofState (s : S) : PGame := ofStateAux (turnBound s) s (refl _) /-- The equivalence between `leftMoves` for a `PGame` constructed using `ofStateAux _ s _`, and `L s`. -/ def leftMovesOfStateAux (n : ℕ) {s : S} (h : turnBound s ≤ n) : LeftMoves (ofStateAux n s h) ≃ { t // t ∈ l s } := by induction n <;> rfl /-- The equivalence between `leftMoves` for a `PGame` constructed using `ofState s`, and `l s`. -/ def leftMovesOfState (s : S) : LeftMoves (ofState s) ≃ { t // t ∈ l s } := leftMovesOfStateAux _ _ /-- The equivalence between `rightMoves` for a `PGame` constructed using `ofStateAux _ s _`, and `R s`. -/ def rightMovesOfStateAux (n : ℕ) {s : S} (h : turnBound s ≤ n) : RightMoves (ofStateAux n s h) ≃ { t // t ∈ r s } := by induction n <;> rfl /-- The equivalence between `rightMoves` for a `PGame` constructed using `ofState s`, and `R s`. -/ def rightMovesOfState (s : S) : RightMoves (ofState s) ≃ { t // t ∈ r s } := rightMovesOfStateAux _ _ /-- The relabelling showing `moveLeft` applied to a game constructed using `ofStateAux` has itself been constructed using `ofStateAux`. -/ def relabellingMoveLeftAux (n : ℕ) {s : S} (h : turnBound s ≤ n) (t : LeftMoves (ofStateAux n s h)) : Relabelling (moveLeft (ofStateAux n s h) t) (ofStateAux (n - 1) ((leftMovesOfStateAux n h) t : S) (turnBound_of_left ((leftMovesOfStateAux n h) t).2 (n - 1) (Nat.le_trans h le_tsub_add))) := by induction n · have t' := (leftMovesOfStateAux 0 h) t exfalso; exact turnBound_ne_zero_of_left_move t'.2 (nonpos_iff_eq_zero.mp h) · rfl /-- The relabelling showing `moveLeft` applied to a game constructed using `of` has itself been constructed using `of`. -/ def relabellingMoveLeft (s : S) (t : LeftMoves (ofState s)) : Relabelling (moveLeft (ofState s) t) (ofState ((leftMovesOfState s).toFun t : S)) := by trans · apply relabellingMoveLeftAux · apply ofStateAuxRelabelling /-- The relabelling showing `moveRight` applied to a game constructed using `ofStateAux` has itself been constructed using `ofStateAux`. -/ def relabellingMoveRightAux (n : ℕ) {s : S} (h : turnBound s ≤ n) (t : RightMoves (ofStateAux n s h)) : Relabelling (moveRight (ofStateAux n s h) t) (ofStateAux (n - 1) ((rightMovesOfStateAux n h) t : S) (turnBound_of_right ((rightMovesOfStateAux n h) t).2 (n - 1) (Nat.le_trans h le_tsub_add))) := by induction n · have t' := (rightMovesOfStateAux 0 h) t exfalso; exact turnBound_ne_zero_of_right_move t'.2 (nonpos_iff_eq_zero.mp h) · rfl /-- The relabelling showing `moveRight` applied to a game constructed using `of` has itself been constructed using `of`. -/ def relabellingMoveRight (s : S) (t : RightMoves (ofState s)) : Relabelling (moveRight (ofState s) t) (ofState ((rightMovesOfState s).toFun t : S)) := by trans · apply relabellingMoveRightAux · apply ofStateAuxRelabelling instance fintypeLeftMovesOfStateAux (n : ℕ) (s : S) (h : turnBound s ≤ n) : Fintype (LeftMoves (ofStateAux n s h)) := by apply Fintype.ofEquiv _ (leftMovesOfStateAux _ _).symm instance fintypeRightMovesOfStateAux (n : ℕ) (s : S) (h : turnBound s ≤ n) : Fintype (RightMoves (ofStateAux n s h)) := by apply Fintype.ofEquiv _ (rightMovesOfStateAux _ _).symm instance shortOfStateAux : ∀ (n : ℕ) {s : S} (h : turnBound s ≤ n), Short (ofStateAux n s h) | 0, s, h => Short.mk' (fun i => by have i := (leftMovesOfStateAux _ _).toFun i exfalso exact turnBound_ne_zero_of_left_move i.2 (nonpos_iff_eq_zero.mp h)) fun j => by have j := (rightMovesOfStateAux _ _).toFun j exfalso exact turnBound_ne_zero_of_right_move j.2 (nonpos_iff_eq_zero.mp h) | n + 1, _, h => Short.mk' (fun i => shortOfRelabelling (relabellingMoveLeftAux (n + 1) h i).symm (shortOfStateAux n _)) fun j => shortOfRelabelling (relabellingMoveRightAux (n + 1) h j).symm (shortOfStateAux n _) instance shortOfState (s : S) : Short (ofState s) := by dsimp [PGame.ofState] infer_instance end PGame namespace Game /-- Construct a combinatorial `Game` from a state. -/ def ofState {S : Type u} [PGame.State S] (s : S) : Game := ⟦PGame.ofState s⟧ end Game end SetTheory
LocallyDiscrete.lean
/- Copyright (c) 2024 Joël Riou. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joël Riou -/ import Mathlib.CategoryTheory.Bicategory.Functor.Pseudofunctor import Mathlib.CategoryTheory.Bicategory.LocallyDiscrete /-! # Pseudofunctors from locally discrete bicategories This file provides various ways of constructing pseudofunctors from locally discrete bicategories. Firstly, we define the constructors `pseudofunctorOfIsLocallyDiscrete` and `oplaxFunctorOfIsLocallyDiscrete` for defining pseudofunctors and oplax functors from a locally discrete bicategories. In this situation, we do not need to care about the field `map₂`, because all the `2`-morphisms in `B` are identities. We also define a specialized constructor `LocallyDiscrete.mkPseudofunctor` when the source bicategory is of the form `B := LocallyDiscrete B₀` for a category `B₀`. We also prove that a functor `F : I ⥤ B` with `B` a strict bicategory can be promoted to a pseudofunctor (or oplax functor) (`Functor.toPseudofunctor`) with domain `LocallyDiscrete I`. -/ namespace CategoryTheory open Bicategory /-- Constructor for pseudofunctors from a locally discrete bicategory. In that case, we do not need to provide the `map₂` field of pseudofunctors. -/ @[simps obj map mapId mapComp] def pseudofunctorOfIsLocallyDiscrete {B C : Type*} [Bicategory B] [IsLocallyDiscrete B] [Bicategory C] (obj : B → C) (map : ∀ {b b' : B}, (b ⟶ b') → (obj b ⟶ obj b')) (mapId : ∀ (b : B), map (𝟙 b) ≅ 𝟙 _) (mapComp : ∀ {b₀ b₁ b₂ : B} (f : b₀ ⟶ b₁) (g : b₁ ⟶ b₂), map (f ≫ g) ≅ map f ≫ map g) (map₂_associator : ∀ {b₀ b₁ b₂ b₃ : B} (f : b₀ ⟶ b₁) (g : b₁ ⟶ b₂) (h : b₂ ⟶ b₃), (mapComp (f ≫ g) h).hom ≫ (mapComp f g).hom ▷ map h ≫ (α_ (map f) (map g) (map h)).hom ≫ map f ◁ (mapComp g h).inv ≫ (mapComp f (g ≫ h)).inv = eqToHom (by simp) := by cat_disch) (map₂_left_unitor : ∀ {b₀ b₁ : B} (f : b₀ ⟶ b₁), (mapComp (𝟙 b₀) f).hom ≫ (mapId b₀).hom ▷ map f ≫ (λ_ (map f)).hom = eqToHom (by simp) := by cat_disch) (map₂_right_unitor : ∀ {b₀ b₁ : B} (f : b₀ ⟶ b₁), (mapComp f (𝟙 b₁)).hom ≫ map f ◁ (mapId b₁).hom ≫ (ρ_ (map f)).hom = eqToHom (by simp) := by cat_disch) : Pseudofunctor B C where obj := obj map := map map₂ φ := eqToHom (by obtain rfl := obj_ext_of_isDiscrete φ dsimp) mapId := mapId mapComp := mapComp map₂_whisker_left _ _ _ η := by obtain rfl := obj_ext_of_isDiscrete η simp map₂_whisker_right η _ := by obtain rfl := obj_ext_of_isDiscrete η simp /-- Constructor for oplax functors from a locally discrete bicategory. In that case, we do not need to provide the `map₂` field of oplax functors. -/ @[simps obj map mapId mapComp] def oplaxFunctorOfIsLocallyDiscrete {B C : Type*} [Bicategory B] [IsLocallyDiscrete B] [Bicategory C] (obj : B → C) (map : ∀ {b b' : B}, (b ⟶ b') → (obj b ⟶ obj b')) (mapId : ∀ (b : B), map (𝟙 b) ⟶ 𝟙 _) (mapComp : ∀ {b₀ b₁ b₂ : B} (f : b₀ ⟶ b₁) (g : b₁ ⟶ b₂), map (f ≫ g) ⟶ map f ≫ map g) (map₂_associator : ∀ {b₀ b₁ b₂ b₃ : B} (f : b₀ ⟶ b₁) (g : b₁ ⟶ b₂) (h : b₂ ⟶ b₃), eqToHom (by simp) ≫ mapComp f (g ≫ h) ≫ map f ◁ mapComp g h = mapComp (f ≫ g) h ≫ mapComp f g ▷ map h ≫ (α_ (map f) (map g) (map h)).hom := by cat_disch) (map₂_left_unitor : ∀ {b₀ b₁ : B} (f : b₀ ⟶ b₁), mapComp (𝟙 b₀) f ≫ mapId b₀ ▷ map f ≫ (λ_ (map f)).hom = eqToHom (by simp) := by cat_disch) (map₂_right_unitor : ∀ {b₀ b₁ : B} (f : b₀ ⟶ b₁), mapComp f (𝟙 b₁) ≫ map f ◁ mapId b₁ ≫ (ρ_ (map f)).hom = eqToHom (by simp) := by cat_disch) : OplaxFunctor B C where obj := obj map := map map₂ φ := eqToHom (by obtain rfl := obj_ext_of_isDiscrete φ dsimp) mapId := mapId mapComp := mapComp mapComp_naturality_left η := by obtain rfl := obj_ext_of_isDiscrete η simp mapComp_naturality_right _ _ _ η := by obtain rfl := obj_ext_of_isDiscrete η simp section variable {C D : Type*} [Category C] [Category D] (F : C ⥤ D) /-- A functor between two categories `C` and `D` can be lifted to a pseudofunctor between the corresponding locally discrete bicategories. -/ @[simps! obj map mapId mapComp] def Functor.toPseudoFunctor : Pseudofunctor (LocallyDiscrete C) (LocallyDiscrete D) := pseudofunctorOfIsLocallyDiscrete (fun ⟨X⟩ ↦.mk <| F.obj X) (fun ⟨f⟩ ↦ (F.map f).toLoc) (fun ⟨X⟩ ↦ eqToIso (by simp)) (fun f g ↦ eqToIso (by simp)) /-- A functor between two categories `C` and `D` can be lifted to an oplax functor between the corresponding locally discrete bicategories. This is just an abbreviation of `Functor.toPseudoFunctor.toOplax`. -/ @[simps! obj map mapId mapComp] abbrev Functor.toOplaxFunctor : OplaxFunctor (LocallyDiscrete C) (LocallyDiscrete D) := F.toPseudoFunctor.toOplax end section variable {I B : Type*} [Category I] [Bicategory B] [Strict B] (F : I ⥤ B) attribute [local simp] Strict.leftUnitor_eqToIso Strict.rightUnitor_eqToIso Strict.associator_eqToIso /-- If `B` is a strict bicategory and `I` is a (1-)category, any functor (of 1-categories) `I ⥤ B` can be promoted to a pseudofunctor from `LocallyDiscrete I` to `B`. -/ @[simps! obj map mapId mapComp] def Functor.toPseudoFunctor' : Pseudofunctor (LocallyDiscrete I) B := pseudofunctorOfIsLocallyDiscrete (fun ⟨X⟩ ↦ F.obj X) (fun ⟨f⟩ ↦ F.map f) (fun ⟨X⟩ ↦ eqToIso (by simp)) (fun f g ↦ eqToIso (by simp)) /-- If `B` is a strict bicategory and `I` is a (1-)category, any functor (of 1-categories) `I ⥤ B` can be promoted to an oplax functor from `LocallyDiscrete I` to `B`. -/ @[simps! obj map mapId mapComp] abbrev Functor.toOplaxFunctor' : OplaxFunctor (LocallyDiscrete I) B := F.toPseudoFunctor'.toOplax end namespace LocallyDiscrete /-- Constructor for pseudofunctors from a locally discrete bicategory. In that case, we do not need to provide the `map₂` field of pseudofunctors. -/ @[simps! obj map mapId mapComp] def mkPseudofunctor {B₀ C : Type*} [Category B₀] [Bicategory C] (obj : B₀ → C) (map : ∀ {b b' : B₀}, (b ⟶ b') → (obj b ⟶ obj b')) (mapId : ∀ (b : B₀), map (𝟙 b) ≅ 𝟙 _) (mapComp : ∀ {b₀ b₁ b₂ : B₀} (f : b₀ ⟶ b₁) (g : b₁ ⟶ b₂), map (f ≫ g) ≅ map f ≫ map g) (map₂_associator : ∀ {b₀ b₁ b₂ b₃ : B₀} (f : b₀ ⟶ b₁) (g : b₁ ⟶ b₂) (h : b₂ ⟶ b₃), (mapComp (f ≫ g) h).hom ≫ (mapComp f g).hom ▷ map h ≫ (α_ (map f) (map g) (map h)).hom ≫ map f ◁ (mapComp g h).inv ≫ (mapComp f (g ≫ h)).inv = eqToHom (by simp) := by cat_disch) (map₂_left_unitor : ∀ {b₀ b₁ : B₀} (f : b₀ ⟶ b₁), (mapComp (𝟙 b₀) f).hom ≫ (mapId b₀).hom ▷ map f ≫ (λ_ (map f)).hom = eqToHom (by simp) := by cat_disch) (map₂_right_unitor : ∀ {b₀ b₁ : B₀} (f : b₀ ⟶ b₁), (mapComp f (𝟙 b₁)).hom ≫ map f ◁ (mapId b₁).hom ≫ (ρ_ (map f)).hom = eqToHom (by simp) := by cat_disch) : Pseudofunctor (LocallyDiscrete B₀) C := pseudofunctorOfIsLocallyDiscrete (fun b ↦ obj b.as) (fun f ↦ map f.as) (fun _ ↦ mapId _) (fun _ _ ↦ mapComp _ _) (fun _ _ _ ↦ map₂_associator _ _ _) (fun _ ↦ map₂_left_unitor _) (fun _ ↦ map₂_right_unitor _) end LocallyDiscrete end CategoryTheory
IteratedFDeriv.lean
/- Copyright (c) 2024 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel -/ import Mathlib.Analysis.Calculus.ContDiff.Operations import Mathlib.Analysis.Calculus.ContDiff.CPolynomial import Mathlib.Data.Fintype.Perm /-! # The iterated derivative of an analytic function If a function is analytic, written as `f (x + y) = ∑ pₙ (y, ..., y)` then its `n`-th iterated derivative at `x` is given by `(v₁, ..., vₙ) ↦ ∑ pₙ (v_{σ (1)}, ..., v_{σ (n)})` where the sum is over all permutations of `{1, ..., n}`. In particular, it is symmetric. This generalizes the result of `HasFPowerSeriesOnBall.factorial_smul` giving `D^n f (v, ..., v) = n! * pₙ (v, ..., v)`. ## Main result * `HasFPowerSeriesOnBall.iteratedFDeriv_eq_sum` shows that `iteratedFDeriv 𝕜 n f x v = ∑ σ : Perm (Fin n), p n (fun i ↦ v (σ i))`, when `f` has `p` as power series within the set `s` on the ball `B (x, r)`. * `ContDiffAt.iteratedFDeriv_comp_perm` proves the symmetry of the iterated derivative of an analytic function, in the form `iteratedFDeriv 𝕜 n f x (v ∘ σ) = iteratedFDeriv 𝕜 n f x v` for any permutation `σ` of `Fin n`. Versions within sets are also given. ## Implementation To prove the formula for the iterated derivative, we decompose an analytic function as the sum of `fun y ↦ pₙ (y, ..., y)` and the rest. For the former, its iterated derivative follows from the formula for iterated derivatives of multilinear maps (see `ContinuousMultilinearMap.iteratedFDeriv_comp_diagonal`). For the latter, we show by induction on `n` that if the `n`-th term in a power series is zero, then the `n`-th iterated derivative vanishes (see `HasFPowerSeriesWithinOnBall.iteratedFDerivWithin_eq_zero`). All these results are proved assuming additionally that the function is analytic on the relevant set (which does not follow from the fact that the function has a power series, if the target space is not complete). This makes it possible to avoid all completeness assumptions in the final statements. When needed, we give versions of some statements assuming completeness and dropping analyticity, for ease of use. -/ open scoped ENNReal Topology ContDiff open Equiv Set variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F] {f : E → F} {p : FormalMultilinearSeries 𝕜 E F} {s : Set E} {x : E} {r : ℝ≥0∞} /-- Formal multilinear series associated to the iterated derivative, defined by iterating `p ↦ p.derivSeries` and currying suitably. It is defined so that, if a function has `p` as a power series, then its iterated derivative of order `k` has `p.iteratedFDerivSeries k` as a power series. -/ noncomputable def FormalMultilinearSeries.iteratedFDerivSeries (p : FormalMultilinearSeries 𝕜 E F) (k : ℕ) : FormalMultilinearSeries 𝕜 E (E [×k]→L[𝕜] F) := match k with | 0 => (continuousMultilinearCurryFin0 𝕜 E F).symm |>.toContinuousLinearEquiv.toContinuousLinearMap.compFormalMultilinearSeries p | (k + 1) => (continuousMultilinearCurryLeftEquiv 𝕜 (fun _ : Fin (k + 1) ↦ E) F).symm |>.toContinuousLinearEquiv.toContinuousLinearMap.compFormalMultilinearSeries (p.iteratedFDerivSeries k).derivSeries /-- If a function has a power series on a ball, then so do its iterated derivatives. -/ protected theorem HasFPowerSeriesWithinOnBall.iteratedFDerivWithin (h : HasFPowerSeriesWithinOnBall f p s x r) (h' : AnalyticOn 𝕜 f s) (k : ℕ) (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) : HasFPowerSeriesWithinOnBall (iteratedFDerivWithin 𝕜 k f s) (p.iteratedFDerivSeries k) s x r := by induction k with | zero => exact (continuousMultilinearCurryFin0 𝕜 E F).symm |>.toContinuousLinearEquiv.toContinuousLinearMap.comp_hasFPowerSeriesWithinOnBall h | succ k ih => rw [iteratedFDerivWithin_succ_eq_comp_left] apply (continuousMultilinearCurryLeftEquiv 𝕜 (fun _ : Fin (k + 1) ↦ E) F).symm |>.toContinuousLinearEquiv.toContinuousLinearMap.comp_hasFPowerSeriesWithinOnBall (ih.fderivWithin_of_mem_of_analyticOn (h'.iteratedFDerivWithin hs _) hs hx) lemma FormalMultilinearSeries.iteratedFDerivSeries_eq_zero {k n : ℕ} (h : p (n + k) = 0) : p.iteratedFDerivSeries k n = 0 := by induction k generalizing n with | zero => ext have : p n = 0 := p.congr_zero rfl h simp [FormalMultilinearSeries.iteratedFDerivSeries, this] | succ k ih => ext simp only [iteratedFDerivSeries, Nat.succ_eq_add_one, ContinuousLinearMap.compFormalMultilinearSeries_apply, ContinuousLinearMap.compContinuousMultilinearMap_coe, ContinuousLinearEquiv.coe_coe, LinearIsometryEquiv.coe_toContinuousLinearEquiv, Function.comp_apply, continuousMultilinearCurryLeftEquiv_symm_apply, ContinuousMultilinearMap.zero_apply, ContinuousLinearMap.zero_apply, derivSeries_eq_zero _ (ih (p.congr_zero (Nat.succ_add_eq_add_succ _ _).symm h))] /-- If the `n`-th term in a power series is zero, then the `n`-th derivative of the corresponding function vanishes. -/ lemma HasFPowerSeriesWithinOnBall.iteratedFDerivWithin_eq_zero (h : HasFPowerSeriesWithinOnBall f p s x r) (h' : AnalyticOn 𝕜 f s) (hu : UniqueDiffOn 𝕜 s) (hx : x ∈ s) {n : ℕ} (hn : p n = 0) : iteratedFDerivWithin 𝕜 n f s x = 0 := by have : iteratedFDerivWithin 𝕜 n f s x = p.iteratedFDerivSeries n 0 (fun _ ↦ 0) := ((h.iteratedFDerivWithin h' n hu hx).coeff_zero _).symm rw [this, p.iteratedFDerivSeries_eq_zero (p.congr_zero (Nat.zero_add n).symm hn), ContinuousMultilinearMap.zero_apply] lemma ContinuousMultilinearMap.iteratedFDeriv_comp_diagonal {n : ℕ} (f : E [×n]→L[𝕜] F) (x : E) (v : Fin n → E) : iteratedFDeriv 𝕜 n (fun x ↦ f (fun _ ↦ x)) x v = ∑ σ : Perm (Fin n), f (fun i ↦ v (σ i)) := by rw [← sum_comp (Equiv.inv (Perm (Fin n)))] let g : E →L[𝕜] (Fin n → E) := ContinuousLinearMap.pi (fun i ↦ ContinuousLinearMap.id 𝕜 E) change iteratedFDeriv 𝕜 n (f ∘ g) x v = _ rw [ContinuousLinearMap.iteratedFDeriv_comp_right _ f.contDiff _ le_rfl, f.iteratedFDeriv_eq] simp only [ContinuousMultilinearMap.iteratedFDeriv, ContinuousMultilinearMap.compContinuousLinearMap_apply, ContinuousMultilinearMap.sum_apply, ContinuousMultilinearMap.iteratedFDerivComponent_apply, Set.mem_range, Pi.compRightL_apply] rw [← sum_comp (Equiv.embeddingEquivOfFinite (Fin n))] congr with σ congr with i have A : ∃ y, σ y = i := by have : Function.Bijective σ := (Fintype.bijective_iff_injective_and_card _).2 ⟨σ.injective, rfl⟩ exact this.surjective i rcases A with ⟨y, rfl⟩ simp only [EmbeddingLike.apply_eq_iff_eq, exists_eq, ↓reduceDIte, Function.Embedding.toEquivRange_symm_apply_self, ContinuousLinearMap.coe_pi', ContinuousLinearMap.coe_id', id_eq, g] congr 1 symm simp [inv_apply, Perm.inv_def, ofBijective_symm_apply_apply, Function.Embedding.equivOfFiniteSelfEmbedding] private lemma HasFPowerSeriesWithinOnBall.iteratedFDerivWithin_eq_sum_of_subset (h : HasFPowerSeriesWithinOnBall f p s x r) (h' : AnalyticOn 𝕜 f s) (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) {n : ℕ} (v : Fin n → E) (h's : s ⊆ EMetric.ball x r) : iteratedFDerivWithin 𝕜 n f s x v = ∑ σ : Perm (Fin n), p n (fun i ↦ v (σ i)) := by have I : insert x s ∩ EMetric.ball x r = s := by rw [Set.insert_eq_of_mem hx] exact Set.inter_eq_left.2 h's have fcont : ContDiffOn 𝕜 (↑n) f s := by apply AnalyticOn.contDiffOn _ hs simpa [I] using h' let g : E → F := fun z ↦ p n (fun _ ↦ z - x) have gcont : ContDiff 𝕜 ω g := by apply (p n).contDiff.comp exact contDiff_pi.2 (fun i ↦ contDiff_id.sub contDiff_const) let q : FormalMultilinearSeries 𝕜 E F := fun k ↦ if h : n = k then (h ▸ p n) else 0 have A : HasFiniteFPowerSeriesOnBall g q x (n + 1) r := by apply HasFiniteFPowerSeriesOnBall.mk' _ h.r_pos · intro y hy rw [Finset.sum_eq_single_of_mem n] · simp [q, g] · simp · intro i hi h'i simp [q, h'i.symm] · intro m hm have : n ≠ m := by omega simp [q, this] have B : HasFPowerSeriesWithinOnBall g q s x r := A.toHasFPowerSeriesOnBall.hasFPowerSeriesWithinOnBall have J1 : iteratedFDerivWithin 𝕜 n f s x = iteratedFDerivWithin 𝕜 n g s x + iteratedFDerivWithin 𝕜 n (f - g) s x := by have : f = g + (f - g) := by abel nth_rewrite 1 [this] rw [iteratedFDerivWithin_add_apply (gcont.of_le le_top).contDiffWithinAt (by exact (fcont _ hx).sub (gcont.of_le le_top).contDiffWithinAt) hs hx] have J2 : iteratedFDerivWithin 𝕜 n (f - g) s x = 0 := by apply (h.sub B).iteratedFDerivWithin_eq_zero (h'.sub ?_) hs hx · simp [q] · apply gcont.contDiffOn.analyticOn have J3 : iteratedFDerivWithin 𝕜 n g s x = iteratedFDeriv 𝕜 n g x := iteratedFDerivWithin_eq_iteratedFDeriv hs (gcont.of_le le_top).contDiffAt hx simp only [J1, J3, J2, add_zero] let g' : E → F := fun z ↦ p n (fun _ ↦ z) have : g = fun z ↦ g' (z - x) := rfl rw [this, iteratedFDeriv_comp_sub] exact (p n).iteratedFDeriv_comp_diagonal _ v /-- If a function has a power series in a ball, then its `n`-th iterated derivative is given by `(v₁, ..., vₙ) ↦ ∑ pₙ (v_{σ (1)}, ..., v_{σ (n)})` where the sum is over all permutations of `{1, ..., n}`. -/ theorem HasFPowerSeriesWithinOnBall.iteratedFDerivWithin_eq_sum (h : HasFPowerSeriesWithinOnBall f p s x r) (h' : AnalyticOn 𝕜 f s) (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) {n : ℕ} (v : Fin n → E) : iteratedFDerivWithin 𝕜 n f s x v = ∑ σ : Perm (Fin n), p n (fun i ↦ v (σ i)) := by have : iteratedFDerivWithin 𝕜 n f s x = iteratedFDerivWithin 𝕜 n f (s ∩ EMetric.ball x r) x := (iteratedFDerivWithin_inter_open EMetric.isOpen_ball (EMetric.mem_ball_self h.r_pos)).symm rw [this] apply HasFPowerSeriesWithinOnBall.iteratedFDerivWithin_eq_sum_of_subset · exact h.mono inter_subset_left · exact h'.mono inter_subset_left · exact hs.inter EMetric.isOpen_ball · exact ⟨hx, EMetric.mem_ball_self h.r_pos⟩ · exact inter_subset_right /-- If a function has a power series in a ball, then its `n`-th iterated derivative is given by `(v₁, ..., vₙ) ↦ ∑ pₙ (v_{σ (1)}, ..., v_{σ (n)})` where the sum is over all permutations of `{1, ..., n}`. -/ theorem HasFPowerSeriesOnBall.iteratedFDeriv_eq_sum (h : HasFPowerSeriesOnBall f p x r) (h' : AnalyticOn 𝕜 f univ) {n : ℕ} (v : Fin n → E) : iteratedFDeriv 𝕜 n f x v = ∑ σ : Perm (Fin n), p n (fun i ↦ v (σ i)) := by simp only [← iteratedFDerivWithin_univ, ← hasFPowerSeriesWithinOnBall_univ] at h ⊢ exact h.iteratedFDerivWithin_eq_sum h' uniqueDiffOn_univ (mem_univ x) v /-- If a function has a power series in a ball, then its `n`-th iterated derivative is given by `(v₁, ..., vₙ) ↦ ∑ pₙ (v_{σ (1)}, ..., v_{σ (n)})` where the sum is over all permutations of `{1, ..., n}`. -/ theorem HasFPowerSeriesWithinOnBall.iteratedFDerivWithin_eq_sum_of_completeSpace [CompleteSpace F] (h : HasFPowerSeriesWithinOnBall f p s x r) (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) {n : ℕ} (v : Fin n → E) : iteratedFDerivWithin 𝕜 n f s x v = ∑ σ : Perm (Fin n), p n (fun i ↦ v (σ i)) := by have : iteratedFDerivWithin 𝕜 n f s x = iteratedFDerivWithin 𝕜 n f (s ∩ EMetric.ball x r) x := (iteratedFDerivWithin_inter_open EMetric.isOpen_ball (EMetric.mem_ball_self h.r_pos)).symm rw [this] apply HasFPowerSeriesWithinOnBall.iteratedFDerivWithin_eq_sum_of_subset · exact h.mono inter_subset_left · apply h.analyticOn.mono rw [insert_eq_of_mem hx] · exact hs.inter EMetric.isOpen_ball · exact ⟨hx, EMetric.mem_ball_self h.r_pos⟩ · exact inter_subset_right /-- If a function has a power series in a ball, then its `n`-th iterated derivative is given by `(v₁, ..., vₙ) ↦ ∑ pₙ (v_{σ (1)}, ..., v_{σ (n)})` where the sum is over all permutations of `{1, ..., n}`. -/ theorem HasFPowerSeriesOnBall.iteratedFDeriv_eq_sum_of_completeSpace [CompleteSpace F] (h : HasFPowerSeriesOnBall f p x r) {n : ℕ} (v : Fin n → E) : iteratedFDeriv 𝕜 n f x v = ∑ σ : Perm (Fin n), p n (fun i ↦ v (σ i)) := by simp only [← iteratedFDerivWithin_univ, ← hasFPowerSeriesWithinOnBall_univ] at h ⊢ exact h.iteratedFDerivWithin_eq_sum_of_completeSpace uniqueDiffOn_univ (mem_univ _) v /-- The `n`-th iterated derivative of an analytic function on a set is symmetric. -/ theorem AnalyticOn.iteratedFDerivWithin_comp_perm (h : AnalyticOn 𝕜 f s) (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) {n : ℕ} (v : Fin n → E) (σ : Perm (Fin n)) : iteratedFDerivWithin 𝕜 n f s x (v ∘ σ) = iteratedFDerivWithin 𝕜 n f s x v := by rcases h x hx with ⟨p, r, hp⟩ rw [hp.iteratedFDerivWithin_eq_sum h hs hx, hp.iteratedFDerivWithin_eq_sum h hs hx] conv_rhs => rw [← Equiv.sum_comp (Equiv.mulLeft σ)] simp only [coe_mulLeft, Perm.coe_mul, Function.comp_apply] theorem AnalyticOn.domDomCongr_iteratedFDerivWithin (h : AnalyticOn 𝕜 f s) (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) {n : ℕ} (σ : Perm (Fin n)) : (iteratedFDerivWithin 𝕜 n f s x).domDomCongr σ = iteratedFDerivWithin 𝕜 n f s x := by ext exact h.iteratedFDerivWithin_comp_perm hs hx _ _ /-- The `n`-th iterated derivative of an analytic function on a set is symmetric. -/ theorem ContDiffWithinAt.iteratedFDerivWithin_comp_perm (h : ContDiffWithinAt 𝕜 ω f s x) (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) {n : ℕ} (v : Fin n → E) (σ : Perm (Fin n)) : iteratedFDerivWithin 𝕜 n f s x (v ∘ σ) = iteratedFDerivWithin 𝕜 n f s x v := by rcases h.contDiffOn' le_rfl (by simp) with ⟨u, u_open, xu, hu⟩ rw [insert_eq_of_mem hx] at hu have : iteratedFDerivWithin 𝕜 n f (s ∩ u) x = iteratedFDerivWithin 𝕜 n f s x := iteratedFDerivWithin_inter_open u_open xu rw [← this] exact AnalyticOn.iteratedFDerivWithin_comp_perm hu.analyticOn (hs.inter u_open) ⟨hx, xu⟩ _ _ theorem ContDiffWithinAt.domDomCongr_iteratedFDerivWithin (h : ContDiffWithinAt 𝕜 ω f s x) (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) {n : ℕ} (σ : Perm (Fin n)) : (iteratedFDerivWithin 𝕜 n f s x).domDomCongr σ = iteratedFDerivWithin 𝕜 n f s x := by ext exact h.iteratedFDerivWithin_comp_perm hs hx _ _ /-- The `n`-th iterated derivative of an analytic function is symmetric. -/ theorem AnalyticOn.iteratedFDeriv_comp_perm (h : AnalyticOn 𝕜 f univ) {n : ℕ} (v : Fin n → E) (σ : Perm (Fin n)) : iteratedFDeriv 𝕜 n f x (v ∘ σ) = iteratedFDeriv 𝕜 n f x v := by rw [← iteratedFDerivWithin_univ] exact h.iteratedFDerivWithin_comp_perm uniqueDiffOn_univ (mem_univ x) _ _ theorem AnalyticOn.domDomCongr_iteratedFDeriv (h : AnalyticOn 𝕜 f univ) {n : ℕ} (σ : Perm (Fin n)) : (iteratedFDeriv 𝕜 n f x).domDomCongr σ = iteratedFDeriv 𝕜 n f x := by rw [← iteratedFDerivWithin_univ] exact h.domDomCongr_iteratedFDerivWithin uniqueDiffOn_univ (mem_univ x) _ /-- The `n`-th iterated derivative of an analytic function is symmetric. -/ theorem ContDiffAt.iteratedFDeriv_comp_perm (h : ContDiffAt 𝕜 ω f x) {n : ℕ} (v : Fin n → E) (σ : Perm (Fin n)) : iteratedFDeriv 𝕜 n f x (v ∘ σ) = iteratedFDeriv 𝕜 n f x v := by rw [← iteratedFDerivWithin_univ] exact h.iteratedFDerivWithin_comp_perm uniqueDiffOn_univ (mem_univ x) _ _ theorem ContDiffAt.domDomCongr_iteratedFDeriv (h : ContDiffAt 𝕜 ω f x) {n : ℕ} (σ : Perm (Fin n)) : (iteratedFDeriv 𝕜 n f x).domDomCongr σ = iteratedFDeriv 𝕜 n f x := by rw [← iteratedFDerivWithin_univ] exact h.domDomCongr_iteratedFDerivWithin uniqueDiffOn_univ (mem_univ x) _
qpoly.v
From HB Require Import structures. From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice. From mathcomp Require Import fintype tuple bigop binomial finset finfun ssralg. From mathcomp Require Import countalg finalg poly polydiv perm fingroup matrix. From mathcomp Require Import mxalgebra mxpoly vector countalg. (******************************************************************************) (* This file defines the algebras R[X]/<p> and their theory. *) (* It mimics the zmod file for polynomials *) (* First, it defines polynomials of bounded size (equivalent of 'I_n), *) (* gives it a structure of choice, finite and countable ring, ..., and *) (* lmodule, when possible. *) (* Internally, the construction uses poly_rV and rVpoly, but they should not *) (* be exposed. *) (* We provide two bases: the 'X^i and the lagrange polynomials. *) (* {poly_n R} == the type of polynomial of size at most n *) (* irreducibleb p == boolean decision procedure for irreducibility *) (* of a bounded size polynomial over a finite idomain *) (* Considering {poly_n F} over a field F, it is a vectType and *) (* 'nX^i == 'X^i as an element of {poly_n R} *) (* polynX == [tuple 'X^0, ..., 'X^(n - 1)], basis of {poly_n R} *) (* x.-lagrange == lagrange basis of {poly_n R} wrt x : nat -> F *) (* x.-lagrange_ i == the ith lagrange polynomial wrt the sampling points x *) (* Second, it defines polynomials quotiented by a poly (equivalent of 'Z_p), *) (* as bounded polynomial. As we are aiming to build a ring structure we need *) (* the polynomial to be monic and of size greater than one. If it is not the *) (* case we quotient by 'X *) (* mk_monic p == the actual polynomial on which we quotient *) (* if p is monic and of size > 1 it is p otherwise 'X *) (* {poly %/ p} == defined as {poly_(size (mk_poly p)).-1 R} on which *) (* there is a ring structure *) (* in_qpoly q == turn the polynomial q into an element of {poly %/ p} by *) (* taking a modulo *) (* 'qX == in_qpoly 'X *) (* The last part that defines the field structure when the quotient is an *) (* irreducible polynomial is defined in field/qfpoly *) (******************************************************************************) Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. Import GRing.Theory. Import Pdiv.CommonRing. Import Pdiv.RingMonic. Import Pdiv.Field. Import FinRing.Theory. Local Open Scope ring_scope. Reserved Notation "'{poly_' n R }" (n at level 2, format "'{poly_' n R }"). Reserved Notation "''nX^' i" (at level 1, format "''nX^' i"). Reserved Notation "x .-lagrange" (format "x .-lagrange"). Reserved Notation "x .-lagrange_" (format "x .-lagrange_"). Reserved Notation "'qX". Reserved Notation "{ 'poly' '%/' p }" (p at level 2, format "{ 'poly' '%/' p }"). Section poly_of_size_zmod. Context {R : nzRingType}. Implicit Types (n : nat). Section poly_of_size. Variable (n : nat). Definition poly_of_size_pred := fun p : {poly R} => size p <= n. Arguments poly_of_size_pred _ /. Definition poly_of_size := [qualify a p | poly_of_size_pred p]. Lemma npoly_submod_closed : submod_closed poly_of_size. Proof. split=> [|x p q sp sq]; rewrite qualifE/= ?size_polyC ?eqxx//. rewrite (leq_trans (size_polyD _ _)) // geq_max. by rewrite (leq_trans (size_scale_leq _ _)). Qed. HB.instance Definition _ := GRing.isSubmodClosed.Build R {poly R} poly_of_size_pred npoly_submod_closed. End poly_of_size. Arguments poly_of_size_pred _ _ /. Section npoly. Variable (n : nat). Record npoly : predArgType := NPoly { polyn :> {poly R}; _ : polyn \is a poly_of_size n }. HB.instance Definition _ := [isSub for @polyn]. Lemma npoly_is_a_poly_of_size (p : npoly) : val p \is a poly_of_size n. Proof. by case: p. Qed. Hint Resolve npoly_is_a_poly_of_size : core. Lemma size_npoly (p : npoly) : size p <= n. Proof. exact: npoly_is_a_poly_of_size. Qed. Hint Resolve size_npoly : core. HB.instance Definition _ := [Choice of npoly by <:]. HB.instance Definition _ := [SubChoice_isSubLmodule of npoly by <:]. Definition npoly_rV : npoly -> 'rV[R]_n := poly_rV \o val. Definition rVnpoly : 'rV[R]_n -> npoly := insubd (0 : npoly) \o rVpoly. Arguments rVnpoly /. Arguments npoly_rV /. Lemma npoly_rV_K : cancel npoly_rV rVnpoly. Proof. move=> p /=; apply/val_inj. by rewrite val_insubd [_ \is a _]size_poly ?poly_rV_K. Qed. Lemma rVnpolyK : cancel rVnpoly npoly_rV. Proof. by move=> p /=; rewrite val_insubd [_ \is a _]size_poly rVpolyK. Qed. Hint Resolve npoly_rV_K rVnpolyK : core. Lemma npoly_vect_axiom : Vector.axiom n npoly. Proof. by exists npoly_rV; [exact:linearPZ | exists rVnpoly]. Qed. HB.instance Definition _ := Lmodule_hasFinDim.Build R npoly npoly_vect_axiom. End npoly. End poly_of_size_zmod. Arguments npoly {R}%_type n%_N. Notation "'{poly_' n R }" := (@npoly R n) : type_scope. #[global] Hint Resolve size_npoly npoly_is_a_poly_of_size : core. Arguments poly_of_size_pred _ _ _ /. Arguments npoly : clear implicits. HB.instance Definition _ (R : countNzRingType) n := [Countable of {poly_n R} by <:]. HB.instance Definition _ (R : finNzRingType) n : isFinite {poly_n R} := CanIsFinite (@npoly_rV_K R n). Section npoly_theory. Context (R : nzRingType) {n : nat}. Lemma polyn_is_linear : linear (@polyn _ _ : {poly_n R} -> _). Proof. by []. Qed. HB.instance Definition _ := GRing.isSemilinear.Build R {poly_n R} {poly R} _ (polyn (n:=n)) (GRing.semilinear_linear polyn_is_linear). Canonical mk_npoly (E : nat -> R) : {poly_n R} := @NPoly R _ (\poly_(i < n) E i) (size_poly _ _). Fact size_npoly0 : size (0 : {poly R}) <= n. Proof. by rewrite size_poly0. Qed. Definition npoly0 := NPoly (size_npoly0). Fact npolyp_key : unit. Proof. exact: tt. Qed. Definition npolyp : {poly R} -> {poly_n R} := locked_with npolyp_key (mk_npoly \o (nth 0)). Definition npoly_of_seq := npolyp \o Poly. Lemma npolyP (p q : {poly_n R}) : nth 0 p =1 nth 0 q <-> p = q. Proof. by split => [/polyP/val_inj|->]. Qed. Lemma coef_npolyp (p : {poly R}) i : (npolyp p)`_i = if i < n then p`_i else 0. Proof. by rewrite /npolyp unlock /= coef_poly. Qed. Lemma big_coef_npoly (p : {poly_n R}) i : n <= i -> p`_i = 0. Proof. by move=> i_big; rewrite nth_default // (leq_trans _ i_big) ?size_npoly. Qed. Lemma npolypK (p : {poly R}) : size p <= n -> npolyp p = p :> {poly R}. Proof. move=> spn; apply/polyP=> i; rewrite coef_npolyp. by have [i_big|i_small] // := ltnP; rewrite nth_default ?(leq_trans spn). Qed. Lemma coefn_sum (I : Type) (r : seq I) (P : pred I) (F : I -> {poly_n R}) (k : nat) : (\sum_(i <- r | P i) F i)`_k = \sum_(i <- r | P i) (F i)`_k. Proof. by rewrite !raddf_sum //= coef_sum. Qed. End npoly_theory. Arguments mk_npoly {R} n E. Arguments npolyp {R} n p. Section fin_npoly. Variable R : finNzRingType. Variable n : nat. Implicit Types p q : {poly_n R}. Definition npoly_enum : seq {poly_n R} := if n isn't n.+1 then [:: npoly0 _] else pmap insub [seq \poly_(i < n.+1) c (inord i) | c : (R ^ n.+1)%type]. Lemma npoly_enum_uniq : uniq npoly_enum. Proof. rewrite /npoly_enum; case: n=> [|k] //. rewrite pmap_sub_uniq // map_inj_uniq => [|f g eqfg]; rewrite ?enum_uniq //. apply/ffunP => /= i; have /(congr1 (fun p : {poly _} => p`_i)) := eqfg. by rewrite !coef_poly ltn_ord inord_val. Qed. Lemma mem_npoly_enum p : p \in npoly_enum. Proof. rewrite /npoly_enum; case: n => [|k] // in p *. case: p => [p sp] /=. by rewrite in_cons -val_eqE /= -size_poly_leq0 [size _ <= _]sp. rewrite mem_pmap_sub; apply/mapP. eexists [ffun i : 'I__ => p`_i]; first by rewrite mem_enum. apply/polyP => i; rewrite coef_poly. have [i_small|i_big] := ltnP; first by rewrite ffunE /= inordK. by rewrite nth_default // 1?(leq_trans _ i_big) // size_npoly. Qed. Lemma card_npoly : #|{poly_n R}| = (#|R| ^ n)%N. Proof. rewrite -(card_imset _ (can_inj (@npoly_rV_K _ _))) eq_cardT. by rewrite -cardT /= card_mx mul1n. by move=> v; apply/imsetP; exists (rVnpoly v); rewrite ?rVnpolyK //. Qed. End fin_npoly. Section Irreducible. Variable R : finIdomainType. Variable p : {poly R}. Definition irreducibleb := ((1 < size p) && [forall q : {poly_((size p).-1) R}, (Pdiv.Ring.rdvdp q p)%R ==> (size q <= 1)])%N. Lemma irreducibleP : reflect (irreducible_poly p) irreducibleb. Proof. rewrite /irreducibleb /irreducible_poly. apply: (iffP idP) => [/andP[sp /'forall_implyP /= Fp]|[sp Fpoly]]. have sp_gt0 : size p > 0 by case: size sp. have p_neq0 : p != 0 by rewrite -size_poly_eq0; case: size sp. split => // q sq_neq1 dvd_qp; rewrite -dvdp_size_eqp // eqn_leq dvdp_leq //=. apply: contraNT sq_neq1; rewrite -ltnNge => sq_lt_sp. have q_small: (size q <= (size p).-1)%N by rewrite -ltnS prednK. rewrite Pdiv.Idomain.dvdpE in dvd_qp. have /= := Fp (NPoly q_small) dvd_qp. rewrite leq_eqVlt ltnS => /orP[//|]; rewrite size_poly_leq0 => /eqP q_eq0. by rewrite -Pdiv.Idomain.dvdpE q_eq0 dvd0p (negPf p_neq0) in dvd_qp. have sp_gt0 : size p > 0 by case: size sp. rewrite sp /=; apply/'forall_implyP => /= q. rewrite -Pdiv.Idomain.dvdpE=> dvd_qp. have [/eqP->//|/Fpoly/(_ dvd_qp)/eqp_size sq_eq_sp] := boolP (size q == 1%N). by have := size_npoly q; rewrite sq_eq_sp -ltnS prednK ?ltnn. Qed. End Irreducible. Section Vspace. Variable (K : fieldType) (n : nat). Lemma dim_polyn : \dim (fullv : {vspace {poly_n K}}) = n. Proof. by rewrite [LHS]mxrank_gen mxrank1. Qed. Definition npolyX : n.-tuple {poly_n K} := [tuple npolyp n 'X^i | i < n]. Notation "''nX^' i" := (tnth npolyX i). Lemma npolyXE (i : 'I_n) : 'nX^i = 'X^i :> {poly _}. Proof. by rewrite tnth_map tnth_ord_tuple npolypK // size_polyXn. Qed. Lemma nth_npolyX (i : 'I_n) : npolyX`_i = 'nX^i. Proof. by rewrite -tnth_nth. Qed. Lemma npolyX_free : free npolyX. Proof. apply/freeP=> u /= sum_uX_eq0 i; have /npolyP /(_ i) := sum_uX_eq0. rewrite (@big_morph _ _ _ 0%R +%R) // coef_sum coef0. rewrite (bigD1 i) ?big1 /= ?addr0 ?coefZ ?(nth_map 0%N) ?size_iota //. by rewrite nth_npolyX npolyXE coefXn eqxx mulr1. move=> j; rewrite -val_eqE /= => neq_ji. by rewrite nth_npolyX npolyXE coefZ coefXn eq_sym (negPf neq_ji) mulr0. Qed. Lemma npolyX_full : basis_of fullv npolyX. Proof. by rewrite basisEfree npolyX_free subvf size_map size_enum_ord dim_polyn /=. Qed. Lemma npolyX_coords (p : {poly_n K}) i : coord npolyX i p = p`_i. Proof. rewrite [p in RHS](coord_basis npolyX_full) ?memvf // coefn_sum. rewrite (bigD1 i) //= coefZ nth_npolyX npolyXE coefXn eqxx mulr1 big1 ?addr0//. move=> j; rewrite -val_eqE => /= neq_ji. by rewrite coefZ nth_npolyX npolyXE coefXn eq_sym (negPf neq_ji) mulr0. Qed. Lemma npolyX_gen (p : {poly K}) : (size p <= n)%N -> p = \sum_(i < n) p`_i *: 'nX^i. Proof. move=> sp; rewrite -[p](@npolypK _ n) //. rewrite [npolyp _ _ in LHS](coord_basis npolyX_full) ?memvf //. rewrite (@big_morph _ _ _ 0%R +%R) // !raddf_sum. by apply: eq_bigr=> i _; rewrite npolyX_coords //= nth_npolyX npolyXE. Qed. Section lagrange. Variables (x : nat -> K). Notation lagrange_def := (fun i :'I_n => let k := i in let p := \prod_(j < n | j != k) ('X - (x j)%:P) in (p.[x k]^-1)%:P * p). Fact lagrange_key : unit. Proof. exact: tt. Qed. Definition lagrange := locked_with lagrange_key [tuple npolyp n (lagrange_def i) | i < n]. Notation lagrange_ := (tnth lagrange). Hypothesis n_gt0 : (0 < n)%N. Hypothesis x_inj : injective x. Let lagrange_def_sample (i j : 'I_n) : (lagrange_def i).[x j] = (i == j)%:R. Proof. clear n_gt0; rewrite hornerM hornerC; set p := (\prod_(_ < _ | _) _). have [<-|neq_ij] /= := altP eqP. rewrite mulVf // horner_prod; apply/prodf_neq0 => k neq_ki. by rewrite hornerXsubC subr_eq0 inj_eq // eq_sym. rewrite [X in _ * X]horner_prod (bigD1 j) 1?eq_sym //=. by rewrite hornerXsubC subrr mul0r mulr0. Qed. Let size_lagrange_def i : size (lagrange_def i) = n. Proof. rewrite size_Cmul; last first. suff : (lagrange_def i).[x i] != 0. by rewrite hornerE mulf_eq0 => /norP []. by rewrite lagrange_def_sample ?eqxx ?oner_eq0. rewrite size_prod /=; last first. by move=> j neq_ji; rewrite polyXsubC_eq0. rewrite (eq_bigr (fun=> (2 * 1)%N)); last first. by move=> j neq_ji; rewrite size_XsubC. rewrite -big_distrr /= sum1_card cardC1 card_ord /=. by case: (n) {i} n_gt0 => ?; rewrite mul2n -addnn -addSn addnK. Qed. Lemma lagrangeE i : lagrange_ i = lagrange_def i :> {poly _}. Proof. rewrite [lagrange]unlock tnth_map. by rewrite [val _]npolypK tnth_ord_tuple // size_lagrange_def. Qed. Lemma nth_lagrange (i : 'I_n) : lagrange`_i = lagrange_ i. Proof. by rewrite -tnth_nth. Qed. Lemma size_lagrange_ i : size (lagrange_ i) = n. Proof. by rewrite lagrangeE size_lagrange_def. Qed. Lemma size_lagrange : size lagrange = n. Proof. by rewrite size_tuple. Qed. Lemma lagrange_sample (i j : 'I_n) : (lagrange_ i).[x j] = (i == j)%:R. Proof. by rewrite lagrangeE lagrange_def_sample. Qed. Lemma lagrange_free : free lagrange. Proof. apply/freeP=> lambda eq_l i. have /(congr1 (fun p : {poly__ _} => p.[x i])) := eq_l. rewrite (@big_morph _ _ _ 0%R +%R) // horner_sum horner0. rewrite (bigD1 i) // big1 => [|j /= /negPf ji] /=; by rewrite ?hornerE nth_lagrange lagrange_sample ?eqxx ?ji ?mulr1 ?mulr0. Qed. Lemma lagrange_full : basis_of fullv lagrange. Proof. by rewrite basisEfree lagrange_free subvf size_lagrange dim_polyn /=. Qed. Lemma lagrange_coords (p : {poly_n K}) i : coord lagrange i p = p.[x i]. Proof. rewrite [p in RHS](coord_basis lagrange_full) ?memvf //. rewrite (@big_morph _ _ _ 0%R +%R) // horner_sum. rewrite (bigD1 i) // big1 => [|j /= /negPf ji] /=; by rewrite ?hornerE nth_lagrange lagrange_sample ?eqxx ?ji ?mulr1 ?mulr0. Qed. Lemma lagrange_gen (p : {poly K}) : (size p <= n)%N -> p = \sum_(i < n) p.[x i]%:P * lagrange_ i. Proof. move=> sp; rewrite -[p](@npolypK _ n) //. rewrite [npolyp _ _ in LHS](coord_basis lagrange_full) ?memvf //. rewrite (@big_morph _ _ _ 0%R +%R) //; apply: eq_bigr=> i _. by rewrite lagrange_coords mul_polyC nth_lagrange. Qed. End lagrange. End Vspace. Notation "''nX^' i" := (tnth (npolyX _) i) : ring_scope. Notation "x .-lagrange" := (lagrange x) : ring_scope. Notation "x .-lagrange_" := (tnth x.-lagrange) : ring_scope. Section Qpoly. Variable R : nzRingType. Variable h : {poly R}. Definition mk_monic := if (1 < size h)%N && (h \is monic) then h else 'X. Definition qpoly := {poly_(size mk_monic).-1 R}. End Qpoly. Notation "{ 'poly' '%/' p }" := (qpoly p) : type_scope. Section QpolyProp. Variable R : nzRingType. Variable h : {poly R}. Lemma monic_mk_monic : (mk_monic h) \is monic. Proof. rewrite /mk_monic; case: leqP=> [_|/=]; first by apply: monicX. by case E : (h \is monic) => [->//|] => _; apply: monicX. Qed. Lemma size_mk_monic_gt1 : (1 < size (mk_monic h))%N. Proof. by rewrite !fun_if size_polyX; case: leqP => //=; rewrite if_same. Qed. Lemma size_mk_monic_gt0 : (0 < size (mk_monic h))%N. Proof. by rewrite (leq_trans _ size_mk_monic_gt1). Qed. Lemma mk_monic_neq0 : mk_monic h != 0. Proof. by rewrite -size_poly_gt0 size_mk_monic_gt0. Qed. Lemma size_mk_monic (p : {poly %/ h}) : size p < size (mk_monic h). Proof. have: (p : {poly R}) \is a poly_of_size (size (mk_monic h)).-1 by case: p. by rewrite qualifE/= -ltnS prednK // size_mk_monic_gt0. Qed. (* standard inject *) Lemma poly_of_size_mod p : rmodp p (mk_monic h) \is a poly_of_size (size (mk_monic h)).-1. Proof. rewrite qualifE/= -ltnS prednK ?size_mk_monic_gt0 //. by apply: ltn_rmodpN0; rewrite mk_monic_neq0. Qed. Definition in_qpoly p : {poly %/ h} := NPoly (poly_of_size_mod p). Lemma in_qpoly_small (p : {poly R}) : size p < size (mk_monic h) -> in_qpoly p = p :> {poly R}. Proof. exact: rmodp_small. Qed. Lemma in_qpoly0 : in_qpoly 0 = 0. Proof. by apply/val_eqP; rewrite /= rmod0p. Qed. Lemma in_qpolyD p q : in_qpoly (p + q) = in_qpoly p + in_qpoly q. Proof. by apply/val_eqP=> /=; rewrite rmodpD ?monic_mk_monic. Qed. Lemma in_qpolyZ a p : in_qpoly (a *: p) = a *: in_qpoly p. Proof. apply/val_eqP=> /=; rewrite rmodpZ ?monic_mk_monic //. Qed. Fact in_qpoly_is_linear : linear in_qpoly. Proof. by move=> k p q; rewrite in_qpolyD in_qpolyZ. Qed. HB.instance Definition _ := GRing.isSemilinear.Build R {poly R} {poly_(size (mk_monic h)).-1 R} _ in_qpoly (GRing.semilinear_linear in_qpoly_is_linear). Lemma qpolyC_proof k : (k%:P : {poly R}) \is a poly_of_size (size (mk_monic h)).-1. Proof. rewrite qualifE/= -ltnS size_polyC prednK ?size_mk_monic_gt0 //. by rewrite (leq_ltn_trans _ size_mk_monic_gt1) //; case: eqP. Qed. Definition qpolyC k : {poly %/ h} := NPoly (qpolyC_proof k). Lemma qpolyCE k : qpolyC k = k%:P :> {poly R}. Proof. by []. Qed. Lemma qpolyC0 : qpolyC 0 = 0. Proof. by apply/val_eqP/eqP. Qed. Definition qpoly1 := qpolyC 1. Definition qpoly_mul (q1 q2 : {poly %/ h}) : {poly %/ h} := in_qpoly ((q1 : {poly R}) * q2). Lemma qpoly_mul1z : left_id qpoly1 qpoly_mul. Proof. by move=> x; apply: val_inj; rewrite /= mul1r rmodp_small // size_mk_monic. Qed. Lemma qpoly_mulz1 : right_id qpoly1 qpoly_mul. Proof. by move=> x; apply: val_inj; rewrite /= mulr1 rmodp_small // size_mk_monic. Qed. Lemma qpoly_nontrivial : qpoly1 != 0. Proof. by apply/eqP/val_eqP; rewrite /= oner_eq0. Qed. Definition qpolyX := in_qpoly 'X. Notation "'qX" := qpolyX. Lemma qpolyXE : 2 < size h -> h \is monic -> 'qX = 'X :> {poly R}. Proof. move=> sh_gt2 h_mo. by rewrite in_qpoly_small // size_polyX /mk_monic ifT // (ltn_trans _ sh_gt2). Qed. End QpolyProp. Notation "'qX" := (qpolyX _) : ring_scope. Lemma mk_monic_X (R : nzRingType) : mk_monic 'X = 'X :> {poly R}. Proof. by rewrite /mk_monic size_polyX monicX. Qed. Lemma mk_monic_Xn (R : nzRingType) n : mk_monic 'X^n = 'X^(n.-1.+1) :> {poly R}. Proof. by case: n => [|n]; rewrite /mk_monic size_polyXn monicXn /= ?expr1. Qed. Lemma card_qpoly (R : finNzRingType) (h : {poly R}): #|{poly %/ h}| = #|R| ^ (size (mk_monic h)).-1. Proof. by rewrite card_npoly. Qed. Lemma card_monic_qpoly (R : finNzRingType) (h : {poly R}): 1 < size h -> h \is monic -> #|{poly %/ h}| = #|R| ^ (size h).-1. Proof. by move=> sh_gt1 hM; rewrite card_qpoly /mk_monic sh_gt1 hM. Qed. Section QRing. Variable A : comNzRingType. Variable h : {poly A}. (* Ring operations *) Lemma qpoly_mulC : commutative (@qpoly_mul A h). Proof. by move=> p q; apply: val_inj; rewrite /= mulrC. Qed. Lemma qpoly_mulA : associative (@qpoly_mul A h). Proof. have rPM := monic_mk_monic h; move=> p q r; apply: val_inj. by rewrite /= rmodp_mulml // rmodp_mulmr // mulrA. Qed. Lemma qpoly_mul_addr : right_distributive (@qpoly_mul A h) +%R. Proof. have rPM := monic_mk_monic h; move=> p q r; apply: val_inj. by rewrite /= !(mulrDr, rmodp_mulmr, rmodpD). Qed. Lemma qpoly_mul_addl : left_distributive (@qpoly_mul A h) +%R. Proof. by move=> p q r; rewrite -!(qpoly_mulC r) qpoly_mul_addr. Qed. HB.instance Definition _ := GRing.Zmodule_isComNzRing.Build {poly__ A} qpoly_mulA qpoly_mulC (@qpoly_mul1z _ h) qpoly_mul_addl (@qpoly_nontrivial _ h). HB.instance Definition _ := GRing.ComNzRing.on {poly %/ h}. Lemma in_qpoly1 : in_qpoly h 1 = 1. Proof. apply/val_eqP/eqP/in_qpoly_small. by rewrite size_polyC oner_eq0 /= size_mk_monic_gt1. Qed. Lemma in_qpolyM q1 q2 : in_qpoly h (q1 * q2) = in_qpoly h q1 * in_qpoly h q2. Proof. apply/val_eqP => /=. by rewrite rmodp_mulml ?rmodp_mulmr // monic_mk_monic. Qed. Fact in_qpoly_monoid_morphism : monoid_morphism (in_qpoly h). Proof. by split; [ apply: in_qpoly1 | apply: in_qpolyM]. Qed. #[warning="-deprecated-since-mathcomp-2.5.0", deprecated(since="mathcomp 2.5.0", note="use `in_qpoly_is_monoid_morphism` instead")] Definition in_qpoly_is_multiplicative := (fun g => (g.2,g.1)) in_qpoly_monoid_morphism. HB.instance Definition _ := GRing.isMonoidMorphism.Build {poly A} {poly %/ h} (in_qpoly h) in_qpoly_monoid_morphism. Lemma poly_of_qpoly_sum I (r : seq I) (P1 : pred I) (F : I -> {poly %/ h}) : ((\sum_(i <- r | P1 i) F i) = \sum_(p <- r | P1 p) ((F p) : {poly A}) :> {poly A})%R. Proof. by elim/big_rec2: _ => // i p q IH <-. Qed. Lemma poly_of_qpolyD (p q : {poly %/ h}) : p + q= (p : {poly A}) + q :> {poly A}. Proof. by []. Qed. Lemma qpolyC_natr p : (p%:R : {poly %/ h}) = p%:R :> {poly A}. Proof. by elim: p => //= p IH; rewrite !mulrS poly_of_qpolyD IH. Qed. Lemma pchar_qpoly : [pchar {poly %/ h}] =i [pchar A]. Proof. move=> p; rewrite !inE; congr (_ && _). apply/eqP/eqP=> [/(congr1 val) /=|pE]; last first. by apply: val_inj => //=; rewrite qpolyC_natr /= -polyC_natr pE. rewrite !qpolyC_natr -!polyC_natr => /(congr1 val) /=. by rewrite polyseqC polyseq0; case: eqP. Qed. Lemma poly_of_qpolyM (p q : {poly %/ h}) : p * q = rmodp ((p : {poly A}) * q) (mk_monic h) :> {poly A}. Proof. by []. Qed. Lemma poly_of_qpolyX (p : {poly %/ h}) n : p ^+ n = rmodp ((p : {poly A}) ^+ n) (mk_monic h) :> {poly A}. Proof. have HhQ := monic_mk_monic h. elim: n => //= [|n IH]. rewrite rmodp_small // size_polyC ?(leq_ltn_trans _ (size_mk_monic_gt1 _)) //. by case: eqP. by rewrite exprS /= IH // rmodp_mulmr // -exprS. Qed. Lemma qpolyCN (a : A) : qpolyC h (- a) = -(qpolyC h a). Proof. apply: val_inj; rewrite /= raddfN //= raddfN. Qed. Lemma qpolyCD : {morph (qpolyC h) : a b / a + b >-> a + b}%R. Proof. by move=> a b; apply/val_eqP/eqP=> /=; rewrite -!raddfD. Qed. Lemma qpolyCM : {morph (qpolyC h) : a b / a * b >-> a * b}%R. Proof. move=> a b; apply/val_eqP/eqP=> /=; rewrite -polyCM rmodp_small //=. have := qpolyC_proof h (a * b). by rewrite qualifE/= -ltnS prednK // size_mk_monic_gt0. Qed. Lemma qpolyC_is_zmod_morphism : zmod_morphism (qpolyC h). Proof. by move=> x y; rewrite qpolyCD qpolyCN. Qed. #[warning="-deprecated-since-mathcomp-2.5.0", deprecated(since="mathcomp 2.5.0", note="use `qpolyC_is_zmod_morphism` instead")] Definition qpolyC_is_additive := qpolyC_is_zmod_morphism. Lemma qpolyC_is_monoid_morphism : monoid_morphism (qpolyC h). Proof. by split=> // x y; rewrite qpolyCM. Qed. #[warning="-deprecated-since-mathcomp-2.5.0", deprecated(since="mathcomp 2.5.0", note="use `qpolyC_is_monoid_morphism` instead")] Definition qpolyC_is_multiplicative := (fun g => (g.2,g.1)) qpolyC_is_monoid_morphism. HB.instance Definition _ := GRing.isZmodMorphism.Build A {poly %/ h} (qpolyC h) qpolyC_is_zmod_morphism. HB.instance Definition _ := GRing.isMonoidMorphism.Build A {poly %/ h} (qpolyC h) qpolyC_is_monoid_morphism. Definition qpoly_scale k (p : {poly %/ h}) : {poly %/ h} := (k *: p)%R. Fact qpoly_scaleA a b p : qpoly_scale a (qpoly_scale b p) = qpoly_scale (a * b) p. Proof. by apply/val_eqP; rewrite /= scalerA. Qed. Fact qpoly_scale1l : left_id 1%R qpoly_scale. Proof. by move=> p; apply/val_eqP; rewrite /= scale1r. Qed. Fact qpoly_scaleDr a : {morph qpoly_scale a : p q / (p + q)%R}. Proof. by move=> p q; apply/val_eqP; rewrite /= scalerDr. Qed. Fact qpoly_scaleDl p : {morph qpoly_scale^~ p : a b / a + b}%R. Proof. by move=> a b; apply/val_eqP; rewrite /= scalerDl. Qed. Fact qpoly_scaleAl a p q : qpoly_scale a (p * q) = (qpoly_scale a p * q). Proof. by apply/val_eqP; rewrite /= -scalerAl rmodpZ // monic_mk_monic. Qed. Fact qpoly_scaleAr a p q : qpoly_scale a (p * q) = p * (qpoly_scale a q). Proof. by apply/val_eqP; rewrite /= -scalerAr rmodpZ // monic_mk_monic. Qed. HB.instance Definition _ := GRing.Lmodule_isLalgebra.Build A {poly__ A} qpoly_scaleAl. HB.instance Definition _ := GRing.Lalgebra.on {poly %/ h}. HB.instance Definition _ := GRing.Lalgebra_isAlgebra.Build A {poly__ A} qpoly_scaleAr. HB.instance Definition _ := GRing.Algebra.on {poly %/ h}. Lemma poly_of_qpolyZ (p : {poly %/ h}) a : a *: p = a *: (p : {poly A}) :> {poly A}. Proof. by []. Qed. End QRing. #[deprecated(since="mathcomp 2.4.0", note="Use pchar_qpoly instead.")] Notation char_qpoly := (pchar_qpoly) (only parsing). Section Field. Variable R : fieldType. Variable h : {poly R}. Local Notation hQ := (mk_monic h). Definition qpoly_inv (p : {poly %/ h}) := if coprimep hQ p then let v : {poly %/ h} := in_qpoly h (egcdp hQ p).2 in ((lead_coef (v * p)) ^-1 *: v) else p. (* Ugly *) Lemma qpoly_mulVz (p : {poly %/ h}) : coprimep hQ p -> (qpoly_inv p * p = 1)%R. Proof. have hQM := monic_mk_monic h. move=> hCp; apply: val_inj; rewrite /qpoly_inv /in_qpoly hCp /=. have p_neq0 : p != 0%R. apply/eqP=> pZ; move: hCp; rewrite pZ. rewrite coprimep0 -size_poly_eq1. by case: size (size_mk_monic_gt1 h) => [|[]]. have F : (egcdp hQ p).1 * hQ + (egcdp hQ p).2 * p %= 1. apply: eqp_trans _ (_ : gcdp hQ p %= _). rewrite eqp_sym. by case: (egcdpP (mk_monic_neq0 h) p_neq0). by rewrite -size_poly_eq1. rewrite rmodp_mulml // -scalerAl rmodpZ // rmodp_mulml //. rewrite -[rmodp]/Pdiv.Ring.rmodp -!Pdiv.IdomainMonic.modpE //. have := eqp_modpl hQ F. rewrite modpD // modp_mull add0r // . rewrite [(1 %% _)%R]modp_small => // [egcdE|]; last first. by rewrite size_polyC oner_eq0 size_mk_monic_gt1. rewrite {2}(eqpfP egcdE) lead_coefC divr1 alg_polyC scale_polyC mulVf //. rewrite lead_coef_eq0. apply/eqP => egcdZ. by move: egcdE; rewrite -size_poly_eq1 egcdZ size_polyC eq_sym eqxx. Qed. Lemma qpoly_mulzV (p : {poly %/ h}) : coprimep hQ p -> (p * (qpoly_inv p) = 1)%R. Proof. by move=> hCp; rewrite /= mulrC qpoly_mulVz. Qed. Lemma qpoly_intro_unit (p q : {poly %/ h}) : (q * p = 1)%R -> coprimep hQ p. Proof. have hQM := monic_mk_monic h. case; rewrite -[rmodp]/Pdiv.Ring.rmodp -!Pdiv.IdomainMonic.modpE // => qp1. have:= coprimep1 hQ. rewrite -coprimep_modr -[1%R]qp1 !coprimep_modr coprimepMr; by case/andP. Qed. Lemma qpoly_inv_out (p : {poly %/ h}) : ~~ coprimep hQ p -> qpoly_inv p = p. Proof. by rewrite /qpoly_inv => /negPf->. Qed. HB.instance Definition _ := GRing.ComNzRing_hasMulInverse.Build {poly__ _} qpoly_mulVz qpoly_intro_unit qpoly_inv_out. HB.instance Definition _ := GRing.ComUnitAlgebra.on {poly %/ h}. Lemma irreducible_poly_coprime (A : idomainType) (p q : {poly A}) : irreducible_poly p -> coprimep p q = ~~(p %| q)%R. Proof. case => H1 H2; apply/coprimepP/negP. move=> sPq H. by have := sPq p (dvdpp _) H; rewrite -size_poly_eq1; case: size H1 => [|[]]. move=> pNDq d dDp dPq. rewrite -size_poly_eq1; case: eqP => // /eqP /(H2 _) => /(_ dDp) dEp. by case: pNDq; rewrite -(eqp_dvdl _ dEp). Qed. End Field.
SemiconjSup.lean
/- Copyright (c) 2020 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.Algebra.Group.Units.Equiv import Mathlib.Algebra.Order.Group.End import Mathlib.Logic.Function.Conjugate import Mathlib.Order.Bounds.OrderIso import Mathlib.Order.OrdContinuous /-! # Semiconjugate by `sSup` In this file we prove two facts about semiconjugate (families of) functions. First, if an order isomorphism `fa : α → α` is semiconjugate to an order embedding `fb : β → β` by `g : α → β`, then `fb` is semiconjugate to `fa` by `y ↦ sSup {x | g x ≤ y}`, see `Semiconj.symm_adjoint`. Second, consider two actions `f₁ f₂ : G → α → α` of a group on a complete lattice by order isomorphisms. Then the map `x ↦ ⨆ g : G, (f₁ g)⁻¹ (f₂ g x)` semiconjugates each `f₁ g'` to `f₂ g'`, see `Function.sSup_div_semiconj`. In the case of a conditionally complete lattice, a similar statement holds true under an additional assumption that each set `{(f₁ g)⁻¹ (f₂ g x) | g : G}` is bounded above, see `Function.csSup_div_semiconj`. The lemmas come from [Étienne Ghys, Groupes d'homéomorphismes du cercle et cohomologie bornée][ghys87:groupes], Proposition 2.1 and 5.4 respectively. In the paper they are formulated for homeomorphisms of the circle, so in order to apply results from this file one has to lift these homeomorphisms to the real line first. -/ -- Guard against import creep assert_not_exists Finset variable {α β γ : Type*} open Set /-- We say that `g : β → α` is an order right adjoint function for `f : α → β` if it sends each `y` to a least upper bound for `{x | f x ≤ y}`. If `α` is a partial order, and `f : α → β` has a right adjoint, then this right adjoint is unique. -/ def IsOrderRightAdjoint [Preorder α] [Preorder β] (f : α → β) (g : β → α) := ∀ y, IsLUB { x | f x ≤ y } (g y) theorem isOrderRightAdjoint_sSup [CompleteSemilatticeSup α] [Preorder β] (f : α → β) : IsOrderRightAdjoint f fun y => sSup { x | f x ≤ y } := fun _ => isLUB_sSup _ theorem isOrderRightAdjoint_csSup [ConditionallyCompleteLattice α] [Preorder β] (f : α → β) (hne : ∀ y, ∃ x, f x ≤ y) (hbdd : ∀ y, BddAbove { x | f x ≤ y }) : IsOrderRightAdjoint f fun y => sSup { x | f x ≤ y } := fun y => isLUB_csSup (hne y) (hbdd y) namespace IsOrderRightAdjoint protected theorem unique [PartialOrder α] [Preorder β] {f : α → β} {g₁ g₂ : β → α} (h₁ : IsOrderRightAdjoint f g₁) (h₂ : IsOrderRightAdjoint f g₂) : g₁ = g₂ := funext fun y => (h₁ y).unique (h₂ y) theorem right_mono [Preorder α] [Preorder β] {f : α → β} {g : β → α} (h : IsOrderRightAdjoint f g) : Monotone g := fun y₁ y₂ hy => ((h y₁).mono (h y₂)) fun _ hx => le_trans hx hy theorem orderIso_comp [Preorder α] [Preorder β] [Preorder γ] {f : α → β} {g : β → α} (h : IsOrderRightAdjoint f g) (e : β ≃o γ) : IsOrderRightAdjoint (e ∘ f) (g ∘ e.symm) := fun y => by simpa [e.le_symm_apply] using h (e.symm y) theorem comp_orderIso [Preorder α] [Preorder β] [Preorder γ] {f : α → β} {g : β → α} (h : IsOrderRightAdjoint f g) (e : γ ≃o α) : IsOrderRightAdjoint (f ∘ e) (e.symm ∘ g) := by intro y change IsLUB (e ⁻¹' { x | f x ≤ y }) (e.symm (g y)) rw [e.isLUB_preimage, e.apply_symm_apply] exact h y end IsOrderRightAdjoint namespace Function /-- If an order automorphism `fa` is semiconjugate to an order embedding `fb` by a function `g` and `g'` is an order right adjoint of `g` (i.e. `g' y = sSup {x | f x ≤ y}`), then `fb` is semiconjugate to `fa` by `g'`. This is a version of Proposition 2.1 from [Étienne Ghys, Groupes d'homéomorphismes du cercle et cohomologie bornée][ghys87:groupes]. -/ theorem Semiconj.symm_adjoint [PartialOrder α] [Preorder β] {fa : α ≃o α} {fb : β ↪o β} {g : α → β} (h : Function.Semiconj g fa fb) {g' : β → α} (hg' : IsOrderRightAdjoint g g') : Function.Semiconj g' fb fa := by refine fun y => (hg' _).unique ?_ rw [← fa.surjective.image_preimage { x | g x ≤ fb y }, preimage_setOf_eq] simp only [h.eq, fb.le_iff_le, fa.leftOrdContinuous (hg' _)] variable {G : Type*} theorem semiconj_of_isLUB [PartialOrder α] [Group G] (f₁ f₂ : G →* α ≃o α) {h : α → α} (H : ∀ x, IsLUB (range fun g' => (f₁ g')⁻¹ (f₂ g' x)) (h x)) (g : G) : Function.Semiconj h (f₂ g) (f₁ g) := by refine fun y => (H _).unique ?_ have := (f₁ g).leftOrdContinuous (H y) rw [← range_comp, ← (Equiv.mulRight g).surjective.range_comp _] at this simpa [comp_def] using this /-- Consider two actions `f₁ f₂ : G → α → α` of a group on a complete lattice by order isomorphisms. Then the map `x ↦ ⨆ g : G, (f₁ g)⁻¹ (f₂ g x)` semiconjugates each `f₁ g'` to `f₂ g'`. This is a version of Proposition 5.4 from [Étienne Ghys, Groupes d'homéomorphismes du cercle et cohomologie bornée][ghys87:groupes]. -/ theorem sSup_div_semiconj [CompleteLattice α] [Group G] (f₁ f₂ : G →* α ≃o α) (g : G) : Function.Semiconj (fun x => ⨆ g' : G, (f₁ g')⁻¹ (f₂ g' x)) (f₂ g) (f₁ g) := semiconj_of_isLUB f₁ f₂ (fun _ => isLUB_iSup) _ /-- Consider two actions `f₁ f₂ : G → α → α` of a group on a conditionally complete lattice by order isomorphisms. Suppose that each set $s(x)=\{f_1(g)^{-1} (f_2(g)(x)) | g \in G\}$ is bounded above. Then the map `x ↦ sSup s(x)` semiconjugates each `f₁ g'` to `f₂ g'`. This is a version of Proposition 5.4 from [Étienne Ghys, Groupes d'homéomorphismes du cercle et cohomologie bornée][ghys87:groupes]. -/ theorem csSup_div_semiconj [ConditionallyCompleteLattice α] [Group G] (f₁ f₂ : G →* α ≃o α) (hbdd : ∀ x, BddAbove (range fun g => (f₁ g)⁻¹ (f₂ g x))) (g : G) : Function.Semiconj (fun x => ⨆ g' : G, (f₁ g')⁻¹ (f₂ g' x)) (f₂ g) (f₁ g) := semiconj_of_isLUB f₁ f₂ (fun x => isLUB_csSup (range_nonempty _) (hbdd x)) _ end Function
Membership.lean
/- Copyright (c) 2018 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Kenny Lau, Johan Commelin, Mario Carneiro, Kevin Buzzard, Amelia Livingston, Yury Kudryashov -/ import Mathlib.Algebra.BigOperators.Group.Multiset.Defs import Mathlib.Algebra.FreeMonoid.Basic import Mathlib.Algebra.Group.Idempotent import Mathlib.Algebra.Group.Nat.Hom import Mathlib.Algebra.Group.Submonoid.MulOpposite import Mathlib.Algebra.Group.Submonoid.Operations import Mathlib.Data.Fintype.EquivFin import Mathlib.Data.Int.Basic /-! # Submonoids: membership criteria In this file we prove various facts about membership in a submonoid: * `pow_mem`, `nsmul_mem`: if `x ∈ S` where `S` is a multiplicative (resp., additive) submonoid and `n` is a natural number, then `x^n` (resp., `n • x`) belongs to `S`; * `mem_iSup_of_directed`, `coe_iSup_of_directed`, `mem_sSup_of_directedOn`, `coe_sSup_of_directedOn`: the supremum of a directed collection of submonoid is their union. * `sup_eq_range`, `mem_sup`: supremum of two submonoids `S`, `T` of a commutative monoid is the set of products; * `closure_singleton_eq`, `mem_closure_singleton`, `mem_closure_pair`: the multiplicative (resp., additive) closure of `{x}` consists of powers (resp., natural multiples) of `x`, and a similar result holds for the closure of `{x, y}`. ## Tags submonoid, submonoids -/ assert_not_exists MonoidWithZero variable {M A B : Type*} section Assoc variable [Monoid M] [SetLike B M] [SubmonoidClass B M] {S : B} end Assoc section NonAssoc variable [MulOneClass M] open Set namespace Submonoid -- TODO: this section can be generalized to `[SubmonoidClass B M] [CompleteLattice B]` -- such that `CompleteLattice.LE` coincides with `SetLike.LE` @[to_additive] theorem mem_iSup_of_directed {ι} [hι : Nonempty ι] {S : ι → Submonoid M} (hS : Directed (· ≤ ·) S) {x : M} : (x ∈ ⨆ i, S i) ↔ ∃ i, x ∈ S i := by refine ⟨?_, fun ⟨i, hi⟩ ↦ le_iSup S i hi⟩ suffices x ∈ closure (⋃ i, (S i : Set M)) → ∃ i, x ∈ S i by simpa only [closure_iUnion, closure_eq (S _)] using this refine closure_induction (fun _ ↦ mem_iUnion.1) ?_ ?_ · exact hι.elim fun i ↦ ⟨i, (S i).one_mem⟩ · rintro x y - - ⟨i, hi⟩ ⟨j, hj⟩ rcases hS i j with ⟨k, hki, hkj⟩ exact ⟨k, (S k).mul_mem (hki hi) (hkj hj)⟩ @[to_additive] theorem coe_iSup_of_directed {ι} [Nonempty ι] {S : ι → Submonoid M} (hS : Directed (· ≤ ·) S) : ((⨆ i, S i : Submonoid M) : Set M) = ⋃ i, S i := Set.ext fun x ↦ by simp [mem_iSup_of_directed hS] @[to_additive] theorem mem_sSup_of_directedOn {S : Set (Submonoid M)} (Sne : S.Nonempty) (hS : DirectedOn (· ≤ ·) S) {x : M} : x ∈ sSup S ↔ ∃ s ∈ S, x ∈ s := by haveI : Nonempty S := Sne.to_subtype simp [sSup_eq_iSup', mem_iSup_of_directed hS.directed_val] @[to_additive] theorem coe_sSup_of_directedOn {S : Set (Submonoid M)} (Sne : S.Nonempty) (hS : DirectedOn (· ≤ ·) S) : (↑(sSup S) : Set M) = ⋃ s ∈ S, ↑s := Set.ext fun x => by simp [mem_sSup_of_directedOn Sne hS] @[to_additive] theorem mem_sup_left {S T : Submonoid M} : ∀ {x : M}, x ∈ S → x ∈ S ⊔ T := by rw [← SetLike.le_def] exact le_sup_left @[to_additive] theorem mem_sup_right {S T : Submonoid M} : ∀ {x : M}, x ∈ T → x ∈ S ⊔ T := by rw [← SetLike.le_def] exact le_sup_right @[to_additive] theorem mul_mem_sup {S T : Submonoid M} {x y : M} (hx : x ∈ S) (hy : y ∈ T) : x * y ∈ S ⊔ T := (S ⊔ T).mul_mem (mem_sup_left hx) (mem_sup_right hy) @[to_additive] theorem mem_iSup_of_mem {ι : Sort*} {S : ι → Submonoid M} (i : ι) : ∀ {x : M}, x ∈ S i → x ∈ iSup S := by rw [← SetLike.le_def] exact le_iSup _ _ @[to_additive] theorem mem_sSup_of_mem {S : Set (Submonoid M)} {s : Submonoid M} (hs : s ∈ S) : ∀ {x : M}, x ∈ s → x ∈ sSup S := by rw [← SetLike.le_def] exact le_sSup hs /-- An induction principle for elements of `⨆ i, S i`. If `C` holds for `1` and all elements of `S i` for all `i`, and is preserved under multiplication, then it holds for all elements of the supremum of `S`. -/ @[to_additive (attr := elab_as_elim) /-- An induction principle for elements of `⨆ i, S i`. If `C` holds for `0` and all elements of `S i` for all `i`, and is preserved under addition, then it holds for all elements of the supremum of `S`. -/] theorem iSup_induction {ι : Sort*} (S : ι → Submonoid M) {motive : M → Prop} {x : M} (hx : x ∈ ⨆ i, S i) (mem : ∀ (i), ∀ x ∈ S i, motive x) (one : motive 1) (mul : ∀ x y, motive x → motive y → motive (x * y)) : motive x := by rw [iSup_eq_closure] at hx refine closure_induction (fun x hx => ?_) one (fun _ _ _ _ ↦ mul _ _) hx obtain ⟨i, hi⟩ := Set.mem_iUnion.mp hx exact mem _ _ hi /-- A dependent version of `Submonoid.iSup_induction`. -/ @[to_additive (attr := elab_as_elim) /-- A dependent version of `AddSubmonoid.iSup_induction`. -/] theorem iSup_induction' {ι : Sort*} (S : ι → Submonoid M) {motive : ∀ x, (x ∈ ⨆ i, S i) → Prop} (mem : ∀ (i), ∀ (x) (hxS : x ∈ S i), motive x (mem_iSup_of_mem i hxS)) (one : motive 1 (one_mem _)) (mul : ∀ x y hx hy, motive x hx → motive y hy → motive (x * y) (mul_mem ‹_› ‹_›)) {x : M} (hx : x ∈ ⨆ i, S i) : motive x hx := by refine Exists.elim (?_ : ∃ Hx, motive x Hx) fun (hx : x ∈ ⨆ i, S i) (hc : motive x hx) => hc refine @iSup_induction _ _ ι S (fun m => ∃ hm, motive m hm) _ hx (fun i x hx => ?_) ?_ fun x y => ?_ · exact ⟨_, mem _ _ hx⟩ · exact ⟨_, one⟩ · rintro ⟨_, Cx⟩ ⟨_, Cy⟩ exact ⟨_, mul _ _ _ _ Cx Cy⟩ end Submonoid end NonAssoc namespace FreeMonoid variable {α : Type*} open Submonoid @[to_additive] theorem closure_range_of : closure (Set.range <| @of α) = ⊤ := eq_top_iff.2 fun x _ => FreeMonoid.recOn x (one_mem _) fun _x _xs hxs => mul_mem (subset_closure <| Set.mem_range_self _) hxs end FreeMonoid namespace Submonoid variable [Monoid M] {a : M} open MonoidHom theorem closure_singleton_eq (x : M) : closure ({x} : Set M) = mrange (powersHom M x) := closure_eq_of_le (Set.singleton_subset_iff.2 ⟨Multiplicative.ofAdd 1, pow_one x⟩) fun _ ⟨_, hn⟩ => hn ▸ pow_mem (subset_closure <| Set.mem_singleton _) _ /-- The submonoid generated by an element of a monoid equals the set of natural number powers of the element. -/ theorem mem_closure_singleton {x y : M} : y ∈ closure ({x} : Set M) ↔ ∃ n : ℕ, x ^ n = y := by rw [closure_singleton_eq, mem_mrange]; rfl theorem mem_closure_singleton_self {y : M} : y ∈ closure ({y} : Set M) := mem_closure_singleton.2 ⟨1, pow_one y⟩ theorem closure_singleton_one : closure ({1} : Set M) = ⊥ := by simp [eq_bot_iff_forall, mem_closure_singleton] section Submonoid variable {S : Submonoid M} [Fintype S] open Fintype /- curly brackets `{}` are used here instead of instance brackets `[]` because the instance in a goal is often not the same as the one inferred by type class inference. -/ @[to_additive] theorem card_bot {_ : Fintype (⊥ : Submonoid M)} : card (⊥ : Submonoid M) = 1 := card_eq_one_iff.2 ⟨⟨(1 : M), Set.mem_singleton 1⟩, fun ⟨_y, hy⟩ => Subtype.eq <| mem_bot.1 hy⟩ @[to_additive] theorem eq_bot_of_card_le (h : card S ≤ 1) : S = ⊥ := let _ := card_le_one_iff_subsingleton.mp h eq_bot_of_subsingleton S @[to_additive] theorem eq_bot_of_card_eq (h : card S = 1) : S = ⊥ := S.eq_bot_of_card_le (le_of_eq h) @[to_additive card_le_one_iff_eq_bot] theorem card_le_one_iff_eq_bot : card S ≤ 1 ↔ S = ⊥ := ⟨fun h => (eq_bot_iff_forall _).2 fun x hx => by simpa [Subtype.ext_iff] using card_le_one_iff.1 h ⟨x, hx⟩ 1, fun h => by simp [h]⟩ @[to_additive] lemma eq_bot_iff_card : S = ⊥ ↔ card S = 1 := ⟨by rintro rfl; exact card_bot, eq_bot_of_card_eq⟩ end Submonoid @[to_additive] theorem _root_.FreeMonoid.mrange_lift {α} (f : α → M) : mrange (FreeMonoid.lift f) = closure (Set.range f) := by rw [mrange_eq_map, ← FreeMonoid.closure_range_of, map_mclosure, ← Set.range_comp, FreeMonoid.lift_comp_of] @[to_additive] theorem closure_eq_mrange (s : Set M) : closure s = mrange (FreeMonoid.lift ((↑) : s → M)) := by rw [FreeMonoid.mrange_lift, Subtype.range_coe] @[to_additive] theorem closure_eq_image_prod (s : Set M) : (closure s : Set M) = List.prod '' { l : List M | ∀ x ∈ l, x ∈ s } := by rw [closure_eq_mrange, coe_mrange, ← Set.range_list_map_coe, ← Set.range_comp] exact congrArg _ (funext <| FreeMonoid.lift_apply _) @[to_additive] theorem exists_list_of_mem_closure {s : Set M} {x : M} (hx : x ∈ closure s) : ∃ l : List M, (∀ y ∈ l, y ∈ s) ∧ l.prod = x := by rwa [← SetLike.mem_coe, closure_eq_image_prod, Set.mem_image] at hx @[to_additive] theorem exists_multiset_of_mem_closure {M : Type*} [CommMonoid M] {s : Set M} {x : M} (hx : x ∈ closure s) : ∃ l : Multiset M, (∀ y ∈ l, y ∈ s) ∧ l.prod = x := by obtain ⟨l, h1, h2⟩ := exists_list_of_mem_closure hx exact ⟨l, h1, (Multiset.prod_coe l).trans h2⟩ @[to_additive (attr := elab_as_elim)] theorem closure_induction_left {s : Set M} {motive : (m : M) → m ∈ closure s → Prop} (one : motive 1 (one_mem _)) (mul_left : ∀ x (hx : x ∈ s), ∀ y hy, motive y hy → motive (x * y) (mul_mem (subset_closure hx) hy)) {x : M} (h : x ∈ closure s) : motive x h := by simp_rw [closure_eq_mrange] at h obtain ⟨l, rfl⟩ := h induction l using FreeMonoid.inductionOn' with | one => exact one | mul_of x y ih => simp only [map_mul, FreeMonoid.lift_eval_of] refine mul_left _ x.prop (FreeMonoid.lift Subtype.val y) _ (ih ?_) simp only [closure_eq_mrange, mem_mrange, exists_apply_eq_apply] @[to_additive (attr := elab_as_elim)] theorem induction_of_closure_eq_top_left {s : Set M} {motive : M → Prop} (hs : closure s = ⊤) (x : M) (one : motive 1) (mul_left : ∀ x ∈ s, ∀ y, motive y → motive (x * y)) : motive x := by have : x ∈ closure s := by simp [hs] induction this using closure_induction_left with | one => exact one | mul_left x hx y _ ih => exact mul_left x hx y ih @[to_additive (attr := elab_as_elim)] theorem closure_induction_right {s : Set M} {motive : (m : M) → m ∈ closure s → Prop} (one : motive 1 (one_mem _)) (mul_right : ∀ x hx, ∀ y (hy : y ∈ s), motive x hx → motive (x * y) (mul_mem hx (subset_closure hy))) {x : M} (h : x ∈ closure s) : motive x h := closure_induction_left (s := MulOpposite.unop ⁻¹' s) (motive := fun m hm => motive m.unop <| by rwa [← op_closure] at hm) one (fun _x hx _y _ => mul_right _ _ _ hx) (by rwa [← op_closure]) @[to_additive (attr := elab_as_elim)] theorem induction_of_closure_eq_top_right {s : Set M} {motive : M → Prop} (hs : closure s = ⊤) (x : M) (one : motive 1) (mul_right : ∀ x, ∀ y ∈ s, motive x → motive (x * y)) : motive x := by have : x ∈ closure s := by simp [hs] induction this using closure_induction_right with | one => exact one | mul_right x _ y hy ih => exact mul_right x y hy ih /-- The submonoid generated by an element. -/ def powers (n : M) : Submonoid M := Submonoid.copy (mrange (powersHom M n)) (Set.range (n ^ · : ℕ → M)) <| Set.ext fun n => exists_congr fun i => by simp; rfl theorem mem_powers (n : M) : n ∈ powers n := ⟨1, pow_one _⟩ theorem coe_powers (x : M) : ↑(powers x) = Set.range fun n : ℕ => x ^ n := rfl theorem mem_powers_iff (x z : M) : x ∈ powers z ↔ ∃ n : ℕ, z ^ n = x := Iff.rfl noncomputable instance decidableMemPowers : DecidablePred (· ∈ Submonoid.powers a) := Classical.decPred _ -- Porting note (https://github.com/leanprover-community/mathlib4/issues/11215): TODO the following instance should follow from a more general principle -- See also https://github.com/leanprover-community/mathlib4/issues/2417 noncomputable instance fintypePowers [Fintype M] : Fintype (powers a) := inferInstanceAs <| Fintype {y // y ∈ powers a} theorem powers_eq_closure (n : M) : powers n = closure {n} := by ext exact mem_closure_singleton.symm lemma powers_le {n : M} {P : Submonoid M} : powers n ≤ P ↔ n ∈ P := by simp [powers_eq_closure] lemma powers_one : powers (1 : M) = ⊥ := bot_unique <| powers_le.2 <| one_mem _ theorem _root_.IsIdempotentElem.coe_powers {a : M} (ha : IsIdempotentElem a) : (Submonoid.powers a : Set M) = {1, a} := let S : Submonoid M := { carrier := {1, a}, mul_mem' := by rintro _ _ (rfl | rfl) (rfl | rfl) · rw [one_mul]; exact .inl rfl · rw [one_mul]; exact .inr rfl · rw [mul_one]; exact .inr rfl · rw [ha]; exact .inr rfl one_mem' := .inl rfl } suffices Submonoid.powers a = S from congr_arg _ this le_antisymm (Submonoid.powers_le.mpr <| .inr rfl) (by rintro _ (rfl | rfl); exacts [one_mem _, Submonoid.mem_powers _]) /-- The submonoid generated by an element is a group if that element has finite order. -/ abbrev groupPowers {x : M} {n : ℕ} (hpos : 0 < n) (hx : x ^ n = 1) : Group (powers x) where inv x := x ^ (n - 1) inv_mul_cancel y := Subtype.ext <| by obtain ⟨_, k, rfl⟩ := y simp only [coe_one, coe_mul, SubmonoidClass.coe_pow] rw [← pow_succ, Nat.sub_add_cancel hpos, ← pow_mul, mul_comm, pow_mul, hx, one_pow] zpow z x := x ^ z.natMod n zpow_zero' z := by simp only [Int.natMod, Int.zero_emod, Int.toNat_zero, pow_zero] zpow_neg' m x := Subtype.ext <| by obtain ⟨_, k, rfl⟩ := x simp only [← pow_mul, Int.natMod, SubmonoidClass.coe_pow] rw [Int.negSucc_eq, ← Int.natCast_succ, ← Int.add_mul_emod_self_right (b := (m + 1 : ℕ))] nth_rw 1 [← mul_one ((m + 1 : ℕ) : ℤ)] rw [← sub_eq_neg_add, ← Int.mul_sub, ← Int.natCast_pred_of_pos hpos]; norm_cast simp only [Int.toNat_natCast] rw [mul_comm, pow_mul, ← pow_eq_pow_mod _ hx, mul_comm k, mul_assoc, pow_mul _ (_ % _), ← pow_eq_pow_mod _ hx, pow_mul, pow_mul] zpow_succ' m x := Subtype.ext <| by obtain ⟨_, k, rfl⟩ := x simp only [← pow_mul, Int.natMod, SubmonoidClass.coe_pow, coe_mul] norm_cast iterate 2 rw [Int.toNat_natCast, mul_comm, pow_mul, ← pow_eq_pow_mod _ hx] rw [← pow_mul _ m, mul_comm, pow_mul, ← pow_succ, ← pow_mul, mul_comm, pow_mul] /-- Exponentiation map from natural numbers to powers. -/ @[simps!] def pow (n : M) (m : ℕ) : powers n := (powersHom M n).mrangeRestrict (Multiplicative.ofAdd m) theorem pow_apply (n : M) (m : ℕ) : Submonoid.pow n m = ⟨n ^ m, m, rfl⟩ := rfl /-- Logarithms from powers to natural numbers. -/ def log [DecidableEq M] {n : M} (p : powers n) : ℕ := Nat.find <| (mem_powers_iff p.val n).mp p.prop @[simp] theorem pow_log_eq_self [DecidableEq M] {n : M} (p : powers n) : pow n (log p) = p := Subtype.ext <| Nat.find_spec p.prop theorem pow_right_injective_iff_pow_injective {n : M} : (Function.Injective fun m : ℕ => n ^ m) ↔ Function.Injective (pow n) := Subtype.coe_injective.of_comp_iff (pow n) @[simp] theorem log_pow_eq_self [DecidableEq M] {n : M} (h : Function.Injective fun m : ℕ => n ^ m) (m : ℕ) : log (pow n m) = m := pow_right_injective_iff_pow_injective.mp h <| pow_log_eq_self _ /-- The exponentiation map is an isomorphism from the additive monoid on natural numbers to powers when it is injective. The inverse is given by the logarithms. -/ @[simps] def powLogEquiv [DecidableEq M] {n : M} (h : Function.Injective fun m : ℕ => n ^ m) : Multiplicative ℕ ≃* powers n where toFun m := pow n m.toAdd invFun m := Multiplicative.ofAdd (log m) left_inv := log_pow_eq_self h right_inv := pow_log_eq_self map_mul' _ _ := by simp only [pow, map_mul, ofAdd_add, toAdd_mul] theorem log_mul [DecidableEq M] {n : M} (h : Function.Injective fun m : ℕ => n ^ m) (x y : powers (n : M)) : log (x * y) = log x + log y := map_mul (powLogEquiv h).symm x y theorem log_pow_int_eq_self {x : ℤ} (h : 1 < x.natAbs) (m : ℕ) : log (pow x m) = m := (powLogEquiv (Int.pow_right_injective h)).symm_apply_apply _ @[simp] theorem map_powers {N : Type*} {F : Type*} [Monoid N] [FunLike F M N] [MonoidHomClass F M N] (f : F) (m : M) : (powers m).map f = powers (f m) := by simp only [powers_eq_closure, map_mclosure f, Set.image_singleton] end Submonoid @[to_additive] theorem IsScalarTower.of_mclosure_eq_top {N α} [Monoid M] [MulAction M N] [SMul N α] [MulAction M α] {s : Set M} (htop : Submonoid.closure s = ⊤) (hs : ∀ x ∈ s, ∀ (y : N) (z : α), (x • y) • z = x • y • z) : IsScalarTower M N α := by refine ⟨fun x => Submonoid.induction_of_closure_eq_top_left htop x ?_ ?_⟩ · intro y z rw [one_smul, one_smul] · clear x intro x hx x' hx' y z rw [mul_smul, mul_smul, hs x hx, hx'] @[to_additive] theorem SMulCommClass.of_mclosure_eq_top {N α} [Monoid M] [SMul N α] [MulAction M α] {s : Set M} (htop : Submonoid.closure s = ⊤) (hs : ∀ x ∈ s, ∀ (y : N) (z : α), x • y • z = y • x • z) : SMulCommClass M N α := by refine ⟨fun x => Submonoid.induction_of_closure_eq_top_left htop x ?_ ?_⟩ · intro y z rw [one_smul, one_smul] · clear x intro x hx x' hx' y z rw [mul_smul, mul_smul, hx', hs x hx] namespace Submonoid variable {N : Type*} [CommMonoid N] open MonoidHom @[to_additive] theorem sup_eq_range (s t : Submonoid N) : s ⊔ t = mrange (s.subtype.coprod t.subtype) := by rw [mrange_eq_map, ← mrange_inl_sup_mrange_inr, map_sup, map_mrange, coprod_comp_inl, map_mrange, coprod_comp_inr, mrange_subtype, mrange_subtype] @[to_additive] theorem mem_sup {s t : Submonoid N} {x : N} : x ∈ s ⊔ t ↔ ∃ y ∈ s, ∃ z ∈ t, y * z = x := by simp only [sup_eq_range, mem_mrange, coprod_apply, coe_subtype, Prod.exists, Subtype.exists, exists_prop] end Submonoid namespace AddSubmonoid variable [AddMonoid A] open Set theorem closure_singleton_eq (x : A) : closure ({x} : Set A) = AddMonoidHom.mrange (multiplesHom A x) := closure_eq_of_le (Set.singleton_subset_iff.2 ⟨1, one_nsmul x⟩) fun _ ⟨_n, hn⟩ => hn ▸ nsmul_mem (subset_closure <| Set.mem_singleton _) _ /-- The `AddSubmonoid` generated by an element of an `AddMonoid` equals the set of natural number multiples of the element. -/ theorem mem_closure_singleton {x y : A} : y ∈ closure ({x} : Set A) ↔ ∃ n : ℕ, n • x = y := by rw [closure_singleton_eq, AddMonoidHom.mem_mrange]; rfl theorem closure_singleton_zero : closure ({0} : Set A) = ⊥ := by simp [eq_bot_iff_forall, mem_closure_singleton, nsmul_zero] /-- The additive submonoid generated by an element. -/ def multiples (x : A) : AddSubmonoid A := AddSubmonoid.copy (AddMonoidHom.mrange (multiplesHom A x)) (Set.range (fun i => i • x : ℕ → A)) <| Set.ext fun n => exists_congr fun i => by simp attribute [to_additive existing] Submonoid.powers attribute [to_additive (attr := simp)] Submonoid.mem_powers attribute [to_additive (attr := norm_cast)] Submonoid.coe_powers attribute [to_additive] Submonoid.mem_powers_iff attribute [to_additive] Submonoid.decidableMemPowers attribute [to_additive] Submonoid.fintypePowers attribute [to_additive] Submonoid.powers_eq_closure attribute [to_additive] Submonoid.powers_le attribute [to_additive (attr := simp)] Submonoid.powers_one attribute [to_additive /-- The additive submonoid generated by an element is an additive group if that element has finite order. -/] Submonoid.groupPowers end AddSubmonoid namespace Submonoid /-- An element is in the closure of a two-element set if it is a linear combination of those two elements. -/ @[to_additive /-- An element is in the closure of a two-element set if it is a linear combination of those two elements. -/] theorem mem_closure_pair {A : Type*} [CommMonoid A] (a b c : A) : c ∈ Submonoid.closure ({a, b} : Set A) ↔ ∃ m n : ℕ, a ^ m * b ^ n = c := by rw [← Set.singleton_union, Submonoid.closure_union, mem_sup] simp_rw [mem_closure_singleton, exists_exists_eq_and] end Submonoid section mul_add theorem ofMul_image_powers_eq_multiples_ofMul [Monoid M] {x : M} : Additive.ofMul '' (Submonoid.powers x : Set M) = AddSubmonoid.multiples (Additive.ofMul x) := by ext exact Set.mem_image_iff_of_inverse (congrFun rfl) (congrFun rfl) theorem ofAdd_image_multiples_eq_powers_ofAdd [AddMonoid A] {x : A} : Multiplicative.ofAdd '' (AddSubmonoid.multiples x : Set A) = Submonoid.powers (Multiplicative.ofAdd x) := by symm rw [Equiv.eq_image_iff_symm_image_eq] exact ofMul_image_powers_eq_multiples_ofMul end mul_add
AddCharacter.lean
/- Copyright (c) 2022 Michael Stoll. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Michael Stoll -/ import Mathlib.NumberTheory.Cyclotomic.PrimitiveRoots import Mathlib.FieldTheory.Finite.Trace import Mathlib.Algebra.Group.AddChar import Mathlib.Data.ZMod.Units import Mathlib.Analysis.Complex.Polynomial.Basic /-! # Additive characters of finite rings and fields This file collects some results on additive characters whose domain is (the additive group of) a finite ring or field. ## Main definitions and results We define an additive character `ψ` to be *primitive* if `mulShift ψ a` is trivial only when `a = 0`. We show that when `ψ` is primitive, then the map `a ↦ mulShift ψ a` is injective (`AddChar.to_mulShift_inj_of_isPrimitive`) and that `ψ` is primitive when `R` is a field and `ψ` is nontrivial (`AddChar.IsNontrivial.isPrimitive`). We also show that there are primitive additive characters on `R` (with suitable target `R'`) when `R` is a field or `R = ZMod n` (`AddChar.primitiveCharFiniteField` and `AddChar.primitiveZModChar`). Finally, we show that the sum of all character values is zero when the character is nontrivial (and the target is a domain); see `AddChar.sum_eq_zero_of_isNontrivial`. ## Tags additive character -/ universe u v namespace AddChar section Additive -- The domain and target of our additive characters. Now we restrict to a ring in the domain. variable {R : Type u} [CommRing R] {R' : Type v} [CommMonoid R'] /-- The values of an additive character on a ring of positive characteristic are roots of unity. -/ lemma val_mem_rootsOfUnity (φ : AddChar R R') (a : R) (h : 0 < ringChar R) : (φ.val_isUnit a).unit ∈ rootsOfUnity (ringChar R).toPNat' R' := by simp only [mem_rootsOfUnity', IsUnit.unit_spec, Nat.toPNat'_coe, h, ↓reduceIte, ← map_nsmul_eq_pow, nsmul_eq_mul, CharP.cast_eq_zero, zero_mul, map_zero_eq_one] /-- An additive character is *primitive* iff all its multiplicative shifts by nonzero elements are nontrivial. -/ def IsPrimitive (ψ : AddChar R R') : Prop := ∀ ⦃a : R⦄, a ≠ 0 → mulShift ψ a ≠ 1 /-- The composition of a primitive additive character with an injective mooid homomorphism is also primitive. -/ lemma IsPrimitive.compMulHom_of_isPrimitive {R'' : Type*} [CommMonoid R''] {φ : AddChar R R'} {f : R' →* R''} (hφ : φ.IsPrimitive) (hf : Function.Injective f) : (f.compAddChar φ).IsPrimitive := fun a ha ↦ by simpa [DFunLike.ext_iff] using (MonoidHom.compAddChar_injective_right f hf).ne (hφ ha) /-- The map associating to `a : R` the multiplicative shift of `ψ` by `a` is injective when `ψ` is primitive. -/ theorem to_mulShift_inj_of_isPrimitive {ψ : AddChar R R'} (hψ : IsPrimitive ψ) : Function.Injective ψ.mulShift := by intro a b h apply_fun fun x => x * mulShift ψ (-b) at h simp only [mulShift_mul, mulShift_zero, add_neg_cancel] at h simpa [← sub_eq_add_neg, sub_eq_zero] using (hψ · h) -- `AddCommGroup.equiv_direct_sum_zmod_of_fintype` -- gives the structure theorem for finite abelian groups. -- This could be used to show that the map above is a bijection. -- We leave this for a later occasion. /-- When `R` is a field `F`, then a nontrivial additive character is primitive -/ theorem IsPrimitive.of_ne_one {F : Type u} [Field F] {ψ : AddChar F R'} (hψ : ψ ≠ 1) : IsPrimitive ψ := fun a ha h ↦ hψ <| by simpa [mulShift_mulShift, ha] using congr_arg (mulShift · a⁻¹) h /-- If `r` is not a unit, then `e.mulShift r` is not primitive. -/ lemma not_isPrimitive_mulShift [Finite R] (e : AddChar R R') {r : R} (hr : ¬ IsUnit r) : ¬ IsPrimitive (e.mulShift r) := by simp only [IsPrimitive, not_forall] simp only [isUnit_iff_mem_nonZeroDivisors_of_finite, mem_nonZeroDivisors_iff_right, not_forall] at hr rcases hr with ⟨x, h, h'⟩ exact ⟨x, h', by simp only [mulShift_mulShift, mul_comm r, h, mulShift_zero, not_ne_iff]⟩ /-- Definition for a primitive additive character on a finite ring `R` into a cyclotomic extension of a field `R'`. It records which cyclotomic extension it is, the character, and the fact that the character is primitive. -/ structure PrimitiveAddChar (R : Type u) [CommRing R] (R' : Type v) [Field R'] where /-- The first projection from `PrimitiveAddChar`, giving the cyclotomic field. -/ n : ℕ+ /-- The second projection from `PrimitiveAddChar`, giving the character. -/ char : AddChar R (CyclotomicField n R') /-- The third projection from `PrimitiveAddChar`, showing that `χ.char` is primitive. -/ prim : IsPrimitive char /-! ### Additive characters on `ZMod n` -/ section ZMod variable {N : ℕ} [NeZero N] {R : Type*} [CommRing R] (e : AddChar (ZMod N) R) /-- If `e` is not primitive, then `e.mulShift d = 1` for some proper divisor `d` of `N`. -/ lemma exists_divisor_of_not_isPrimitive (he : ¬e.IsPrimitive) : ∃ d : ℕ, d ∣ N ∧ d < N ∧ e.mulShift d = 1 := by simp_rw [IsPrimitive, not_forall, not_ne_iff] at he rcases he with ⟨b, hb_ne, hb⟩ -- We have `AddChar.mulShift e b = 1`, but `b ≠ 0`. obtain ⟨d, hd, u, hu, rfl⟩ := b.eq_unit_mul_divisor refine ⟨d, hd, lt_of_le_of_ne (Nat.le_of_dvd (NeZero.pos _) hd) ?_, ?_⟩ · exact fun h ↦ by simp only [h, ZMod.natCast_self, mul_zero, ne_eq, not_true_eq_false] at hb_ne · rw [← mulShift_unit_eq_one_iff _ hu, ← hb, mul_comm] ext1 y rw [mulShift_apply, mulShift_apply, mulShift_apply, mul_assoc] end ZMod section ZModChar variable {C : Type v} [CommMonoid C] section ZModCharDef /-- We can define an additive character on `ZMod n` when we have an `n`th root of unity `ζ : C`. -/ def zmodChar (n : ℕ) [NeZero n] {ζ : C} (hζ : ζ ^ n = 1) : AddChar (ZMod n) C where toFun a := ζ ^ a.val map_zero_eq_one' := by simp only [ZMod.val_zero, pow_zero] map_add_eq_mul' x y := by simp only [ZMod.val_add, ← pow_eq_pow_mod _ hζ, ← pow_add] /-- The additive character on `ZMod n` defined using `ζ` sends `a` to `ζ^a`. -/ theorem zmodChar_apply {n : ℕ} [NeZero n] {ζ : C} (hζ : ζ ^ n = 1) (a : ZMod n) : zmodChar n hζ a = ζ ^ a.val := rfl theorem zmodChar_apply' {n : ℕ} [NeZero n] {ζ : C} (hζ : ζ ^ n = 1) (a : ℕ) : zmodChar n hζ a = ζ ^ a := by rw [pow_eq_pow_mod a hζ, zmodChar_apply, ZMod.val_natCast] end ZModCharDef /-- An additive character on `ZMod n` is nontrivial iff it takes a value `≠ 1` on `1`. -/ theorem zmod_char_ne_one_iff (n : ℕ) [NeZero n] (ψ : AddChar (ZMod n) C) : ψ ≠ 1 ↔ ψ 1 ≠ 1 := by rw [ne_one_iff] refine ⟨?_, fun h => ⟨_, h⟩⟩ contrapose! rintro h₁ a have ha₁ : a = a.val • (1 : ZMod ↑n) := by rw [nsmul_eq_mul, mul_one]; exact (ZMod.natCast_zmod_val a).symm rw [ha₁, map_nsmul_eq_pow, h₁, one_pow] /-- A primitive additive character on `ZMod n` takes the value `1` only at `0`. -/ theorem IsPrimitive.zmod_char_eq_one_iff (n : ℕ) [NeZero n] {ψ : AddChar (ZMod n) C} (hψ : IsPrimitive ψ) (a : ZMod n) : ψ a = 1 ↔ a = 0 := by refine ⟨fun h => not_imp_comm.mp (@hψ a) ?_, fun ha => by rw [ha, map_zero_eq_one]⟩ rw [zmod_char_ne_one_iff n (mulShift ψ a), mulShift_apply, mul_one, h, Classical.not_not] /-- The converse: if the additive character takes the value `1` only at `0`, then it is primitive. -/ theorem zmod_char_primitive_of_eq_one_only_at_zero (n : ℕ) (ψ : AddChar (ZMod n) C) (hψ : ∀ a, ψ a = 1 → a = 0) : IsPrimitive ψ := by refine fun a ha hf => ?_ have h : mulShift ψ a 1 = (1 : AddChar (ZMod n) C) (1 : ZMod n) := congr_fun (congr_arg (↑) hf) 1 rw [mulShift_apply, mul_one] at h; norm_cast at h exact ha (hψ a h) /-- The additive character on `ZMod n` associated to a primitive `n`th root of unity is primitive -/ theorem zmodChar_primitive_of_primitive_root (n : ℕ) [NeZero n] {ζ : C} (h : IsPrimitiveRoot ζ n) : IsPrimitive (zmodChar n ((IsPrimitiveRoot.iff_def ζ n).mp h).left) := by apply zmod_char_primitive_of_eq_one_only_at_zero intro a ha rw [zmodChar_apply, ← pow_zero ζ] at ha exact (ZMod.val_eq_zero a).mp (IsPrimitiveRoot.pow_inj h (ZMod.val_lt a) (NeZero.pos _) ha) /-- There is a primitive additive character on `ZMod n` if the characteristic of the target does not divide `n` -/ noncomputable def primitiveZModChar (n : ℕ+) (F' : Type v) [Field F'] (h : (n : F') ≠ 0) : PrimitiveAddChar (ZMod n) F' := have : NeZero (n : F') := ⟨h⟩ ⟨n, zmodChar n (IsCyclotomicExtension.zeta_pow n F' _), zmodChar_primitive_of_primitive_root n (IsCyclotomicExtension.zeta_spec n F' _)⟩ end ZModChar end Additive /-! ### Existence of a primitive additive character on a finite field -/ /-- There is a primitive additive character on the finite field `F` if the characteristic of the target is different from that of `F`. We obtain it as the composition of the trace from `F` to `ZMod p` with a primitive additive character on `ZMod p`, where `p` is the characteristic of `F`. -/ noncomputable def FiniteField.primitiveChar (F F' : Type*) [Field F] [Finite F] [Field F'] (h : ringChar F' ≠ ringChar F) : PrimitiveAddChar F F' := by let p := ringChar F haveI hp : Fact p.Prime := ⟨CharP.char_is_prime F _⟩ let pp := p.toPNat hp.1.pos have hp₂ : ¬ringChar F' ∣ p := by rcases CharP.char_is_prime_or_zero F' (ringChar F') with hq | hq · exact mt (Nat.Prime.dvd_iff_eq hp.1 (Nat.Prime.ne_one hq)).mp h.symm · rw [hq] exact fun hf => Nat.Prime.ne_zero hp.1 (zero_dvd_iff.mp hf) let ψ := primitiveZModChar pp F' (neZero_iff.mp (NeZero.of_not_dvd F' hp₂)) letI : Algebra (ZMod p) F := ZMod.algebra _ _ let ψ' := ψ.char.compAddMonoidHom (Algebra.trace (ZMod p) F).toAddMonoidHom have hψ' : ψ' ≠ 1 := by obtain ⟨a, ha⟩ := FiniteField.trace_to_zmod_nondegenerate F one_ne_zero rw [one_mul] at ha exact ne_one_iff.2 ⟨a, fun hf => ha <| (ψ.prim.zmod_char_eq_one_iff pp <| Algebra.trace (ZMod p) F a).mp hf⟩ exact ⟨ψ.n, ψ', IsPrimitive.of_ne_one hψ'⟩ /-! ### The sum of all character values -/ section sum variable {R : Type*} [AddGroup R] [Fintype R] {R' : Type*} [CommRing R'] /-- The sum over the values of a nontrivial additive character vanishes if the target ring is a domain. -/ theorem sum_eq_zero_of_ne_one [IsDomain R'] {ψ : AddChar R R'} (hψ : ψ ≠ 1) : ∑ a, ψ a = 0 := by rcases ne_one_iff.1 hψ with ⟨b, hb⟩ have h₁ : ∑ a : R, ψ (b + a) = ∑ a : R, ψ a := Fintype.sum_bijective _ (AddGroup.addLeft_bijective b) _ _ fun x => rfl simp_rw [map_add_eq_mul] at h₁ have h₂ : ∑ a : R, ψ a = Finset.univ.sum ↑ψ := rfl rw [← Finset.mul_sum, h₂] at h₁ exact eq_zero_of_mul_eq_self_left hb h₁ /-- The sum over the values of the trivial additive character is the cardinality of the source. -/ theorem sum_eq_card_of_eq_one {ψ : AddChar R R'} (hψ : ψ = 1) : ∑ a, ψ a = Fintype.card R := by simp [hψ] end sum /-- The sum over the values of `mulShift ψ b` for `ψ` primitive is zero when `b ≠ 0` and `#R` otherwise. -/ theorem sum_mulShift {R : Type*} [CommRing R] [Fintype R] [DecidableEq R] {R' : Type*} [CommRing R'] [IsDomain R'] {ψ : AddChar R R'} (b : R) (hψ : IsPrimitive ψ) : ∑ x : R, ψ (x * b) = if b = 0 then Fintype.card R else 0 := by split_ifs with h · -- case `b = 0` simp only [h, mul_zero, map_zero_eq_one, Finset.sum_const, Nat.smul_one_eq_cast] rfl · -- case `b ≠ 0` simp_rw [mul_comm] exact mod_cast sum_eq_zero_of_ne_one (hψ h) /-! ### Complex-valued additive characters -/ section Ring variable {R : Type*} [CommRing R] /-- Post-composing an additive character to `ℂ` with complex conjugation gives the inverse character. -/ lemma starComp_eq_inv (hR : 0 < ringChar R) {φ : AddChar R ℂ} : (starRingEnd ℂ).compAddChar φ = φ⁻¹ := by ext1 a simp only [RingHom.toMonoidHom_eq_coe, MonoidHom.coe_compAddChar, MonoidHom.coe_coe, Function.comp_apply, inv_apply'] have H := Complex.norm_eq_one_of_mem_rootsOfUnity <| φ.val_mem_rootsOfUnity a hR exact (Complex.inv_eq_conj H).symm lemma starComp_apply (hR : 0 < ringChar R) {φ : AddChar R ℂ} (a : R) : (starRingEnd ℂ) (φ a) = φ⁻¹ a := by rw [← starComp_eq_inv hR] rfl end Ring section Field variable (F : Type*) [Field F] [Finite F] private lemma ringChar_ne : ringChar ℂ ≠ ringChar F := by simpa only [ringChar.eq_zero] using (CharP.ringChar_ne_zero_of_finite F).symm /-- A primitive additive character on the finite field `F` with values in `ℂ`. -/ noncomputable def FiniteField.primitiveChar_to_Complex : AddChar F ℂ := by letI ch := primitiveChar F ℂ <| ringChar_ne F refine MonoidHom.compAddChar ?_ ch.char exact (IsCyclotomicExtension.algEquiv {(ch.n : ℕ)} ℂ (CyclotomicField ch.n ℂ) ℂ).toMonoidHom lemma FiniteField.primitiveChar_to_Complex_isPrimitive : (primitiveChar_to_Complex F).IsPrimitive := by refine IsPrimitive.compMulHom_of_isPrimitive (PrimitiveAddChar.prim _) ?_ let nn := (primitiveChar F ℂ <| ringChar_ne F).n exact (IsCyclotomicExtension.algEquiv {(nn : ℕ)} ℂ (CyclotomicField nn ℂ) ℂ).injective end Field end AddChar
Grothendieck.lean
/- Copyright (c) 2024 Calle Sönne. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Calle Sönne -/ import Mathlib.CategoryTheory.Bicategory.LocallyDiscrete import Mathlib.CategoryTheory.Bicategory.NaturalTransformation.Pseudo /-! # The Grothendieck construction Given a category `𝒮` and any pseudofunctor `F` from `𝒮ᵒᵖ` to `Cat`, we associate to it a category `∫ F`, equipped with a functor `∫ F ⥤ 𝒮`. The category `∫ F` is defined as follows: * Objects: pairs `(S, a)` where `S` is an object of the base category and `a` is an object of the category `F(S)`. * Morphisms: morphisms `(R, b) ⟶ (S, a)` are defined as pairs `(f, h)` where `f : R ⟶ S` is a morphism in `𝒮` and `h : b ⟶ F(f)(a)` The projection functor `∫ F ⥤ 𝒮` is then given by projecting to the first factors, i.e. * On objects, it sends `(S, a)` to `S` * On morphisms, it sends `(f, h)` to `f` ## Future work / TODO 1. Once the bicategory of pseudofunctors has been defined, show that this construction forms a pseudofunctor from `Pseudofunctor (LocallyDiscrete 𝒮ᵒᵖ) Cat` to `Cat`. 2. One could probably deduce the results in `CategoryTheory.Grothendieck` as a specialization of the results in this file. ## References [Vistoli2008] "Notes on Grothendieck Topologies, Fibered Categories and Descent Theory" by Angelo Vistoli -/ namespace CategoryTheory.Pseudofunctor universe w v₁ v₂ v₃ u₁ u₂ u₃ open Functor Category Opposite Discrete Bicategory StrongTrans variable {𝒮 : Type u₁} [Category.{v₁} 𝒮] {F : Pseudofunctor (LocallyDiscrete 𝒮ᵒᵖ) Cat.{v₂, u₂}} /-- The type of objects in the fibered category associated to a presheaf valued in types. -/ @[ext] structure Grothendieck (F : Pseudofunctor (LocallyDiscrete 𝒮ᵒᵖ) Cat.{v₂, u₂}) where /-- The underlying object in the base category. -/ base : 𝒮 /-- The object in the fiber of the base object. -/ fiber : F.obj ⟨op base⟩ namespace Grothendieck /-- Notation for the Grothendieck category associated to a pseudofunctor `F`. -/ scoped prefix:75 "∫ " => Grothendieck /-- A morphism in the Grothendieck category `F : C ⥤ Cat` consists of `base : X.base ⟶ Y.base` and `f.fiber : (F.map base).obj X.fiber ⟶ Y.fiber`. -/ structure Hom (X Y : ∫ F) where /-- The morphism between base objects. -/ base : X.base ⟶ Y.base /-- The morphism in the fiber over the domain. -/ fiber : X.fiber ⟶ (F.map base.op.toLoc).obj Y.fiber @[simps! id_base id_fiber comp_base comp_fiber] instance categoryStruct : CategoryStruct (∫ F) where Hom X Y := Hom X Y id X := { base := 𝟙 X.base fiber := (F.mapId ⟨op X.base⟩).inv.app X.fiber } comp {_ _ Z} f g := { base := f.base ≫ g.base fiber := f.fiber ≫ (F.map f.base.op.toLoc).map g.fiber ≫ (F.mapComp g.base.op.toLoc f.base.op.toLoc).inv.app Z.fiber } section variable {a b : ∫ F} @[ext (iff := false)] lemma Hom.ext (f g : a ⟶ b) (hfg₁ : f.base = g.base) (hfg₂ : f.fiber = g.fiber ≫ eqToHom (hfg₁ ▸ rfl)) : f = g := by cases f; cases g congr dsimp at hfg₁ rw [← conj_eqToHom_iff_heq _ _ rfl (hfg₁ ▸ rfl)] simpa only [eqToHom_refl, id_comp] using hfg₂ lemma Hom.ext_iff (f g : a ⟶ b) : f = g ↔ ∃ (hfg : f.base = g.base), f.fiber = g.fiber ≫ eqToHom (hfg ▸ rfl) where mp hfg := ⟨by rw [hfg], by simp [hfg]⟩ mpr := fun ⟨hfg₁, hfg₂⟩ => Hom.ext f g hfg₁ hfg₂ lemma Hom.congr {a b : ∫ F} {f g : a ⟶ b} (h : f = g) : f.fiber = g.fiber ≫ eqToHom (h ▸ rfl) := by simp [h] end /-- The category structure on `∫ F`. -/ instance category : Category (∫ F) where toCategoryStruct := Pseudofunctor.Grothendieck.categoryStruct id_comp {a b} f := by ext · simp · simp [F.mapComp_id_right_inv_app, Strict.rightUnitor_eqToIso, ← NatTrans.naturality_assoc] comp_id {a b} f := by ext · simp · simp [F.mapComp_id_left_inv_app, ← Functor.map_comp_assoc, Strict.leftUnitor_eqToIso] assoc f g h := by ext · simp · simp [← NatTrans.naturality_assoc, F.mapComp_assoc_right_inv_app, Strict.associator_eqToIso] variable (F) /-- The projection `∫ F ⥤ 𝒮` given by projecting both objects and homs to the first factor. -/ @[simps] def forget (F : Pseudofunctor (LocallyDiscrete 𝒮ᵒᵖ) Cat.{v₂, u₂}) : ∫ F ⥤ 𝒮 where obj X := X.base map f := f.base section attribute [local simp] Strict.leftUnitor_eqToIso Strict.rightUnitor_eqToIso Strict.associator_eqToIso variable {F} {G : Pseudofunctor (LocallyDiscrete 𝒮ᵒᵖ) Cat.{v₂, u₂}} {H : Pseudofunctor (LocallyDiscrete 𝒮ᵒᵖ) Cat.{v₂, u₂}} /-- The Grothendieck construction is functorial: a strong natural transformation `α : F ⟶ G` induces a functor `Grothendieck.map : ∫ F ⥤ ∫ G`. -/ @[simps!] def map (α : F ⟶ G) : ∫ F ⥤ ∫ G where obj a := { base := a.base fiber := (α.app ⟨op a.base⟩).obj a.fiber } map {a b} f := { base := f.1 fiber := (α.app ⟨op a.base⟩).map f.2 ≫ (α.naturality f.1.op.toLoc).hom.app b.fiber } map_id a := by ext1 · dsimp · simp [StrongTrans.naturality_id_hom_app, ← Functor.map_comp_assoc] map_comp {a b c} f g := by ext · dsimp · dsimp rw [StrongTrans.naturality_comp_hom_app] simp only [map_comp, Cat.comp_obj, Strict.associator_eqToIso, eqToIso_refl, Iso.refl_hom, Cat.id_app, Iso.refl_inv, id_comp, assoc, comp_id] slice_lhs 2 4 => simp only [← Functor.map_comp, Iso.inv_hom_id_app, Cat.comp_obj, comp_id] simp [← Functor.comp_map] @[simp] lemma map_id_map {x y : ∫ F} (f : x ⟶ y) : (map (𝟙 F)).map f = f := by ext <;> simp @[simp] theorem map_comp_forget (α : F ⟶ G) : map α ⋙ forget G = forget F := rfl section variable (F) /-- The natural isomorphism witnessing the pseudo-unity constraint of `Grothendieck.map`. -/ def mapIdIso : map (𝟙 F) ≅ 𝟭 (∫ F) := NatIso.ofComponents (fun _ ↦ eqToIso (by cat_disch)) lemma map_id_eq : map (𝟙 F) = 𝟭 (∫ F) := Functor.ext_of_iso (mapIdIso F) (fun x ↦ by simp [map]) (fun x ↦ by simp [mapIdIso]) end /-- The natural isomorphism witnessing the pseudo-functoriality of `Grothendieck.map`. -/ def mapCompIso (α : F ⟶ G) (β : G ⟶ H) : map (α ≫ β) ≅ map α ⋙ map β := NatIso.ofComponents (fun _ ↦ eqToIso (by cat_disch)) (fun f ↦ by dsimp simp only [comp_id, id_comp] ext <;> simp) lemma map_comp_eq (α : F ⟶ G) (β : G ⟶ H) : map (α ≫ β) = map α ⋙ map β := Functor.ext_of_iso (mapCompIso α β) (fun _ ↦ by simp [map]) (fun _ ↦ by simp [mapCompIso]) end end Pseudofunctor.Grothendieck end CategoryTheory
gproduct.v
(* (c) Copyright 2006-2016 Microsoft Corporation and Inria. *) (* Distributed under the terms of CeCILL-B. *) From HB Require Import structures. From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq div. From mathcomp Require Import choice fintype bigop finset fingroup morphism. From mathcomp Require Import quotient action finfun. (******************************************************************************) (* Partial, semidirect, central, and direct products. *) (* ++ Internal products, with A, B : {set gT}, are partial operations : *) (* partial_product A B == A * B if A is a group normalised by the group B, *) (* and the empty set otherwise. *) (* A ><| B == A * B if this is a semi-direct product (i.e., if A *) (* is normalised by B and intersects it trivially). *) (* A \* B == A * B if this is a central product ([A, B] = 1). *) (* A \x B == A * B if this is a direct product. *) (* [complements to K in G] == set of groups H s.t. K * H = G and K :&: H = 1. *) (* [splits G, over K] == [complements to K in G] is not empty. *) (* remgr A B x == the right remainder in B of x mod A, i.e., *) (* some element of (A :* x) :&: B. *) (* divgr A B x == the "division" in B of x by A: for all x, *) (* x = divgr A B x * remgr A B x. *) (* ++ External products : *) (* pairg1, pair1g == the isomorphisms aT1 -> aT1 * aT2, aT2 -> aT1 * aT2. *) (* (aT1 * aT2 has a direct product group structure.) *) (* dfung1 i == the morphism gT i -> {dffun forall j, gt j} where *) (* gT : I -> finGroupType is a family of finite groups. *) (* sdprod_by to == the semidirect product defined by to : groupAction H K. *) (* This is a finGroupType; the actual semidirect product is *) (* the total set [set: sdprod_by to] on that type. *) (* sdpair[12] to == the isomorphisms injecting K and H into *) (* sdprod_by to = sdpair1 to @* K ><| sdpair2 to @* H. *) (* External central products (with identified centers) will be defined later *) (* in file center.v. *) (* ++ Morphisms on product groups: *) (* pprodm nAB fJ fAB == the morphism extending fA and fB on A <*> B when *) (* nAB : B \subset 'N(A), *) (* fJ : {in A & B, morph_act 'J 'J fA fB}, and *) (* fAB : {in A :&: B, fA =1 fB}. *) (* sdprodm defG fJ == the morphism extending fA and fB on G, given *) (* defG : A ><| B = G and *) (* fJ : {in A & B, morph_act 'J 'J fA fB}. *) (* xsdprodm fHKact == the total morphism on sdprod_by to induced by *) (* fH : {morphism H >-> rT}, fK : {morphism K >-> rT}, *) (* with to : groupAction K H, *) (* given fHKact : morph_act to 'J fH fK. *) (* cprodm defG cAB fAB == the morphism extending fA and fB on G, when *) (* defG : A \* B = G, *) (* cAB : fB @* B \subset 'C(fB @* A), *) (* and fAB : {in A :&: B, fA =1 fB}. *) (* dprodm defG cAB == the morphism extending fA and fB on G, when *) (* defG : A \x B = G and *) (* cAB : fA @* B \subset 'C(fA @* A) *) (* mulgm (x, y) == x * y; mulgm is an isomorphism from setX A B to G *) (* iff A \x B = G . *) (******************************************************************************) Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. Import GroupScope. Section Defs. Variables gT : finGroupType. Implicit Types A B C : {set gT}. Definition partial_product A B := if A == 1 then B else if B == 1 then A else if [&& group_set A, group_set B & B \subset 'N(A)] then A * B else set0. Definition semidirect_product A B := if A :&: B \subset 1%G then partial_product A B else set0. Definition central_product A B := if B \subset 'C(A) then partial_product A B else set0. Definition direct_product A B := if A :&: B \subset 1%G then central_product A B else set0. Definition complements_to_in A B := [set K : {group gT} | A :&: K == 1 & A * K == B]. Definition splits_over B A := complements_to_in A B != set0. (* Product remainder functions -- right variant only. *) Definition remgr A B x := repr (A :* x :&: B). Definition divgr A B x := x * (remgr A B x)^-1. End Defs. Arguments partial_product _ _%_g _%_g : clear implicits. Arguments semidirect_product _ _%_g _%_g : clear implicits. Arguments central_product _ _%_g _%_g : clear implicits. Arguments complements_to_in _ _%_g _%_g. Arguments splits_over _ _%_g _%_g. Arguments remgr _ _%_g _%_g _%_g. Arguments divgr _ _%_g _%_g _%_g. Arguments direct_product : clear implicits. Notation pprod := (partial_product _). Notation sdprod := (semidirect_product _). Notation cprod := (central_product _). Notation dprod := (direct_product _). Notation "G ><| H" := (sdprod G H)%g (at level 40, left associativity) : group_scope. Notation "G \* H" := (cprod G H)%g (at level 40, left associativity) : group_scope. Notation "G \x H" := (dprod G H)%g (at level 40, left associativity) : group_scope. Notation "[ 'complements' 'to' A 'in' B ]" := (complements_to_in A B) (format "[ 'complements' 'to' A 'in' B ]") : group_scope. Notation "[ 'splits' B , 'over' A ]" := (splits_over B A) (format "[ 'splits' B , 'over' A ]") : group_scope. (* Prenex Implicits remgl divgl. *) Prenex Implicits remgr divgr. Section InternalProd. Variable gT : finGroupType. Implicit Types A B C : {set gT}. Implicit Types G H K L M : {group gT}. Local Notation pprod := (partial_product gT). Local Notation sdprod := (semidirect_product gT) (only parsing). Local Notation cprod := (central_product gT) (only parsing). Local Notation dprod := (direct_product gT) (only parsing). Lemma pprod1g : left_id 1 pprod. Proof. by move=> A; rewrite /pprod eqxx. Qed. Lemma pprodg1 : right_id 1 pprod. Proof. by move=> A; rewrite /pprod eqxx; case: eqP. Qed. Variant are_groups A B : Prop := AreGroups K H of A = K & B = H. Lemma group_not0 G : set0 <> G. Proof. by move/setP/(_ 1); rewrite inE group1. Qed. Lemma mulg0 : right_zero (@set0 gT) mulg. Proof. by move=> A; apply/setP=> x; rewrite inE; apply/imset2P=> [[y z]]; rewrite inE. Qed. Lemma mul0g : left_zero (@set0 gT) mulg. Proof. by move=> A; apply/setP=> x; rewrite inE; apply/imset2P=> [[y z]]; rewrite inE. Qed. Lemma pprodP A B G : pprod A B = G -> [/\ are_groups A B, A * B = G & B \subset 'N(A)]. Proof. have Gnot0 := @group_not0 G; rewrite /pprod; do 2?case: eqP => [-> ->| _]. - by rewrite mul1g norms1; split; first exists 1%G G. - by rewrite mulg1 sub1G; split; first exists G 1%G. by case: and3P => // [[gA gB ->]]; split; first exists (Group gA) (Group gB). Qed. Lemma pprodE K H : H \subset 'N(K) -> pprod K H = K * H. Proof. move=> nKH; rewrite /pprod nKH !groupP /=. by do 2?case: eqP => [-> | _]; rewrite ?mulg1 ?mul1g. Qed. Lemma pprodEY K H : H \subset 'N(K) -> pprod K H = K <*> H. Proof. by move=> nKH; rewrite pprodE ?norm_joinEr. Qed. Lemma pprodW A B G : pprod A B = G -> A * B = G. Proof. by case/pprodP. Qed. Lemma pprodWC A B G : pprod A B = G -> B * A = G. Proof. by case/pprodP=> _ <- /normC. Qed. Lemma pprodWY A B G : pprod A B = G -> A <*> B = G. Proof. by case/pprodP=> [[K H -> ->] <- /norm_joinEr]. Qed. Lemma pprodJ A B x : pprod A B :^ x = pprod (A :^ x) (B :^ x). Proof. rewrite /pprod !conjsg_eq1 !group_setJ normJ conjSg -conjsMg. by do 3?case: ifP => // _; apply: conj0g. Qed. (* Properties of the remainders *) Lemma remgrMl K B x y : y \in K -> remgr K B (y * x) = remgr K B x. Proof. by move=> Ky; rewrite {1}/remgr rcosetM rcoset_id. Qed. Lemma remgrP K B x : (remgr K B x \in K :* x :&: B) = (x \in K * B). Proof. set y := _ x; apply/idP/mulsgP=> [|[g b Kg Bb x_gb]]. rewrite inE rcoset_sym mem_rcoset => /andP[Kxy' By]. by exists (x * y^-1) y; rewrite ?mulgKV. by apply: (mem_repr b); rewrite inE rcoset_sym mem_rcoset x_gb mulgK Kg. Qed. Lemma remgr1 K H x : x \in K -> remgr K H x = 1. Proof. by move=> Kx; rewrite /remgr rcoset_id ?repr_group. Qed. Lemma divgr_eq A B x : x = divgr A B x * remgr A B x. Proof. by rewrite mulgKV. Qed. Lemma divgrMl K B x y : x \in K -> divgr K B (x * y) = x * divgr K B y. Proof. by move=> Hx; rewrite /divgr remgrMl ?mulgA. Qed. Lemma divgr_id K H x : x \in K -> divgr K H x = x. Proof. by move=> Kx; rewrite /divgr remgr1 // invg1 mulg1. Qed. Lemma mem_remgr K B x : x \in K * B -> remgr K B x \in B. Proof. by rewrite -remgrP => /setIP[]. Qed. Lemma mem_divgr K B x : x \in K * B -> divgr K B x \in K. Proof. by rewrite -remgrP inE rcoset_sym mem_rcoset => /andP[]. Qed. Section DisjointRem. Variables K H : {group gT}. Hypothesis tiKH : K :&: H = 1. Lemma remgr_id x : x \in H -> remgr K H x = x. Proof. move=> Hx; apply/eqP; rewrite eq_mulgV1 (sameP eqP set1gP) -tiKH inE. rewrite -mem_rcoset groupMr ?groupV // -in_setI remgrP. by apply: subsetP Hx; apply: mulG_subr. Qed. Lemma remgrMid x y : x \in K -> y \in H -> remgr K H (x * y) = y. Proof. by move=> Kx Hy; rewrite remgrMl ?remgr_id. Qed. Lemma divgrMid x y : x \in K -> y \in H -> divgr K H (x * y) = x. Proof. by move=> Kx Hy; rewrite /divgr remgrMid ?mulgK. Qed. End DisjointRem. (* Intersection of a centraliser with a disjoint product. *) Lemma subcent_TImulg K H A : K :&: H = 1 -> A \subset 'N(K) :&: 'N(H) -> 'C_K(A) * 'C_H(A) = 'C_(K * H)(A). Proof. move=> tiKH /subsetIP[nKA nHA]; apply/eqP. rewrite group_modl ?subsetIr // eqEsubset setSI ?mulSg ?subsetIl //=. apply/subsetP=> _ /setIP[/mulsgP[x y Kx Hy ->] cAxy]. rewrite inE cAxy mem_mulg // inE Kx /=. apply/centP=> z Az; apply/commgP/conjg_fixP. move/commgP/conjg_fixP/(congr1 (divgr K H)): (centP cAxy z Az). by rewrite conjMg !divgrMid ?memJ_norm // (subsetP nKA, subsetP nHA). Qed. (* Complements, and splitting. *) Lemma complP H A B : reflect (A :&: H = 1 /\ A * H = B) (H \in [complements to A in B]). Proof. by apply: (iffP setIdP); case; split; apply/eqP. Qed. Lemma splitsP B A : reflect (exists H, H \in [complements to A in B]) [splits B, over A]. Proof. exact: set0Pn. Qed. Lemma complgC H K G : (H \in [complements to K in G]) = (K \in [complements to H in G]). Proof. rewrite !inE setIC; congr (_ && _). by apply/eqP/eqP=> defG; rewrite -(comm_group_setP _) // defG groupP. Qed. Section NormalComplement. Variables K H G : {group gT}. Hypothesis complH_K : H \in [complements to K in G]. Lemma remgrM : K <| G -> {in G &, {morph remgr K H : x y / x * y}}. Proof. case/normalP=> _; case/complP: complH_K => tiKH <- nK_KH x y KHx KHy. rewrite {1}(divgr_eq K H y) mulgA (conjgCV x) {2}(divgr_eq K H x) -2!mulgA. rewrite mulgA remgrMid //; last by rewrite groupMl mem_remgr. by rewrite groupMl !(=^~ mem_conjg, nK_KH, mem_divgr). Qed. Lemma divgrM : H \subset 'C(K) -> {in G &, {morph divgr K H : x y / x * y}}. Proof. move=> cKH; have /complP[_ defG] := complH_K. have nsKG: K <| G by rewrite -defG -cent_joinEr // normalYl cents_norm. move=> x y Gx Gy; rewrite {1}/divgr remgrM // invMg -!mulgA (mulgA y). by congr (_ * _); rewrite -(centsP cKH) ?groupV ?(mem_remgr, mem_divgr, defG). Qed. End NormalComplement. (* Semi-direct product *) Lemma sdprod1g : left_id 1 sdprod. Proof. by move=> A; rewrite /sdprod subsetIl pprod1g. Qed. Lemma sdprodg1 : right_id 1 sdprod. Proof. by move=> A; rewrite /sdprod subsetIr pprodg1. Qed. Lemma sdprodP A B G : A ><| B = G -> [/\ are_groups A B, A * B = G, B \subset 'N(A) & A :&: B = 1]. Proof. rewrite /sdprod; case: ifP => [trAB | _ /group_not0[] //]. case/pprodP=> gAB defG nBA; split=> {defG nBA}//. by case: gAB trAB => H K -> -> /trivgP. Qed. Lemma sdprodE K H : H \subset 'N(K) -> K :&: H = 1 -> K ><| H = K * H. Proof. by move=> nKH tiKH; rewrite /sdprod tiKH subxx pprodE. Qed. Lemma sdprodEY K H : H \subset 'N(K) -> K :&: H = 1 -> K ><| H = K <*> H. Proof. by move=> nKH tiKH; rewrite sdprodE ?norm_joinEr. Qed. Lemma sdprodWpp A B G : A ><| B = G -> pprod A B = G. Proof. by case/sdprodP=> [[K H -> ->] <- /pprodE]. Qed. Lemma sdprodW A B G : A ><| B = G -> A * B = G. Proof. by move/sdprodWpp/pprodW. Qed. Lemma sdprodWC A B G : A ><| B = G -> B * A = G. Proof. by move/sdprodWpp/pprodWC. Qed. Lemma sdprodWY A B G : A ><| B = G -> A <*> B = G. Proof. by move/sdprodWpp/pprodWY. Qed. Lemma sdprodJ A B x : (A ><| B) :^ x = A :^ x ><| B :^ x. Proof. rewrite /sdprod -conjIg sub_conjg conjs1g -pprodJ. by case: ifP => _ //; apply: imset0. Qed. Lemma sdprod_context G K H : K ><| H = G -> [/\ K <| G, H \subset G, K * H = G, H \subset 'N(K) & K :&: H = 1]. Proof. case/sdprodP=> _ <- nKH tiKH. by rewrite /normal mulG_subl mulG_subr mulG_subG normG. Qed. Lemma sdprod_compl G K H : K ><| H = G -> H \in [complements to K in G]. Proof. by case/sdprodP=> _ mulKH _ tiKH; apply/complP. Qed. Lemma sdprod_normal_complP G K H : K <| G -> reflect (K ><| H = G) (K \in [complements to H in G]). Proof. case/andP=> _ nKG; rewrite complgC. apply: (iffP idP); [case/complP=> tiKH mulKH | exact: sdprod_compl]. by rewrite sdprodE ?(subset_trans _ nKG) // -mulKH mulG_subr. Qed. Lemma sdprod_card G A B : A ><| B = G -> (#|A| * #|B|)%N = #|G|. Proof. by case/sdprodP=> [[H K -> ->] <- _ /TI_cardMg]. Qed. Lemma sdprod_isom G A B : A ><| B = G -> {nAB : B \subset 'N(A) | isom B (G / A) (restrm nAB (coset A))}. Proof. case/sdprodP=> [[K H -> ->] <- nKH tiKH]. by exists nKH; rewrite quotientMidl quotient_isom. Qed. Lemma sdprod_isog G A B : A ><| B = G -> B \isog G / A. Proof. by case/sdprod_isom=> nAB; apply: isom_isog. Qed. Lemma sdprod_subr G A B M : A ><| B = G -> M \subset B -> A ><| M = A <*> M. Proof. case/sdprodP=> [[K H -> ->] _ nKH tiKH] sMH. by rewrite sdprodEY ?(subset_trans sMH) //; apply/trivgP; rewrite -tiKH setIS. Qed. Lemma index_sdprod G A B : A ><| B = G -> #|B| = #|G : A|. Proof. case/sdprodP=> [[K H -> ->] <- _ tiHK]. by rewrite indexMg -indexgI setIC tiHK indexg1. Qed. Lemma index_sdprodr G A B M : A ><| B = G -> M \subset B -> #|B : M| = #|G : A <*> M|. Proof. move=> defG; case/sdprodP: defG (defG) => [[K H -> ->] mulKH nKH _] defG sMH. rewrite -!divgS //=; last by rewrite -genM_join gen_subG -mulKH mulgS. by rewrite -(sdprod_card defG) -(sdprod_card (sdprod_subr defG sMH)) divnMl. Qed. Lemma quotient_sdprodr_isom G A B M : A ><| B = G -> M <| B -> {f : {morphism B / M >-> coset_of (A <*> M)} | isom (B / M) (G / (A <*> M)) f & forall L, L \subset B -> f @* (L / M) = A <*> L / (A <*> M)}. Proof. move=> defG nsMH; have [defA defB]: A = <<A>>%G /\ B = <<B>>%G. by have [[K1 H1 -> ->] _ _ _] := sdprodP defG; rewrite /= !genGid. do [rewrite {}defA {}defB; move: {A}<<A>>%G {B}<<B>>%G => K H] in defG nsMH *. have [[nKH /isomP[injKH imKH]] sMH] := (sdprod_isom defG, normal_sub nsMH). have [[nsKG sHG mulKH _ _] nKM] := (sdprod_context defG, subset_trans sMH nKH). have nsKMG: K <*> M <| G. by rewrite -quotientYK // -mulKH -quotientK ?cosetpre_normal ?quotient_normal. have [/= f inj_f im_f] := third_isom (joing_subl K M) nsKG nsKMG. rewrite quotientYidl //= -imKH -(restrm_quotientE nKH sMH) in f inj_f im_f. have /domP[h [_ ker_h _ im_h]]: 'dom (f \o quotm _ nsMH) = H / M. by rewrite ['dom _]morphpre_quotm injmK. have{} im_h L: L \subset H -> h @* (L / M) = K <*> L / (K <*> M). move=> sLH; have [sLG sKKM] := (subset_trans sLH sHG, joing_subl K M). rewrite im_h morphim_comp morphim_quotm [_ @* L]restrm_quotientE ?im_f //. rewrite quotientY ?(normsG sKKM) ?(subset_trans sLG) ?normal_norm //. by rewrite (quotientS1 sKKM) joing1G. exists h => //; apply/isomP; split; last by rewrite im_h //= (sdprodWY defG). by rewrite ker_h injm_comp ?injm_quotm. Qed. Lemma quotient_sdprodr_isog G A B M : A ><| B = G -> M <| B -> B / M \isog G / (A <*> M). Proof. move=> defG; case/sdprodP: defG (defG) => [[K H -> ->] _ _ _] => defG nsMH. by have [h /isom_isog->] := quotient_sdprodr_isom defG nsMH. Qed. Lemma sdprod_modl A B G H : A ><| B = G -> A \subset H -> A ><| (B :&: H) = G :&: H. Proof. case/sdprodP=> {A B} [[A B -> ->]] <- nAB tiAB sAH. rewrite -group_modl ?sdprodE ?subIset ?nAB //. by rewrite setIA tiAB (setIidPl _) ?sub1G. Qed. Lemma sdprod_modr A B G H : A ><| B = G -> B \subset H -> (H :&: A) ><| B = H :&: G. Proof. case/sdprodP=> {A B}[[A B -> ->]] <- nAB tiAB sAH. rewrite -group_modr ?sdprodE ?normsI // ?normsG //. by rewrite -setIA tiAB (setIidPr _) ?sub1G. Qed. Lemma subcent_sdprod B C G A : B ><| C = G -> A \subset 'N(B) :&: 'N(C) -> 'C_B(A) ><| 'C_C(A) = 'C_G(A). Proof. case/sdprodP=> [[H K -> ->] <- nHK tiHK] nHKA {B C G}. rewrite sdprodE ?subcent_TImulg ?normsIG //. by rewrite -setIIl tiHK (setIidPl (sub1G _)). Qed. Lemma sdprod_recl n G K H K1 : #|G| <= n -> K ><| H = G -> K1 \proper K -> H \subset 'N(K1) -> exists G1 : {group gT}, [/\ #|G1| < n, G1 \subset G & K1 ><| H = G1]. Proof. move=> leGn; case/sdprodP=> _ defG nKH tiKH ltK1K nK1H. have tiK1H: K1 :&: H = 1 by apply/trivgP; rewrite -tiKH setSI ?proper_sub. exists (K1 <*> H)%G; rewrite /= -defG sdprodE // norm_joinEr //. rewrite ?mulSg ?proper_sub ?(leq_trans _ leGn) //=. by rewrite -defG ?TI_cardMg // ltn_pmul2r ?proper_card. Qed. Lemma sdprod_recr n G K H H1 : #|G| <= n -> K ><| H = G -> H1 \proper H -> exists G1 : {group gT}, [/\ #|G1| < n, G1 \subset G & K ><| H1 = G1]. Proof. move=> leGn; case/sdprodP=> _ defG nKH tiKH ltH1H. have [sH1H _] := andP ltH1H; have nKH1 := subset_trans sH1H nKH. have tiKH1: K :&: H1 = 1 by apply/trivgP; rewrite -tiKH setIS. exists (K <*> H1)%G; rewrite /= -defG sdprodE // norm_joinEr //. rewrite ?mulgS // ?(leq_trans _ leGn) //=. by rewrite -defG ?TI_cardMg // ltn_pmul2l ?proper_card. Qed. Lemma mem_sdprod G A B x : A ><| B = G -> x \in G -> exists y, exists z, [/\ y \in A, z \in B, x = y * z & {in A & B, forall u t, x = u * t -> u = y /\ t = z}]. Proof. case/sdprodP=> [[K H -> ->{A B}] <- _ tiKH] /mulsgP[y z Ky Hz ->{x}]. exists y; exists z; split=> // u t Ku Ht eqyzut. move: (congr1 (divgr K H) eqyzut) (congr1 (remgr K H) eqyzut). by rewrite !remgrMid // !divgrMid. Qed. (* Central product *) Lemma cprod1g : left_id 1 cprod. Proof. by move=> A; rewrite /cprod cents1 pprod1g. Qed. Lemma cprodg1 : right_id 1 cprod. Proof. by move=> A; rewrite /cprod sub1G pprodg1. Qed. Lemma cprodP A B G : A \* B = G -> [/\ are_groups A B, A * B = G & B \subset 'C(A)]. Proof. by rewrite /cprod; case: ifP => [cAB /pprodP[] | _ /group_not0[]]. Qed. Lemma cprodE G H : H \subset 'C(G) -> G \* H = G * H. Proof. by move=> cGH; rewrite /cprod cGH pprodE ?cents_norm. Qed. Lemma cprodEY G H : H \subset 'C(G) -> G \* H = G <*> H. Proof. by move=> cGH; rewrite cprodE ?cent_joinEr. Qed. Lemma cprodWpp A B G : A \* B = G -> pprod A B = G. Proof. by case/cprodP=> [[K H -> ->] <- /cents_norm/pprodE]. Qed. Lemma cprodW A B G : A \* B = G -> A * B = G. Proof. by move/cprodWpp/pprodW. Qed. Lemma cprodWC A B G : A \* B = G -> B * A = G. Proof. by move/cprodWpp/pprodWC. Qed. Lemma cprodWY A B G : A \* B = G -> A <*> B = G. Proof. by move/cprodWpp/pprodWY. Qed. Lemma cprodJ A B x : (A \* B) :^ x = A :^ x \* B :^ x. Proof. by rewrite /cprod centJ conjSg -pprodJ; case: ifP => _ //; apply: imset0. Qed. Lemma cprod_normal2 A B G : A \* B = G -> A <| G /\ B <| G. Proof. case/cprodP=> [[K H -> ->] <- cKH]; rewrite -cent_joinEr //. by rewrite normalYl normalYr !cents_norm // centsC. Qed. Lemma bigcprodW I (r : seq I) P F G : \big[cprod/1]_(i <- r | P i) F i = G -> \prod_(i <- r | P i) F i = G. Proof. elim/big_rec2: _ G => // i A B _ IH G /cprodP[[_ H _ defB] <- _]. by rewrite (IH H) defB. Qed. Lemma bigcprodWY I (r : seq I) P F G : \big[cprod/1]_(i <- r | P i) F i = G -> << \bigcup_(i <- r | P i) F i >> = G. Proof. elim/big_rec2: _ G => [|i A B _ IH G]; first by rewrite gen0. case/cprodP => [[K H -> defB] <- cKH]. by rewrite -[<<_>>]joing_idr (IH H) ?cent_joinEr -?defB. Qed. Lemma triv_cprod A B : (A \* B == 1) = (A == 1) && (B == 1). Proof. case A1: (A == 1); first by rewrite (eqP A1) cprod1g. apply/eqP=> /cprodP[[G H defA ->]] /eqP. by rewrite defA trivMg -defA A1. Qed. Lemma cprod_ntriv A B : A != 1 -> B != 1 -> A \* B = if [&& group_set A, group_set B & B \subset 'C(A)] then A * B else set0. Proof. move=> A1 B1; rewrite /cprod; case: ifP => cAB; rewrite ?cAB ?andbF //=. by rewrite /pprod -if_neg A1 -if_neg B1 cents_norm. Qed. Lemma trivg0 : (@set0 gT == 1) = false. Proof. by rewrite eqEcard cards0 cards1 andbF. Qed. Lemma group0 : group_set (@set0 gT) = false. Proof. by rewrite /group_set inE. Qed. Lemma cprod0g A : set0 \* A = set0. Proof. by rewrite /cprod centsC sub0set /pprod group0 trivg0 !if_same. Qed. Lemma cprodC : commutative cprod. Proof. rewrite /cprod => A B; case: ifP => cAB; rewrite centsC cAB // /pprod. by rewrite andbCA normC !cents_norm // 1?centsC //; do 2!case: eqP => // ->. Qed. Lemma cprodA : associative cprod. Proof. move=> A B C; case A1: (A == 1); first by rewrite (eqP A1) !cprod1g. case B1: (B == 1); first by rewrite (eqP B1) cprod1g cprodg1. case C1: (C == 1); first by rewrite (eqP C1) !cprodg1. rewrite !(triv_cprod, cprod_ntriv) ?{}A1 ?{}B1 ?{}C1 //. case: isgroupP => [[G ->{A}] | _]; last by rewrite group0. case: (isgroupP B) => [[H ->{B}] | _]; last by rewrite group0. case: (isgroupP C) => [[K ->{C}] | _]; last by rewrite group0 !andbF. case cGH: (H \subset 'C(G)); case cHK: (K \subset 'C(H)); last first. - by rewrite group0. - by rewrite group0 /= mulG_subG cGH andbF. - by rewrite group0 /= centM subsetI cHK !andbF. rewrite /= mulgA mulG_subG centM subsetI cGH cHK andbT -(cent_joinEr cHK). by rewrite -(cent_joinEr cGH) !groupP. Qed. HB.instance Definition _ := Monoid.isComLaw.Build {set gT} 1 cprod cprodA cprodC cprod1g. Lemma cprod_modl A B G H : A \* B = G -> A \subset H -> A \* (B :&: H) = G :&: H. Proof. case/cprodP=> [[U V -> -> {A B}]] defG cUV sUH. by rewrite cprodE; [rewrite group_modl ?defG | rewrite subIset ?cUV]. Qed. Lemma cprod_modr A B G H : A \* B = G -> B \subset H -> (H :&: A) \* B = H :&: G. Proof. by rewrite -!(cprodC B) !(setIC H); apply: cprod_modl. Qed. Lemma bigcprodYP (I : finType) (P : pred I) (H : I -> {group gT}) : reflect (forall i j, P i -> P j -> i != j -> H i \subset 'C(H j)) (\big[cprod/1]_(i | P i) H i == (\prod_(i | P i) H i)%G). Proof. apply: (iffP eqP) => [defG i j Pi Pj neq_ij | cHH]. rewrite (bigD1 j) // (bigD1 i) /= ?cprodA in defG; last exact/andP. by case/cprodP: defG => [[K _ /cprodP[//]]]. set Q := P; have sQP: subpred Q P by []; have [n leQn] := ubnP #|Q|. elim: n => // n IHn in (Q) leQn sQP *. have [i Qi | Q0] := pickP Q; last by rewrite !big_pred0. rewrite (cardD1x Qi) add1n ltnS !(bigD1 i Qi) /= in leQn *. rewrite {}IHn {n leQn}// => [|j /andP[/sQP //]]. rewrite bigprodGE cprodEY // gen_subG; apply/bigcupsP=> j /andP[neq_ji Qj]. by rewrite cHH ?sQP. Qed. Lemma bigcprodEY I r (P : pred I) (H : I -> {group gT}) G : abelian G -> (forall i, P i -> H i \subset G) -> \big[cprod/1]_(i <- r | P i) H i = (\prod_(i <- r | P i) H i)%G. Proof. move=> cGG sHG; apply/eqP; rewrite !(big_tnth _ _ r). by apply/bigcprodYP=> i j Pi Pj _; rewrite (sub_abelian_cent2 cGG) ?sHG. Qed. Lemma perm_bigcprod (I : eqType) r1 r2 (A : I -> {set gT}) G x : \big[cprod/1]_(i <- r1) A i = G -> {in r1, forall i, x i \in A i} -> perm_eq r1 r2 -> \prod_(i <- r1) x i = \prod_(i <- r2) x i. Proof. elim: r1 r2 G => [|i r1 IHr] r2 G defG Ax eq_r12. by rewrite perm_sym in eq_r12; rewrite (perm_small_eq _ eq_r12) ?big_nil. have /rot_to[n r3 Dr2]: i \in r2 by rewrite -(perm_mem eq_r12) mem_head. transitivity (\prod_(j <- rot n r2) x j). rewrite Dr2 !big_cons in defG Ax *; have [[_ G1 _ defG1] _ _] := cprodP defG. rewrite (IHr r3 G1) //; first by case/allP/andP: Ax => _ /allP. by rewrite -(perm_cons i) -Dr2 perm_sym perm_rot perm_sym. rewrite -(cat_take_drop n r2) [in LHS]cat_take_drop in eq_r12 *. rewrite (perm_big _ eq_r12) !big_cat /= !(big_nth i) !big_mkord in defG *. have /cprodP[[G1 G2 defG1 defG2] _ /centsP-> //] := defG. rewrite defG2 -(bigcprodW defG2) mem_prodg // => k _; apply: Ax. by rewrite (perm_mem eq_r12) mem_cat orbC mem_nth. rewrite defG1 -(bigcprodW defG1) mem_prodg // => k _; apply: Ax. by rewrite (perm_mem eq_r12) mem_cat mem_nth. Qed. Lemma reindex_bigcprod (I J : finType) (h : J -> I) P (A : I -> {set gT}) G x : {on SimplPred P, bijective h} -> \big[cprod/1]_(i | P i) A i = G -> {in SimplPred P, forall i, x i \in A i} -> \prod_(i | P i) x i = \prod_(j | P (h j)) x (h j). Proof. case=> h1 hK h1K defG Ax; have [e big_e [Ue mem_e] _] := big_enumP P. rewrite -!big_e in defG *; rewrite -(big_map h P x) -[RHS]big_filter filter_map. apply: perm_bigcprod defG _ _ => [i|]; first by rewrite mem_e => /Ax. have [r _ [Ur /= mem_r] _] := big_enumP; apply: uniq_perm Ue _ _ => [|i]. by rewrite map_inj_in_uniq // => i j; rewrite !mem_r ; apply: (can_in_inj hK). rewrite mem_e; apply/idP/mapP=> [Pi|[j r_j ->]]; last by rewrite -mem_r. by exists (h1 i); rewrite ?mem_r h1K. Qed. (* Direct product *) Lemma dprod1g : left_id 1 dprod. Proof. by move=> A; rewrite /dprod subsetIl cprod1g. Qed. Lemma dprodg1 : right_id 1 dprod. Proof. by move=> A; rewrite /dprod subsetIr cprodg1. Qed. Lemma dprodP A B G : A \x B = G -> [/\ are_groups A B, A * B = G, B \subset 'C(A) & A :&: B = 1]. Proof. rewrite /dprod; case: ifP => trAB; last by case/group_not0. by case/cprodP=> gAB; split=> //; case: gAB trAB => ? ? -> -> /trivgP. Qed. Lemma dprodE G H : H \subset 'C(G) -> G :&: H = 1 -> G \x H = G * H. Proof. by move=> cGH trGH; rewrite /dprod trGH sub1G cprodE. Qed. Lemma dprodEY G H : H \subset 'C(G) -> G :&: H = 1 -> G \x H = G <*> H. Proof. by move=> cGH trGH; rewrite /dprod trGH subxx cprodEY. Qed. Lemma dprodEcp A B : A :&: B = 1 -> A \x B = A \* B. Proof. by move=> trAB; rewrite /dprod trAB subxx. Qed. Lemma dprodEsd A B : B \subset 'C(A) -> A \x B = A ><| B. Proof. by rewrite /dprod /cprod => ->. Qed. Lemma dprodWcp A B G : A \x B = G -> A \* B = G. Proof. by move=> defG; have [_ _ _ /dprodEcp <-] := dprodP defG. Qed. Lemma dprodWsd A B G : A \x B = G -> A ><| B = G. Proof. by move=> defG; have [_ _ /dprodEsd <-] := dprodP defG. Qed. Lemma dprodW A B G : A \x B = G -> A * B = G. Proof. by move/dprodWsd/sdprodW. Qed. Lemma dprodWC A B G : A \x B = G -> B * A = G. Proof. by move/dprodWsd/sdprodWC. Qed. Lemma dprodWY A B G : A \x B = G -> A <*> B = G. Proof. by move/dprodWsd/sdprodWY. Qed. Lemma cprod_card_dprod G A B : A \* B = G -> #|A| * #|B| <= #|G| -> A \x B = G. Proof. by case/cprodP=> [[K H -> ->] <- cKH] /cardMg_TI; apply: dprodE. Qed. Lemma dprodJ A B x : (A \x B) :^ x = A :^ x \x B :^ x. Proof. rewrite /dprod -conjIg sub_conjg conjs1g -cprodJ. by case: ifP => _ //; apply: imset0. Qed. Lemma dprod_normal2 A B G : A \x B = G -> A <| G /\ B <| G. Proof. by move/dprodWcp/cprod_normal2. Qed. Lemma dprodYP K H : reflect (K \x H = K <*> H) (H \subset 'C(K) :\: K^#). Proof. rewrite subsetD -setI_eq0 setIDA setD_eq0 setIC subG1 /=. by apply: (iffP andP) => [[cKH /eqP/dprodEY->] | /dprodP[_ _ -> ->]]. Qed. Lemma dprodC : commutative dprod. Proof. by move=> A B; rewrite /dprod setIC cprodC. Qed. Lemma dprodWsdC A B G : A \x B = G -> B ><| A = G. Proof. by rewrite dprodC => /dprodWsd. Qed. Lemma dprodA : associative dprod. Proof. move=> A B C; case A1: (A == 1); first by rewrite (eqP A1) !dprod1g. case B1: (B == 1); first by rewrite (eqP B1) dprod1g dprodg1. case C1: (C == 1); first by rewrite (eqP C1) !dprodg1. rewrite /dprod (fun_if (cprod A)) (fun_if (cprod^~ C)) -cprodA. rewrite -(cprodC set0) !cprod0g cprod_ntriv ?B1 ?{}C1 //. case: and3P B1 => [[] | _ _]; last by rewrite cprodC cprod0g !if_same. case/isgroupP=> H ->; case/isgroupP=> K -> {B C}; move/cent_joinEr=> eHK H1. rewrite cprod_ntriv ?trivMg ?{}A1 ?{}H1 // mulG_subG. case: and4P => [[] | _]; last by rewrite !if_same. case/isgroupP=> G ->{A} _ cGH _; rewrite cprodEY // -eHK. case trGH: (G :&: H \subset _); case trHK: (H :&: K \subset _); last first. - by rewrite !if_same. - rewrite if_same; case: ifP => // trG_HK; case/negP: trGH. by apply: subset_trans trG_HK; rewrite setIS ?joing_subl. - rewrite if_same; case: ifP => // trGH_K; case/negP: trHK. by apply: subset_trans trGH_K; rewrite setSI ?joing_subr. do 2![case: ifP] => // trGH_K trG_HK; [case/negP: trGH_K | case/negP: trG_HK]. apply: subset_trans trHK; rewrite subsetI subsetIr -{2}(mulg1 H) -mulGS. rewrite setIC group_modl ?joing_subr //= cent_joinEr // -eHK. by rewrite -group_modr ?joing_subl //= setIC -(normC (sub1G _)) mulSg. apply: subset_trans trGH; rewrite subsetI subsetIl -{2}(mul1g H) -mulSG. rewrite setIC group_modr ?joing_subl //= eHK -(cent_joinEr cGH). by rewrite -group_modl ?joing_subr //= setIC (normC (sub1G _)) mulgS. Qed. HB.instance Definition _ := Monoid.isComLaw.Build {set gT} 1 dprod dprodA dprodC dprod1g. Lemma bigdprodWcp I (r : seq I) P F G : \big[dprod/1]_(i <- r | P i) F i = G -> \big[cprod/1]_(i <- r | P i) F i = G. Proof. elim/big_rec2: _ G => // i A B _ IH G /dprodP[[K H -> defB] <- cKH _]. by rewrite (IH H) // cprodE -defB. Qed. Lemma bigdprodW I (r : seq I) P F G : \big[dprod/1]_(i <- r | P i) F i = G -> \prod_(i <- r | P i) F i = G. Proof. by move/bigdprodWcp; apply: bigcprodW. Qed. Lemma bigdprodWY I (r : seq I) P F G : \big[dprod/1]_(i <- r | P i) F i = G -> << \bigcup_(i <- r | P i) F i >> = G. Proof. by move/bigdprodWcp; apply: bigcprodWY. Qed. Lemma bigdprodYP (I : finType) (P : pred I) (F : I -> {group gT}) : reflect (forall i, P i -> (\prod_(j | P j && (j != i)) F j)%G \subset 'C(F i) :\: (F i)^#) (\big[dprod/1]_(i | P i) F i == (\prod_(i | P i) F i)%G). Proof. apply: (iffP eqP) => [defG i Pi | dxG]. rewrite !(bigD1 i Pi) /= in defG; have [[_ G' _ defG'] _ _ _] := dprodP defG. by apply/dprodYP; rewrite -defG defG' bigprodGE (bigdprodWY defG'). set Q := P; have sQP: subpred Q P by []; have [n leQn] := ubnP #|Q|. elim: n => // n IHn in (Q) leQn sQP *. have [i Qi | Q0] := pickP Q; last by rewrite !big_pred0. rewrite (cardD1x Qi) add1n ltnS !(bigD1 i Qi) /= in leQn *. rewrite {}IHn {n leQn}// => [|j /andP[/sQP //]]. apply/dprodYP; apply: subset_trans (dxG i (sQP i Qi)); rewrite !bigprodGE. by apply: genS; apply/bigcupsP=> j /andP[Qj ne_ji]; rewrite (bigcup_max j) ?sQP. Qed. Lemma dprod_modl A B G H : A \x B = G -> A \subset H -> A \x (B :&: H) = G :&: H. Proof. case/dprodP=> [[U V -> -> {A B}]] defG cUV trUV sUH. rewrite dprodEcp; first by apply: cprod_modl; rewrite ?cprodE. by rewrite setIA trUV (setIidPl _) ?sub1G. Qed. Lemma dprod_modr A B G H : A \x B = G -> B \subset H -> (H :&: A) \x B = H :&: G. Proof. by rewrite -!(dprodC B) !(setIC H); apply: dprod_modl. Qed. Lemma subcent_dprod B C G A : B \x C = G -> A \subset 'N(B) :&: 'N(C) -> 'C_B(A) \x 'C_C(A) = 'C_G(A). Proof. move=> defG; have [_ _ cBC _] := dprodP defG; move: defG. by rewrite !dprodEsd 1?(centSS _ _ cBC) ?subsetIl //; apply: subcent_sdprod. Qed. Lemma dprod_card A B G : A \x B = G -> (#|A| * #|B|)%N = #|G|. Proof. by case/dprodP=> [[H K -> ->] <- _]; move/TI_cardMg. Qed. Lemma bigdprod_card I r (P : pred I) E G : \big[dprod/1]_(i <- r | P i) E i = G -> (\prod_(i <- r | P i) #|E i|)%N = #|G|. Proof. elim/big_rec2: _ G => [G <- | i A B _ IH G defG]; first by rewrite cards1. have [[_ H _ defH] _ _ _] := dprodP defG. by rewrite -(dprod_card defG) (IH H) defH. Qed. Lemma bigcprod_card_dprod I r (P : pred I) (A : I -> {set gT}) G : \big[cprod/1]_(i <- r | P i) A i = G -> \prod_(i <- r | P i) #|A i| <= #|G| -> \big[dprod/1]_(i <- r | P i) A i = G. Proof. elim: r G => [|i r IHr]; rewrite !(big_nil, big_cons) //; case: ifP => _ // G. case/cprodP=> [[K H -> defH]]; rewrite defH => <- cKH leKH_G. have /implyP := leq_trans leKH_G (dvdn_leq _ (dvdn_cardMg K H)). rewrite muln_gt0 leq_pmul2l !cardG_gt0 //= => /(IHr H defH){}defH. by rewrite defH dprodE // cardMg_TI // -(bigdprod_card defH). Qed. Lemma bigcprod_coprime_dprod (I : finType) (P : pred I) (A : I -> {set gT}) G : \big[cprod/1]_(i | P i) A i = G -> (forall i j, P i -> P j -> i != j -> coprime #|A i| #|A j|) -> \big[dprod/1]_(i | P i) A i = G. Proof. move=> defG coA; set Q := P in defG *; have sQP: subpred Q P by []. have [m leQm] := ubnP #|Q|; elim: m => // m IHm in (Q) leQm G defG sQP *. have [i Qi | Q0] := pickP Q; last by rewrite !big_pred0 in defG *. move: defG; rewrite !(bigD1 i Qi) /= => /cprodP[[Hi Gi defAi defGi] <-]. rewrite defAi defGi => cHGi. have{} defGi: \big[dprod/1]_(j | Q j && (j != i)) A j = Gi. by apply: IHm => [||j /andP[/sQP]] //; rewrite (cardD1x Qi) in leQm. rewrite defGi dprodE // coprime_TIg // -defAi -(bigdprod_card defGi). elim/big_rec: _ => [|j n /andP[neq_ji Qj] IHn]; first exact: coprimen1. by rewrite coprimeMr coprime_sym coA ?sQP. Qed. Lemma mem_dprod G A B x : A \x B = G -> x \in G -> exists y, exists z, [/\ y \in A, z \in B, x = y * z & {in A & B, forall u t, x = u * t -> u = y /\ t = z}]. Proof. move=> defG; have [_ _ cBA _] := dprodP defG. by apply: mem_sdprod; rewrite -dprodEsd. Qed. Lemma mem_bigdprod (I : finType) (P : pred I) F G x : \big[dprod/1]_(i | P i) F i = G -> x \in G -> exists c, [/\ forall i, P i -> c i \in F i, x = \prod_(i | P i) c i & forall e, (forall i, P i -> e i \in F i) -> x = \prod_(i | P i) e i -> forall i, P i -> e i = c i]. Proof. move=> defG; rewrite -(bigdprodW defG) => /prodsgP[c Fc ->]. have [r big_r [_ mem_r] _] := big_enumP P. exists c; split=> // e Fe eq_ce i Pi; rewrite -!{}big_r in defG eq_ce. have{Pi}: i \in r by rewrite mem_r. have{mem_r}: all P r by apply/allP=> j; rewrite mem_r. elim: r G defG eq_ce => // j r IHr G. rewrite !big_cons inE /= => /dprodP[[K H defK defH] _ _]. rewrite defK defH => tiFjH eq_ce /andP[Pj Pr]. suffices{i IHr} eq_cej: c j = e j. case/predU1P=> [-> //|]; apply: IHr defH _ Pr. by apply: (mulgI (c j)); rewrite eq_ce eq_cej. rewrite !(big_nth j) !big_mkord in defH eq_ce. move/(congr1 (divgr K H)): eq_ce; move/bigdprodW: defH => defH. move/(all_nthP j) in Pr. by rewrite !divgrMid // -?defK -?defH ?mem_prodg // => *; rewrite ?Fc ?Fe ?Pr. Qed. Lemma comm_prodG I r (G : I -> {group gT}) (P : {pred I}) : {in P &, forall i j, commute (G i) (G j)} -> (\prod_(i <- r | P i) G i)%G = \prod_(i <- r | P i) G i :> {set gT}. Proof. elim: r => /= [|i {}r IHr]; rewrite !(big_nil, big_cons)//=. case: ifP => //= Pi Gcomm; rewrite comm_joingE {}IHr// /commute. elim: r => [|j r IHr]; first by rewrite big_nil mulg1 mul1g. by rewrite big_cons; case: ifP => //= Pj; rewrite mulgA Gcomm// -!mulgA IHr. Qed. End InternalProd. Arguments complP {gT H A B}. Arguments splitsP {gT B A}. Arguments sdprod_normal_complP {gT G K H}. Arguments dprodYP {gT K H}. Arguments bigdprodYP {gT I P F}. Section MorphimInternalProd. Variables (gT rT : finGroupType) (D : {group gT}) (f : {morphism D >-> rT}). Section OneProd. Variables G H K : {group gT}. Hypothesis sGD : G \subset D. Lemma morphim_pprod : pprod K H = G -> pprod (f @* K) (f @* H) = f @* G. Proof. case/pprodP=> _ defG mKH; rewrite pprodE ?morphim_norms //. by rewrite -morphimMl ?(subset_trans _ sGD) -?defG // mulG_subl. Qed. Lemma morphim_coprime_sdprod : K ><| H = G -> coprime #|K| #|H| -> f @* K ><| f @* H = f @* G. Proof. rewrite /sdprod => defG coHK; move: defG. by rewrite !coprime_TIg ?coprime_morph // !subxx; apply: morphim_pprod. Qed. Lemma injm_sdprod : 'injm f -> K ><| H = G -> f @* K ><| f @* H = f @* G. Proof. move=> inj_f; case/sdprodP=> _ defG nKH tiKH. by rewrite /sdprod -injmI // tiKH morphim1 subxx morphim_pprod // pprodE. Qed. Lemma morphim_cprod : K \* H = G -> f @* K \* f @* H = f @* G. Proof. case/cprodP=> _ defG cKH; rewrite /cprod morphim_cents // morphim_pprod //. by rewrite pprodE // cents_norm // centsC. Qed. Lemma injm_dprod : 'injm f -> K \x H = G -> f @* K \x f @* H = f @* G. Proof. move=> inj_f; case/dprodP=> _ defG cHK tiKH. by rewrite /dprod -injmI // tiKH morphim1 subxx morphim_cprod // cprodE. Qed. Lemma morphim_coprime_dprod : K \x H = G -> coprime #|K| #|H| -> f @* K \x f @* H = f @* G. Proof. rewrite /dprod => defG coHK; move: defG. by rewrite !coprime_TIg ?coprime_morph // !subxx; apply: morphim_cprod. Qed. End OneProd. Implicit Type G : {group gT}. Lemma morphim_bigcprod I r (P : pred I) (H : I -> {group gT}) G : G \subset D -> \big[cprod/1]_(i <- r | P i) H i = G -> \big[cprod/1]_(i <- r | P i) f @* H i = f @* G. Proof. elim/big_rec2: _ G => [|i fB B Pi def_fB] G sGD defG. by rewrite -defG morphim1. case/cprodP: defG (defG) => [[Hi Gi -> defB] _ _]; rewrite defB => defG. rewrite (def_fB Gi) //; first exact: morphim_cprod. by apply: subset_trans sGD; case/cprod_normal2: defG => _ /andP[]. Qed. Lemma injm_bigdprod I r (P : pred I) (H : I -> {group gT}) G : G \subset D -> 'injm f -> \big[dprod/1]_(i <- r | P i) H i = G -> \big[dprod/1]_(i <- r | P i) f @* H i = f @* G. Proof. move=> sGD injf; elim/big_rec2: _ G sGD => [|i fB B Pi def_fB] G sGD defG. by rewrite -defG morphim1. case/dprodP: defG (defG) => [[Hi Gi -> defB] _ _ _]; rewrite defB => defG. rewrite (def_fB Gi) //; first exact: injm_dprod. by apply: subset_trans sGD; case/dprod_normal2: defG => _ /andP[]. Qed. Lemma morphim_coprime_bigdprod (I : finType) P (H : I -> {group gT}) G : G \subset D -> \big[dprod/1]_(i | P i) H i = G -> (forall i j, P i -> P j -> i != j -> coprime #|H i| #|H j|) -> \big[dprod/1]_(i | P i) f @* H i = f @* G. Proof. move=> sGD /bigdprodWcp defG coH; have def_fG := morphim_bigcprod sGD defG. by apply: bigcprod_coprime_dprod => // i j *; rewrite coprime_morph ?coH. Qed. End MorphimInternalProd. Section QuotientInternalProd. Variables (gT : finGroupType) (G K H M : {group gT}). Hypothesis nMG: G \subset 'N(M). Lemma quotient_pprod : pprod K H = G -> pprod (K / M) (H / M) = G / M. Proof. exact: morphim_pprod. Qed. Lemma quotient_coprime_sdprod : K ><| H = G -> coprime #|K| #|H| -> (K / M) ><| (H / M) = G / M. Proof. exact: morphim_coprime_sdprod. Qed. Lemma quotient_cprod : K \* H = G -> (K / M) \* (H / M) = G / M. Proof. exact: morphim_cprod. Qed. Lemma quotient_coprime_dprod : K \x H = G -> coprime #|K| #|H| -> (K / M) \x (H / M) = G / M. Proof. exact: morphim_coprime_dprod. Qed. End QuotientInternalProd. Section ExternalDirProd. Variables gT1 gT2 : finGroupType. Definition extprod_mulg (x y : gT1 * gT2) := (x.1 * y.1, x.2 * y.2). Definition extprod_invg (x : gT1 * gT2) := (x.1^-1, x.2^-1). Lemma extprod_mul1g : left_id (1, 1) extprod_mulg. Proof. by case=> x1 x2; congr (_, _); apply: mul1g. Qed. Lemma extprod_mulVg : left_inverse (1, 1) extprod_invg extprod_mulg. Proof. by move=> x; congr (_, _); apply: mulVg. Qed. Lemma extprod_mulgA : associative extprod_mulg. Proof. by move=> x y z; congr (_, _); apply: mulgA. Qed. HB.instance Definition _ := isMulGroup.Build (gT1 * gT2)%type extprod_mulgA extprod_mul1g extprod_mulVg. Lemma group_setX (H1 : {group gT1}) (H2 : {group gT2}) : group_set (setX H1 H2). Proof. apply/group_setP; split; first by rewrite !inE !group1. by case=> [x1 x2] [y1 y2] /[!inE] /andP[Hx1 Hx2] /andP[Hy1 Hy2] /[!groupM]. Qed. Canonical setX_group H1 H2 := Group (group_setX H1 H2). Definition pairg1 x : gT1 * gT2 := (x, 1). Definition pair1g x : gT1 * gT2 := (1, x). Lemma pairg1_morphM : {morph pairg1 : x y / x * y}. Proof. by move=> x y /=; rewrite {2}/mulg /= /extprod_mulg /= mul1g. Qed. Canonical pairg1_morphism := @Morphism _ _ setT _ (in2W pairg1_morphM). Lemma pair1g_morphM : {morph pair1g : x y / x * y}. Proof. by move=> x y /=; rewrite {2}/mulg /= /extprod_mulg /= mul1g. Qed. Canonical pair1g_morphism := @Morphism _ _ setT _ (in2W pair1g_morphM). Lemma fst_morphM : {morph (@fst gT1 gT2) : x y / x * y}. Proof. by move=> x y. Qed. Lemma snd_morphM : {morph (@snd gT1 gT2) : x y / x * y}. Proof. by move=> x y. Qed. Canonical fst_morphism := @Morphism _ _ setT _ (in2W fst_morphM). Canonical snd_morphism := @Morphism _ _ setT _ (in2W snd_morphM). Lemma injm_pair1g : 'injm pair1g. Proof. by apply/subsetP=> x /morphpreP[_ /set1P[->]]; apply: set11. Qed. Lemma injm_pairg1 : 'injm pairg1. Proof. by apply/subsetP=> x /morphpreP[_ /set1P[->]]; apply: set11. Qed. Lemma morphim_pairg1 (H1 : {set gT1}) : pairg1 @* H1 = setX H1 1. Proof. by rewrite -imset2_pair imset2_set1r morphimEsub ?subsetT. Qed. Lemma morphim_pair1g (H2 : {set gT2}) : pair1g @* H2 = setX 1 H2. Proof. by rewrite -imset2_pair imset2_set1l morphimEsub ?subsetT. Qed. Lemma morphim_fstX (H1: {set gT1}) (H2 : {group gT2}) : [morphism of fun x => x.1] @* setX H1 H2 = H1. Proof. apply/eqP; rewrite eqEsubset morphimE setTI /=. apply/andP; split; apply/subsetP=> x. by case/imsetP=> x0 /[1!inE] /andP[Hx1 _] ->. move=> Hx1; apply/imsetP; exists (x, 1); last by trivial. by rewrite in_setX Hx1 /=. Qed. Lemma morphim_sndX (H1: {group gT1}) (H2 : {set gT2}) : [morphism of fun x => x.2] @* setX H1 H2 = H2. Proof. apply/eqP; rewrite eqEsubset morphimE setTI /=. apply/andP; split; apply/subsetP=> x. by case/imsetP=> x0 /[1!inE] /andP[_ Hx2] ->. move=> Hx2; apply/imsetP; exists (1, x); last by []. by rewrite in_setX Hx2 andbT. Qed. Lemma setX_prod (H1 : {set gT1}) (H2 : {set gT2}) : setX H1 1 * setX 1 H2 = setX H1 H2. Proof. apply/setP=> [[x y]]; rewrite !inE /=. apply/imset2P/andP=> [[[x1 u1] [v1 y1]] | [Hx Hy]]. rewrite !inE /= => /andP[Hx1 /eqP->] /andP[/eqP-> Hx] [-> ->]. by rewrite mulg1 mul1g. exists (x, 1 : gT2) (1 : gT1, y); rewrite ?inE ?Hx ?eqxx //. by rewrite /mulg /= /extprod_mulg /= mulg1 mul1g. Qed. Lemma setX_dprod (H1 : {group gT1}) (H2 : {group gT2}) : setX H1 1 \x setX 1 H2 = setX H1 H2. Proof. rewrite dprodE ?setX_prod //. apply/centsP=> [[x u]] /[!inE]/= /andP[/eqP-> _] [v y]. by rewrite !inE /= => /andP[_ /eqP->]; congr (_, _); rewrite ?mul1g ?mulg1. apply/trivgP; apply/subsetP=> [[x y]]; rewrite !inE /= -!andbA. by case/and4P=> _ /eqP-> /eqP->; rewrite eqxx. Qed. Lemma isog_setX1 (H1 : {group gT1}) : isog H1 (setX H1 1). Proof. apply/isogP; exists [morphism of restrm (subsetT H1) pairg1]. by rewrite injm_restrm ?injm_pairg1. by rewrite morphim_restrm morphim_pairg1 setIid. Qed. Lemma isog_set1X (H2 : {group gT2}) : isog H2 (setX 1 H2). Proof. apply/isogP; exists [morphism of restrm (subsetT H2) pair1g]. by rewrite injm_restrm ?injm_pair1g. by rewrite morphim_restrm morphim_pair1g setIid. Qed. Lemma setX_gen (H1 : {set gT1}) (H2 : {set gT2}) : 1 \in H1 -> 1 \in H2 -> <<setX H1 H2>> = setX <<H1>> <<H2>>. Proof. move=> H1_1 H2_1; apply/eqP. rewrite eqEsubset gen_subG setXS ?subset_gen //. (* TODO: investigate why the occurrence selection changed *) rewrite -[in X in X \subset _]setX_prod. rewrite -morphim_pair1g -morphim_pairg1 !morphim_gen ?subsetT //. by rewrite morphim_pair1g morphim_pairg1 mul_subG // genS // setXS ?sub1set. Qed. End ExternalDirProd. Section ExternalDirDepProd. Variables (I : finType) (gT : I -> finGroupType). Notation gTn := {dffun forall i, gT i}. Implicit Types (H : forall i, {group gT i}) (x y : {dffun forall i, gT i}). Definition extnprod_mulg (x y : gTn) : gTn := [ffun i => (x i * y i)%g]. Definition extnprod_invg (x : gTn) : gTn := [ffun i => (x i)^-1%g]. Lemma extnprod_mul1g : left_id [ffun=> 1%g] extnprod_mulg. Proof. by move=> x; apply/ffunP => i; rewrite !ffunE mul1g. Qed. Lemma extnprod_mulVg : left_inverse [ffun=> 1%g] extnprod_invg extnprod_mulg. Proof. by move=> x; apply/ffunP => i; rewrite !ffunE mulVg. Qed. Lemma extnprod_mulgA : associative extnprod_mulg. Proof. by move=> x y z; apply/ffunP => i; rewrite !ffunE mulgA. Qed. HB.instance Definition _ := isMulGroup.Build {dffun forall i : I, gT i} extnprod_mulgA extnprod_mul1g extnprod_mulVg. Lemma oneg_ffun i : (1 : gTn) i = 1. Proof. by rewrite ffunE. Qed. Lemma mulg_ffun i (x y : gTn) : (x * y) i = x i * y i. Proof. by rewrite ffunE. Qed. Lemma invg_ffun i (x : gTn) : x^-1 i = (x i)^-1. Proof. by rewrite ffunE. Qed. Lemma prodg_ffun T (r : seq T) (F : T -> gTn) (P : {pred T}) i : (\prod_(t <- r | P t) F t) i = \prod_(t <- r | P t) F t i. Proof. exact: (big_morph _ (@mulg_ffun i) (@oneg_ffun i)). Qed. Lemma group_setXn H : group_set (setXn H). Proof. by apply/group_setP; split=> [|x y] /[!inE]/= => [|/forallP xH /forallP yH]; apply/forallP => i; rewrite ?ffunE (group1, groupM)// ?xH ?yH. Qed. Canonical setXn_group H := Group (group_setXn H). Definition dfung1 i (g : gT i) : gTn := finfun (dfwith (fun=> 1 : gT _) g). Lemma dfung1_id i (g : gT i) : dfung1 g i = g. Proof. by rewrite ffunE dfwith_in. Qed. Lemma dfung1_dflt i (g : gT i) j : i != j -> dfung1 g j = 1. Proof. by move=> ij; rewrite ffunE dfwith_out. Qed. Lemma dfung1_morphM i : {morph @dfung1 i : g h / g * h}. Proof. move=> g h; apply/ffunP=> j; have [{j}<-|nij] := eqVneq i j. by rewrite !(dfung1_id, ffunE). by rewrite !(dfung1_dflt, ffunE)// mulg1. Qed. Canonical dfung1_morphism i := @Morphism _ _ setT _ (in2W (@dfung1_morphM i)). Lemma dffunM i : {morph (fun x => x i) : x y / x * y}. Proof. by move=> x y; rewrite !ffunE. Qed. Canonical dffun_morphism i := @Morphism _ _ setT _ (in2W (@dffunM i)). Lemma injm_dfung1 i : 'injm (@dfung1 i). Proof. apply/subsetP => x /morphpreP[_ /set1P /ffunP/=/(_ i)]. by rewrite !(ffunE, dfung1_id) => ->; apply: set11. Qed. Lemma group_set_dfwith H i (G : {group gT i}) j : group_set (dfwith (H : forall k, {set gT k}) (G : {set _}) j). Proof. have [<-|ij] := eqVneq i j; first by rewrite !dfwith_in// groupP. by rewrite !dfwith_out // groupP. Qed. Canonical group_dfwith H i G j := Group (@group_set_dfwith H i G j). Lemma group_dfwithE H i G j : @group_dfwith H i G j = dfwith H G j. Proof. by apply/val_inj; have [<-|nij]/= := eqVneq i j; [rewrite !dfwith_in|rewrite !dfwith_out]. Qed. Fact set1gXn_key : unit. Proof. by []. Qed. Definition set1gXn {i} (H : {set gT i}) : {set {dffun forall i : I, gT i}} := locked_with set1gXn_key (setXn (dfwith (fun i0 : I => [1 gT _]%g) H)). Lemma set1gXnE {i} (H : {set gT i}) : set1gXn H = setXn (dfwith (fun i0 : I => [1 gT _]%g) H). Proof. by rewrite /set1gXn unlock. Qed. Lemma set1gXnP {i} (H : {set gT i}) x : reflect (exists2 h, h \in H & x = dfung1 h) (x \in set1gXn H). Proof. rewrite set1gXnE/=; apply: (iffP setXnP) => [xP|[h hH ->] j]; last first. by rewrite ffunE; case: dfwithP => [|k ?]; rewrite (dfwith_in, dfwith_out). exists (x i); first by have := xP i; rewrite dfwith_in. apply/ffunP => j; have := xP j; rewrite ffunE. case: dfwithP => // [xiH|k neq_ik]; first by rewrite dfwith_in. by move=> /set1gP->; rewrite dfwith_out. Qed. Lemma morphim_dfung1 i (G : {set gT i}) : @dfung1 i @* G = set1gXn G. Proof. by rewrite morphimEsub//=; apply/setP=> /= x; apply/imsetP/set1gXnP. Qed. Lemma morphim_dffunXn i H : dffun_morphism i @* setXn H = H i. Proof. apply/eqP; rewrite eqEsubset morphimE setTI /=. apply/andP; split; apply/subsetP=> x. by case/imsetP => x0 /[1!inE] /forallP/(_ i)/= ? ->. move=> Hx1; apply/imsetP; exists (dfung1 x); last by rewrite dfung1_id. by rewrite in_setXn; apply/forallP => j /[!ffunE]; case: dfwithP. Qed. Lemma set1gXn_group_set {i} (H : {group gT i}) : group_set (set1gXn H). Proof. by rewrite set1gXnE; exact: group_setXn. Qed. Canonical groupXn1 {i} (H : {group gT i}) := Group (set1gXn_group_set H). Lemma setXn_prod H : \prod_i set1gXn (H i) = setXn H. Proof. apply/setP => /= x; apply/prodsgP /setXnP => [[/= f fH {x}-> i]|xH /=]. rewrite prodg_ffun group_prod// => j _. by have /set1gXnP[x xH ->] := fH j isT; rewrite ffunE; case: dfwithP. exists (fun i => dfung1 (x i)) => [i _|]; first by apply/set1gXnP; exists (x i). apply/ffunP => i; rewrite prodg_ffun (big_only1 i) ?dfung1_id//. by move=> j ij _; rewrite dfung1_dflt. Qed. Lemma set1gXn_commute (H : forall i, {group gT i}) i j : commute (set1gXn (H i)) (set1gXn (H j)). Proof. have [-> //|neqij] := eqVneq j i. apply/centC/centsP => _ /set1gXnP [hi hiH ->] _ /set1gXnP [hj hjH ->]. apply/ffunP => k; rewrite !ffunE. by case: dfwithP => [|?]; rewrite ?mulg1 ?mul1g// dfwith_out// mulg1 mul1g. Qed. Lemma setXn_dprod H : \big[dprod/1]_i set1gXn (H i) = setXn H. Proof. rewrite -setXn_prod//=. suff -> : \big[dprod/1]_i groupXn1 (H i) = (\prod_i groupXn1 (H i))%G. by rewrite comm_prodG//=; apply: in2W; apply: set1gXn_commute. apply/eqP; apply/bigdprodYP => i //= _; rewrite subsetD. apply/andP; split. rewrite comm_prodG; last by apply: in2W; apply: set1gXn_commute. apply/centsP => _ /prodsgP[/= h_ h_P ->] _ /set1gXnP [h hH ->]. apply/ffunP => j; rewrite !ffunE/=. rewrite (big_morph _ (@dffunM j) (_ : _ = 1)) ?ffunE//. case: dfwithP => {j} [|? ?]; last by rewrite mulg1 mul1g. rewrite big1 ?mulg1 ?mul1g// => j neq_ji. by have /set1gXnP[? _ ->] := h_P j neq_ji; rewrite ffunE dfwith_out. rewrite -setI_eq0 -subset0; apply/subsetP => /= x; rewrite !inE. rewrite comm_prodG; last by apply: in2W; apply: set1gXn_commute. move=> /and3P[+ + /set1gXnP [h _ x_h]]; rewrite {x}x_h. move=> /prodsgP[x_ x_P /ffunP/(_ i)]; rewrite ffunE dfwith_in => {h}->. apply: contra_neqT => _; apply/ffunP => j; rewrite !ffunE/=. case: dfwithP => // {j}; rewrite (big_morph _ (@dffunM i) (_ : _ = 1)) ?ffunE//. rewrite big1// => j neq_ji. by have /set1gXnP[g gH /ffunP->] := x_P _ neq_ji; rewrite ffunE dfwith_out. Qed. Lemma isog_setXn i (G : {group gT i}) : G \isog set1gXn G. Proof. apply/(@isogP _ _ G); exists [morphism of restrm (subsetT G) (@dfung1 i)]. by rewrite injm_restrm ?injm_dfung1. by rewrite morphim_restrm morphim_dfung1 setIid. Qed. Lemma setXn_gen H : (forall i, 1 \in H i) -> <<setXn H>> = setXn (fun i => <<H i>>). Proof. move=> H1; apply/eqP; rewrite eqEsubset gen_subG setXnS/=; last first. by move=> ?; rewrite subset_gen. rewrite -[in X in X \subset _]setXn_prod; under eq_bigr do rewrite -morphim_dfung1 morphim_gen ?subsetT// morphim_dfung1. rewrite prod_subG// => i; rewrite genS // set1gXnE setXnS // => j. by case: dfwithP => // k _; rewrite sub1set. Qed. End ExternalDirDepProd. Lemma groupX0 (gT : 'I_0 -> finGroupType) (G : forall i, {group gT i}) : setXn G = 1%g. Proof. by apply/setP => ?; apply/setXnP/set1P => [_|_ []//]; apply/ffunP => -[]. Qed. Section ExternalSDirProd. Variables (aT rT : finGroupType) (D : {group aT}) (R : {group rT}). (* The pair (a, x) denotes the product sdpair2 a * sdpair1 x *) Inductive sdprod_by (to : groupAction D R) : predArgType := SdPair (ax : aT * rT) of ax \in setX D R. Coercion pair_of_sd to (u : sdprod_by to) := let: SdPair ax _ := u in ax. Variable to : groupAction D R. Notation sdT := (sdprod_by to). Notation sdval := (@pair_of_sd to). HB.instance Definition _ := [isSub for sdval]. #[hnf] HB.instance Definition _ := [Finite of sdT by <:]. Definition sdprod_one := SdPair to (group1 _). Lemma sdprod_inv_proof (u : sdT) : (u.1^-1, to u.2^-1 u.1^-1) \in setX D R. Proof. by case: u => [[a x]] /= /setXP[Da Rx]; rewrite inE gact_stable !groupV ?Da. Qed. Definition sdprod_inv u := SdPair to (sdprod_inv_proof u). Lemma sdprod_mul_proof (u v : sdT) : (u.1 * v.1, to u.2 v.1 * v.2) \in setX D R. Proof. case: u v => [[a x] /= /setXP[Da Rx]] [[b y] /= /setXP[Db Ry]]. by rewrite inE !groupM //= gact_stable. Qed. Definition sdprod_mul u v := SdPair to (sdprod_mul_proof u v). Lemma sdprod_mul1g : left_id sdprod_one sdprod_mul. Proof. move=> u; apply: val_inj; case: u => [[a x] /=]; case/setXP=> Da _. by rewrite gact1 // !mul1g. Qed. Lemma sdprod_mulVg : left_inverse sdprod_one sdprod_inv sdprod_mul. Proof. move=> u; apply: val_inj; case: u => [[a x] /=]; case/setXP=> Da _. by rewrite actKVin ?mulVg. Qed. Lemma sdprod_mulgA : associative sdprod_mul. Proof. move=> u v w; apply: val_inj; case: u => [[a x]] /=; case/setXP=> Da Rx. case: v w => [[b y]] /=; case/setXP=> Db Ry [[c z]] /=; case/setXP=> Dc Rz. by rewrite !(actMin to) // gactM ?gact_stable // !mulgA. Qed. HB.instance Definition _ := isMulGroup.Build sdT sdprod_mulgA sdprod_mul1g sdprod_mulVg. Definition sdprod_groupType : finGroupType := sdT. Definition sdpair1 x := insubd sdprod_one (1, x) : sdT. Definition sdpair2 a := insubd sdprod_one (a, 1) : sdT. Lemma sdpair1_morphM : {in R &, {morph sdpair1 : x y / x * y}}. Proof. move=> x y Rx Ry; apply: val_inj. by rewrite /= !val_insubd !inE !group1 !groupM ?Rx ?Ry //= mulg1 act1. Qed. Lemma sdpair2_morphM : {in D &, {morph sdpair2 : a b / a * b}}. Proof. move=> a b Da Db; apply: val_inj. by rewrite /= !val_insubd !inE !group1 !groupM ?Da ?Db //= mulg1 gact1. Qed. Canonical sdpair1_morphism := Morphism sdpair1_morphM. Canonical sdpair2_morphism := Morphism sdpair2_morphM. Lemma injm_sdpair1 : 'injm sdpair1. Proof. apply/subsetP=> x /setIP[Rx]. by rewrite !inE -val_eqE val_insubd inE Rx group1 /=; case/andP. Qed. Lemma injm_sdpair2 : 'injm sdpair2. Proof. apply/subsetP=> a /setIP[Da]. by rewrite !inE -val_eqE val_insubd inE Da group1 /=; case/andP. Qed. Lemma sdpairE (u : sdT) : u = sdpair2 u.1 * sdpair1 u.2. Proof. apply: val_inj; case: u => [[a x] /= /setXP[Da Rx]]. by rewrite !val_insubd !inE Da Rx !(group1, gact1) // mulg1 mul1g. Qed. Lemma sdpair_act : {in R & D, forall x a, sdpair1 (to x a) = sdpair1 x ^ sdpair2 a}. Proof. move=> x a Rx Da; apply: val_inj. rewrite /= !val_insubd !inE !group1 gact_stable ?Da ?Rx //=. by rewrite !mul1g mulVg invg1 mulg1 actKVin ?mul1g. Qed. Lemma sdpair_setact (G : {set rT}) a : G \subset R -> a \in D -> sdpair1 @* (to^~ a @: G) = (sdpair1 @* G) :^ sdpair2 a. Proof. move=> sGR Da; have GtoR := subsetP sGR; apply/eqP. rewrite eqEcard cardJg !(card_injm injm_sdpair1) //; last first. by apply/subsetP=> _ /imsetP[x Gx ->]; rewrite gact_stable ?GtoR. rewrite (card_imset _ (act_inj _ _)) leqnn andbT. apply/subsetP=> _ /morphimP[xa Rxa /imsetP[x Gx def_xa ->]]. rewrite mem_conjg -morphV // -sdpair_act ?groupV // def_xa actKin //. by rewrite mem_morphim ?GtoR. Qed. Lemma im_sdpair_norm : sdpair2 @* D \subset 'N(sdpair1 @* R). Proof. apply/subsetP=> _ /morphimP[a _ Da ->]. rewrite inE -sdpair_setact // morphimS //. by apply/subsetP=> _ /imsetP[x Rx ->]; rewrite gact_stable. Qed. Lemma im_sdpair_TI : (sdpair1 @* R) :&: (sdpair2 @* D) = 1. Proof. apply/trivgP; apply/subsetP=> _ /setIP[/morphimP[x _ Rx ->]]. case/morphimP=> a _ Da /eqP; rewrite inE -!val_eqE. by rewrite !val_insubd !inE Da Rx !group1 /eq_op /= eqxx; case/andP. Qed. Lemma im_sdpair : (sdpair1 @* R) * (sdpair2 @* D) = setT. Proof. apply/eqP; rewrite -subTset -(normC im_sdpair_norm). apply/subsetP=> /= u _; rewrite [u]sdpairE. by case: u => [[a x] /= /setXP[Da Rx]]; rewrite mem_mulg ?mem_morphim. Qed. Lemma sdprod_sdpair : sdpair1 @* R ><| sdpair2 @* D = setT. Proof. by rewrite sdprodE ?(im_sdpair_norm, im_sdpair, im_sdpair_TI). Qed. Variables (A : {set aT}) (G : {set rT}). Lemma gacentEsd : 'C_(|to)(A) = sdpair1 @*^-1 'C(sdpair2 @* A). Proof. apply/setP=> x; apply/idP/idP. case/setIP=> Rx /afixP cDAx; rewrite mem_morphpre //. apply/centP=> _ /morphimP[a Da Aa ->]; red. by rewrite conjgC -sdpair_act // cDAx // inE Da. case/morphpreP=> Rx cAx; rewrite inE Rx; apply/afixP=> a /setIP[Da Aa]. apply: (injmP injm_sdpair1); rewrite ?gact_stable /= ?sdpair_act //=. by rewrite /conjg (centP cAx) ?mulKg ?mem_morphim. Qed. Hypotheses (sAD : A \subset D) (sGR : G \subset R). Lemma astabEsd : 'C(G | to) = sdpair2 @*^-1 'C(sdpair1 @* G). Proof. have ssGR := subsetP sGR; apply/setP=> a; apply/idP/idP=> [cGa|]. rewrite mem_morphpre ?(astab_dom cGa) //. apply/centP=> _ /morphimP[x Rx Gx ->]; symmetry. by rewrite conjgC -sdpair_act ?(astab_act cGa) ?(astab_dom cGa). case/morphpreP=> Da cGa; rewrite !inE Da; apply/subsetP=> x Gx; rewrite inE. apply/eqP; apply: (injmP injm_sdpair1); rewrite ?gact_stable ?ssGR //=. by rewrite sdpair_act ?ssGR // /conjg -(centP cGa) ?mulKg ?mem_morphim ?ssGR. Qed. Lemma astabsEsd : 'N(G | to) = sdpair2 @*^-1 'N(sdpair1 @* G). Proof. apply/setP=> a; apply/idP/idP=> [nGa|]. have Da := astabs_dom nGa; rewrite mem_morphpre // inE sub_conjg. apply/subsetP=> _ /morphimP[x Rx Gx ->]. by rewrite mem_conjgV -sdpair_act // mem_morphim ?gact_stable ?astabs_act. case/morphpreP=> Da nGa; rewrite !inE Da; apply/subsetP=> x Gx. have Rx := subsetP sGR _ Gx; have Rxa: to x a \in R by rewrite gact_stable. rewrite inE -sub1set -(injmSK injm_sdpair1) ?morphim_set1 ?sub1set //=. by rewrite sdpair_act ?memJ_norm ?mem_morphim. Qed. Lemma actsEsd : [acts A, on G | to] = (sdpair2 @* A \subset 'N(sdpair1 @* G)). Proof. by rewrite sub_morphim_pre -?astabsEsd. Qed. End ExternalSDirProd. Section ProdMorph. Variables gT rT : finGroupType. Implicit Types A B : {set gT}. Implicit Types G H K : {group gT}. Implicit Types C D : {set rT}. Implicit Type L : {group rT}. Section defs. Variables (A B : {set gT}) (fA fB : gT -> FinGroup.sort rT). Definition pprodm of B \subset 'N(A) & {in A & B, morph_act 'J 'J fA fB} & {in A :&: B, fA =1 fB} := fun x => fA (divgr A B x) * fB (remgr A B x). End defs. Section Props. Variables H K : {group gT}. Variables (fH : {morphism H >-> rT}) (fK : {morphism K >-> rT}). Hypothesis nHK : K \subset 'N(H). Hypothesis actf : {in H & K, morph_act 'J 'J fH fK}. Hypothesis eqfHK : {in H :&: K, fH =1 fK}. Local Notation f := (pprodm nHK actf eqfHK). Lemma pprodmE x a : x \in H -> a \in K -> f (x * a) = fH x * fK a. Proof. move=> Hx Ka; have: x * a \in H * K by rewrite mem_mulg. rewrite -remgrP inE /f rcoset_sym mem_rcoset /divgr -mulgA groupMl //. case/andP; move: (remgr H K _) => b Hab Kb; rewrite morphM // -mulgA. have Kab: a * b^-1 \in K by rewrite groupM ?groupV. by congr (_ * _); rewrite eqfHK 1?inE ?Hab // -morphM // mulgKV. Qed. Lemma pprodmEl : {in H, f =1 fH}. Proof. by move=> x Hx; rewrite -(mulg1 x) pprodmE // morph1 !mulg1. Qed. Lemma pprodmEr : {in K, f =1 fK}. Proof. by move=> a Ka; rewrite -(mul1g a) pprodmE // morph1 !mul1g. Qed. Lemma pprodmM : {in H <*> K &, {morph f: x y / x * y}}. Proof. move=> xa yb; rewrite norm_joinEr //. move=> /imset2P[x a Ha Ka ->{xa}] /imset2P[y b Hy Kb ->{yb}]. have Hya: y ^ a^-1 \in H by rewrite -mem_conjg (normsP nHK). rewrite mulgA -(mulgA x) (conjgCV a y) (mulgA x) -mulgA !pprodmE 1?groupMl //. by rewrite morphM // actf ?groupV ?morphV // morphM // !mulgA mulgKV invgK. Qed. Canonical pprodm_morphism := Morphism pprodmM. Lemma morphim_pprodm A B : A \subset H -> B \subset K -> f @* (A * B) = fH @* A * fK @* B. Proof. move=> sAH sBK; rewrite [f @* _]morphimEsub /=; last first. by rewrite norm_joinEr // mulgSS. apply/setP=> y; apply/imsetP/idP=> [[_ /mulsgP[x a Ax Ba ->] ->{y}] |]. have Hx := subsetP sAH x Ax; have Ka := subsetP sBK a Ba. by rewrite pprodmE // imset2_f ?mem_morphim. case/mulsgP=> _ _ /morphimP[x Hx Ax ->] /morphimP[a Ka Ba ->] ->{y}. by exists (x * a); rewrite ?mem_mulg ?pprodmE. Qed. Lemma morphim_pprodml A : A \subset H -> f @* A = fH @* A. Proof. by move=> sAH; rewrite -{1}(mulg1 A) morphim_pprodm ?sub1G // morphim1 mulg1. Qed. Lemma morphim_pprodmr B : B \subset K -> f @* B = fK @* B. Proof. by move=> sBK; rewrite -{1}(mul1g B) morphim_pprodm ?sub1G // morphim1 mul1g. Qed. Lemma ker_pprodm : 'ker f = [set x * a^-1 | x in H, a in K & fH x == fK a]. Proof. apply/setP=> y; rewrite 3!inE {1}norm_joinEr //=. apply/andP/imset2P=> [[/mulsgP[x a Hx Ka ->{y}]]|[x a Hx]]. rewrite pprodmE // => fxa1. by exists x a^-1; rewrite ?invgK // inE groupVr ?morphV // eq_mulgV1 invgK. case/setIdP=> Kx /eqP fx ->{y}. by rewrite imset2_f ?pprodmE ?groupV ?morphV // fx mulgV. Qed. Lemma injm_pprodm : 'injm f = [&& 'injm fH, 'injm fK & fH @* H :&: fK @* K == fH @* K]. Proof. apply/idP/and3P=> [injf | [injfH injfK]]. rewrite eq_sym -{1}morphimIdom -(morphim_pprodml (subsetIl _ _)) injmI //. rewrite morphim_pprodml // morphim_pprodmr //=; split=> //. apply/injmP=> x y Hx Hy /=; rewrite -!pprodmEl //. by apply: (injmP injf); rewrite ?mem_gen ?inE ?Hx ?Hy. apply/injmP=> a b Ka Kb /=; rewrite -!pprodmEr //. by apply: (injmP injf); rewrite ?mem_gen //; apply/setUP; right. move/eqP=> fHK; rewrite ker_pprodm; apply/subsetP=> y. case/imset2P=> x a Hx /setIdP[Ka /eqP fxa] ->. have: fH x \in fH @* K by rewrite -fHK inE {2}fxa !mem_morphim. case/morphimP=> z Hz Kz /(injmP injfH) def_x. rewrite def_x // eqfHK ?inE ?Hz // in fxa. by rewrite def_x // (injmP injfK _ _ Kz Ka fxa) mulgV set11. Qed. End Props. Section Sdprodm. Variables H K G : {group gT}. Variables (fH : {morphism H >-> rT}) (fK : {morphism K >-> rT}). Hypothesis eqHK_G : H ><| K = G. Hypothesis actf : {in H & K, morph_act 'J 'J fH fK}. Lemma sdprodm_norm : K \subset 'N(H). Proof. by case/sdprodP: eqHK_G. Qed. Lemma sdprodm_sub : G \subset H <*> K. Proof. by case/sdprodP: eqHK_G => _ <- nHK _; rewrite norm_joinEr. Qed. Lemma sdprodm_eqf : {in H :&: K, fH =1 fK}. Proof. by case/sdprodP: eqHK_G => _ _ _ -> _ /set1P->; rewrite !morph1. Qed. Definition sdprodm := restrm sdprodm_sub (pprodm sdprodm_norm actf sdprodm_eqf). Canonical sdprodm_morphism := Eval hnf in [morphism of sdprodm]. Lemma sdprodmE a b : a \in H -> b \in K -> sdprodm (a * b) = fH a * fK b. Proof. exact: pprodmE. Qed. Lemma sdprodmEl a : a \in H -> sdprodm a = fH a. Proof. exact: pprodmEl. Qed. Lemma sdprodmEr b : b \in K -> sdprodm b = fK b. Proof. exact: pprodmEr. Qed. Lemma morphim_sdprodm A B : A \subset H -> B \subset K -> sdprodm @* (A * B) = fH @* A * fK @* B. Proof. move=> sAH sBK; rewrite /sdprodm morphim_restrm /= (setIidPr _) ?morphim_pprodm //. by case/sdprodP: eqHK_G => _ <- _ _; apply: mulgSS. Qed. Lemma im_sdprodm : sdprodm @* G = fH @* H * fK @* K. Proof. by rewrite -morphim_sdprodm //; case/sdprodP: eqHK_G => _ ->. Qed. Lemma morphim_sdprodml A : A \subset H -> sdprodm @* A = fH @* A. Proof. by move=> sHA; rewrite -{1}(mulg1 A) morphim_sdprodm ?sub1G // morphim1 mulg1. Qed. Lemma morphim_sdprodmr B : B \subset K -> sdprodm @* B = fK @* B. Proof. by move=> sBK; rewrite -{1}(mul1g B) morphim_sdprodm ?sub1G // morphim1 mul1g. Qed. Lemma ker_sdprodm : 'ker sdprodm = [set a * b^-1 | a in H, b in K & fH a == fK b]. Proof. rewrite ker_restrm (setIidPr _) ?subIset ?ker_pprodm //; apply/orP; left. by case/sdprodP: eqHK_G => _ <- nHK _; rewrite norm_joinEr. Qed. Lemma injm_sdprodm : 'injm sdprodm = [&& 'injm fH, 'injm fK & fH @* H :&: fK @* K == 1]. Proof. rewrite ker_sdprodm -(ker_pprodm sdprodm_norm actf sdprodm_eqf) injm_pprodm. congr [&& _, _ & _ == _]; have [_ _ _ tiHK] := sdprodP eqHK_G. by rewrite -morphimIdom tiHK morphim1. Qed. End Sdprodm. Section Cprodm. Variables H K G : {group gT}. Variables (fH : {morphism H >-> rT}) (fK : {morphism K >-> rT}). Hypothesis eqHK_G : H \* K = G. Hypothesis cfHK : fK @* K \subset 'C(fH @* H). Hypothesis eqfHK : {in H :&: K, fH =1 fK}. Lemma cprodm_norm : K \subset 'N(H). Proof. by rewrite cents_norm //; case/cprodP: eqHK_G. Qed. Lemma cprodm_sub : G \subset H <*> K. Proof. by case/cprodP: eqHK_G => _ <- cHK; rewrite cent_joinEr. Qed. Lemma cprodm_actf : {in H & K, morph_act 'J 'J fH fK}. Proof. case/cprodP: eqHK_G => _ _ cHK a b Ha Kb /=. by rewrite /conjg -(centsP cHK b) // -(centsP cfHK (fK b)) ?mulKg ?mem_morphim. Qed. Definition cprodm := restrm cprodm_sub (pprodm cprodm_norm cprodm_actf eqfHK). Canonical cprodm_morphism := Eval hnf in [morphism of cprodm]. Lemma cprodmE a b : a \in H -> b \in K -> cprodm (a * b) = fH a * fK b. Proof. exact: pprodmE. Qed. Lemma cprodmEl a : a \in H -> cprodm a = fH a. Proof. exact: pprodmEl. Qed. Lemma cprodmEr b : b \in K -> cprodm b = fK b. Proof. exact: pprodmEr. Qed. Lemma morphim_cprodm A B : A \subset H -> B \subset K -> cprodm @* (A * B) = fH @* A * fK @* B. Proof. move=> sAH sBK; rewrite [LHS]morphim_restrm /= (setIidPr _) ?morphim_pprodm //. by case/cprodP: eqHK_G => _ <- _; apply: mulgSS. Qed. Lemma im_cprodm : cprodm @* G = fH @* H * fK @* K. Proof. by have [_ defHK _] := cprodP eqHK_G; rewrite -{2}defHK morphim_cprodm. Qed. Lemma morphim_cprodml A : A \subset H -> cprodm @* A = fH @* A. Proof. by move=> sHA; rewrite -{1}(mulg1 A) morphim_cprodm ?sub1G // morphim1 mulg1. Qed. Lemma morphim_cprodmr B : B \subset K -> cprodm @* B = fK @* B. Proof. by move=> sBK; rewrite -{1}(mul1g B) morphim_cprodm ?sub1G // morphim1 mul1g. Qed. Lemma ker_cprodm : 'ker cprodm = [set a * b^-1 | a in H, b in K & fH a == fK b]. Proof. rewrite ker_restrm (setIidPr _) ?subIset ?ker_pprodm //; apply/orP; left. by case/cprodP: eqHK_G => _ <- cHK; rewrite cent_joinEr. Qed. Lemma injm_cprodm : 'injm cprodm = [&& 'injm fH, 'injm fK & fH @* H :&: fK @* K == fH @* K]. Proof. by rewrite ker_cprodm -(ker_pprodm cprodm_norm cprodm_actf eqfHK) injm_pprodm. Qed. End Cprodm. Section Dprodm. Variables G H K : {group gT}. Variables (fH : {morphism H >-> rT}) (fK : {morphism K >-> rT}). Hypothesis eqHK_G : H \x K = G. Hypothesis cfHK : fK @* K \subset 'C(fH @* H). Lemma dprodm_cprod : H \* K = G. Proof. by rewrite -eqHK_G /dprod; case/dprodP: eqHK_G => _ _ _ ->; rewrite subxx. Qed. Lemma dprodm_eqf : {in H :&: K, fH =1 fK}. Proof. by case/dprodP: eqHK_G => _ _ _ -> _ /set1P->; rewrite !morph1. Qed. Definition dprodm := cprodm dprodm_cprod cfHK dprodm_eqf. Canonical dprodm_morphism := Eval hnf in [morphism of dprodm]. Lemma dprodmE a b : a \in H -> b \in K -> dprodm (a * b) = fH a * fK b. Proof. exact: pprodmE. Qed. Lemma dprodmEl a : a \in H -> dprodm a = fH a. Proof. exact: pprodmEl. Qed. Lemma dprodmEr b : b \in K -> dprodm b = fK b. Proof. exact: pprodmEr. Qed. Lemma morphim_dprodm A B : A \subset H -> B \subset K -> dprodm @* (A * B) = fH @* A * fK @* B. Proof. exact: morphim_cprodm. Qed. Lemma im_dprodm : dprodm @* G = fH @* H * fK @* K. Proof. exact: im_cprodm. Qed. Lemma morphim_dprodml A : A \subset H -> dprodm @* A = fH @* A. Proof. exact: morphim_cprodml. Qed. Lemma morphim_dprodmr B : B \subset K -> dprodm @* B = fK @* B. Proof. exact: morphim_cprodmr. Qed. Lemma ker_dprodm : 'ker dprodm = [set a * b^-1 | a in H, b in K & fH a == fK b]. Proof. exact: ker_cprodm. Qed. Lemma injm_dprodm : 'injm dprodm = [&& 'injm fH, 'injm fK & fH @* H :&: fK @* K == 1]. Proof. rewrite injm_cprodm -(morphimIdom fH K). by case/dprodP: eqHK_G => _ _ _ ->; rewrite morphim1. Qed. End Dprodm. Lemma isog_dprod A B G C D L : A \x B = G -> C \x D = L -> isog A C -> isog B D -> isog G L. Proof. move=> defG {C D} /dprodP[[C D -> ->] defL cCD trCD]. case/dprodP: defG (defG) => {A B} [[A B -> ->] defG _ _] dG defC defD. case/isogP: defC defL cCD trCD => fA injfA <-{C}. case/isogP: defD => fB injfB <-{D} defL cCD trCD. apply/isogP; exists (dprodm_morphism dG cCD). by rewrite injm_dprodm injfA injfB trCD eqxx. by rewrite /= -{2}defG morphim_dprodm. Qed. End ProdMorph. Section ExtSdprodm. Variables gT aT rT : finGroupType. Variables (H : {group gT}) (K : {group aT}) (to : groupAction K H). Variables (fH : {morphism H >-> rT}) (fK : {morphism K >-> rT}). Hypothesis actf : {in H & K, morph_act to 'J fH fK}. Local Notation fsH := (fH \o invm (injm_sdpair1 to)). Local Notation fsK := (fK \o invm (injm_sdpair2 to)). Let DgH := sdpair1 to @* H. Let DgK := sdpair2 to @* K. Lemma xsdprodm_dom1 : DgH \subset 'dom fsH. Proof. by rewrite ['dom _]morphpre_invm. Qed. Local Notation gH := (restrm xsdprodm_dom1 fsH). Lemma xsdprodm_dom2 : DgK \subset 'dom fsK. Proof. by rewrite ['dom _]morphpre_invm. Qed. Local Notation gK := (restrm xsdprodm_dom2 fsK). Lemma im_sdprodm1 : gH @* DgH = fH @* H. Proof. by rewrite morphim_restrm setIid morphim_comp im_invm. Qed. Lemma im_sdprodm2 : gK @* DgK = fK @* K. Proof. by rewrite morphim_restrm setIid morphim_comp im_invm. Qed. Lemma xsdprodm_act : {in DgH & DgK, morph_act 'J 'J gH gK}. Proof. move=> fh fk; case/morphimP=> h _ Hh ->{fh}; case/morphimP=> k _ Kk ->{fk}. by rewrite /= -sdpair_act // /restrm /= !invmE ?actf ?gact_stable. Qed. Definition xsdprodm := sdprodm (sdprod_sdpair to) xsdprodm_act. Canonical xsdprod_morphism := [morphism of xsdprodm]. Lemma im_xsdprodm : xsdprodm @* setT = fH @* H * fK @* K. Proof. by rewrite -im_sdpair morphim_sdprodm // im_sdprodm1 im_sdprodm2. Qed. Lemma injm_xsdprodm : 'injm xsdprodm = [&& 'injm fH, 'injm fK & fH @* H :&: fK @* K == 1]. Proof. rewrite injm_sdprodm im_sdprodm1 im_sdprodm2 !subG1 /=. rewrite (ker_restrm xsdprodm_dom1) (ker_restrm xsdprodm_dom2) /= !ker_comp. rewrite !morphpre_invm !morphimIim. by rewrite !morphim_injm_eq1 ?subsetIl ?injm_sdpair1 ?injm_sdpair2. Qed. End ExtSdprodm. Section DirprodIsom. Variable gT : finGroupType. Implicit Types G H : {group gT}. Definition mulgm : gT * gT -> _ := uncurry mulg. Lemma imset_mulgm (A B : {set gT}) : mulgm @: setX A B = A * B. Proof. by rewrite -curry_imset2X. Qed. Lemma mulgmP H1 H2 G : reflect (H1 \x H2 = G) (misom (setX H1 H2) G mulgm). Proof. apply: (iffP misomP) => [[pM /isomP[injf /= <-]] | ]. have /dprodP[_ /= defX cH12] := setX_dprod H1 H2. rewrite -{4}defX {}defX => /(congr1 (fun A => morphm pM @* A)). move/(morphimS (morphm_morphism pM)): cH12 => /=. have sH1H: setX H1 1 \subset setX H1 H2 by rewrite setXS ?sub1G. have sH2H: setX 1 H2 \subset setX H1 H2 by rewrite setXS ?sub1G. rewrite morphim1 injm_cent ?injmI //= subsetI => /andP[_]. by rewrite !morphimEsub //= !imset_mulgm mulg1 mul1g; apply: dprodE. case/dprodP=> _ defG cH12 trH12. have fM: morphic (setX H1 H2) mulgm. apply/morphicP=> [[x1 x2] [y1 y2] /setXP[_ Hx2] /setXP[Hy1 _]]. by rewrite /= mulgA -(mulgA x1) -(centsP cH12 x2) ?mulgA. exists fM; apply/isomP; split; last by rewrite morphimEsub //= imset_mulgm. apply/subsetP=> [[x1 x2]]; rewrite !inE /= andbC -eq_invg_mul. case: eqP => //= <-; rewrite groupV -in_setI trH12 => /set1P->. by rewrite invg1 eqxx. Qed. End DirprodIsom. Arguments mulgmP {gT H1 H2 G}. Prenex Implicits mulgm.
Norm.lean
/- Copyright (c) 2018 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro, Johannes Hölzl -/ import Mathlib.Analysis.Normed.Group.Basic import Mathlib.MeasureTheory.Integral.Lebesgue.Basic /-! # Interactions between the Lebesgue integral and norms -/ namespace MeasureTheory variable {α : Type*} [MeasurableSpace α] {μ : Measure α} theorem lintegral_ofReal_le_lintegral_enorm (f : α → ℝ) : ∫⁻ x, ENNReal.ofReal (f x) ∂μ ≤ ∫⁻ x, ‖f x‖ₑ ∂μ := by simp_rw [← ofReal_norm_eq_enorm] refine lintegral_mono fun x => ENNReal.ofReal_le_ofReal ?_ rw [Real.norm_eq_abs] exact le_abs_self (f x) theorem lintegral_enorm_of_ae_nonneg {f : α → ℝ} (h_nonneg : 0 ≤ᵐ[μ] f) : ∫⁻ x, ‖f x‖ₑ ∂μ = ∫⁻ x, .ofReal (f x) ∂μ := by apply lintegral_congr_ae filter_upwards [h_nonneg] with x hx rw [Real.enorm_eq_ofReal hx] theorem lintegral_enorm_of_nonneg {f : α → ℝ} (h_nonneg : 0 ≤ f) : ∫⁻ x, ‖f x‖ₑ ∂μ = ∫⁻ x, .ofReal (f x) ∂μ := lintegral_enorm_of_ae_nonneg <| .of_forall h_nonneg end MeasureTheory
Operations.lean
/- Copyright (c) 2019 Kenny Lau. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kenny Lau -/ import Mathlib.Algebra.Algebra.Bilinear import Mathlib.Algebra.Algebra.Opposite import Mathlib.Algebra.Group.Pointwise.Finset.Basic import Mathlib.Algebra.Group.Pointwise.Set.BigOperators import Mathlib.Algebra.Module.Submodule.Pointwise import Mathlib.Algebra.Ring.NonZeroDivisors import Mathlib.Algebra.Ring.Submonoid.Pointwise import Mathlib.Data.Set.Semiring import Mathlib.GroupTheory.GroupAction.SubMulAction.Pointwise /-! # Multiplication and division of submodules of an algebra. An interface for multiplication and division of sub-R-modules of an R-algebra A is developed. ## Main definitions Let `R` be a commutative ring (or semiring) and let `A` be an `R`-algebra. * `1 : Submodule R A` : the R-submodule R of the R-algebra A * `Mul (Submodule R A)` : multiplication of two sub-R-modules M and N of A is defined to be the smallest submodule containing all the products `m * n`. * `Div (Submodule R A)` : `I / J` is defined to be the submodule consisting of all `a : A` such that `a • J ⊆ I` It is proved that `Submodule R A` is a semiring, and also an algebra over `Set A`. Additionally, in the `Pointwise` locale we promote `Submodule.pointwiseDistribMulAction` to a `MulSemiringAction` as `Submodule.pointwiseMulSemiringAction`. When `R` is not necessarily commutative, and `A` is merely a `R`-module with a ring structure such that `IsScalarTower R A A` holds (equivalent to the data of a ring homomorphism `R →+* A` by `ringHomEquivModuleIsScalarTower`), we can still define `1 : Submodule R A` and `Mul (Submodule R A)`, but `1` is only a left identity, not necessarily a right one. ## Tags multiplication of submodules, division of submodules, submodule semiring -/ universe uι u v open Algebra Set MulOpposite open Pointwise namespace SubMulAction variable {R : Type u} {A : Type v} [CommSemiring R] [Semiring A] [Algebra R A] theorem algebraMap_mem (r : R) : algebraMap R A r ∈ (1 : SubMulAction R A) := ⟨r, (algebraMap_eq_smul_one r).symm⟩ theorem mem_one' {x : A} : x ∈ (1 : SubMulAction R A) ↔ ∃ y, algebraMap R A y = x := exists_congr fun r => by rw [algebraMap_eq_smul_one] end SubMulAction namespace Submodule section Module variable {R : Type u} [Semiring R] {A : Type v} [Semiring A] [Module R A] -- TODO: Why is this in a file about `Algebra`? -- TODO: potentially change this back to `LinearMap.range (Algebra.linearMap R A)` -- once a version of `Algebra` without the `commutes'` field is introduced. -- See issue https://github.com/leanprover-community/mathlib4/issues/18110. /-- `1 : Submodule R A` is the submodule `R ∙ 1` of `A`. -/ instance one : One (Submodule R A) := ⟨LinearMap.range (LinearMap.toSpanSingleton R A 1)⟩ theorem one_eq_span : (1 : Submodule R A) = R ∙ 1 := (LinearMap.span_singleton_eq_range _ _ _).symm theorem le_one_toAddSubmonoid : 1 ≤ (1 : Submodule R A).toAddSubmonoid := by rintro x ⟨n, rfl⟩ exact ⟨n, show (n : R) • (1 : A) = n by rw [Nat.cast_smul_eq_nsmul, nsmul_one]⟩ @[simp] theorem toSubMulAction_one : (1 : Submodule R A).toSubMulAction = 1 := SetLike.ext fun _ ↦ by rw [one_eq_span, SubMulAction.mem_one]; exact mem_span_singleton theorem one_eq_span_one_set : (1 : Submodule R A) = span R 1 := one_eq_span @[simp] theorem one_le {P : Submodule R A} : (1 : Submodule R A) ≤ P ↔ (1 : A) ∈ P := by simp [one_eq_span] variable {M : Type*} [AddCommMonoid M] [Module R M] [Module A M] [IsScalarTower R A M] instance : SMul (Submodule R A) (Submodule R M) where smul A' M' := { __ := A'.toAddSubmonoid • M'.toAddSubmonoid smul_mem' := fun r m hm ↦ AddSubmonoid.smul_induction_on hm (fun a ha m hm ↦ by rw [← smul_assoc]; exact AddSubmonoid.smul_mem_smul (A'.smul_mem r ha) hm) fun m₁ m₂ h₁ h₂ ↦ by rw [smul_add]; exact (A'.1 • M'.1).add_mem h₁ h₂ } section variable {I J : Submodule R A} {N P : Submodule R M} theorem smul_toAddSubmonoid : (I • N).toAddSubmonoid = I.toAddSubmonoid • N.toAddSubmonoid := rfl theorem smul_mem_smul {r} {n} (hr : r ∈ I) (hn : n ∈ N) : r • n ∈ I • N := AddSubmonoid.smul_mem_smul hr hn theorem smul_le : I • N ≤ P ↔ ∀ r ∈ I, ∀ n ∈ N, r • n ∈ P := AddSubmonoid.smul_le @[simp, norm_cast] lemma coe_set_smul : (I : Set A) • N = I • N := set_smul_eq_of_le _ _ _ (fun _ _ hr hx ↦ smul_mem_smul hr hx) (smul_le.mpr fun _ hr _ hx ↦ mem_set_smul_of_mem_mem hr hx) @[elab_as_elim] theorem smul_induction_on {p : M → Prop} {x} (H : x ∈ I • N) (smul : ∀ r ∈ I, ∀ n ∈ N, p (r • n)) (add : ∀ x y, p x → p y → p (x + y)) : p x := AddSubmonoid.smul_induction_on H smul add /-- Dependent version of `Submodule.smul_induction_on`. -/ @[elab_as_elim] theorem smul_induction_on' {x : M} (hx : x ∈ I • N) {p : ∀ x, x ∈ I • N → Prop} (smul : ∀ (r : A) (hr : r ∈ I) (n : M) (hn : n ∈ N), p (r • n) (smul_mem_smul hr hn)) (add : ∀ x hx y hy, p x hx → p y hy → p (x + y) (add_mem ‹_› ‹_›)) : p x hx := by refine Exists.elim ?_ fun (h : x ∈ I • N) (H : p x h) ↦ H exact smul_induction_on hx (fun a ha x hx ↦ ⟨_, smul _ ha _ hx⟩) fun x y ⟨_, hx⟩ ⟨_, hy⟩ ↦ ⟨_, add _ _ _ _ hx hy⟩ theorem smul_mono (hij : I ≤ J) (hnp : N ≤ P) : I • N ≤ J • P := AddSubmonoid.smul_le_smul hij hnp theorem smul_mono_left (h : I ≤ J) : I • N ≤ J • N := smul_mono h le_rfl instance : CovariantClass (Submodule R A) (Submodule R M) HSMul.hSMul LE.le := ⟨fun _ _ => smul_mono le_rfl⟩ variable (I J N P) @[simp] theorem smul_bot : I • (⊥ : Submodule R M) = ⊥ := toAddSubmonoid_injective <| AddSubmonoid.addSubmonoid_smul_bot _ @[simp] theorem bot_smul : (⊥ : Submodule R A) • N = ⊥ := le_bot_iff.mp <| smul_le.mpr <| by rintro _ rfl _ _; rw [zero_smul]; exact zero_mem _ theorem smul_sup : I • (N ⊔ P) = I • N ⊔ I • P := toAddSubmonoid_injective <| by simp only [smul_toAddSubmonoid, sup_toAddSubmonoid, AddSubmonoid.addSubmonoid_smul_sup] theorem sup_smul : (I ⊔ J) • N = I • N ⊔ J • N := le_antisymm (smul_le.mpr fun mn hmn p hp ↦ by obtain ⟨m, hm, n, hn, rfl⟩ := mem_sup.mp hmn rw [add_smul]; exact add_mem_sup (smul_mem_smul hm hp) <| smul_mem_smul hn hp) (sup_le (smul_mono_left le_sup_left) <| smul_mono_left le_sup_right) protected theorem smul_assoc {B} [Semiring B] [Module R B] [Module A B] [Module B M] [IsScalarTower R A B] [IsScalarTower R B M] [IsScalarTower A B M] (I : Submodule R A) (J : Submodule R B) (N : Submodule R M) : (I • J) • N = I • J • N := le_antisymm (smul_le.2 fun _ hrsij t htn ↦ smul_induction_on hrsij (fun r hr s hs ↦ smul_assoc r s t ▸ smul_mem_smul hr (smul_mem_smul hs htn)) fun x y ↦ (add_smul x y t).symm ▸ add_mem) (smul_le.2 fun r hr _ hsn ↦ smul_induction_on hsn (fun j hj n hn ↦ (smul_assoc r j n).symm ▸ smul_mem_smul (smul_mem_smul hr hj) hn) fun m₁ m₂ ↦ (smul_add r m₁ m₂) ▸ add_mem) theorem smul_iSup {ι : Sort*} {I : Submodule R A} {t : ι → Submodule R M} : I • (⨆ i, t i)= ⨆ i, I • t i := toAddSubmonoid_injective <| by simp only [smul_toAddSubmonoid, iSup_toAddSubmonoid, AddSubmonoid.smul_iSup] theorem iSup_smul {ι : Sort*} {t : ι → Submodule R A} {N : Submodule R M} : (⨆ i, t i) • N = ⨆ i, t i • N := le_antisymm (smul_le.mpr fun t ht s hs ↦ iSup_induction _ (motive := (· • s ∈ _)) ht (fun i t ht ↦ mem_iSup_of_mem i <| smul_mem_smul ht hs) (by simp_rw [zero_smul]; apply zero_mem) fun x y ↦ by simp_rw [add_smul]; apply add_mem) (iSup_le fun i ↦ Submodule.smul_mono_left <| le_iSup _ i) protected theorem one_smul : (1 : Submodule R A) • N = N := by refine le_antisymm (smul_le.mpr fun r hr m hm ↦ ?_) fun m hm ↦ ?_ · obtain ⟨r, rfl⟩ := hr rw [LinearMap.toSpanSingleton_apply, smul_one_smul]; exact N.smul_mem r hm · rw [← one_smul A m]; exact smul_mem_smul (one_le.mp le_rfl) hm theorem smul_subset_smul : (↑I : Set A) • (↑N : Set M) ⊆ (↑(I • N) : Set M) := AddSubmonoid.smul_subset_smul end variable [IsScalarTower R A A] /-- Multiplication of sub-R-modules of an R-module A that is also a semiring. The submodule `M * N` consists of finite sums of elements `m * n` for `m ∈ M` and `n ∈ N`. -/ instance mul : Mul (Submodule R A) where mul := (· • ·) variable (S T : Set A) {M N P Q : Submodule R A} {m n : A} theorem mul_mem_mul (hm : m ∈ M) (hn : n ∈ N) : m * n ∈ M * N := smul_mem_smul hm hn theorem mul_le : M * N ≤ P ↔ ∀ m ∈ M, ∀ n ∈ N, m * n ∈ P := smul_le theorem mul_toAddSubmonoid (M N : Submodule R A) : (M * N).toAddSubmonoid = M.toAddSubmonoid * N.toAddSubmonoid := rfl @[elab_as_elim] protected theorem mul_induction_on {C : A → Prop} {r : A} (hr : r ∈ M * N) (hm : ∀ m ∈ M, ∀ n ∈ N, C (m * n)) (ha : ∀ x y, C x → C y → C (x + y)) : C r := smul_induction_on hr hm ha /-- A dependent version of `mul_induction_on`. -/ @[elab_as_elim] protected theorem mul_induction_on' {C : ∀ r, r ∈ M * N → Prop} (mem_mul_mem : ∀ m (hm : m ∈ M) n (hn : n ∈ N), C (m * n) (mul_mem_mul hm hn)) (add : ∀ x hx y hy, C x hx → C y hy → C (x + y) (add_mem hx hy)) {r : A} (hr : r ∈ M * N) : C r hr := smul_induction_on' hr mem_mul_mem add variable (M) @[simp] theorem mul_bot : M * ⊥ = ⊥ := smul_bot _ @[simp] theorem bot_mul : ⊥ * M = ⊥ := bot_smul _ protected theorem one_mul : (1 : Submodule R A) * M = M := Submodule.one_smul _ variable {M} @[mono] theorem mul_le_mul (hmp : M ≤ P) (hnq : N ≤ Q) : M * N ≤ P * Q := smul_mono hmp hnq theorem mul_le_mul_left (h : M ≤ N) : M * P ≤ N * P := smul_mono_left h theorem mul_le_mul_right (h : N ≤ P) : M * N ≤ M * P := smul_mono_right _ h theorem mul_comm_of_commute (h : ∀ m ∈ M, ∀ n ∈ N, Commute m n) : M * N = N * M := toAddSubmonoid_injective <| AddSubmonoid.mul_comm_of_commute h variable (M N P) theorem mul_sup : M * (N ⊔ P) = M * N ⊔ M * P := smul_sup _ _ _ theorem sup_mul : (M ⊔ N) * P = M * P ⊔ N * P := sup_smul _ _ _ theorem mul_subset_mul : (↑M : Set A) * (↑N : Set A) ⊆ (↑(M * N) : Set A) := smul_subset_smul _ _ lemma restrictScalars_mul {A B C} [Semiring A] [Semiring B] [Semiring C] [SMul A B] [Module A C] [Module B C] [IsScalarTower A C C] [IsScalarTower B C C] [IsScalarTower A B C] {I J : Submodule B C} : (I * J).restrictScalars A = I.restrictScalars A * J.restrictScalars A := rfl variable {ι : Sort uι} theorem iSup_mul (s : ι → Submodule R A) (t : Submodule R A) : (⨆ i, s i) * t = ⨆ i, s i * t := iSup_smul theorem mul_iSup (t : Submodule R A) (s : ι → Submodule R A) : (t * ⨆ i, s i) = ⨆ i, t * s i := smul_iSup /-- Sub-`R`-modules of an `R`-module form an idempotent semiring. -/ instance : NonUnitalSemiring (Submodule R A) where __ := toAddSubmonoid_injective.semigroup _ mul_toAddSubmonoid zero_mul := bot_mul mul_zero := mul_bot left_distrib := mul_sup right_distrib := sup_mul instance : Pow (Submodule R A) ℕ where pow s n := npowRec n s theorem pow_eq_npowRec {n : ℕ} : M ^ n = npowRec n M := rfl protected theorem pow_zero : M ^ 0 = 1 := rfl protected theorem pow_succ {n : ℕ} : M ^ (n + 1) = M ^ n * M := rfl protected theorem pow_add {m n : ℕ} (h : n ≠ 0) : M ^ (m + n) = M ^ m * M ^ n := npowRec_add m n h _ M.one_mul protected theorem pow_one : M ^ 1 = M := by rw [Submodule.pow_succ, Submodule.pow_zero, Submodule.one_mul] /-- `Submodule.pow_succ` with the right hand side commuted. -/ protected theorem pow_succ' {n : ℕ} (h : n ≠ 0) : M ^ (n + 1) = M * M ^ n := by rw [add_comm, M.pow_add h, Submodule.pow_one] @[simp] theorem bot_pow : ∀ {n : ℕ}, n ≠ 0 → (⊥ : Submodule R A) ^ n = ⊥ | 1, _ => Submodule.pow_one _ | n + 2, _ => by rw [Submodule.pow_succ, bot_pow n.succ_ne_zero, bot_mul] theorem pow_toAddSubmonoid {n : ℕ} (h : n ≠ 0) : (M ^ n).toAddSubmonoid = M.toAddSubmonoid ^ n := by induction n with | zero => exact (h rfl).elim | succ n ih => rw [Submodule.pow_succ, pow_succ, mul_toAddSubmonoid] cases n with | zero => rw [Submodule.pow_zero, pow_zero, one_mul, ← mul_toAddSubmonoid, Submodule.one_mul] | succ n => rw [ih n.succ_ne_zero] theorem le_pow_toAddSubmonoid {n : ℕ} : M.toAddSubmonoid ^ n ≤ (M ^ n).toAddSubmonoid := by obtain rfl | hn := Decidable.eq_or_ne n 0 · rw [Submodule.pow_zero, pow_zero] exact le_one_toAddSubmonoid · exact (pow_toAddSubmonoid M hn).ge theorem pow_subset_pow {n : ℕ} : (↑M : Set A) ^ n ⊆ ↑(M ^ n : Submodule R A) := trans AddSubmonoid.pow_subset_pow (le_pow_toAddSubmonoid M) theorem pow_mem_pow {x : A} (hx : x ∈ M) (n : ℕ) : x ^ n ∈ M ^ n := pow_subset_pow _ <| Set.pow_mem_pow hx lemma restrictScalars_pow {A B C : Type*} [Semiring A] [Semiring B] [Semiring C] [SMul A B] [Module A C] [Module B C] [IsScalarTower A C C] [IsScalarTower B C C] [IsScalarTower A B C] {I : Submodule B C} : ∀ {n : ℕ}, (hn : n ≠ 0) → (I ^ n).restrictScalars A = I.restrictScalars A ^ n | 1, _ => by simp [Submodule.pow_one] | n + 2, _ => by simp [Submodule.pow_succ (n := n + 1), restrictScalars_mul, restrictScalars_pow n.succ_ne_zero] end Module variable {ι : Sort uι} variable {R : Type u} [CommSemiring R] section AlgebraSemiring variable {A : Type v} [Semiring A] [Algebra R A] variable (S T : Set A) {M N P Q : Submodule R A} {m n : A} theorem one_eq_range : (1 : Submodule R A) = LinearMap.range (Algebra.linearMap R A) := by rw [one_eq_span, LinearMap.span_singleton_eq_range, LinearMap.toSpanSingleton_eq_algebra_linearMap] theorem algebraMap_mem (r : R) : algebraMap R A r ∈ (1 : Submodule R A) := by simp [one_eq_range] @[simp] theorem mem_one {x : A} : x ∈ (1 : Submodule R A) ↔ ∃ y, algebraMap R A y = x := by simp [one_eq_range] theorem smul_one_eq_span (x : A) : x • (1 : Submodule R A) = span R {x} := by rw [one_eq_span, smul_span, smul_set_singleton, smul_eq_mul, mul_one] protected theorem map_one {A'} [Semiring A'] [Algebra R A'] (f : A →ₐ[R] A') : map f.toLinearMap (1 : Submodule R A) = 1 := by ext simp @[simp] theorem map_op_one : map (↑(opLinearEquiv R : A ≃ₗ[R] Aᵐᵒᵖ) : A →ₗ[R] Aᵐᵒᵖ) (1 : Submodule R A) = 1 := by ext x induction x simp @[simp] theorem comap_op_one : comap (↑(opLinearEquiv R : A ≃ₗ[R] Aᵐᵒᵖ) : A →ₗ[R] Aᵐᵒᵖ) (1 : Submodule R Aᵐᵒᵖ) = 1 := by ext simp @[simp] theorem map_unop_one : map (↑(opLinearEquiv R : A ≃ₗ[R] Aᵐᵒᵖ).symm : Aᵐᵒᵖ →ₗ[R] A) (1 : Submodule R Aᵐᵒᵖ) = 1 := by rw [← comap_equiv_eq_map_symm, comap_op_one] @[simp] theorem comap_unop_one : comap (↑(opLinearEquiv R : A ≃ₗ[R] Aᵐᵒᵖ).symm : Aᵐᵒᵖ →ₗ[R] A) (1 : Submodule R A) = 1 := by rw [← map_equiv_eq_comap_symm, map_op_one] theorem mul_eq_map₂ : M * N = map₂ (LinearMap.mul R A) M N := le_antisymm (mul_le.mpr fun _m hm _n ↦ apply_mem_map₂ _ hm) (map₂_le.mpr fun _m hm _n ↦ mul_mem_mul hm) variable (R M N) theorem span_mul_span : span R S * span R T = span R (S * T) := by rw [mul_eq_map₂]; apply map₂_span_span lemma mul_def : M * N = span R (M * N : Set A) := by simp [← span_mul_span] variable {R} (P Q) protected theorem mul_one : M * 1 = M := by conv_lhs => rw [one_eq_span, ← span_eq M] rw [span_mul_span] simp protected theorem map_mul {A'} [Semiring A'] [Algebra R A'] (f : A →ₐ[R] A') : map f.toLinearMap (M * N) = map f.toLinearMap M * map f.toLinearMap N := calc map f.toLinearMap (M * N) = ⨆ i : M, (N.map (LinearMap.mul R A i)).map f.toLinearMap := by rw [mul_eq_map₂]; apply map_iSup _ = map f.toLinearMap M * map f.toLinearMap N := by rw [mul_eq_map₂] apply congr_arg sSup ext S constructor <;> rintro ⟨y, hy⟩ · use ⟨f y, mem_map.mpr ⟨y.1, y.2, rfl⟩⟩ refine Eq.trans ?_ hy ext simp · obtain ⟨y', hy', fy_eq⟩ := mem_map.mp y.2 use ⟨y', hy'⟩ refine Eq.trans ?_ hy rw [f.toLinearMap_apply] at fy_eq ext simp [fy_eq] theorem map_op_mul : map (↑(opLinearEquiv R : A ≃ₗ[R] Aᵐᵒᵖ) : A →ₗ[R] Aᵐᵒᵖ) (M * N) = map (↑(opLinearEquiv R : A ≃ₗ[R] Aᵐᵒᵖ) : A →ₗ[R] Aᵐᵒᵖ) N * map (↑(opLinearEquiv R : A ≃ₗ[R] Aᵐᵒᵖ) : A →ₗ[R] Aᵐᵒᵖ) M := by apply le_antisymm · simp_rw [map_le_iff_le_comap] refine mul_le.2 fun m hm n hn => ?_ rw [mem_comap, map_equiv_eq_comap_symm, map_equiv_eq_comap_symm] change op n * op m ∈ _ exact mul_mem_mul hn hm · refine mul_le.2 (MulOpposite.rec' fun m hm => MulOpposite.rec' fun n hn => ?_) rw [Submodule.mem_map_equiv] at hm hn ⊢ exact mul_mem_mul hn hm theorem comap_unop_mul : comap (↑(opLinearEquiv R : A ≃ₗ[R] Aᵐᵒᵖ).symm : Aᵐᵒᵖ →ₗ[R] A) (M * N) = comap (↑(opLinearEquiv R : A ≃ₗ[R] Aᵐᵒᵖ).symm : Aᵐᵒᵖ →ₗ[R] A) N * comap (↑(opLinearEquiv R : A ≃ₗ[R] Aᵐᵒᵖ).symm : Aᵐᵒᵖ →ₗ[R] A) M := by simp_rw [← map_equiv_eq_comap_symm, map_op_mul] theorem map_unop_mul (M N : Submodule R Aᵐᵒᵖ) : map (↑(opLinearEquiv R : A ≃ₗ[R] Aᵐᵒᵖ).symm : Aᵐᵒᵖ →ₗ[R] A) (M * N) = map (↑(opLinearEquiv R : A ≃ₗ[R] Aᵐᵒᵖ).symm : Aᵐᵒᵖ →ₗ[R] A) N * map (↑(opLinearEquiv R : A ≃ₗ[R] Aᵐᵒᵖ).symm : Aᵐᵒᵖ →ₗ[R] A) M := have : Function.Injective (↑(opLinearEquiv R : A ≃ₗ[R] Aᵐᵒᵖ) : A →ₗ[R] Aᵐᵒᵖ) := LinearEquiv.injective _ map_injective_of_injective this <| by rw [← map_comp, map_op_mul, ← map_comp, ← map_comp, LinearEquiv.comp_coe, LinearEquiv.symm_trans_self, LinearEquiv.refl_toLinearMap, map_id, map_id, map_id] theorem comap_op_mul (M N : Submodule R Aᵐᵒᵖ) : comap (↑(opLinearEquiv R : A ≃ₗ[R] Aᵐᵒᵖ) : A →ₗ[R] Aᵐᵒᵖ) (M * N) = comap (↑(opLinearEquiv R : A ≃ₗ[R] Aᵐᵒᵖ) : A →ₗ[R] Aᵐᵒᵖ) N * comap (↑(opLinearEquiv R : A ≃ₗ[R] Aᵐᵒᵖ) : A →ₗ[R] Aᵐᵒᵖ) M := by simp_rw [comap_equiv_eq_map_symm, map_unop_mul] section variable {α : Type*} [Monoid α] [DistribMulAction α A] [SMulCommClass α R A] instance [IsScalarTower α A A] : IsScalarTower α (Submodule R A) (Submodule R A) where smul_assoc a S T := by rw [← S.span_eq, ← T.span_eq, smul_span, smul_eq_mul, smul_eq_mul, span_mul_span, span_mul_span, smul_span, smul_mul_assoc] instance [SMulCommClass α A A] : SMulCommClass α (Submodule R A) (Submodule R A) where smul_comm a S T := by rw [← S.span_eq, ← T.span_eq, smul_span, smul_eq_mul, smul_eq_mul, span_mul_span, span_mul_span, smul_span, mul_smul_comm] instance [SMulCommClass A α A] : SMulCommClass (Submodule R A) α (Submodule R A) := have := SMulCommClass.symm A α A; .symm .. end section open Pointwise /-- `Submodule.pointwiseNeg` distributes over multiplication. This is available as an instance in the `Pointwise` locale. -/ protected def hasDistribPointwiseNeg {A} [Ring A] [Algebra R A] : HasDistribNeg (Submodule R A) := toAddSubmonoid_injective.hasDistribNeg _ neg_toAddSubmonoid mul_toAddSubmonoid scoped[Pointwise] attribute [instance] Submodule.hasDistribPointwiseNeg end section DecidableEq theorem mem_span_mul_finite_of_mem_span_mul {R A} [Semiring R] [AddCommMonoid A] [Mul A] [Module R A] {S : Set A} {S' : Set A} {x : A} (hx : x ∈ span R (S * S')) : ∃ T T' : Finset A, ↑T ⊆ S ∧ ↑T' ⊆ S' ∧ x ∈ span R (T * T' : Set A) := by classical obtain ⟨U, h, hU⟩ := mem_span_finite_of_mem_span hx obtain ⟨T, T', hS, hS', h⟩ := Finset.subset_mul h use T, T', hS, hS' have h' : (U : Set A) ⊆ T * T' := by assumption_mod_cast have h'' := span_mono h' hU assumption end DecidableEq theorem mul_eq_span_mul_set (s t : Submodule R A) : s * t = span R ((s : Set A) * (t : Set A)) := by rw [mul_eq_map₂]; exact map₂_eq_span_image2 _ s t theorem mem_span_mul_finite_of_mem_mul {P Q : Submodule R A} {x : A} (hx : x ∈ P * Q) : ∃ T T' : Finset A, (T : Set A) ⊆ P ∧ (T' : Set A) ⊆ Q ∧ x ∈ span R (T * T' : Set A) := Submodule.mem_span_mul_finite_of_mem_span_mul (by rwa [← Submodule.span_eq P, ← Submodule.span_eq Q, Submodule.span_mul_span] at hx) variable {M N P} theorem mem_span_singleton_mul {x y : A} : x ∈ span R {y} * P ↔ ∃ z ∈ P, y * z = x := by simp_rw [mul_eq_map₂, map₂_span_singleton_eq_map, mem_map, LinearMap.mul_apply_apply] theorem mem_mul_span_singleton {x y : A} : x ∈ P * span R {y} ↔ ∃ z ∈ P, z * y = x := by simp_rw [mul_eq_map₂, map₂_span_singleton_eq_map_flip, mem_map, LinearMap.flip_apply, LinearMap.mul_apply_apply] lemma span_singleton_mul {x : A} {p : Submodule R A} : Submodule.span R {x} * p = x • p := ext fun _ ↦ mem_span_singleton_mul lemma mem_smul_iff_inv_mul_mem {S} [DivisionSemiring S] [Algebra R S] {x : S} {p : Submodule R S} {y : S} (hx : x ≠ 0) : y ∈ x • p ↔ x⁻¹ * y ∈ p := by constructor · rintro ⟨a, ha : a ∈ p, rfl⟩; simpa [inv_mul_cancel_left₀ hx] · exact fun h ↦ ⟨_, h, by simp [mul_inv_cancel_left₀ hx]⟩ lemma mul_mem_smul_iff {S} [CommRing S] [Algebra R S] {x : S} {p : Submodule R S} {y : S} (hx : x ∈ nonZeroDivisors S) : x * y ∈ x • p ↔ y ∈ p := by simp [mem_smul_pointwise_iff_exists, mul_cancel_left_mem_nonZeroDivisors hx] variable (M N) in theorem mul_smul_mul_eq_smul_mul_smul (x y : R) : (x * y) • (M * N) = (x • M) * (y • N) := mul_smul_mul_comm x y M N /-- Sub-R-modules of an R-algebra form an idempotent semiring. -/ instance idemSemiring : IdemSemiring (Submodule R A) where __ := instNonUnitalSemiring one_mul := Submodule.one_mul mul_one := Submodule.mul_one bot_le _ := bot_le instance : IsOrderedRing (Submodule R A) where mul_le_mul_of_nonneg_left _ _ _ h _ := mul_le_mul_left' h _ mul_le_mul_of_nonneg_right _ _ _ h _ := mul_le_mul_right' h _ variable (M) theorem span_pow (s : Set A) : ∀ n : ℕ, span R s ^ n = span R (s ^ n) | 0 => by rw [pow_zero, pow_zero, one_eq_span_one_set] | n + 1 => by rw [pow_succ, pow_succ, span_pow s n, span_mul_span] theorem pow_eq_span_pow_set (n : ℕ) : M ^ n = span R ((M : Set A) ^ n) := by rw [← span_pow, span_eq] /-- Dependent version of `Submodule.pow_induction_on_left`. -/ @[elab_as_elim] protected theorem pow_induction_on_left' {C : ∀ (n : ℕ) (x), x ∈ M ^ n → Prop} (algebraMap : ∀ r : R, C 0 (algebraMap _ _ r) (algebraMap_mem r)) (add : ∀ x y i hx hy, C i x hx → C i y hy → C i (x + y) (add_mem ‹_› ‹_›)) (mem_mul : ∀ m (hm : m ∈ M), ∀ (i x hx), C i x hx → C i.succ (m * x) ((pow_succ' M i).symm ▸ (mul_mem_mul hm hx))) {n : ℕ} {x : A} (hx : x ∈ M ^ n) : C n x hx := by induction n generalizing x with | zero => rw [pow_zero] at hx obtain ⟨r, rfl⟩ := mem_one.mp hx exact algebraMap r | succ n n_ih => revert hx simp_rw [pow_succ'] exact fun hx ↦ Submodule.mul_induction_on' (fun m hm x ih => mem_mul _ hm _ _ _ (n_ih ih)) (fun x hx y hy Cx Cy => add _ _ _ _ _ Cx Cy) hx /-- Dependent version of `Submodule.pow_induction_on_right`. -/ @[elab_as_elim] protected theorem pow_induction_on_right' {C : ∀ (n : ℕ) (x), x ∈ M ^ n → Prop} (algebraMap : ∀ r : R, C 0 (algebraMap _ _ r) (algebraMap_mem r)) (add : ∀ x y i hx hy, C i x hx → C i y hy → C i (x + y) (add_mem ‹_› ‹_›)) (mul_mem : ∀ i x hx, C i x hx → ∀ m (hm : m ∈ M), C i.succ (x * m) (mul_mem_mul hx hm)) {n : ℕ} {x : A} (hx : x ∈ M ^ n) : C n x hx := by induction n generalizing x with | zero => rw [pow_zero] at hx obtain ⟨r, rfl⟩ := mem_one.mp hx exact algebraMap r | succ n n_ih => revert hx simp_rw [pow_succ] exact fun hx ↦ Submodule.mul_induction_on' (fun m hm x ih => mul_mem _ _ hm (n_ih _) _ ih) (fun x hx y hy Cx Cy => add _ _ _ _ _ Cx Cy) hx /-- To show a property on elements of `M ^ n` holds, it suffices to show that it holds for scalars, is closed under addition, and holds for `m * x` where `m ∈ M` and it holds for `x` -/ @[elab_as_elim] protected theorem pow_induction_on_left {C : A → Prop} (hr : ∀ r : R, C (algebraMap _ _ r)) (hadd : ∀ x y, C x → C y → C (x + y)) (hmul : ∀ m ∈ M, ∀ (x), C x → C (m * x)) {x : A} {n : ℕ} (hx : x ∈ M ^ n) : C x := Submodule.pow_induction_on_left' M (C := fun _ a _ => C a) hr (fun x y _i _hx _hy => hadd x y) (fun _m hm _i _x _hx => hmul _ hm _) hx /-- To show a property on elements of `M ^ n` holds, it suffices to show that it holds for scalars, is closed under addition, and holds for `x * m` where `m ∈ M` and it holds for `x` -/ @[elab_as_elim] protected theorem pow_induction_on_right {C : A → Prop} (hr : ∀ r : R, C (algebraMap _ _ r)) (hadd : ∀ x y, C x → C y → C (x + y)) (hmul : ∀ x, C x → ∀ m ∈ M, C (x * m)) {x : A} {n : ℕ} (hx : x ∈ M ^ n) : C x := Submodule.pow_induction_on_right' (M := M) (C := fun _ a _ => C a) hr (fun x y _i _hx _hy => hadd x y) (fun _i _x _hx => hmul _) hx /-- `Submonoid.map` as a `RingHom`, when applied to an `AlgHom`. -/ @[simps] def mapHom {A'} [Semiring A'] [Algebra R A'] (f : A →ₐ[R] A') : Submodule R A →+* Submodule R A' where toFun := map f.toLinearMap map_zero' := Submodule.map_bot _ map_add' := (Submodule.map_sup · · _) map_one' := Submodule.map_one _ map_mul' := (Submodule.map_mul · · _) theorem mapHom_id : mapHom (.id R A) = .id _ := RingHom.ext map_id /-- The ring of submodules of the opposite algebra is isomorphic to the opposite ring of submodules. -/ @[simps apply symm_apply] def equivOpposite : Submodule R Aᵐᵒᵖ ≃+* (Submodule R A)ᵐᵒᵖ where toFun p := op <| p.comap (↑(opLinearEquiv R : A ≃ₗ[R] Aᵐᵒᵖ) : A →ₗ[R] Aᵐᵒᵖ) invFun p := p.unop.comap (↑(opLinearEquiv R : A ≃ₗ[R] Aᵐᵒᵖ).symm : Aᵐᵒᵖ →ₗ[R] A) left_inv _ := SetLike.coe_injective <| rfl right_inv _ := unop_injective <| SetLike.coe_injective rfl map_add' p q := by simp [comap_equiv_eq_map_symm, ← op_add] map_mul' _ _ := congr_arg op <| comap_op_mul _ _ protected theorem map_pow {A'} [Semiring A'] [Algebra R A'] (f : A →ₐ[R] A') (n : ℕ) : map f.toLinearMap (M ^ n) = map f.toLinearMap M ^ n := map_pow (mapHom f) M n theorem comap_unop_pow (n : ℕ) : comap (↑(opLinearEquiv R : A ≃ₗ[R] Aᵐᵒᵖ).symm : Aᵐᵒᵖ →ₗ[R] A) (M ^ n) = comap (↑(opLinearEquiv R : A ≃ₗ[R] Aᵐᵒᵖ).symm : Aᵐᵒᵖ →ₗ[R] A) M ^ n := (equivOpposite : Submodule R Aᵐᵒᵖ ≃+* _).symm.map_pow (op M) n theorem comap_op_pow (n : ℕ) (M : Submodule R Aᵐᵒᵖ) : comap (↑(opLinearEquiv R : A ≃ₗ[R] Aᵐᵒᵖ) : A →ₗ[R] Aᵐᵒᵖ) (M ^ n) = comap (↑(opLinearEquiv R : A ≃ₗ[R] Aᵐᵒᵖ) : A →ₗ[R] Aᵐᵒᵖ) M ^ n := op_injective <| (equivOpposite : Submodule R Aᵐᵒᵖ ≃+* _).map_pow M n theorem map_op_pow (n : ℕ) : map (↑(opLinearEquiv R : A ≃ₗ[R] Aᵐᵒᵖ) : A →ₗ[R] Aᵐᵒᵖ) (M ^ n) = map (↑(opLinearEquiv R : A ≃ₗ[R] Aᵐᵒᵖ) : A →ₗ[R] Aᵐᵒᵖ) M ^ n := by rw [map_equiv_eq_comap_symm, map_equiv_eq_comap_symm, comap_unop_pow] theorem map_unop_pow (n : ℕ) (M : Submodule R Aᵐᵒᵖ) : map (↑(opLinearEquiv R : A ≃ₗ[R] Aᵐᵒᵖ).symm : Aᵐᵒᵖ →ₗ[R] A) (M ^ n) = map (↑(opLinearEquiv R : A ≃ₗ[R] Aᵐᵒᵖ).symm : Aᵐᵒᵖ →ₗ[R] A) M ^ n := by rw [← comap_equiv_eq_map_symm, ← comap_equiv_eq_map_symm, comap_op_pow] /-- `span` is a semiring homomorphism (recall multiplication is pointwise multiplication of subsets on either side). -/ @[simps] noncomputable def span.ringHom : SetSemiring A →+* Submodule R A where toFun s := Submodule.span R (SetSemiring.down s) map_zero' := span_empty map_one' := one_eq_span.symm map_add' := span_union map_mul' s t := by simp_rw [SetSemiring.down_mul, span_mul_span] section variable {α : Type*} [Monoid α] [MulSemiringAction α A] [SMulCommClass α R A] /-- The action on a submodule corresponding to applying the action to every element. This is available as an instance in the `Pointwise` locale. This is a stronger version of `Submodule.pointwiseDistribMulAction`. -/ protected def pointwiseMulSemiringAction : MulSemiringAction α (Submodule R A) where __ := Submodule.pointwiseDistribMulAction smul_mul r x y := Submodule.map_mul x y <| MulSemiringAction.toAlgHom R A r smul_one r := Submodule.map_one <| MulSemiringAction.toAlgHom R A r scoped[Pointwise] attribute [instance] Submodule.pointwiseMulSemiringAction end end AlgebraSemiring section AlgebraCommSemiring variable {A : Type v} [CommSemiring A] [Algebra R A] variable {M N : Submodule R A} {m n : A} theorem mul_mem_mul_rev (hm : m ∈ M) (hn : n ∈ N) : n * m ∈ M * N := mul_comm m n ▸ mul_mem_mul hm hn variable (M N) protected theorem mul_comm : M * N = N * M := le_antisymm (mul_le.2 fun _r hrm _s hsn => mul_mem_mul_rev hsn hrm) (mul_le.2 fun _r hrn _s hsm => mul_mem_mul_rev hsm hrn) /-- Sub-R-modules of an R-algebra A form a semiring. -/ instance : IdemCommSemiring (Submodule R A) := { Submodule.idemSemiring with mul_comm := Submodule.mul_comm } theorem prod_span {ι : Type*} (s : Finset ι) (M : ι → Set A) : (∏ i ∈ s, Submodule.span R (M i)) = Submodule.span R (∏ i ∈ s, M i) := by letI := Classical.decEq ι refine Finset.induction_on s ?_ ?_ · simp [one_eq_span, Set.singleton_one] · intro _ _ H ih rw [Finset.prod_insert H, Finset.prod_insert H, ih, span_mul_span] theorem prod_span_singleton {ι : Type*} (s : Finset ι) (x : ι → A) : (∏ i ∈ s, span R ({x i} : Set A)) = span R {∏ i ∈ s, x i} := by rw [prod_span, Set.finset_prod_singleton] variable (R A) /-- R-submodules of the R-algebra A are a module over `Set A`. -/ noncomputable instance moduleSet : Module (SetSemiring A) (Submodule R A) where smul s P := span R (SetSemiring.down s) * P smul_add _ _ _ := mul_add _ _ _ add_smul s t P := by simp_rw [HSMul.hSMul, SetSemiring.down_add, span_union, sup_mul, add_eq_sup] mul_smul s t P := by simp_rw [HSMul.hSMul, SetSemiring.down_mul, ← mul_assoc, span_mul_span] one_smul P := by simp_rw [HSMul.hSMul, SetSemiring.down_one, ← one_eq_span_one_set, one_mul] zero_smul P := by simp_rw [HSMul.hSMul, SetSemiring.down_zero, span_empty, bot_mul, bot_eq_zero] smul_zero _ := mul_bot _ variable {R A} theorem setSemiring_smul_def (s : SetSemiring A) (P : Submodule R A) : s • P = span R (SetSemiring.down (α := A) s) * P := rfl theorem smul_le_smul {s t : SetSemiring A} {M N : Submodule R A} (h₁ : SetSemiring.down (α := A) s ⊆ SetSemiring.down (α := A) t) (h₂ : M ≤ N) : s • M ≤ t • N := mul_le_mul (span_mono h₁) h₂ theorem singleton_smul (a : A) (M : Submodule R A) : Set.up ({a} : Set A) • M = M.map (LinearMap.mulLeft R a) := by conv_lhs => rw [← span_eq M] rw [setSemiring_smul_def, SetSemiring.down_up, span_mul_span, singleton_mul] exact (map (LinearMap.mulLeft R a) M).span_eq section Quotient /-- The elements of `I / J` are the `x` such that `x • J ⊆ I`. In fact, we define `x ∈ I / J` to be `∀ y ∈ J, x * y ∈ I` (see `mem_div_iff_forall_mul_mem`), which is equivalent to `x • J ⊆ I` (see `mem_div_iff_smul_subset`), but nicer to use in proofs. This is the general form of the ideal quotient, traditionally written $I : J$. -/ instance : Div (Submodule R A) := ⟨fun I J => { carrier := { x | ∀ y ∈ J, x * y ∈ I } zero_mem' := fun y _ => by rw [zero_mul] apply Submodule.zero_mem add_mem' := fun ha hb y hy => by rw [add_mul] exact Submodule.add_mem _ (ha _ hy) (hb _ hy) smul_mem' := fun r x hx y hy => by rw [Algebra.smul_mul_assoc] exact Submodule.smul_mem _ _ (hx _ hy) }⟩ theorem mem_div_iff_forall_mul_mem {x : A} {I J : Submodule R A} : x ∈ I / J ↔ ∀ y ∈ J, x * y ∈ I := Iff.refl _ theorem mem_div_iff_smul_subset {x : A} {I J : Submodule R A} : x ∈ I / J ↔ x • (J : Set A) ⊆ I := ⟨fun h y ⟨y', hy', xy'_eq_y⟩ => by rw [← xy'_eq_y]; exact h _ hy', fun h _ hy => h (Set.smul_mem_smul_set hy)⟩ theorem le_div_iff {I J K : Submodule R A} : I ≤ J / K ↔ ∀ x ∈ I, ∀ z ∈ K, x * z ∈ J := Iff.refl _ theorem le_div_iff_mul_le {I J K : Submodule R A} : I ≤ J / K ↔ I * K ≤ J := by rw [le_div_iff, mul_le] theorem one_le_one_div {I : Submodule R A} : 1 ≤ 1 / I ↔ I ≤ 1 := by rw [le_div_iff_mul_le, one_mul] @[simp] theorem one_mem_div {I J : Submodule R A} : 1 ∈ I / J ↔ J ≤ I := by rw [← one_le, le_div_iff_mul_le, one_mul] theorem le_self_mul_one_div {I : Submodule R A} (hI : I ≤ 1) : I ≤ I * (1 / I) := by refine (mul_one I).symm.trans_le ?_ apply mul_le_mul_right (one_le_one_div.mpr hI) theorem mul_one_div_le_one {I : Submodule R A} : I * (1 / I) ≤ 1 := by rw [Submodule.mul_le] intro m hm n hn rw [Submodule.mem_div_iff_forall_mul_mem] at hn rw [mul_comm] exact hn m hm @[simp] protected theorem map_div {B : Type*} [CommSemiring B] [Algebra R B] (I J : Submodule R A) (h : A ≃ₐ[R] B) : (I / J).map h.toLinearMap = I.map h.toLinearMap / J.map h.toLinearMap := by ext x simp only [mem_map, mem_div_iff_forall_mul_mem, AlgEquiv.toLinearMap_apply] constructor · rintro ⟨x, hx, rfl⟩ _ ⟨y, hy, rfl⟩ exact ⟨x * y, hx _ hy, map_mul h x y⟩ · rintro hx refine ⟨h.symm x, fun z hz => ?_, h.apply_symm_apply x⟩ obtain ⟨xz, xz_mem, hxz⟩ := hx (h z) ⟨z, hz, rfl⟩ convert xz_mem apply h.injective rw [map_mul, h.apply_symm_apply, hxz] end Quotient end AlgebraCommSemiring end Submodule
RootSystem.lean
/- Copyright (c) 2024 Andrew Yang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Andrew Yang -/ import Mathlib.Algebra.Lie.Weights.Killing import Mathlib.LinearAlgebra.RootSystem.Basic import Mathlib.LinearAlgebra.RootSystem.Irreducible import Mathlib.LinearAlgebra.RootSystem.Reduced import Mathlib.LinearAlgebra.RootSystem.Finite.CanonicalBilinear import Mathlib.Algebra.Algebra.Rat /-! # The root system associated with a Lie algebra We show that the roots of a finite dimensional splitting semisimple Lie algebra over a field of characteristic 0 form a root system. We achieve this by studying root chains. ## Main results - `LieAlgebra.IsKilling.apply_coroot_eq_cast`: If `β - qα ... β ... β + rα` is the `α`-chain through `β`, then `β (coroot α) = q - r`. In particular, it is an integer. - `LieAlgebra.IsKilling.rootSpace_zsmul_add_ne_bot_iff`: The `α`-chain through `β` (`β - qα ... β ... β + rα`) are the only roots of the form `β + kα`. - `LieAlgebra.IsKilling.eq_neg_or_eq_of_eq_smul`: `±α` are the only `K`-multiples of a root `α` that are also (non-zero) roots. - `LieAlgebra.IsKilling.rootSystem`: The root system of a finite-dimensional Lie algebra with non-degenerate Killing form over a field of characteristic zero, relative to a splitting Cartan subalgebra. -/ noncomputable section namespace LieAlgebra.IsKilling open LieModule Module variable {K L : Type*} [Field K] [CharZero K] [LieRing L] [LieAlgebra K L] [IsKilling K L] [FiniteDimensional K L] {H : LieSubalgebra K L} [H.IsCartanSubalgebra] [IsTriangularizable K H L] variable (α β : Weight K H L) private lemma chainLength_aux (hα : α.IsNonZero) {x} (hx : x ∈ rootSpace H (chainTop α β)) : ∃ n : ℕ, n • x = ⁅coroot α, x⁆ := by by_cases hx' : x = 0 · exact ⟨0, by simp [hx']⟩ obtain ⟨h, e, f, isSl2, he, hf⟩ := exists_isSl2Triple_of_weight_isNonZero hα obtain rfl := isSl2.h_eq_coroot hα he hf have : isSl2.HasPrimitiveVectorWith x (chainTop α β (coroot α)) := have := lie_mem_genWeightSpace_of_mem_genWeightSpace he hx ⟨hx', by rw [← lie_eq_smul_of_mem_rootSpace hx]; rfl, by rwa [genWeightSpace_add_chainTop α β hα] at this⟩ obtain ⟨μ, hμ⟩ := this.exists_nat exact ⟨μ, by rw [← Nat.cast_smul_eq_nsmul K, ← hμ, lie_eq_smul_of_mem_rootSpace hx]⟩ /-- The length of the `α`-chain through `β`. See `chainBotCoeff_add_chainTopCoeff`. -/ def chainLength (α β : Weight K H L) : ℕ := letI := Classical.propDecidable if hα : α.IsZero then 0 else (chainLength_aux α β hα (chainTop α β).exists_ne_zero.choose_spec.1).choose lemma chainLength_of_isZero (hα : α.IsZero) : chainLength α β = 0 := dif_pos hα lemma chainLength_nsmul {x} (hx : x ∈ rootSpace H (chainTop α β)) : chainLength α β • x = ⁅coroot α, x⁆ := by by_cases hα : α.IsZero · rw [coroot_eq_zero_iff.mpr hα, chainLength_of_isZero _ _ hα, zero_smul, zero_lie] let x' := (chainTop α β).exists_ne_zero.choose have h : x' ∈ rootSpace H (chainTop α β) ∧ x' ≠ 0 := (chainTop α β).exists_ne_zero.choose_spec obtain ⟨k, rfl⟩ : ∃ k : K, k • x' = x := by simpa using (finrank_eq_one_iff_of_nonzero' ⟨x', h.1⟩ (by simpa using h.2)).mp (finrank_rootSpace_eq_one _ (chainTop_isNonZero α β hα)) ⟨_, hx⟩ rw [lie_smul, smul_comm, chainLength, dif_neg hα, (chainLength_aux α β hα h.1).choose_spec] lemma chainLength_smul {x} (hx : x ∈ rootSpace H (chainTop α β)) : (chainLength α β : K) • x = ⁅coroot α, x⁆ := by rw [Nat.cast_smul_eq_nsmul, chainLength_nsmul _ _ hx] lemma apply_coroot_eq_cast' : β (coroot α) = ↑(chainLength α β - 2 * chainTopCoeff α β : ℤ) := by by_cases hα : α.IsZero · rw [coroot_eq_zero_iff.mpr hα, chainLength, dif_pos hα, hα.eq, chainTopCoeff_zero, map_zero, CharP.cast_eq_zero, mul_zero, sub_self, Int.cast_zero] obtain ⟨x, hx, x_ne0⟩ := (chainTop α β).exists_ne_zero have := chainLength_smul _ _ hx rw [lie_eq_smul_of_mem_rootSpace hx, ← sub_eq_zero, ← sub_smul, smul_eq_zero_iff_left x_ne0, sub_eq_zero, coe_chainTop', nsmul_eq_mul, Pi.natCast_def, Pi.add_apply, Pi.mul_apply, root_apply_coroot hα] at this simp only [Int.cast_sub, Int.cast_natCast, Int.cast_mul, Int.cast_ofNat, eq_sub_iff_add_eq', this, mul_comm (2 : K)] lemma rootSpace_neg_nsmul_add_chainTop_of_le {n : ℕ} (hn : n ≤ chainLength α β) : rootSpace H (- (n • α) + chainTop α β) ≠ ⊥ := by by_cases hα : α.IsZero · simpa only [hα.eq, smul_zero, neg_zero, chainTop_zero, zero_add, ne_eq] using β.2 obtain ⟨x, hx, x_ne0⟩ := (chainTop α β).exists_ne_zero obtain ⟨h, e, f, isSl2, he, hf⟩ := exists_isSl2Triple_of_weight_isNonZero hα obtain rfl := isSl2.h_eq_coroot hα he hf have prim : isSl2.HasPrimitiveVectorWith x (chainLength α β : K) := have := lie_mem_genWeightSpace_of_mem_genWeightSpace he hx ⟨x_ne0, (chainLength_smul _ _ hx).symm, by rwa [genWeightSpace_add_chainTop _ _ hα] at this⟩ simp only [← smul_neg, ne_eq, LieSubmodule.eq_bot_iff, not_forall] exact ⟨_, toEnd_pow_apply_mem hf hx n, prim.pow_toEnd_f_ne_zero_of_eq_nat rfl hn⟩ lemma rootSpace_neg_nsmul_add_chainTop_of_lt (hα : α.IsNonZero) {n : ℕ} (hn : chainLength α β < n) : rootSpace H (- (n • α) + chainTop α β) = ⊥ := by by_contra e let W : Weight K H L := ⟨_, e⟩ have hW : (W : H → K) = - (n • α) + chainTop α β := rfl have H₁ : 1 + n + chainTopCoeff (-α) W ≤ chainLength (-α) W := by have := apply_coroot_eq_cast' (-α) W simp only [coroot_neg, map_neg, hW, nsmul_eq_mul, Pi.natCast_def, coe_chainTop, zsmul_eq_mul, Int.cast_natCast, Pi.add_apply, Pi.neg_apply, Pi.mul_apply, root_apply_coroot hα, mul_two, apply_coroot_eq_cast' α β, Int.cast_sub, Int.cast_mul, Int.cast_ofNat, mul_comm (2 : K), add_sub_cancel, add_sub, Nat.cast_inj, eq_sub_iff_add_eq, ← Nat.cast_add, ← sub_eq_neg_add, sub_eq_iff_eq_add] at this omega have H₂ : ((1 + n + chainTopCoeff (-α) W) • α + chainTop (-α) W : H → K) = (chainTopCoeff α β + 1) • α + β := by simp only [Weight.coe_neg, ← Nat.cast_smul_eq_nsmul ℤ, Nat.cast_add, Nat.cast_one, coe_chainTop, smul_neg, ← neg_smul, hW, ← add_assoc, ← add_smul, ← sub_eq_add_neg] congr 2 ring have := rootSpace_neg_nsmul_add_chainTop_of_le (-α) W H₁ rw [Weight.coe_neg, ← smul_neg, neg_neg, ← Weight.coe_neg, H₂] at this exact this (genWeightSpace_chainTopCoeff_add_one_nsmul_add α β hα) lemma chainTopCoeff_le_chainLength : chainTopCoeff α β ≤ chainLength α β := by by_cases hα : α.IsZero · simp only [hα.eq, chainTopCoeff_zero, zero_le] rw [← not_lt, ← Nat.succ_le] intro e apply genWeightSpace_nsmul_add_ne_bot_of_le α β (Nat.sub_le (chainTopCoeff α β) (chainLength α β).succ) rw [← Nat.cast_smul_eq_nsmul ℤ, Nat.cast_sub e, sub_smul, sub_eq_neg_add, add_assoc, ← coe_chainTop, Nat.cast_smul_eq_nsmul] exact rootSpace_neg_nsmul_add_chainTop_of_lt α β hα (Nat.lt_succ_self _) lemma chainBotCoeff_add_chainTopCoeff : chainBotCoeff α β + chainTopCoeff α β = chainLength α β := by by_cases hα : α.IsZero · rw [hα.eq, chainTopCoeff_zero, chainBotCoeff_zero, zero_add, chainLength_of_isZero α β hα] apply le_antisymm · rw [← Nat.le_sub_iff_add_le (chainTopCoeff_le_chainLength α β), ← not_lt, ← Nat.succ_le, chainBotCoeff, ← Weight.coe_neg] intro e apply genWeightSpace_nsmul_add_ne_bot_of_le _ _ e rw [← Nat.cast_smul_eq_nsmul ℤ, Nat.cast_succ, Nat.cast_sub (chainTopCoeff_le_chainLength α β), LieModule.Weight.coe_neg, smul_neg, ← neg_smul, neg_add_rev, neg_sub, sub_eq_neg_add, ← add_assoc, ← neg_add_rev, add_smul, add_assoc, ← coe_chainTop, neg_smul, ← @Nat.cast_one ℤ, ← Nat.cast_add, Nat.cast_smul_eq_nsmul] exact rootSpace_neg_nsmul_add_chainTop_of_lt α β hα (Nat.lt_succ_self _) · rw [← not_lt] intro e apply rootSpace_neg_nsmul_add_chainTop_of_le α β e rw [← Nat.succ_add, ← Nat.cast_smul_eq_nsmul ℤ, ← neg_smul, coe_chainTop, ← add_assoc, ← add_smul, Nat.cast_add, neg_add, add_assoc, neg_add_cancel, add_zero, neg_smul, ← smul_neg, Nat.cast_smul_eq_nsmul] exact genWeightSpace_chainTopCoeff_add_one_nsmul_add (-α) β (Weight.IsNonZero.neg hα) lemma chainTopCoeff_add_chainBotCoeff : chainTopCoeff α β + chainBotCoeff α β = chainLength α β := by rw [add_comm, chainBotCoeff_add_chainTopCoeff] lemma chainBotCoeff_le_chainLength : chainBotCoeff α β ≤ chainLength α β := (Nat.le_add_left _ _).trans_eq (chainTopCoeff_add_chainBotCoeff α β) @[simp] lemma chainLength_neg : chainLength (-α) β = chainLength α β := by rw [← chainBotCoeff_add_chainTopCoeff, ← chainBotCoeff_add_chainTopCoeff, add_comm, Weight.coe_neg, chainTopCoeff_neg, chainBotCoeff_neg] @[simp] lemma chainLength_zero [Nontrivial L] : chainLength 0 β = 0 := by simp [← chainBotCoeff_add_chainTopCoeff] /-- If `β - qα ... β ... β + rα` is the `α`-chain through `β`, then `β (coroot α) = q - r`. In particular, it is an integer. -/ lemma apply_coroot_eq_cast : β (coroot α) = (chainBotCoeff α β - chainTopCoeff α β : ℤ) := by rw [apply_coroot_eq_cast', ← chainTopCoeff_add_chainBotCoeff]; congr 1; omega lemma le_chainBotCoeff_of_rootSpace_ne_top (hα : α.IsNonZero) (n : ℤ) (hn : rootSpace H (-n • α + β) ≠ ⊥) : n ≤ chainBotCoeff α β := by contrapose! hn lift n to ℕ using (Nat.cast_nonneg _).trans hn.le rw [Nat.cast_lt, ← @Nat.add_lt_add_iff_right (chainTopCoeff α β), chainBotCoeff_add_chainTopCoeff] at hn have := rootSpace_neg_nsmul_add_chainTop_of_lt α β hα hn rwa [← Nat.cast_smul_eq_nsmul ℤ, ← neg_smul, coe_chainTop, ← add_assoc, ← add_smul, Nat.cast_add, neg_add, add_assoc, neg_add_cancel, add_zero] at this /-- Members of the `α`-chain through `β` are the only roots of the form `β - kα`. -/ lemma rootSpace_zsmul_add_ne_bot_iff (hα : α.IsNonZero) (n : ℤ) : rootSpace H (n • α + β) ≠ ⊥ ↔ n ≤ chainTopCoeff α β ∧ -n ≤ chainBotCoeff α β := by constructor · refine (fun hn ↦ ⟨?_, le_chainBotCoeff_of_rootSpace_ne_top α β hα _ (by rwa [neg_neg])⟩) rw [← chainBotCoeff_neg, ← Weight.coe_neg] apply le_chainBotCoeff_of_rootSpace_ne_top _ _ hα.neg rwa [neg_smul, Weight.coe_neg, smul_neg, neg_neg] · rintro ⟨h₁, h₂⟩ set k := chainTopCoeff α β - n with hk; clear_value k lift k to ℕ using (by rw [hk, le_sub_iff_add_le, zero_add]; exact h₁) rw [eq_sub_iff_add_eq, ← eq_sub_iff_add_eq'] at hk subst hk simp only [neg_sub, tsub_le_iff_right, ← Nat.cast_add, Nat.cast_le, chainBotCoeff_add_chainTopCoeff] at h₂ have := rootSpace_neg_nsmul_add_chainTop_of_le α β h₂ rwa [coe_chainTop, ← Nat.cast_smul_eq_nsmul ℤ, ← neg_smul, ← add_assoc, ← add_smul, ← sub_eq_neg_add] at this lemma rootSpace_zsmul_add_ne_bot_iff_mem (hα : α.IsNonZero) (n : ℤ) : rootSpace H (n • α + β) ≠ ⊥ ↔ n ∈ Finset.Icc (-chainBotCoeff α β : ℤ) (chainTopCoeff α β) := by rw [rootSpace_zsmul_add_ne_bot_iff α β hα n, Finset.mem_Icc, and_comm, neg_le] lemma chainTopCoeff_of_eq_zsmul_add (hα : α.IsNonZero) (β' : Weight K H L) (n : ℤ) (hβ' : (β' : H → K) = n • α + β) : chainTopCoeff α β' = chainTopCoeff α β - n := by apply le_antisymm · refine le_sub_iff_add_le.mpr ((rootSpace_zsmul_add_ne_bot_iff α β hα _).mp ?_).1 rw [add_smul, add_assoc, ← hβ', ← coe_chainTop] exact (chainTop α β').2 · refine ((rootSpace_zsmul_add_ne_bot_iff α β' hα _).mp ?_).1 rw [hβ', ← add_assoc, ← add_smul, sub_add_cancel, ← coe_chainTop] exact (chainTop α β).2 lemma chainBotCoeff_of_eq_zsmul_add (hα : α.IsNonZero) (β' : Weight K H L) (n : ℤ) (hβ' : (β' : H → K) = n • α + β) : chainBotCoeff α β' = chainBotCoeff α β + n := by have : (β' : H → K) = -n • (-α) + β := by rwa [neg_smul, smul_neg, neg_neg] rw [chainBotCoeff, chainBotCoeff, ← Weight.coe_neg, chainTopCoeff_of_eq_zsmul_add (-α) β hα.neg β' (-n) this, sub_neg_eq_add] lemma chainLength_of_eq_zsmul_add (β' : Weight K H L) (n : ℤ) (hβ' : (β' : H → K) = n • α + β) : chainLength α β' = chainLength α β := by by_cases hα : α.IsZero · rw [chainLength_of_isZero _ _ hα, chainLength_of_isZero _ _ hα] · apply Nat.cast_injective (R := ℤ) rw [← chainTopCoeff_add_chainBotCoeff, ← chainTopCoeff_add_chainBotCoeff, Nat.cast_add, Nat.cast_add, chainTopCoeff_of_eq_zsmul_add α β hα β' n hβ', chainBotCoeff_of_eq_zsmul_add α β hα β' n hβ', sub_eq_add_neg, add_add_add_comm, neg_add_cancel, add_zero] lemma chainTopCoeff_zero_right [Nontrivial L] (hα : α.IsNonZero) : chainTopCoeff α (0 : Weight K H L) = 1 := by symm apply eq_of_le_of_not_lt · rw [Nat.one_le_iff_ne_zero] intro e exact α.2 (by simpa [e, Weight.coe_zero] using genWeightSpace_chainTopCoeff_add_one_nsmul_add α (0 : Weight K H L) hα) obtain ⟨x, hx, x_ne0⟩ := (chainTop α (0 : Weight K H L)).exists_ne_zero obtain ⟨h, e, f, isSl2, he, hf⟩ := exists_isSl2Triple_of_weight_isNonZero hα obtain rfl := isSl2.h_eq_coroot hα he hf have prim : isSl2.HasPrimitiveVectorWith x (chainLength α (0 : Weight K H L) : K) := have := lie_mem_genWeightSpace_of_mem_genWeightSpace he hx ⟨x_ne0, (chainLength_smul _ _ hx).symm, by rwa [genWeightSpace_add_chainTop _ _ hα] at this⟩ obtain ⟨k, hk⟩ : ∃ k : K, k • f = (toEnd K L L f ^ (chainTopCoeff α (0 : Weight K H L) + 1)) x := by have : (toEnd K L L f ^ (chainTopCoeff α (0 : Weight K H L) + 1)) x ∈ rootSpace H (-α) := by convert toEnd_pow_apply_mem hf hx (chainTopCoeff α (0 : Weight K H L) + 1) using 2 rw [coe_chainTop', Weight.coe_zero, add_zero, succ_nsmul', add_assoc, smul_neg, neg_add_cancel, add_zero] simpa using (finrank_eq_one_iff_of_nonzero' ⟨f, hf⟩ (by simpa using isSl2.f_ne_zero)).mp (finrank_rootSpace_eq_one _ hα.neg) ⟨_, this⟩ apply_fun (⁅f, ·⁆) at hk simp only [lie_smul, lie_self, smul_zero, prim.lie_f_pow_toEnd_f] at hk intro e refine prim.pow_toEnd_f_ne_zero_of_eq_nat rfl ?_ hk.symm have := (apply_coroot_eq_cast' α 0).symm simp only [← @Nat.cast_two ℤ, ← Nat.cast_mul, Weight.zero_apply, Int.cast_eq_zero, sub_eq_zero, Nat.cast_inj] at this rwa [this, Nat.succ_le, two_mul, add_lt_add_iff_left] lemma chainBotCoeff_zero_right [Nontrivial L] (hα : α.IsNonZero) : chainBotCoeff α (0 : Weight K H L) = 1 := chainTopCoeff_zero_right (-α) hα.neg lemma chainLength_zero_right [Nontrivial L] (hα : α.IsNonZero) : chainLength α 0 = 2 := by rw [← chainBotCoeff_add_chainTopCoeff, chainTopCoeff_zero_right α hα, chainBotCoeff_zero_right α hα] lemma rootSpace_two_smul (hα : α.IsNonZero) : rootSpace H (2 • α) = ⊥ := by cases subsingleton_or_nontrivial L · exact IsEmpty.elim inferInstance α simpa [chainTopCoeff_zero_right α hα] using genWeightSpace_chainTopCoeff_add_one_nsmul_add α (0 : Weight K H L) hα lemma rootSpace_one_div_two_smul (hα : α.IsNonZero) : rootSpace H ((2⁻¹ : K) • α) = ⊥ := by by_contra h let W : Weight K H L := ⟨_, h⟩ have hW : 2 • (W : H → K) = α := by change 2 • (2⁻¹ : K) • (α : H → K) = α rw [← Nat.cast_smul_eq_nsmul K, smul_smul]; simp apply α.genWeightSpace_ne_bot have := rootSpace_two_smul W (fun (e : (W : H → K) = 0) ↦ hα <| by apply_fun (2 • ·) at e; simpa [hW] using e) rwa [hW] at this lemma eq_neg_one_or_eq_zero_or_eq_one_of_eq_smul (hα : α.IsNonZero) (k : K) (h : (β : H → K) = k • α) : k = -1 ∨ k = 0 ∨ k = 1 := by cases subsingleton_or_nontrivial L · exact IsEmpty.elim inferInstance α have H := apply_coroot_eq_cast' α β rw [h] at H simp only [Pi.smul_apply, root_apply_coroot hα] at H rcases (chainLength α β).even_or_odd with (⟨n, hn⟩|⟨n, hn⟩) · rw [hn, ← two_mul] at H simp only [smul_eq_mul, Nat.cast_mul, Nat.cast_ofNat, ← mul_sub, ← mul_comm (2 : K), Int.cast_sub, Int.cast_mul, Int.cast_ofNat, Int.cast_natCast, mul_eq_mul_left_iff, OfNat.ofNat_ne_zero, or_false] at H rw [← Int.cast_natCast, ← Int.cast_natCast (chainTopCoeff α β), ← Int.cast_sub] at H have := (rootSpace_zsmul_add_ne_bot_iff_mem α 0 hα (n - chainTopCoeff α β)).mp (by rw [← Int.cast_smul_eq_zsmul K, ← H, ← h, Weight.coe_zero, add_zero]; exact β.2) rw [chainTopCoeff_zero_right α hα, chainBotCoeff_zero_right α hα, Nat.cast_one] at this set k' : ℤ := n - chainTopCoeff α β subst H have : k' ∈ ({-1, 0, 1} : Finset ℤ) := by change k' ∈ Finset.Icc (-1 : ℤ) (1 : ℤ) exact this simpa only [Int.reduceNeg, Finset.mem_insert, Finset.mem_singleton, ← @Int.cast_inj K, Int.cast_zero, Int.cast_neg, Int.cast_one] using this · apply_fun (· / 2) at H rw [hn, smul_eq_mul] at H have hk : k = n + 2⁻¹ - chainTopCoeff α β := by simpa [sub_div, add_div] using H have := (rootSpace_zsmul_add_ne_bot_iff α β hα (chainTopCoeff α β - n)).mpr ?_ swap · simp only [tsub_le_iff_right, le_add_iff_nonneg_right, Nat.cast_nonneg, neg_sub, true_and] rw [← Nat.cast_add, chainBotCoeff_add_chainTopCoeff, hn] omega rw [h, hk, ← Int.cast_smul_eq_zsmul K, ← add_smul] at this simp only [Int.cast_sub, Int.cast_natCast, sub_add_sub_cancel', add_sub_cancel_left, ne_eq] at this cases this (rootSpace_one_div_two_smul α hα) /-- `±α` are the only `K`-multiples of a root `α` that are also (non-zero) roots. -/ lemma eq_neg_or_eq_of_eq_smul (hβ : β.IsNonZero) (k : K) (h : (β : H → K) = k • α) : β = -α ∨ β = α := by by_cases hα : α.IsZero · rw [hα, smul_zero] at h; cases hβ h rcases eq_neg_one_or_eq_zero_or_eq_one_of_eq_smul α β hα k h with (rfl | rfl | rfl) · exact .inl (by ext; rw [h, neg_one_smul]; rfl) · cases hβ (by rwa [zero_smul] at h) · exact .inr (by ext; rw [h, one_smul]) /-- The reflection of a root along another. -/ def reflectRoot (α β : Weight K H L) : Weight K H L where toFun := β - β (coroot α) • α genWeightSpace_ne_bot' := by by_cases hα : α.IsZero · simpa [hα.eq] using β.genWeightSpace_ne_bot rw [sub_eq_neg_add, apply_coroot_eq_cast α β, ← neg_smul, ← Int.cast_neg, Int.cast_smul_eq_zsmul, rootSpace_zsmul_add_ne_bot_iff α β hα] omega lemma reflectRoot_isNonZero (α β : Weight K H L) (hβ : β.IsNonZero) : (reflectRoot α β).IsNonZero := by intro e have : β (coroot α) = 0 := by by_cases hα : α.IsZero · simp [coroot_eq_zero_iff.mpr hα] apply add_left_injective (β (coroot α)) simpa [root_apply_coroot hα, mul_two] using congr_fun (sub_eq_zero.mp e) (coroot α) have : reflectRoot α β = β := by ext; simp [reflectRoot, this] exact hβ (this ▸ e) variable (H) /-- The root system of a finite-dimensional Lie algebra with non-degenerate Killing form over a field of characteristic zero, relative to a splitting Cartan subalgebra. -/ def rootSystem : RootSystem H.root K (Dual K H) H := RootSystem.mk' IsReflexive.toPerfectPairingDual { toFun := (↑) inj' := by intro α β h; ext x; simpa using LinearMap.congr_fun h x } { toFun := coroot ∘ (↑) inj' := by rintro ⟨α, hα⟩ ⟨β, hβ⟩ h; simpa using h } (fun ⟨α, hα⟩ ↦ by simpa using root_apply_coroot <| by simpa using hα) (by rintro ⟨α, hα⟩ - ⟨⟨β, hβ⟩, rfl⟩ simpa using ⟨reflectRoot α β, by simpa using reflectRoot_isNonZero α β <| by simpa using hβ, rfl⟩) (by convert span_weight_isNonZero_eq_top K L H; ext; simp) (fun α β ↦ ⟨chainBotCoeff β.1 α.1 - chainTopCoeff β.1 α.1, by simp [apply_coroot_eq_cast β.1 α.1]⟩) @[simp] lemma corootForm_rootSystem_eq_killing : (rootSystem H).CorootForm = (killingForm K L).restrict H := by rw [restrict_killingForm_eq_sum, RootPairing.CorootForm, ← Finset.sum_coe_sort (s := H.root)] rfl @[simp] lemma rootSystem_toPerfectPairing_apply (f x) : (rootSystem H).toPerfectPairing f x = f x := rfl @[simp] lemma rootSystem_pairing_apply (α β) : (rootSystem H).pairing β α = β.1 (coroot α.1) := rfl @[simp] lemma rootSystem_root_apply (α) : (rootSystem H).root α = α := rfl @[simp] lemma rootSystem_coroot_apply (α) : (rootSystem H).coroot α = coroot α := rfl instance : (rootSystem H).IsCrystallographic where exists_value α β := ⟨chainBotCoeff β.1 α.1 - chainTopCoeff β.1 α.1, by simp [apply_coroot_eq_cast β.1 α.1]⟩ instance : (rootSystem H).IsReduced where eq_or_eq_neg := by intro ⟨α, hα⟩ ⟨β, hβ⟩ e rw [LinearIndependent.pair_iff' ((rootSystem H).ne_zero _), not_forall] at e simp only [rootSystem_root_apply, ne_eq, not_not] at e obtain ⟨u, hu⟩ := e obtain (h | h) := eq_neg_or_eq_of_eq_smul α β (by simpa using hβ) u (by ext x; exact DFunLike.congr_fun hu.symm x) · right; ext x; simpa [neg_eq_iff_eq_neg] using DFunLike.congr_fun h.symm x · left; ext x; simpa using DFunLike.congr_fun h.symm x section IsSimple -- Note that after #10068 (Cartan's criterion) is complete we can omit `[IsKilling K L]` variable [IsSimple K L] open Weight in lemma eq_top_of_invtSubmodule_ne_bot (q : Submodule K (Dual K H)) (h₀ : ∀ (i : H.root), q ∈ End.invtSubmodule ((rootSystem H).reflection i)) (h₁ : q ≠ ⊥) : q = ⊤ := by have _i := nontrivial_of_isIrreducible K L L let S := rootSystem H by_contra h₃ suffices h₂ : ∀ Φ, Φ.Nonempty → S.root '' Φ ⊆ q → (∀ i ∉ Φ, q ≤ LinearMap.ker (S.coroot' i)) → Φ = Set.univ by have := (S.eq_top_of_mem_invtSubmodule_of_forall_eq_univ q h₁ h₀) h₂ apply False.elim (h₃ this) intro Φ hΦ₁ hΦ₂ hΦ₃ by_contra hc have hΦ₂' : ∀ i ∈ Φ, (S.root i) ∈ q := by intro i hi apply hΦ₂ exact Set.mem_image_of_mem S.root hi have s₁ (i j : H.root) (h₁ : i ∈ Φ) (h₂ : j ∉ Φ) : S.root i (S.coroot j) = 0 := (hΦ₃ j h₂) (hΦ₂' i h₁) have s₁' (i j : H.root) (h₁ : i ∈ Φ) (h₂ : j ∉ Φ) : S.root j (S.coroot i) = 0 := (S.pairing_eq_zero_iff (i := i) (j := j)).1 (s₁ i j h₁ h₂) have s₂ (i j : H.root) (h₁ : i ∈ Φ) (h₂ : j ∉ Φ) : i.1 (coroot j) = 0 := s₁ i j h₁ h₂ have s₂' (i j : H.root) (h₁ : i ∈ Φ) (h₂ : j ∉ Φ) : j.1 (coroot i) = 0 := s₁' i j h₁ h₂ have s₃ (i j : H.root) (h₁ : i ∈ Φ) (h₂ : j ∉ Φ) : genWeightSpace L (i.1.1 + j.1.1) = ⊥ := by by_contra h have i_non_zero : i.1.IsNonZero := by grind have j_non_zero : j.1.IsNonZero := by grind let r := Weight.mk (R := K) (L := H) (M := L) (i.1.1 + j.1.1) h have r₁ : r ≠ 0 := by intro a have h_eq : i.1 = -j.1 := Weight.ext <| congrFun (eq_neg_of_add_eq_zero_left <| by have := congr_arg Weight.toFun a simp at this; exact this) have := s₂ i j h₁ h₂ rw [h_eq, coe_neg, Pi.neg_apply, root_apply_coroot j_non_zero] at this simp at this have r₂ : r ∈ H.root := by simp [isNonZero_iff_ne_zero, r₁] cases Classical.em (⟨r, r₂⟩ ∈ Φ) with | inl hl => have e₁ : i.1.1 (coroot j) = 0 := s₂ i j h₁ h₂ have e₂ : j.1.1 (coroot j) = 2 := root_apply_coroot j_non_zero have : (0 : K) = 2 := calc 0 = (i.1.1 + j.1.1) (coroot j) := (s₂ ⟨r, r₂⟩ j hl h₂).symm _ = i.1.1 (coroot j) + j.1.1 (coroot j) := rfl _ = 2 := by rw [e₁, e₂, zero_add] simp at this | inr hr => have e₁ : j.1.1 (coroot i) = 0 := s₂' i j h₁ h₂ have e₂ : i.1.1 (coroot i) = 2 := root_apply_coroot i_non_zero have : (0 : K) = 2 := calc 0 = (i.1.1 + j.1.1) (coroot i) := (s₂' i ⟨r, r₂⟩ h₁ hr).symm _ = i.1.1 (coroot i) + j.1.1 (coroot i) := rfl _ = 2 := by rw [e₁, e₂, add_zero] simp at this have s₄ (i j : H.root) (h1 : i ∈ Φ) (h2 : j ∉ Φ) (li : rootSpace H i.1.1) (lj : rootSpace H j.1.1) : ⁅li.1, lj.1⁆ = 0 := by have h₃ := lie_mem_genWeightSpace_of_mem_genWeightSpace li.2 lj.2 rw [s₃ i j h1 h2] at h₃ exact h₃ let g := ⋃ i ∈ Φ, (rootSpace H i : Set L) let I := LieSubalgebra.lieSpan K L g have s₅ : I ≠ ⊤ := by obtain ⟨j, hj⟩ := (Set.ne_univ_iff_exists_notMem Φ).mp hc obtain ⟨z, hz₁, hz₂⟩ := exists_ne_zero (R := K) (L := H) (M := L) j by_contra! hI have center_element : z ∈ center K L := by have commutes_with_all (x : L) : ⁅x, z⁆ = 0 := by have x_mem_I : x ∈ I := by rw [hI]; exact trivial induction x_mem_I using LieSubalgebra.lieSpan_induction with | mem x hx => obtain ⟨i, hi, hx1_mem⟩ := Set.mem_iUnion₂.mp hx have := s₄ i j hi hj simp only [Subtype.forall] at this exact (this x hx1_mem) z hz₁ | zero => exact zero_lie z | add _ _ _ _ e f => rw [add_lie, e, f, add_zero] | smul _ _ _ d => simp only [smul_lie, smul_eq_zero] right exact d | lie _ _ _ _ e f => rw [lie_lie, e, f, lie_zero, lie_zero, sub_self] exact commutes_with_all rw [center_eq_bot] at center_element exact hz₂ center_element have s₆ : I ≠ ⊥ := by obtain ⟨r, hr⟩ := Set.nonempty_def.mp hΦ₁ obtain ⟨x, hx₁, hx₂⟩ := exists_ne_zero (R := K) (L := H) (M := L) r have x_in_g : x ∈ g := by apply Set.mem_iUnion_of_mem r simp only [Set.mem_iUnion] exact ⟨hr, hx₁⟩ have x_mem_I : x ∈ I := LieSubalgebra.mem_lieSpan.mpr (fun _ a ↦ a x_in_g) by_contra h exact hx₂ (I.eq_bot_iff.mp h x x_mem_I) have s₇ : ∀ x y : L, y ∈ I → ⁅x, y⁆ ∈ I := by have gen : ⨆ χ : Weight K H L, (genWeightSpace L χ).toSubmodule = ⊤ := by simp only [LieSubmodule.iSup_toSubmodule_eq_top] exact iSup_genWeightSpace_eq_top' K H L intro x y hy have hx : x ∈ ⨆ χ : Weight K H L, (genWeightSpace L χ).toSubmodule := by simp only [gen, Submodule.mem_top] induction hx using Submodule.iSup_induction' with | mem j x hx => induction hy using LieSubalgebra.lieSpan_induction with | mem x₁ hx₁ => obtain ⟨i, hi, x₁_mem⟩ := Set.mem_iUnion₂.mp hx₁ have r₁ (j : Weight K H L) : j = 0 ∨ j ∈ H.root := by rcases (eq_or_ne j 0) with h | h · left exact h · right refine Finset.mem_filter.mpr ?_ exact ⟨Finset.mem_univ j, isNonZero_iff_ne_zero.mpr h⟩ rcases (r₁ j) with h | h have h₁ : ⁅x, x₁⁆ ∈ g := by have h₂ := lie_mem_genWeightSpace_of_mem_genWeightSpace hx x₁_mem rw [h, coe_zero, zero_add] at h₂ exact Set.mem_biUnion hi h₂ exact LieSubalgebra.mem_lieSpan.mpr fun _ a ↦ a h₁ rcases (Classical.em (⟨j, h⟩ ∈ Φ)) with h₁ | h₁ exact I.lie_mem (LieSubalgebra.mem_lieSpan.mpr fun _ a ↦ a (Set.mem_biUnion h₁ hx)) (LieSubalgebra.mem_lieSpan.mpr fun _ a ↦ a hx₁) have : ⁅x, x₁⁆ = 0 := by rw [← neg_eq_zero, lie_skew x₁ x, (s₄ i ⟨j, h⟩ hi h₁ ⟨x₁, x₁_mem⟩ ⟨x, hx⟩)] rw [this] exact I.zero_mem | zero => simp only [lie_zero, zero_mem, I] | add _ _ _ _ e f => simp only [lie_add] exact add_mem e f | smul a _ _ d => simp only [lie_smul] exact I.smul_mem a d | lie a b c d e f => have : ⁅x, ⁅a, b⁆⁆ = ⁅⁅x, a⁆, b⁆ + ⁅a, ⁅x, b⁆⁆ := by simp only [lie_lie, sub_add_cancel] rw [this] exact add_mem (I.lie_mem e d) (I.lie_mem c f) | zero => simp only [zero_lie, zero_mem] | add x1 y1 _ _ hx hy => simp only [add_lie] exact add_mem hx hy obtain ⟨I', h⟩ := (LieSubalgebra.exists_lieIdeal_coe_eq_iff (K := I)).2 s₇ have : IsSimple K L := inferInstance have : I' = ⊥ ∨ I' = ⊤ := this.eq_bot_or_eq_top I' have c₁ : I' ≠ ⊤ := by rw [← h] at s₅ exact ne_of_apply_ne (LieIdeal.toLieSubalgebra K L) s₅ have c₂ : I' ≠ ⊥ := by rw [← h] at s₆ exact ne_of_apply_ne (LieIdeal.toLieSubalgebra K L) s₆ grind instance : (rootSystem H).IsIrreducible := by have _i := nontrivial_of_isIrreducible K L L exact RootPairing.IsIrreducible.mk' (rootSystem H).toRootPairing <| eq_top_of_invtSubmodule_ne_bot H end IsSimple end LieAlgebra.IsKilling
Convolution.lean
/- Copyright (c) 2022 Floris van Doorn. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Floris van Doorn -/ import Mathlib.Analysis.Calculus.ContDiff.Basic import Mathlib.Analysis.Calculus.ParametricIntegral import Mathlib.MeasureTheory.Integral.Prod import Mathlib.MeasureTheory.Function.LocallyIntegrable import Mathlib.MeasureTheory.Group.Integral import Mathlib.MeasureTheory.Group.Prod import Mathlib.MeasureTheory.Integral.IntervalIntegral.Basic /-! # Convolution of functions This file defines the convolution on two functions, i.e. `x ↦ ∫ f(t)g(x - t) ∂t`. In the general case, these functions can be vector-valued, and have an arbitrary (additive) group as domain. We use a continuous bilinear operation `L` on these function values as "multiplication". The domain must be equipped with a Haar measure `μ` (though many individual results have weaker conditions on `μ`). For many applications we can take `L = ContinuousLinearMap.lsmul ℝ ℝ` or `L = ContinuousLinearMap.mul ℝ ℝ`. We also define `ConvolutionExists` and `ConvolutionExistsAt` to state that the convolution is well-defined (everywhere or at a single point). These conditions are needed for pointwise computations (e.g. `ConvolutionExistsAt.distrib_add`), but are generally not strong enough for any local (or global) properties of the convolution. For this we need stronger assumptions on `f` and/or `g`, and generally if we impose stronger conditions on one of the functions, we can impose weaker conditions on the other. We have proven many of the properties of the convolution assuming one of these functions has compact support (in which case the other function only needs to be locally integrable). We still need to prove the properties for other pairs of conditions (e.g. both functions are rapidly decreasing) # Design Decisions We use a bilinear map `L` to "multiply" the two functions in the integrand. This generality has several advantages * This allows us to compute the total derivative of the convolution, in case the functions are multivariate. The total derivative is again a convolution, but where the codomains of the functions can be higher-dimensional. See `HasCompactSupport.hasFDerivAt_convolution_right`. * This allows us to use `@[to_additive]` everywhere (which would not be possible if we would use `mul`/`smul` in the integral, since `@[to_additive]` will incorrectly also try to additivize those definitions). * We need to support the case where at least one of the functions is vector-valued, but if we use `smul` to multiply the functions, that would be an asymmetric definition. # Main Definitions * `MeasureTheory.convolution f g L μ x = (f ⋆[L, μ] g) x = ∫ t, L (f t) (g (x - t)) ∂μ` is the convolution of `f` and `g` w.r.t. the continuous bilinear map `L` and measure `μ`. * `MeasureTheory.ConvolutionExistsAt f g x L μ` states that the convolution `(f ⋆[L, μ] g) x` is well-defined (i.e. the integral exists). * `MeasureTheory.ConvolutionExists f g L μ` states that the convolution `f ⋆[L, μ] g` is well-defined at each point. # Main Results * `HasCompactSupport.hasFDerivAt_convolution_right` and `HasCompactSupport.hasFDerivAt_convolution_left`: we can compute the total derivative of the convolution as a convolution with the total derivative of the right (left) function. * `HasCompactSupport.contDiff_convolution_right` and `HasCompactSupport.contDiff_convolution_left`: the convolution is `𝒞ⁿ` if one of the functions is `𝒞ⁿ` with compact support and the other function in locally integrable. Versions of these statements for functions depending on a parameter are also given. * `MeasureTheory.convolution_tendsto_right`: Given a sequence of nonnegative normalized functions whose support tends to a small neighborhood around `0`, the convolution tends to the right argument. This is specialized to bump functions in `ContDiffBump.convolution_tendsto_right`. # Notation The following notations are localized in the locale `Convolution`: * `f ⋆[L, μ] g` for the convolution. Note: you have to use parentheses to apply the convolution to an argument: `(f ⋆[L, μ] g) x`. * `f ⋆[L] g := f ⋆[L, volume] g` * `f ⋆ g := f ⋆[lsmul ℝ ℝ] g` # To do * Existence and (uniform) continuity of the convolution if one of the maps is in `ℒ^p` and the other in `ℒ^q` with `1 / p + 1 / q = 1`. This might require a generalization of `MeasureTheory.MemLp.smul` where `smul` is generalized to a continuous bilinear map. (see e.g. [Fremlin, *Measure Theory* (volume 2)][fremlin_vol2], 255K) * The convolution is an `AEStronglyMeasurable` function (see e.g. [Fremlin, *Measure Theory* (volume 2)][fremlin_vol2], 255I). * Prove properties about the convolution if both functions are rapidly decreasing. * Use `@[to_additive]` everywhere (this likely requires changes in `to_additive`) -/ open Set Function Filter MeasureTheory MeasureTheory.Measure TopologicalSpace open Bornology ContinuousLinearMap Metric Topology open scoped Pointwise NNReal Filter universe u𝕜 uG uE uE' uE'' uF uF' uF'' uP variable {𝕜 : Type u𝕜} {G : Type uG} {E : Type uE} {E' : Type uE'} {E'' : Type uE''} {F : Type uF} {F' : Type uF'} {F'' : Type uF''} {P : Type uP} variable [NormedAddCommGroup E] [NormedAddCommGroup E'] [NormedAddCommGroup E''] [NormedAddCommGroup F] {f f' : G → E} {g g' : G → E'} {x x' : G} {y y' : E} namespace MeasureTheory section NontriviallyNormedField variable [NontriviallyNormedField 𝕜] variable [NormedSpace 𝕜 E] [NormedSpace 𝕜 E'] [NormedSpace 𝕜 E''] [NormedSpace 𝕜 F] variable (L : E →L[𝕜] E' →L[𝕜] F) section NoMeasurability variable [AddGroup G] [TopologicalSpace G] theorem convolution_integrand_bound_right_of_le_of_subset {C : ℝ} (hC : ∀ i, ‖g i‖ ≤ C) {x t : G} {s u : Set G} (hx : x ∈ s) (hu : -tsupport g + s ⊆ u) : ‖L (f t) (g (x - t))‖ ≤ u.indicator (fun t => ‖L‖ * ‖f t‖ * C) t := by -- Porting note: had to add `f := _` refine le_indicator (f := fun t ↦ ‖L (f t) (g (x - t))‖) (fun t _ => ?_) (fun t ht => ?_) t · apply_rules [L.le_of_opNorm₂_le_of_le, le_rfl] · have : x - t ∉ support g := by refine mt (fun hxt => hu ?_) ht refine ⟨_, Set.neg_mem_neg.mpr (subset_closure hxt), _, hx, ?_⟩ simp only [neg_sub, sub_add_cancel] simp only [notMem_support.mp this, (L _).map_zero, norm_zero, le_rfl] theorem _root_.HasCompactSupport.convolution_integrand_bound_right_of_subset (hcg : HasCompactSupport g) (hg : Continuous g) {x t : G} {s u : Set G} (hx : x ∈ s) (hu : -tsupport g + s ⊆ u) : ‖L (f t) (g (x - t))‖ ≤ u.indicator (fun t => ‖L‖ * ‖f t‖ * ⨆ i, ‖g i‖) t := by refine convolution_integrand_bound_right_of_le_of_subset _ (fun i => ?_) hx hu exact le_ciSup (hg.norm.bddAbove_range_of_hasCompactSupport hcg.norm) _ theorem _root_.HasCompactSupport.convolution_integrand_bound_right (hcg : HasCompactSupport g) (hg : Continuous g) {x t : G} {s : Set G} (hx : x ∈ s) : ‖L (f t) (g (x - t))‖ ≤ (-tsupport g + s).indicator (fun t => ‖L‖ * ‖f t‖ * ⨆ i, ‖g i‖) t := hcg.convolution_integrand_bound_right_of_subset L hg hx Subset.rfl theorem _root_.Continuous.convolution_integrand_fst [ContinuousSub G] (hg : Continuous g) (t : G) : Continuous fun x => L (f t) (g (x - t)) := L.continuous₂.comp₂ continuous_const <| hg.comp <| continuous_id.sub continuous_const theorem _root_.HasCompactSupport.convolution_integrand_bound_left (hcf : HasCompactSupport f) (hf : Continuous f) {x t : G} {s : Set G} (hx : x ∈ s) : ‖L (f (x - t)) (g t)‖ ≤ (-tsupport f + s).indicator (fun t => (‖L‖ * ⨆ i, ‖f i‖) * ‖g t‖) t := by convert hcf.convolution_integrand_bound_right L.flip hf hx using 1 simp_rw [L.opNorm_flip, mul_right_comm] end NoMeasurability section Measurability variable [MeasurableSpace G] {μ ν : Measure G} /-- The convolution of `f` and `g` exists at `x` when the function `t ↦ L (f t) (g (x - t))` is integrable. There are various conditions on `f` and `g` to prove this. -/ def ConvolutionExistsAt [Sub G] (f : G → E) (g : G → E') (x : G) (L : E →L[𝕜] E' →L[𝕜] F) (μ : Measure G := by volume_tac) : Prop := Integrable (fun t => L (f t) (g (x - t))) μ /-- The convolution of `f` and `g` exists when the function `t ↦ L (f t) (g (x - t))` is integrable for all `x : G`. There are various conditions on `f` and `g` to prove this. -/ def ConvolutionExists [Sub G] (f : G → E) (g : G → E') (L : E →L[𝕜] E' →L[𝕜] F) (μ : Measure G := by volume_tac) : Prop := ∀ x : G, ConvolutionExistsAt f g x L μ section ConvolutionExists variable {L} in theorem ConvolutionExistsAt.integrable [Sub G] {x : G} (h : ConvolutionExistsAt f g x L μ) : Integrable (fun t => L (f t) (g (x - t))) μ := h section Group variable [AddGroup G] theorem AEStronglyMeasurable.convolution_integrand' [MeasurableAdd₂ G] [MeasurableNeg G] (hf : AEStronglyMeasurable f ν) (hg : AEStronglyMeasurable g <| map (fun p : G × G => p.1 - p.2) (μ.prod ν)) : AEStronglyMeasurable (fun p : G × G => L (f p.2) (g (p.1 - p.2))) (μ.prod ν) := L.aestronglyMeasurable_comp₂ hf.comp_snd <| hg.comp_measurable measurable_sub section variable [MeasurableAdd G] [MeasurableNeg G] theorem AEStronglyMeasurable.convolution_integrand_snd' (hf : AEStronglyMeasurable f μ) {x : G} (hg : AEStronglyMeasurable g <| map (fun t => x - t) μ) : AEStronglyMeasurable (fun t => L (f t) (g (x - t))) μ := L.aestronglyMeasurable_comp₂ hf <| hg.comp_measurable <| measurable_id.const_sub x theorem AEStronglyMeasurable.convolution_integrand_swap_snd' {x : G} (hf : AEStronglyMeasurable f <| map (fun t => x - t) μ) (hg : AEStronglyMeasurable g μ) : AEStronglyMeasurable (fun t => L (f (x - t)) (g t)) μ := L.aestronglyMeasurable_comp₂ (hf.comp_measurable <| measurable_id.const_sub x) hg /-- A sufficient condition to prove that `f ⋆[L, μ] g` exists. We assume that `f` is integrable on a set `s` and `g` is bounded and ae strongly measurable on `x₀ - s` (note that both properties hold if `g` is continuous with compact support). -/ theorem _root_.BddAbove.convolutionExistsAt' {x₀ : G} {s : Set G} (hbg : BddAbove ((fun i => ‖g i‖) '' ((fun t => -t + x₀) ⁻¹' s))) (hs : MeasurableSet s) (h2s : (support fun t => L (f t) (g (x₀ - t))) ⊆ s) (hf : IntegrableOn f s μ) (hmg : AEStronglyMeasurable g <| map (fun t => x₀ - t) (μ.restrict s)) : ConvolutionExistsAt f g x₀ L μ := by rw [ConvolutionExistsAt] rw [← integrableOn_iff_integrable_of_support_subset h2s] set s' := (fun t => -t + x₀) ⁻¹' s have : ∀ᵐ t : G ∂μ.restrict s, ‖L (f t) (g (x₀ - t))‖ ≤ s.indicator (fun t => ‖L‖ * ‖f t‖ * ⨆ i : s', ‖g i‖) t := by filter_upwards refine le_indicator (fun t ht => ?_) fun t ht => ?_ · apply_rules [L.le_of_opNorm₂_le_of_le, le_rfl] refine (le_ciSup_set hbg <| mem_preimage.mpr ?_) rwa [neg_sub, sub_add_cancel] · have : t ∉ support fun t => L (f t) (g (x₀ - t)) := mt (fun h => h2s h) ht rw [notMem_support.mp this, norm_zero] refine Integrable.mono' ?_ ?_ this · rw [integrable_indicator_iff hs]; exact ((hf.norm.const_mul _).mul_const _).integrableOn · exact hf.aestronglyMeasurable.convolution_integrand_snd' L hmg /-- If `‖f‖ *[μ] ‖g‖` exists, then `f *[L, μ] g` exists. -/ theorem ConvolutionExistsAt.of_norm' {x₀ : G} (h : ConvolutionExistsAt (fun x => ‖f x‖) (fun x => ‖g x‖) x₀ (mul ℝ ℝ) μ) (hmf : AEStronglyMeasurable f μ) (hmg : AEStronglyMeasurable g <| map (fun t => x₀ - t) μ) : ConvolutionExistsAt f g x₀ L μ := by refine (h.const_mul ‖L‖).mono' (hmf.convolution_integrand_snd' L hmg) (Eventually.of_forall fun x => ?_) rw [mul_apply', ← mul_assoc] apply L.le_opNorm₂ @[deprecated (since := "2025-02-07")] alias ConvolutionExistsAt.ofNorm' := ConvolutionExistsAt.of_norm' end section Left variable [MeasurableAdd₂ G] [MeasurableNeg G] [SFinite μ] [IsAddRightInvariant μ] theorem AEStronglyMeasurable.convolution_integrand_snd (hf : AEStronglyMeasurable f μ) (hg : AEStronglyMeasurable g μ) (x : G) : AEStronglyMeasurable (fun t => L (f t) (g (x - t))) μ := hf.convolution_integrand_snd' L <| hg.mono_ac <| (quasiMeasurePreserving_sub_left_of_right_invariant μ x).absolutelyContinuous theorem AEStronglyMeasurable.convolution_integrand_swap_snd (hf : AEStronglyMeasurable f μ) (hg : AEStronglyMeasurable g μ) (x : G) : AEStronglyMeasurable (fun t => L (f (x - t)) (g t)) μ := (hf.mono_ac (quasiMeasurePreserving_sub_left_of_right_invariant μ x).absolutelyContinuous).convolution_integrand_swap_snd' L hg /-- If `‖f‖ *[μ] ‖g‖` exists, then `f *[L, μ] g` exists. -/ theorem ConvolutionExistsAt.of_norm {x₀ : G} (h : ConvolutionExistsAt (fun x => ‖f x‖) (fun x => ‖g x‖) x₀ (mul ℝ ℝ) μ) (hmf : AEStronglyMeasurable f μ) (hmg : AEStronglyMeasurable g μ) : ConvolutionExistsAt f g x₀ L μ := h.of_norm' L hmf <| hmg.mono_ac (quasiMeasurePreserving_sub_left_of_right_invariant μ x₀).absolutelyContinuous @[deprecated (since := "2025-02-07")] alias ConvolutionExistsAt.ofNorm := ConvolutionExistsAt.of_norm end Left section Right variable [MeasurableAdd₂ G] [MeasurableNeg G] [SFinite μ] [IsAddRightInvariant μ] [SFinite ν] theorem AEStronglyMeasurable.convolution_integrand (hf : AEStronglyMeasurable f ν) (hg : AEStronglyMeasurable g μ) : AEStronglyMeasurable (fun p : G × G => L (f p.2) (g (p.1 - p.2))) (μ.prod ν) := hf.convolution_integrand' L <| hg.mono_ac (quasiMeasurePreserving_sub_of_right_invariant μ ν).absolutelyContinuous theorem Integrable.convolution_integrand (hf : Integrable f ν) (hg : Integrable g μ) : Integrable (fun p : G × G => L (f p.2) (g (p.1 - p.2))) (μ.prod ν) := by have h_meas : AEStronglyMeasurable (fun p : G × G => L (f p.2) (g (p.1 - p.2))) (μ.prod ν) := hf.aestronglyMeasurable.convolution_integrand L hg.aestronglyMeasurable have h2_meas : AEStronglyMeasurable (fun y : G => ∫ x : G, ‖L (f y) (g (x - y))‖ ∂μ) ν := h_meas.prod_swap.norm.integral_prod_right' simp_rw [integrable_prod_iff' h_meas] refine ⟨Eventually.of_forall fun t => (L (f t)).integrable_comp (hg.comp_sub_right t), ?_⟩ refine Integrable.mono' ?_ h2_meas (Eventually.of_forall fun t => (?_ : _ ≤ ‖L‖ * ‖f t‖ * ∫ x, ‖g (x - t)‖ ∂μ)) · simp only [integral_sub_right_eq_self (‖g ·‖)] exact (hf.norm.const_mul _).mul_const _ · simp_rw [← integral_const_mul] rw [Real.norm_of_nonneg (by positivity)] exact integral_mono_of_nonneg (Eventually.of_forall fun t => norm_nonneg _) ((hg.comp_sub_right t).norm.const_mul _) (Eventually.of_forall fun t => L.le_opNorm₂ _ _) theorem Integrable.ae_convolution_exists (hf : Integrable f ν) (hg : Integrable g μ) : ∀ᵐ x ∂μ, ConvolutionExistsAt f g x L ν := ((integrable_prod_iff <| hf.aestronglyMeasurable.convolution_integrand L hg.aestronglyMeasurable).mp <| hf.convolution_integrand L hg).1 end Right variable [TopologicalSpace G] [IsTopologicalAddGroup G] [BorelSpace G] theorem _root_.HasCompactSupport.convolutionExistsAt {x₀ : G} (h : HasCompactSupport fun t => L (f t) (g (x₀ - t))) (hf : LocallyIntegrable f μ) (hg : Continuous g) : ConvolutionExistsAt f g x₀ L μ := by let u := (Homeomorph.neg G).trans (Homeomorph.addRight x₀) let v := (Homeomorph.neg G).trans (Homeomorph.addLeft x₀) apply ((u.isCompact_preimage.mpr h).bddAbove_image hg.norm.continuousOn).convolutionExistsAt' L isClosed_closure.measurableSet subset_closure (hf.integrableOn_isCompact h) have A : AEStronglyMeasurable (g ∘ v) (μ.restrict (tsupport fun t : G => L (f t) (g (x₀ - t)))) := by apply (hg.comp v.continuous).continuousOn.aestronglyMeasurable_of_isCompact h exact (isClosed_tsupport _).measurableSet convert ((v.continuous.measurable.measurePreserving (μ.restrict (tsupport fun t => L (f t) (g (x₀ - t))))).aestronglyMeasurable_comp_iff v.measurableEmbedding).1 A ext x simp only [v, Homeomorph.neg, sub_eq_add_neg, val_toAddUnits_apply, Homeomorph.trans_apply, Equiv.neg_apply, Homeomorph.homeomorph_mk_coe, Homeomorph.coe_addLeft] theorem _root_.HasCompactSupport.convolutionExists_right (hcg : HasCompactSupport g) (hf : LocallyIntegrable f μ) (hg : Continuous g) : ConvolutionExists f g L μ := by intro x₀ refine HasCompactSupport.convolutionExistsAt L ?_ hf hg refine (hcg.comp_homeomorph (Homeomorph.subLeft x₀)).mono ?_ refine fun t => mt fun ht : g (x₀ - t) = 0 => ?_ simp_rw [ht, (L _).map_zero] theorem _root_.HasCompactSupport.convolutionExists_left_of_continuous_right (hcf : HasCompactSupport f) (hf : LocallyIntegrable f μ) (hg : Continuous g) : ConvolutionExists f g L μ := by intro x₀ refine HasCompactSupport.convolutionExistsAt L ?_ hf hg refine hcf.mono ?_ refine fun t => mt fun ht : f t = 0 => ?_ simp_rw [ht, L.map_zero₂] end Group section CommGroup variable [AddCommGroup G] section MeasurableGroup variable [MeasurableNeg G] [IsAddLeftInvariant μ] /-- A sufficient condition to prove that `f ⋆[L, μ] g` exists. We assume that the integrand has compact support and `g` is bounded on this support (note that both properties hold if `g` is continuous with compact support). We also require that `f` is integrable on the support of the integrand, and that both functions are strongly measurable. This is a variant of `BddAbove.convolutionExistsAt'` in an abelian group with a left-invariant measure. This allows us to state the boundedness and measurability of `g` in a more natural way. -/ theorem _root_.BddAbove.convolutionExistsAt [MeasurableAdd₂ G] [SFinite μ] {x₀ : G} {s : Set G} (hbg : BddAbove ((fun i => ‖g i‖) '' ((fun t => x₀ - t) ⁻¹' s))) (hs : MeasurableSet s) (h2s : (support fun t => L (f t) (g (x₀ - t))) ⊆ s) (hf : IntegrableOn f s μ) (hmg : AEStronglyMeasurable g μ) : ConvolutionExistsAt f g x₀ L μ := by refine BddAbove.convolutionExistsAt' L ?_ hs h2s hf ?_ · simp_rw [← sub_eq_neg_add, hbg] · have : AEStronglyMeasurable g (map (fun t : G => x₀ - t) μ) := hmg.mono_ac (quasiMeasurePreserving_sub_left_of_right_invariant μ x₀).absolutelyContinuous apply this.mono_measure exact map_mono restrict_le_self (measurable_const.sub measurable_id') variable {L} [MeasurableAdd G] [IsNegInvariant μ] theorem convolutionExistsAt_flip : ConvolutionExistsAt g f x L.flip μ ↔ ConvolutionExistsAt f g x L μ := by simp_rw [ConvolutionExistsAt, ← integrable_comp_sub_left (fun t => L (f t) (g (x - t))) x, sub_sub_cancel, flip_apply] theorem ConvolutionExistsAt.integrable_swap (h : ConvolutionExistsAt f g x L μ) : Integrable (fun t => L (f (x - t)) (g t)) μ := by convert h.comp_sub_left x simp_rw [sub_sub_self] theorem convolutionExistsAt_iff_integrable_swap : ConvolutionExistsAt f g x L μ ↔ Integrable (fun t => L (f (x - t)) (g t)) μ := convolutionExistsAt_flip.symm end MeasurableGroup variable [TopologicalSpace G] [IsTopologicalAddGroup G] [BorelSpace G] variable [IsAddLeftInvariant μ] [IsNegInvariant μ] theorem _root_.HasCompactSupport.convolutionExists_left (hcf : HasCompactSupport f) (hf : Continuous f) (hg : LocallyIntegrable g μ) : ConvolutionExists f g L μ := fun x₀ => convolutionExistsAt_flip.mp <| hcf.convolutionExists_right L.flip hg hf x₀ @[deprecated (since := "2025-02-06")] alias _root_.HasCompactSupport.convolutionExistsLeft := HasCompactSupport.convolutionExists_left theorem _root_.HasCompactSupport.convolutionExists_right_of_continuous_left (hcg : HasCompactSupport g) (hf : Continuous f) (hg : LocallyIntegrable g μ) : ConvolutionExists f g L μ := fun x₀ => convolutionExistsAt_flip.mp <| hcg.convolutionExists_left_of_continuous_right L.flip hg hf x₀ @[deprecated (since := "2025-02-06")] alias _root_.HasCompactSupport.convolutionExistsRightOfContinuousLeft := HasCompactSupport.convolutionExists_right_of_continuous_left end CommGroup end ConvolutionExists variable [NormedSpace ℝ F] /-- The convolution of two functions `f` and `g` with respect to a continuous bilinear map `L` and measure `μ`. It is defined to be `(f ⋆[L, μ] g) x = ∫ t, L (f t) (g (x - t)) ∂μ`. -/ noncomputable def convolution [Sub G] (f : G → E) (g : G → E') (L : E →L[𝕜] E' →L[𝕜] F) (μ : Measure G := by volume_tac) : G → F := fun x => ∫ t, L (f t) (g (x - t)) ∂μ /-- The convolution of two functions with respect to a bilinear operation `L` and a measure `μ`. -/ scoped[Convolution] notation:67 f " ⋆[" L:67 ", " μ:67 "] " g:66 => convolution f g L μ /-- The convolution of two functions with respect to a bilinear operation `L` and the volume. -/ scoped[Convolution] notation:67 f " ⋆[" L:67 "]" g:66 => convolution f g L MeasureSpace.volume /-- The convolution of two real-valued functions with respect to volume. -/ scoped[Convolution] notation:67 f " ⋆ " g:66 => convolution f g (ContinuousLinearMap.lsmul ℝ ℝ) MeasureSpace.volume open scoped Convolution theorem convolution_def [Sub G] : (f ⋆[L, μ] g) x = ∫ t, L (f t) (g (x - t)) ∂μ := rfl /-- The definition of convolution where the bilinear operator is scalar multiplication. Note: it often helps the elaborator to give the type of the convolution explicitly. -/ theorem convolution_lsmul [Sub G] {f : G → 𝕜} {g : G → F} : (f ⋆[lsmul 𝕜 𝕜, μ] g : G → F) x = ∫ t, f t • g (x - t) ∂μ := rfl /-- The definition of convolution where the bilinear operator is multiplication. -/ theorem convolution_mul [Sub G] [NormedSpace ℝ 𝕜] {f : G → 𝕜} {g : G → 𝕜} : (f ⋆[mul 𝕜 𝕜, μ] g) x = ∫ t, f t * g (x - t) ∂μ := rfl section Group variable {L} [AddGroup G] theorem smul_convolution [SMulCommClass ℝ 𝕜 F] {y : 𝕜} : y • f ⋆[L, μ] g = y • (f ⋆[L, μ] g) := by ext; simp only [Pi.smul_apply, convolution_def, ← integral_smul, L.map_smul₂] theorem convolution_smul [SMulCommClass ℝ 𝕜 F] {y : 𝕜} : f ⋆[L, μ] y • g = y • (f ⋆[L, μ] g) := by ext; simp only [Pi.smul_apply, convolution_def, ← integral_smul, (L _).map_smul] @[simp] theorem zero_convolution : 0 ⋆[L, μ] g = 0 := by ext simp_rw [convolution_def, Pi.zero_apply, L.map_zero₂, integral_zero] @[simp] theorem convolution_zero : f ⋆[L, μ] 0 = 0 := by ext simp_rw [convolution_def, Pi.zero_apply, (L _).map_zero, integral_zero] theorem ConvolutionExistsAt.distrib_add {x : G} (hfg : ConvolutionExistsAt f g x L μ) (hfg' : ConvolutionExistsAt f g' x L μ) : (f ⋆[L, μ] (g + g')) x = (f ⋆[L, μ] g) x + (f ⋆[L, μ] g') x := by simp only [convolution_def, (L _).map_add, Pi.add_apply, integral_add hfg hfg'] theorem ConvolutionExists.distrib_add (hfg : ConvolutionExists f g L μ) (hfg' : ConvolutionExists f g' L μ) : f ⋆[L, μ] (g + g') = f ⋆[L, μ] g + f ⋆[L, μ] g' := by ext x exact (hfg x).distrib_add (hfg' x) theorem ConvolutionExistsAt.add_distrib {x : G} (hfg : ConvolutionExistsAt f g x L μ) (hfg' : ConvolutionExistsAt f' g x L μ) : ((f + f') ⋆[L, μ] g) x = (f ⋆[L, μ] g) x + (f' ⋆[L, μ] g) x := by simp only [convolution_def, L.map_add₂, Pi.add_apply, integral_add hfg hfg'] theorem ConvolutionExists.add_distrib (hfg : ConvolutionExists f g L μ) (hfg' : ConvolutionExists f' g L μ) : (f + f') ⋆[L, μ] g = f ⋆[L, μ] g + f' ⋆[L, μ] g := by ext x exact (hfg x).add_distrib (hfg' x) theorem convolution_mono_right {f g g' : G → ℝ} (hfg : ConvolutionExistsAt f g x (lsmul ℝ ℝ) μ) (hfg' : ConvolutionExistsAt f g' x (lsmul ℝ ℝ) μ) (hf : ∀ x, 0 ≤ f x) (hg : ∀ x, g x ≤ g' x) : (f ⋆[lsmul ℝ ℝ, μ] g) x ≤ (f ⋆[lsmul ℝ ℝ, μ] g') x := by apply integral_mono hfg hfg' simp only [lsmul_apply, Algebra.id.smul_eq_mul] intro t apply mul_le_mul_of_nonneg_left (hg _) (hf _) theorem convolution_mono_right_of_nonneg {f g g' : G → ℝ} (hfg' : ConvolutionExistsAt f g' x (lsmul ℝ ℝ) μ) (hf : ∀ x, 0 ≤ f x) (hg : ∀ x, g x ≤ g' x) (hg' : ∀ x, 0 ≤ g' x) : (f ⋆[lsmul ℝ ℝ, μ] g) x ≤ (f ⋆[lsmul ℝ ℝ, μ] g') x := by by_cases H : ConvolutionExistsAt f g x (lsmul ℝ ℝ) μ · exact convolution_mono_right H hfg' hf hg have : (f ⋆[lsmul ℝ ℝ, μ] g) x = 0 := integral_undef H rw [this] exact integral_nonneg fun y => mul_nonneg (hf y) (hg' (x - y)) variable (L) theorem convolution_congr [MeasurableAdd₂ G] [MeasurableNeg G] [SFinite μ] [IsAddRightInvariant μ] (h1 : f =ᵐ[μ] f') (h2 : g =ᵐ[μ] g') : f ⋆[L, μ] g = f' ⋆[L, μ] g' := by ext x apply integral_congr_ae exact (h1.prodMk <| h2.comp_tendsto (quasiMeasurePreserving_sub_left_of_right_invariant μ x).tendsto_ae).fun_comp ↿fun x y ↦ L x y theorem support_convolution_subset_swap : support (f ⋆[L, μ] g) ⊆ support g + support f := by intro x h2x by_contra hx apply h2x simp_rw [Set.mem_add, ← exists_and_left, not_exists, not_and_or, notMem_support] at hx rw [convolution_def] convert integral_zero G F using 2 ext t rcases hx (x - t) t with (h | h | h) · rw [h, (L _).map_zero] · rw [h, L.map_zero₂] · exact (h <| sub_add_cancel x t).elim section variable [MeasurableAdd₂ G] [MeasurableNeg G] [SFinite μ] [IsAddRightInvariant μ] theorem Integrable.integrable_convolution (hf : Integrable f μ) (hg : Integrable g μ) : Integrable (f ⋆[L, μ] g) μ := (hf.convolution_integrand L hg).integral_prod_left end variable [TopologicalSpace G] variable [IsTopologicalAddGroup G] protected theorem _root_.HasCompactSupport.convolution [T2Space G] (hcf : HasCompactSupport f) (hcg : HasCompactSupport g) : HasCompactSupport (f ⋆[L, μ] g) := (hcg.isCompact.add hcf).of_isClosed_subset isClosed_closure <| closure_minimal ((support_convolution_subset_swap L).trans <| add_subset_add subset_closure subset_closure) (hcg.isCompact.add hcf).isClosed variable [BorelSpace G] [TopologicalSpace P] /-- The convolution `f * g` is continuous if `f` is locally integrable and `g` is continuous and compactly supported. Version where `g` depends on an additional parameter in a subset `s` of a parameter space `P` (and the compact support `k` is independent of the parameter in `s`). -/ theorem continuousOn_convolution_right_with_param {g : P → G → E'} {s : Set P} {k : Set G} (hk : IsCompact k) (hgs : ∀ p, ∀ x, p ∈ s → x ∉ k → g p x = 0) (hf : LocallyIntegrable f μ) (hg : ContinuousOn ↿g (s ×ˢ univ)) : ContinuousOn (fun q : P × G => (f ⋆[L, μ] g q.1) q.2) (s ×ˢ univ) := by /- First get rid of the case where the space is not locally compact. Then `g` vanishes everywhere and the conclusion is trivial. -/ by_cases H : ∀ p ∈ s, ∀ x, g p x = 0 · apply (continuousOn_const (c := 0)).congr rintro ⟨p, x⟩ ⟨hp, -⟩ apply integral_eq_zero_of_ae (Eventually.of_forall (fun y ↦ ?_)) simp [H p hp _] have : LocallyCompactSpace G := by push_neg at H rcases H with ⟨p, hp, x, hx⟩ have A : support (g p) ⊆ k := support_subset_iff'.2 (fun y hy ↦ hgs p y hp hy) have B : Continuous (g p) := by refine hg.comp_continuous (.prodMk_right _) fun x => ?_ simpa only [prodMk_mem_set_prod_eq, mem_univ, and_true] using hp rcases eq_zero_or_locallyCompactSpace_of_support_subset_isCompact_of_addGroup hk A B with H|H · simp [H] at hx · exact H /- Since `G` is locally compact, one may thicken `k` a little bit into a larger compact set `(-k) + t`, outside of which all functions that appear in the convolution vanish. Then we can apply a continuity statement for integrals depending on a parameter, with respect to locally integrable functions and compactly supported continuous functions. -/ rintro ⟨q₀, x₀⟩ ⟨hq₀, -⟩ obtain ⟨t, t_comp, ht⟩ : ∃ t, IsCompact t ∧ t ∈ 𝓝 x₀ := exists_compact_mem_nhds x₀ let k' : Set G := (-k) +ᵥ t have k'_comp : IsCompact k' := IsCompact.vadd_set hk.neg t_comp let g' : (P × G) → G → E' := fun p x ↦ g p.1 (p.2 - x) let s' : Set (P × G) := s ×ˢ t have A : ContinuousOn g'.uncurry (s' ×ˢ univ) := by have : g'.uncurry = g.uncurry ∘ (fun w ↦ (w.1.1, w.1.2 - w.2)) := by ext y; rfl rw [this] refine hg.comp (by fun_prop) ?_ simp +contextual [s', MapsTo] have B : ContinuousOn (fun a ↦ ∫ x, L (f x) (g' a x) ∂μ) s' := by apply continuousOn_integral_bilinear_of_locally_integrable_of_compact_support L k'_comp A _ (hf.integrableOn_isCompact k'_comp) rintro ⟨p, x⟩ y ⟨hp, hx⟩ hy apply hgs p _ hp contrapose! hy exact ⟨y - x, by simpa using hy, x, hx, by simp⟩ apply ContinuousWithinAt.mono_of_mem_nhdsWithin (B (q₀, x₀) ⟨hq₀, mem_of_mem_nhds ht⟩) exact mem_nhdsWithin_prod_iff.2 ⟨s, self_mem_nhdsWithin, t, nhdsWithin_le_nhds ht, Subset.rfl⟩ /-- The convolution `f * g` is continuous if `f` is locally integrable and `g` is continuous and compactly supported. Version where `g` depends on an additional parameter in an open subset `s` of a parameter space `P` (and the compact support `k` is independent of the parameter in `s`), given in terms of compositions with an additional continuous map. -/ theorem continuousOn_convolution_right_with_param_comp {s : Set P} {v : P → G} (hv : ContinuousOn v s) {g : P → G → E'} {k : Set G} (hk : IsCompact k) (hgs : ∀ p, ∀ x, p ∈ s → x ∉ k → g p x = 0) (hf : LocallyIntegrable f μ) (hg : ContinuousOn ↿g (s ×ˢ univ)) : ContinuousOn (fun x => (f ⋆[L, μ] g x) (v x)) s := by apply (continuousOn_convolution_right_with_param L hk hgs hf hg).comp (continuousOn_id.prodMk hv) intro x hx simp only [hx, prodMk_mem_set_prod_eq, mem_univ, and_self_iff, _root_.id] /-- The convolution is continuous if one function is locally integrable and the other has compact support and is continuous. -/ theorem _root_.HasCompactSupport.continuous_convolution_right (hcg : HasCompactSupport g) (hf : LocallyIntegrable f μ) (hg : Continuous g) : Continuous (f ⋆[L, μ] g) := by rw [← continuousOn_univ] let g' : G → G → E' := fun _ q => g q have : ContinuousOn ↿g' (univ ×ˢ univ) := (hg.comp continuous_snd).continuousOn exact continuousOn_convolution_right_with_param_comp L (continuousOn_univ.2 continuous_id) hcg (fun p x _ hx => image_eq_zero_of_notMem_tsupport hx) hf this /-- The convolution is continuous if one function is integrable and the other is bounded and continuous. -/ theorem _root_.BddAbove.continuous_convolution_right_of_integrable [FirstCountableTopology G] [SecondCountableTopologyEither G E'] (hbg : BddAbove (range fun x => ‖g x‖)) (hf : Integrable f μ) (hg : Continuous g) : Continuous (f ⋆[L, μ] g) := by refine continuous_iff_continuousAt.mpr fun x₀ => ?_ have : ∀ᶠ x in 𝓝 x₀, ∀ᵐ t : G ∂μ, ‖L (f t) (g (x - t))‖ ≤ ‖L‖ * ‖f t‖ * ⨆ i, ‖g i‖ := by filter_upwards with x; filter_upwards with t apply_rules [L.le_of_opNorm₂_le_of_le, le_rfl, le_ciSup hbg (x - t)] refine continuousAt_of_dominated ?_ this ?_ ?_ · exact Eventually.of_forall fun x => hf.aestronglyMeasurable.convolution_integrand_snd' L hg.aestronglyMeasurable · exact (hf.norm.const_mul _).mul_const _ · exact Eventually.of_forall fun t => (L.continuous₂.comp₂ continuous_const <| hg.comp <| continuous_id.sub continuous_const).continuousAt end Group section CommGroup variable [AddCommGroup G] theorem support_convolution_subset : support (f ⋆[L, μ] g) ⊆ support f + support g := (support_convolution_subset_swap L).trans (add_comm _ _).subset variable [IsAddLeftInvariant μ] [IsNegInvariant μ] section Measurable variable [MeasurableNeg G] variable [MeasurableAdd G] /-- Commutativity of convolution -/ theorem convolution_flip : g ⋆[L.flip, μ] f = f ⋆[L, μ] g := by ext1 x simp_rw [convolution_def] rw [← integral_sub_left_eq_self _ μ x] simp_rw [sub_sub_self, flip_apply] /-- The symmetric definition of convolution. -/ theorem convolution_eq_swap : (f ⋆[L, μ] g) x = ∫ t, L (f (x - t)) (g t) ∂μ := by rw [← convolution_flip]; rfl /-- The symmetric definition of convolution where the bilinear operator is scalar multiplication. -/ theorem convolution_lsmul_swap {f : G → 𝕜} {g : G → F} : (f ⋆[lsmul 𝕜 𝕜, μ] g : G → F) x = ∫ t, f (x - t) • g t ∂μ := convolution_eq_swap _ /-- The symmetric definition of convolution where the bilinear operator is multiplication. -/ theorem convolution_mul_swap [NormedSpace ℝ 𝕜] {f : G → 𝕜} {g : G → 𝕜} : (f ⋆[mul 𝕜 𝕜, μ] g) x = ∫ t, f (x - t) * g t ∂μ := convolution_eq_swap _ /-- The convolution of two even functions is also even. -/ theorem convolution_neg_of_neg_eq (h1 : ∀ᵐ x ∂μ, f (-x) = f x) (h2 : ∀ᵐ x ∂μ, g (-x) = g x) : (f ⋆[L, μ] g) (-x) = (f ⋆[L, μ] g) x := calc ∫ t : G, (L (f t)) (g (-x - t)) ∂μ = ∫ t : G, (L (f (-t))) (g (x + t)) ∂μ := by apply integral_congr_ae filter_upwards [h1, (eventually_add_left_iff μ x).2 h2] with t ht h't simp_rw [ht, ← h't, neg_add'] _ = ∫ t : G, (L (f t)) (g (x - t)) ∂μ := by rw [← integral_neg_eq_self] simp only [neg_neg, ← sub_eq_add_neg] end Measurable variable [TopologicalSpace G] variable [IsTopologicalAddGroup G] variable [BorelSpace G] theorem _root_.HasCompactSupport.continuous_convolution_left (hcf : HasCompactSupport f) (hf : Continuous f) (hg : LocallyIntegrable g μ) : Continuous (f ⋆[L, μ] g) := by rw [← convolution_flip] exact hcf.continuous_convolution_right L.flip hg hf theorem _root_.BddAbove.continuous_convolution_left_of_integrable [FirstCountableTopology G] [SecondCountableTopologyEither G E] (hbf : BddAbove (range fun x => ‖f x‖)) (hf : Continuous f) (hg : Integrable g μ) : Continuous (f ⋆[L, μ] g) := by rw [← convolution_flip] exact hbf.continuous_convolution_right_of_integrable L.flip hg hf end CommGroup section NormedAddCommGroup variable [SeminormedAddCommGroup G] /-- Compute `(f ⋆ g) x₀` if the support of the `f` is within `Metric.ball 0 R`, and `g` is constant on `Metric.ball x₀ R`. We can simplify the RHS further if we assume `f` is integrable, but also if `L = (•)` or more generally if `L` has an `AntilipschitzWith`-condition. -/ theorem convolution_eq_right' {x₀ : G} {R : ℝ} (hf : support f ⊆ ball (0 : G) R) (hg : ∀ x ∈ ball x₀ R, g x = g x₀) : (f ⋆[L, μ] g) x₀ = ∫ t, L (f t) (g x₀) ∂μ := by have h2 : ∀ t, L (f t) (g (x₀ - t)) = L (f t) (g x₀) := fun t ↦ by by_cases ht : t ∈ support f · have h2t := hf ht rw [mem_ball_zero_iff] at h2t specialize hg (x₀ - t) rw [sub_eq_add_neg, add_mem_ball_iff_norm, norm_neg, ← sub_eq_add_neg] at hg rw [hg h2t] · rw [notMem_support] at ht simp_rw [ht, L.map_zero₂] simp_rw [convolution_def, h2] variable [BorelSpace G] [SecondCountableTopology G] variable [IsAddLeftInvariant μ] [SFinite μ] /-- Approximate `(f ⋆ g) x₀` if the support of the `f` is bounded within a ball, and `g` is near `g x₀` on a ball with the same radius around `x₀`. See `dist_convolution_le` for a special case. We can simplify the second argument of `dist` further if we add some extra type-classes on `E` and `𝕜` or if `L` is scalar multiplication. -/ theorem dist_convolution_le' {x₀ : G} {R ε : ℝ} {z₀ : E'} (hε : 0 ≤ ε) (hif : Integrable f μ) (hf : support f ⊆ ball (0 : G) R) (hmg : AEStronglyMeasurable g μ) (hg : ∀ x ∈ ball x₀ R, dist (g x) z₀ ≤ ε) : dist ((f ⋆[L, μ] g : G → F) x₀) (∫ t, L (f t) z₀ ∂μ) ≤ (‖L‖ * ∫ x, ‖f x‖ ∂μ) * ε := by have hfg : ConvolutionExistsAt f g x₀ L μ := by refine BddAbove.convolutionExistsAt L ?_ Metric.isOpen_ball.measurableSet (Subset.trans ?_ hf) hif.integrableOn hmg swap; · refine fun t => mt fun ht : f t = 0 => ?_; simp_rw [ht, L.map_zero₂] rw [bddAbove_def] refine ⟨‖z₀‖ + ε, ?_⟩ rintro _ ⟨x, hx, rfl⟩ refine norm_le_norm_add_const_of_dist_le (hg x ?_) rwa [mem_ball_iff_norm, norm_sub_rev, ← mem_ball_zero_iff] have h2 : ∀ t, dist (L (f t) (g (x₀ - t))) (L (f t) z₀) ≤ ‖L (f t)‖ * ε := by intro t; by_cases ht : t ∈ support f · have h2t := hf ht rw [mem_ball_zero_iff] at h2t specialize hg (x₀ - t) rw [sub_eq_add_neg, add_mem_ball_iff_norm, norm_neg, ← sub_eq_add_neg] at hg refine ((L (f t)).dist_le_opNorm _ _).trans ?_ exact mul_le_mul_of_nonneg_left (hg h2t) (norm_nonneg _) · rw [notMem_support] at ht simp_rw [ht, L.map_zero₂, L.map_zero, norm_zero, zero_mul, dist_self] rfl simp_rw [convolution_def] simp_rw [dist_eq_norm] at h2 ⊢ rw [← integral_sub hfg.integrable]; swap; · exact (L.flip z₀).integrable_comp hif refine (norm_integral_le_of_norm_le ((L.integrable_comp hif).norm.mul_const ε) (Eventually.of_forall h2)).trans ?_ rw [integral_mul_const] refine mul_le_mul_of_nonneg_right ?_ hε have h3 : ∀ t, ‖L (f t)‖ ≤ ‖L‖ * ‖f t‖ := by intro t exact L.le_opNorm (f t) refine (integral_mono (L.integrable_comp hif).norm (hif.norm.const_mul _) h3).trans_eq ?_ rw [integral_const_mul] variable [NormedSpace ℝ E] [NormedSpace ℝ E'] [CompleteSpace E'] /-- Approximate `f ⋆ g` if the support of the `f` is bounded within a ball, and `g` is near `g x₀` on a ball with the same radius around `x₀`. This is a special case of `dist_convolution_le'` where `L` is `(•)`, `f` has integral 1 and `f` is nonnegative. -/ theorem dist_convolution_le {f : G → ℝ} {x₀ : G} {R ε : ℝ} {z₀ : E'} (hε : 0 ≤ ε) (hf : support f ⊆ ball (0 : G) R) (hnf : ∀ x, 0 ≤ f x) (hintf : ∫ x, f x ∂μ = 1) (hmg : AEStronglyMeasurable g μ) (hg : ∀ x ∈ ball x₀ R, dist (g x) z₀ ≤ ε) : dist ((f ⋆[lsmul ℝ ℝ, μ] g : G → E') x₀) z₀ ≤ ε := by have hif : Integrable f μ := integrable_of_integral_eq_one hintf convert (dist_convolution_le' (lsmul ℝ ℝ) hε hif hf hmg hg).trans _ · simp_rw [lsmul_apply, integral_smul_const, hintf, one_smul] · simp_rw [Real.norm_of_nonneg (hnf _), hintf, mul_one] exact (mul_le_mul_of_nonneg_right opNorm_lsmul_le hε).trans_eq (one_mul ε) /-- `(φ i ⋆ g i) (k i)` tends to `z₀` as `i` tends to some filter `l` if * `φ` is a sequence of nonnegative functions with integral `1` as `i` tends to `l`; * The support of `φ` tends to small neighborhoods around `(0 : G)` as `i` tends to `l`; * `g i` is `mu`-a.e. strongly measurable as `i` tends to `l`; * `g i x` tends to `z₀` as `(i, x)` tends to `l ×ˢ 𝓝 x₀`; * `k i` tends to `x₀`. See also `ContDiffBump.convolution_tendsto_right`. -/ theorem convolution_tendsto_right {ι} {g : ι → G → E'} {l : Filter ι} {x₀ : G} {z₀ : E'} {φ : ι → G → ℝ} {k : ι → G} (hnφ : ∀ᶠ i in l, ∀ x, 0 ≤ φ i x) (hiφ : ∀ᶠ i in l, ∫ x, φ i x ∂μ = 1) -- todo: we could weaken this to "the integral tends to 1" (hφ : Tendsto (fun n => support (φ n)) l (𝓝 0).smallSets) (hmg : ∀ᶠ i in l, AEStronglyMeasurable (g i) μ) (hcg : Tendsto (uncurry g) (l ×ˢ 𝓝 x₀) (𝓝 z₀)) (hk : Tendsto k l (𝓝 x₀)) : Tendsto (fun i : ι => (φ i ⋆[lsmul ℝ ℝ, μ] g i : G → E') (k i)) l (𝓝 z₀) := by simp_rw [tendsto_smallSets_iff] at hφ rw [Metric.tendsto_nhds] at hcg ⊢ simp_rw [Metric.eventually_prod_nhds_iff] at hcg intro ε hε have h2ε : 0 < ε / 3 := div_pos hε (by simp) obtain ⟨p, hp, δ, hδ, hgδ⟩ := hcg _ h2ε dsimp only [uncurry] at hgδ have h2k := hk.eventually (ball_mem_nhds x₀ <| half_pos hδ) have h2φ := hφ (ball (0 : G) _) <| ball_mem_nhds _ (half_pos hδ) filter_upwards [hp, h2k, h2φ, hnφ, hiφ, hmg] with i hpi hki hφi hnφi hiφi hmgi have hgi : dist (g i (k i)) z₀ < ε / 3 := hgδ hpi (hki.trans <| half_lt_self hδ) have h1 : ∀ x' ∈ ball (k i) (δ / 2), dist (g i x') (g i (k i)) ≤ ε / 3 + ε / 3 := by intro x' hx' refine (dist_triangle_right _ _ _).trans (add_le_add (hgδ hpi ?_).le hgi.le) exact ((dist_triangle _ _ _).trans_lt (add_lt_add hx'.out hki)).trans_eq (add_halves δ) have := dist_convolution_le (add_pos h2ε h2ε).le hφi hnφi hiφi hmgi h1 refine ((dist_triangle _ _ _).trans_lt (add_lt_add_of_le_of_lt this hgi)).trans_eq ?_ field_simp; ring_nf end NormedAddCommGroup end Measurability end NontriviallyNormedField open scoped Convolution section RCLike variable [RCLike 𝕜] variable [NormedSpace 𝕜 E] variable [NormedSpace 𝕜 E'] variable [NormedSpace 𝕜 E''] variable [NormedSpace ℝ F] [NormedSpace 𝕜 F] variable {n : ℕ∞} variable [MeasurableSpace G] {μ ν : Measure G} variable (L : E →L[𝕜] E' →L[𝕜] F) section Assoc variable [CompleteSpace F] variable [NormedAddCommGroup F'] [NormedSpace ℝ F'] [NormedSpace 𝕜 F'] [CompleteSpace F'] variable [NormedAddCommGroup F''] [NormedSpace ℝ F''] [NormedSpace 𝕜 F''] [CompleteSpace F''] variable {k : G → E''} variable (L₂ : F →L[𝕜] E'' →L[𝕜] F') variable (L₃ : E →L[𝕜] F'' →L[𝕜] F') variable (L₄ : E' →L[𝕜] E'' →L[𝕜] F'') variable [AddGroup G] variable [SFinite μ] [SFinite ν] [IsAddRightInvariant μ] theorem integral_convolution [MeasurableAdd₂ G] [MeasurableNeg G] [NormedSpace ℝ E] [NormedSpace ℝ E'] [CompleteSpace E] [CompleteSpace E'] (hf : Integrable f ν) (hg : Integrable g μ) : ∫ x, (f ⋆[L, ν] g) x ∂μ = L (∫ x, f x ∂ν) (∫ x, g x ∂μ) := by refine (integral_integral_swap (by apply hf.convolution_integrand L hg)).trans ?_ simp_rw [integral_comp_comm _ (hg.comp_sub_right _), integral_sub_right_eq_self] exact (L.flip (∫ x, g x ∂μ)).integral_comp_comm hf variable [MeasurableAdd₂ G] [IsAddRightInvariant ν] [MeasurableNeg G] /-- Convolution is associative. This has a weak but inconvenient integrability condition. See also `MeasureTheory.convolution_assoc`. -/ theorem convolution_assoc' (hL : ∀ (x : E) (y : E') (z : E''), L₂ (L x y) z = L₃ x (L₄ y z)) {x₀ : G} (hfg : ∀ᵐ y ∂μ, ConvolutionExistsAt f g y L ν) (hgk : ∀ᵐ x ∂ν, ConvolutionExistsAt g k x L₄ μ) (hi : Integrable (uncurry fun x y => (L₃ (f y)) ((L₄ (g (x - y))) (k (x₀ - x)))) (μ.prod ν)) : ((f ⋆[L, ν] g) ⋆[L₂, μ] k) x₀ = (f ⋆[L₃, ν] g ⋆[L₄, μ] k) x₀ := calc ((f ⋆[L, ν] g) ⋆[L₂, μ] k) x₀ = ∫ t, L₂ (∫ s, L (f s) (g (t - s)) ∂ν) (k (x₀ - t)) ∂μ := rfl _ = ∫ t, ∫ s, L₂ (L (f s) (g (t - s))) (k (x₀ - t)) ∂ν ∂μ := (integral_congr_ae (hfg.mono fun t ht => ((L₂.flip (k (x₀ - t))).integral_comp_comm ht).symm)) _ = ∫ t, ∫ s, L₃ (f s) (L₄ (g (t - s)) (k (x₀ - t))) ∂ν ∂μ := by simp_rw [hL] _ = ∫ s, ∫ t, L₃ (f s) (L₄ (g (t - s)) (k (x₀ - t))) ∂μ ∂ν := by rw [integral_integral_swap hi] _ = ∫ s, ∫ u, L₃ (f s) (L₄ (g u) (k (x₀ - s - u))) ∂μ ∂ν := by congr; ext t rw [eq_comm, ← integral_sub_right_eq_self _ t] simp_rw [sub_sub_sub_cancel_right] _ = ∫ s, L₃ (f s) (∫ u, L₄ (g u) (k (x₀ - s - u)) ∂μ) ∂ν := by refine integral_congr_ae ?_ refine ((quasiMeasurePreserving_sub_left_of_right_invariant ν x₀).ae hgk).mono fun t ht => ?_ exact (L₃ (f t)).integral_comp_comm ht _ = (f ⋆[L₃, ν] g ⋆[L₄, μ] k) x₀ := rfl /-- Convolution is associative. This requires that * all maps are a.e. strongly measurable w.r.t one of the measures * `f ⋆[L, ν] g` exists almost everywhere * `‖g‖ ⋆[μ] ‖k‖` exists almost everywhere * `‖f‖ ⋆[ν] (‖g‖ ⋆[μ] ‖k‖)` exists at `x₀` -/ theorem convolution_assoc (hL : ∀ (x : E) (y : E') (z : E''), L₂ (L x y) z = L₃ x (L₄ y z)) {x₀ : G} (hf : AEStronglyMeasurable f ν) (hg : AEStronglyMeasurable g μ) (hk : AEStronglyMeasurable k μ) (hfg : ∀ᵐ y ∂μ, ConvolutionExistsAt f g y L ν) (hgk : ∀ᵐ x ∂ν, ConvolutionExistsAt (fun x => ‖g x‖) (fun x => ‖k x‖) x (mul ℝ ℝ) μ) (hfgk : ConvolutionExistsAt (fun x => ‖f x‖) ((fun x => ‖g x‖) ⋆[mul ℝ ℝ, μ] fun x => ‖k x‖) x₀ (mul ℝ ℝ) ν) : ((f ⋆[L, ν] g) ⋆[L₂, μ] k) x₀ = (f ⋆[L₃, ν] g ⋆[L₄, μ] k) x₀ := by refine convolution_assoc' L L₂ L₃ L₄ hL hfg (hgk.mono fun x hx => hx.of_norm L₄ hg hk) ?_ -- the following is similar to `Integrable.convolution_integrand` have h_meas : AEStronglyMeasurable (uncurry fun x y => L₃ (f y) (L₄ (g x) (k (x₀ - y - x)))) (μ.prod ν) := by refine L₃.aestronglyMeasurable_comp₂ hf.comp_snd ?_ refine L₄.aestronglyMeasurable_comp₂ hg.comp_fst ?_ refine (hk.mono_ac ?_).comp_measurable ((measurable_const.sub measurable_snd).sub measurable_fst) refine QuasiMeasurePreserving.absolutelyContinuous ?_ refine QuasiMeasurePreserving.prod_of_left ((measurable_const.sub measurable_snd).sub measurable_fst) (Eventually.of_forall fun y => ?_) dsimp only exact quasiMeasurePreserving_sub_left_of_right_invariant μ _ have h2_meas : AEStronglyMeasurable (fun y => ∫ x, ‖L₃ (f y) (L₄ (g x) (k (x₀ - y - x)))‖ ∂μ) ν := h_meas.prod_swap.norm.integral_prod_right' have h3 : map (fun z : G × G => (z.1 - z.2, z.2)) (μ.prod ν) = μ.prod ν := (measurePreserving_sub_prod μ ν).map_eq suffices Integrable (uncurry fun x y => L₃ (f y) (L₄ (g x) (k (x₀ - y - x)))) (μ.prod ν) by rw [← h3] at this convert this.comp_measurable (measurable_sub.prodMk measurable_snd) ext ⟨x, y⟩ simp +unfoldPartialApp only [uncurry, Function.comp_apply, sub_sub_sub_cancel_right] simp_rw [integrable_prod_iff' h_meas] refine ⟨((quasiMeasurePreserving_sub_left_of_right_invariant ν x₀).ae hgk).mono fun t ht => (L₃ (f t)).integrable_comp <| ht.of_norm L₄ hg hk, ?_⟩ refine (hfgk.const_mul (‖L₃‖ * ‖L₄‖)).mono' h2_meas (((quasiMeasurePreserving_sub_left_of_right_invariant ν x₀).ae hgk).mono fun t ht => ?_) simp_rw [convolution_def, mul_apply', mul_mul_mul_comm ‖L₃‖ ‖L₄‖, ← integral_const_mul] rw [Real.norm_of_nonneg (by positivity)] refine integral_mono_of_nonneg (Eventually.of_forall fun t => norm_nonneg _) ((ht.const_mul _).const_mul _) (Eventually.of_forall fun s => ?_) simp only [← mul_assoc ‖L₄‖] apply_rules [ContinuousLinearMap.le_of_opNorm₂_le_of_le, le_rfl] end Assoc variable [NormedAddCommGroup G] [BorelSpace G] theorem convolution_precompR_apply {g : G → E'' →L[𝕜] E'} (hf : LocallyIntegrable f μ) (hcg : HasCompactSupport g) (hg : Continuous g) (x₀ : G) (x : E'') : (f ⋆[L.precompR E'', μ] g) x₀ x = (f ⋆[L, μ] fun a => g a x) x₀ := by have := hcg.convolutionExists_right (L.precompR E'' :) hf hg x₀ simp_rw [convolution_def, ContinuousLinearMap.integral_apply this] rfl variable [NormedSpace 𝕜 G] [SFinite μ] [IsAddLeftInvariant μ] /-- Compute the total derivative of `f ⋆ g` if `g` is `C^1` with compact support and `f` is locally integrable. To write down the total derivative as a convolution, we use `ContinuousLinearMap.precompR`. -/ theorem _root_.HasCompactSupport.hasFDerivAt_convolution_right (hcg : HasCompactSupport g) (hf : LocallyIntegrable f μ) (hg : ContDiff 𝕜 1 g) (x₀ : G) : HasFDerivAt (f ⋆[L, μ] g) ((f ⋆[L.precompR G, μ] fderiv 𝕜 g) x₀) x₀ := by rcases hcg.eq_zero_or_finiteDimensional 𝕜 hg.continuous with (rfl | fin_dim) · have : fderiv 𝕜 (0 : G → E') = 0 := fderiv_const (0 : E') simp only [this, convolution_zero, Pi.zero_apply] exact hasFDerivAt_const (0 : F) x₀ have : ProperSpace G := FiniteDimensional.proper_rclike 𝕜 G set L' := L.precompR G have h1 : ∀ᶠ x in 𝓝 x₀, AEStronglyMeasurable (fun t => L (f t) (g (x - t))) μ := Eventually.of_forall (hf.aestronglyMeasurable.convolution_integrand_snd L hg.continuous.aestronglyMeasurable) have h2 : ∀ x, AEStronglyMeasurable (fun t => L' (f t) (fderiv 𝕜 g (x - t))) μ := hf.aestronglyMeasurable.convolution_integrand_snd L' (hg.continuous_fderiv le_rfl).aestronglyMeasurable have h3 : ∀ x t, HasFDerivAt (fun x => g (x - t)) (fderiv 𝕜 g (x - t)) x := fun x t ↦ by simpa using (hg.differentiable le_rfl).differentiableAt.hasFDerivAt.comp x ((hasFDerivAt_id x).sub (hasFDerivAt_const t x)) let K' := -tsupport (fderiv 𝕜 g) + closedBall x₀ 1 have hK' : IsCompact K' := (hcg.fderiv 𝕜).isCompact.neg.add (isCompact_closedBall x₀ 1) apply hasFDerivAt_integral_of_dominated_of_fderiv_le zero_lt_one h1 _ (h2 x₀) · filter_upwards with t x hx using (hcg.fderiv 𝕜).convolution_integrand_bound_right L' (hg.continuous_fderiv le_rfl) (ball_subset_closedBall hx) · rw [integrable_indicator_iff hK'.measurableSet] exact ((hf.integrableOn_isCompact hK').norm.const_mul _).mul_const _ · exact Eventually.of_forall fun t x _ => (L _).hasFDerivAt.comp x (h3 x t) · exact hcg.convolutionExists_right L hf hg.continuous x₀ theorem _root_.HasCompactSupport.hasFDerivAt_convolution_left [IsNegInvariant μ] (hcf : HasCompactSupport f) (hf : ContDiff 𝕜 1 f) (hg : LocallyIntegrable g μ) (x₀ : G) : HasFDerivAt (f ⋆[L, μ] g) ((fderiv 𝕜 f ⋆[L.precompL G, μ] g) x₀) x₀ := by simp +singlePass only [← convolution_flip] exact hcf.hasFDerivAt_convolution_right L.flip hg hf x₀ end RCLike section Real /-! The one-variable case -/ variable [RCLike 𝕜] variable [NormedSpace 𝕜 E] variable [NormedSpace 𝕜 E'] variable [NormedSpace ℝ F] [NormedSpace 𝕜 F] variable {f₀ : 𝕜 → E} {g₀ : 𝕜 → E'} variable {n : ℕ∞} variable (L : E →L[𝕜] E' →L[𝕜] F) variable {μ : Measure 𝕜} variable [IsAddLeftInvariant μ] [SFinite μ] theorem _root_.HasCompactSupport.hasDerivAt_convolution_right (hf : LocallyIntegrable f₀ μ) (hcg : HasCompactSupport g₀) (hg : ContDiff 𝕜 1 g₀) (x₀ : 𝕜) : HasDerivAt (f₀ ⋆[L, μ] g₀) ((f₀ ⋆[L, μ] deriv g₀) x₀) x₀ := by convert (hcg.hasFDerivAt_convolution_right L hf hg x₀).hasDerivAt using 1 rw [convolution_precompR_apply L hf (hcg.fderiv 𝕜) (hg.continuous_fderiv le_rfl)] rfl theorem _root_.HasCompactSupport.hasDerivAt_convolution_left [IsNegInvariant μ] (hcf : HasCompactSupport f₀) (hf : ContDiff 𝕜 1 f₀) (hg : LocallyIntegrable g₀ μ) (x₀ : 𝕜) : HasDerivAt (f₀ ⋆[L, μ] g₀) ((deriv f₀ ⋆[L, μ] g₀) x₀) x₀ := by simp +singlePass only [← convolution_flip] exact hcf.hasDerivAt_convolution_right L.flip hg hf x₀ end Real section WithParam variable [RCLike 𝕜] [NormedSpace 𝕜 E] [NormedSpace 𝕜 E'] [NormedSpace 𝕜 E''] [NormedSpace ℝ F] [NormedSpace 𝕜 F] [MeasurableSpace G] [NormedAddCommGroup G] [BorelSpace G] [NormedSpace 𝕜 G] [NormedAddCommGroup P] [NormedSpace 𝕜 P] {μ : Measure G} (L : E →L[𝕜] E' →L[𝕜] F) /-- The derivative of the convolution `f * g` is given by `f * Dg`, when `f` is locally integrable and `g` is `C^1` and compactly supported. Version where `g` depends on an additional parameter in an open subset `s` of a parameter space `P` (and the compact support `k` is independent of the parameter in `s`). -/ theorem hasFDerivAt_convolution_right_with_param {g : P → G → E'} {s : Set P} {k : Set G} (hs : IsOpen s) (hk : IsCompact k) (hgs : ∀ p, ∀ x, p ∈ s → x ∉ k → g p x = 0) (hf : LocallyIntegrable f μ) (hg : ContDiffOn 𝕜 1 ↿g (s ×ˢ univ)) (q₀ : P × G) (hq₀ : q₀.1 ∈ s) : HasFDerivAt (fun q : P × G => (f ⋆[L, μ] g q.1) q.2) ((f ⋆[L.precompR (P × G), μ] fun x : G => fderiv 𝕜 ↿g (q₀.1, x)) q₀.2) q₀ := by let g' := fderiv 𝕜 ↿g have A : ∀ p ∈ s, Continuous (g p) := fun p hp ↦ by refine hg.continuousOn.comp_continuous (.prodMk_right _) fun x => ?_ simpa only [prodMk_mem_set_prod_eq, mem_univ, and_true] using hp have A' : ∀ q : P × G, q.1 ∈ s → s ×ˢ univ ∈ 𝓝 q := fun q hq ↦ by apply (hs.prod isOpen_univ).mem_nhds simpa only [mem_prod, mem_univ, and_true] using hq -- The derivative of `g` vanishes away from `k`. have g'_zero : ∀ p x, p ∈ s → x ∉ k → g' (p, x) = 0 := by intro p x hp hx refine (hasFDerivAt_zero_of_eventually_const 0 ?_).fderiv have M2 : kᶜ ∈ 𝓝 x := hk.isClosed.isOpen_compl.mem_nhds hx have M1 : s ∈ 𝓝 p := hs.mem_nhds hp rw [nhds_prod_eq] filter_upwards [prod_mem_prod M1 M2] rintro ⟨p, y⟩ ⟨hp, hy⟩ exact hgs p y hp hy /- We find a small neighborhood of `{q₀.1} × k` on which the derivative is uniformly bounded. This follows from the continuity at all points of the compact set `k`. -/ obtain ⟨ε, C, εpos, h₀ε, hε⟩ : ∃ ε C, 0 < ε ∧ ball q₀.1 ε ⊆ s ∧ ∀ p x, ‖p - q₀.1‖ < ε → ‖g' (p, x)‖ ≤ C := by have A : IsCompact ({q₀.1} ×ˢ k) := isCompact_singleton.prod hk obtain ⟨t, kt, t_open, ht⟩ : ∃ t, {q₀.1} ×ˢ k ⊆ t ∧ IsOpen t ∧ IsBounded (g' '' t) := by have B : ContinuousOn g' (s ×ˢ univ) := hg.continuousOn_fderiv_of_isOpen (hs.prod isOpen_univ) le_rfl apply exists_isOpen_isBounded_image_of_isCompact_of_continuousOn A (hs.prod isOpen_univ) _ B simp only [prod_subset_prod_iff, hq₀, singleton_subset_iff, subset_univ, and_self_iff, true_or] obtain ⟨ε, εpos, hε, h'ε⟩ : ∃ ε : ℝ, 0 < ε ∧ thickening ε ({q₀.fst} ×ˢ k) ⊆ t ∧ ball q₀.1 ε ⊆ s := by obtain ⟨ε, εpos, hε⟩ : ∃ ε : ℝ, 0 < ε ∧ thickening ε (({q₀.fst} : Set P) ×ˢ k) ⊆ t := A.exists_thickening_subset_open t_open kt obtain ⟨δ, δpos, hδ⟩ : ∃ δ : ℝ, 0 < δ ∧ ball q₀.1 δ ⊆ s := Metric.isOpen_iff.1 hs _ hq₀ refine ⟨min ε δ, lt_min εpos δpos, ?_, ?_⟩ · exact Subset.trans (thickening_mono (min_le_left _ _) _) hε · exact Subset.trans (ball_subset_ball (min_le_right _ _)) hδ obtain ⟨C, Cpos, hC⟩ : ∃ C, 0 < C ∧ g' '' t ⊆ closedBall 0 C := ht.subset_closedBall_lt 0 0 refine ⟨ε, C, εpos, h'ε, fun p x hp => ?_⟩ have hps : p ∈ s := h'ε (mem_ball_iff_norm.2 hp) by_cases hx : x ∈ k · have H : (p, x) ∈ t := by apply hε refine mem_thickening_iff.2 ⟨(q₀.1, x), ?_, ?_⟩ · simp only [hx, singleton_prod, mem_image, Prod.mk_inj, true_and, exists_eq_right] · rw [← dist_eq_norm] at hp simpa only [Prod.dist_eq, εpos, dist_self, max_lt_iff, and_true] using hp have : g' (p, x) ∈ closedBall (0 : P × G →L[𝕜] E') C := hC (mem_image_of_mem _ H) rwa [mem_closedBall_zero_iff] at this · have : g' (p, x) = 0 := g'_zero _ _ hps hx rw [this] simpa only [norm_zero] using Cpos.le /- Now, we wish to apply a theorem on differentiation of integrals. For this, we need to check trivial measurability or integrability assumptions (in `I1`, `I2`, `I3`), as well as a uniform integrability assumption over the derivative (in `I4` and `I5`) and pointwise differentiability in `I6`. -/ have I1 : ∀ᶠ x : P × G in 𝓝 q₀, AEStronglyMeasurable (fun a : G => L (f a) (g x.1 (x.2 - a))) μ := by filter_upwards [A' q₀ hq₀] rintro ⟨p, x⟩ ⟨hp, -⟩ refine (HasCompactSupport.convolutionExists_right L ?_ hf (A _ hp) _).1 apply hk.of_isClosed_subset (isClosed_tsupport _) exact closure_minimal (support_subset_iff'.2 fun z hz => hgs _ _ hp hz) hk.isClosed have I2 : Integrable (fun a : G => L (f a) (g q₀.1 (q₀.2 - a))) μ := by have M : HasCompactSupport (g q₀.1) := HasCompactSupport.intro hk fun x hx => hgs q₀.1 x hq₀ hx apply M.convolutionExists_right L hf (A q₀.1 hq₀) q₀.2 have I3 : AEStronglyMeasurable (fun a : G => (L (f a)).comp (g' (q₀.fst, q₀.snd - a))) μ := by have T : HasCompactSupport fun y => g' (q₀.1, y) := HasCompactSupport.intro hk fun x hx => g'_zero q₀.1 x hq₀ hx apply (HasCompactSupport.convolutionExists_right (L.precompR (P × G) :) T hf _ q₀.2).1 have : ContinuousOn g' (s ×ˢ univ) := hg.continuousOn_fderiv_of_isOpen (hs.prod isOpen_univ) le_rfl apply this.comp_continuous (.prodMk_right _) intro x simpa only [prodMk_mem_set_prod_eq, mem_univ, and_true] using hq₀ set K' := (-k + {q₀.2} : Set G) with K'_def have hK' : IsCompact K' := hk.neg.add isCompact_singleton obtain ⟨U, U_open, K'U, hU⟩ : ∃ U, IsOpen U ∧ K' ⊆ U ∧ IntegrableOn f U μ := hf.integrableOn_nhds_isCompact hK' obtain ⟨δ, δpos, δε, hδ⟩ : ∃ δ, (0 : ℝ) < δ ∧ δ ≤ ε ∧ K' + ball 0 δ ⊆ U := by obtain ⟨V, V_mem, hV⟩ : ∃ V ∈ 𝓝 (0 : G), K' + V ⊆ U := compact_open_separated_add_right hK' U_open K'U rcases Metric.mem_nhds_iff.1 V_mem with ⟨δ, δpos, hδ⟩ refine ⟨min δ ε, lt_min δpos εpos, min_le_right δ ε, ?_⟩ exact (add_subset_add_left ((ball_subset_ball (min_le_left _ _)).trans hδ)).trans hV letI := ContinuousLinearMap.hasOpNorm (𝕜 := 𝕜) (𝕜₂ := 𝕜) (E := E) (F := (P × G →L[𝕜] E') →L[𝕜] P × G →L[𝕜] F) (σ₁₂ := RingHom.id 𝕜) let bound : G → ℝ := indicator U fun t => ‖(L.precompR (P × G))‖ * ‖f t‖ * C have I4 : ∀ᵐ a : G ∂μ, ∀ x : P × G, dist x q₀ < δ → ‖L.precompR (P × G) (f a) (g' (x.fst, x.snd - a))‖ ≤ bound a := by filter_upwards with a x hx rw [Prod.dist_eq, dist_eq_norm, dist_eq_norm] at hx have : (-tsupport fun a => g' (x.1, a)) + ball q₀.2 δ ⊆ U := by apply Subset.trans _ hδ rw [K'_def, add_assoc] apply add_subset_add · rw [neg_subset_neg] refine closure_minimal (support_subset_iff'.2 fun z hz => ?_) hk.isClosed apply g'_zero x.1 z (h₀ε _) hz rw [mem_ball_iff_norm] exact ((le_max_left _ _).trans_lt hx).trans_le δε · simp only [add_ball, thickening_singleton, zero_vadd, subset_rfl] apply convolution_integrand_bound_right_of_le_of_subset _ _ _ this · intro y exact hε _ _ (((le_max_left _ _).trans_lt hx).trans_le δε) · rw [mem_ball_iff_norm] exact (le_max_right _ _).trans_lt hx have I5 : Integrable bound μ := by rw [integrable_indicator_iff U_open.measurableSet] exact (hU.norm.const_mul _).mul_const _ have I6 : ∀ᵐ a : G ∂μ, ∀ x : P × G, dist x q₀ < δ → HasFDerivAt (fun x : P × G => L (f a) (g x.1 (x.2 - a))) ((L (f a)).comp (g' (x.fst, x.snd - a))) x := by filter_upwards with a x hx apply (L _).hasFDerivAt.comp x have N : s ×ˢ univ ∈ 𝓝 (x.1, x.2 - a) := by apply A' apply h₀ε rw [Prod.dist_eq] at hx exact lt_of_lt_of_le (lt_of_le_of_lt (le_max_left _ _) hx) δε have Z := ((hg.differentiableOn le_rfl).differentiableAt N).hasFDerivAt have Z' : HasFDerivAt (fun x : P × G => (x.1, x.2 - a)) (ContinuousLinearMap.id 𝕜 (P × G)) x := by have : (fun x : P × G => (x.1, x.2 - a)) = _root_.id - fun x => (0, a) := by ext x <;> simp only [Pi.sub_apply, _root_.id, Prod.fst_sub, sub_zero, Prod.snd_sub] rw [this] exact (hasFDerivAt_id x).sub_const (0, a) exact Z.comp x Z' exact hasFDerivAt_integral_of_dominated_of_fderiv_le δpos I1 I2 I3 I4 I5 I6 /-- The convolution `f * g` is `C^n` when `f` is locally integrable and `g` is `C^n` and compactly supported. Version where `g` depends on an additional parameter in an open subset `s` of a parameter space `P` (and the compact support `k` is independent of the parameter in `s`). In this version, all the types belong to the same universe (to get an induction working in the proof). Use instead `contDiffOn_convolution_right_with_param`, which removes this restriction. -/ theorem contDiffOn_convolution_right_with_param_aux {G : Type uP} {E' : Type uP} {F : Type uP} {P : Type uP} [NormedAddCommGroup E'] [NormedAddCommGroup F] [NormedSpace 𝕜 E'] [NormedSpace ℝ F] [NormedSpace 𝕜 F] [MeasurableSpace G] {μ : Measure G} [NormedAddCommGroup G] [BorelSpace G] [NormedSpace 𝕜 G] [NormedAddCommGroup P] [NormedSpace 𝕜 P] {f : G → E} {n : ℕ∞} (L : E →L[𝕜] E' →L[𝕜] F) {g : P → G → E'} {s : Set P} {k : Set G} (hs : IsOpen s) (hk : IsCompact k) (hgs : ∀ p, ∀ x, p ∈ s → x ∉ k → g p x = 0) (hf : LocallyIntegrable f μ) (hg : ContDiffOn 𝕜 n ↿g (s ×ˢ univ)) : ContDiffOn 𝕜 n (fun q : P × G => (f ⋆[L, μ] g q.1) q.2) (s ×ˢ univ) := by /- We have a formula for the derivation of `f * g`, which is of the same form, thanks to `hasFDerivAt_convolution_right_with_param`. Therefore, we can prove the result by induction on `n` (but for this we need the spaces at the different steps of the induction to live in the same universe, which is why we make the assumption in the lemma that all the relevant spaces come from the same universe). -/ induction n using ENat.nat_induction generalizing g E' F with | h0 => rw [WithTop.coe_zero, contDiffOn_zero] at hg ⊢ exact continuousOn_convolution_right_with_param L hk hgs hf hg | hsuc n ih => simp only [Nat.succ_eq_add_one, Nat.cast_add, Nat.cast_one, WithTop.coe_add, WithTop.coe_natCast, WithTop.coe_one] at hg ⊢ let f' : P → G → P × G →L[𝕜] F := fun p a => (f ⋆[L.precompR (P × G), μ] fun x : G => fderiv 𝕜 (uncurry g) (p, x)) a have A : ∀ q₀ : P × G, q₀.1 ∈ s → HasFDerivAt (fun q : P × G => (f ⋆[L, μ] g q.1) q.2) (f' q₀.1 q₀.2) q₀ := hasFDerivAt_convolution_right_with_param L hs hk hgs hf hg.one_of_succ rw [contDiffOn_succ_iff_fderiv_of_isOpen (hs.prod (@isOpen_univ G _))] at hg ⊢ refine ⟨?_, by simp, ?_⟩ · rintro ⟨p, x⟩ ⟨hp, -⟩ exact (A (p, x) hp).differentiableAt.differentiableWithinAt · suffices H : ContDiffOn 𝕜 n ↿f' (s ×ˢ univ) by apply H.congr rintro ⟨p, x⟩ ⟨hp, -⟩ exact (A (p, x) hp).fderiv have B : ∀ (p : P) (x : G), p ∈ s → x ∉ k → fderiv 𝕜 (uncurry g) (p, x) = 0 := by intro p x hp hx apply (hasFDerivAt_zero_of_eventually_const (0 : E') _).fderiv have M2 : kᶜ ∈ 𝓝 x := IsOpen.mem_nhds hk.isClosed.isOpen_compl hx have M1 : s ∈ 𝓝 p := hs.mem_nhds hp rw [nhds_prod_eq] filter_upwards [prod_mem_prod M1 M2] rintro ⟨p, y⟩ ⟨hp, hy⟩ exact hgs p y hp hy apply ih (L.precompR (P × G) :) B convert hg.2.2 | htop ih => rw [contDiffOn_infty] at hg ⊢ exact fun n ↦ ih n L hgs (hg n) /-- The convolution `f * g` is `C^n` when `f` is locally integrable and `g` is `C^n` and compactly supported. Version where `g` depends on an additional parameter in an open subset `s` of a parameter space `P` (and the compact support `k` is independent of the parameter in `s`). -/ theorem contDiffOn_convolution_right_with_param {f : G → E} {n : ℕ∞} (L : E →L[𝕜] E' →L[𝕜] F) {g : P → G → E'} {s : Set P} {k : Set G} (hs : IsOpen s) (hk : IsCompact k) (hgs : ∀ p, ∀ x, p ∈ s → x ∉ k → g p x = 0) (hf : LocallyIntegrable f μ) (hg : ContDiffOn 𝕜 n ↿g (s ×ˢ univ)) : ContDiffOn 𝕜 n (fun q : P × G => (f ⋆[L, μ] g q.1) q.2) (s ×ˢ univ) := by /- The result is known when all the universes are the same, from `contDiffOn_convolution_right_with_param_aux`. We reduce to this situation by pushing everything through `ULift` continuous linear equivalences. -/ let eG : Type max uG uE' uF uP := ULift.{max uE' uF uP} G borelize eG let eE' : Type max uE' uG uF uP := ULift.{max uG uF uP} E' let eF : Type max uF uG uE' uP := ULift.{max uG uE' uP} F let eP : Type max uP uG uE' uF := ULift.{max uG uE' uF} P let isoG : eG ≃L[𝕜] G := ContinuousLinearEquiv.ulift let isoE' : eE' ≃L[𝕜] E' := ContinuousLinearEquiv.ulift let isoF : eF ≃L[𝕜] F := ContinuousLinearEquiv.ulift let isoP : eP ≃L[𝕜] P := ContinuousLinearEquiv.ulift let ef := f ∘ isoG let eμ : Measure eG := Measure.map isoG.symm μ let eg : eP → eG → eE' := fun ep ex => isoE'.symm (g (isoP ep) (isoG ex)) let eL := ContinuousLinearMap.comp ((ContinuousLinearEquiv.arrowCongr isoE' isoF).symm : (E' →L[𝕜] F) →L[𝕜] eE' →L[𝕜] eF) L let R := fun q : eP × eG => (ef ⋆[eL, eμ] eg q.1) q.2 have R_contdiff : ContDiffOn 𝕜 n R ((isoP ⁻¹' s) ×ˢ univ) := by have hek : IsCompact (isoG ⁻¹' k) := isoG.toHomeomorph.isClosedEmbedding.isCompact_preimage hk have hes : IsOpen (isoP ⁻¹' s) := isoP.continuous.isOpen_preimage _ hs refine contDiffOn_convolution_right_with_param_aux eL hes hek ?_ ?_ ?_ · intro p x hp hx simp only [eg, ContinuousLinearEquiv.map_eq_zero_iff] exact hgs _ _ hp hx · exact (locallyIntegrable_map_homeomorph isoG.symm.toHomeomorph).2 hf · apply isoE'.symm.contDiff.comp_contDiffOn apply hg.comp (isoP.prodCongr isoG).contDiff.contDiffOn rintro ⟨p, x⟩ ⟨hp, -⟩ simpa only [mem_preimage, ContinuousLinearEquiv.prodCongr_apply, prodMk_mem_set_prod_eq, mem_univ, and_true] using hp have A : ContDiffOn 𝕜 n (isoF ∘ R ∘ (isoP.prodCongr isoG).symm) (s ×ˢ univ) := by apply isoF.contDiff.comp_contDiffOn apply R_contdiff.comp (ContinuousLinearEquiv.contDiff _).contDiffOn rintro ⟨p, x⟩ ⟨hp, -⟩ simpa only [mem_preimage, mem_prod, mem_univ, and_true, ContinuousLinearEquiv.prodCongr_symm, ContinuousLinearEquiv.prodCongr_apply, ContinuousLinearEquiv.apply_symm_apply] using hp have : isoF ∘ R ∘ (isoP.prodCongr isoG).symm = fun q : P × G => (f ⋆[L, μ] g q.1) q.2 := by apply funext rintro ⟨p, x⟩ simp only [(· ∘ ·), ContinuousLinearEquiv.prodCongr_symm, ContinuousLinearEquiv.prodCongr_apply] simp only [R, convolution] rw [IsClosedEmbedding.integral_map, ← isoF.integral_comp_comm] · rfl · exact isoG.symm.toHomeomorph.isClosedEmbedding simp_rw [this] at A exact A /-- The convolution `f * g` is `C^n` when `f` is locally integrable and `g` is `C^n` and compactly supported. Version where `g` depends on an additional parameter in an open subset `s` of a parameter space `P` (and the compact support `k` is independent of the parameter in `s`), given in terms of composition with an additional `C^n` function. -/ theorem contDiffOn_convolution_right_with_param_comp {n : ℕ∞} (L : E →L[𝕜] E' →L[𝕜] F) {s : Set P} {v : P → G} (hv : ContDiffOn 𝕜 n v s) {f : G → E} {g : P → G → E'} {k : Set G} (hs : IsOpen s) (hk : IsCompact k) (hgs : ∀ p, ∀ x, p ∈ s → x ∉ k → g p x = 0) (hf : LocallyIntegrable f μ) (hg : ContDiffOn 𝕜 n ↿g (s ×ˢ univ)) : ContDiffOn 𝕜 n (fun x => (f ⋆[L, μ] g x) (v x)) s := by apply (contDiffOn_convolution_right_with_param L hs hk hgs hf hg).comp (contDiffOn_id.prodMk hv) intro x hx simp only [hx, prodMk_mem_set_prod_eq, mem_univ, and_self_iff, _root_.id] /-- The convolution `g * f` is `C^n` when `f` is locally integrable and `g` is `C^n` and compactly supported. Version where `g` depends on an additional parameter in an open subset `s` of a parameter space `P` (and the compact support `k` is independent of the parameter in `s`). -/ theorem contDiffOn_convolution_left_with_param [μ.IsAddLeftInvariant] [μ.IsNegInvariant] (L : E' →L[𝕜] E →L[𝕜] F) {f : G → E} {n : ℕ∞} {g : P → G → E'} {s : Set P} {k : Set G} (hs : IsOpen s) (hk : IsCompact k) (hgs : ∀ p, ∀ x, p ∈ s → x ∉ k → g p x = 0) (hf : LocallyIntegrable f μ) (hg : ContDiffOn 𝕜 n ↿g (s ×ˢ univ)) : ContDiffOn 𝕜 n (fun q : P × G => (g q.1 ⋆[L, μ] f) q.2) (s ×ˢ univ) := by simpa only [convolution_flip] using contDiffOn_convolution_right_with_param L.flip hs hk hgs hf hg /-- The convolution `g * f` is `C^n` when `f` is locally integrable and `g` is `C^n` and compactly supported. Version where `g` depends on an additional parameter in an open subset `s` of a parameter space `P` (and the compact support `k` is independent of the parameter in `s`), given in terms of composition with additional `C^n` functions. -/ theorem contDiffOn_convolution_left_with_param_comp [μ.IsAddLeftInvariant] [μ.IsNegInvariant] (L : E' →L[𝕜] E →L[𝕜] F) {s : Set P} {n : ℕ∞} {v : P → G} (hv : ContDiffOn 𝕜 n v s) {f : G → E} {g : P → G → E'} {k : Set G} (hs : IsOpen s) (hk : IsCompact k) (hgs : ∀ p, ∀ x, p ∈ s → x ∉ k → g p x = 0) (hf : LocallyIntegrable f μ) (hg : ContDiffOn 𝕜 n ↿g (s ×ˢ univ)) : ContDiffOn 𝕜 n (fun x => (g x ⋆[L, μ] f) (v x)) s := by apply (contDiffOn_convolution_left_with_param L hs hk hgs hf hg).comp (contDiffOn_id.prodMk hv) intro x hx simp only [hx, prodMk_mem_set_prod_eq, mem_univ, and_self_iff, _root_.id] theorem _root_.HasCompactSupport.contDiff_convolution_right {n : ℕ∞} (hcg : HasCompactSupport g) (hf : LocallyIntegrable f μ) (hg : ContDiff 𝕜 n g) : ContDiff 𝕜 n (f ⋆[L, μ] g) := by rcases exists_compact_iff_hasCompactSupport.2 hcg with ⟨k, hk, h'k⟩ rw [← contDiffOn_univ] exact contDiffOn_convolution_right_with_param_comp L contDiffOn_id isOpen_univ hk (fun p x _ hx => h'k x hx) hf (hg.comp contDiff_snd).contDiffOn theorem _root_.HasCompactSupport.contDiff_convolution_left [μ.IsAddLeftInvariant] [μ.IsNegInvariant] {n : ℕ∞} (hcf : HasCompactSupport f) (hf : ContDiff 𝕜 n f) (hg : LocallyIntegrable g μ) : ContDiff 𝕜 n (f ⋆[L, μ] g) := by rw [← convolution_flip] exact hcf.contDiff_convolution_right L.flip hg hf end WithParam section Nonneg variable [NormedSpace ℝ E] [NormedSpace ℝ E'] [NormedSpace ℝ F] /-- The forward convolution of two functions `f` and `g` on `ℝ`, with respect to a continuous bilinear map `L` and measure `ν`. It is defined to be the function mapping `x` to `∫ t in 0..x, L (f t) (g (x - t)) ∂ν` if `0 < x`, and 0 otherwise. -/ noncomputable def posConvolution (f : ℝ → E) (g : ℝ → E') (L : E →L[ℝ] E' →L[ℝ] F) (ν : Measure ℝ := by volume_tac) : ℝ → F := indicator (Ioi (0 : ℝ)) fun x => ∫ t in (0)..x, L (f t) (g (x - t)) ∂ν theorem posConvolution_eq_convolution_indicator (f : ℝ → E) (g : ℝ → E') (L : E →L[ℝ] E' →L[ℝ] F) (ν : Measure ℝ := by volume_tac) [NoAtoms ν] : posConvolution f g L ν = convolution (indicator (Ioi 0) f) (indicator (Ioi 0) g) L ν := by ext1 x rw [convolution, posConvolution, indicator] split_ifs with h · rw [intervalIntegral.integral_of_le (le_of_lt h), integral_Ioc_eq_integral_Ioo, ← integral_indicator (measurableSet_Ioo : MeasurableSet (Ioo 0 x))] congr 1 with t : 1 have : t ≤ 0 ∨ t ∈ Ioo 0 x ∨ x ≤ t := by rcases le_or_gt t 0 with (h | h) · exact Or.inl h · rcases lt_or_ge t x with (h' | h') exacts [Or.inr (Or.inl ⟨h, h'⟩), Or.inr (Or.inr h')] rcases this with (ht | ht | ht) · rw [indicator_of_notMem (notMem_Ioo_of_le ht), indicator_of_notMem (notMem_Ioi.mpr ht), ContinuousLinearMap.map_zero, ContinuousLinearMap.zero_apply] · rw [indicator_of_mem ht, indicator_of_mem (mem_Ioi.mpr ht.1), indicator_of_mem (mem_Ioi.mpr <| sub_pos.mpr ht.2)] · rw [indicator_of_notMem (notMem_Ioo_of_ge ht), indicator_of_notMem (notMem_Ioi.mpr (sub_nonpos_of_le ht)), ContinuousLinearMap.map_zero] · convert (integral_zero ℝ F).symm with t by_cases ht : 0 < t · rw [indicator_of_notMem (_ : x - t ∉ Ioi 0), ContinuousLinearMap.map_zero] rw [notMem_Ioi] at h ⊢ exact sub_nonpos.mpr (h.trans ht.le) · rw [indicator_of_notMem (mem_Ioi.not.mpr ht), ContinuousLinearMap.map_zero, ContinuousLinearMap.zero_apply] theorem integrable_posConvolution {f : ℝ → E} {g : ℝ → E'} {μ ν : Measure ℝ} [SFinite μ] [SFinite ν] [IsAddRightInvariant μ] [NoAtoms ν] (hf : IntegrableOn f (Ioi 0) ν) (hg : IntegrableOn g (Ioi 0) μ) (L : E →L[ℝ] E' →L[ℝ] F) : Integrable (posConvolution f g L ν) μ := by rw [← integrable_indicator_iff (measurableSet_Ioi : MeasurableSet (Ioi (0 : ℝ)))] at hf hg rw [posConvolution_eq_convolution_indicator f g L ν] exact (hf.convolution_integrand L hg).integral_prod_left /-- The integral over `Ioi 0` of a forward convolution of two functions is equal to the product of their integrals over this set. (Compare `integral_convolution` for the two-sided convolution.) -/ theorem integral_posConvolution [CompleteSpace E] [CompleteSpace E'] [CompleteSpace F] {μ ν : Measure ℝ} [SFinite μ] [SFinite ν] [IsAddRightInvariant μ] [NoAtoms ν] {f : ℝ → E} {g : ℝ → E'} (hf : IntegrableOn f (Ioi 0) ν) (hg : IntegrableOn g (Ioi 0) μ) (L : E →L[ℝ] E' →L[ℝ] F) : ∫ x : ℝ in Ioi 0, ∫ t : ℝ in (0)..x, L (f t) (g (x - t)) ∂ν ∂μ = L (∫ x : ℝ in Ioi 0, f x ∂ν) (∫ x : ℝ in Ioi 0, g x ∂μ) := by rw [← integrable_indicator_iff measurableSet_Ioi] at hf hg simp_rw [← integral_indicator measurableSet_Ioi] convert integral_convolution L hf hg using 4 with x apply posConvolution_eq_convolution_indicator end Nonneg end MeasureTheory
ErwQuestion.lean
/- Copyright (c) 2025 Lean FRO, LLC. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kim Morrison -/ import Mathlib.Init import Lean.Elab.Tactic.Rewrite /-! # The `erw?` tactic `erw? [r, ...]` calls `erw [r, ...]` (at hypothesis `h` if written `erw [r, ...] at h`), and then attempts to identify any subexpression which would block the use of `rw` instead. It does so by identifying subexpressions which are defeq, but not at reducible transparency. -/ open Lean Parser.Tactic Elab Tactic Meta namespace Mathlib.Tactic.Erw? /-- If set to `true`, `erw?` will log more information as it attempts to identify subexpressions which would block the use of `rw` instead. -/ register_option tactic.erw?.verbose : Bool := { defValue := false descr := "`erw?` logs more information as it attempts to identify subexpressions \ which would block the use of `rw` instead." } /-- `erw? [r, ...]` calls `erw [r, ...]` (at hypothesis `h` if written `erw [r, ...] at h`), and then attempts to identify any subexpression which would block the use of `rw` instead. It does so by identifying subexpressions which are defeq, but not at reducible transparency. -/ syntax (name := erw?) "erw? " rwRuleSeq (location)? : tactic local macro_rules | `(term| verbose $e) => `(term| modify (·.push fun _ => $e)) /-- Check if two expressions are different at reducible transparency. Attempt to log an info message for the first subexpressions which are different (but agree at default transparency). Also returns an array of messages for the `verbose` report. -/ def logDiffs (tk : Syntax) (e₁ e₂ : Expr) : StateT (Array (Unit → MessageData)) MetaM Bool := do withOptions (fun opts => opts.setBool `pp.analyze true) do if ← withReducible (isDefEq e₁ e₂) then verbose m!"{checkEmoji} at reducible transparency,\ {indentD e₁}\nand{indentD e₂}\nare defeq." -- They agree at reducible transparency, we're done. return false else verbose m!"{crossEmoji} at reducible transparency,\ {indentD e₁}\nand{indentD e₂}\nare not defeq." if ← isDefEq e₁ e₂ then match e₁, e₂ with | Expr.app f₁ a₁, Expr.app f₂ a₂ => if ← logDiffs tk a₁ a₂ then return true else if ← logDiffs tk f₁ f₂ then return true else logInfoAt tk m!"{crossEmoji} at reducible transparency,\ {indentD e₁}\nand{indentD e₂}\nare not defeq, but they are at default transparency." return true | Expr.const _ _, Expr.const _ _ => logInfoAt tk m!"{crossEmoji} at reducible transparency,\ {indentD e₁}\nand{indentD e₂}\nare not defeq, but they are at default transparency." return true | _, _ => verbose m!"{crossEmoji}{indentD e₁}\nand{indentD e₂}\nare not both applications or constants." return false else verbose m!"{crossEmoji}{indentD e₁}\nand{indentD e₂}\nare not defeq at default transparency." return false /-- Checks that the input `Expr` represents a proof produced by `(e)rw` and returns the types of the LHS of the equality being written (one from the target, the other from the lemma used). These will be defeq, but not necessarily reducibly so. -/ def extractRewriteEq (e : Expr) : MetaM (Expr × Expr) := do let (``Eq.mpr, #[_, _, e, _]) := e.getAppFnArgs | throwError "Unexpected term produced by `erw`, head is not an `Eq.mpr`." let (``id, #[ty, e]) := e.getAppFnArgs | throwError "Unexpected term produced by `erw`, not of the form: `Eq.mpr (id _) _`." let some (_, tgt, _) := ty.eq? | throwError "Unexpected term produced by `erw`, type hint is not an equality." let some (_, inferred, _) := (← inferType e).eq? | throwError "Unexpected term produced by `erw`, inferred type is not an equality." return (tgt, inferred) /-- Checks that the input `Expr` represents a proof produced by `(e)rw at` and returns the type of the LHS of the equality (from the lemma used). This will be defeq to the hypothesis being written, but not necessarily reducibly so. -/ def extractRewriteHypEq (e : Expr) : MetaM Expr := do let (.anonymous, .mk (e :: _)) := e.getAppFnArgs | throwError "Unexpected term produced by `erw at`, head is not an mvar applied to a proof." let (``Eq.mp, #[_, _, e, _]) := e.getAppFnArgs | throwError "Unexpected term produced by `erw at`, head is not an `Eq.mp`." let some (_, inferred, _) := (← inferType e).eq? | throwError "Unexpected term produced by `erw at`, inferred type is not an equality." return inferred elab_rules : tactic | `(tactic| erw?%$tk $rs $(loc)?) => withMainContext do logInfoAt rs "Debugging `erw?`" let verbose := (← getOptions).get `tactic.erw?.verbose (defVal := false) let cfg := { transparency := .default } -- Default transparency turns `rw` into `erw`. -- Follow the implementation of `rw`, using `withRWRulesSeq` followed by -- `rewriteLocalDecl` or `rewriteTarget`. let loc := expandOptLocation (mkOptionalNode loc) withRWRulesSeq tk rs fun symm term => do withLocation loc (fun loc => do let g ← getMainGoal rewriteLocalDecl term symm loc cfg let decl ← loc.getDecl let e := (← instantiateMVars (.mvar g)).headBeta let inferred ← withRef tk do extractRewriteHypEq e let (_, msgs) ← (logDiffs tk decl.type inferred).run #[] if verbose then logInfoAt tk <| .joinSep (m!"Expression appearing in {decl.toExpr}:{indentD decl.type}" :: m!"Expression from `erw`: {inferred}" :: msgs.toList.map (· ())) "\n\n") (do let g ← getMainGoal rewriteTarget term symm cfg evalTactic (←`(tactic| try with_reducible rfl)) let e := (← instantiateMVars (.mvar g)).headBeta let (tgt, inferred) ← withRef tk do extractRewriteEq e let (_, msgs) ← (logDiffs tk tgt inferred).run #[] if verbose then logInfoAt tk <| .joinSep (m!"Expression appearing in target:{indentD tgt}" :: m!"Expression from `erw`: {inferred}" :: msgs.toList.map (· ())) "\n\n") (throwTacticEx `rewrite · "did not find instance of the pattern in the current goal") end Mathlib.Tactic.Erw?
ToFinsupp.lean
/- Copyright (c) 2022 Yakov Pechersky. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yakov Pechersky -/ import Mathlib.Algebra.BigOperators.Group.List.Basic import Mathlib.Algebra.Group.Embedding import Mathlib.Algebra.Group.Finsupp import Mathlib.Algebra.Group.Nat.Defs import Mathlib.Data.List.GetD /-! # Lists as finsupp ## Main definitions - `List.toFinsupp`: Interpret a list as a finitely supported function, where the indexing type is `ℕ`, and the values are either the elements of the list (accessing by indexing) or `0` outside of the list. ## Main theorems - `List.toFinsupp_eq_sum_map_enum_single`: A `l : List M` over `M` an `AddMonoid`, when interpreted as a finitely supported function, is equal to the sum of `Finsupp.single` produced by mapping over `List.enum l`. ## Implementation details The functions defined here rely on a decidability predicate that each element in the list can be decidably determined to be not equal to zero or that one can decide one is out of the bounds of a list. For concretely defined lists that are made up of elements of decidable terms, this holds. More work will be needed to support lists over non-dec-eq types like `ℝ`, where the elements are beyond the dec-eq terms of casted values from `ℕ, ℤ, ℚ`. -/ namespace List variable {M : Type*} [Zero M] (l : List M) [DecidablePred (getD l · 0 ≠ 0)] (n : ℕ) /-- Indexing into a `l : List M`, as a finitely-supported function, where the support are all the indices within the length of the list that index to a non-zero value. Indices beyond the end of the list are sent to 0. This is a computable version of the `Finsupp.onFinset` construction. -/ def toFinsupp : ℕ →₀ M where toFun i := getD l i 0 support := {i ∈ Finset.range l.length | getD l i 0 ≠ 0} mem_support_toFun n := by simp only [Ne, Finset.mem_filter, Finset.mem_range, and_iff_right_iff_imp] contrapose! exact getD_eq_default _ _ @[norm_cast] theorem coe_toFinsupp : (l.toFinsupp : ℕ → M) = (l.getD · 0) := rfl @[simp, norm_cast] theorem toFinsupp_apply (i : ℕ) : (l.toFinsupp : ℕ → M) i = l.getD i 0 := rfl theorem toFinsupp_support : l.toFinsupp.support = {i ∈ Finset.range l.length | getD l i 0 ≠ 0} := rfl theorem toFinsupp_apply_lt (hn : n < l.length) : l.toFinsupp n = l[n] := getD_eq_getElem _ _ hn theorem toFinsupp_apply_fin (n : Fin l.length) : l.toFinsupp n = l[n] := getD_eq_getElem _ _ n.isLt theorem toFinsupp_apply_le (hn : l.length ≤ n) : l.toFinsupp n = 0 := getD_eq_default _ _ hn @[simp] theorem toFinsupp_nil [DecidablePred fun i => getD ([] : List M) i 0 ≠ 0] : toFinsupp ([] : List M) = 0 := by ext simp theorem toFinsupp_singleton (x : M) [DecidablePred (getD [x] · 0 ≠ 0)] : toFinsupp [x] = Finsupp.single 0 x := by ext ⟨_ | i⟩ <;> simp theorem toFinsupp_append {R : Type*} [AddZeroClass R] (l₁ l₂ : List R) [DecidablePred (getD (l₁ ++ l₂) · 0 ≠ 0)] [DecidablePred (getD l₁ · 0 ≠ 0)] [DecidablePred (getD l₂ · 0 ≠ 0)] : toFinsupp (l₁ ++ l₂) = toFinsupp l₁ + (toFinsupp l₂).embDomain (addLeftEmbedding l₁.length) := by ext n simp only [toFinsupp_apply, Finsupp.add_apply] cases lt_or_ge n l₁.length with | inl h => rw [getD_append _ _ _ _ h, Finsupp.embDomain_notin_range, add_zero] rintro ⟨k, rfl : length l₁ + k = n⟩ omega | inr h => rcases Nat.exists_eq_add_of_le h with ⟨k, rfl⟩ rw [getD_append_right _ _ _ _ h, Nat.add_sub_cancel_left, getD_eq_default _ _ h, zero_add] exact Eq.symm (Finsupp.embDomain_apply _ _ _) theorem toFinsupp_cons_eq_single_add_embDomain {R : Type*} [AddZeroClass R] (x : R) (xs : List R) [DecidablePred (getD (x::xs) · 0 ≠ 0)] [DecidablePred (getD xs · 0 ≠ 0)] : toFinsupp (x::xs) = Finsupp.single 0 x + (toFinsupp xs).embDomain ⟨Nat.succ, Nat.succ_injective⟩ := by classical convert toFinsupp_append [x] xs using 3 · exact (toFinsupp_singleton x).symm · ext n exact add_comm n 1 theorem toFinsupp_concat_eq_toFinsupp_add_single {R : Type*} [AddZeroClass R] (x : R) (xs : List R) [DecidablePred fun i => getD (xs ++ [x]) i 0 ≠ 0] [DecidablePred fun i => getD xs i 0 ≠ 0] : toFinsupp (xs ++ [x]) = toFinsupp xs + Finsupp.single xs.length x := by classical rw [toFinsupp_append, toFinsupp_singleton, Finsupp.embDomain_single, addLeftEmbedding_apply, add_zero] theorem toFinsupp_eq_sum_mapIdx_single {R : Type*} [AddMonoid R] (l : List R) [DecidablePred (getD l · 0 ≠ 0)] : toFinsupp l = (l.mapIdx fun n r => Finsupp.single n r).sum := by /- Porting note (https://github.com/leanprover-community/mathlib4/issues/11215): TODO: `induction` fails to substitute `l = []` in `[DecidablePred (getD l · 0 ≠ 0)]`, so we manually do some `revert`/`intro` as a workaround -/ revert l; intro l induction l using List.reverseRecOn with | nil => exact toFinsupp_nil | append_singleton x xs ih => classical simp [toFinsupp_concat_eq_toFinsupp_add_single, ih] end List
LevelOne.lean
/- Copyright (c) 2024 Chris Birkbeck. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Birkbeck -/ import Mathlib.Analysis.Complex.AbsMax import Mathlib.NumberTheory.Modular import Mathlib.NumberTheory.ModularForms.QExpansion /-! # Level one modular forms This file contains results specific to modular forms of level one, ie. modular forms for `SL(2, ℤ)`. TODO: Add finite-dimensionality of these spaces of modular forms. -/ open UpperHalfPlane ModularGroup SlashInvariantForm ModularForm Complex CongruenceSubgroup Real Function SlashInvariantFormClass ModularFormClass Periodic local notation "𝕢" => qParam variable {F : Type*} [FunLike F ℍ ℂ] {k : ℤ} namespace SlashInvariantForm variable [SlashInvariantFormClass F Γ(1) k] lemma exists_one_half_le_im_and_norm_le (hk : k ≤ 0) (f : F) (τ : ℍ) : ∃ ξ : ℍ, 1 / 2 ≤ ξ.im ∧ ‖f τ‖ ≤ ‖f ξ‖ := let ⟨γ, hγ, hdenom⟩ := exists_one_half_le_im_smul_and_norm_denom_le τ ⟨γ • τ, hγ, by simpa only [slash_action_eqn'' _ (mem_Gamma_one γ), norm_mul, norm_zpow] using le_mul_of_one_le_left (norm_nonneg _) <| one_le_zpow_of_nonpos₀ (norm_pos_iff.2 (denom_ne_zero _ _)) hdenom hk⟩ variable (k) in /-- If a constant function is modular of weight `k`, then either `k = 0`, or the constant is `0`. -/ lemma wt_eq_zero_of_eq_const {f : F} {c : ℂ} (hf : ⇑f = Function.const _ c) : k = 0 ∨ c = 0 := by have hI := slash_action_eqn'' f (mem_Gamma_one S) I have h2I2 := slash_action_eqn'' f (mem_Gamma_one S) ⟨2 * Complex.I, by norm_num⟩ simp_rw [sl_moeb, hf, Function.const, denom_S, coe_mk_subtype] at hI h2I2 nth_rw 1 [h2I2] at hI simp only [mul_zpow, coe_I, mul_eq_mul_right_iff, mul_left_eq_self₀] at hI refine hI.imp_left (Or.casesOn · (fun H ↦ ?_) (False.elim ∘ zpow_ne_zero k I_ne_zero)) rwa [← ofReal_ofNat, ← ofReal_zpow, ← ofReal_one, ofReal_inj, zpow_eq_one_iff_right₀ (by norm_num) (by norm_num)] at H end SlashInvariantForm namespace ModularFormClass variable [ModularFormClass F Γ(1) k] private theorem cuspFunction_eqOn_const_of_nonpos_wt (hk : k ≤ 0) (f : F) : Set.EqOn (cuspFunction 1 f) (const ℂ (cuspFunction 1 f 0)) (Metric.ball 0 1) := by refine eq_const_of_exists_le (fun q hq ↦ ?_) (exp_nonneg (-π)) ?_ (fun q hq ↦ ?_) · exact (differentiableAt_cuspFunction 1 f (mem_ball_zero_iff.mp hq)).differentiableWithinAt · simp only [exp_lt_one_iff, Left.neg_neg_iff, pi_pos] · simp only [Metric.mem_closedBall, dist_zero_right] rcases eq_or_ne q 0 with rfl | hq' · refine ⟨0, by simpa only [norm_zero] using exp_nonneg _, le_rfl⟩ · obtain ⟨ξ, hξ, hξ₂⟩ := exists_one_half_le_im_and_norm_le hk f ⟨_, im_invQParam_pos_of_norm_lt_one Real.zero_lt_one (mem_ball_zero_iff.mp hq) hq'⟩ exact ⟨_, norm_qParam_le_of_one_half_le_im hξ, by simpa only [← eq_cuspFunction 1 f, Nat.cast_one, coe_mk_subtype, qParam_right_inv one_ne_zero hq'] using hξ₂⟩ private theorem levelOne_nonpos_wt_const (hk : k ≤ 0) (f : F) : ⇑f = Function.const _ (cuspFunction 1 f 0) := by ext z have hQ : 𝕢 1 z ∈ (Metric.ball 0 1) := by simpa only [Metric.mem_ball, dist_zero_right, neg_mul, mul_zero, div_one, Real.exp_zero] using (norm_qParam_lt_iff zero_lt_one 0 z.1).mpr z.2 simpa only [← eq_cuspFunction 1 f z, Nat.cast_one, Function.const_apply] using (cuspFunction_eqOn_const_of_nonpos_wt hk f) hQ lemma levelOne_neg_weight_eq_zero (hk : k < 0) (f : F) : ⇑f = 0 := by have hf := levelOne_nonpos_wt_const hk.le f rcases wt_eq_zero_of_eq_const k hf with rfl | hf₀ · exact (lt_irrefl _ hk).elim · rw [hf, hf₀, const_zero] lemma levelOne_weight_zero_const [ModularFormClass F Γ(1) 0] (f : F) : ∃ c, ⇑f = Function.const _ c := ⟨_, levelOne_nonpos_wt_const le_rfl f⟩ end ModularFormClass lemma ModularForm.levelOne_weight_zero_rank_one : Module.rank ℂ (ModularForm Γ(1) 0) = 1 := by refine rank_eq_one (const 1) (by simp [DFunLike.ne_iff]) fun g ↦ ?_ obtain ⟨c', hc'⟩ := levelOne_weight_zero_const g aesop lemma ModularForm.levelOne_neg_weight_rank_zero (hk : k < 0) : Module.rank ℂ (ModularForm Γ(1) k) = 0 := by refine rank_eq_zero_iff.mpr fun f ↦ ⟨_, one_ne_zero, ?_⟩ simpa only [one_smul, ← DFunLike.coe_injective.eq_iff] using levelOne_neg_weight_eq_zero hk f
Basic.lean
/- Copyright (c) 2023 Adam Topaz. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Adam Topaz, Dagur Asgeirsson -/ import Mathlib.Topology.ExtremallyDisconnected import Mathlib.Topology.Category.CompHaus.Projective import Mathlib.Topology.Category.Profinite.Basic /-! # Extremally disconnected sets This file develops some of the basic theory of extremally disconnected compact Hausdorff spaces. ## Overview This file defines the type `Stonean` of all extremally (note: not "extremely"!) disconnected compact Hausdorff spaces, gives it the structure of a large category, and proves some basic observations about this category and various functors from it. The Lean implementation: a term of type `Stonean` is a pair, considering of a term of type `CompHaus` (i.e. a compact Hausdorff topological space) plus a proof that the space is extremally disconnected. This is equivalent to the assertion that the term is projective in `CompHaus`, in the sense of category theory (i.e., such that morphisms out of the object can be lifted along epimorphisms). ## Main definitions * `Stonean` : the category of extremally disconnected compact Hausdorff spaces. * `Stonean.toCompHaus` : the forgetful functor `Stonean ⥤ CompHaus` from Stonean spaces to compact Hausdorff spaces * `Stonean.toProfinite` : the functor from Stonean spaces to profinite spaces. ## Implementation The category `Stonean` is defined using the structure `CompHausLike`. See the file `CompHausLike.Basic` for more information. -/ universe u open CategoryTheory open scoped Topology /-- `Stonean` is the category of extremally disconnected compact Hausdorff spaces. -/ abbrev Stonean := CompHausLike (fun X ↦ ExtremallyDisconnected X) namespace CompHaus /-- `Projective` implies `ExtremallyDisconnected`. -/ instance (X : CompHaus.{u}) [Projective X] : ExtremallyDisconnected X := by apply CompactT2.Projective.extremallyDisconnected intro A B _ _ _ _ _ _ f g hf hg hsurj let A' : CompHaus := CompHaus.of A let B' : CompHaus := CompHaus.of B let f' : X ⟶ B' := CompHausLike.ofHom _ ⟨f, hf⟩ let g' : A' ⟶ B' := CompHausLike.ofHom _ ⟨g,hg⟩ have : Epi g' := by rw [CompHaus.epi_iff_surjective] assumption obtain ⟨h, hh⟩ := Projective.factors f' g' refine ⟨h, h.hom.2, ?_⟩ ext t apply_fun (fun e => e t) at hh exact hh /-- `Projective` implies `Stonean`. -/ @[simps!] def toStonean (X : CompHaus.{u}) [Projective X] : Stonean where toTop := X.toTop prop := inferInstance end CompHaus namespace Stonean /-- The (forgetful) functor from Stonean spaces to compact Hausdorff spaces. -/ abbrev toCompHaus : Stonean.{u} ⥤ CompHaus.{u} := compHausLikeToCompHaus _ /-- The forgetful functor `Stonean ⥤ CompHaus` is fully faithful. -/ abbrev fullyFaithfulToCompHaus : toCompHaus.FullyFaithful := CompHausLike.fullyFaithfulToCompHausLike _ open CompHausLike instance (X : Type*) [TopologicalSpace X] [ExtremallyDisconnected X] : HasProp (fun Y ↦ ExtremallyDisconnected Y) X := ⟨(inferInstance : ExtremallyDisconnected X)⟩ /-- Construct a term of `Stonean` from a type endowed with the structure of a compact, Hausdorff and extremally disconnected topological space. -/ abbrev of (X : Type*) [TopologicalSpace X] [CompactSpace X] [T2Space X] [ExtremallyDisconnected X] : Stonean := CompHausLike.of _ X instance (X : Stonean.{u}) : ExtremallyDisconnected X := X.prop /-- The functor from Stonean spaces to profinite spaces. -/ abbrev toProfinite : Stonean.{u} ⥤ Profinite.{u} := CompHausLike.toCompHausLike (fun _ ↦ inferInstance) /-- A finite discrete space as a Stonean space. -/ def mkFinite (X : Type*) [Finite X] [TopologicalSpace X] [DiscreteTopology X] : Stonean where toTop := (CompHaus.of X).toTop prop := by dsimp constructor intro U _ apply isOpen_discrete (closure U) /-- A morphism in `Stonean` is an epi iff it is surjective. -/ lemma epi_iff_surjective {X Y : Stonean} (f : X ⟶ Y) : Epi f ↔ Function.Surjective f := by refine ⟨?_, fun h => ConcreteCategory.epi_of_surjective f h⟩ dsimp [Function.Surjective] intro h y by_contra! hy let C := Set.range f have hC : IsClosed C := (isCompact_range f.hom.continuous).isClosed let U := Cᶜ have hUy : U ∈ 𝓝 y := by simp only [U, C, Set.mem_range, hy, exists_false, not_false_eq_true, hC.compl_mem_nhds] obtain ⟨V, hV, hyV, hVU⟩ := isTopologicalBasis_isClopen.mem_nhds_iff.mp hUy classical let g : Y ⟶ mkFinite (ULift (Fin 2)) := TopCat.ofHom ⟨(LocallyConstant.ofIsClopen hV).map ULift.up, LocallyConstant.continuous _⟩ let h : Y ⟶ mkFinite (ULift (Fin 2)) := TopCat.ofHom ⟨fun _ => ⟨1⟩, continuous_const⟩ have H : h = g := by rw [← cancel_epi f] ext x apply ULift.ext -- why is `ext` not doing this automatically? change 1 = ite _ _ _ -- why is `dsimp` not getting me here? rw [if_neg] refine mt (hVU ·) ?_ -- what would be an idiomatic tactic for this step? simpa only [U, Set.mem_compl_iff, Set.mem_range, not_exists, not_forall, not_not] using exists_apply_eq_apply f x apply_fun fun e => (e y).down at H change 1 = ite _ _ _ at H -- why is `dsimp at H` not getting me here? rw [if_pos hyV] at H exact one_ne_zero H /-- Every Stonean space is projective in `CompHaus` -/ instance instProjectiveCompHausCompHaus (X : Stonean) : Projective (toCompHaus.obj X) where factors := by intro B C φ f _ haveI : ExtremallyDisconnected (toCompHaus.obj X).toTop := X.prop have hf : Function.Surjective f := by rwa [← CompHaus.epi_iff_surjective] obtain ⟨f', h⟩ := CompactT2.ExtremallyDisconnected.projective φ.hom.continuous f.hom.continuous hf use ofHom _ ⟨f', h.left⟩ ext exact congr_fun h.right _ /-- Every Stonean space is projective in `Profinite` -/ instance (X : Stonean) : Projective (toProfinite.obj X) where factors := by intro B C φ f _ haveI : ExtremallyDisconnected (toProfinite.obj X) := X.prop have hf : Function.Surjective f := by rwa [← Profinite.epi_iff_surjective] obtain ⟨f', h⟩ := CompactT2.ExtremallyDisconnected.projective φ.hom.continuous f.hom.continuous hf use ofHom _ ⟨f', h.left⟩ ext exact congr_fun h.right _ /-- Every Stonean space is projective in `Stonean`. -/ instance (X : Stonean) : Projective X where factors := by intro B C φ f _ haveI : ExtremallyDisconnected X.toTop := X.prop have hf : Function.Surjective f := by rwa [← Stonean.epi_iff_surjective] obtain ⟨f', h⟩ := CompactT2.ExtremallyDisconnected.projective φ.hom.continuous f.hom.continuous hf use ofHom _ ⟨f', h.left⟩ ext exact congr_fun h.right _ end Stonean namespace CompHaus /-- If `X` is compact Hausdorff, `presentation X` is a Stonean space equipped with an epimorphism down to `X` (see `CompHaus.presentation.π` and `CompHaus.presentation.epi_π`). It is a "constructive" witness to the fact that `CompHaus` has enough projectives. -/ noncomputable def presentation (X : CompHaus) : Stonean where toTop := (projectivePresentation X).p.1 prop := instExtremallyDisconnectedCarrierToTopTrueOfProjective X.projectivePresentation.p /-- The morphism from `presentation X` to `X`. -/ noncomputable def presentation.π (X : CompHaus) : Stonean.toCompHaus.obj X.presentation ⟶ X := (projectivePresentation X).f /-- The morphism from `presentation X` to `X` is an epimorphism. -/ noncomputable instance presentation.epi_π (X : CompHaus) : Epi (π X) := (projectivePresentation X).epi /-- The underlying `CompHaus` of a `Stonean`. -/ abbrev _root_.Stonean.compHaus (X : Stonean) := Stonean.toCompHaus.obj X /-- ``` X | (f) | \/ Z ---(e)---> Y ``` If `Z` is a Stonean space, `f : X ⟶ Y` an epi in `CompHaus` and `e : Z ⟶ Y` is arbitrary, then `lift e f` is a fixed (but arbitrary) lift of `e` to a morphism `Z ⟶ X`. It exists because `Z` is a projective object in `CompHaus`. -/ noncomputable def lift {X Y : CompHaus} {Z : Stonean} (e : Z.compHaus ⟶ Y) (f : X ⟶ Y) [Epi f] : Z.compHaus ⟶ X := Projective.factorThru e f @[simp, reassoc] lemma lift_lifts {X Y : CompHaus} {Z : Stonean} (e : Z.compHaus ⟶ Y) (f : X ⟶ Y) [Epi f] : lift e f ≫ f = e := by simp [lift] lemma Gleason (X : CompHaus.{u}) : Projective X ↔ ExtremallyDisconnected X := by constructor · intro h change ExtremallyDisconnected X.toStonean infer_instance · intro h let X' : Stonean := ⟨X.toTop, inferInstance⟩ change Projective X'.compHaus apply Stonean.instProjectiveCompHausCompHaus end CompHaus namespace Profinite /-- If `X` is profinite, `presentation X` is a Stonean space equipped with an epimorphism down to `X` (see `Profinite.presentation.π` and `Profinite.presentation.epi_π`). -/ noncomputable def presentation (X : Profinite) : Stonean where toTop := (profiniteToCompHaus.obj X).projectivePresentation.p.toTop prop := (profiniteToCompHaus.obj X).presentation.prop /-- The morphism from `presentation X` to `X`. -/ noncomputable def presentation.π (X : Profinite) : Stonean.toProfinite.obj X.presentation ⟶ X := (profiniteToCompHaus.obj X).projectivePresentation.f /-- The morphism from `presentation X` to `X` is an epimorphism. -/ noncomputable instance presentation.epi_π (X : Profinite) : Epi (π X) := by have := (profiniteToCompHaus.obj X).projectivePresentation.epi rw [CompHaus.epi_iff_surjective] at this rw [epi_iff_surjective] exact this /-- ``` X | (f) | \/ Z ---(e)---> Y ``` If `Z` is a Stonean space, `f : X ⟶ Y` an epi in `Profinite` and `e : Z ⟶ Y` is arbitrary, then `lift e f` is a fixed (but arbitrary) lift of `e` to a morphism `Z ⟶ X`. It is `CompHaus.lift e f` as a morphism in `Profinite`. -/ noncomputable def lift {X Y : Profinite} {Z : Stonean} (e : Stonean.toProfinite.obj Z ⟶ Y) (f : X ⟶ Y) [Epi f] : Stonean.toProfinite.obj Z ⟶ X := Projective.factorThru e f @[simp, reassoc] lemma lift_lifts {X Y : Profinite} {Z : Stonean} (e : Stonean.toProfinite.obj Z ⟶ Y) (f : X ⟶ Y) [Epi f] : lift e f ≫ f = e := by simp [lift] lemma projective_of_extrDisc {X : Profinite.{u}} (hX : ExtremallyDisconnected X) : Projective X := by change Projective (Stonean.toProfinite.obj ⟨X.toTop, inferInstance⟩) exact inferInstance end Profinite
Thickening.lean
/- Copyright (c) 2021 Kalle Kytölä. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kalle Kytölä -/ import Mathlib.Topology.MetricSpace.HausdorffDistance /-! # Thickenings in pseudo-metric spaces ## Main definitions * `Metric.thickening δ s`, the open thickening by radius `δ` of a set `s` in a pseudo emetric space. * `Metric.cthickening δ s`, the closed thickening by radius `δ` of a set `s` in a pseudo emetric space. ## Main results * `Disjoint.exists_thickenings`: two disjoint sets admit disjoint thickenings * `Disjoint.exists_cthickenings`: two disjoint sets admit disjoint closed thickenings * `IsCompact.exists_cthickening_subset_open`: if `s` is compact, `t` is open and `s ⊆ t`, some `cthickening` of `s` is contained in `t`. * `Metric.hasBasis_nhdsSet_cthickening`: the `cthickening`s of a compact set `K` form a basis of the neighbourhoods of `K` * `Metric.closure_eq_iInter_cthickening'`: the closure of a set equals the intersection of its closed thickenings of positive radii accumulating at zero. The same holds for open thickenings. * `IsCompact.cthickening_eq_biUnion_closedBall`: if `s` is compact, `cthickening δ s` is the union of `closedBall`s of radius `δ` around `x : E`. -/ noncomputable section open NNReal ENNReal Topology Set Filter Bornology universe u v w variable {ι : Sort*} {α : Type u} namespace Metric section Thickening variable [PseudoEMetricSpace α] {δ : ℝ} {s : Set α} {x : α} open EMetric /-- The (open) `δ`-thickening `Metric.thickening δ E` of a subset `E` in a pseudo emetric space consists of those points that are at distance less than `δ` from some point of `E`. -/ def thickening (δ : ℝ) (E : Set α) : Set α := { x : α | infEdist x E < ENNReal.ofReal δ } theorem mem_thickening_iff_infEdist_lt : x ∈ thickening δ s ↔ infEdist x s < ENNReal.ofReal δ := Iff.rfl /-- An exterior point of a subset `E` (i.e., a point outside the closure of `E`) is not in the (open) `δ`-thickening of `E` for small enough positive `δ`. -/ lemma eventually_notMem_thickening_of_infEdist_pos {E : Set α} {x : α} (h : x ∉ closure E) : ∀ᶠ δ in 𝓝 (0 : ℝ), x ∉ Metric.thickening δ E := by obtain ⟨ε, ⟨ε_pos, ε_lt⟩⟩ := exists_real_pos_lt_infEdist_of_notMem_closure h filter_upwards [eventually_lt_nhds ε_pos] with δ hδ simp only [thickening, mem_setOf_eq, not_lt] exact (ENNReal.ofReal_le_ofReal hδ.le).trans ε_lt.le @[deprecated (since := "2025-05-23")] alias eventually_not_mem_thickening_of_infEdist_pos := eventually_notMem_thickening_of_infEdist_pos /-- The (open) thickening equals the preimage of an open interval under `EMetric.infEdist`. -/ theorem thickening_eq_preimage_infEdist (δ : ℝ) (E : Set α) : thickening δ E = (infEdist · E) ⁻¹' Iio (ENNReal.ofReal δ) := rfl /-- The (open) thickening is an open set. -/ theorem isOpen_thickening {δ : ℝ} {E : Set α} : IsOpen (thickening δ E) := Continuous.isOpen_preimage continuous_infEdist _ isOpen_Iio /-- The (open) thickening of the empty set is empty. -/ @[simp] theorem thickening_empty (δ : ℝ) : thickening δ (∅ : Set α) = ∅ := by simp only [thickening, setOf_false, infEdist_empty, not_top_lt] theorem thickening_of_nonpos (hδ : δ ≤ 0) (s : Set α) : thickening δ s = ∅ := eq_empty_of_forall_notMem fun _ => ((ENNReal.ofReal_of_nonpos hδ).trans_le bot_le).not_gt /-- The (open) thickening `Metric.thickening δ E` of a fixed subset `E` is an increasing function of the thickening radius `δ`. -/ @[gcongr] theorem thickening_mono {δ₁ δ₂ : ℝ} (hle : δ₁ ≤ δ₂) (E : Set α) : thickening δ₁ E ⊆ thickening δ₂ E := preimage_mono (Iio_subset_Iio (ENNReal.ofReal_le_ofReal hle)) /-- The (open) thickening `Metric.thickening δ E` with a fixed thickening radius `δ` is an increasing function of the subset `E`. -/ theorem thickening_subset_of_subset (δ : ℝ) {E₁ E₂ : Set α} (h : E₁ ⊆ E₂) : thickening δ E₁ ⊆ thickening δ E₂ := fun _ hx => lt_of_le_of_lt (infEdist_anti h) hx theorem mem_thickening_iff_exists_edist_lt {δ : ℝ} (E : Set α) (x : α) : x ∈ thickening δ E ↔ ∃ z ∈ E, edist x z < ENNReal.ofReal δ := infEdist_lt_iff /-- The frontier of the (open) thickening of a set is contained in an `EMetric.infEdist` level set. -/ theorem frontier_thickening_subset (E : Set α) {δ : ℝ} : frontier (thickening δ E) ⊆ { x : α | infEdist x E = ENNReal.ofReal δ } := frontier_lt_subset_eq continuous_infEdist continuous_const open scoped Function in -- required for scoped `on` notation theorem frontier_thickening_disjoint (A : Set α) : Pairwise (Disjoint on fun r : ℝ => frontier (thickening r A)) := by refine (pairwise_disjoint_on _).2 fun r₁ r₂ hr => ?_ rcases le_total r₁ 0 with h₁ | h₁ · simp [thickening_of_nonpos h₁] refine ((disjoint_singleton.2 fun h => hr.ne ?_).preimage _).mono (frontier_thickening_subset _) (frontier_thickening_subset _) apply_fun ENNReal.toReal at h rwa [ENNReal.toReal_ofReal h₁, ENNReal.toReal_ofReal (h₁.trans hr.le)] at h /-- Any set is contained in the complement of the δ-thickening of the complement of its δ-thickening. -/ lemma subset_compl_thickening_compl_thickening_self (δ : ℝ) (E : Set α) : E ⊆ (thickening δ (thickening δ E)ᶜ)ᶜ := by intro x x_in_E simp only [thickening, mem_compl_iff, mem_setOf_eq, not_lt] apply EMetric.le_infEdist.mpr fun y hy ↦ ?_ simp only [mem_compl_iff, mem_setOf_eq, not_lt] at hy simpa only [edist_comm] using le_trans hy <| EMetric.infEdist_le_edist_of_mem x_in_E /-- The δ-thickening of the complement of the δ-thickening of a set is contained in the complement of the set. -/ lemma thickening_compl_thickening_self_subset_compl (δ : ℝ) (E : Set α) : thickening δ (thickening δ E)ᶜ ⊆ Eᶜ := by apply compl_subset_compl.mp simpa only [compl_compl] using subset_compl_thickening_compl_thickening_self δ E variable {X : Type u} [PseudoMetricSpace X] theorem mem_thickening_iff_infDist_lt {E : Set X} {x : X} (h : E.Nonempty) : x ∈ thickening δ E ↔ infDist x E < δ := lt_ofReal_iff_toReal_lt (infEdist_ne_top h) /-- A point in a metric space belongs to the (open) `δ`-thickening of a subset `E` if and only if it is at distance less than `δ` from some point of `E`. -/ theorem mem_thickening_iff {E : Set X} {x : X} : x ∈ thickening δ E ↔ ∃ z ∈ E, dist x z < δ := by have key_iff : ∀ z : X, edist x z < ENNReal.ofReal δ ↔ dist x z < δ := fun z ↦ by rw [dist_edist, lt_ofReal_iff_toReal_lt (edist_ne_top _ _)] simp_rw [mem_thickening_iff_exists_edist_lt, key_iff] @[simp] theorem thickening_singleton (δ : ℝ) (x : X) : thickening δ ({x} : Set X) = ball x δ := by ext simp [mem_thickening_iff] theorem ball_subset_thickening {x : X} {E : Set X} (hx : x ∈ E) (δ : ℝ) : ball x δ ⊆ thickening δ E := Subset.trans (by simp) (thickening_subset_of_subset δ <| singleton_subset_iff.mpr hx) /-- The (open) `δ`-thickening `Metric.thickening δ E` of a subset `E` in a metric space equals the union of balls of radius `δ` centered at points of `E`. -/ theorem thickening_eq_biUnion_ball {δ : ℝ} {E : Set X} : thickening δ E = ⋃ x ∈ E, ball x δ := by ext x simp only [mem_iUnion₂, exists_prop] exact mem_thickening_iff protected theorem _root_.Bornology.IsBounded.thickening {δ : ℝ} {E : Set X} (h : IsBounded E) : IsBounded (thickening δ E) := by rcases E.eq_empty_or_nonempty with rfl | ⟨x, hx⟩ · simp · refine (isBounded_iff_subset_closedBall x).2 ⟨δ + diam E, fun y hy ↦ ?_⟩ calc dist y x ≤ infDist y E + diam E := dist_le_infDist_add_diam (x := y) h hx _ ≤ δ + diam E := add_le_add_right ((mem_thickening_iff_infDist_lt ⟨x, hx⟩).1 hy).le _ end Thickening section Cthickening variable [PseudoEMetricSpace α] {δ ε : ℝ} {s t : Set α} {x : α} open EMetric /-- The closed `δ`-thickening `Metric.cthickening δ E` of a subset `E` in a pseudo emetric space consists of those points that are at infimum distance at most `δ` from `E`. -/ def cthickening (δ : ℝ) (E : Set α) : Set α := { x : α | infEdist x E ≤ ENNReal.ofReal δ } @[simp] theorem mem_cthickening_iff : x ∈ cthickening δ s ↔ infEdist x s ≤ ENNReal.ofReal δ := Iff.rfl /-- An exterior point of a subset `E` (i.e., a point outside the closure of `E`) is not in the closed `δ`-thickening of `E` for small enough positive `δ`. -/ lemma eventually_notMem_cthickening_of_infEdist_pos {E : Set α} {x : α} (h : x ∉ closure E) : ∀ᶠ δ in 𝓝 (0 : ℝ), x ∉ Metric.cthickening δ E := by obtain ⟨ε, ⟨ε_pos, ε_lt⟩⟩ := exists_real_pos_lt_infEdist_of_notMem_closure h filter_upwards [eventually_lt_nhds ε_pos] with δ hδ simp only [cthickening, mem_setOf_eq, not_le] exact ((ofReal_lt_ofReal_iff ε_pos).mpr hδ).trans ε_lt @[deprecated (since := "2025-05-23")] alias eventually_not_mem_cthickening_of_infEdist_pos := eventually_notMem_cthickening_of_infEdist_pos theorem mem_cthickening_of_edist_le (x y : α) (δ : ℝ) (E : Set α) (h : y ∈ E) (h' : edist x y ≤ ENNReal.ofReal δ) : x ∈ cthickening δ E := (infEdist_le_edist_of_mem h).trans h' theorem mem_cthickening_of_dist_le {α : Type*} [PseudoMetricSpace α] (x y : α) (δ : ℝ) (E : Set α) (h : y ∈ E) (h' : dist x y ≤ δ) : x ∈ cthickening δ E := by apply mem_cthickening_of_edist_le x y δ E h rw [edist_dist] exact ENNReal.ofReal_le_ofReal h' theorem cthickening_eq_preimage_infEdist (δ : ℝ) (E : Set α) : cthickening δ E = (fun x => infEdist x E) ⁻¹' Iic (ENNReal.ofReal δ) := rfl /-- The closed thickening is a closed set. -/ theorem isClosed_cthickening {δ : ℝ} {E : Set α} : IsClosed (cthickening δ E) := IsClosed.preimage continuous_infEdist isClosed_Iic /-- The closed thickening of the empty set is empty. -/ @[simp] theorem cthickening_empty (δ : ℝ) : cthickening δ (∅ : Set α) = ∅ := by simp only [cthickening, ENNReal.ofReal_ne_top, setOf_false, infEdist_empty, top_le_iff] theorem cthickening_of_nonpos {δ : ℝ} (hδ : δ ≤ 0) (E : Set α) : cthickening δ E = closure E := by ext x simp [mem_closure_iff_infEdist_zero, cthickening, ENNReal.ofReal_eq_zero.2 hδ] /-- The closed thickening with radius zero is the closure of the set. -/ @[simp] theorem cthickening_zero (E : Set α) : cthickening 0 E = closure E := cthickening_of_nonpos le_rfl E theorem cthickening_max_zero (δ : ℝ) (E : Set α) : cthickening (max 0 δ) E = cthickening δ E := by cases le_total δ 0 <;> simp [cthickening_of_nonpos, *] /-- The closed thickening `Metric.cthickening δ E` of a fixed subset `E` is an increasing function of the thickening radius `δ`. -/ theorem cthickening_mono {δ₁ δ₂ : ℝ} (hle : δ₁ ≤ δ₂) (E : Set α) : cthickening δ₁ E ⊆ cthickening δ₂ E := preimage_mono (Iic_subset_Iic.mpr (ENNReal.ofReal_le_ofReal hle)) @[simp] theorem cthickening_singleton {α : Type*} [PseudoMetricSpace α] (x : α) {δ : ℝ} (hδ : 0 ≤ δ) : cthickening δ ({x} : Set α) = closedBall x δ := by ext y simp [cthickening, edist_dist, ENNReal.ofReal_le_ofReal_iff hδ] theorem closedBall_subset_cthickening_singleton {α : Type*} [PseudoMetricSpace α] (x : α) (δ : ℝ) : closedBall x δ ⊆ cthickening δ ({x} : Set α) := by rcases lt_or_ge δ 0 with (hδ | hδ) · simp only [closedBall_eq_empty.mpr hδ, empty_subset] · simp only [cthickening_singleton x hδ, Subset.rfl] /-- The closed thickening `Metric.cthickening δ E` with a fixed thickening radius `δ` is an increasing function of the subset `E`. -/ theorem cthickening_subset_of_subset (δ : ℝ) {E₁ E₂ : Set α} (h : E₁ ⊆ E₂) : cthickening δ E₁ ⊆ cthickening δ E₂ := fun _ hx => le_trans (infEdist_anti h) hx theorem cthickening_subset_thickening {δ₁ : ℝ≥0} {δ₂ : ℝ} (hlt : (δ₁ : ℝ) < δ₂) (E : Set α) : cthickening δ₁ E ⊆ thickening δ₂ E := fun _ hx => hx.out.trans_lt ((ENNReal.ofReal_lt_ofReal_iff (lt_of_le_of_lt δ₁.prop hlt)).mpr hlt) /-- The closed thickening `Metric.cthickening δ₁ E` is contained in the open thickening `Metric.thickening δ₂ E` if the radius of the latter is positive and larger. -/ theorem cthickening_subset_thickening' {δ₁ δ₂ : ℝ} (δ₂_pos : 0 < δ₂) (hlt : δ₁ < δ₂) (E : Set α) : cthickening δ₁ E ⊆ thickening δ₂ E := fun _ hx => lt_of_le_of_lt hx.out ((ENNReal.ofReal_lt_ofReal_iff δ₂_pos).mpr hlt) /-- The open thickening `Metric.thickening δ E` is contained in the closed thickening `Metric.cthickening δ E` with the same radius. -/ theorem thickening_subset_cthickening (δ : ℝ) (E : Set α) : thickening δ E ⊆ cthickening δ E := by intro x hx rw [thickening, mem_setOf_eq] at hx exact hx.le theorem thickening_subset_cthickening_of_le {δ₁ δ₂ : ℝ} (hle : δ₁ ≤ δ₂) (E : Set α) : thickening δ₁ E ⊆ cthickening δ₂ E := (thickening_subset_cthickening δ₁ E).trans (cthickening_mono hle E) theorem _root_.Bornology.IsBounded.cthickening {α : Type*} [PseudoMetricSpace α] {δ : ℝ} {E : Set α} (h : IsBounded E) : IsBounded (cthickening δ E) := by have : IsBounded (thickening (max (δ + 1) 1) E) := h.thickening apply this.subset exact cthickening_subset_thickening' (zero_lt_one.trans_le (le_max_right _ _)) ((lt_add_one _).trans_le (le_max_left _ _)) _ protected theorem _root_.IsCompact.cthickening {α : Type*} [PseudoMetricSpace α] [ProperSpace α] {s : Set α} (hs : IsCompact s) {r : ℝ} : IsCompact (cthickening r s) := isCompact_of_isClosed_isBounded isClosed_cthickening hs.isBounded.cthickening theorem thickening_subset_interior_cthickening (δ : ℝ) (E : Set α) : thickening δ E ⊆ interior (cthickening δ E) := (subset_interior_iff_isOpen.mpr isOpen_thickening).trans (interior_mono (thickening_subset_cthickening δ E)) theorem closure_thickening_subset_cthickening (δ : ℝ) (E : Set α) : closure (thickening δ E) ⊆ cthickening δ E := (closure_mono (thickening_subset_cthickening δ E)).trans isClosed_cthickening.closure_subset /-- The closed thickening of a set contains the closure of the set. -/ theorem closure_subset_cthickening (δ : ℝ) (E : Set α) : closure E ⊆ cthickening δ E := by rw [← cthickening_of_nonpos (min_le_right δ 0)] exact cthickening_mono (min_le_left δ 0) E /-- The (open) thickening of a set contains the closure of the set. -/ theorem closure_subset_thickening {δ : ℝ} (δ_pos : 0 < δ) (E : Set α) : closure E ⊆ thickening δ E := by rw [← cthickening_zero] exact cthickening_subset_thickening' δ_pos δ_pos E /-- A set is contained in its own (open) thickening. -/ theorem self_subset_thickening {δ : ℝ} (δ_pos : 0 < δ) (E : Set α) : E ⊆ thickening δ E := (@subset_closure _ _ E).trans (closure_subset_thickening δ_pos E) /-- A set is contained in its own closed thickening. -/ theorem self_subset_cthickening {δ : ℝ} (E : Set α) : E ⊆ cthickening δ E := subset_closure.trans (closure_subset_cthickening δ E) theorem thickening_mem_nhdsSet (E : Set α) {δ : ℝ} (hδ : 0 < δ) : thickening δ E ∈ 𝓝ˢ E := isOpen_thickening.mem_nhdsSet.2 <| self_subset_thickening hδ E theorem cthickening_mem_nhdsSet (E : Set α) {δ : ℝ} (hδ : 0 < δ) : cthickening δ E ∈ 𝓝ˢ E := mem_of_superset (thickening_mem_nhdsSet E hδ) (thickening_subset_cthickening _ _) @[simp] theorem thickening_union (δ : ℝ) (s t : Set α) : thickening δ (s ∪ t) = thickening δ s ∪ thickening δ t := by simp_rw [thickening, infEdist_union, min_lt_iff, setOf_or] @[simp] theorem cthickening_union (δ : ℝ) (s t : Set α) : cthickening δ (s ∪ t) = cthickening δ s ∪ cthickening δ t := by simp_rw [cthickening, infEdist_union, min_le_iff, setOf_or] @[simp] theorem thickening_iUnion (δ : ℝ) (f : ι → Set α) : thickening δ (⋃ i, f i) = ⋃ i, thickening δ (f i) := by simp_rw [thickening, infEdist_iUnion, iInf_lt_iff, setOf_exists] lemma thickening_biUnion {ι : Type*} (δ : ℝ) (f : ι → Set α) (I : Set ι) : thickening δ (⋃ i ∈ I, f i) = ⋃ i ∈ I, thickening δ (f i) := by simp only [thickening_iUnion] theorem ediam_cthickening_le (ε : ℝ≥0) : EMetric.diam (cthickening ε s) ≤ EMetric.diam s + 2 * ε := by refine diam_le fun x hx y hy => ENNReal.le_of_forall_pos_le_add fun δ hδ _ => ?_ rw [mem_cthickening_iff, ENNReal.ofReal_coe_nnreal] at hx hy have hε : (ε : ℝ≥0∞) < ε + δ := ENNReal.coe_lt_coe.2 (lt_add_of_pos_right _ hδ) replace hx := hx.trans_lt hε obtain ⟨x', hx', hxx'⟩ := infEdist_lt_iff.mp hx calc edist x y ≤ edist x x' + edist y x' := edist_triangle_right _ _ _ _ ≤ ε + δ + (infEdist y s + EMetric.diam s) := add_le_add hxx'.le (edist_le_infEdist_add_ediam hx') _ ≤ ε + δ + (ε + EMetric.diam s) := add_le_add_left (add_le_add_right hy _) _ _ = _ := by rw [two_mul]; ac_rfl theorem ediam_thickening_le (ε : ℝ≥0) : EMetric.diam (thickening ε s) ≤ EMetric.diam s + 2 * ε := (EMetric.diam_mono <| thickening_subset_cthickening _ _).trans <| ediam_cthickening_le _ theorem diam_cthickening_le {α : Type*} [PseudoMetricSpace α] (s : Set α) (hε : 0 ≤ ε) : diam (cthickening ε s) ≤ diam s + 2 * ε := by lift ε to ℝ≥0 using hε refine (toReal_le_add' (ediam_cthickening_le _) ?_ ?_).trans_eq ?_ · exact fun h ↦ top_unique <| h ▸ EMetric.diam_mono (self_subset_cthickening _) · simp [mul_eq_top] · simp [diam] theorem diam_thickening_le {α : Type*} [PseudoMetricSpace α] (s : Set α) (hε : 0 ≤ ε) : diam (thickening ε s) ≤ diam s + 2 * ε := by by_cases hs : IsBounded s · exact (diam_mono (thickening_subset_cthickening _ _) hs.cthickening).trans (diam_cthickening_le _ hε) obtain rfl | hε := hε.eq_or_lt · simp [thickening_of_nonpos, diam_nonneg] · rw [diam_eq_zero_of_unbounded (mt (IsBounded.subset · <| self_subset_thickening hε _) hs)] positivity @[simp] theorem thickening_closure : thickening δ (closure s) = thickening δ s := by simp_rw [thickening, infEdist_closure] @[simp] theorem cthickening_closure : cthickening δ (closure s) = cthickening δ s := by simp_rw [cthickening, infEdist_closure] lemma thickening_eq_empty_iff_of_pos (hε : 0 < ε) : thickening ε s = ∅ ↔ s = ∅ := ⟨fun h ↦ subset_eq_empty (self_subset_thickening hε _) h, by simp +contextual⟩ lemma thickening_nonempty_iff_of_pos (hε : 0 < ε) : (thickening ε s).Nonempty ↔ s.Nonempty := by simp [nonempty_iff_ne_empty, thickening_eq_empty_iff_of_pos hε] @[simp] lemma thickening_eq_empty_iff : thickening ε s = ∅ ↔ ε ≤ 0 ∨ s = ∅ := by obtain hε | hε := lt_or_ge 0 ε · simp [thickening_eq_empty_iff_of_pos, hε] · simp [hε, thickening_of_nonpos hε] @[simp] lemma thickening_nonempty_iff : (thickening ε s).Nonempty ↔ 0 < ε ∧ s.Nonempty := by simp [nonempty_iff_ne_empty] open ENNReal theorem _root_.Disjoint.exists_thickenings (hst : Disjoint s t) (hs : IsCompact s) (ht : IsClosed t) : ∃ δ, 0 < δ ∧ Disjoint (thickening δ s) (thickening δ t) := by obtain ⟨r, hr, h⟩ := exists_pos_forall_lt_edist hs ht hst refine ⟨r / 2, half_pos (NNReal.coe_pos.2 hr), ?_⟩ rw [disjoint_iff_inf_le] rintro z ⟨hzs, hzt⟩ rw [mem_thickening_iff_exists_edist_lt] at hzs hzt rw [← NNReal.coe_two, ← NNReal.coe_div, ENNReal.ofReal_coe_nnreal] at hzs hzt obtain ⟨x, hx, hzx⟩ := hzs obtain ⟨y, hy, hzy⟩ := hzt refine (h x hx y hy).not_ge ?_ calc edist x y ≤ edist z x + edist z y := edist_triangle_left _ _ _ _ ≤ ↑(r / 2) + ↑(r / 2) := add_le_add hzx.le hzy.le _ = r := by rw [← ENNReal.coe_add, add_halves] theorem _root_.Disjoint.exists_cthickenings (hst : Disjoint s t) (hs : IsCompact s) (ht : IsClosed t) : ∃ δ, 0 < δ ∧ Disjoint (cthickening δ s) (cthickening δ t) := by obtain ⟨δ, hδ, h⟩ := hst.exists_thickenings hs ht refine ⟨δ / 2, half_pos hδ, h.mono ?_ ?_⟩ <;> exact cthickening_subset_thickening' hδ (half_lt_self hδ) _ /-- If `s` is compact, `t` is open and `s ⊆ t`, some `cthickening` of `s` is contained in `t`. -/ theorem _root_.IsCompact.exists_cthickening_subset_open (hs : IsCompact s) (ht : IsOpen t) (hst : s ⊆ t) : ∃ δ, 0 < δ ∧ cthickening δ s ⊆ t := (hst.disjoint_compl_right.exists_cthickenings hs ht.isClosed_compl).imp fun _ h => ⟨h.1, disjoint_compl_right_iff_subset.1 <| h.2.mono_right <| self_subset_cthickening _⟩ theorem _root_.IsCompact.exists_isCompact_cthickening [LocallyCompactSpace α] (hs : IsCompact s) : ∃ δ, 0 < δ ∧ IsCompact (cthickening δ s) := by rcases exists_compact_superset hs with ⟨K, K_compact, hK⟩ rcases hs.exists_cthickening_subset_open isOpen_interior hK with ⟨δ, δpos, hδ⟩ refine ⟨δ, δpos, ?_⟩ exact K_compact.of_isClosed_subset isClosed_cthickening (hδ.trans interior_subset) theorem _root_.IsCompact.exists_thickening_subset_open (hs : IsCompact s) (ht : IsOpen t) (hst : s ⊆ t) : ∃ δ, 0 < δ ∧ thickening δ s ⊆ t := let ⟨δ, h₀, hδ⟩ := hs.exists_cthickening_subset_open ht hst ⟨δ, h₀, (thickening_subset_cthickening _ _).trans hδ⟩ theorem hasBasis_nhdsSet_thickening {K : Set α} (hK : IsCompact K) : (𝓝ˢ K).HasBasis (fun δ : ℝ => 0 < δ) fun δ => thickening δ K := (hasBasis_nhdsSet K).to_hasBasis' (fun _U hU => hK.exists_thickening_subset_open hU.1 hU.2) fun _ => thickening_mem_nhdsSet K theorem hasBasis_nhdsSet_cthickening {K : Set α} (hK : IsCompact K) : (𝓝ˢ K).HasBasis (fun δ : ℝ => 0 < δ) fun δ => cthickening δ K := (hasBasis_nhdsSet K).to_hasBasis' (fun _U hU => hK.exists_cthickening_subset_open hU.1 hU.2) fun _ => cthickening_mem_nhdsSet K theorem cthickening_eq_iInter_cthickening' {δ : ℝ} (s : Set ℝ) (hsδ : s ⊆ Ioi δ) (hs : ∀ ε, δ < ε → (s ∩ Ioc δ ε).Nonempty) (E : Set α) : cthickening δ E = ⋂ ε ∈ s, cthickening ε E := by apply Subset.antisymm · exact subset_iInter₂ fun _ hε => cthickening_mono (le_of_lt (hsδ hε)) E · unfold cthickening intro x hx simp only [mem_iInter, mem_setOf_eq] at * apply ENNReal.le_of_forall_pos_le_add intro η η_pos _ rcases hs (δ + η) (lt_add_of_pos_right _ (NNReal.coe_pos.mpr η_pos)) with ⟨ε, ⟨hsε, hε⟩⟩ apply ((hx ε hsε).trans (ENNReal.ofReal_le_ofReal hε.2)).trans rw [ENNReal.coe_nnreal_eq η] exact ENNReal.ofReal_add_le theorem cthickening_eq_iInter_cthickening {δ : ℝ} (E : Set α) : cthickening δ E = ⋂ (ε : ℝ) (_ : δ < ε), cthickening ε E := by apply cthickening_eq_iInter_cthickening' (Ioi δ) rfl.subset simp_rw [inter_eq_right.mpr Ioc_subset_Ioi_self] exact fun _ hε => nonempty_Ioc.mpr hε theorem cthickening_eq_iInter_thickening' {δ : ℝ} (δ_nn : 0 ≤ δ) (s : Set ℝ) (hsδ : s ⊆ Ioi δ) (hs : ∀ ε, δ < ε → (s ∩ Ioc δ ε).Nonempty) (E : Set α) : cthickening δ E = ⋂ ε ∈ s, thickening ε E := by refine (subset_iInter₂ fun ε hε => ?_).antisymm ?_ · obtain ⟨ε', -, hε'⟩ := hs ε (hsδ hε) have ss := cthickening_subset_thickening' (lt_of_le_of_lt δ_nn hε'.1) hε'.1 E exact ss.trans (thickening_mono hε'.2 E) · rw [cthickening_eq_iInter_cthickening' s hsδ hs E] exact iInter₂_mono fun ε _ => thickening_subset_cthickening ε E theorem cthickening_eq_iInter_thickening {δ : ℝ} (δ_nn : 0 ≤ δ) (E : Set α) : cthickening δ E = ⋂ (ε : ℝ) (_ : δ < ε), thickening ε E := by apply cthickening_eq_iInter_thickening' δ_nn (Ioi δ) rfl.subset simp_rw [inter_eq_right.mpr Ioc_subset_Ioi_self] exact fun _ hε => nonempty_Ioc.mpr hε theorem cthickening_eq_iInter_thickening'' (δ : ℝ) (E : Set α) : cthickening δ E = ⋂ (ε : ℝ) (_ : max 0 δ < ε), thickening ε E := by rw [← cthickening_max_zero, cthickening_eq_iInter_thickening] exact le_max_left _ _ /-- The closure of a set equals the intersection of its closed thickenings of positive radii accumulating at zero. -/ theorem closure_eq_iInter_cthickening' (E : Set α) (s : Set ℝ) (hs : ∀ ε, 0 < ε → (s ∩ Ioc 0 ε).Nonempty) : closure E = ⋂ δ ∈ s, cthickening δ E := by by_cases hs₀ : s ⊆ Ioi 0 · rw [← cthickening_zero] apply cthickening_eq_iInter_cthickening' _ hs₀ hs obtain ⟨δ, hδs, δ_nonpos⟩ := not_subset.mp hs₀ rw [Set.mem_Ioi, not_lt] at δ_nonpos apply Subset.antisymm · exact subset_iInter₂ fun ε _ => closure_subset_cthickening ε E · rw [← cthickening_of_nonpos δ_nonpos E] exact biInter_subset_of_mem hδs /-- The closure of a set equals the intersection of its closed thickenings of positive radii. -/ theorem closure_eq_iInter_cthickening (E : Set α) : closure E = ⋂ (δ : ℝ) (_ : 0 < δ), cthickening δ E := by rw [← cthickening_zero] exact cthickening_eq_iInter_cthickening E /-- The closure of a set equals the intersection of its open thickenings of positive radii accumulating at zero. -/ theorem closure_eq_iInter_thickening' (E : Set α) (s : Set ℝ) (hs₀ : s ⊆ Ioi 0) (hs : ∀ ε, 0 < ε → (s ∩ Ioc 0 ε).Nonempty) : closure E = ⋂ δ ∈ s, thickening δ E := by rw [← cthickening_zero] apply cthickening_eq_iInter_thickening' le_rfl _ hs₀ hs /-- The closure of a set equals the intersection of its (open) thickenings of positive radii. -/ theorem closure_eq_iInter_thickening (E : Set α) : closure E = ⋂ (δ : ℝ) (_ : 0 < δ), thickening δ E := by rw [← cthickening_zero] exact cthickening_eq_iInter_thickening rfl.ge E /-- The frontier of the closed thickening of a set is contained in an `EMetric.infEdist` level set. -/ theorem frontier_cthickening_subset (E : Set α) {δ : ℝ} : frontier (cthickening δ E) ⊆ { x : α | infEdist x E = ENNReal.ofReal δ } := frontier_le_subset_eq continuous_infEdist continuous_const /-- The closed ball of radius `δ` centered at a point of `E` is included in the closed thickening of `E`. -/ theorem closedBall_subset_cthickening {α : Type*} [PseudoMetricSpace α] {x : α} {E : Set α} (hx : x ∈ E) (δ : ℝ) : closedBall x δ ⊆ cthickening δ E := by refine (closedBall_subset_cthickening_singleton _ _).trans (cthickening_subset_of_subset _ ?_) simpa using hx theorem cthickening_subset_iUnion_closedBall_of_lt {α : Type*} [PseudoMetricSpace α] (E : Set α) {δ δ' : ℝ} (hδ₀ : 0 < δ') (hδδ' : δ < δ') : cthickening δ E ⊆ ⋃ x ∈ E, closedBall x δ' := by refine (cthickening_subset_thickening' hδ₀ hδδ' E).trans fun x hx => ?_ obtain ⟨y, hy₁, hy₂⟩ := mem_thickening_iff.mp hx exact mem_iUnion₂.mpr ⟨y, hy₁, hy₂.le⟩ /-- The closed thickening of a compact set `E` is the union of the balls `Metric.closedBall x δ` over `x ∈ E`. See also `Metric.cthickening_eq_biUnion_closedBall`. -/ theorem _root_.IsCompact.cthickening_eq_biUnion_closedBall {α : Type*} [PseudoMetricSpace α] {δ : ℝ} {E : Set α} (hE : IsCompact E) (hδ : 0 ≤ δ) : cthickening δ E = ⋃ x ∈ E, closedBall x δ := by rcases eq_empty_or_nonempty E with (rfl | hne) · simp only [cthickening_empty, biUnion_empty] refine Subset.antisymm (fun x hx ↦ ?_) (iUnion₂_subset fun x hx ↦ closedBall_subset_cthickening hx _) obtain ⟨y, yE, hy⟩ : ∃ y ∈ E, infEdist x E = edist x y := hE.exists_infEdist_eq_edist hne _ have D1 : edist x y ≤ ENNReal.ofReal δ := (le_of_eq hy.symm).trans hx have D2 : dist x y ≤ δ := by rw [edist_dist] at D1 exact (ENNReal.ofReal_le_ofReal_iff hδ).1 D1 exact mem_biUnion yE D2 theorem cthickening_eq_biUnion_closedBall {α : Type*} [PseudoMetricSpace α] [ProperSpace α] (E : Set α) (hδ : 0 ≤ δ) : cthickening δ E = ⋃ x ∈ closure E, closedBall x δ := by rcases eq_empty_or_nonempty E with (rfl | hne) · simp only [cthickening_empty, biUnion_empty, closure_empty] rw [← cthickening_closure] refine Subset.antisymm (fun x hx ↦ ?_) (iUnion₂_subset fun x hx ↦ closedBall_subset_cthickening hx _) obtain ⟨y, yE, hy⟩ : ∃ y ∈ closure E, infDist x (closure E) = dist x y := isClosed_closure.exists_infDist_eq_dist (closure_nonempty_iff.mpr hne) x replace hy : dist x y ≤ δ := (ENNReal.ofReal_le_ofReal_iff hδ).mp (((congr_arg ENNReal.ofReal hy.symm).le.trans ENNReal.ofReal_toReal_le).trans hx) exact mem_biUnion yE hy nonrec theorem _root_.IsClosed.cthickening_eq_biUnion_closedBall {α : Type*} [PseudoMetricSpace α] [ProperSpace α] {E : Set α} (hE : IsClosed E) (hδ : 0 ≤ δ) : cthickening δ E = ⋃ x ∈ E, closedBall x δ := by rw [cthickening_eq_biUnion_closedBall E hδ, hE.closure_eq] /-- For the equality, see `infEdist_cthickening`. -/ theorem infEdist_le_infEdist_cthickening_add : infEdist x s ≤ infEdist x (cthickening δ s) + ENNReal.ofReal δ := by refine le_of_forall_gt fun r h => ?_ simp_rw [← lt_tsub_iff_right, infEdist_lt_iff, mem_cthickening_iff] at h obtain ⟨y, hy, hxy⟩ := h exact infEdist_le_edist_add_infEdist.trans_lt ((ENNReal.add_lt_add_of_lt_of_le (hy.trans_lt ENNReal.ofReal_lt_top).ne hxy hy).trans_eq (tsub_add_cancel_of_le <| le_self_add.trans (lt_tsub_iff_left.1 hxy).le)) /-- For the equality, see `infEdist_thickening`. -/ theorem infEdist_le_infEdist_thickening_add : infEdist x s ≤ infEdist x (thickening δ s) + ENNReal.ofReal δ := infEdist_le_infEdist_cthickening_add.trans <| add_le_add_right (infEdist_anti <| thickening_subset_cthickening _ _) _ /-- For the equality, see `thickening_thickening`. -/ @[simp] theorem thickening_thickening_subset (ε δ : ℝ) (s : Set α) : thickening ε (thickening δ s) ⊆ thickening (ε + δ) s := by obtain hε | hε := le_total ε 0 · simp only [thickening_of_nonpos hε, empty_subset] obtain hδ | hδ := le_total δ 0 · simp only [thickening_of_nonpos hδ, thickening_empty, empty_subset] intro x simp_rw [mem_thickening_iff_exists_edist_lt, ENNReal.ofReal_add hε hδ] exact fun ⟨y, ⟨z, hz, hy⟩, hx⟩ => ⟨z, hz, (edist_triangle _ _ _).trans_lt <| ENNReal.add_lt_add hx hy⟩ /-- For the equality, see `thickening_cthickening`. -/ @[simp] theorem thickening_cthickening_subset (ε : ℝ) (hδ : 0 ≤ δ) (s : Set α) : thickening ε (cthickening δ s) ⊆ thickening (ε + δ) s := by obtain hε | hε := le_total ε 0 · simp only [thickening_of_nonpos hε, empty_subset] intro x simp_rw [mem_thickening_iff_exists_edist_lt, mem_cthickening_iff, ← infEdist_lt_iff, ENNReal.ofReal_add hε hδ] rintro ⟨y, hy, hxy⟩ exact infEdist_le_edist_add_infEdist.trans_lt (ENNReal.add_lt_add_of_lt_of_le (hy.trans_lt ENNReal.ofReal_lt_top).ne hxy hy) /-- For the equality, see `cthickening_thickening`. -/ @[simp] theorem cthickening_thickening_subset (hε : 0 ≤ ε) (δ : ℝ) (s : Set α) : cthickening ε (thickening δ s) ⊆ cthickening (ε + δ) s := by obtain hδ | hδ := le_total δ 0 · simp only [thickening_of_nonpos hδ, cthickening_empty, empty_subset] intro x simp_rw [mem_cthickening_iff, ENNReal.ofReal_add hε hδ] exact fun hx => infEdist_le_infEdist_thickening_add.trans (add_le_add_right hx _) /-- For the equality, see `cthickening_cthickening`. -/ @[simp] theorem cthickening_cthickening_subset (hε : 0 ≤ ε) (hδ : 0 ≤ δ) (s : Set α) : cthickening ε (cthickening δ s) ⊆ cthickening (ε + δ) s := by intro x simp_rw [mem_cthickening_iff, ENNReal.ofReal_add hε hδ] exact fun hx => infEdist_le_infEdist_cthickening_add.trans (add_le_add_right hx _) open scoped Function in -- required for scoped `on` notation theorem frontier_cthickening_disjoint (A : Set α) : Pairwise (Disjoint on fun r : ℝ≥0 => frontier (cthickening r A)) := fun r₁ r₂ hr => ((disjoint_singleton.2 <| by simpa).preimage _).mono (frontier_cthickening_subset _) (frontier_cthickening_subset _) end Cthickening theorem thickening_ball [PseudoMetricSpace α] (x : α) (ε δ : ℝ) : thickening ε (ball x δ) ⊆ ball x (ε + δ) := by rw [← thickening_singleton, ← thickening_singleton] apply thickening_thickening_subset end Metric section Clopen open Metric variable [PseudoEMetricSpace α] {s : Set α} lemma IsClopen.of_thickening_subset_self {δ : ℝ} (hδ : 0 < δ) (hs : thickening δ s ⊆ s) : IsClopen s := by replace hs : thickening δ s = s := le_antisymm hs (self_subset_thickening hδ s) refine ⟨?_, hs ▸ isOpen_thickening⟩ rw [← closure_subset_iff_isClosed, closure_eq_iInter_thickening] exact Set.biInter_subset_of_mem hδ |>.trans_eq hs lemma IsClopen.of_cthickening_subset_self {δ : ℝ} (hδ : 0 < δ) (hs : cthickening δ s ⊆ s) : IsClopen s := .of_thickening_subset_self hδ <| (thickening_subset_cthickening δ s).trans hs end Clopen open Metric in theorem IsCompact.exists_thickening_image_subset [PseudoEMetricSpace α] {β : Type*} [PseudoEMetricSpace β] {f : α → β} {K : Set α} {U : Set β} (hK : IsCompact K) (ho : IsOpen U) (hf : ∀ x ∈ K, ContinuousAt f x) (hKU : MapsTo f K U) : ∃ ε > 0, ∃ V ∈ 𝓝ˢ K, thickening ε (f '' V) ⊆ U := by apply hK.induction_on (p := fun K ↦ ∃ ε > 0, ∃ V ∈ 𝓝ˢ K, thickening ε (f '' V) ⊆ U) · use 1, by positivity, ∅, by simp, by simp · exact fun s t hst ⟨ε, hε, V, hV, hthickening⟩ ↦ ⟨ε, hε, V, nhdsSet_mono hst hV, hthickening⟩ · rintro s t ⟨ε₁, hε₁, V₁, hV₁, hV₁thickening⟩ ⟨ε₂, hε₂, V₂, hV₂, hV₂thickening⟩ refine ⟨min ε₁ ε₂, by positivity, V₁ ∪ V₂, union_mem_nhdsSet hV₁ hV₂, ?_⟩ rw [image_union, thickening_union] calc thickening (ε₁ ⊓ ε₂) (f '' V₁) ∪ thickening (ε₁ ⊓ ε₂) (f '' V₂) _ ⊆ thickening ε₁ (f '' V₁) ∪ thickening ε₂ (f '' V₂) := by gcongr <;> norm_num _ ⊆ U ∪ U := by gcongr _ = U := union_self _ · intro x hx have : {f x} ⊆ U := by rw [singleton_subset_iff]; exact hKU hx obtain ⟨δ, hδ, hthick⟩ := (isCompact_singleton (x := f x)).exists_thickening_subset_open ho this let V := f ⁻¹' (thickening (δ / 2) {f x}) have : V ∈ 𝓝 x := by apply hf x hx apply isOpen_thickening.mem_nhds exact (self_subset_thickening (by positivity) _) rfl refine ⟨K ∩ (interior V), inter_mem_nhdsWithin K (interior_mem_nhds.mpr this), δ / 2, by positivity, V, by rw [← subset_interior_iff_mem_nhdsSet]; simp, ?_⟩ calc thickening (δ / 2) (f '' V) _ ⊆ thickening (δ / 2) (thickening (δ / 2) {f x}) := thickening_subset_of_subset _ (image_preimage_subset f _) _ ⊆ thickening ((δ / 2) + (δ / 2)) ({f x}) := thickening_thickening_subset (δ / 2) (δ / 2) {f x} _ ⊆ U := by simp [hthick]
Linear.lean
/- Copyright (c) 2021 Bhavik Mehta. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Bhavik Mehta -/ import Mathlib.Order.Zorn /-! # Extend a partial order to a linear order This file constructs a linear order which is an extension of the given partial order, using Zorn's lemma. -/ universe u open Set /-- **Szpilrajn extension theorem**: any partial order can be extended to a linear order. -/ theorem extend_partialOrder {α : Type u} (r : α → α → Prop) [IsPartialOrder α r] : ∃ s : α → α → Prop, IsLinearOrder α s ∧ r ≤ s := by let S := { s | IsPartialOrder α s } have hS : ∀ c, c ⊆ S → IsChain (· ≤ ·) c → ∀ y ∈ c, ∃ ub ∈ S, ∀ z ∈ c, z ≤ ub := by rintro c hc₁ hc₂ s hs haveI := (hc₁ hs).1 refine ⟨sSup c, ?_, fun z hz => le_sSup hz⟩ refine { refl := ?_ trans := ?_ antisymm := ?_ } <;> simp_rw [binary_relation_sSup_iff] · intro x exact ⟨s, hs, refl x⟩ · rintro x y z ⟨s₁, h₁s₁, h₂s₁⟩ ⟨s₂, h₁s₂, h₂s₂⟩ haveI : IsPartialOrder _ _ := hc₁ h₁s₁ haveI : IsPartialOrder _ _ := hc₁ h₁s₂ rcases hc₂.total h₁s₁ h₁s₂ with h | h · exact ⟨s₂, h₁s₂, _root_.trans (h _ _ h₂s₁) h₂s₂⟩ · exact ⟨s₁, h₁s₁, _root_.trans h₂s₁ (h _ _ h₂s₂)⟩ · rintro x y ⟨s₁, h₁s₁, h₂s₁⟩ ⟨s₂, h₁s₂, h₂s₂⟩ haveI : IsPartialOrder _ _ := hc₁ h₁s₁ haveI : IsPartialOrder _ _ := hc₁ h₁s₂ rcases hc₂.total h₁s₁ h₁s₂ with h | h · exact antisymm (h _ _ h₂s₁) h₂s₂ · apply antisymm h₂s₁ (h _ _ h₂s₂) obtain ⟨s, hrs, hs⟩ := zorn_le_nonempty₀ S hS r ‹_› haveI : IsPartialOrder α s := hs.prop refine ⟨s, { total := ?_, refl := hs.1.refl, trans := hs.1.trans, antisymm := hs.1.antisymm }, hrs⟩ intro x y by_contra! h let s' x' y' := s x' y' ∨ s x' x ∧ s y y' rw [hs.eq_of_le (y := s') ?_ fun _ _ ↦ Or.inl] at h · apply h.1 (Or.inr ⟨refl _, refl _⟩) · refine { refl := fun x ↦ Or.inl (refl _) trans := ?_ antisymm := ?_ } · rintro a b c (ab | ⟨ax : s a x, yb : s y b⟩) (bc | ⟨bx : s b x, yc : s y c⟩) · exact Or.inl (_root_.trans ab bc) · exact Or.inr ⟨_root_.trans ab bx, yc⟩ · exact Or.inr ⟨ax, _root_.trans yb bc⟩ · exact Or.inr ⟨ax, yc⟩ rintro a b (ab | ⟨ax : s a x, yb : s y b⟩) (ba | ⟨bx : s b x, ya : s y a⟩) · exact antisymm ab ba · exact (h.2 (_root_.trans ya (_root_.trans ab bx))).elim · exact (h.2 (_root_.trans yb (_root_.trans ba ax))).elim · exact (h.2 (_root_.trans yb bx)).elim /-- A type alias for `α`, intended to extend a partial order on `α` to a linear order. -/ def LinearExtension (α : Type u) : Type u := α noncomputable instance {α : Type u} [PartialOrder α] : LinearOrder (LinearExtension α) where le := (extend_partialOrder ((· ≤ ·) : α → α → Prop)).choose le_refl := (extend_partialOrder ((· ≤ ·) : α → α → Prop)).choose_spec.1.1.1.1.1 le_trans := (extend_partialOrder ((· ≤ ·) : α → α → Prop)).choose_spec.1.1.1.2.1 le_antisymm := (extend_partialOrder ((· ≤ ·) : α → α → Prop)).choose_spec.1.1.2.1 le_total := (extend_partialOrder ((· ≤ ·) : α → α → Prop)).choose_spec.1.2.1 toDecidableLE := Classical.decRel _ /-- The embedding of `α` into `LinearExtension α` as an order homomorphism. -/ noncomputable def toLinearExtension {α : Type u} [PartialOrder α] : α →o LinearExtension α where toFun x := x monotone' := (extend_partialOrder ((· ≤ ·) : α → α → Prop)).choose_spec.2 instance {α : Type u} [Inhabited α] : Inhabited (LinearExtension α) := ⟨(default : α)⟩
Presheaf.lean
/- Copyright (c) 2020 Bhavik Mehta. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Bhavik Mehta, Joël Riou -/ import Mathlib.CategoryTheory.Comma.Presheaf.Basic import Mathlib.CategoryTheory.Elements import Mathlib.CategoryTheory.Functor.KanExtension.Adjunction import Mathlib.CategoryTheory.Limits.Final import Mathlib.CategoryTheory.Limits.Over /-! # Colimit of representables This file constructs an adjunction `Presheaf.yonedaAdjunction` between `(Cᵒᵖ ⥤ Type u)` and `ℰ` given a functor `A : C ⥤ ℰ`, where the right adjoint `restrictedYoneda` sends `(E : ℰ)` to `c ↦ (A.obj c ⟶ E)`, and the left adjoint `(Cᵒᵖ ⥤ Type v₁) ⥤ ℰ` is a pointwise left Kan extension of `A` along the Yoneda embedding, which exists provided `ℰ` has colimits) We also show that every presheaf is a colimit of representables. This result is also known as the density theorem, the co-Yoneda lemma and the Ninja Yoneda lemma. Two formulations are given: * `colimitOfRepresentable` uses the category of elements of a functor to types; * `isColimitTautologicalCocone` uses the category of costructured arrows. In the lemma `isLeftKanExtension_along_yoneda_iff`, we show that if `L : (Cᵒᵖ ⥤ Type v₁) ⥤ ℰ)` and `α : A ⟶ yoneda ⋙ L`, then `α` makes `L` the left Kan extension of `L` along yoneda if and only if `α` is an isomorphism (i.e. `L` extends `A`) and `L` preserves colimits. `uniqueExtensionAlongYoneda` shows `yoneda.leftKanExtension A` is unique amongst functors preserving colimits with this property, establishing the presheaf category as the free cocompletion of a category. Given a functor `F : C ⥤ D`, we also show construct an isomorphism `compYonedaIsoYonedaCompLan : F ⋙ yoneda ≅ yoneda ⋙ F.op.lan`, and show that it makes `F.op.lan` a left Kan extension of `F ⋙ yoneda`. ## Tags colimit, representable, presheaf, free cocompletion ## References * [S. MacLane, I. Moerdijk, *Sheaves in Geometry and Logic*][MM92] * https://ncatlab.org/nlab/show/Yoneda+extension -/ namespace CategoryTheory open Category Limits universe v₁ v₂ v₃ u₁ u₂ u₃ namespace Presheaf variable {C : Type u₁} [Category.{v₁} C] variable {ℰ : Type u₂} [Category.{v₁} ℰ] (A : C ⥤ ℰ) /-- The functor taking `(E : ℰ) (c : Cᵒᵖ)` to the homset `(A.obj C ⟶ E)`. It is shown in `L_adjunction` that this functor has a left adjoint (provided `E` has colimits) given by taking colimits over categories of elements. In the case where `ℰ = Cᵒᵖ ⥤ Type u` and `A = yoneda`, this functor is isomorphic to the identity. Defined as in [MM92], Chapter I, Section 5, Theorem 2. -/ @[simps!] def restrictedYoneda : ℰ ⥤ Cᵒᵖ ⥤ Type v₁ := yoneda ⋙ (Functor.whiskeringLeft _ _ (Type v₁)).obj (Functor.op A) /-- Auxiliary definition for `restrictedYonedaHomEquiv`. -/ def restrictedYonedaHomEquiv' (P : Cᵒᵖ ⥤ Type v₁) (E : ℰ) : (CostructuredArrow.proj yoneda P ⋙ A ⟶ (Functor.const (CostructuredArrow yoneda P)).obj E) ≃ (P ⟶ (restrictedYoneda A).obj E) where toFun f := { app := fun _ x => f.app (CostructuredArrow.mk (yonedaEquiv.symm x)) naturality := fun {X₁ X₂} φ => by ext x let ψ : CostructuredArrow.mk (yonedaEquiv.symm (P.map φ x)) ⟶ CostructuredArrow.mk (yonedaEquiv.symm x) := CostructuredArrow.homMk φ.unop (by dsimp [yonedaEquiv] cat_disch ) simpa using (f.naturality ψ).symm } invFun g := { app := fun y => yonedaEquiv (y.hom ≫ g) naturality := fun {X₁ X₂} φ => by dsimp rw [← CostructuredArrow.w φ] dsimp [yonedaEquiv] simp only [comp_id, id_comp] refine (congr_fun (g.naturality φ.left.op) (X₂.hom.app (Opposite.op X₂.left) (𝟙 _))).symm.trans ?_ dsimp apply congr_arg simpa using congr_fun (X₂.hom.naturality φ.left.op).symm (𝟙 _) } left_inv f := by ext ⟨X, ⟨⟨⟩⟩, φ⟩ suffices yonedaEquiv.symm (φ.app (Opposite.op X) (𝟙 X)) = φ by dsimp erw [yonedaEquiv_apply] dsimp [CostructuredArrow.mk] erw [this] exact yonedaEquiv.injective (by cat_disch) right_inv g := by ext X x dsimp erw [yonedaEquiv_apply] dsimp rw [yonedaEquiv_symm_app_apply] simp section example [HasColimitsOfSize.{v₁, max u₁ v₁} ℰ] : yoneda.HasPointwiseLeftKanExtension A := inferInstance variable [yoneda.HasPointwiseLeftKanExtension A] variable {A} variable (L : (Cᵒᵖ ⥤ Type v₁) ⥤ ℰ) (α : A ⟶ yoneda ⋙ L) [L.IsLeftKanExtension α] /-- Auxiliary definition for `yonedaAdjunction`. -/ noncomputable def restrictedYonedaHomEquiv (P : Cᵒᵖ ⥤ Type v₁) (E : ℰ) : (L.obj P ⟶ E) ≃ (P ⟶ (restrictedYoneda A).obj E) := (Functor.isPointwiseLeftKanExtensionOfIsLeftKanExtension _ α P).homEquiv.trans (restrictedYonedaHomEquiv' A P E) /-- If `L : (Cᵒᵖ ⥤ Type v₁) ⥤ ℰ` is a pointwise left Kan extension of a functor `A : C ⥤ ℰ` along the Yoneda embedding, then `L` is a left adjoint of `restrictedYoneda A : ℰ ⥤ Cᵒᵖ ⥤ Type v₁` -/ noncomputable def yonedaAdjunction : L ⊣ restrictedYoneda A := Adjunction.mkOfHomEquiv { homEquiv := restrictedYonedaHomEquiv L α homEquiv_naturality_left_symm := fun {P Q X} f g => by obtain ⟨g, rfl⟩ := (restrictedYonedaHomEquiv L α Q X).surjective g apply (restrictedYonedaHomEquiv L α P X).injective simp only [Equiv.apply_symm_apply, Equiv.symm_apply_apply] ext Y y dsimp [restrictedYonedaHomEquiv, restrictedYonedaHomEquiv', IsColimit.homEquiv] rw [assoc, assoc, ← L.map_comp_assoc] congr 3 apply yonedaEquiv.injective simp [yonedaEquiv] homEquiv_naturality_right := fun {P X Y} f g => by apply (restrictedYonedaHomEquiv L α P Y).symm.injective simp only [Equiv.symm_apply_apply] dsimp [restrictedYonedaHomEquiv, restrictedYonedaHomEquiv', IsColimit.homEquiv] apply (Functor.isPointwiseLeftKanExtensionOfIsLeftKanExtension L α P).hom_ext intro p rw [IsColimit.fac] dsimp [restrictedYoneda, yonedaEquiv] simp only [assoc] congr 3 apply yonedaEquiv.injective simp [yonedaEquiv] } include α in /-- Any left Kan extension along the Yoneda embedding preserves colimits. -/ lemma preservesColimitsOfSize_of_isLeftKanExtension : PreservesColimitsOfSize.{v₃, u₃} L := (yonedaAdjunction L α).leftAdjoint_preservesColimits lemma isIso_of_isLeftKanExtension : IsIso α := (Functor.isPointwiseLeftKanExtensionOfIsLeftKanExtension _ α).isIso_hom variable (A) /-- See Property 2 of https://ncatlab.org/nlab/show/Yoneda+extension#properties. -/ noncomputable instance preservesColimitsOfSize_leftKanExtension : PreservesColimitsOfSize.{v₃, u₃} (yoneda.leftKanExtension A) := (yonedaAdjunction _ (yoneda.leftKanExtensionUnit A)).leftAdjoint_preservesColimits instance : IsIso (yoneda.leftKanExtensionUnit A) := isIso_of_isLeftKanExtension _ (yoneda.leftKanExtensionUnit A) /-- A pointwise left Kan extension along the Yoneda embedding is an extension. -/ noncomputable def isExtensionAlongYoneda : yoneda ⋙ yoneda.leftKanExtension A ≅ A := (asIso (yoneda.leftKanExtensionUnit A)).symm end /-- A functor to the presheaf category in which everything in the image is representable (witnessed by the fact that it factors through the yoneda embedding). `coconeOfRepresentable` gives a cocone for this functor which is a colimit and has point `P`. -/ @[reducible] def functorToRepresentables (P : Cᵒᵖ ⥤ Type v₁) : P.Elementsᵒᵖ ⥤ Cᵒᵖ ⥤ Type v₁ := (CategoryOfElements.π P).leftOp ⋙ yoneda /-- This is a cocone with point `P` for the functor `functorToRepresentables P`. It is shown in `colimitOfRepresentable P` that this cocone is a colimit: that is, we have exhibited an arbitrary presheaf `P` as a colimit of representables. The construction of [MM92], Chapter I, Section 5, Corollary 3. -/ @[simps] noncomputable def coconeOfRepresentable (P : Cᵒᵖ ⥤ Type v₁) : Cocone (functorToRepresentables P) where pt := P ι := { app := fun x => yonedaEquiv.symm x.unop.2 naturality := fun {x₁ x₂} f => by dsimp rw [comp_id, ← yonedaEquiv_symm_map] congr 1 rw [f.unop.2] } /-- The legs of the cocone `coconeOfRepresentable` are natural in the choice of presheaf. -/ theorem coconeOfRepresentable_naturality {P₁ P₂ : Cᵒᵖ ⥤ Type v₁} (α : P₁ ⟶ P₂) (j : P₁.Elementsᵒᵖ) : (coconeOfRepresentable P₁).ι.app j ≫ α = (coconeOfRepresentable P₂).ι.app ((CategoryOfElements.map α).op.obj j) := by ext T f simpa [coconeOfRepresentable_ι_app] using FunctorToTypes.naturality _ _ α f.op _ /-- The cocone with point `P` given by `coconeOfRepresentable` is a colimit: that is, we have exhibited an arbitrary presheaf `P` as a colimit of representables. The result of [MM92], Chapter I, Section 5, Corollary 3. -/ noncomputable def colimitOfRepresentable (P : Cᵒᵖ ⥤ Type v₁) : IsColimit (coconeOfRepresentable P) where desc s := { app := fun X x => (s.ι.app (Opposite.op (Functor.elementsMk P X x))).app X (𝟙 _) naturality := fun X Y f => by ext x have eq₁ := congr_fun (congr_app (s.w (CategoryOfElements.homMk (P.elementsMk X x) (P.elementsMk Y (P.map f x)) f rfl).op) Y) (𝟙 _) dsimp at eq₁ ⊢ simpa [← eq₁, id_comp] using congr_fun ((s.ι.app (Opposite.op (P.elementsMk X x))).naturality f) (𝟙 _) } fac s j := by ext X x let φ : j.unop ⟶ Functor.elementsMk P X ((yonedaEquiv.symm j.unop.2).app X x) := ⟨x.op, rfl⟩ simpa using congr_fun (congr_app (s.ι.naturality φ.op).symm X) (𝟙 _) uniq s m hm := by ext X x dsimp rw [← hm] apply congr_arg simp [coconeOfRepresentable_ι_app, yonedaEquiv] variable {A : C ⥤ ℰ} example [HasColimitsOfSize.{v₁, max u₁ v₁} ℰ] : yoneda.HasPointwiseLeftKanExtension A := inferInstance variable [yoneda.HasPointwiseLeftKanExtension A] section variable (L : (Cᵒᵖ ⥤ Type v₁) ⥤ ℰ) (α : A ⟶ yoneda ⋙ L) instance [L.IsLeftKanExtension α] : IsIso α := (Functor.isPointwiseLeftKanExtensionOfIsLeftKanExtension L α).isIso_hom lemma isLeftKanExtension_along_yoneda_iff : L.IsLeftKanExtension α ↔ (IsIso α ∧ PreservesColimitsOfSize.{v₁, max u₁ v₁} L) := by constructor · intro exact ⟨inferInstance, preservesColimits_of_natIso (Functor.leftKanExtensionUnique _ (yoneda.leftKanExtensionUnit A) _ α)⟩ · rintro ⟨_, _⟩ apply Functor.LeftExtension.IsPointwiseLeftKanExtension.isLeftKanExtension (E := Functor.LeftExtension.mk _ α) intro P dsimp [Functor.LeftExtension.IsPointwiseLeftKanExtensionAt] apply IsColimit.ofWhiskerEquivalence (CategoryOfElements.costructuredArrowYonedaEquivalence _) let e : CategoryOfElements.toCostructuredArrow P ⋙ CostructuredArrow.proj yoneda P ⋙ A ≅ functorToRepresentables P ⋙ L := Functor.isoWhiskerLeft _ (Functor.isoWhiskerLeft _ (asIso α)) ≪≫ Functor.isoWhiskerLeft _ (Functor.associator _ _ _).symm ≪≫ (Functor.associator _ _ _).symm ≪≫ Functor.isoWhiskerRight (Iso.refl _) L apply (IsColimit.precomposeHomEquiv e.symm _).1 exact IsColimit.ofIsoColimit (isColimitOfPreserves L (colimitOfRepresentable P)) (Cocones.ext (Iso.refl _)) lemma isLeftKanExtension_of_preservesColimits (L : (Cᵒᵖ ⥤ Type v₁) ⥤ ℰ) (e : A ≅ yoneda ⋙ L) [PreservesColimitsOfSize.{v₁, max u₁ v₁} L] : L.IsLeftKanExtension e.hom := by rw [isLeftKanExtension_along_yoneda_iff] exact ⟨inferInstance, ⟨inferInstance⟩⟩ end /-- Show that `yoneda.leftKanExtension A` is the unique colimit-preserving functor which extends `A` to the presheaf category. The second part of [MM92], Chapter I, Section 5, Corollary 4. See Property 3 of https://ncatlab.org/nlab/show/Yoneda+extension#properties. -/ noncomputable def uniqueExtensionAlongYoneda (L : (Cᵒᵖ ⥤ Type v₁) ⥤ ℰ) (e : A ≅ yoneda ⋙ L) [PreservesColimitsOfSize.{v₁, max u₁ v₁} L] : L ≅ yoneda.leftKanExtension A := have := isLeftKanExtension_of_preservesColimits L e Functor.leftKanExtensionUnique _ e.hom _ (yoneda.leftKanExtensionUnit A) instance (L : (Cᵒᵖ ⥤ Type v₁) ⥤ ℰ) [PreservesColimitsOfSize.{v₁, max u₁ v₁} L] [yoneda.HasPointwiseLeftKanExtension (yoneda ⋙ L)] : L.IsLeftKanExtension (𝟙 _ : yoneda ⋙ L ⟶ _) := isLeftKanExtension_of_preservesColimits _ (Iso.refl _) /-- If `L` preserves colimits and `ℰ` has them, then it is a left adjoint. Note this is a (partial) converse to `leftAdjointPreservesColimits`. -/ lemma isLeftAdjoint_of_preservesColimits (L : (C ⥤ Type v₁) ⥤ ℰ) [PreservesColimitsOfSize.{v₁, max u₁ v₁} L] [yoneda.HasPointwiseLeftKanExtension (yoneda ⋙ (opOpEquivalence C).congrLeft.functor.comp L)] : L.IsLeftAdjoint := ⟨_, ⟨((opOpEquivalence C).congrLeft.symm.toAdjunction.comp (yonedaAdjunction _ (𝟙 _))).ofNatIsoLeft ((opOpEquivalence C).congrLeft.invFunIdAssoc L)⟩⟩ section variable {D : Type u₂} [Category.{v₁} D] (F : C ⥤ D) section instance (X : C) (Y : F.op.LeftExtension (yoneda.obj X)) : Unique (Functor.LeftExtension.mk _ (yonedaMap F X) ⟶ Y) where default := StructuredArrow.homMk (yonedaEquiv.symm (yonedaEquiv (F := F.op.comp Y.right) Y.hom)) (by ext Z f simpa using congr_fun (Y.hom.naturality f.op).symm (𝟙 _)) uniq φ := by ext1 apply yonedaEquiv.injective dsimp simp only [Equiv.apply_symm_apply, ← StructuredArrow.w φ] dsimp [yonedaEquiv] simp only [Functor.map_id] /-- Given `F : C ⥤ D` and `X : C`, `yoneda.obj (F.obj X) : Dᵒᵖ ⥤ Type _` is the left Kan extension of `yoneda.obj X : Cᵒᵖ ⥤ Type _` along `F.op`. -/ instance (X : C) : (yoneda.obj (F.obj X)).IsLeftKanExtension (yonedaMap F X) := ⟨⟨Limits.IsInitial.ofUnique _⟩⟩ end section variable [∀ (P : Cᵒᵖ ⥤ Type v₁), F.op.HasLeftKanExtension P] /-- `F ⋙ yoneda` is naturally isomorphic to `yoneda ⋙ F.op.lan`. -/ noncomputable def compYonedaIsoYonedaCompLan : F ⋙ yoneda ≅ yoneda ⋙ F.op.lan := NatIso.ofComponents (fun X => Functor.leftKanExtensionUnique _ (yonedaMap F X) (F.op.lan.obj _) (F.op.lanUnit.app (yoneda.obj X))) (fun {X Y} f => by apply yonedaEquiv.injective have eq₁ := congr_fun ((yoneda.obj (F.obj Y)).descOfIsLeftKanExtension_fac_app (yonedaMap F Y) (F.op.lan.obj (yoneda.obj Y)) (F.op.lanUnit.app (yoneda.obj Y)) _) f have eq₂ := congr_fun (((yoneda.obj (F.obj X)).descOfIsLeftKanExtension_fac_app (yonedaMap F X) (F.op.lan.obj (yoneda.obj X)) (F.op.lanUnit.app (yoneda.obj X))) _) (𝟙 _) have eq₃ := congr_fun (congr_app (F.op.lanUnit.naturality (yoneda.map f)) _) (𝟙 _) dsimp at eq₁ eq₂ eq₃ simp only [Functor.map_id] at eq₂ simp only [id_comp] at eq₃ simp [yonedaEquiv, eq₁, eq₂, eq₃]) @[simp] lemma compYonedaIsoYonedaCompLan_inv_app_app_apply_eq_id (X : C) : ((compYonedaIsoYonedaCompLan F).inv.app X).app (Opposite.op (F.obj X)) ((F.op.lanUnit.app (yoneda.obj X)).app _ (𝟙 X)) = 𝟙 _ := (congr_fun (Functor.descOfIsLeftKanExtension_fac_app _ (F.op.lanUnit.app (yoneda.obj X)) _ (yonedaMap F X) (Opposite.op X)) (𝟙 _)).trans (by simp) end namespace compYonedaIsoYonedaCompLan variable {F} section variable {X : C} {G : (Cᵒᵖ ⥤ Type v₁) ⥤ Dᵒᵖ ⥤ Type v₁} (φ : F ⋙ yoneda ⟶ yoneda ⋙ G) /-- Auxiliary definition for `presheafHom`. -/ def coconeApp {P : Cᵒᵖ ⥤ Type v₁} (x : P.Elements) : yoneda.obj x.1.unop ⟶ F.op ⋙ G.obj P := yonedaEquiv.symm ((G.map (yonedaEquiv.symm x.2)).app _ ((φ.app x.1.unop).app _ (𝟙 _))) @[reassoc (attr := simp)] lemma coconeApp_naturality {P : Cᵒᵖ ⥤ Type v₁} {x y : P.Elements} (f : x ⟶ y) : yoneda.map f.1.unop ≫ coconeApp φ x = coconeApp φ y := by have eq₁ : yoneda.map f.1.unop ≫ yonedaEquiv.symm x.2 = yonedaEquiv.symm y.2 := yonedaEquiv.injective (by simpa only [Equiv.apply_symm_apply, ← yonedaEquiv_naturality] using f.2) have eq₂ := congr_fun ((G.map (yonedaEquiv.symm x.2)).naturality (F.map f.1.unop).op) ((φ.app x.1.unop).app _ (𝟙 _)) have eq₃ := congr_fun (congr_app (φ.naturality f.1.unop) _) (𝟙 _) have eq₄ := congr_fun ((φ.app x.1.unop).naturality (F.map f.1.unop).op) dsimp at eq₂ eq₃ eq₄ apply yonedaEquiv.injective dsimp only [coconeApp] rw [Equiv.apply_symm_apply, ← yonedaEquiv_naturality, Equiv.apply_symm_apply] simp [← eq₁, ← eq₂, ← eq₃, ← eq₄, Functor.map_comp, FunctorToTypes.comp, id_comp, comp_id] /-- Given functors `F : C ⥤ D` and `G : (Cᵒᵖ ⥤ Type v₁) ⥤ (Dᵒᵖ ⥤ Type v₁)`, and a natural transformation `φ : F ⋙ yoneda ⟶ yoneda ⋙ G`, this is the (natural) morphism `P ⟶ F.op ⋙ G.obj P` for all `P : Cᵒᵖ ⥤ Type v₁` that is determined by `φ`. -/ noncomputable def presheafHom (P : Cᵒᵖ ⥤ Type v₁) : P ⟶ F.op ⋙ G.obj P := (colimitOfRepresentable P).desc (Cocone.mk _ { app := fun x => coconeApp φ x.unop }) lemma yonedaEquiv_ι_presheafHom (P : Cᵒᵖ ⥤ Type v₁) {X : C} (f : yoneda.obj X ⟶ P) : yonedaEquiv (f ≫ presheafHom φ P) = (G.map f).app (Opposite.op (F.obj X)) ((φ.app X).app _ (𝟙 _)) := by obtain ⟨x, rfl⟩ := yonedaEquiv.symm.surjective f erw [(colimitOfRepresentable P).fac _ (Opposite.op (P.elementsMk _ x))] dsimp only [coconeApp] apply Equiv.apply_symm_apply lemma yonedaEquiv_presheafHom_yoneda_obj (X : C) : yonedaEquiv (presheafHom φ (yoneda.obj X)) = ((φ.app X).app (F.op.obj (Opposite.op X)) (𝟙 _)) := by simpa using yonedaEquiv_ι_presheafHom φ (yoneda.obj X) (𝟙 _) @[reassoc (attr := simp)] lemma presheafHom_naturality {P Q : Cᵒᵖ ⥤ Type v₁} (f : P ⟶ Q) : presheafHom φ P ≫ Functor.whiskerLeft F.op (G.map f) = f ≫ presheafHom φ Q := hom_ext_yoneda (fun X p => yonedaEquiv.injective (by rw [← assoc p f, yonedaEquiv_ι_presheafHom, ← assoc, yonedaEquiv_comp, yonedaEquiv_ι_presheafHom, Functor.whiskerLeft_app, Functor.map_comp, FunctorToTypes.comp] dsimp)) variable [∀ (P : Cᵒᵖ ⥤ Type v₁), F.op.HasLeftKanExtension P] /-- Given functors `F : C ⥤ D` and `G : (Cᵒᵖ ⥤ Type v₁) ⥤ (Dᵒᵖ ⥤ Type v₁)`, and a natural transformation `φ : F ⋙ yoneda ⟶ yoneda ⋙ G`, this is the canonical natural transformation `F.op.lan ⟶ G`, which is part of the that `F.op.lan : (Cᵒᵖ ⥤ Type v₁) ⥤ Dᵒᵖ ⥤ Type v₁` is the left Kan extension of `F ⋙ yoneda : C ⥤ Dᵒᵖ ⥤ Type v₁` along `yoneda : C ⥤ Cᵒᵖ ⥤ Type v₁`. -/ noncomputable def natTrans : F.op.lan ⟶ G where app P := (F.op.lan.obj P).descOfIsLeftKanExtension (F.op.lanUnit.app P) _ (presheafHom φ P) naturality {P Q} f := by apply (F.op.lan.obj P).hom_ext_of_isLeftKanExtension (F.op.lanUnit.app P) have eq := F.op.lanUnit.naturality f dsimp at eq ⊢ rw [Functor.descOfIsLeftKanExtension_fac_assoc, ← reassoc_of% eq, Functor.descOfIsLeftKanExtension_fac, presheafHom_naturality] lemma natTrans_app_yoneda_obj (X : C) : (natTrans φ).app (yoneda.obj X) = (compYonedaIsoYonedaCompLan F).inv.app X ≫ φ.app X := by dsimp [natTrans] apply (F.op.lan.obj (yoneda.obj X)).hom_ext_of_isLeftKanExtension (F.op.lanUnit.app _) rw [Functor.descOfIsLeftKanExtension_fac] apply yonedaEquiv.injective rw [yonedaEquiv_presheafHom_yoneda_obj] exact congr_arg _ (compYonedaIsoYonedaCompLan_inv_app_app_apply_eq_id F X).symm end variable [∀ (P : Cᵒᵖ ⥤ Type v₁), F.op.HasLeftKanExtension P] /-- Given a functor `F : C ⥤ D`, this definition is part of the verification that `Functor.LeftExtension.mk F.op.lan (compYonedaIsoYonedaCompLan F).hom` is universal, i.e. that `F.op.lan : (Cᵒᵖ ⥤ Type v₁) ⥤ Dᵒᵖ ⥤ Type v₁` is the left Kan extension of `F ⋙ yoneda : C ⥤ Dᵒᵖ ⥤ Type v₁` along `yoneda : C ⥤ Cᵒᵖ ⥤ Type v₁`. -/ noncomputable def extensionHom (Φ : yoneda.LeftExtension (F ⋙ yoneda)) : Functor.LeftExtension.mk F.op.lan (compYonedaIsoYonedaCompLan F).hom ⟶ Φ := StructuredArrow.homMk (natTrans Φ.hom) (by ext X : 2 dsimp rw [natTrans_app_yoneda_obj, Iso.hom_inv_id_app_assoc]) @[ext] lemma hom_ext {Φ : yoneda.LeftExtension (F ⋙ yoneda)} (f g : Functor.LeftExtension.mk F.op.lan (compYonedaIsoYonedaCompLan F).hom ⟶ Φ) : f = g := by ext P : 3 apply (F.op.lan.obj P).hom_ext_of_isLeftKanExtension (F.op.lanUnit.app P) apply (colimitOfRepresentable P).hom_ext intro x have eq := F.op.lanUnit.naturality (yonedaEquiv.symm x.unop.2) have eq₁ := congr_fun (congr_app (congr_app (StructuredArrow.w f) x.unop.1.unop) (F.op.obj x.unop.1)) (𝟙 _) have eq₂ := congr_fun (congr_app (congr_app (StructuredArrow.w g) x.unop.1.unop) (F.op.obj x.unop.1)) (𝟙 _) dsimp at eq₁ eq₂ eq ⊢ simp only [reassoc_of% eq, ← Functor.whiskerLeft_comp] congr 2 simp only [← cancel_epi ((compYonedaIsoYonedaCompLan F).hom.app x.unop.1.unop), NatTrans.naturality] apply yonedaEquiv.injective dsimp [yonedaEquiv_apply] rw [eq₁, eq₂] end compYonedaIsoYonedaCompLan variable [∀ (P : Cᵒᵖ ⥤ Type v₁), F.op.HasLeftKanExtension P] noncomputable instance (Φ : StructuredArrow (F ⋙ yoneda) ((Functor.whiskeringLeft C (Cᵒᵖ ⥤ Type v₁) (Dᵒᵖ ⥤ Type v₁)).obj yoneda)) : Unique (Functor.LeftExtension.mk F.op.lan (compYonedaIsoYonedaCompLan F).hom ⟶ Φ) where default := compYonedaIsoYonedaCompLan.extensionHom Φ uniq _ := compYonedaIsoYonedaCompLan.hom_ext _ _ /-- Given a functor `F : C ⥤ D`, `F.op.lan : (Cᵒᵖ ⥤ Type v₁) ⥤ Dᵒᵖ ⥤ Type v₁` is the left Kan extension of `F ⋙ yoneda : C ⥤ Dᵒᵖ ⥤ Type v₁` along `yoneda : C ⥤ Cᵒᵖ ⥤ Type v₁`. -/ instance : F.op.lan.IsLeftKanExtension (compYonedaIsoYonedaCompLan F).hom := ⟨⟨Limits.IsInitial.ofUnique _⟩⟩ end section variable {C : Type u₁} [Category.{v₁} C] (P : Cᵒᵖ ⥤ Type v₁) /-- For a presheaf `P`, consider the forgetful functor from the category of representable presheaves over `P` to the category of presheaves. There is a tautological cocone over this functor whose leg for a natural transformation `V ⟶ P` with `V` representable is just that natural transformation. -/ @[simps] def tautologicalCocone : Cocone (CostructuredArrow.proj yoneda P ⋙ yoneda) where pt := P ι := { app := fun X => X.hom } /-- The tautological cocone with point `P` is a colimit cocone, exhibiting `P` as a colimit of representables. Proposition 2.6.3(i) in [Kashiwara2006] -/ def isColimitTautologicalCocone : IsColimit (tautologicalCocone P) where desc := fun s => by refine ⟨fun X t => yonedaEquiv (s.ι.app (CostructuredArrow.mk (yonedaEquiv.symm t))), ?_⟩ intros X Y f ext t dsimp rw [yonedaEquiv_naturality', yonedaEquiv_symm_map] simpa using (s.ι.naturality (CostructuredArrow.homMk' (CostructuredArrow.mk (yonedaEquiv.symm t)) f.unop)).symm fac := by intro s t dsimp apply yonedaEquiv.injective rw [yonedaEquiv_comp] dsimp only rw [Equiv.symm_apply_apply] rfl uniq := by intro s j h ext V x obtain ⟨t, rfl⟩ := yonedaEquiv.surjective x dsimp rw [Equiv.symm_apply_apply, ← yonedaEquiv_comp] exact congr_arg _ (h (CostructuredArrow.mk t)) variable {I : Type v₁} [SmallCategory I] (F : I ⥤ C) /-- Given a functor `F : I ⥤ C`, a cocone `c` on `F ⋙ yoneda : I ⥤ Cᵒᵖ ⥤ Type v₁` induces a functor `I ⥤ CostructuredArrow yoneda c.pt` which maps `i : I` to the leg `yoneda.obj (F.obj i) ⟶ c.pt`. If `c` is a colimit cocone, then that functor is final. Proposition 2.6.3(ii) in [Kashiwara2006] -/ theorem final_toCostructuredArrow_comp_pre {c : Cocone (F ⋙ yoneda)} (hc : IsColimit c) : Functor.Final (c.toCostructuredArrow ⋙ CostructuredArrow.pre F yoneda c.pt) := by apply Functor.final_of_isTerminal_colimit_comp_yoneda suffices IsTerminal (colimit ((c.toCostructuredArrow ⋙ CostructuredArrow.pre F yoneda c.pt) ⋙ CostructuredArrow.toOver yoneda c.pt)) by apply IsTerminal.isTerminalOfObj (overEquivPresheafCostructuredArrow c.pt).inverse apply IsTerminal.ofIso this refine ?_ ≪≫ (preservesColimitIso (overEquivPresheafCostructuredArrow c.pt).inverse _).symm apply HasColimit.isoOfNatIso exact Functor.isoWhiskerLeft _ (CostructuredArrow.toOverCompOverEquivPresheafCostructuredArrow c.pt).isoCompInverse apply IsTerminal.ofIso Over.mkIdTerminal let isc : IsColimit ((Over.forget _).mapCocone _) := isColimitOfPreserves _ (colimit.isColimit ((c.toCostructuredArrow ⋙ CostructuredArrow.pre F yoneda c.pt) ⋙ CostructuredArrow.toOver yoneda c.pt)) exact Over.isoMk (hc.coconePointUniqueUpToIso isc) (hc.hom_ext fun i => by simp) end end Presheaf end CategoryTheory
Bound.lean
/- Copyright (c) 2024 Geoffrey Irving. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Geoffrey Irving -/ import Aesop import Mathlib.Tactic.Bound.Attribute import Mathlib.Tactic.Lemma import Mathlib.Tactic.Linarith.Frontend import Mathlib.Tactic.NormNum.Core /-! ## The `bound` tactic `bound` is an `aesop` wrapper that proves inequalities by straightforward recursion on structure, assuming that intermediate terms are nonnegative or positive as needed. It also has some support for guessing where it is unclear where to recurse, such as which side of a `min` or `max` to use as the bound or whether to assume a power is less than or greater than one. The functionality of `bound` overlaps with `positivity` and `gcongr`, but can jump back and forth between `0 ≤ x` and `x ≤ y`-type inequalities. For example, `bound` proves `0 ≤ c → b ≤ a → 0 ≤ a * c - b * c` by turning the goal into `b * c ≤ a * c`, then using `mul_le_mul_of_nonneg_right`. `bound` also uses specialized lemmas for goals of the form `1 ≤ x, 1 < x, x ≤ 1, x < 1`. Additional hypotheses can be passed as `bound [h0, h1 n, ...]`. This is equivalent to declaring them via `have` before calling `bound`. See `MathlibTest/Bound/bound.lean` for tests. ### Calc usage Since `bound` requires the inequality proof to exactly match the structure of the expression, it is often useful to iterate between `bound` and `rw / simp` using `calc`. Here is an example: ``` -- Calc example: A weak lower bound for `z ↦ z^2 + c` lemma le_sqr_add {c z : ℂ} (cz : abs c ≤ abs z) (z3 : 3 ≤ abs z) : 2 * abs z ≤ abs (z^2 + c) := by calc abs (z^2 + c) _ ≥ abs (z^2) - abs c := by bound _ ≥ abs (z^2) - abs z := by bound _ ≥ (abs z - 1) * abs z := by rw [mul_comm, mul_sub_one, ← pow_two, ← abs.map_pow] _ ≥ 2 * abs z := by bound ``` ### Aesop rules `bound` uses threes types of aesop rules: `apply`, `forward`, and closing `tactic`s. To register a lemma as an `apply` rule, tag it with `@[bound]`. It will be automatically converted into either a `norm apply` or `safe apply` rule depending on the number and type of its hypotheses: 1. Nonnegativity/positivity/nonpositivity/negativity hypotheses get score 1 (those involving `0`). 2. Other inequalities get score 10. 3. Disjunctions `a ∨ b` get score 100, plus the score of `a` and `b`. Score `0` lemmas turn into `norm apply` rules, and score `0 < s` lemmas turn into `safe apply s` rules. The score is roughly lexicographic ordering on the counts of the three type (guessing, general, involving-zero), and tries to minimize the complexity of hypotheses we have to prove. See `Mathlib/Tactic/Bound/Attribute.lean` for the full algorithm. To register a lemma as a `forward` rule, tag it with `@[bound_forward]`. The most important builtin forward rule is `le_of_lt`, so that strict inequalities can be used to prove weak inequalities. Another example is `HasFPowerSeriesOnBall.r_pos`, so that `bound` knows that any power series present in the context have positive radius of convergence. Custom `@[bound_forward]` rules that similarly expose inequalities inside structures are often useful. ### Guessing apply rules There are several cases where there are two standard ways to recurse down an inequality, and it is not obvious which is correct without more information. For example, `a ≤ min b c` is registered as a `safe apply 4` rule, since we always need to prove `a ≤ b ∧ a ≤ c`. But if we see `min a b ≤ c`, either `a ≤ c` or `b ≤ c` suffices, and we don't know which. In these cases we declare a new lemma with an `∨` hypotheses that covers the two cases. Tagging it as `@[bound]` will add a +100 penalty to the score, so that it will be used only if necessary. Aesop will then try both ways by splitting on the resulting `∨` hypothesis. Currently the two types of guessing rules are 1. `min` and `max` rules, for both `≤` and `<` 2. `pow` and `rpow` monotonicity rules which branch on `1 ≤ a` or `a ≤ 1`. ### Closing tactics We close numerical goals with `norm_num` and `linarith`. -/ open Lean Elab Meta Term Mathlib.Tactic Syntax open Lean.Elab.Tactic (liftMetaTactic liftMetaTactic' TacticM getMainGoal) namespace Mathlib.Tactic.Bound /-! ### `.mpr` lemmas of iff statements for use as Aesop apply rules Once Aesop can do general terms directly, we can remove these: https://github.com/leanprover-community/aesop/issues/107 -/ lemma mul_lt_mul_left_of_pos_of_lt {α : Type} {a b c : α} [Mul α] [Zero α] [Preorder α] [PosMulStrictMono α] [PosMulReflectLT α] (a0 : 0 < a) : b < c → a * b < a * c := (mul_lt_mul_left a0).mpr lemma mul_lt_mul_right_of_pos_of_lt {α : Type} {a b c : α} [Mul α] [Zero α] [Preorder α] [MulPosStrictMono α] [MulPosReflectLT α] (c0 : 0 < c) : a < b → a * c < b * c := (mul_lt_mul_right c0).mpr lemma Nat.cast_pos_of_pos {R : Type} [Semiring R] [PartialOrder R] [IsOrderedRing R] [Nontrivial R] {n : ℕ} : 0 < n → 0 < (n : R) := Nat.cast_pos.mpr lemma Nat.one_le_cast_of_le {α : Type} [AddCommMonoidWithOne α] [PartialOrder α] [AddLeftMono α] [ZeroLEOneClass α] [CharZero α] {n : ℕ} : 1 ≤ n → 1 ≤ (n : α) := Nat.one_le_cast.mpr /-! ### Apply rules for `bound` Most `bound` lemmas are registered in-place where the lemma is declared. These are only the lemmas that do not require additional imports within this file. -/ -- Reflexivity attribute [bound] le_refl -- 0 ≤, 0 < attribute [bound] sq_nonneg Nat.cast_nonneg abs_nonneg Nat.zero_lt_succ pow_pos pow_nonneg sub_nonneg_of_le sub_pos_of_lt inv_nonneg_of_nonneg inv_pos_of_pos tsub_pos_of_lt mul_pos mul_nonneg div_pos div_nonneg add_nonneg -- 1 ≤, ≤ 1 attribute [bound] Nat.one_le_cast_of_le one_le_mul_of_one_le_of_one_le -- ≤ attribute [bound] le_abs_self neg_abs_le neg_le_neg tsub_le_tsub_right mul_le_mul_of_nonneg_left mul_le_mul_of_nonneg_right le_add_of_nonneg_right le_add_of_nonneg_left le_mul_of_one_le_right mul_le_of_le_one_right sub_le_sub add_le_add mul_le_mul -- < attribute [bound] Nat.cast_pos_of_pos neg_lt_neg sub_lt_sub_left sub_lt_sub_right add_lt_add_left add_lt_add_right mul_lt_mul_left_of_pos_of_lt mul_lt_mul_right_of_pos_of_lt -- min and max attribute [bound] min_le_right min_le_left le_max_left le_max_right le_min max_le lt_min max_lt -- Memorize a few constants to avoid going to `norm_num` attribute [bound] zero_le_one zero_lt_one zero_le_two zero_lt_two /-! ### Forward rules for `bound` -/ -- Bound applies `le_of_lt` to all hypotheses attribute [bound_forward] le_of_lt /-! ### Guessing rules: when we don't know how to recurse -/ section Guessing variable {α : Type} [LinearOrder α] {a b c : α} -- `min` and `max` guessing lemmas lemma le_max_of_le_left_or_le_right : a ≤ b ∨ a ≤ c → a ≤ max b c := le_max_iff.mpr lemma lt_max_of_lt_left_or_lt_right : a < b ∨ a < c → a < max b c := lt_max_iff.mpr lemma min_le_of_left_le_or_right_le : a ≤ c ∨ b ≤ c → min a b ≤ c := min_le_iff.mpr lemma min_lt_of_left_lt_or_right_lt : a < c ∨ b < c → min a b < c := min_lt_iff.mpr -- Register guessing rules attribute [bound] -- Which side of the `max` should we use as the lower bound? le_max_of_le_left_or_le_right lt_max_of_lt_left_or_lt_right -- Which side of the `min` should we use as the upper bound? min_le_of_left_le_or_right_le min_lt_of_left_lt_or_right_lt end Guessing /-! ### Closing tactics TODO: Kim Morrison noted that we could check for `ℕ` or `ℤ` and try `omega` as well. -/ /-- Close numerical goals with `norm_num` -/ def boundNormNum : Aesop.RuleTac := Aesop.SingleRuleTac.toRuleTac fun i => do let tac := do Mathlib.Meta.NormNum.elabNormNum .missing .missing .missing let goals ← Lean.Elab.Tactic.run i.goal tac |>.run' if !goals.isEmpty then failure return (#[], none, some .hundred) attribute [aesop unsafe 10% tactic (rule_sets := [Bound])] boundNormNum /-- Close numerical and other goals with `linarith` -/ def boundLinarith : Aesop.RuleTac := Aesop.SingleRuleTac.toRuleTac fun i => do Linarith.linarith false [] {} i.goal return (#[], none, some .hundred) attribute [aesop unsafe 5% tactic (rule_sets := [Bound])] boundLinarith /-! ### `bound` tactic implementation -/ /-- Aesop configuration for `bound` -/ def boundConfig : Aesop.Options := { enableSimp := false } end Mathlib.Tactic.Bound /-- `bound` tactic for proving inequalities via straightforward recursion on expression structure. An example use case is ``` -- Calc example: A weak lower bound for `z ↦ z^2 + c` lemma le_sqr_add (c z : ℝ) (cz : ‖c‖ ≤ ‖z‖) (z3 : 3 ≤ ‖z‖) : 2 * ‖z‖ ≤ ‖z^2 + c‖ := by calc ‖z^2 + c‖ _ ≥ ‖z^2‖ - ‖c‖ := by bound _ ≥ ‖z^2‖ - ‖z‖ := by bound _ ≥ (‖z‖ - 1) * ‖z‖ := by rw [mul_comm, mul_sub_one, ← pow_two, ← norm_pow] _ ≥ 2 * ‖z‖ := by bound ``` `bound` is built on top of `aesop`, and uses 1. Apply lemmas registered via the `@[bound]` attribute 2. Forward lemmas registered via the `@[bound_forward]` attribute 3. Local hypotheses from the context 4. Optionally: additional hypotheses provided as `bound [h₀, h₁]` or similar. These are added to the context as if by `have := hᵢ`. The functionality of `bound` overlaps with `positivity` and `gcongr`, but can jump back and forth between `0 ≤ x` and `x ≤ y`-type inequalities. For example, `bound` proves `0 ≤ c → b ≤ a → 0 ≤ a * c - b * c` by turning the goal into `b * c ≤ a * c`, then using `mul_le_mul_of_nonneg_right`. `bound` also contains lemmas for goals of the form `1 ≤ x, 1 < x, x ≤ 1, x < 1`. Conversely, `gcongr` can prove inequalities for more types of relations, supports all `positivity` functionality, and is likely faster since it is more specialized (not built atop `aesop`). -/ syntax "bound " (" [" term,* "]")? : tactic -- Plain `bound` elaboration, with no hypotheses elab_rules : tactic | `(tactic| bound) => do let tac ← `(tactic| aesop (rule_sets := [Bound, -default]) (config := Bound.boundConfig)) liftMetaTactic fun g ↦ do return (← Lean.Elab.runTactic g tac.raw).1 -- Rewrite `bound [h₀, h₁]` into `have := h₀, have := h₁, bound`, and similar macro_rules | `(tactic| bound%$tk [$[$ts],*]) => do let haves ← ts.mapM fun (t : Term) => withRef t `(tactic| have := $t) `(tactic| ($haves;*; bound%$tk)) /-! We register `bound` with the `hint` tactic. -/ register_hint bound
IsAlgClosed.lean
/- Copyright (c) 2025 Junyan Xu. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Junyan Xu -/ import Mathlib.FieldTheory.IsAlgClosed.Basic import Mathlib.RingTheory.SimpleModule.WedderburnArtin /-! # Wedderburn–Artin Theorem over an algebraically closed field -/ variable (F R : Type*) [Field F] [IsAlgClosed F] [Ring R] [Algebra F R] /-- The **Wedderburn–Artin Theorem** over algebraically closed fields: a finite-dimensional simple algebra over an algebraically closed field is isomorphic to a matrix algebra over the field. -/ theorem IsSimpleRing.exists_algEquiv_matrix_of_isAlgClosed [IsSimpleRing R] [FiniteDimensional F R] : ∃ (n : ℕ) (_ : NeZero n), Nonempty (R ≃ₐ[F] Matrix (Fin n) (Fin n) F) := have := IsArtinianRing.of_finite F R have ⟨n, hn, D, _, _, _, ⟨e⟩⟩ := exists_algEquiv_matrix_divisionRing_finite F R ⟨n, hn, ⟨e.trans <| .mapMatrix <| .symm <| .ofBijective (Algebra.ofId F D) IsAlgClosed.algebraMap_bijective_of_isIntegral⟩⟩ /-- The **Wedderburn–Artin Theorem** over algebraically closed fields: a finite-dimensional semisimple algebra over an algebraically closed field is isomorphic to a product of matrix algebras over the field. -/ theorem IsSemisimpleRing.exists_algEquiv_pi_matrix_of_isAlgClosed [IsSemisimpleRing R] [FiniteDimensional F R] : ∃ (n : ℕ) (d : Fin n → ℕ), (∀ i, NeZero (d i)) ∧ Nonempty (R ≃ₐ[F] Π i, Matrix (Fin (d i)) (Fin (d i)) F) := have ⟨n, D, d, _, _, _, hd, ⟨e⟩⟩ := exists_algEquiv_pi_matrix_divisionRing_finite F R ⟨n, d, hd, ⟨e.trans <| .piCongrRight fun i ↦ .mapMatrix <| .symm <| .ofBijective (Algebra.ofId F (D i)) IsAlgClosed.algebraMap_bijective_of_isIntegral⟩⟩
Limit.lean
/- Copyright (c) 2020 Kim Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kim Morrison -/ import Mathlib.CategoryTheory.Category.Cat import Mathlib.CategoryTheory.Limits.Types.Limits import Mathlib.CategoryTheory.Limits.Preserves.Basic /-! # The category of small categories has all small limits. An object in the limit consists of a family of objects, which are carried to one another by the functors in the diagram. A morphism between two such objects is a family of morphisms between the corresponding objects, which are carried to one another by the action on morphisms of the functors in the diagram. ## Future work Can the indexing category live in a lower universe? -/ noncomputable section universe v u open CategoryTheory.Limits namespace CategoryTheory variable {J : Type v} [SmallCategory J] namespace Cat namespace HasLimits instance categoryObjects {F : J ⥤ Cat.{u, u}} {j} : SmallCategory ((F ⋙ Cat.objects.{u, u}).obj j) := (F.obj j).str /-- Auxiliary definition: the diagram whose limit gives the morphism space between two objects of the limit category. -/ @[simps] def homDiagram {F : J ⥤ Cat.{v, v}} (X Y : limit (F ⋙ Cat.objects.{v, v})) : J ⥤ Type v where obj j := limit.π (F ⋙ Cat.objects) j X ⟶ limit.π (F ⋙ Cat.objects) j Y map f g := by refine eqToHom ?_ ≫ (F.map f).map g ≫ eqToHom ?_ · exact (congr_fun (limit.w (F ⋙ Cat.objects) f) X).symm · exact congr_fun (limit.w (F ⋙ Cat.objects) f) Y map_id X := by funext f letI : Category (objects.obj (F.obj X)) := (inferInstance : Category (F.obj X)) simp [Functor.congr_hom (F.map_id X) f] map_comp {_ _ Z} f g := by funext h letI : Category (objects.obj (F.obj Z)) := (inferInstance : Category (F.obj Z)) simp [Functor.congr_hom (F.map_comp f g) h, eqToHom_map] @[simps] instance (F : J ⥤ Cat.{v, v}) : Category (limit (F ⋙ Cat.objects)) where Hom X Y := limit (homDiagram X Y) id X := Types.Limit.mk.{v, v} (homDiagram X X) (fun _ => 𝟙 _) fun j j' f => by simp comp {X Y Z} f g := Types.Limit.mk.{v, v} (homDiagram X Z) (fun j => limit.π (homDiagram X Y) j f ≫ limit.π (homDiagram Y Z) j g) fun j j' h => by simp [← congr_fun (limit.w (homDiagram X Y) h) f, ← congr_fun (limit.w (homDiagram Y Z) h) g] id_comp _ := by apply Types.limit_ext.{v, v} simp comp_id _ := by apply Types.limit_ext.{v, v} simp /-- Auxiliary definition: the limit category. -/ @[simps] def limitConeX (F : J ⥤ Cat.{v, v}) : Cat.{v, v} where α := limit (F ⋙ Cat.objects) /-- Auxiliary definition: the cone over the limit category. -/ @[simps] def limitCone (F : J ⥤ Cat.{v, v}) : Cone F where pt := limitConeX F π := { app := fun j => { obj := limit.π (F ⋙ Cat.objects) j map := fun f => limit.π (homDiagram _ _) j f } naturality := fun _ _ f => CategoryTheory.Functor.ext (fun X => (congr_fun (limit.w (F ⋙ Cat.objects) f) X).symm) fun X Y h => (congr_fun (limit.w (homDiagram X Y) f) h).symm } /-- Auxiliary definition: the universal morphism to the proposed limit cone. -/ @[simps] def limitConeLift (F : J ⥤ Cat.{v, v}) (s : Cone F) : s.pt ⟶ limitConeX F where obj := limit.lift (F ⋙ Cat.objects) { pt := s.pt π := { app := fun j => (s.π.app j).obj naturality := fun _ _ f => objects.congr_map (s.π.naturality f) } } map f := by fapply Types.Limit.mk.{v, v} · intro j refine eqToHom ?_ ≫ (s.π.app j).map f ≫ eqToHom ?_ <;> simp · intro j j' h dsimp simp only [Category.assoc, Functor.map_comp, eqToHom_map, eqToHom_trans, eqToHom_trans_assoc, ← Functor.comp_map] have := (s.π.naturality h).symm dsimp at this rw [Category.id_comp] at this erw [Functor.congr_hom this f] simp @[simp] theorem limit_π_homDiagram_eqToHom {F : J ⥤ Cat.{v, v}} (X Y : limit (F ⋙ Cat.objects.{v, v})) (j : J) (h : X = Y) : limit.π (homDiagram X Y) j (eqToHom h) = eqToHom (congr_arg (limit.π (F ⋙ Cat.objects.{v, v}) j) h) := by subst h simp /-- Auxiliary definition: the proposed cone is a limit cone. -/ def limitConeIsLimit (F : J ⥤ Cat.{v, v}) : IsLimit (limitCone F) where lift := limitConeLift F fac s j := CategoryTheory.Functor.ext (by simp) fun X Y f => by dsimp [limitConeLift] exact Types.Limit.π_mk.{v, v} _ _ _ _ uniq s m w := by symm refine CategoryTheory.Functor.ext ?_ ?_ · intro X apply Types.limit_ext.{v, v} intro j simp [Types.Limit.lift_π_apply', ← w j] · intro X Y f simp [fun j => Functor.congr_hom (w j).symm f] end HasLimits /-- The category of small categories has all small limits. -/ instance : HasLimits Cat.{v, v} where has_limits_of_shape _ := { has_limit := fun F => ⟨⟨⟨HasLimits.limitCone F, HasLimits.limitConeIsLimit F⟩⟩⟩ } instance : PreservesLimits Cat.objects.{v, v} where preservesLimitsOfShape := { preservesLimit := fun {F} => preservesLimit_of_preserves_limit_cone (HasLimits.limitConeIsLimit F) (Limits.IsLimit.ofIsoLimit (limit.isLimit (F ⋙ Cat.objects)) (Cones.ext (by rfl) (by cat_disch))) } end Cat end CategoryTheory
Localization.lean
/- Copyright (c) 2024 Christian Merten. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Christian Merten -/ import Mathlib.Algebra.Module.LocalizedModule.IsLocalization import Mathlib.Algebra.MvPolynomial.CommRing import Mathlib.RingTheory.Ideal.Quotient.Operations import Mathlib.RingTheory.Localization.Away.Basic import Mathlib.RingTheory.Localization.BaseChange import Mathlib.RingTheory.TensorProduct.MvPolynomial /-! # Localization and multivariate polynomial rings In this file we show some results connecting multivariate polynomial rings and localization. ## Main results - `MvPolynomial.isLocalization`: If `S` is the localization of `R` at a submonoid `M`, then `MvPolynomial σ S` is the localization of `MvPolynomial σ R` at the image of `M` in `MvPolynomial σ R`. -/ variable {σ R : Type*} [CommRing R] (M : Submonoid R) variable (S : Type*) [CommRing S] [Algebra R S] namespace MvPolynomial variable [IsLocalization M S] attribute [local instance] algebraMvPolynomial /-- If `S` is the localization of `R` at a submonoid `M`, then `MvPolynomial σ S` is the localization of `MvPolynomial σ R` at `M.map MvPolynomial.C`. See also `Polynomial.isLocalization` for the univariate case. -/ instance isLocalization : IsLocalization (M.map <| C (σ := σ)) (MvPolynomial σ S) := isLocalizedModule_iff_isLocalization.mp <| (isLocalizedModule_iff_isBaseChange M S _).mpr <| .of_equiv (algebraTensorAlgEquiv _ _).toLinearEquiv fun _ ↦ by simp lemma isLocalization_C_mk' (a : R) (m : M) : C (IsLocalization.mk' S a m) = IsLocalization.mk' (MvPolynomial σ S) (C (σ := σ) a) ⟨C m, Submonoid.mem_map_of_mem C m.property⟩ := by simp_rw [IsLocalization.eq_mk'_iff_mul_eq, algebraMap_def, map_C, ← map_mul, IsLocalization.mk'_spec] end MvPolynomial namespace IsLocalization.Away open MvPolynomial variable (r : R) [IsLocalization.Away r S] /-- The canonical algebra map from `MvPolynomial Unit R` quotiented by `C r * X () - 1` to the localization of `R` away from `r`. -/ private noncomputable def auxHom : (MvPolynomial Unit R) ⧸ (Ideal.span { C r * X () - 1 }) →ₐ[R] S := Ideal.Quotient.liftₐ (Ideal.span { C r * X () - 1}) (aeval (fun _ ↦ invSelf r)) <| by intro p hp refine Submodule.span_induction ?_ ?_ ?_ ?_ hp · rintro p ⟨q, rfl⟩ simp · simp · intro p q _ _ hp hq simp [hp, hq] · intro a x _ hx simp [hx] @[simp] private lemma auxHom_mk (p : MvPolynomial Unit R) : auxHom S r p = aeval (S₁ := S) (fun _ ↦ invSelf r) p := rfl private noncomputable def auxInv : S →+* (MvPolynomial Unit R) ⧸ Ideal.span { C r * X () - 1 } := letI g : R →+* MvPolynomial Unit R ⧸ (Ideal.span { C r * X () - 1 }) := (Ideal.Quotient.mk _).comp C IsLocalization.Away.lift (S := S) (g := g) r <| by simp only [RingHom.coe_comp, Function.comp_apply, g] rw [isUnit_iff_exists_inv] use (Ideal.Quotient.mk _ <| X ()) rw [← map_mul, ← map_one (Ideal.Quotient.mk _), Ideal.Quotient.mk_eq_mk_iff_sub_mem] exact Ideal.mem_span_singleton_self (C r * X () - 1) private lemma auxHom_auxInv : (auxHom S r).toRingHom.comp (auxInv S r) = RingHom.id S := by apply IsLocalization.ringHom_ext (Submonoid.powers r) ext x simp [auxInv] private lemma auxInv_auxHom : (auxInv S r).comp (auxHom (S := S) r).toRingHom = RingHom.id _ := by rw [← RingHom.cancel_right (Ideal.Quotient.mk_surjective)] ext x · simp [auxInv] · simp only [auxInv, AlgHom.toRingHom_eq_coe, RingHom.coe_comp, RingHom.coe_coe, Function.comp_apply, auxHom_mk, aeval_X, RingHomCompTriple.comp_eq, invSelf, Away.lift, lift_mk'_spec] simp only [map_one] rw [← map_one (Ideal.Quotient.mk _), ← map_mul, Ideal.Quotient.mk_eq_mk_iff_sub_mem, ← Ideal.neg_mem_iff, neg_sub] exact Ideal.mem_span_singleton_self (C r * X x - 1) /-- The canonical algebra isomorphism from `MvPolynomial Unit R` quotiented by `C r * X () - 1` to the localization of `R` away from `r`. -/ noncomputable def mvPolynomialQuotientEquiv : ((MvPolynomial Unit R) ⧸ Ideal.span { C r * X () - 1 }) ≃ₐ[R] S where toFun := auxHom S r invFun := auxInv S r left_inv x := by simpa using congrFun (congrArg DFunLike.coe <| auxInv_auxHom S r) x right_inv s := by simpa using congrFun (congrArg DFunLike.coe <| auxHom_auxInv S r) s map_mul' := by simp map_add' := by simp commutes' := by simp @[simp] lemma mvPolynomialQuotientEquiv_apply (p : MvPolynomial Unit R) : mvPolynomialQuotientEquiv S r (Ideal.Quotient.mk _ p) = aeval (S₁ := S) (fun _ ↦ invSelf r) p := rfl end IsLocalization.Away
rat.v
(* (c) Copyright 2006-2016 Microsoft Corporation and Inria. *) (* Distributed under the terms of CeCILL-B. *) From HB Require Import structures. From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq choice. From mathcomp Require Import prime fintype finfun bigop order tuple ssralg. From mathcomp Require Import countalg div ssrnum ssrint archimedean poly zmodp. From mathcomp Require Import polydiv intdiv matrix mxalgebra vector. (******************************************************************************) (* This file defines a datatype for rational numbers and equips it with a *) (* structure of archimedean, real field, with int and nat declared as closed *) (* subrings. *) (* rat == the type of rational number, with single constructor Rat *) (* <number> == <number> as a rat with <number> a decimal constant. *) (* This notation is in rat_scope (delimited with %Q). *) (* n%:Q == explicit cast from int to rat, ie. the specialization to *) (* rationals of the generic ring morphism n%:~R *) (* numq r == numerator of (r : rat) *) (* denq r == denominator of (r : rat) *) (* ratr r == generic embedding of (r : rat) into an arbitrary unit ring.*) (* [rat x // y] == smart constructor for rationals, definitionally equal *) (* to x / y for concrete values, intended for printing only *) (* of normal forms. The parsable notation is for debugging. *) (* inIntSpan X v <-> v is an integral linear combination of elements of *) (* X : seq V, where V is a zmodType. We prove that this is a *) (* decidable property for Q-vector spaces. *) (******************************************************************************) Import Order.TTheory GRing.Theory Num.Theory. Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. Reserved Notation "[ 'rat' x // y ]" (format "[ 'rat' x // y ]"). Reserved Notation "n %:Q" (left associativity, format "n %:Q"). Local Open Scope ring_scope. Local Notation sgr := Num.sg. Record rat : Set := Rat { valq : (int * int); _ : (0 < valq.2) && coprime `|valq.1| `|valq.2| }. Bind Scope ring_scope with rat. Delimit Scope rat_scope with Q. Definition ratz (n : int) := @Rat (n, 1) (coprimen1 _). (* Coercion ratz (n : int) := @Rat (n, 1) (coprimen1 _). *) Definition rat_isSub := Eval hnf in [isSub for valq]. HB.instance Definition _ := rat_isSub. #[hnf] HB.instance Definition _ := [Equality of rat by <:]. HB.instance Definition _ := [Countable of rat by <:]. Definition numq x := (valq x).1. Definition denq x := (valq x).2. Arguments numq : simpl never. Arguments denq : simpl never. Lemma denq_gt0 x : 0 < denq x. Proof. by rewrite /denq; case: x=> [[a b] /= /andP []]. Qed. #[global] Hint Resolve denq_gt0 : core. Definition denq_ge0 x := ltW (denq_gt0 x). Lemma denq_lt0 x : (denq x < 0) = false. Proof. by rewrite lt_gtF. Qed. Lemma denq_neq0 x : denq x != 0. Proof. by rewrite /denq gt_eqF ?denq_gt0. Qed. #[global] Hint Resolve denq_neq0 : core. Lemma denq_eq0 x : (denq x == 0) = false. Proof. exact: negPf (denq_neq0 _). Qed. Lemma coprime_num_den x : coprime `|numq x| `|denq x|. Proof. by rewrite /numq /denq; case: x=> [[a b] /= /andP []]. Qed. Fact RatK x P : @Rat (numq x, denq x) P = x. Proof. by move: x P => [[a b] P'] P; apply: val_inj. Qed. Definition fracq_subdef x := if x.2 != 0 then let g := gcdn `|x.1| `|x.2| in ((-1) ^ ((x.2 < 0) (+) (x.1 < 0)) * (`|x.1| %/ g)%:Z, (`|x.2| %/ g)%:Z) else (0, 1). Arguments fracq_subdef /. Definition fracq_opt_subdef (x : int * int) := if (0 < x.2) && coprime `|x.1| `|x.2| then x else fracq_subdef x. Lemma fracq_opt_subdefE x : fracq_opt_subdef x = fracq_subdef x. Proof. rewrite /fracq_opt_subdef; case: ifP => //; case: x => n d /= /andP[d_gt0 cnd]. rewrite /fracq_subdef gt_eqF//= lt_gtF//= (eqP cnd) !divn1 abszEsg gtz0_abs//. rewrite mulrA sgz_def mulrnAr -signr_addb addbb expr0. by have [->|] := eqVneq n 0; rewrite (mulr0, mul1r). Qed. Fact fracq_subproof x (y := fracq_opt_subdef x) : (0 < y.2) && (coprime `|y.1| `|y.2|). Proof. rewrite {}/y fracq_opt_subdefE /=; have [] //= := eqVneq x.2 0. case: x => [/= n d]; rewrite -absz_gt0 => dN0. have ggt0 : (0 < gcdn `|n| `|d|)%N by rewrite gcdn_gt0 dN0 orbT. rewrite ltz_nat divn_gt0// dvdn_leq ?dvdn_gcdr//=. rewrite abszM abszX abszN1 exp1n mul1n absz_nat. rewrite /coprime -(@eqn_pmul2r (gcdn `|n| `|d|))// mul1n. by rewrite muln_gcdl !divnK ?(dvdn_gcdl, dvdn_gcdr). Qed. Lemma fracq_opt_subdef_id x : fracq_opt_subdef (fracq_opt_subdef x) = fracq_subdef x. Proof. rewrite [fracq_opt_subdef (_ x)]/fracq_opt_subdef. by rewrite fracq_subproof fracq_opt_subdefE. Qed. (* We use a match expression in order to "lock" the definition of fracq. *) (* Indeed, the kernel will try to reduce a fracq only when applied to *) (* a term which has "enough" constructors: i.e. it reduces to a pair of *) (* a Posz or Negz on the first component, and a Posz of 0 or S, or a Negz *) (* on the second component. See issue #698. *) (* Additionally, we use fracq_opt_subdef to precompute the normal form *) (* before we use fracq_subproof in order to make sure the proof will be *) (* independent from the input of fracq. This ensure reflexivity of any *) (* computation involving rationals as long as all operators use fracq. *) (* As a consequence val (fracq x) = fracq_opt_subdef (fracq_opt_subdef x)) *) Definition fracq '((n', d')) : rat := match d', n' with | Posz 0 as d, _ as n => Rat (fracq_subproof (1, 0)) | _ as d, Posz _ as n | _ as d, _ as n => Rat (fracq_subproof (fracq_opt_subdef (n, d))) end. Arguments fracq : simpl never. (* Define a Number Notation for rat in rat_scope *) (* Since rat values obtained from fracq contain fracq_subdef, which is not *) (* an inductive constructor, we need to go through an intermediate *) (* inductive type. *) Variant Irat_prf := Ifracq_subproof : (int * int) -> Irat_prf. Variant Irat := IRat : (int * int) -> Irat_prf -> Irat. Definition parse (x : Number.number) : option Irat := let parse_pos i f := let nf := Decimal.nb_digits f in let d := (10 ^ nf)%nat in let n := (Nat.of_uint i * d + Nat.of_uint f)%nat in valq (fracq (Posz n, Posz d)) in let parse i f := match i with | Decimal.Pos i => parse_pos i f | Decimal.Neg i => let (n, d) := parse_pos i f in ((- n)%R, d) end in match x with | Number.Decimal (Decimal.Decimal i f) => let nd := parse i f in Some (IRat nd (Ifracq_subproof nd)) | Number.Decimal (Decimal.DecimalExp _ _ _) => None | Number.Hexadecimal _ => None end. Definition print (r : Irat) : option Number.number := let print_pos n d := if d == 1%nat then Some (Nat.to_uint n, Decimal.Nil) else let d2d5 := match prime_decomp d with | [:: (2, d2); (5, d5)] => Some (d2, d5) | [:: (2, d2)] => Some (d2, O) | [:: (5, d5)] => Some (O, d5) | _ => None end in match d2d5 with | Some (d2, d5) => let f := (2 ^ (d5 - d2) * 5 ^ (d2 - d5))%nat in let (i, f) := edivn (n * f) (d * f) in Some (Nat.to_uint i, Nat.to_uint f) | None => None end in let print_IRat nd := match nd with | (Posz n, Posz d) => match print_pos n d with | Some (i, f) => Some (Decimal.Pos i, f) | None => None end | (Negz n, Posz d) => match print_pos n.+1 d with | Some (i, f) => Some (Decimal.Neg i, f) | None => None end | (_, Negz _) => None end in match r with | IRat nd _ => match print_IRat nd with | Some (i, f) => Some (Number.Decimal (Decimal.Decimal i f)) | None => None end end. Number Notation rat parse print (via Irat mapping [Rat => IRat, fracq_subproof => Ifracq_subproof]) : rat_scope. (* Now, the following should parse as rat (and print unchanged) *) (* Check 12%Q. *) (* Check 3.14%Q. *) (* Check (-3.14)%Q. *) (* Check 0.5%Q. *) (* Check 0.2%Q. *) Lemma val_fracq x : val (fracq x) = fracq_subdef x. Proof. by case: x => [[n|n] [[|[|d]]|d]]//=; rewrite !fracq_opt_subdef_id. Qed. Lemma num_fracq x : numq (fracq x) = if x.2 != 0 then (-1) ^ ((x.2 < 0) (+) (x.1 < 0)) * (`|x.1| %/ gcdn `|x.1| `|x.2|)%:Z else 0. Proof. by rewrite /numq val_fracq/=; case: ifP. Qed. Lemma den_fracq x : denq (fracq x) = if x.2 != 0 then (`|x.2| %/ gcdn `|x.1| `|x.2|)%:Z else 1. Proof. by rewrite /denq val_fracq/=; case: ifP. Qed. Fact ratz_frac n : ratz n = fracq (n, 1). Proof. by apply: val_inj; rewrite val_fracq/= gcdn1 !divn1 abszE mulr_sign_norm. Qed. Fact valqK x : fracq (valq x) = x. Proof. move: x => [[n d] /= Pnd]; apply: val_inj; rewrite ?val_fracq/=. move: Pnd; rewrite /coprime /fracq /= => /andP[] hd -/eqP hnd. by rewrite lt_gtF ?gt_eqF //= hnd !divn1 mulz_sign_abs abszE gtr0_norm. Qed. Definition scalq '(n, d) := sgr d * (gcdn `|n| `|d|)%:Z. Lemma scalq_def x : scalq x = sgr x.2 * (gcdn `|x.1| `|x.2|)%:Z. Proof. by case: x. Qed. Fact scalq_eq0 x : (scalq x == 0) = (x.2 == 0). Proof. case: x => n d; rewrite scalq_def /= mulf_eq0 sgr_eq0 /= eqz_nat. rewrite -[gcdn _ _ == 0]negbK -lt0n gcdn_gt0 ?absz_gt0 [X in ~~ X]orbC. by case: sgrP. Qed. Lemma sgr_scalq x : sgr (scalq x) = sgr x.2. Proof. rewrite scalq_def sgrM sgr_id -[(gcdn _ _)%:Z]intz sgr_nat. by rewrite -lt0n gcdn_gt0 ?absz_gt0 orbC; case: sgrP; rewrite // mul0r. Qed. Lemma signr_scalq x : (scalq x < 0) = (x.2 < 0). Proof. by rewrite -!sgr_cp0 sgr_scalq. Qed. Lemma scalqE x : x.2 != 0 -> scalq x = (-1) ^+ (x.2 < 0)%R * (gcdn `|x.1| `|x.2|)%:Z. Proof. by rewrite scalq_def; case: sgrP. Qed. Fact valq_frac x : x.2 != 0 -> x = (scalq x * numq (fracq x), scalq x * denq (fracq x)). Proof. move=> x2_neq0; rewrite scalqE//; move: x2_neq0. case: x => [n d] /= d_neq0; rewrite num_fracq den_fracq/= ?d_neq0. rewrite mulr_signM -mulrA -!PoszM addKb. do 2!rewrite muln_divCA ?(dvdn_gcdl, dvdn_gcdr) // divnn. by rewrite gcdn_gt0 !absz_gt0 d_neq0 orbT !muln1 !mulz_sign_abs. Qed. Definition zeroq := 0%Q. Definition oneq := 1%Q. Fact frac0q x : fracq (0, x) = zeroq. Proof. apply: val_inj; rewrite //= val_fracq/= div0n !gcd0n !mulr0 !divnn. by have [//|x_neq0] := eqVneq; rewrite absz_gt0 x_neq0. Qed. Fact fracq0 x : fracq (x, 0) = zeroq. Proof. exact/eqP. Qed. Variant fracq_spec (x : int * int) : int * int -> rat -> Type := | FracqSpecN of x.2 = 0 : fracq_spec x (x.1, 0) zeroq | FracqSpecP k fx of k != 0 : fracq_spec x (k * numq fx, k * denq fx) fx. Fact fracqP x : fracq_spec x x (fracq x). Proof. case: x => n d /=; have [d_eq0 | d_neq0] := eqVneq d 0. by rewrite d_eq0 fracq0; constructor. by rewrite {2}[(_, _)]valq_frac //; constructor; rewrite scalq_eq0. Qed. Lemma rat_eqE x y : (x == y) = (numq x == numq y) && (denq x == denq y). Proof. rewrite -val_eqE [val x]surjective_pairing [val y]surjective_pairing /=. by rewrite xpair_eqE. Qed. Lemma sgr_denq x : sgr (denq x) = 1. Proof. by apply/eqP; rewrite sgr_cp0. Qed. Lemma normr_denq x : `|denq x| = denq x. Proof. by rewrite gtr0_norm. Qed. Lemma absz_denq x : `|denq x|%N = denq x :> int. Proof. by rewrite abszE normr_denq. Qed. Lemma rat_eq x y : (x == y) = (numq x * denq y == numq y * denq x). Proof. symmetry; rewrite rat_eqE andbC. have [->|] /= := eqVneq (denq _); first by rewrite (inj_eq (mulIf _)). apply: contraNF => /eqP hxy; rewrite -absz_denq -[eqbRHS]absz_denq. rewrite eqz_nat /= eqn_dvd. rewrite -(@Gauss_dvdr _ `|numq x|) 1?coprime_sym ?coprime_num_den // andbC. rewrite -(@Gauss_dvdr _ `|numq y|) 1?coprime_sym ?coprime_num_den //. by rewrite -!abszM hxy -{1}hxy !abszM !dvdn_mull ?dvdnn. Qed. Fact fracq_eq x y : x.2 != 0 -> y.2 != 0 -> (fracq x == fracq y) = (x.1 * y.2 == y.1 * x.2). Proof. case: fracqP=> //= u fx u_neq0 _; case: fracqP=> //= v fy v_neq0 _; symmetry. rewrite [eqbRHS]mulrC mulrACA [eqbRHS]mulrACA. by rewrite [denq _ * _]mulrC (inj_eq (mulfI _)) ?mulf_neq0 // rat_eq. Qed. Fact fracq_eq0 x : (fracq x == zeroq) = (x.1 == 0) || (x.2 == 0). Proof. move: x=> [n d] /=; have [->|d0] := eqVneq d 0. by rewrite fracq0 eqxx orbT. by rewrite -[zeroq]valqK orbF fracq_eq ?d0 //= mulr1 mul0r. Qed. Fact fracqMM x n d : x != 0 -> fracq (x * n, x * d) = fracq (n, d). Proof. move=> x_neq0; apply/eqP. have [->|d_neq0] := eqVneq d 0; first by rewrite mulr0 !fracq0. by rewrite fracq_eq ?mulf_neq0 //= mulrCA mulrA. Qed. (* We "lock" the definition of addq, oppq, mulq and invq, using a match on *) (* the constructor Rat for both arguments, so that it may only be reduced *) (* when applied to explicit rationals. Since fracq is also "locked" in a *) (* similar way, fracq will not reduce to a Rat x xP unless it is also applied *) (* to "enough" constructors. This preserves the reduction on gound elements *) (* while it suspends it when applied to at least one variable at the leaf of *) (* the arithmetic operation. *) (* Moreover we optimize addition when one or both arguments are integers, *) (* in which case we presimplify the output, this shortens the size of the hnf *) (* of terms of the form N%:Q when N is a concrete natural number. *) Definition addq_subdef (x y : int * int) := let: (x1, x2) := x in let: (y1, y2) := y in match x2, y2 with | Posz 1, Posz 1 => match x1, y1 with | Posz 0, _ => (y1, 1) | _, Posz 0 => (x1, 1) | Posz n, Posz 1 => (Posz n.+1, 1) | Posz 1, Posz n => (Posz n.+1, 1) | _, _ => (x1 + y1, 1) end | Posz 1, _ => (x1 * y2 + y1, y2) | _, Posz 1 => (x1 + y1 * x2, x2) | _, _ => (x1 * y2 + y1 * x2, x2 * y2) end. Definition addq '(Rat x xP) '(Rat y yP) := fracq (addq_subdef x y). Lemma addq_def x y : addq x y = fracq (addq_subdef (valq x) (valq y)). Proof. by case: x; case: y. Qed. Lemma addq_subdefE x y : addq_subdef x y = (x.1 * y.2 + y.1 * x.2, x.2 * y.2). Proof. case: x y => [x1 [[|[|x2]]|x2]] [y1 [[|[|y2]]|y2]]/=; rewrite ?Monoid.simpm//. by case: x1 y1 => [[|[|m]]|m] [[|[|n]]|n]; rewrite ?Monoid.simpm// -PoszD addn1. Qed. Definition oppq_subdef (x : int * int) := (- x.1, x.2). Definition oppq '(Rat x xP) := fracq (oppq_subdef x). Definition oppq_def x : oppq x = fracq (oppq_subdef (valq x)). Proof. by case: x. Qed. Fact addq_subdefC : commutative addq_subdef. Proof. by move=> x y; rewrite !addq_subdefE addrC [x.2 * _]mulrC. Qed. Fact addq_subdefA : associative addq_subdef. Proof. move=> x y z; rewrite !addq_subdefE. by rewrite !mulrA !mulrDl addrA ![_ * x.2]mulrC !mulrA. Qed. Fact addq_frac x y : x.2 != 0 -> y.2 != 0 -> (addq (fracq x) (fracq y)) = fracq (addq_subdef x y). Proof. case: fracqP => // u fx u_neq0 _; case: fracqP => // v fy v_neq0 _. rewrite addq_def !addq_subdefE /=. rewrite ![(_ * numq _) * _]mulrACA [(_ * denq _) * _]mulrACA. by rewrite [v * _]mulrC -mulrDr fracqMM ?mulf_neq0. Qed. Fact ratzD : {morph ratz : x y / x + y >-> addq x y}. Proof. by move=> x y; rewrite !ratz_frac addq_frac// addq_subdefE/= !mulr1. Qed. Fact oppq_frac x : oppq (fracq x) = fracq (oppq_subdef x). Proof. rewrite /oppq_subdef; case: fracqP => /= [|u fx u_neq0]. by rewrite fracq0. by rewrite oppq_def -mulrN fracqMM. Qed. Fact ratzN : {morph ratz : x / - x >-> oppq x}. Proof. by move=> x /=; rewrite !ratz_frac // /add /= !mulr1. Qed. Fact addqC : commutative addq. Proof. by move=> x y; rewrite !addq_def /= addq_subdefC. Qed. Fact addqA : associative addq. Proof. move=> x y z; rewrite -[x]valqK -[y]valqK -[z]valqK. by rewrite ?addq_frac ?addq_subdefA// ?addq_subdefE ?mulf_neq0 ?denq_neq0. Qed. Fact add0q : left_id zeroq addq. Proof. move=> x; rewrite -[x]valqK -[zeroq]valqK addq_frac ?denq_neq0 // !addq_subdefE. by rewrite mul0r add0r mulr1 mul1r -surjective_pairing. Qed. Fact addNq : left_inverse (fracq (0, 1)) oppq addq. Proof. move=> x; rewrite -[x]valqK !(addq_frac, oppq_frac) ?denq_neq0 //. rewrite !addq_subdefE /oppq_subdef //= mulNr addNr; apply/eqP. by rewrite fracq_eq ?mulf_neq0 ?denq_neq0 //= !mul0r. Qed. HB.instance Definition _ := GRing.isZmodule.Build rat addqA addqC add0q addNq. Definition mulq_subdef (x y : int * int) := let: (x1, x2) := x in let: (y1, y2) := y in match x2, y2 with | Posz 1, Posz 1 => (x1 * y1, 1) | Posz 1, _ => (x1 * y1, y2) | _, Posz 1 => (x1 * y1, x2) | _, _ => (x1 * y1, x2 * y2) end. Definition mulq '(Rat x xP) '(Rat y yP) := fracq (mulq_subdef x y). Lemma mulq_def x y : mulq x y = fracq (mulq_subdef (valq x) (valq y)). Proof. by case: x; case: y. Qed. Lemma mulq_subdefE x y : mulq_subdef x y = (x.1 * y.1, x.2 * y.2). Proof. by case: x y => [x1 [[|[|x2]]|x2]] [y1 [[|[|y2]]|y2]]/=; rewrite ?Monoid.simpm. Qed. Fact mulq_subdefC : commutative mulq_subdef. Proof. by move=> x y; rewrite !mulq_subdefE mulrC [_ * x.2]mulrC. Qed. Fact mul_subdefA : associative mulq_subdef. Proof. by move=> x y z; rewrite !mulq_subdefE !mulrA. Qed. Definition invq_subdef (x : int * int) := (x.2, x.1). Definition invq '(Rat x xP) := fracq (invq_subdef x). Lemma invq_def x : invq x = fracq (invq_subdef (valq x)). Proof. by case: x. Qed. Fact mulq_frac x y : (mulq (fracq x) (fracq y)) = fracq (mulq_subdef x y). Proof. rewrite mulq_def !mulq_subdefE; case: (fracqP x) => /= [|u fx u_neq0]. by rewrite !mul0r !mul1r fracq0 frac0q. case: (fracqP y) => /= [|v fy v_neq0]. by rewrite !mulr0 !mulr1 fracq0 frac0q. by rewrite ![_ * (v * _)]mulrACA [RHS]fracqMM ?mulf_neq0. Qed. Fact ratzM : {morph ratz : x y / x * y >-> mulq x y}. Proof. by move=> x y /=; rewrite !ratz_frac //= !mulr1. Qed. Fact invq_frac x : x.1 != 0 -> x.2 != 0 -> invq (fracq x) = fracq (invq_subdef x). Proof. by rewrite invq_def; case: (fracqP x) => // k ? k0; rewrite fracqMM. Qed. Fact mulqC : commutative mulq. Proof. by move=> x y; rewrite !mulq_def mulq_subdefC. Qed. Fact mulqA : associative mulq. Proof. by move=> x y z; rewrite -[x]valqK -[y]valqK -[z]valqK !mulq_frac mul_subdefA. Qed. Fact mul1q : left_id oneq mulq. Proof. move=> x; rewrite -[x]valqK -[oneq]valqK; rewrite mulq_frac !mulq_subdefE. by rewrite !mul1r -surjective_pairing. Qed. Fact mulq_addl : left_distributive mulq addq. Proof. move=> x y z; rewrite -[x]valqK -[y]valqK -[z]valqK /=. rewrite !(mulq_frac, addq_frac, mulq_subdefE, addq_subdefE) ?mulf_neq0 ?denq_neq0 //=. apply/eqP; rewrite fracq_eq ?mulf_neq0 ?denq_neq0 //= !mulrDl; apply/eqP. by rewrite !mulrA ![_ * (valq z).1]mulrC !mulrA ![_ * (valq x).2]mulrC !mulrA. Qed. Fact nonzero1q : oneq != zeroq. Proof. by []. Qed. HB.instance Definition _ := GRing.Zmodule_isComNzRing.Build rat mulqA mulqC mul1q mulq_addl nonzero1q. Fact mulVq x : x != 0 -> mulq (invq x) x = 1. Proof. rewrite -[x]valqK -[0]valqK fracq_eq ?denq_neq0 //= mulr1 mul0r=> nx0. rewrite !(mulq_frac, invq_frac, mulq_subdefE) ?denq_neq0 // -[1]valqK. by apply/eqP; rewrite fracq_eq ?mulf_neq0 ?denq_neq0 //= mulr1 mul1r mulrC. Qed. Fact invq0 : invq 0 = 0. Proof. exact/eqP. Qed. HB.instance Definition _ := GRing.ComNzRing_isField.Build rat mulVq invq0. Lemma numq_eq0 x : (numq x == 0) = (x == 0). Proof. rewrite -[x]valqK fracq_eq0; case: fracqP=> /= [|k {}x k0]. by rewrite eqxx orbT. by rewrite !mulf_eq0 (negPf k0) /= denq_eq0 orbF. Qed. Notation "n %:Q" := ((n : int)%:~R : rat) : ring_scope. #[global] Hint Resolve denq_neq0 denq_gt0 denq_ge0 : core. Definition subq (x y : rat) : rat := (addq x (oppq y)). Definition divq (x y : rat) : rat := (mulq x (invq y)). Infix "+" := addq : rat_scope. Notation "- x" := (oppq x) : rat_scope. Infix "*" := mulq : rat_scope. Notation "x ^-1" := (invq x) : rat_scope. Infix "-" := subq : rat_scope. Infix "/" := divq : rat_scope. (* ratz should not be used, %:Q should be used instead *) Lemma ratzE n : ratz n = n%:Q. Proof. elim: n=> [|n ihn|n ihn]; first by rewrite mulr0z ratz_frac. by rewrite intS mulrzDr ratzD ihn. by rewrite intS opprD mulrzDr ratzD ihn. Qed. Lemma numq_int n : numq n%:Q = n. Proof. by rewrite -ratzE. Qed. Lemma denq_int n : denq n%:Q = 1. Proof. by rewrite -ratzE. Qed. Lemma rat0 : 0%:Q = 0. Proof. by []. Qed. Lemma rat1 : 1%:Q = 1. Proof. by []. Qed. Lemma numqN x : numq (- x) = - numq x. Proof. rewrite [- _]oppq_def/= num_fracq. case: x => -[a b]; rewrite /numq/= => /andP[b_gt0]. rewrite /coprime => /eqP cab. by rewrite lt_gtF ?gt_eqF // {2}abszN cab divn1 mulz_sign_abs. Qed. Lemma denqN x : denq (- x) = denq x. Proof. rewrite [- _]oppq_def den_fracq. case: x => -[a b]; rewrite /denq/= => /andP[b_gt0]. by rewrite /coprime=> /eqP cab; rewrite gt_eqF // abszN cab divn1 gtz0_abs. Qed. (* Will be subsumed by pnatr_eq0 *) Fact intq_eq0 n : (n%:~R == 0 :> rat) = (n == 0)%N. Proof. by rewrite -ratzE /ratz rat_eqE/= /numq /denq/= eqxx andbT. Qed. (* fracq should never appear, its canonical form is _%:Q / _%:Q *) Lemma fracqE x : fracq x = x.1%:Q / x.2%:Q. Proof. move: x => [m n] /=; apply/val_inj; rewrite val_fracq/=. case: eqVneq => //= [->|n_neq0]; first by rewrite rat0 invr0 mulr0. rewrite -[m%:Q]valqK -[n%:Q]valqK. rewrite [_^-1]invq_frac ?denq_neq0 ?numq_eq0 ?intq_eq0//=. rewrite [X in valq X]mulq_frac val_fracq /invq_subdef !mulq_subdefE/=. by rewrite -!/(numq _) -!/(denq _) !numq_int !denq_int mul1r mulr1 n_neq0. Qed. Lemma divq_num_den x : (numq x)%:Q / (denq x)%:Q = x. Proof. by rewrite -{3}[x]valqK [valq _]surjective_pairing /= fracqE. Qed. Variant divq_spec (n d : int) : int -> int -> rat -> Type := | DivqSpecN of d = 0 : divq_spec n d n 0 0 | DivqSpecP k x of k != 0 : divq_spec n d (k * numq x) (k * denq x) x. (* replaces fracqP *) Lemma divqP n d : divq_spec n d n d (n%:Q / d%:Q). Proof. set x := (n, d); rewrite -[n]/x.1 -[d]/x.2 -fracqE. by case: fracqP => [_|k fx k_neq0] /=; constructor. Qed. Variant rat_spec (* (x : rat) *) : rat -> int -> int -> Type := Rat_spec (n : int) (d : nat) & coprime `|n| d.+1 : rat_spec (* x *) (n%:Q / d.+1%:Q) n d.+1. Lemma ratP x : rat_spec x (numq x) (denq x). Proof. rewrite -{1}[x](divq_num_den); case hd: denq => [p|n]. have: 0 < p%:Z by rewrite -hd denq_gt0. case: p hd=> //= n hd; constructor; rewrite -?hd ?divq_num_den //. by rewrite -[n.+1]/`|n.+1|%N -hd coprime_num_den. by move: (denq_gt0 x); rewrite hd. Qed. Lemma coprimeq_num n d : coprime `|n| `|d| -> numq (n%:~R / d%:~R) = sgr d * n. Proof. move=> cnd /=; have <- := fracqE (n, d). rewrite num_fracq/= (eqP (cnd : _ == 1)) divn1. have [|d_gt0|d_lt0] := sgrP d; by rewrite (mul0r, mul1r, mulN1r) //= ?[_ ^ _]signrN ?mulNr mulz_sign_abs. Qed. Lemma coprimeq_den n d : coprime `|n| `|d| -> denq (n%:~R / d%:~R) = (if d == 0 then 1 else `|d|). Proof. move=> cnd; have <- := fracqE (n, d). by rewrite den_fracq/= (eqP (cnd : _ == 1)) divn1; case: d {cnd}; case. Qed. Lemma denqVz (i : int) : i != 0 -> denq (i%:~R^-1) = `|i|. Proof. move=> h; rewrite -div1r -[1]/(1%:~R). by rewrite coprimeq_den /= ?coprime1n // (negPf h). Qed. Lemma numqE x : (numq x)%:~R = x * (denq x)%:~R. Proof. by rewrite -{2}[x]divq_num_den divfK // intq_eq0 denq_eq0. Qed. Lemma denqP x : {d | denq x = d.+1}. Proof. by rewrite /denq; case: x => [[_ [[|d]|]] //= _]; exists d. Qed. Definition normq '(Rat x _) : rat := `|x.1|%:~R / (x.2)%:~R. Definition le_rat '(Rat x _) '(Rat y _) := x.1 * y.2 <= y.1 * x.2. Definition lt_rat '(Rat x _) '(Rat y _) := x.1 * y.2 < y.1 * x.2. Lemma normqE x : normq x = `|numq x|%:~R / (denq x)%:~R. Proof. by case: x. Qed. Lemma le_ratE x y : le_rat x y = (numq x * denq y <= numq y * denq x). Proof. by case: x; case: y. Qed. Lemma lt_ratE x y : lt_rat x y = (numq x * denq y < numq y * denq x). Proof. by case: x; case: y. Qed. Lemma gt_rat0 x : lt_rat 0 x = (0 < numq x). Proof. by rewrite lt_ratE mul0r mulr1. Qed. Lemma lt_rat0 x : lt_rat x 0 = (numq x < 0). Proof. by rewrite lt_ratE mul0r mulr1. Qed. Lemma ge_rat0 x : le_rat 0 x = (0 <= numq x). Proof. by rewrite le_ratE mul0r mulr1. Qed. Lemma le_rat0 x : le_rat x 0 = (numq x <= 0). Proof. by rewrite le_ratE mul0r mulr1. Qed. Fact le_rat0D x y : le_rat 0 x -> le_rat 0 y -> le_rat 0 (x + y). Proof. rewrite !ge_rat0 => hnx hny. have hxy: (0 <= numq x * denq y + numq y * denq x). by rewrite addr_ge0 ?mulr_ge0. rewrite [_ + _]addq_def /numq /= -!/(denq _) ?mulf_eq0 ?denq_eq0. rewrite val_fracq/=; case: ifP => //=. by rewrite ?addq_subdefE !mulr_ge0// !le_gtF ?mulr_ge0 ?denq_ge0//=. Qed. Fact le_rat0M x y : le_rat 0 x -> le_rat 0 y -> le_rat 0 (x * y). Proof. rewrite !ge_rat0 => hnx hny. have hxy: (0 <= numq x * denq y + numq y * denq x). by rewrite addr_ge0 ?mulr_ge0. rewrite [_ * _]mulq_def /numq /= -!/(denq _) ?mulf_eq0 ?denq_eq0. rewrite val_fracq/=; case: ifP => //=. by rewrite ?mulq_subdefE !mulr_ge0// !le_gtF ?mulr_ge0 ?denq_ge0//=. Qed. Fact le_rat0_anti x : le_rat 0 x -> le_rat x 0 -> x = 0. Proof. by move=> hx hy; apply/eqP; rewrite -numq_eq0 eq_le -ge_rat0 -le_rat0 hx hy. Qed. Lemma sgr_numq_div (n d : int) : sgr (numq (n%:Q / d%:Q)) = sgr n * sgr d. Proof. set x := (n, d); rewrite -[n]/x.1 -[d]/x.2 -fracqE. case: fracqP => [|k fx k_neq0] /=; first by rewrite mulr0. by rewrite !sgrM mulrACA -expr2 sqr_sg k_neq0 sgr_denq mulr1 mul1r. Qed. Fact subq_ge0 x y : le_rat 0 (y - x) = le_rat x y. Proof. symmetry; rewrite ge_rat0 !le_ratE -subr_ge0. case: ratP => nx dx cndx; case: ratP => ny dy cndy. rewrite -!mulNr addf_div ?intq_eq0 // !mulNr -!rmorphM -rmorphB /=. symmetry; rewrite !leNgt -sgr_cp0 sgr_numq_div mulrC gtr0_sg //. by rewrite mul1r sgr_cp0. Qed. Fact le_rat_total : total le_rat. Proof. by move=> x y; rewrite !le_ratE; apply: le_total. Qed. Fact numq_sign_mul (b : bool) x : numq ((-1) ^+ b * x) = (-1) ^+ b * numq x. Proof. by case: b; rewrite ?(mul1r, mulN1r) // numqN. Qed. Fact numq_div_lt0 n d : n != 0 -> d != 0 -> (numq (n%:~R / d%:~R) < 0)%R = (n < 0)%R (+) (d < 0)%R. Proof. move=> n0 d0; rewrite -sgr_cp0 sgr_numq_div !sgr_def n0 d0. by rewrite !mulr1n -signr_addb; case: (_ (+) _). Qed. Lemma normr_num_div n d : `|numq (n%:~R / d%:~R)| = numq (`|n|%:~R / `|d|%:~R). Proof. rewrite (normrEsg n) (normrEsg d) !rmorphM /= invfM mulrACA !sgr_def. have [->|n_neq0] := eqVneq; first by rewrite mul0r mulr0. have [->|d_neq0] := eqVneq; first by rewrite invr0 !mulr0. rewrite !intr_sign invr_sign -signr_addb numq_sign_mul -numq_div_lt0 //. by apply: (canRL (signrMK _)); rewrite mulz_sign_abs. Qed. Fact norm_ratN x : normq (- x) = normq x. Proof. by rewrite !normqE numqN denqN normrN. Qed. Fact ge_rat0_norm x : le_rat 0 x -> normq x = x. Proof. rewrite ge_rat0; case: ratP=> [] // n d cnd n_ge0. by rewrite normqE /= normr_num_div ?ger0_norm // divq_num_den. Qed. Fact lt_rat_def x y : (lt_rat x y) = (y != x) && (le_rat x y). Proof. by rewrite lt_ratE le_ratE lt_def rat_eq. Qed. HB.instance Definition _ := Num.IntegralDomain_isLeReal.Build rat le_rat0D le_rat0M le_rat0_anti subq_ge0 (@le_rat_total 0) norm_ratN ge_rat0_norm lt_rat_def. Lemma numq_ge0 x : (0 <= numq x) = (0 <= x). Proof. by case: ratP => n d cnd; rewrite ?pmulr_lge0 ?invr_gt0 (ler0z, ltr0z). Qed. Lemma numq_le0 x : (numq x <= 0) = (x <= 0). Proof. by rewrite -oppr_ge0 -numqN numq_ge0 oppr_ge0. Qed. Lemma numq_gt0 x : (0 < numq x) = (0 < x). Proof. by rewrite !ltNge numq_le0. Qed. Lemma numq_lt0 x : (numq x < 0) = (x < 0). Proof. by rewrite !ltNge numq_ge0. Qed. Lemma sgr_numq x : sgz (numq x) = sgz x. Proof. apply/eqP; case: (sgzP x); rewrite sgz_cp0 ?(numq_gt0, numq_lt0) //. by move->. Qed. Lemma denq_mulr_sign (b : bool) x : denq ((-1) ^+ b * x) = denq x. Proof. by case: b; rewrite ?(mul1r, mulN1r) // denqN. Qed. Lemma denq_norm x : denq `|x| = denq x. Proof. by rewrite normrEsign denq_mulr_sign. Qed. Module ratArchimedean. Section ratArchimedean. Implicit Types x : rat. Definition floor x : int := (numq x %/ denq x)%Z. Definition ceil x : int := - (- numq x %/ denq x)%Z. Definition truncn x : nat := if 0 <= x then (`|numq x| %/ `|denq x|)%N else 0%N. Let is_int x := denq x == 1. Let is_nat x := (0 <= x) && (denq x == 1). Fact floorP x : if x \is Num.real then (floor x)%:~R <= x < (floor x + 1)%:~R else floor x == 0. Proof. rewrite num_real /floor; case: (ratP x) => n d _ {x}; rewrite ler_pdivlMr//. by rewrite ltr_pdivrMr// -!intrM ler_int ltr_int lez_floor ?ltz_ceil. Qed. Fact ceilP x : ceil x = - floor (- x). Proof. by rewrite /ceil /floor numqN denqN. Qed. Fact truncnP x : truncn x = if floor x is Posz n then n else 0. Proof. rewrite /truncn /floor; case: (ratP x) => n d _ {x} /=. by rewrite !ler_pdivlMr// mul0r; case: n => n; rewrite ler0z//= mul1n. Qed. Fact intrP x : reflect (exists n, x = n%:~R) (is_int x). Proof. apply: (iffP idP) => [/eqP d1 | [i ->]]; [|by rewrite /is_int denq_int]. by exists (numq x); case: (ratP x) d1 => n d _ ->; rewrite divr1. Qed. Fact natrP x : reflect (exists n, x = n%:R) (is_nat x). Proof. apply: (iffP idP) => [/andP[]/[swap]/intrP[i ->]|[n ->]]. by rewrite ler0z; case: i => [n _|//]; exists n. by rewrite /is_nat pmulrn ler0z denq_int. Qed. End ratArchimedean. End ratArchimedean. HB.instance Definition _ := Num.NumDomain_hasFloorCeilTruncn.Build rat ratArchimedean.floorP ratArchimedean.ceilP ratArchimedean.truncnP ratArchimedean.intrP ratArchimedean.natrP. Lemma floorErat (x : rat) : Num.floor x = (numq x %/ denq x)%Z. Proof. by []. Qed. Lemma ceilErat (x : rat) : Num.ceil x = - (- numq x %/ denq x)%Z. Proof. by []. Qed. Lemma Qint_def (x : rat) : (x \is a Num.int) = (denq x == 1). Proof. by []. Qed. Lemma numqK : {in Num.int, cancel (fun x => numq x) intr}. Proof. by move=> _ /intrP [x ->]; rewrite numq_int. Qed. Lemma natq_div m n : (n %| m)%N -> (m %/ n)%:R = m%:R / n%:R :> rat. Proof. exact/pchar0_natf_div/pchar_num. Qed. Section InRing. Variable R : unitRingType. Definition ratr x : R := (numq x)%:~R / (denq x)%:~R. Lemma ratr_int z : ratr z%:~R = z%:~R. Proof. by rewrite /ratr numq_int denq_int divr1. Qed. Lemma ratr_nat n : ratr n%:R = n%:R. Proof. exact: ratr_int n. Qed. Lemma rpred_rat (S : divringClosed R) a : ratr a \in S. Proof. by rewrite rpred_div ?rpred_int. Qed. End InRing. Section Fmorph. Implicit Type rR : unitRingType. Lemma fmorph_rat (aR : fieldType) rR (f : {rmorphism aR -> rR}) a : f (ratr _ a) = ratr _ a. Proof. by rewrite fmorph_div !rmorph_int. Qed. Lemma fmorph_eq_rat rR (f : {rmorphism rat -> rR}) : f =1 ratr _. Proof. by move=> a; rewrite -{1}[a]divq_num_den fmorph_div !rmorph_int. Qed. End Fmorph. Section Linear. Implicit Types (U V : lmodType rat) (A B : lalgType rat). Lemma rat_linear U V (f : U -> V) : zmod_morphism f -> scalable f. Proof. move=> fB a u. pose aM := GRing.isZmodMorphism.Build U V f fB. pose phi : {additive U -> V} := HB.pack f aM. rewrite -[f]/(phi : _ -> _) -{2}[a]divq_num_den mulrC -scalerA. apply: canRL (scalerK _) _; first by rewrite intr_eq0 denq_neq0. rewrite 2!scaler_int -3!raddfMz /=. by rewrite -scalerMzr scalerMzl -mulrzr -numqE scaler_int. Qed. End Linear. Section InPrealField. Variable F : numFieldType. Fact ratr_is_zmod_morphism : zmod_morphism (@ratr F). Proof. have injZtoQ: @injective rat int intr by apply: intr_inj. have nz_den x: (denq x)%:~R != 0 :> F by rewrite intr_eq0 denq_eq0. move=> x y. apply: (canLR (mulfK (nz_den _))); apply: (mulIf (nz_den x)). rewrite mulrAC mulrBl divfK ?nz_den // mulrAC -!rmorphM. apply: (mulIf (nz_den y)); rewrite mulrAC mulrBl divfK ?nz_den //. rewrite -!(rmorphM, rmorphB); congr _%:~R; apply: injZtoQ. rewrite !(rmorphM, rmorphB) /= [_ - _]lock /= -lock !numqE. by rewrite (mulrAC y) -!mulrBl -mulrA mulrAC !mulrA. Qed. #[warning="-deprecated-since-mathcomp-2.5.0", deprecated(since="mathcomp 2.5.0", note="use `ratr_is_additive` instead")] Definition ratr_is_additive := ratr_is_zmod_morphism. Fact ratr_is_monoid_morphism : monoid_morphism (@ratr F). Proof. have injZtoQ: @injective rat int intr by apply: intr_inj. have nz_den x: (denq x)%:~R != 0 :> F by rewrite intr_eq0 denq_eq0. split=> [|x y]; first by rewrite /ratr divr1. rewrite /ratr mulrC mulrAC; apply: canLR (mulKf (nz_den _)) _; rewrite !mulrA. do 2!apply: canRL (mulfK (nz_den _)) _; rewrite -!rmorphM; congr _%:~R. apply: injZtoQ; rewrite !rmorphM [x * y]lock /= !numqE -lock. by rewrite -!mulrA mulrA mulrCA -!mulrA (mulrCA y). Qed. #[warning="-deprecated-since-mathcomp-2.5.0", deprecated(since="mathcomp 2.5.0", note="use `ratr_is_monoid_morphism` instead")] Definition ratr_is_multiplicative := (fun g => (g.2,g.1)) ratr_is_monoid_morphism. HB.instance Definition _ := GRing.isZmodMorphism.Build rat F (@ratr F) ratr_is_zmod_morphism. HB.instance Definition _ := GRing.isMonoidMorphism.Build rat F (@ratr F) ratr_is_monoid_morphism. Lemma ler_rat : {mono (@ratr F) : x y / x <= y}. Proof. move=> x y /=; case: (ratP x) => nx dx cndx; case: (ratP y) => ny dy cndy. rewrite !fmorph_div /= !ratr_int !ler_pdivlMr ?ltr0z //. by rewrite ![_ / _ * _]mulrAC !ler_pdivrMr ?ltr0z // -!rmorphM /= !ler_int. Qed. Lemma ltr_rat : {mono (@ratr F) : x y / x < y}. Proof. exact: leW_mono ler_rat. Qed. Lemma ler0q x : (0 <= ratr F x) = (0 <= x). Proof. by rewrite (_ : 0 = ratr F 0) ?ler_rat ?rmorph0. Qed. Lemma lerq0 x : (ratr F x <= 0) = (x <= 0). Proof. by rewrite (_ : 0 = ratr F 0) ?ler_rat ?rmorph0. Qed. Lemma ltr0q x : (0 < ratr F x) = (0 < x). Proof. by rewrite (_ : 0 = ratr F 0) ?ltr_rat ?rmorph0. Qed. Lemma ltrq0 x : (ratr F x < 0) = (x < 0). Proof. by rewrite (_ : 0 = ratr F 0) ?ltr_rat ?rmorph0. Qed. Lemma ratr_sg x : ratr F (sgr x) = sgr (ratr F x). Proof. by rewrite !sgr_def fmorph_eq0 ltrq0 rmorphMn /= rmorph_sign. Qed. Lemma ratr_norm x : ratr F `|x| = `|ratr F x|. Proof. by rewrite {2}[x]numEsign rmorphMsign normrMsign [`|ratr F _|]ger0_norm ?ler0q. Qed. Lemma minr_rat : {morph ratr F : x y / Num.min x y}. Proof. by move=> x y; rewrite !minEle ler_rat; case: leP. Qed. Lemma maxr_rat : {morph ratr F : x y / Num.max x y}. Proof. by move=> x y; rewrite !maxEle ler_rat; case: leP. Qed. End InPrealField. Section InParchiField. Variable F : archiNumFieldType. Lemma floor_rat : {mono (@ratr F) : x / Num.floor x}. Proof. move=> x; apply: floor_def; apply/andP; split. - by rewrite -ratr_int ler_rat floor_le_tmp. - by rewrite -ratr_int ltr_rat floorD1_gt. Qed. Lemma ceil_rat : {mono (@ratr F) : x / Num.ceil x}. Proof. by move=> x; rewrite !ceilNfloor -rmorphN floor_rat. Qed. End InParchiField. Arguments ratr {R}. Lemma Qint_dvdz (m d : int) : (d %| m)%Z -> (m%:~R / d%:~R : rat) \is a Num.int. Proof. case/dvdzP=> z ->; rewrite rmorphM /=; have [->|dn0] := eqVneq d 0. by rewrite mulr0 mul0r. by rewrite mulfK ?intr_eq0. Qed. Lemma Qnat_dvd (m d : nat) : (d %| m)%N -> (m%:R / d%:R : rat) \is a Num.nat. Proof. by move=> h; rewrite natrEint divr_ge0 ?ler0n // !pmulrn Qint_dvdz. Qed. Section ZpolyScale. Local Notation pZtoQ := (map_poly (intr : int -> rat)). Lemma size_rat_int_poly p : size (pZtoQ p) = size p. Proof. by apply: size_map_inj_poly; first apply: intr_inj. Qed. Lemma rat_poly_scale (p : {poly rat}) : {q : {poly int} & {a | a != 0 & p = a%:~R^-1 *: pZtoQ q}}. Proof. pose a := \prod_(i < size p) denq p`_i. have nz_a: a != 0 by apply/prodf_neq0=> i _; apply: denq_neq0. exists (map_poly numq (a%:~R *: p)), a => //. apply: canRL (scalerK _) _; rewrite ?intr_eq0 //. apply/polyP=> i; rewrite !(coefZ, coef_map_id0) // numqK // Qint_def mulrC. have [ltip | /(nth_default 0)->] := ltnP i (size p); last by rewrite mul0r. by rewrite [a](bigD1 (Ordinal ltip)) // rmorphM mulrA -numqE -rmorphM denq_int. Qed. Lemma dvdp_rat_int p q : (pZtoQ p %| pZtoQ q) = (p %| q). Proof. apply/dvdpP/Pdiv.Idomain.dvdpP=> [[/= r1 Dq] | [[/= a r] nz_a Dq]]; last first. exists (a%:~R^-1 *: pZtoQ r). by rewrite -scalerAl -rmorphM -Dq /= linearZ/= scalerK ?intr_eq0. have [r [a nz_a Dr1]] := rat_poly_scale r1; exists (a, r) => //=. apply: (map_inj_poly _ _ : injective pZtoQ) => //; first exact: intr_inj. by rewrite linearZ /= Dq Dr1 -scalerAl -rmorphM scalerKV ?intr_eq0. Qed. Lemma dvdpP_rat_int p q : p %| pZtoQ q -> {p1 : {poly int} & {a | a != 0 & p = a *: pZtoQ p1} & {r | q = p1 * r}}. Proof. have{p} [p [a nz_a ->]] := rat_poly_scale p. rewrite dvdpZl ?invr_eq0 ?intr_eq0 // dvdp_rat_int => dv_p_q. exists (zprimitive p); last exact: dvdpP_int. have [-> | nz_p] := eqVneq p 0. by exists 1; rewrite ?oner_eq0 // zprimitive0 map_poly0 !scaler0. exists ((zcontents p)%:~R / a%:~R). by rewrite mulf_neq0 ?invr_eq0 ?intr_eq0 ?zcontents_eq0. by rewrite mulrC -scalerA -map_polyZ -zpolyEprim. Qed. Lemma irreducible_rat_int p : irreducible_poly (pZtoQ p) <-> irreducible_poly p. Proof. rewrite /irreducible_poly size_rat_int_poly; split=> -[] p1 p_irr; split=> //. move=> q q1; rewrite /eqp -!dvdp_rat_int => rq. by apply/p_irr => //; rewrite size_rat_int_poly. move=> q + /dvdpP_rat_int [] r [] c c0 qE [] s sE. rewrite qE size_scale// size_rat_int_poly => r1. apply/(eqp_trans (eqp_scale _ c0)). rewrite /eqp !dvdp_rat_int; apply/p_irr => //. by rewrite sE dvdp_mulIl. Qed. End ZpolyScale. (* Integral spans. *) Definition inIntSpan (V : zmodType) m (s : m.-tuple V) v := exists a : int ^ m, v = \sum_(i < m) s`_i *~ a i. Lemma solve_Qint_span (vT : vectType rat) m (s : m.-tuple vT) v : {b : int ^ m & {p : seq (int ^ m) & forall a : int ^ m, v = \sum_(i < m) s`_i *~ a i <-> exists c : seq int, a = b + \sum_(i < size p) p`_i *~ c`_i}} + (~ inIntSpan s v). Proof. have s_s (i : 'I_m): s`_i \in <<s>>%VS by rewrite memv_span ?memt_nth. have s_Zs a: \sum_(i < m) s`_i *~ a i \in <<s>>%VS. by apply/rpred_sum => i _; apply/rpredMz. case s_v: (v \in <<s>>%VS); last by right=> [[a Dv]]; rewrite Dv s_Zs in s_v. move SE : (\matrix_(i < m, j < _) coord (vbasis <<s>>) j s`_i) => S. move rE : (\rank S) => r; move kE : (m - r)%N => k. have Dm: (m = k + r)%N by rewrite -kE -rE subnK ?rank_leq_row. rewrite Dm in s s_s s_Zs s_v S SE rE kE *. move=> {Dm m}; pose m := (k + r)%N. have [K kerK]: {K : 'M_(k, m) | map_mx intr K == kermx S}%MS. move: (mxrank_ker S); rewrite rE kE => krk. pose B := row_base (kermx S); pose d := \prod_ij denq (B ij.1 ij.2). exists (castmx (krk, erefl m) (map_mx numq (intr d *: B))). rewrite map_castmx !eqmx_cast -map_mx_comp map_mx_id_in => [|i j]; last first. rewrite mxE mulrC [d](bigD1 (i, j)) //= rmorphM mulrA. by rewrite -numqE -rmorphM numq_int. suff nz_d: d%:Q != 0 by rewrite !eqmx_scale // !eq_row_base andbb. by rewrite intr_eq0; apply/prodf_neq0 => i _; apply: denq_neq0. have [L _ [G uG [D _ defK]]] := int_Smith_normal_form K. have {K L D defK kerK} [kerGu kerS_sub_Gu]: map_mx intr (usubmx G) *m S = 0 /\ (kermx S <= map_mx intr (usubmx G))%MS. pose Kl : 'M[rat]_k := map_mx intr (lsubmx (K *m invmx G)). have {}defK: map_mx intr K = Kl *m map_mx intr (usubmx G). rewrite /Kl -map_mxM; congr map_mx. rewrite -[LHS](mulmxKV uG) -{2}[G]vsubmxK -{1}[K *m _]hsubmxK. rewrite mul_row_col -[RHS]addr0; congr (_ + _). rewrite defK mulmxK //= -[RHS](mul0mx _ (dsubmx G)); congr (_ *m _). apply/matrixP => i j; rewrite !mxE big1 //= => j1 _. rewrite mxE /= eqn_leq andbC. by rewrite leqNgt (leq_trans (valP j1)) ?mulr0 ?leq_addr. split; last by rewrite -(eqmxP kerK); apply/submxP; exists Kl. suff /row_full_inj: row_full Kl. by apply; rewrite mulmx0 mulmxA (sub_kermxP _) // -(eqmxP kerK) defK. rewrite /row_full eqn_leq rank_leq_row /= -{1}kE -{2}rE -(mxrank_ker S). by rewrite -(eqmxP kerK) defK mxrankM_maxl. pose T := map_mx intr (dsubmx G) *m S. have defS: map_mx intr (rsubmx (invmx G)) *m T = S. rewrite mulmxA -map_mxM /=; move: (mulVmx uG). rewrite -{2}[G]vsubmxK -{1}[invmx G]hsubmxK mul_row_col. move/(canRL (addKr _)) ->; rewrite -mulNmx raddfD /= map_mx1 map_mxM /=. by rewrite mulmxDl -mulmxA kerGu mulmx0 add0r mul1mx. pose vv := \row_j coord (vbasis <<s>>) j v. have uS: row_full S. apply/row_fullP; exists (\matrix_(i, j) coord s j (vbasis <<s>>)`_i). apply/matrixP => j1 j2; rewrite !mxE. rewrite -(coord_free _ _ (basis_free (vbasisP _))). rewrite -!tnth_nth (coord_span (vbasis_mem (mem_tnth j1 _))) linear_sum. by apply: eq_bigr => /= i _; rewrite -SE !mxE (tnth_nth 0) !linearZ. have eqST: (S :=: T)%MS by apply/eqmxP; rewrite -{1}defS !submxMl. case Zv: (map_mx denq (vv *m pinvmx T) == const_mx 1); last first. right=> [[a Dv]]; case/eqP: Zv; apply/rowP. have ->: vv = map_mx intr (\row_i a i) *m S. apply/rowP => j; rewrite !mxE Dv linear_sum. by apply: eq_bigr => i _; rewrite -SE -scaler_int linearZ !mxE. rewrite -defS -2!mulmxA; have ->: T *m pinvmx T = 1%:M. have uT: row_free T by rewrite /row_free -eqST rE. by apply: (row_free_inj uT); rewrite mul1mx mulmxKpV. by move=> i; rewrite mulmx1 -map_mxM 2!mxE denq_int mxE. pose b := map_mx numq (vv *m pinvmx T) *m dsubmx G. left; exists [ffun j => b 0 j], [seq [ffun j => (usubmx G) i j] | i : 'I_k]. rewrite size_image card_ord => a; rewrite -[a](addNKr [ffun j => b 0 j]). move: (_ + a) => h; under eq_bigr => i _ do rewrite !ffunE mulrzDr. rewrite big_split /=. have <-: v = \sum_(i < m) s`_i *~ b 0 i. transitivity (\sum_j (map_mx intr b *m S) 0 j *: (vbasis <<s>>)`_j). rewrite {1}(coord_vbasis s_v); apply: eq_bigr => j _; congr (_ *: _). suff ->: map_mx intr b = vv *m pinvmx T *m map_mx intr (dsubmx G). by rewrite -(mulmxA _ _ S) mulmxKpV ?mxE // -eqST submx_full. rewrite map_mxM /=; congr (_ *m _); apply/rowP => i; rewrite 2!mxE numqE. by have /eqP/rowP/(_ i)/[!mxE] -> := Zv; rewrite mulr1. rewrite (coord_vbasis (s_Zs _)); apply: eq_bigr => j _; congr (_ *: _). rewrite linear_sum mxE; apply: eq_bigr => i _. by rewrite -SE -scaler_int linearZ [b]lock !mxE. split. rewrite -[LHS]addr0 => /addrI hP; pose c := \row_i h i *m lsubmx (invmx G). exists [seq c 0 i | i : 'I_k]; congr (_ + _). have/sub_kermxP: map_mx intr (\row_i h i) *m S = 0. transitivity (\row_j coord (vbasis <<s>>) j (\sum_(i < m) s`_i *~ h i)). apply/rowP => j; rewrite !mxE linear_sum; apply: eq_bigr => i _. by rewrite -SE !mxE -scaler_int linearZ. by apply/rowP => j; rewrite !mxE -hP linear0. case/submx_trans/(_ kerS_sub_Gu)/submxP => c' /[dup]. move/(congr1 (mulmx^~ (map_mx intr (lsubmx (invmx G))))). rewrite -mulmxA -!map_mxM [in RHS]mulmx_lsub mul_usub_mx -/c mulmxV //=. rewrite scalar_mx_block -/(ulsubmx _) block_mxKul map_scalar_mx mulmx1. move=> <- {c'}; rewrite -map_mxM /= => defh; apply/ffunP => j. move/rowP/(_ j): defh; rewrite sum_ffunE !mxE => /intr_inj ->. apply: eq_bigr => i _; rewrite ffunMzE mulrzz mulrC. rewrite (nth_map i) ?size_enum_ord // nth_ord_enum ffunE. by rewrite (nth_map i) ?size_enum_ord // nth_ord_enum. case=> c /addrI -> {h}; rewrite -[LHS]addr0; congr (_ + _). pose h := \row_(j < k) c`_j *m usubmx G. transitivity (\sum_j (map_mx intr h *m S) 0 j *: (vbasis <<s>>)`_j). by rewrite map_mxM -mulmxA kerGu mulmx0 big1 // => j _; rewrite mxE scale0r. rewrite (coord_vbasis (s_Zs _)); apply: eq_bigr => i _; congr (_ *: _). rewrite linear_sum -SE mxE; apply: eq_bigr => j _. rewrite -scaler_int linearZ !mxE sum_ffunE; congr (_%:~R * _). apply: {i} eq_bigr => i _; rewrite mxE ffunMzE mulrzz mulrC. by rewrite (nth_map i) ?size_enum_ord // ffunE nth_ord_enum. Qed. Lemma dec_Qint_span (vT : vectType rat) m (s : m.-tuple vT) v : decidable (inIntSpan s v). Proof. have [[b [p aP]]|] := solve_Qint_span s v; last by right. left; exists b; apply/(aP b); exists [::]; rewrite big1 ?addr0 // => i _. by rewrite nth_nil mulr0z. Qed. Lemma eisenstein_crit (p : nat) (q : {poly int}) : prime p -> (size q != 1)%N -> ~~ (p %| lead_coef q)%Z -> ~~ (p ^+ 2 %| q`_0)%Z -> (forall i, (i < (size q).-1)%N -> p %| q`_i)%Z -> irreducible_poly q. Proof. move=> p_prime qN1 Ndvd_pql Ndvd_pq0 dvd_pq. apply/irreducible_rat_int. have qN0 : q != 0 by rewrite -lead_coef_eq0; apply: contraNneq Ndvd_pql => ->. split. rewrite size_map_poly_id0 ?intr_eq0 ?lead_coef_eq0//. by rewrite ltn_neqAle eq_sym qN1 size_poly_gt0. move=> f' +/dvdpP_rat_int[f [d dN0 feq]]; rewrite {f'}feq size_scale// => fN1. move=> /= [g q_eq]; rewrite q_eq (eqp_trans (eqp_scale _ _))//. have fN0 : f != 0 by apply: contra_neq qN0; rewrite q_eq => ->; rewrite mul0r. have gN0 : g != 0 by apply: contra_neq qN0; rewrite q_eq => ->; rewrite mulr0. rewrite size_map_poly_id0 ?intr_eq0 ?lead_coef_eq0// in fN1. have [/eqP/size_poly1P[c cN0 ->]|gN1] := eqVneq (size g) 1%N. by rewrite mulrC mul_polyC map_polyZ/= eqp_sym eqp_scale// intr_eq0. have c_neq0 : (lead_coef q)%:~R != 0 :> 'F_p by rewrite -(dvdz_pcharf (pchar_Fp _)). have : map_poly (intr : int -> 'F_p) q = (lead_coef q)%:~R *: 'X^((size q).-1). apply/val_inj/(@eq_from_nth _ 0) => [|i]; rewrite size_map_poly_id0//. by rewrite size_scale// size_polyXn -polySpred. move=> i_small; rewrite coef_poly i_small coefZ coefXn lead_coefE. move: i_small; rewrite polySpred// ltnS/=. case: ltngtP => // [i_lt|->]; rewrite (mulr1, mulr0)//= => _. by apply/eqP; rewrite -(dvdz_pcharf (pchar_Fp _))// dvd_pq. rewrite [in LHS]q_eq rmorphM/=. set c := (X in X *: _); set n := (_.-1). set pf := map_poly _ f; set pg := map_poly _ g => pfMpg. have dvdXn (r : {poly _}) : size r != 1%N -> r %| c *: 'X^n -> r`_0 = 0. move=> rN1; rewrite (eqp_dvdr _ (eqp_scale _ _))//. rewrite -['X]subr0; move=> /dvdp_exp_XsubCP[k lekn]; rewrite subr0. move=> /eqpP[u /andP[u1N0 u2N0]]; have [->|k_gt0] := posnP k. move=> /(congr1 (size \o val))/eqP. by rewrite /= !size_scale// size_polyXn (negPf rN1). move=> /(congr1 (fun p : {poly _} => p`_0))/eqP. by rewrite !coefZ coefXn [0 == _]ltn_eqF// mulr0 mulf_eq0 (negPf u1N0)=> /eqP. suff : ((p : int) ^+ 2 %| q`_0)%Z by rewrite (negPf Ndvd_pq0). have := c_neq0; rewrite q_eq coefM big_ord1. rewrite lead_coefM rmorphM mulf_eq0 negb_or => /andP[lpfN0 qfN0]. have pfN1 : size pf != 1%N by rewrite size_map_poly_id0. have pgN1 : size pg != 1%N by rewrite size_map_poly_id0. have /(dvdXn _ pgN1) /eqP : pg %| c *: 'X^n by rewrite -pfMpg dvdp_mull. have /(dvdXn _ pfN1) /eqP : pf %| c *: 'X^n by rewrite -pfMpg dvdp_mulr. by rewrite !coef_map// -!(dvdz_pcharf (pchar_Fp _))//; apply: dvdz_mul. Qed. (* Connecting rationals to the ring and field tactics *) Ltac rat_to_ring := rewrite -?[0%Q]/(0 : rat)%R -?[1%Q]/(1 : rat)%R -?[(_ - _)%Q]/(_ - _ : rat)%R -?[(_ / _)%Q]/(_ / _ : rat)%R -?[(_ + _)%Q]/(_ + _ : rat)%R -?[(_ * _)%Q]/(_ * _ : rat)%R -?[(- _)%Q]/(- _ : rat)%R -?[(_ ^-1)%Q]/(_ ^-1 : rat)%R /=. Ltac ring_to_rat := rewrite -?[0%R]/0%Q -?[1%R]/1%Q -?[(_ - _)%R]/(_ - _)%Q -?[(_ / _)%R]/(_ / _)%Q -?[(_ + _)%R]/(_ + _)%Q -?[(_ * _)%R]/(_ * _)%Q -?[(- _)%R]/(- _)%Q -?[(_ ^-1)%R]/(_ ^-1)%Q /=. (* Pretty printing or normal element of rat. *) Notation "[ 'rat' x // y ]" := (@Rat (x, y) _) (only printing) : ring_scope. (* For debugging purposes we provide the parsable version *) Notation "[ 'rat' x // y ]" := (@Rat (x : int, y : int) (fracq_subproof (x : int, y : int))) : ring_scope. (* A specialization of vm_compute rewrite rule for pattern _%:Q *) Lemma rat_vm_compute n (x : rat) : vm_compute_eq n%:Q x -> n%:Q = x. Proof. exact. Qed.
finset.v
(* (c) Copyright 2006-2016 Microsoft Corporation and Inria. *) (* Distributed under the terms of CeCILL-B. *) From HB Require Import structures. From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat div seq. From mathcomp Require Import choice fintype finfun bigop. (******************************************************************************) (* This file defines a type for sets over a finite Type, similar to the type *) (* of functions over a finite Type defined in finfun.v (indeed, based in it): *) (* {set T} where T must have a finType structure. *) (* We equip {set T} itself with a finType structure, hence Leibnitz and *) (* extensional equalities coincide on {set T}, and we can form {set {set T}}. *) (* If A, B : {set T} and P : {set {set T}}, we define: *) (* x \in A == x belongs to A (i.e., {set T} implements predType, *) (* by coercion to pred_sort) *) (* mem A == the predicate corresponding to A *) (* finset p == the set corresponding to a predicate p *) (* [set x | P] == the set containing the x such that P is true (x may *) (* appear in P) *) (* [set x | P & Q] := [set x | P && Q] *) (* [set x in A] == the set containing the x in a collective predicate A *) (* [set x in A | P] == the set containing the x in A such that P is true *) (* [set x in A | P & Q] := [set x in A | P && Q] *) (* All these have typed variants [set x : T | P], [set x : T in A], etc. *) (* set0 == the empty set *) (* [set: T] or setT == the full set (the A containing all x : T) *) (* [set x] == the singleton {x} *) (* [set~ x] == the complement of the singleton {x} *) (* [set:: s] == the set spanned by the sequence s *) (* [set a1; a2;...; an] := a1 |: [set a2] :|: ... :|: [set an] *) (* A :|: B == the union of A and B *) (* x |: A == A with the element x added (:= [set x] :|: A) *) (* A :&: B == the intersection of A and B *) (* ~: A == the complement of A *) (* A :\: B == the difference A minus B *) (* A :\ x == A with the element x removed (:= A :\: [set x]) *) (* \bigcup_<range> A == the union of all A, for i in <range> (i is bound in *) (* A, see bigop.v) *) (* \bigcap_<range> A == the intersection of all A, for i in <range> *) (* cover P == the union of the set of sets P *) (* trivIset P <=> the elements of P are pairwise disjoint *) (* partition P A <=> P is a partition of A *) (* pblock P x == a block of P containing x, or else set0 *) (* equivalence_partition R D == the partition induced on D by the relation R *) (* (provided R is an equivalence relation in D) *) (* preim_partition f D == the partition induced on D by the equivalence *) (* [rel x y | f x == f y] *) (* is_transversal X P D <=> X is a transversal of the partition P of D *) (* transversal P D == a transversal of P, provided P is a partition of D *) (* transversal_repr x0 X B == a representative of B \in P selected by the *) (* transversal X of P, or else x0 *) (* powerset A == the set of all subset of the set A *) (* P ::&: A == those sets in P that are subsets of the set A *) (* setX A1 A2 == cartesian product of A1 and A2 *) (* := [set u | u.1 \in A1 & u.2 \in A2] *) (* setXn I f A == indexed cartesian product of *) (* A : forall i : I, {set f i} *) (* f @^-1: A == the preimage of the collective predicate A under f *) (* f @: A == the image set of the collective predicate A by f *) (* f @2:(A, B) == the image set of A x B by the binary function f *) (* [set E | x in A] == the set of all the values of the expression E, for x *) (* drawn from the collective predicate A *) (* [set E | x in A & P] == the set of values of E for x drawn from A, such *) (* that P is true *) (* [set E | x in A, y in B] == the set of values of E for x drawn from A and *) (* and y drawn from B; B may depend on x *) (* [set E | x in A, y in B & P] == the set of values of E for x drawn from A *) (* y drawn from B, such that P is true *) (* [set E | x : T] == the set of all values of E, with x in type T *) (* [set E | x : T & P] == the set of values of E for x : T s.t. P is true *) (* [set E | x : T, y : U in B], [set E | x : T, y : U in B & P], *) (* [set E | x : T in A, y : U], [set E | x : T in A, y : U & P], *) (* [set E | x : T, y : U], [set E | x : T, y : U & P] *) (* == type-ranging versions of the binary comprehensions *) (* [set E | x : T in A], [set E | x in A, y], [set E | x, y & P], etc. *) (* == typed and untyped variants of the comprehensions above*) (* The types may be required as type inference processes *) (* E before considering A or B. Note that type casts in *) (* the binary comprehension must either be both present *) (* or absent and that there are no untyped variants for *) (* single-type comprehension as Coq parsing confuses *) (* [x | P] and [E | x]. *) (* minset p A == A is a minimal set satisfying p *) (* maxset p A == A is a maximal set satisfying p *) (* unset1 A == [pick x in A] if #|A| == 1, else None *) (* fprod_pick I T_ p == pick a function of type (forall i : I, T_ i) provided *) (* a proof p of 0 < #|fprod I T_| is given *) (* ftagged I T_ p f i == untag (fprod_pick I T_ p) i (fun x=>x) (f i), useful *) (* to lift f : {ffun I -> {i : I & T_ i}} (akin to FProd's building blocks) *) (* to a vanilla dependent function of type (forall i : I, T_ i). *) (* Provided a monotonous function F : {set T} -> {set T}, we get fixpoints *) (* fixset F := iter #|T| F set0 *) (* == the least fixpoint of F *) (* == the minimal set such that F X == X *) (* fix_order F x == the minimum number of iterations so that *) (* x is in iter (fix_order F x) F set0 *) (* funsetC F := fun X => ~: F (~: X) *) (* cofixset F == the greatest fixpoint of F *) (* == the maximal set such that F X == X *) (* := ~: fixset (funsetC F) *) (* We also provide notations A :=: B, A :<>: B, A :==: B, A :!=: B, A :=P: B *) (* that specialize A = B, A <> B, A == B, etc., to {set _}. This is useful *) (* for subtypes of {set T}, such as {group T}, that coerce to {set T}. *) (* We give many lemmas on these operations, on card, and on set inclusion. *) (* In addition to the standard suffixes described in ssrbool.v, we associate *) (* the following suffixes to set operations: *) (* 0 -- the empty set, as in in_set0 : (x \in set0) = false *) (* T -- the full set, as in in_setT : x \in [set: T] *) (* 1 -- a singleton set, as in in_set1 : (x \in [set a]) = (x == a) *) (* 2 -- an unordered pair, as in *) (* in_set2 : (x \in [set a; b]) = (x == a) || (x == b) *) (* C -- complement, as in setCK : ~: ~: A = A *) (* I -- intersection, as in setIid : A :&: A = A *) (* U -- union, as in setUid : A :|: A = A *) (* D -- difference, as in setDv : A :\: A = set0 *) (* S -- a subset argument, as in *) (* setIS: B \subset C -> A :&: B \subset A :&: C *) (* These suffixes are sometimes preceded with an `s' to distinguish them from *) (* their basic ssrbool interpretation, e.g., *) (* card1 : #|pred1 x| = 1 and cards1 : #|[set x]| = 1 *) (* We also use a trailing `r' to distinguish a right-hand complement from *) (* commutativity, e.g., *) (* setIC : A :&: B = B :&: A and setICr : A :&: ~: A = set0. *) (******************************************************************************) Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. Declare Scope set_scope. Section SetType. Variable T : finType. Inductive set_type : predArgType := FinSet of {ffun pred T}. Definition finfun_of_set A := let: FinSet f := A in f. Definition set_of := set_type. Identity Coercion type_of_set_of : set_of >-> set_type. Definition set_isSub := Eval hnf in [isNew for finfun_of_set]. HB.instance Definition _ := set_isSub. HB.instance Definition _ := [Finite of set_type by <:]. End SetType. Delimit Scope set_scope with SET. Bind Scope set_scope with set_type. Bind Scope set_scope with set_of. Open Scope set_scope. Arguments set_of T%_type. Arguments finfun_of_set {T} A%_SET. Notation "{ 'set' T }" := (set_of T) (format "{ 'set' T }") : type_scope. (* We later define several subtypes that coerce to set; for these it is *) (* preferable to state equalities at the {set _} level, even when comparing *) (* subtype values, because the primitive "injection" tactic tends to diverge *) (* on complex types (e.g., quotient groups). We provide some parse-only *) (* notation to make this technicality less obstructive. *) Notation "A :=: B" := (A = B :> {set _}) (at level 70, no associativity, only parsing) : set_scope. Notation "A :<>: B" := (A <> B :> {set _}) (at level 70, no associativity, only parsing) : set_scope. Notation "A :==: B" := (A == B :> {set _}) (at level 70, no associativity, only parsing) : set_scope. Notation "A :!=: B" := (A != B :> {set _}) (at level 70, no associativity, only parsing) : set_scope. Notation "A :=P: B" := (A =P B :> {set _}) (at level 70, no associativity, only parsing) : set_scope. HB.lock Definition finset (T : finType) (P : pred T) : {set T} := @FinSet T (finfun P). Canonical finset_unlock := Unlockable finset.unlock. (* The weird type of pred_of_set is imposed by the syntactic restrictions on *) (* coercion declarations; it is unfortunately not possible to use a functor *) (* to retype the declaration, because this triggers an ugly bug in the Coq *) (* coercion chaining code. *) HB.lock Definition pred_of_set T (A : set_type T) : fin_pred_sort (predPredType T) := val A. Canonical pred_of_set_unlock := Unlockable pred_of_set.unlock. Notation "[ 'set' x : T | P ]" := (finset (fun x : T => P%B)) (x at level 99, only parsing) : set_scope. Notation "[ 'set' x | P ]" := [set x : _ | P] (P at level 99, format "[ 'set' x | P ]") : set_scope. Notation "[ 'set' x 'in' A ]" := [set x | x \in A] (format "[ 'set' x 'in' A ]") : set_scope. Notation "[ 'set' x : T 'in' A ]" := [set x : T | x \in A] (only parsing) : set_scope. Notation "[ 'set' x : T | P & Q ]" := [set x : T | P && Q] (only parsing) : set_scope. Notation "[ 'set' x | P & Q ]" := [set x | P && Q ] (P at level 99, format "[ 'set' x | P & Q ]") : set_scope. Notation "[ 'set' x : T 'in' A | P ]" := [set x : T | x \in A & P] (only parsing) : set_scope. Notation "[ 'set' x 'in' A | P ]" := [set x | x \in A & P] (format "[ 'set' x 'in' A | P ]") : set_scope. Notation "[ 'set' x 'in' A | P & Q ]" := [set x in A | P && Q] (format "[ 'set' x 'in' A | P & Q ]") : set_scope. Notation "[ 'set' x : T 'in' A | P & Q ]" := [set x : T in A | P && Q] (only parsing) : set_scope. Notation "[ 'set' :: s ]" := (finset [in pred_of_seq s]) (format "[ 'set' :: s ]") : set_scope. (* This lets us use set and subtypes of set, like group or coset_of, both as *) (* collective predicates and as arguments of the \pi(_) notation. *) Coercion pred_of_set: set_type >-> fin_pred_sort. (* Declare pred_of_set as a canonical instance of topred, but use the *) (* coercion to resolve mem A to @mem (predPredType T) (pred_of_set A). *) Canonical set_predType T := @PredType _ (unkeyed (set_type T)) (@pred_of_set T). Section BasicSetTheory. Variable T : finType. Implicit Types (x : T) (A B : {set T}) (pA : pred T). HB.instance Definition _ := Finite.on {set T}. Lemma in_set pA x : x \in finset pA = pA x. Proof. by rewrite [@finset]unlock unlock [x \in _]ffunE. Qed. Lemma setP A B : A =i B <-> A = B. Proof. by split=> [eqAB|-> //]; apply/val_inj/ffunP=> x; have:= eqAB x; rewrite unlock. Qed. Definition set0 := [set x : T | false]. Definition setTfor := [set x : T | true]. Lemma in_setT x : x \in setTfor. Proof. by rewrite in_set. Qed. Lemma eqsVneq A B : eq_xor_neq A B (B == A) (A == B). Proof. exact: eqVneq. Qed. Lemma eq_finset (pA pB : pred T) : pA =1 pB -> finset pA = finset pB. Proof. by move=> eq_p; apply/setP => x; rewrite !(in_set, inE) eq_p. Qed. End BasicSetTheory. Arguments eqsVneq {T} A B, {T A B}. Arguments set0 {T}. Arguments setTfor T%_type. Arguments eq_finset {T} [pA] pB eq_pAB. #[global] Hint Resolve in_setT : core. Notation "[ 'set' : T ]" := (setTfor T) (format "[ 'set' : T ]") : set_scope. Notation setT := [set: _] (only parsing). HB.lock Definition set1 (T : finType) (a : T) := [set x | x == a]. Section setOpsDefs. Variable T : finType. Implicit Types (a x : T) (A B D : {set T}) (P : {set {set T}}). Definition setU A B := [set x | (x \in A) || (x \in B)]. Definition setI A B := [set x in A | x \in B]. Definition setC A := [set x | x \notin A]. Definition setD A B := [set x | x \notin B & x \in A]. Definition ssetI P D := [set A in P | A \subset D]. Definition powerset D := [set A : {set T} | A \subset D]. End setOpsDefs. Notation "[ 'set' a ]" := (set1 a) (a at level 99, format "[ 'set' a ]") : set_scope. Notation "[ 'set' a : T ]" := [set (a : T)] (a at level 99, format "[ 'set' a : T ]") : set_scope. Notation "A :|: B" := (setU A B) : set_scope. Notation "a |: A" := ([set a] :|: A) : set_scope. (* This is left-associative due to historical limitations of the .. Notation. *) Notation "[ 'set' a1 ; a2 ; .. ; an ]" := (setU .. (a1 |: [set a2]) .. [set an]) (format "[ 'set' a1 ; a2 ; .. ; an ]") : set_scope. Notation "A :&: B" := (setI A B) : set_scope. Notation "~: A" := (setC A) (at level 35, right associativity) : set_scope. Notation "[ 'set' ~ a ]" := (~: [set a]) (format "[ 'set' ~ a ]") : set_scope. Notation "A :\: B" := (setD A B) : set_scope. Notation "A :\ a" := (A :\: [set a]) : set_scope. Notation "P ::&: D" := (ssetI P D) (at level 48) : set_scope. Section setOps. Variable T : finType. Implicit Types (a x : T) (A B C D : {set T}) (pA pB pC : pred T). Lemma eqEsubset A B : (A == B) = (A \subset B) && (B \subset A). Proof. by apply/eqP/subset_eqP=> /setP. Qed. Lemma subEproper A B : A \subset B = (A == B) || (A \proper B). Proof. by rewrite eqEsubset -andb_orr orbN andbT. Qed. Lemma eqVproper A B : A \subset B -> A = B \/ A \proper B. Proof. by rewrite subEproper => /predU1P. Qed. Lemma properEneq A B : A \proper B = (A != B) && (A \subset B). Proof. by rewrite andbC eqEsubset negb_and andb_orr andbN. Qed. Lemma proper_neq A B : A \proper B -> A != B. Proof. by rewrite properEneq; case/andP. Qed. Lemma eqEproper A B : (A == B) = (A \subset B) && ~~ (A \proper B). Proof. by rewrite negb_and negbK andb_orr andbN eqEsubset. Qed. Lemma eqEcard A B : (A == B) = (A \subset B) && (#|B| <= #|A|). Proof. rewrite eqEsubset; apply: andb_id2l => sAB. by rewrite (geq_leqif (subset_leqif_card sAB)). Qed. Lemma properEcard A B : (A \proper B) = (A \subset B) && (#|A| < #|B|). Proof. by rewrite properEneq ltnNge andbC eqEcard; case: (A \subset B). Qed. Lemma subset_leqif_cards A B : A \subset B -> (#|A| <= #|B| ?= iff (A == B)). Proof. by move=> sAB; rewrite eqEsubset sAB; apply: subset_leqif_card. Qed. Lemma in_set0 x : x \in set0 = false. Proof. by rewrite in_set. Qed. Lemma sub0set A : set0 \subset A. Proof. by apply/subsetP=> x; rewrite in_set. Qed. Lemma subset0 A : (A \subset set0) = (A == set0). Proof. by rewrite eqEsubset sub0set andbT. Qed. Lemma proper0 A : (set0 \proper A) = (A != set0). Proof. by rewrite properE sub0set subset0. Qed. Lemma subset_neq0 A B : A \subset B -> A != set0 -> B != set0. Proof. by rewrite -!proper0 => sAB /proper_sub_trans->. Qed. Lemma set_0Vmem A : (A = set0) + {x : T | x \in A}. Proof. case: (pickP (mem A)) => [x Ax | A0]; [by right; exists x | left]. by apply/setP=> x; rewrite in_set; apply: A0. Qed. Lemma set_enum A : [set x | x \in enum A] = A. Proof. by apply/setP => x; rewrite in_set mem_enum. Qed. Lemma enum_set0 : enum set0 = [::] :> seq T. Proof. by rewrite (eq_enum (in_set _)) enum0. Qed. Lemma subsetT A : A \subset setT. Proof. by apply/subsetP=> x; rewrite in_set. Qed. Lemma subsetT_hint mA : subset mA (mem [set: T]). Proof. by rewrite unlock; apply/pred0P=> x; rewrite !inE in_set. Qed. Hint Resolve subsetT_hint : core. Lemma subTset A : (setT \subset A) = (A == setT). Proof. by rewrite eqEsubset subsetT. Qed. Lemma properT A : (A \proper setT) = (A != setT). Proof. by rewrite properEneq subsetT andbT. Qed. Lemma set1P x a : reflect (x = a) (x \in [set a]). Proof. by rewrite set1.unlock in_set; apply: eqP. Qed. Lemma enum_setT : enum [set: T] = Finite.enum T. Proof. by rewrite (eq_enum (in_set _)) enumT. Qed. Lemma in_set1 x a : (x \in [set a]) = (x == a). Proof. by rewrite set1.unlock in_set. Qed. Definition inE := (in_set, in_set1, inE). Lemma set11 x : x \in [set x]. Proof. by rewrite !inE. Qed. Lemma set1_inj : injective (@set1 T). Proof. by move=> a b eqsab; apply/set1P; rewrite -eqsab set11. Qed. Lemma enum_set1 a : enum [set a] = [:: a]. Proof. by rewrite set1.unlock (eq_enum (in_set _)) enum1. Qed. Lemma setU1P x a B : reflect (x = a \/ x \in B) (x \in a |: B). Proof. by rewrite !inE; apply: predU1P. Qed. Lemma in_setU1 x a B : (x \in a |: B) = (x == a) || (x \in B). Proof. by rewrite !inE. Qed. Lemma set_nil : [set:: nil] = @set0 T. Proof. by rewrite -enum_set0 set_enum. Qed. Lemma set_seq1 a : [set:: [:: a]] = [set a]. Proof. by rewrite -enum_set1 set_enum. Qed. Lemma set_cons a s : [set:: a :: s] = a |: [set:: s]. Proof. by apply/setP=> x; rewrite !inE. Qed. Lemma setU11 x B : x \in x |: B. Proof. by rewrite !inE eqxx. Qed. Lemma setU1r x a B : x \in B -> x \in a |: B. Proof. by move=> Bx; rewrite !inE predU1r. Qed. (* We need separate lemmas for the explicit enumerations since they *) (* associate on the left. *) Lemma set1Ul x A b : x \in A -> x \in A :|: [set b]. Proof. by move=> Ax; rewrite !inE Ax. Qed. Lemma set1Ur A b : b \in A :|: [set b]. Proof. by rewrite !inE eqxx orbT. Qed. Lemma in_setC1 x a : (x \in [set~ a]) = (x != a). Proof. by rewrite !inE. Qed. Lemma setC11 x : (x \in [set~ x]) = false. Proof. by rewrite !inE eqxx. Qed. Lemma setD1P x A b : reflect (x != b /\ x \in A) (x \in A :\ b). Proof. by rewrite !inE; apply: andP. Qed. Lemma in_setD1 x A b : (x \in A :\ b) = (x != b) && (x \in A) . Proof. by rewrite !inE. Qed. Lemma setD11 b A : (b \in A :\ b) = false. Proof. by rewrite !inE eqxx. Qed. Lemma setD1K a A : a \in A -> a |: (A :\ a) = A. Proof. by move=> Aa; apply/setP=> x /[!inE]; case: eqP => // ->. Qed. Lemma setU1K a B : a \notin B -> (a |: B) :\ a = B. Proof. by move/negPf=> nBa; apply/setP=> x /[!inE]; case: eqP => // ->. Qed. Lemma set2P x a b : reflect (x = a \/ x = b) (x \in [set a; b]). Proof. by rewrite !inE; apply: pred2P. Qed. Lemma in_set2 x a b : (x \in [set a; b]) = (x == a) || (x == b). Proof. by rewrite !inE. Qed. Lemma set21 a b : a \in [set a; b]. Proof. by rewrite !inE eqxx. Qed. Lemma set22 a b : b \in [set a; b]. Proof. by rewrite !inE eqxx orbT. Qed. Lemma setUP x A B : reflect (x \in A \/ x \in B) (x \in A :|: B). Proof. by rewrite !inE; apply: orP. Qed. Lemma in_setU x A B : (x \in A :|: B) = (x \in A) || (x \in B). Proof. exact: in_set. Qed. Lemma setUC A B : A :|: B = B :|: A. Proof. by apply/setP => x; rewrite !inE orbC. Qed. Lemma setUS A B C : A \subset B -> C :|: A \subset C :|: B. Proof. move=> sAB; apply/subsetP=> x; rewrite !inE. by case: (x \in C) => //; apply: (subsetP sAB). Qed. Lemma setSU A B C : A \subset B -> A :|: C \subset B :|: C. Proof. by move=> sAB; rewrite -!(setUC C) setUS. Qed. Lemma setUSS A B C D : A \subset C -> B \subset D -> A :|: B \subset C :|: D. Proof. by move=> /(setSU B) /subset_trans sAC /(setUS C)/sAC. Qed. Lemma set0U A : set0 :|: A = A. Proof. by apply/setP => x; rewrite !inE orFb. Qed. Lemma setU0 A : A :|: set0 = A. Proof. by rewrite setUC set0U. Qed. Lemma setUA A B C : A :|: (B :|: C) = A :|: B :|: C. Proof. by apply/setP => x; rewrite !inE orbA. Qed. Lemma setUCA A B C : A :|: (B :|: C) = B :|: (A :|: C). Proof. by rewrite !setUA (setUC B). Qed. Lemma setUAC A B C : A :|: B :|: C = A :|: C :|: B. Proof. by rewrite -!setUA (setUC B). Qed. Lemma setUACA A B C D : (A :|: B) :|: (C :|: D) = (A :|: C) :|: (B :|: D). Proof. by rewrite -!setUA (setUCA B). Qed. Lemma setTU A : setT :|: A = setT. Proof. by apply/setP => x; rewrite !inE orTb. Qed. Lemma setUT A : A :|: setT = setT. Proof. by rewrite setUC setTU. Qed. Lemma setUid A : A :|: A = A. Proof. by apply/setP=> x; rewrite inE orbb. Qed. Lemma setUUl A B C : A :|: B :|: C = (A :|: C) :|: (B :|: C). Proof. by rewrite setUA !(setUAC _ C) -(setUA _ C) setUid. Qed. Lemma setUUr A B C : A :|: (B :|: C) = (A :|: B) :|: (A :|: C). Proof. by rewrite !(setUC A) setUUl. Qed. (* intersection *) (* setIdP is a generalisation of setIP that applies to comprehensions. *) Lemma setIdP x pA pB : reflect (pA x /\ pB x) (x \in [set y | pA y & pB y]). Proof. by rewrite !inE; apply: andP. Qed. Lemma setId2P x pA pB pC : reflect [/\ pA x, pB x & pC x] (x \in [set y | pA y & pB y && pC y]). Proof. by rewrite !inE; apply: and3P. Qed. Lemma setIdE A pB : [set x in A | pB x] = A :&: [set x | pB x]. Proof. by apply/setP=> x; rewrite !inE. Qed. Lemma setIP x A B : reflect (x \in A /\ x \in B) (x \in A :&: B). Proof. exact: (iffP (@setIdP _ _ _)). Qed. Lemma in_setI x A B : (x \in A :&: B) = (x \in A) && (x \in B). Proof. exact: in_set. Qed. Lemma setIC A B : A :&: B = B :&: A. Proof. by apply/setP => x; rewrite !inE andbC. Qed. Lemma setIS A B C : A \subset B -> C :&: A \subset C :&: B. Proof. move=> sAB; apply/subsetP=> x; rewrite !inE. by case: (x \in C) => //; apply: (subsetP sAB). Qed. Lemma setSI A B C : A \subset B -> A :&: C \subset B :&: C. Proof. by move=> sAB; rewrite -!(setIC C) setIS. Qed. Lemma setISS A B C D : A \subset C -> B \subset D -> A :&: B \subset C :&: D. Proof. by move=> /(setSI B) /subset_trans sAC /(setIS C) /sAC. Qed. Lemma setTI A : setT :&: A = A. Proof. by apply/setP => x; rewrite !inE andTb. Qed. Lemma setIT A : A :&: setT = A. Proof. by rewrite setIC setTI. Qed. Lemma set0I A : set0 :&: A = set0. Proof. by apply/setP => x; rewrite !inE andFb. Qed. Lemma setI0 A : A :&: set0 = set0. Proof. by rewrite setIC set0I. Qed. Lemma setIA A B C : A :&: (B :&: C) = A :&: B :&: C. Proof. by apply/setP=> x; rewrite !inE andbA. Qed. Lemma setICA A B C : A :&: (B :&: C) = B :&: (A :&: C). Proof. by rewrite !setIA (setIC A). Qed. Lemma setIAC A B C : A :&: B :&: C = A :&: C :&: B. Proof. by rewrite -!setIA (setIC B). Qed. Lemma setIACA A B C D : (A :&: B) :&: (C :&: D) = (A :&: C) :&: (B :&: D). Proof. by rewrite -!setIA (setICA B). Qed. Lemma setIid A : A :&: A = A. Proof. by apply/setP=> x; rewrite inE andbb. Qed. Lemma setIIl A B C : A :&: B :&: C = (A :&: C) :&: (B :&: C). Proof. by rewrite setIA !(setIAC _ C) -(setIA _ C) setIid. Qed. Lemma setIIr A B C : A :&: (B :&: C) = (A :&: B) :&: (A :&: C). Proof. by rewrite !(setIC A) setIIl. Qed. (* distribute /cancel *) Lemma setIUr A B C : A :&: (B :|: C) = (A :&: B) :|: (A :&: C). Proof. by apply/setP=> x; rewrite !inE andb_orr. Qed. Lemma setIUl A B C : (A :|: B) :&: C = (A :&: C) :|: (B :&: C). Proof. by apply/setP=> x; rewrite !inE andb_orl. Qed. Lemma setUIr A B C : A :|: (B :&: C) = (A :|: B) :&: (A :|: C). Proof. by apply/setP=> x; rewrite !inE orb_andr. Qed. Lemma setUIl A B C : (A :&: B) :|: C = (A :|: C) :&: (B :|: C). Proof. by apply/setP=> x; rewrite !inE orb_andl. Qed. Lemma setUK A B : (A :|: B) :&: A = A. Proof. by apply/setP=> x; rewrite !inE orbK. Qed. Lemma setKU A B : A :&: (B :|: A) = A. Proof. by apply/setP=> x; rewrite !inE orKb. Qed. Lemma setIK A B : (A :&: B) :|: A = A. Proof. by apply/setP=> x; rewrite !inE andbK. Qed. Lemma setKI A B : A :|: (B :&: A) = A. Proof. by apply/setP=> x; rewrite !inE andKb. Qed. (* complement *) Lemma setCP x A : reflect (~ x \in A) (x \in ~: A). Proof. by rewrite !inE; apply: negP. Qed. Lemma in_setC x A : (x \in ~: A) = (x \notin A). Proof. exact: in_set. Qed. Lemma setCK : involutive (@setC T). Proof. by move=> A; apply/setP=> x; rewrite !inE negbK. Qed. Lemma setC_inj : injective (@setC T). Proof. exact: can_inj setCK. Qed. Lemma subsets_disjoint A B : (A \subset B) = [disjoint A & ~: B]. Proof. by rewrite subset_disjoint; apply: eq_disjoint_r => x; rewrite !inE. Qed. Lemma disjoints_subset A B : [disjoint A & B] = (A \subset ~: B). Proof. by rewrite subsets_disjoint setCK. Qed. Lemma powersetCE A B : (A \in powerset (~: B)) = [disjoint A & B]. Proof. by rewrite inE disjoints_subset. Qed. Lemma setCS A B : (~: A \subset ~: B) = (B \subset A). Proof. by rewrite !subsets_disjoint setCK disjoint_sym. Qed. Lemma setCU A B : ~: (A :|: B) = ~: A :&: ~: B. Proof. by apply/setP=> x; rewrite !inE negb_or. Qed. Lemma setCI A B : ~: (A :&: B) = ~: A :|: ~: B. Proof. by apply/setP=> x; rewrite !inE negb_and. Qed. Lemma setUCr A : A :|: ~: A = setT. Proof. by apply/setP=> x; rewrite !inE orbN. Qed. Lemma setICr A : A :&: ~: A = set0. Proof. by apply/setP=> x; rewrite !inE andbN. Qed. Lemma setC0 : ~: set0 = [set: T]. Proof. by apply/setP=> x; rewrite !inE. Qed. Lemma setCT : ~: [set: T] = set0. Proof. by rewrite -setC0 setCK. Qed. Lemma properC A B : (~: B \proper ~: A) = (A \proper B). Proof. by rewrite !properE !setCS. Qed. (* difference *) Lemma setDP A B x : reflect (x \in A /\ x \notin B) (x \in A :\: B). Proof. by rewrite inE andbC; apply: andP. Qed. Lemma in_setD A B x : (x \in A :\: B) = (x \notin B) && (x \in A). Proof. exact: in_set. Qed. Lemma setDE A B : A :\: B = A :&: ~: B. Proof. by apply/setP => x; rewrite !inE andbC. Qed. Lemma setSD A B C : A \subset B -> A :\: C \subset B :\: C. Proof. by rewrite !setDE; apply: setSI. Qed. Lemma setDS A B C : A \subset B -> C :\: B \subset C :\: A. Proof. by rewrite !setDE -setCS; apply: setIS. Qed. Lemma setDSS A B C D : A \subset C -> D \subset B -> A :\: B \subset C :\: D. Proof. by move=> /(setSD B) /subset_trans sAC /(setDS C) /sAC. Qed. Lemma setD0 A : A :\: set0 = A. Proof. by apply/setP=> x; rewrite !inE. Qed. Lemma set0D A : set0 :\: A = set0. Proof. by apply/setP=> x; rewrite !inE andbF. Qed. Lemma setDT A : A :\: setT = set0. Proof. by apply/setP=> x; rewrite !inE. Qed. Lemma setTD A : setT :\: A = ~: A. Proof. by apply/setP=> x; rewrite !inE andbT. Qed. Lemma setDv A : A :\: A = set0. Proof. by apply/setP=> x; rewrite !inE andNb. Qed. Lemma setCD A B : ~: (A :\: B) = ~: A :|: B. Proof. by rewrite !setDE setCI setCK. Qed. Lemma setID A B : A :&: B :|: A :\: B = A. Proof. by rewrite setDE -setIUr setUCr setIT. Qed. Lemma setDUl A B C : (A :|: B) :\: C = (A :\: C) :|: (B :\: C). Proof. by rewrite !setDE setIUl. Qed. Lemma setDUr A B C : A :\: (B :|: C) = (A :\: B) :&: (A :\: C). Proof. by rewrite !setDE setCU setIIr. Qed. Lemma setDIl A B C : (A :&: B) :\: C = (A :\: C) :&: (B :\: C). Proof. by rewrite !setDE setIIl. Qed. Lemma setIDA A B C : A :&: (B :\: C) = (A :&: B) :\: C. Proof. by rewrite !setDE setIA. Qed. Lemma setIDAC A B C : (A :\: B) :&: C = (A :&: C) :\: B. Proof. by rewrite !setDE setIAC. Qed. Lemma setDIr A B C : A :\: (B :&: C) = (A :\: B) :|: (A :\: C). Proof. by rewrite !setDE setCI setIUr. Qed. Lemma setDDl A B C : (A :\: B) :\: C = A :\: (B :|: C). Proof. by rewrite !setDE setCU setIA. Qed. Lemma setDDr A B C : A :\: (B :\: C) = (A :\: B) :|: (A :&: C). Proof. by rewrite !setDE setCI setIUr setCK. Qed. (* powerset *) Lemma powersetE A B : (A \in powerset B) = (A \subset B). Proof. by rewrite inE. Qed. Lemma powersetS A B : (powerset A \subset powerset B) = (A \subset B). Proof. apply/subsetP/idP=> [sAB | sAB C /[!inE]/subset_trans->//]. by rewrite -powersetE sAB // inE. Qed. Lemma powerset0 : powerset set0 = [set set0] :> {set {set T}}. Proof. by apply/setP=> A; rewrite set1.unlock !inE subset0. Qed. Lemma powersetT : powerset [set: T] = [set: {set T}]. Proof. by apply/setP=> A; rewrite !inE subsetT. Qed. Lemma setI_powerset P A : P :&: powerset A = P ::&: A. Proof. by apply/setP=> B; rewrite !inE. Qed. (* cardinal lemmas for sets *) Lemma cardsE pA : #|[set x in pA]| = #|pA|. Proof. exact/eq_card/in_set. Qed. Lemma sum1dep_card pA : \sum_(x | pA x) 1 = #|[set x | pA x]|. Proof. by rewrite sum1_card cardsE. Qed. Lemma sum_nat_cond_const pA n : \sum_(x | pA x) n = #|[set x | pA x]| * n. Proof. by rewrite sum_nat_const cardsE. Qed. Lemma cards0 : #|@set0 T| = 0. Proof. by rewrite cardsE card0. Qed. Lemma cards_eq0 A : (#|A| == 0) = (A == set0). Proof. by rewrite (eq_sym A) eqEcard sub0set cards0 leqn0. Qed. Lemma set0Pn A : reflect (exists x, x \in A) (A != set0). Proof. by rewrite -cards_eq0; apply: existsP. Qed. Lemma set0_Nexists A : (A == set0) = ~~ [exists x, x \in A]. Proof. by rewrite -(sameP (set0Pn _) existsP) negbK. Qed. Lemma card_gt0 A : (0 < #|A|) = (A != set0). Proof. by rewrite lt0n cards_eq0. Qed. Lemma cards0_eq A : #|A| = 0 -> A = set0. Proof. by move=> A_0; apply/setP=> x; rewrite inE (card0_eq A_0). Qed. Lemma cards1 x : #|[set x]| = 1. Proof. by rewrite set1.unlock cardsE card1. Qed. Lemma cardsUI A B : #|A :|: B| + #|A :&: B| = #|A| + #|B|. Proof. by rewrite !cardsE cardUI. Qed. Lemma cardsU A B : #|A :|: B| = #|A| + #|B| - #|A :&: B|. Proof. by rewrite -cardsUI addnK. Qed. Lemma cardsI A B : #|A :&: B| = #|A| + #|B| - #|A :|: B|. Proof. by rewrite -cardsUI addKn. Qed. Lemma cardsT : #|[set: T]| = #|T|. Proof. by rewrite cardsE. Qed. Lemma cardsID B A : #|A :&: B| + #|A :\: B| = #|A|. Proof. by rewrite !cardsE cardID. Qed. Lemma cardsD A B : #|A :\: B| = #|A| - #|A :&: B|. Proof. by rewrite -(cardsID B A) addKn. Qed. Lemma cardsC A : #|A| + #|~: A| = #|T|. Proof. by rewrite cardsE cardC. Qed. Lemma cardsCs A : #|A| = #|T| - #|~: A|. Proof. by rewrite -(cardsC A) addnK. Qed. Lemma cardsU1 a A : #|a |: A| = (a \notin A) + #|A|. Proof. by rewrite -cardU1; apply: eq_card=> x; rewrite !inE. Qed. Lemma cards2 a b : #|[set a; b]| = (a != b).+1. Proof. by rewrite -card2; apply: eq_card=> x; rewrite !inE. Qed. Lemma cardsC1 a : #|[set~ a]| = #|T|.-1. Proof. by rewrite -(cardC1 a); apply: eq_card=> x; rewrite !inE. Qed. Lemma cardsD1 a A : #|A| = (a \in A) + #|A :\ a|. Proof. by rewrite (cardD1 a); congr (_ + _); apply: eq_card => x; rewrite !inE. Qed. (* other inclusions *) Lemma subsetIl A B : A :&: B \subset A. Proof. by apply/subsetP=> x /[!inE] /andP[]. Qed. Lemma subsetIr A B : A :&: B \subset B. Proof. by apply/subsetP=> x /[!inE] /andP[]. Qed. Lemma subsetUl A B : A \subset A :|: B. Proof. by apply/subsetP=> x /[!inE] ->. Qed. Lemma subsetUr A B : B \subset A :|: B. Proof. by apply/subsetP=> x; rewrite inE orbC => ->. Qed. Lemma subsetU1 x A : A \subset x |: A. Proof. exact: subsetUr. Qed. Lemma subsetDl A B : A :\: B \subset A. Proof. by rewrite setDE subsetIl. Qed. Lemma subD1set A x : A :\ x \subset A. Proof. by rewrite subsetDl. Qed. Lemma subsetDr A B : A :\: B \subset ~: B. Proof. by rewrite setDE subsetIr. Qed. Lemma sub1set A x : ([set x] \subset A) = (x \in A). Proof. by rewrite -subset_pred1; apply: eq_subset=> y; rewrite !inE. Qed. Variant cards_eq_spec A : seq T -> {set T} -> nat -> Type := | CardEq (s : seq T) & uniq s : cards_eq_spec A s [set x | x \in s] (size s). Lemma cards_eqP A : cards_eq_spec A (enum A) A #|A|. Proof. by move: (enum A) (cardE A) (set_enum A) (enum_uniq A) => s -> <-; constructor. Qed. Lemma cards1P A : reflect (exists x, A = [set x]) (#|A| == 1). Proof. apply: (iffP idP) => [|[x ->]]; last by rewrite cards1. by have [[|x []]// _] := cards_eqP; exists x; apply/setP => y; rewrite !inE. Qed. Lemma cards2P A : reflect (exists x y : T, x != y /\ A = [set x; y]) (#|A| == 2). Proof. apply: (iffP idP) => [|[x] [y] [xy ->]]; last by rewrite cards2 xy. have [[|x [|y []]]//=] := cards_eqP; rewrite !inE andbT => neq_xy. by exists x, y; split=> //; apply/setP => z; rewrite !inE. Qed. Lemma subset1 A x : (A \subset [set x]) = (A == [set x]) || (A == set0). Proof. rewrite eqEcard cards1 -cards_eq0 orbC andbC. by case: posnP => // A0; rewrite (cards0_eq A0) sub0set. Qed. Lemma powerset1 x : powerset [set x] = [set set0; [set x]]. Proof. by apply/setP=> A; rewrite inE subset1 orbC set1.unlock !inE. Qed. Lemma setIidPl A B : reflect (A :&: B = A) (A \subset B). Proof. apply: (iffP subsetP) => [sAB | <- x /setIP[] //]. by apply/setP=> x /[1!inE]; apply/andb_idr/sAB. Qed. Arguments setIidPl {A B}. Lemma setIidPr A B : reflect (A :&: B = B) (B \subset A). Proof. by rewrite setIC; apply: setIidPl. Qed. Lemma cardsDS A B : B \subset A -> #|A :\: B| = #|A| - #|B|. Proof. by rewrite cardsD => /setIidPr->. Qed. Lemma setUidPl A B : reflect (A :|: B = A) (B \subset A). Proof. by rewrite -setCS (sameP setIidPl eqP) -setCU (inj_eq setC_inj); apply: eqP. Qed. Lemma setUidPr A B : reflect (A :|: B = B) (A \subset B). Proof. by rewrite setUC; apply: setUidPl. Qed. Lemma setDidPl A B : reflect (A :\: B = A) [disjoint A & B]. Proof. by rewrite setDE disjoints_subset; apply: setIidPl. Qed. Lemma subIset A B C : (B \subset A) || (C \subset A) -> (B :&: C \subset A). Proof. by case/orP; apply: subset_trans; rewrite (subsetIl, subsetIr). Qed. Lemma subsetI A B C : (A \subset B :&: C) = (A \subset B) && (A \subset C). Proof. rewrite !(sameP setIidPl eqP) setIA; have [-> //|] := eqVneq (A :&: B) A. by apply: contraNF => /eqP <-; rewrite -setIA -setIIl setIAC. Qed. Lemma subsetIP A B C : reflect (A \subset B /\ A \subset C) (A \subset B :&: C). Proof. by rewrite subsetI; apply: andP. Qed. Lemma subsetIidl A B : (A \subset A :&: B) = (A \subset B). Proof. by rewrite subsetI subxx. Qed. Lemma subsetIidr A B : (B \subset A :&: B) = (B \subset A). Proof. by rewrite setIC subsetIidl. Qed. Lemma powersetI A B : powerset (A :&: B) = powerset A :&: powerset B. Proof. by apply/setP=> C; rewrite !inE subsetI. Qed. Lemma subUset A B C : (B :|: C \subset A) = (B \subset A) && (C \subset A). Proof. by rewrite -setCS setCU subsetI !setCS. Qed. Lemma subsetU A B C : (A \subset B) || (A \subset C) -> A \subset B :|: C. Proof. by rewrite -!(setCS _ A) setCU; apply: subIset. Qed. Lemma subUsetP A B C : reflect (A \subset C /\ B \subset C) (A :|: B \subset C). Proof. by rewrite subUset; apply: andP. Qed. Lemma subsetC A B : (A \subset ~: B) = (B \subset ~: A). Proof. by rewrite -setCS setCK. Qed. Lemma subCset A B : (~: A \subset B) = (~: B \subset A). Proof. by rewrite -setCS setCK. Qed. Lemma subsetD A B C : (A \subset B :\: C) = (A \subset B) && [disjoint A & C]. Proof. by rewrite setDE subsetI -disjoints_subset. Qed. Lemma subDset A B C : (A :\: B \subset C) = (A \subset B :|: C). Proof. apply/subsetP/subsetP=> sABC x; rewrite !inE. by case Bx: (x \in B) => // Ax; rewrite sABC ?inE ?Bx. by case Bx: (x \in B) => // /sABC; rewrite inE Bx. Qed. Lemma subsetDP A B C : reflect (A \subset B /\ [disjoint A & C]) (A \subset B :\: C). Proof. by rewrite subsetD; apply: andP. Qed. Lemma setU_eq0 A B : (A :|: B == set0) = (A == set0) && (B == set0). Proof. by rewrite -!subset0 subUset. Qed. Lemma setD_eq0 A B : (A :\: B == set0) = (A \subset B). Proof. by rewrite -subset0 subDset setU0. Qed. Lemma setI_eq0 A B : (A :&: B == set0) = [disjoint A & B]. Proof. by rewrite disjoints_subset -setD_eq0 setDE setCK. Qed. Lemma eq0_subset B A : (A == set0) = (A \subset B) && (A \subset ~: B). Proof. by rewrite -subsetI setICr subset0. Qed. Lemma disjoint_setI0 A B : [disjoint A & B] -> A :&: B = set0. Proof. by rewrite -setI_eq0; move/eqP. Qed. Lemma subsetC_disjoint A B : [disjoint A & B] -> forall C, C != set0 -> C \subset A -> ~~ (C \subset B). Proof. move=> dAB C + CA; apply: contra_neqN => CB. by apply/eqP; rewrite -subset0 -(disjoint_setI0 dAB) subsetI CA CB. Qed. Lemma disjoints1 A x : [disjoint [set x] & A] = (x \notin A). Proof. by rewrite (@eq_disjoint1 _ x) // => y; rewrite !inE. Qed. Lemma subsetD1 A B x : (A \subset B :\ x) = (A \subset B) && (x \notin A). Proof. by rewrite setDE subsetI subsetC sub1set inE. Qed. Lemma subsetD1P A B x : reflect (A \subset B /\ x \notin A) (A \subset B :\ x). Proof. by rewrite subsetD1; apply: andP. Qed. Lemma properD1 A x : x \in A -> A :\ x \proper A. Proof. move=> Ax; rewrite properE subsetDl; apply/subsetPn; exists x=> //. by rewrite in_setD1 Ax eqxx. Qed. Lemma properIr A B : ~~ (B \subset A) -> A :&: B \proper B. Proof. by move=> nsAB; rewrite properE subsetIr subsetI negb_and nsAB. Qed. Lemma properIl A B : ~~ (A \subset B) -> A :&: B \proper A. Proof. by move=> nsBA; rewrite properE subsetIl subsetI negb_and nsBA orbT. Qed. Lemma properUr A B : ~~ (A \subset B) -> B \proper A :|: B. Proof. by rewrite properE subsetUr subUset subxx /= andbT. Qed. Lemma properUl A B : ~~ (B \subset A) -> A \proper A :|: B. Proof. by move=> not_sBA; rewrite setUC properUr. Qed. Lemma proper1set A x : ([set x] \proper A) -> (x \in A). Proof. by move/proper_sub; rewrite sub1set. Qed. Lemma properIset A B C : (B \proper A) || (C \proper A) -> (B :&: C \proper A). Proof. by case/orP; apply: sub_proper_trans; rewrite (subsetIl, subsetIr). Qed. Lemma properI A B C : (A \proper B :&: C) -> (A \proper B) && (A \proper C). Proof. move=> pAI; apply/andP. by split; apply: (proper_sub_trans pAI); rewrite (subsetIl, subsetIr). Qed. Lemma properU A B C : (B :|: C \proper A) -> (B \proper A) && (C \proper A). Proof. move=> pUA; apply/andP. by split; apply: sub_proper_trans pUA; rewrite (subsetUr, subsetUl). Qed. Lemma properD A B C : (A \proper B :\: C) -> (A \proper B) && [disjoint A & C]. Proof. by rewrite setDE disjoints_subset => /properI/andP[-> /proper_sub]. Qed. Lemma properCr A B : (A \proper ~: B) = (B \proper ~: A). Proof. by rewrite -properC setCK. Qed. Lemma properCl A B : (~: A \proper B) = (~: B \proper A). Proof. by rewrite -properC setCK. Qed. (* relationship with seq *) Lemma enum_setU A B : perm_eq (enum (A :|: B)) (undup (enum A ++ enum B)). Proof. apply: uniq_perm; rewrite ?enum_uniq ?undup_uniq//. by move=> i; rewrite mem_undup mem_enum inE mem_cat !mem_enum. Qed. Lemma enum_setI A B : perm_eq (enum (A :&: B)) (filter [in B] (enum A)). Proof. apply: uniq_perm; rewrite ?enum_uniq// 1?filter_uniq// ?enum_uniq//. by move=> x; rewrite /= mem_enum mem_filter inE mem_enum andbC. Qed. Lemma has_set1 pA A a : has pA (enum [set a]) = pA a. Proof. by rewrite enum_set1 has_seq1. Qed. Lemma has_setU pA A B : has pA (enum (A :|: B)) = (has pA (enum A)) || (has pA (enum B)). Proof. by rewrite (perm_has _ (enum_setU _ _)) has_undup has_cat. Qed. Lemma all_set1 pA A a : all pA (enum [set a]) = pA a. Proof. by rewrite enum_set1 all_seq1. Qed. Lemma all_setU pA A B : all pA (enum (A :|: B)) = (all pA (enum A)) && (all pA (enum B)). Proof. by rewrite (perm_all _ (enum_setU _ _)) all_undup all_cat. Qed. End setOps. Arguments set1P {T x a}. Arguments set1_inj {T} [x1 x2]. Arguments set2P {T x a b}. Arguments setIdP {T x pA pB}. Arguments setIP {T x A B}. Arguments setU1P {T x a B}. Arguments setD1P {T x A b}. Arguments setUP {T x A B}. Arguments setDP {T A B x}. Arguments cards1P {T A}. Arguments setCP {T x A}. Arguments setIidPl {T A B}. Arguments setIidPr {T A B}. Arguments setUidPl {T A B}. Arguments setUidPr {T A B}. Arguments setDidPl {T A B}. Arguments subsetIP {T A B C}. Arguments subUsetP {T A B C}. Arguments subsetDP {T A B C}. Arguments subsetD1P {T A B x}. Prenex Implicits set1. #[global] Hint Extern 0 (is_true (subset _ (mem (pred_of_set (setTfor _))))) => solve [apply: subsetT_hint] : core. Section setOpsAlgebra. Import Monoid. Variable T : finType. HB.instance Definition _ := isComLaw.Build {set T} [set: T] (@setI T) (@setIA T) (@setIC T) (@setTI T). HB.instance Definition _ := isMulLaw.Build {set T} set0 (@setI T) (@set0I T) (@setI0 T). HB.instance Definition _ := isComLaw.Build {set T} set0 (@setU T) (@setUA T) (@setUC T) (@set0U T). HB.instance Definition _ := isMulLaw.Build {set T} [set: T] (@setU T) (@setTU T) (@setUT T). HB.instance Definition _ := isAddLaw.Build {set T} (@setU T) (@setI T) (@setUIl T) (@setUIr T). HB.instance Definition _ := isAddLaw.Build {set T} (@setI T) (@setU T) (@setIUl T) (@setIUr T). End setOpsAlgebra. Section CartesianProd. Variables fT1 fT2 : finType. Variables (A1 : {set fT1}) (A2 : {set fT2}). Definition setX := [set u | u.1 \in A1 & u.2 \in A2]. Lemma in_setX x1 x2 : ((x1, x2) \in setX) = (x1 \in A1) && (x2 \in A2). Proof. by rewrite inE. Qed. Lemma setXP x1 x2 : reflect (x1 \in A1 /\ x2 \in A2) ((x1, x2) \in setX). Proof. by rewrite inE; apply: andP. Qed. Lemma cardsX : #|setX| = #|A1| * #|A2|. Proof. by rewrite cardsE cardX. Qed. End CartesianProd. Arguments setXP {fT1 fT2 A1 A2 x1 x2}. Section CartesianNProd. Variables (I : finType) (fT : I -> finType). Variables (A : forall i, {set fT i}). Implicit Types (x : {dffun forall i, fT i}). Definition setXn := [set x : {dffun _} in family A]. Lemma in_setXn x : (x \in setXn) = [forall i, x i \in A i]. Proof. by rewrite inE. Qed. Lemma setXnP x : reflect (forall i, x i \in A i) (x \in setXn). Proof. by rewrite inE; apply: forallP. Qed. Lemma cardsXn : #|setXn| = \prod_i #|A i|. Proof. by rewrite cardsE card_family foldrE big_map big_enum. Qed. End CartesianNProd. Arguments setXnP {I fT A x}. HB.lock Definition imset (aT rT : finType) f mD := [set y in @image_mem aT rT f mD]. Canonical imset_unlock := Unlockable imset.unlock. HB.lock Definition imset2 (aT1 aT2 rT : finType) f (D1 : mem_pred aT1) (D2 : _ -> mem_pred aT2) := [set y in @image_mem _ rT (uncurry f) (mem [pred u | D1 u.1 & D2 u.1 u.2])]. Canonical imset2_unlock := Unlockable imset2.unlock. Definition preimset (aT : finType) rT f (R : mem_pred rT) := [set x : aT | in_mem (f x) R]. Notation "f @^-1: A" := (preimset f (mem A)) (at level 24) : set_scope. Notation "f @: A" := (imset f (mem A)) (at level 24) : set_scope. Notation "f @2: ( A , B )" := (imset2 f (mem A) (fun _ => mem B)) (at level 24, format "f @2: ( A , B )") : set_scope. (* Comprehensions *) Notation "[ 'set' E | x 'in' A ]" := ((fun x => E) @: A) (format "[ '[hv' 'set' E '/ ' | x 'in' A ] ']'") : set_scope. Notation "[ 'set' E | x 'in' A & P ]" := [set E | x in pred_of_set [set x in A | P]] (format "[ '[hv' 'set' E '/ ' | x 'in' A '/ ' & P ] ']'") : set_scope. Notation "[ 'set' E | x 'in' A , y 'in' B ]" := (imset2 (fun x y => E) (mem A) (fun x => mem B)) (y at level 99, format "[ '[hv' 'set' E '/ ' | x 'in' A , '/ ' y 'in' B ] ']'" ) : set_scope. Notation "[ 'set' E | x 'in' A , y 'in' B & P ]" := [set E | x in A, y in pred_of_set [set y in B | P]] (format "[ '[hv' 'set' E '/ ' | x 'in' A , '/ ' y 'in' B '/ ' & P ] ']'" ) : set_scope. (* Typed variants *) Notation "[ 'set' E | x : T 'in' A ]" := ((fun x : T => E) @: A) (only parsing) : set_scope. Notation "[ 'set' E | x : T 'in' A & P ]" := [set E | x : T in [set x : T in A | P]] (only parsing) : set_scope. Notation "[ 'set' E | x : T 'in' A , y : U 'in' B ]" := (imset2 (fun (x : T) (y : U) => E) (mem A) (fun (x : T) => mem B)) (y at level 99, only parsing) : set_scope. Notation "[ 'set' E | x : T 'in' A , y : U 'in' B & P ]" := [set E | x : T in A, y : U in [set y : U in B | P]] (only parsing) : set_scope. (* Comprehensions over a type *) Local Notation predOfType T := (pred_of_simpl (@pred_of_argType T)). Notation "[ 'set' E | x : T ]" := [set E | x : T in predOfType T] (format "[ '[hv' 'set' E '/ ' | x : T ] ']'") : set_scope. Notation "[ 'set' E | x : T & P ]" := [set E | x : T in pred_of_set [set x : T | P]] (format "[ '[hv' 'set' E '/ ' | x : T '/ ' & P ] ']'") : set_scope. Notation "[ 'set' E | x : T , y : U 'in' B ]" := [set E | x : T in predOfType T, y : U in B] (y at level 99, format "[ '[hv' 'set' E '/ ' | x : T , '/ ' y : U 'in' B ] ']'") : set_scope. Notation "[ 'set' E | x : T , y : U 'in' B & P ]" := [set E | x : T, y : U in pred_of_set [set y in B | P]] (format "[ '[hv ' 'set' E '/' | x : T , '/ ' y : U 'in' B '/' & P ] ']'" ) : set_scope. Notation "[ 'set' E | x : T 'in' A , y : U ]" := [set E | x : T in A, y : U in predOfType U] (format "[ '[hv' 'set' E '/ ' | x : T 'in' A , '/ ' y : U ] ']'") : set_scope. Notation "[ 'set' E | x : T 'in' A , y : U & P ]" := [set E | x : T in A, y : U in pred_of_set [set y in P]] (format "[ '[hv' 'set' E '/ ' | x : T 'in' A , '/ ' y : U & P ] ']'") : set_scope. Notation "[ 'set' E | x : T , y : U ]" := [set E | x : T, y : U in predOfType U] (format "[ '[hv' 'set' E '/ ' | x : T , '/ ' y : U ] ']'") : set_scope. Notation "[ 'set' E | x : T , y : U & P ]" := [set E | x : T, y : U in pred_of_set [set y in P]] (format "[ '[hv' 'set' E '/ ' | x : T , '/ ' y : U & P ] ']'") : set_scope. (* Untyped variants *) Notation "[ 'set' E | x , y 'in' B ]" := [set E | x : _, y : _ in B] (y at level 99, only parsing) : set_scope. Notation "[ 'set' E | x , y 'in' B & P ]" := [set E | x : _, y : _ in B & P] (only parsing) : set_scope. Notation "[ 'set' E | x 'in' A , y ]" := [set E | x : _ in A, y : _] (only parsing) : set_scope. Notation "[ 'set' E | x 'in' A , y & P ]" := [set E | x : _ in A, y : _ & P] (only parsing) : set_scope. Notation "[ 'set' E | x , y ]" := [set E | x : _, y : _] (only parsing) : set_scope. Notation "[ 'set' E | x , y & P ]" := [set E | x : _, y : _ & P ] (only parsing) : set_scope. Section FunImage. Variables aT aT2 : finType. Section ImsetTheory. Variable rT : finType. Section ImsetProp. Variables (f : aT -> rT) (f2 : aT -> aT2 -> rT). Lemma imsetP D y : reflect (exists2 x, in_mem x D & y = f x) (y \in imset f D). Proof. by rewrite [@imset]unlock inE; apply: imageP. Qed. Variant imset2_spec D1 D2 y : Prop := Imset2spec x1 x2 of in_mem x1 D1 & in_mem x2 (D2 x1) & y = f2 x1 x2. Lemma imset2P D1 D2 y : reflect (imset2_spec D1 D2 y) (y \in imset2 f2 D1 D2). Proof. rewrite [@imset2]unlock inE. apply: (iffP imageP) => [[[x1 x2] Dx12] | [x1 x2 Dx1 Dx2]] -> {y}. by case/andP: Dx12; exists x1 x2. by exists (x1, x2); rewrite //= !inE Dx1. Qed. Lemma imset_f (D : {pred aT}) x : x \in D -> f x \in f @: D. Proof. by move=> Dx; apply/imsetP; exists x. Qed. Lemma mem_imset (D : {pred aT}) x : injective f -> f x \in f @: D = (x \in D). Proof. by move=> f_inj; apply/imsetP/idP;[case=> [y] ? /f_inj -> | move=> ?; exists x]. Qed. Lemma imset0 : f @: set0 = set0. Proof. by apply/setP => y /[!inE]; apply/imsetP => -[x /[!inE]]. Qed. Lemma imset_eq0 (A : {set aT}) : (f @: A == set0) = (A == set0). Proof. have [-> | [x Ax]] := set_0Vmem A; first by rewrite imset0 !eqxx. by rewrite -!cards_eq0 (cardsD1 x) Ax (cardsD1 (f x)) imset_f. Qed. Lemma imset_set1 x : f @: [set x] = [set f x]. Proof. apply/setP => y. by apply/imsetP/set1P=> [[x' /set1P-> //]| ->]; exists x; rewrite ?set11. Qed. Lemma imset_inj : injective f -> injective (fun A : {set aT} => f @: A). Proof. move=> inj_f A B => /setP E; apply/setP => x. by rewrite -(mem_imset A x inj_f) E mem_imset. Qed. Lemma imset_disjoint (A B : {pred aT}) : injective f -> [disjoint f @: A & f @: B] = [disjoint A & B]. Proof. move=> inj_f; apply/pred0Pn/pred0Pn => /= [[_ /andP[/imsetP[x xA ->]] xB]|]. by exists x; rewrite xA -(mem_imset B x inj_f). by move=> [x /andP[xA xB]]; exists (f x); rewrite !mem_imset ?xA. Qed. Lemma imset2_f (D : {pred aT}) (D2 : aT -> {pred aT2}) x x2 : x \in D -> x2 \in D2 x -> f2 x x2 \in [set f2 y y2 | y in D, y2 in D2 y]. Proof. by move=> Dx Dx2; apply/imset2P; exists x x2. Qed. Lemma mem_imset2 (D : {pred aT}) (D2 : aT -> {pred aT2}) x x2 : injective2 f2 -> (f2 x x2 \in [set f2 y y2 | y in D, y2 in D2 y]) = (x \in D) && (x2 \in D2 x). Proof. move=> inj2_f; apply/imset2P/andP => [|[xD xD2]]; last by exists x x2. by move => [x' x2' xD xD2 eq_f2]; case: (inj2_f _ _ _ _ eq_f2) => -> ->. Qed. Lemma sub_imset_pre (A : {pred aT}) (B : {pred rT}) : (f @: A \subset B) = (A \subset f @^-1: B). Proof. apply/subsetP/subsetP=> [sfAB x Ax | sAf'B fx]. by rewrite inE sfAB ?imset_f. by move=> /imsetP[a + ->] => /sAf'B /[!inE]. Qed. Lemma preimsetS (A B : {pred rT}) : A \subset B -> (f @^-1: A) \subset (f @^-1: B). Proof. by move=> sAB; apply/subsetP=> y /[!inE]; apply: subsetP. Qed. Lemma preimset0 : f @^-1: set0 = set0. Proof. by apply/setP=> x; rewrite !inE. Qed. Lemma preimsetT : f @^-1: setT = setT. Proof. by apply/setP=> x; rewrite !inE. Qed. Lemma preimsetI (A B : {set rT}) : f @^-1: (A :&: B) = (f @^-1: A) :&: (f @^-1: B). Proof. by apply/setP=> y; rewrite !inE. Qed. Lemma preimsetU (A B : {set rT}) : f @^-1: (A :|: B) = (f @^-1: A) :|: (f @^-1: B). Proof. by apply/setP=> y; rewrite !inE. Qed. Lemma preimsetD (A B : {set rT}) : f @^-1: (A :\: B) = (f @^-1: A) :\: (f @^-1: B). Proof. by apply/setP=> y; rewrite !inE. Qed. Lemma preimsetC (A : {set rT}) : f @^-1: (~: A) = ~: f @^-1: A. Proof. by apply/setP=> y; rewrite !inE. Qed. Lemma imsetS (A B : {pred aT}) : A \subset B -> f @: A \subset f @: B. Proof. move=> sAB; apply/subsetP => _ /imsetP[x Ax ->]. by apply/imsetP; exists x; rewrite ?(subsetP sAB). Qed. Lemma imset_proper (A B : {set aT}) : {in B &, injective f} -> A \proper B -> f @: A \proper f @: B. Proof. move=> injf /properP[sAB [x Bx nAx]]; rewrite properE imsetS //=. apply: contra nAx => sfBA. have: f x \in f @: A by rewrite (subsetP sfBA) ?imset_f. by case/imsetP=> y Ay /injf-> //; apply: subsetP sAB y Ay. Qed. Lemma preimset_proper (A B : {set rT}) : B \subset codom f -> A \proper B -> (f @^-1: A) \proper (f @^-1: B). Proof. move=> sBc /properP[sAB [u Bu nAu]]; rewrite properE preimsetS //=. by apply/subsetPn; exists (iinv (subsetP sBc _ Bu)); rewrite inE /= f_iinv. Qed. Lemma imsetU (A B : {set aT}) : f @: (A :|: B) = (f @: A) :|: (f @: B). Proof. apply/eqP; rewrite eqEsubset subUset. rewrite 2?imsetS (andbT, subsetUl, subsetUr) // andbT. apply/subsetP=> _ /imsetP[x ABx ->]; apply/setUP. by case/setUP: ABx => [Ax | Bx]; [left | right]; apply/imsetP; exists x. Qed. Lemma imsetU1 a (A : {set aT}) : f @: (a |: A) = f a |: (f @: A). Proof. by rewrite imsetU imset_set1. Qed. Lemma imsetI (A B : {set aT}) : {in A & B, injective f} -> f @: (A :&: B) = f @: A :&: f @: B. Proof. move=> injf; apply/eqP; rewrite eqEsubset subsetI. rewrite 2?imsetS (andTb, subsetIl, subsetIr) //=. apply/subsetP=> _ /setIP[/imsetP[x Ax ->] /imsetP[z Bz /injf eqxz]]. by rewrite imset_f // inE Ax eqxz. Qed. Lemma imset2Sl (A B : {pred aT}) (C : {pred aT2}) : A \subset B -> f2 @2: (A, C) \subset f2 @2: (B, C). Proof. move=> sAB; apply/subsetP=> _ /imset2P[x y Ax Cy ->]. by apply/imset2P; exists x y; rewrite ?(subsetP sAB). Qed. Lemma imset2Sr (A B : {pred aT2}) (C : {pred aT}) : A \subset B -> f2 @2: (C, A) \subset f2 @2: (C, B). Proof. move=> sAB; apply/subsetP=> _ /imset2P[x y Ax Cy ->]. by apply/imset2P; exists x y; rewrite ?(subsetP sAB). Qed. Lemma imset2S (A B : {pred aT}) (A2 B2 : {pred aT2}) : A \subset B -> A2 \subset B2 -> f2 @2: (A, A2) \subset f2 @2: (B, B2). Proof. by move=> /(imset2Sl B2) sBA /(imset2Sr A)/subset_trans->. Qed. End ImsetProp. Implicit Types (f g : aT -> rT) (D : {pred aT}) (R : {pred rT}). Lemma eq_preimset f g R : f =1 g -> f @^-1: R = g @^-1: R. Proof. by move=> eqfg; apply/setP => y; rewrite !inE eqfg. Qed. Lemma eq_imset f g D : f =1 g -> f @: D = g @: D. Proof. move=> eqfg; apply/setP=> y. by apply/imsetP/imsetP=> [] [x Dx ->]; exists x; rewrite ?eqfg. Qed. Lemma eq_in_imset f g D : {in D, f =1 g} -> f @: D = g @: D. Proof. move=> eqfg; apply/setP => y. by apply/imsetP/imsetP=> [] [x Dx ->]; exists x; rewrite ?eqfg. Qed. Lemma eq_in_imset2 (f g : aT -> aT2 -> rT) (D : {pred aT}) (D2 : {pred aT2}) : {in D & D2, f =2 g} -> f @2: (D, D2) = g @2: (D, D2). Proof. move=> eqfg; apply/setP => y. by apply/imset2P/imset2P=> [] [x x2 Dx Dx2 ->]; exists x x2; rewrite ?eqfg. Qed. End ImsetTheory. Lemma imset2_pair (A : {set aT}) (B : {set aT2}) : [set (x, y) | x in A, y in B] = setX A B. Proof. apply/setP=> [[x y]]; rewrite !inE /=. by apply/imset2P/andP=> [[_ _ _ _ [-> ->]//]| []]; exists x y. Qed. Lemma setXS (A1 B1 : {set aT}) (A2 B2 : {set aT2}) : A1 \subset B1 -> A2 \subset B2 -> setX A1 A2 \subset setX B1 B2. Proof. by move=> sAB1 sAB2; rewrite -!imset2_pair imset2S. Qed. End FunImage. Arguments imsetP {aT rT f D y}. Arguments imset2P {aT aT2 rT f2 D1 D2 y}. Arguments imset_disjoint {aT rT f A B}. Section unset1. Variable (I : finType). Implicit Types (i : I) (A : {set I}). Lemma pick_set1 i0 : [pick x in [set i0]] = Some i0. Proof. by case: pickP => [i /[!inE]/eqP-> | /(_ i0)/[!(inE, eqxx)]]. Qed. Definition unset1 A : option I := if #|A| == 1 then [pick x in A] else None. Lemma set1K : pcancel set1 unset1. Proof. by move=> i; rewrite /unset1 cards1 eqxx pick_set1. Qed. Lemma omap_unset1K A : #|A| = 1 -> omap set1 (unset1 A) = Some A. Proof. by move=> /eqP/cards1P[i ->]; rewrite set1K. Qed. Lemma unset10 : unset1 set0 = None. Proof. by rewrite /unset1 cards0. Qed. Lemma unset1N1 A : #|A| != 1 -> unset1 A = None. Proof. by move=> AN1; rewrite /unset1 ifN. Qed. Lemma unset1K : ocancel unset1 set1. Proof. move=> A; rewrite /unset1. by case: ifPn => // /cards1P[i ->]/=; rewrite pick_set1. Qed. End unset1. Arguments unset1 {I}. Lemma setXnS (I : finType) (T : I -> finType) (A B : forall i, {set T i}) : (forall i, A i \subset B i) -> setXn A \subset setXn B. Proof. move=> sAB; apply/subsetP => x /setXnP xA. by apply/setXnP => i; apply/subsetP: (xA i). Qed. Lemma eq_setXn (I : finType) (T : I -> finType) (A B : forall i, {set T i}) : (forall i, A i = B i) -> setXn A = setXn B. Proof. by move=> eqAB; apply/eqP; rewrite eqEsubset !setXnS// => j; rewrite eqAB. Qed. Section BigOpsAnyOp. Variables (R : Type) (x : R) (op : R -> R -> R). Variables I : finType. Implicit Type F : I -> R. Lemma big_set0 F : \big[op/x]_(i in set0) F i = x. Proof. by apply: big_pred0 => i; rewrite inE. Qed. Lemma big_set1E j F : \big[op/x]_(i in [set j]) F i = op (F j) x. Proof. by rewrite -big_pred1_eq_id; apply: eq_bigl => i; apply: in_set1. Qed. Lemma big_set (A : pred I) F : \big[op/x]_(i in [set i | A i]) (F i) = \big[op/x]_(i in A) (F i). Proof. by apply: eq_bigl => i; rewrite inE. Qed. End BigOpsAnyOp. Section BigOpsSemiGroup. Variables (R : Type) (op : SemiGroup.com_law R). Variable (le : rel R). Hypotheses (le_refl : reflexive le) (le_incr : forall x y, le x (op x y)). Context [x : R]. Lemma subset_le_big_cond (I : finType) (A A' P P' : {pred I}) (F : I -> R) : [set i in A | P i] \subset [set i in A' | P' i] -> le (\big[op/x]_(i in A | P i) F i) (\big[op/x]_(i in A' | P' i) F i). Proof. by move=> /subsetP AP; apply: sub_le_big => // i; have /[!inE] := AP i. Qed. Lemma big_imset_idem [I J : finType] (h : I -> J) (A : pred I) F : idempotent_op op -> \big[op/x]_(j in h @: A) F j = \big[op/x]_(i in A) F (h i). Proof. rewrite -!big_image => op_idem; rewrite -big_undup// -[RHS]big_undup//. apply/perm_big/perm_undup => j; apply/imageP. have [mem_j | /imageP mem_j] := boolP (j \in [seq h j | j in A]). - by exists j => //; apply/imsetP; apply: imageP mem_j. - by case=> k /imsetP [i j_in_A ->] eq_i; apply: mem_j; exists i. Qed. End BigOpsSemiGroup. Section BigOps. Variables (R : Type) (idx : R). Variables (op : Monoid.law idx) (aop : Monoid.com_law idx). Variables (times : Monoid.mul_law idx) (plus : Monoid.add_law idx times). Variables I J : finType. Implicit Type A B : {set I}. Implicit Type h : I -> J. Implicit Type P : pred I. Implicit Type F : I -> R. Lemma big_set1 a F : \big[op/idx]_(i in [set a]) F i = F a. Proof. by apply: big_pred1 => i; rewrite !inE. Qed. Lemma big_setID A B F : \big[aop/idx]_(i in A) F i = aop (\big[aop/idx]_(i in A :&: B) F i) (\big[aop/idx]_(i in A :\: B) F i). Proof. rewrite (bigID [in B]) setDE. by congr (aop _ _); apply: eq_bigl => i; rewrite !inE. Qed. Lemma big_setIDcond A B P F : \big[aop/idx]_(i in A | P i) F i = aop (\big[aop/idx]_(i in A :&: B | P i) F i) (\big[aop/idx]_(i in A :\: B | P i) F i). Proof. by rewrite !big_mkcondr; apply: big_setID. Qed. Lemma big_setD1 a A F : a \in A -> \big[aop/idx]_(i in A) F i = aop (F a) (\big[aop/idx]_(i in A :\ a) F i). Proof. move=> Aa; rewrite (bigD1 a Aa); congr (aop _). by apply: eq_bigl => x; rewrite !inE andbC. Qed. Lemma big_setU1 a A F : a \notin A -> \big[aop/idx]_(i in a |: A) F i = aop (F a) (\big[aop/idx]_(i in A) F i). Proof. by move=> notAa; rewrite (@big_setD1 a) ?setU11 //= setU1K. Qed. Lemma big_subset_idem_cond A B P F : idempotent_op aop -> A \subset B -> aop (\big[aop/idx]_(i in A | P i) F i) (\big[aop/idx]_(i in B | P i) F i) = \big[aop/idx]_(i in B | P i) F i. Proof. by move=> idaop /setIidPr <-; rewrite (big_setIDcond B A) Monoid.mulmA /= idaop. Qed. Lemma big_subset_idem A B F : idempotent_op aop -> A \subset B -> aop (\big[aop/idx]_(i in A) F i) (\big[aop/idx]_(i in B) F i) = \big[aop/idx]_(i in B) F i. Proof. by rewrite -2!big_condT; apply: big_subset_idem_cond. Qed. Lemma big_setU_cond A B P F : idempotent_op aop -> \big[aop/idx]_(i in A :|: B | P i) F i = aop (\big[aop/idx]_(i in A | P i) F i) (\big[aop/idx]_(i in B | P i) F i). Proof. move=> idemaop; rewrite (big_setIDcond _ A) setUK setDUl setDv set0U. rewrite (big_setIDcond B A) Monoid.mulmCA Monoid.mulmA /=. by rewrite (@big_subset_idem_cond (B :&: A)) // subsetIr. Qed. Lemma big_setU A B F : idempotent_op aop -> \big[aop/idx]_(i in A :|: B) F i = aop (\big[aop/idx]_(i in A) F i) (\big[aop/idx]_(i in B) F i). Proof. by rewrite -3!big_condT; apply: big_setU_cond. Qed. Lemma big_imset h (A : {pred I}) G : {in A &, injective h} -> \big[aop/idx]_(j in h @: A) G j = \big[aop/idx]_(i in A) G (h i). Proof. move=> injh; pose hA := mem (image h A). rewrite (eq_bigl hA) => [|j]; last exact/imsetP/imageP. pose h' := omap (fun u : {j | hA j} => iinv (svalP u)) \o insub. rewrite (reindex_omap h h') => [|j hAj]; rewrite {}/h'/= ?insubT/= ?f_iinv//. apply: eq_bigl => i; case: insubP => [u /= -> def_u | nhAhi]; last first. by apply/andP/idP => [[]//| Ai]; case/imageP: nhAhi; exists i. set i' := iinv _; have Ai' : i' \in A := mem_iinv (svalP u). by apply/eqP/idP => [[<-] // | Ai]; congr Some; apply: injh; rewrite ?f_iinv. Qed. Lemma big_imset_cond h (A : {pred I}) (P : pred J) G : {in A &, injective h} -> \big[aop/idx]_(j in h @: A | P j) G j = \big[aop/idx]_(i in A | P (h i)) G (h i). Proof. by move=> h_inj; rewrite 2!big_mkcondr big_imset. Qed. Lemma partition_big_imset h (A : {pred I}) F : \big[aop/idx]_(i in A) F i = \big[aop/idx]_(j in h @: A) \big[aop/idx]_(i in A | h i == j) F i. Proof. by apply: partition_big => i Ai; apply/imsetP; exists i. Qed. Lemma big_cards1 (f : {set I} -> R) : \big[aop/idx]_(A : {set I} | #|A| == 1) f A = \big[aop/idx]_(i : I) f [set i]. Proof. rewrite (reindex_omap set1 unset1) => [|A /cards1P[i ->] /[!set1K]//]. by apply: eq_bigl => i; rewrite set1K cards1 !eqxx. Qed. End BigOps. Lemma bigA_distr (R : Type) (zero one : R) (mul : Monoid.mul_law zero) (add : Monoid.add_law zero mul) (I : finType) (F G : I -> R) : \big[mul/one]_i add (F i) (G i) = \big[add/zero]_(J in {set I}) \big[mul/one]_i (if i \in J then F i else G i). Proof. under eq_bigr => i _ do rewrite -(big_bool _ (fun b => if b then F i else G i)). rewrite bigA_distr_bigA. set f := fun J : {set I} => val J. transitivity (\big[add/zero]_(f0 in (imset f (mem setT))) \big[mul/one]_i (if f0 i then F i else G i)). suff <-: setT = imset f (mem setT) by apply: congr_big=>// i; rewrite in_setT. apply/esym/eqP; rewrite -subTset; apply/subsetP => b _. by apply/imsetP; exists (FinSet b). rewrite big_imset; last by case=> g; case=> h _ _; rewrite /f => /= ->. apply: congr_big => //; case=> g; first exact: in_setT. by move=> _; apply: eq_bigr => i _; congr (if _ then _ else _); rewrite unlock. Qed. Arguments big_setID [R idx aop I A]. Arguments big_setD1 [R idx aop I] a [A F]. Arguments big_setU1 [R idx aop I] a [A F]. Arguments big_imset [R idx aop I J h A]. Arguments partition_big_imset [R idx aop I J]. Section Fun2Set1. Variables aT1 aT2 rT : finType. Variables (f : aT1 -> aT2 -> rT). Lemma imset2_set1l x1 (D2 : {pred aT2}) : f @2: ([set x1], D2) = f x1 @: D2. Proof. apply/setP=> y; apply/imset2P/imsetP=> [[x x2 /set1P->]| [x2 Dx2 ->]]. by exists x2. by exists x1 x2; rewrite ?set11. Qed. Lemma imset2_set1r x2 (D1 : {pred aT1}) : f @2: (D1, [set x2]) = f^~ x2 @: D1. Proof. apply/setP=> y; apply/imset2P/imsetP=> [[x1 x Dx1 /set1P->]| [x1 Dx1 ->]]. by exists x1. by exists x1 x2; rewrite ?set11. Qed. End Fun2Set1. Section CardFunImage. Variables aT aT2 rT : finType. Variables (f : aT -> rT) (g : rT -> aT) (f2 : aT -> aT2 -> rT). Variables (D : {pred aT}) (D2 : {pred aT}). Lemma imset_card : #|f @: D| = #|image f D|. Proof. by rewrite [@imset]unlock cardsE. Qed. Lemma leq_imset_card : #|f @: D| <= #|D|. Proof. by rewrite imset_card leq_image_card. Qed. Lemma card_in_imset : {in D &, injective f} -> #|f @: D| = #|D|. Proof. by move=> injf; rewrite imset_card card_in_image. Qed. Lemma card_imset : injective f -> #|f @: D| = #|D|. Proof. by move=> injf; rewrite imset_card card_image. Qed. Lemma imset_injP : reflect {in D &, injective f} (#|f @: D| == #|D|). Proof. by rewrite [@imset]unlock cardsE; apply: image_injP. Qed. Lemma can2_in_imset_pre : {in D, cancel f g} -> {on D, cancel g & f} -> f @: D = g @^-1: D. Proof. move=> fK gK; apply/setP=> y; rewrite inE. by apply/imsetP/idP=> [[x Ax ->] | Agy]; last exists (g y); rewrite ?(fK, gK). Qed. Lemma can2_imset_pre : cancel f g -> cancel g f -> f @: D = g @^-1: D. Proof. by move=> fK gK; apply: can2_in_imset_pre; apply: in1W. Qed. End CardFunImage. Arguments imset_injP {aT rT f D}. Lemma on_card_preimset (aT rT : finType) (f : aT -> rT) (R : {pred rT}) : {on R, bijective f} -> #|f @^-1: R| = #|R|. Proof. case=> g fK gK; rewrite -(can2_in_imset_pre gK) // card_in_imset //. exact: can_in_inj gK. Qed. Lemma can_imset_pre (T : finType) f g (A : {set T}) : cancel f g -> f @: A = g @^-1: A :> {set T}. Proof. move=> fK; apply: can2_imset_pre => // x. suffices fx: x \in codom f by rewrite -(f_iinv fx) fK. exact/(subset_cardP (card_codom (can_inj fK)))/subsetP. Qed. Lemma imset_id (T : finType) (A : {set T}) : [set x | x in A] = A. Proof. by apply/setP=> x; rewrite (@can_imset_pre _ _ id) ?inE. Qed. Lemma card_preimset (T : finType) (f : T -> T) (A : {set T}) : injective f -> #|f @^-1: A| = #|A|. Proof. move=> injf; apply: on_card_preimset; apply: onW_bij. have ontof: _ \in codom f by apply/(subset_cardP (card_codom injf))/subsetP. by exists (fun x => iinv (ontof x)) => x; rewrite (f_iinv, iinv_f). Qed. Lemma card_powerset (T : finType) (A : {set T}) : #|powerset A| = 2 ^ #|A|. Proof. rewrite -card_bool -(card_pffun_on false) -(card_imset _ val_inj). apply: eq_card => f; pose sf := false.-support f; pose D := finset sf. have sDA: (D \subset A) = (sf \subset A) by apply: eq_subset; apply: in_set. have eq_sf x : sf x = f x by rewrite /= negb_eqb addbF. have valD: val D = f by rewrite /D unlock; apply/ffunP=> x; rewrite ffunE eq_sf. apply/imsetP/pffun_onP=> [[B] | [sBA _]]; last by exists D; rewrite // inE ?sDA. by rewrite inE -sDA -valD => sBA /val_inj->. Qed. Section FunImageComp. Variables T T' U : finType. Lemma imset_comp (f : T' -> U) (g : T -> T') (H : {pred T}) : (f \o g) @: H = f @: (g @: H). Proof. apply/setP/subset_eqP/andP. split; apply/subsetP=> _ /imsetP[x0 Hx0 ->]; apply/imsetP. by exists (g x0); first apply: imset_f. by move/imsetP: Hx0 => [x1 Hx1 ->]; exists x1. Qed. End FunImageComp. Notation "\bigcup_ ( i <- r | P ) F" := (\big[@setU _/set0]_(i <- r | P) F%SET) : set_scope. Notation "\bigcup_ ( i <- r ) F" := (\big[@setU _/set0]_(i <- r) F%SET) : set_scope. Notation "\bigcup_ ( m <= i < n | P ) F" := (\big[@setU _/set0]_(m <= i < n | P%B) F%SET) : set_scope. Notation "\bigcup_ ( m <= i < n ) F" := (\big[@setU _/set0]_(m <= i < n) F%SET) : set_scope. Notation "\bigcup_ ( i | P ) F" := (\big[@setU _/set0]_(i | P%B) F%SET) : set_scope. Notation "\bigcup_ i F" := (\big[@setU _/set0]_i F%SET) : set_scope. Notation "\bigcup_ ( i : t | P ) F" := (\big[@setU _/set0]_(i : t | P%B) F%SET) (only parsing): set_scope. Notation "\bigcup_ ( i : t ) F" := (\big[@setU _/set0]_(i : t) F%SET) (only parsing) : set_scope. Notation "\bigcup_ ( i < n | P ) F" := (\big[@setU _/set0]_(i < n | P%B) F%SET) : set_scope. Notation "\bigcup_ ( i < n ) F" := (\big[@setU _/set0]_ (i < n) F%SET) : set_scope. Notation "\bigcup_ ( i 'in' A | P ) F" := (\big[@setU _/set0]_(i in A | P%B) F%SET) : set_scope. Notation "\bigcup_ ( i 'in' A ) F" := (\big[@setU _/set0]_(i in A) F%SET) : set_scope. Notation "\bigcap_ ( i <- r | P ) F" := (\big[@setI _/setT]_(i <- r | P%B) F%SET) : set_scope. Notation "\bigcap_ ( i <- r ) F" := (\big[@setI _/setT]_(i <- r) F%SET) : set_scope. Notation "\bigcap_ ( m <= i < n | P ) F" := (\big[@setI _/setT]_(m <= i < n | P%B) F%SET) : set_scope. Notation "\bigcap_ ( m <= i < n ) F" := (\big[@setI _/setT]_(m <= i < n) F%SET) : set_scope. Notation "\bigcap_ ( i | P ) F" := (\big[@setI _/setT]_(i | P%B) F%SET) : set_scope. Notation "\bigcap_ i F" := (\big[@setI _/setT]_i F%SET) : set_scope. Notation "\bigcap_ ( i : t | P ) F" := (\big[@setI _/setT]_(i : t | P%B) F%SET) (only parsing): set_scope. Notation "\bigcap_ ( i : t ) F" := (\big[@setI _/setT]_(i : t) F%SET) (only parsing) : set_scope. Notation "\bigcap_ ( i < n | P ) F" := (\big[@setI _/setT]_(i < n | P%B) F%SET) : set_scope. Notation "\bigcap_ ( i < n ) F" := (\big[@setI _/setT]_(i < n) F%SET) : set_scope. Notation "\bigcap_ ( i 'in' A | P ) F" := (\big[@setI _/setT]_(i in A | P%B) F%SET) : set_scope. Notation "\bigcap_ ( i 'in' A ) F" := (\big[@setI _/setT]_(i in A) F%SET) : set_scope. Section BigSetOps. Variables T I : finType. Implicit Types (U : {pred T}) (P : pred I) (A B : {set I}) (F : I -> {set T}). (* It is very hard to use this lemma, because the unification fails to *) (* defer the F j pattern (even though it's a Miller pattern!). *) Lemma bigcup_sup j P F : P j -> F j \subset \bigcup_(i | P i) F i. Proof. by move=> Pj; rewrite (bigD1 j) //= subsetUl. Qed. Lemma bigcup_max j U P F : P j -> U \subset F j -> U \subset \bigcup_(i | P i) F i. Proof. by move=> Pj sUF; apply: subset_trans (bigcup_sup _ Pj). Qed. Lemma bigcupP x P F : reflect (exists2 i, P i & x \in F i) (x \in \bigcup_(i | P i) F i). Proof. apply: (iffP idP) => [|[i Pi]]; last first. by apply: subsetP x; apply: bigcup_sup. by elim/big_rec: _ => [|i _ Pi _ /setUP[|//]]; [rewrite inE | exists i]. Qed. Lemma bigcupsP U P F : reflect (forall i, P i -> F i \subset U) (\bigcup_(i | P i) F i \subset U). Proof. apply: (iffP idP) => [sFU i Pi| sFU]. by apply: subset_trans sFU; apply: bigcup_sup. by apply/subsetP=> x /bigcupP[i Pi]; apply: (subsetP (sFU i Pi)). Qed. Lemma bigcup0P P F : reflect (forall i, P i -> F i = set0) (\bigcup_(i | P i) F i == set0). Proof. rewrite -subset0; apply: (iffP (bigcupsP _ _ _)) => sub0 i /sub0; last by move->. by rewrite subset0 => /eqP. Qed. Lemma bigcup_disjointP U P F : reflect (forall i : I, P i -> [disjoint U & F i]) [disjoint U & \bigcup_(i | P i) F i]. Proof. apply: (iffP idP) => [dUF i Pp|dUF]. by apply: disjointWr dUF; apply: bigcup_sup. rewrite disjoint_sym disjoint_subset. by apply/bigcupsP=> i /dUF; rewrite disjoint_sym disjoint_subset. Qed. Lemma bigcup_disjoint U P F : (forall i, P i -> [disjoint U & F i]) -> [disjoint U & \bigcup_(i | P i) F i]. Proof. by move/bigcup_disjointP. Qed. Lemma bigcup_setU A B F : \bigcup_(i in A :|: B) F i = (\bigcup_(i in A) F i) :|: (\bigcup_ (i in B) F i). Proof. apply/setP=> x; apply/bigcupP/setUP=> [[i] | ]. by case/setUP; [left | right]; apply/bigcupP; exists i. by case=> /bigcupP[i Pi]; exists i; rewrite // inE Pi ?orbT. Qed. Lemma bigcup_seq r F : \bigcup_(i <- r) F i = \bigcup_(i in r) F i. Proof. elim: r => [|i r IHr]; first by rewrite big_nil big_pred0. rewrite big_cons {}IHr; case r_i: (i \in r). rewrite (setUidPr _) ?bigcup_sup //. by apply: eq_bigl => j /[!inE]; case: eqP => // ->. rewrite (bigD1 i (mem_head i r)) /=; congr (_ :|: _). by apply: eq_bigl => j /=; rewrite andbC; case: eqP => // ->. Qed. (* Unlike its setU counterpart, this lemma is useable. *) Lemma bigcap_inf j P F : P j -> \bigcap_(i | P i) F i \subset F j. Proof. by move=> Pj; rewrite (bigD1 j) //= subsetIl. Qed. Lemma bigcap_min j U P F : P j -> F j \subset U -> \bigcap_(i | P i) F i \subset U. Proof. by move=> Pj; apply: subset_trans (bigcap_inf _ Pj). Qed. Lemma bigcapsP U P F : reflect (forall i, P i -> U \subset F i) (U \subset \bigcap_(i | P i) F i). Proof. apply: (iffP idP) => [sUF i Pi | sUF]. by apply: subset_trans sUF _; apply: bigcap_inf. elim/big_rec: _ => [|i V Pi sUV]; apply/subsetP=> x Ux; rewrite inE //. by rewrite !(subsetP _ x Ux) ?sUF. Qed. Lemma bigcapP x P F : reflect (forall i, P i -> x \in F i) (x \in \bigcap_(i | P i) F i). Proof. rewrite -sub1set. by apply: (iffP (bigcapsP _ _ _)) => Fx i /Fx; rewrite sub1set. Qed. Lemma setC_bigcup J r (P : pred J) (F : J -> {set T}) : ~: (\bigcup_(j <- r | P j) F j) = \bigcap_(j <- r | P j) ~: F j. Proof. by apply: big_morph => [A B|]; rewrite ?setC0 ?setCU. Qed. Lemma setC_bigcap J r (P : pred J) (F : J -> {set T}) : ~: (\bigcap_(j <- r | P j) F j) = \bigcup_(j <- r | P j) ~: F j. Proof. by apply: big_morph => [A B|]; rewrite ?setCT ?setCI. Qed. Lemma bigcap_setU A B F : (\bigcap_(i in A :|: B) F i) = (\bigcap_(i in A) F i) :&: (\bigcap_(i in B) F i). Proof. by apply: setC_inj; rewrite setCI !setC_bigcap bigcup_setU. Qed. Lemma bigcap_seq r F : \bigcap_(i <- r) F i = \bigcap_(i in r) F i. Proof. by apply: setC_inj; rewrite !setC_bigcap bigcup_seq. Qed. End BigSetOps. Arguments bigcup_sup [T I] j [P F]. Arguments bigcup_max [T I] j [U P F]. Arguments bigcupP {T I x P F}. Arguments bigcupsP {T I U P F}. Arguments bigcup_disjointP {T I U P F}. Arguments bigcap_inf [T I] j [P F]. Arguments bigcap_min [T I] j [U P F]. Arguments bigcapP {T I x P F}. Arguments bigcapsP {T I U P F}. Section ImsetCurry. Variables (aT1 aT2 rT : finType) (f : aT1 -> aT2 -> rT). Section Curry. Variables (A1 : {set aT1}) (A2 : {set aT2}). Variables (D1 : {pred aT1}) (D2 : {pred aT2}). Lemma curry_imset2X : f @2: (A1, A2) = uncurry f @: (setX A1 A2). Proof. rewrite [@imset]unlock unlock; apply/setP=> x; rewrite !in_set; congr (x \in _). by apply: eq_image => u //=; rewrite !inE. Qed. Lemma curry_imset2l : f @2: (D1, D2) = \bigcup_(x1 in D1) f x1 @: D2. Proof. apply/setP=> y; apply/imset2P/bigcupP => [[x1 x2 Dx1 Dx2 ->{y}] | [x1 Dx1]]. by exists x1; rewrite // imset_f. by case/imsetP=> x2 Dx2 ->{y}; exists x1 x2. Qed. Lemma curry_imset2r : f @2: (D1, D2) = \bigcup_(x2 in D2) f^~ x2 @: D1. Proof. apply/setP=> y; apply/imset2P/bigcupP => [[x1 x2 Dx1 Dx2 ->{y}] | [x2 Dx2]]. by exists x2; rewrite // (imset_f (f^~ x2)). by case/imsetP=> x1 Dx1 ->{y}; exists x1 x2. Qed. End Curry. Lemma imset2Ul (A B : {set aT1}) (C : {set aT2}) : f @2: (A :|: B, C) = f @2: (A, C) :|: f @2: (B, C). Proof. by rewrite !curry_imset2l bigcup_setU. Qed. Lemma imset2Ur (A : {set aT1}) (B C : {set aT2}) : f @2: (A, B :|: C) = f @2: (A, B) :|: f @2: (A, C). Proof. by rewrite !curry_imset2r bigcup_setU. Qed. End ImsetCurry. Section Partitions. Variables T I : finType. Implicit Types (x y z : T) (A B D X : {set T}) (P Q : {set {set T}}). Implicit Types (J : pred I) (F : I -> {set T}). Definition cover P := \bigcup_(B in P) B. Definition pblock P x := odflt set0 (pick [pred B in P | x \in B]). Definition trivIset P := \sum_(B in P) #|B| == #|cover P|. Definition partition P D := [&& cover P == D, trivIset P & set0 \notin P]. Definition is_transversal X P D := [&& partition P D, X \subset D & [forall B in P, #|X :&: B| == 1]]. Definition transversal P D := [set odflt x [pick y in pblock P x] | x in D]. Definition transversal_repr x0 X B := odflt x0 [pick x in X :&: B]. Lemma leq_card_setU A B : #|A :|: B| <= #|A| + #|B| ?= iff [disjoint A & B]. Proof. rewrite -(addn0 #|_|) -setI_eq0 -cards_eq0 -cardsUI eq_sym. by rewrite (mono_leqif (leq_add2l _)). Qed. Lemma leq_card_cover P : #|cover P| <= \sum_(A in P) #|A| ?= iff trivIset P. Proof. split; last exact: eq_sym. rewrite /cover; elim/big_rec2: _ => [|A n U _ leUn]; first by rewrite cards0. by rewrite (leq_trans (leq_card_setU A U).1) ?leq_add2l. Qed. Lemma imset_cover (T' : finType) P (f : T -> T') : [set f x | x in cover P] = \bigcup_(i in P) [set f x | x in i]. Proof. apply/setP=> y; apply/imsetP/bigcupP => [|[A AP /imsetP[x xA ->]]]. by move=> [x /bigcupP[A AP xA] ->]; exists A => //; rewrite imset_f. by exists x => //; apply/bigcupP; exists A. Qed. Lemma cover1 A : cover [set A] = A. Proof. by rewrite /cover big_set1. Qed. Lemma trivIset1 A : trivIset [set A]. Proof. by rewrite /trivIset cover1 big_set1. Qed. Lemma trivIsetP P : reflect {in P &, forall A B, A != B -> [disjoint A & B]} (trivIset P). Proof. rewrite -[P]set_enum; elim: {P}(enum _) (enum_uniq P) => [_ | A e IHe] /=. by rewrite /trivIset /cover !big_set0 cards0; left=> A; rewrite inE. case/andP; rewrite set_cons -(in_set (fun B => B \in e)) => PA {}/IHe. move: {e}[set x in e] PA => P PA IHP. rewrite /trivIset /cover !big_setU1 //= eq_sym. have:= leq_card_cover P; rewrite -(mono_leqif (leq_add2l #|A|)). move/(leqif_trans (leq_card_setU _ _))->; rewrite disjoints_subset setC_bigcup. case: bigcapsP => [disjA | meetA]; last first. right=> [tI]; case: meetA => B PB; rewrite -disjoints_subset. by rewrite tI ?setU11 ?setU1r //; apply: contraNneq PA => ->. apply: (iffP IHP) => [] tI B C PB PC; last by apply: tI; apply: setU1r. by case/setU1P: PC PB => [->|PC] /setU1P[->|PB]; try by [apply: tI | case/eqP]; first rewrite disjoint_sym; rewrite disjoints_subset disjA. Qed. Lemma trivIsetS P Q : P \subset Q -> trivIset Q -> trivIset P. Proof. by move/subsetP/sub_in2=> sPQ /trivIsetP/sPQ/trivIsetP. Qed. Lemma trivIsetD P Q : trivIset P -> trivIset (P :\: Q). Proof. move/trivIsetP => tP; apply/trivIsetP => A B /setDP[TA _] /setDP[TB _]; exact: tP. Qed. Lemma trivIsetU P Q : trivIset Q -> trivIset P -> [disjoint cover Q & cover P] -> trivIset (Q :|: P). Proof. move => /trivIsetP tQ /trivIsetP tP dQP; apply/trivIsetP => A B. move => /setUP[?|?] /setUP[?|?]; first [exact:tQ|exact:tP|move => _]. by apply: disjointW dQP; rewrite bigcup_sup. by rewrite disjoint_sym; apply: disjointW dQP; rewrite bigcup_sup. Qed. Lemma coverD1 P B : trivIset P -> B \in P -> cover (P :\ B) = cover P :\: B. Proof. move/trivIsetP => tP SP; apply/setP => x; rewrite inE. apply/bigcupP/idP => [[A /setD1P [ADS AP] xA]|/andP[xNS /bigcupP[A AP xA]]]. by rewrite (disjointFr (tP _ _ _ _ ADS)) //=; apply/bigcupP; exists A. by exists A; rewrite // !inE AP andbT; apply: contraNneq xNS => <-. Qed. Lemma trivIsetI P D : trivIset P -> trivIset (P ::&: D). Proof. by apply: trivIsetS; rewrite -setI_powerset subsetIl. Qed. Lemma cover_setI P D : cover (P ::&: D) \subset cover P :&: D. Proof. by apply/bigcupsP=> A /setIdP[PA sAD]; rewrite subsetI sAD andbT (bigcup_max A). Qed. Lemma mem_pblock P x : (x \in pblock P x) = (x \in cover P). Proof. rewrite /pblock; apply/esym/bigcupP. case: pickP => /= [A /andP[PA Ax]| noA]; first by rewrite Ax; exists A. by rewrite inE => [[A PA Ax]]; case/andP: (noA A). Qed. Lemma pblock_mem P x : x \in cover P -> pblock P x \in P. Proof. by rewrite -mem_pblock /pblock; case: pickP => [A /andP[]| _] //=; rewrite inE. Qed. Lemma def_pblock P B x : trivIset P -> B \in P -> x \in B -> pblock P x = B. Proof. move/trivIsetP=> tiP PB Bx; have Px: x \in cover P by apply/bigcupP; exists B. apply: (contraNeq (tiP _ _ _ PB)); first by rewrite pblock_mem. by apply/pred0Pn; exists x; rewrite /= mem_pblock Px. Qed. Lemma same_pblock P x y : trivIset P -> x \in pblock P y -> pblock P x = pblock P y. Proof. rewrite {1 3}/pblock => tI; case: pickP => [A|]; last by rewrite inE. by case/andP=> PA _{y} /= Ax; apply: def_pblock. Qed. Lemma eq_pblock P x y : trivIset P -> x \in cover P -> (pblock P x == pblock P y) = (y \in pblock P x). Proof. move=> tiP Px; apply/eqP/idP=> [eq_xy | /same_pblock-> //]. move: Px; rewrite -mem_pblock eq_xy /pblock. by case: pickP => [B /andP[] // | _] /[1!inE]. Qed. Lemma trivIsetU1 A P : {in P, forall B, [disjoint A & B]} -> trivIset P -> set0 \notin P -> trivIset (A |: P) /\ A \notin P. Proof. move=> tiAP tiP notPset0; split; last first. apply: contra notPset0 => P_A. by have:= tiAP A P_A; rewrite -setI_eq0 setIid => /eqP <-. apply/trivIsetP=> B1 B2 /setU1P[->|PB1] /setU1P[->|PB2]; by [apply: (trivIsetP _ tiP) | rewrite ?eqxx // ?(tiAP, disjoint_sym)]. Qed. Lemma cover_imset J F : cover (F @: J) = \bigcup_(i in J) F i. Proof. apply/setP=> x. apply/bigcupP/bigcupP=> [[_ /imsetP[i Ji ->]] | [i]]; first by exists i. by exists (F i); first apply: imset_f. Qed. Lemma trivIimset J F (P := F @: J) : {in J &, forall i j, j != i -> [disjoint F i & F j]} -> set0 \notin P -> trivIset P /\ {in J &, injective F}. Proof. move=> tiF notPset0; split=> [|i j Ji Jj /= eqFij]. apply/trivIsetP=> _ _ /imsetP[i Ji ->] /imsetP[j Jj ->] neqFij. by rewrite tiF // (contraNneq _ neqFij) // => ->. apply: contraNeq notPset0 => neq_ij; apply/imsetP; exists i => //; apply/eqP. by rewrite eq_sym -[F i]setIid setI_eq0 {1}eqFij tiF. Qed. Lemma cover_partition P D : partition P D -> cover P = D. Proof. by case/and3P=> /eqP. Qed. Lemma partition0 P D : partition P D -> set0 \in P = false. Proof. case/and3P => _ _. by apply: contraNF. Qed. Lemma partition_neq0 P D B : partition P D -> B \in P -> B != set0. Proof. by move=> partP; apply: contraTneq => ->; rewrite (partition0 partP). Qed. Lemma partition_trivIset P D : partition P D -> trivIset P. Proof. by case/and3P. Qed. Lemma partitionS P D B : partition P D -> B \in P -> B \subset D. Proof. by move=> partP BP; rewrite -(cover_partition partP); apply: bigcup_max BP _. Qed. Lemma partitionD1 P D B : partition P D -> B \in P -> partition (P :\ B) (D :\: B). Proof. case/and3P => /eqP covP trivP set0P SP. by rewrite /partition inE (negbTE set0P) trivIsetD ?coverD1 -?covP ?eqxx ?andbF. Qed. Lemma partitionU1 P D B : partition P D -> B != set0 -> [disjoint B & D] -> partition (B |: P) (B :|: D). Proof. case/and3P => /eqP covP trivP set0P BD0 disSD. rewrite /partition !inE (negbTE set0P) orbF [_ == B]eq_sym BD0 andbT. rewrite /cover bigcup_setU /= big_set1 -covP eqxx /=. by move: disSD; rewrite -covP=> /bigcup_disjointP/trivIsetU1 => -[]. Qed. Lemma partition_set0 P : partition P set0 = (P == set0). Proof. apply/and3P/eqP => [[/bigcup0P covP _ ]|->]; last first. by rewrite /partition inE /trivIset/cover !big_set0 cards0 !eqxx. by apply: contraNeq => /set0Pn[B BP]; rewrite -(covP B BP). Qed. Lemma card_partition P D : partition P D -> #|D| = \sum_(A in P) #|A|. Proof. by case/and3P=> /eqP <- /eqnP. Qed. Lemma card_uniform_partition n P D : {in P, forall A, #|A| = n} -> partition P D -> #|D| = #|P| * n. Proof. by move=> uniP /card_partition->; rewrite -sum_nat_const; apply: eq_bigr. Qed. Lemma partition_pigeonhole P D A : partition P D -> #|P| <= #|A| -> A \subset D -> {in P, forall B, #|A :&: B| <= 1} -> {in P, forall B, A :&: B != set0}. Proof. move=> partP card_A_P /subsetP subAD sub1; apply/forall_inP. apply: contraTT card_A_P => /forall_inPn [B BP]; rewrite negbK => AB0. rewrite -!ltnNge -(setD1K BP) cardsU1 !inE eqxx /= add1n ltnS. have [tP covP] := (partition_trivIset partP,cover_partition partP). have APx x : x \in A -> x \in pblock P x by rewrite mem_pblock covP; apply: subAD. have inj_f : {in A &, injective (pblock P)}. move=> x y xA yA /eqP; rewrite eq_pblock ?covP ?subAD // => Pxy. apply: (@card_le1_eqP _ (A :&: pblock P x)); rewrite ?inE ?Pxy ?APx ?andbT //. by apply: sub1; rewrite pblock_mem ?covP ?subAD. rewrite -(card_in_imset inj_f); apply: subset_leq_card. apply/subsetP => ? /imsetP[x xA ->]. rewrite !inE pblock_mem ?covP ?subAD ?andbT //. by apply: contraTneq AB0 => <-; apply/set0Pn; exists x; rewrite inE APx ?andbT. Qed. Section BigOps. Variables (R : Type) (idx : R) (op : Monoid.com_law idx). Let rhs_cond P K E := \big[op/idx]_(A in P) \big[op/idx]_(x in A | K x) E x. Let rhs P E := \big[op/idx]_(A in P) \big[op/idx]_(x in A) E x. Lemma big_trivIset_cond P (K : pred T) (E : T -> R) : trivIset P -> \big[op/idx]_(x in cover P | K x) E x = rhs_cond P K E. Proof. move=> tiP; rewrite (partition_big (pblock P) [in P]) -/op => /= [|x]. apply: eq_bigr => A PA; apply: eq_bigl => x; rewrite andbAC; congr (_ && _). rewrite -mem_pblock; apply/andP/idP=> [[Px /eqP <- //] | Ax]. by rewrite (def_pblock tiP PA Ax). by case/andP=> Px _; apply: pblock_mem. Qed. Lemma big_trivIset P (E : T -> R) : trivIset P -> \big[op/idx]_(x in cover P) E x = rhs P E. Proof. have biginT := eq_bigl _ _ (fun _ => andbT _) => tiP. by rewrite -biginT big_trivIset_cond //; apply: eq_bigr => A _; apply: biginT. Qed. Lemma set_partition_big_cond P D (K : pred T) (E : T -> R) : partition P D -> \big[op/idx]_(x in D | K x) E x = rhs_cond P K E. Proof. by case/and3P=> /eqP <- tI_P _; apply: big_trivIset_cond. Qed. Lemma set_partition_big P D (E : T -> R) : partition P D -> \big[op/idx]_(x in D) E x = rhs P E. Proof. by case/and3P=> /eqP <- tI_P _; apply: big_trivIset. Qed. Lemma partition_disjoint_bigcup (F : I -> {set T}) E : (forall i j, i != j -> [disjoint F i & F j]) -> \big[op/idx]_(x in \bigcup_i F i) E x = \big[op/idx]_i \big[op/idx]_(x in F i) E x. Proof. move=> disjF; pose P := [set F i | i in I & F i != set0]. have trivP: trivIset P. apply/trivIsetP=> _ _ /imsetP[i _ ->] /imsetP[j _ ->] neqFij. by apply: disjF; apply: contraNneq neqFij => ->. have ->: \bigcup_i F i = cover P. apply/esym; rewrite cover_imset big_mkcond; apply: eq_bigr => i _. by rewrite inE; case: eqP. rewrite big_trivIset // /rhs big_imset => [|i j _ /setIdP[_ notFj0] eqFij]. rewrite big_mkcond; apply: eq_bigr => i _; rewrite inE. by case: eqP => //= ->; rewrite big_set0. by apply: contraNeq (disjF _ _) _; rewrite -setI_eq0 eqFij setIid. Qed. End BigOps. Section Equivalence. Variables (R : rel T) (D : {set T}). Let Px x := [set y in D | R x y]. Definition equivalence_partition := [set Px x | x in D]. Local Notation P := equivalence_partition. Hypothesis eqiR : {in D & &, equivalence_rel R}. Let Pxx x : x \in D -> x \in Px x. Proof. by move=> Dx; rewrite !inE Dx (eqiR Dx Dx). Qed. Let PPx x : x \in D -> Px x \in P := fun Dx => imset_f _ Dx. Lemma equivalence_partitionP : partition P D. Proof. have defD: cover P == D. rewrite eqEsubset; apply/andP; split. by apply/bigcupsP=> _ /imsetP[x Dx ->]; rewrite /Px setIdE subsetIl. by apply/subsetP=> x Dx; apply/bigcupP; exists (Px x); rewrite (Pxx, PPx). have tiP: trivIset P. apply/trivIsetP=> _ _ /imsetP[x Dx ->] /imsetP[y Dy ->]; apply: contraR. case/pred0Pn=> z /andP[] /[!inE] /andP[Dz Rxz] /andP[_ Ryz]. apply/eqP/setP=> t /[!inE]; apply: andb_id2l => Dt. by rewrite (eqiR Dx Dz Dt) // (eqiR Dy Dz Dt). rewrite /partition tiP defD /=. by apply/imsetP=> [[x /Pxx Px_x Px0]]; rewrite -Px0 inE in Px_x. Qed. Lemma pblock_equivalence_partition : {in D &, forall x y, (y \in pblock P x) = R x y}. Proof. have [_ tiP _] := and3P equivalence_partitionP. by move=> x y Dx Dy; rewrite /= (def_pblock tiP (PPx Dx) (Pxx Dx)) inE Dy. Qed. End Equivalence. Lemma pblock_equivalence P D : partition P D -> {in D & &, equivalence_rel (fun x y => y \in pblock P x)}. Proof. case/and3P=> /eqP <- tiP _ x y z Px Py Pz. by rewrite mem_pblock; split=> // /same_pblock->. Qed. Lemma equivalence_partition_pblock P D : partition P D -> equivalence_partition (fun x y => y \in pblock P x) D = P. Proof. case/and3P=> /eqP <-{D} tiP notP0; apply/setP=> B /=; set D := cover P. have defP x: x \in D -> [set y in D | y \in pblock P x] = pblock P x. by move=> Dx; apply/setIidPr; rewrite (bigcup_max (pblock P x)) ?pblock_mem. apply/imsetP/idP=> [[x Px ->{B}] | PB]; first by rewrite defP ?pblock_mem. have /set0Pn[x Bx]: B != set0 := memPn notP0 B PB. have Px: x \in cover P by apply/bigcupP; exists B. by exists x; rewrite // defP // (def_pblock tiP PB Bx). Qed. Section Preim. Variables (rT : eqType) (f : T -> rT). Definition preim_partition := equivalence_partition (fun x y => f x == f y). Lemma preim_partitionP D : partition (preim_partition D) D. Proof. by apply/equivalence_partitionP; split=> // /eqP->. Qed. End Preim. Lemma preim_partition_pblock P D : partition P D -> preim_partition (pblock P) D = P. Proof. move=> partP; have [/eqP defD tiP _] := and3P partP. rewrite -{2}(equivalence_partition_pblock partP); apply: eq_in_imset => x Dx. by apply/setP=> y; rewrite !inE eq_pblock ?defD. Qed. Lemma transversalP P D : partition P D -> is_transversal (transversal P D) P D. Proof. case/and3P=> /eqP <- tiP notP0; apply/and3P; split; first exact/and3P. apply/subsetP=> _ /imsetP[x Px ->]; case: pickP => //= y Pxy. by apply/bigcupP; exists (pblock P x); rewrite ?pblock_mem //. apply/forall_inP=> B PB; have /set0Pn[x Bx]: B != set0 := memPn notP0 B PB. apply/cards1P; exists (odflt x [pick y in pblock P x]); apply/esym/eqP. rewrite eqEsubset sub1set !inE -andbA; apply/andP; split. by apply/imset_f/bigcupP; exists B. rewrite (def_pblock tiP PB Bx); case def_y: _ / pickP => [y By | /(_ x)/idP//]. rewrite By /=; apply/subsetP=> _ /setIP[/imsetP[z Pz ->]]. case: {1}_ / pickP => [t zPt Bt | /(_ z)/idP[]]; last by rewrite mem_pblock. by rewrite -(same_pblock tiP zPt) (def_pblock tiP PB Bt) def_y inE. Qed. Section Transversals. Variables (X : {set T}) (P : {set {set T}}) (D : {set T}). Hypothesis trPX : is_transversal X P D. Lemma transversal_sub : X \subset D. Proof. by case/and3P: trPX. Qed. Let tiP : trivIset P. Proof. by case/andP: trPX => /and3P[]. Qed. Let sXP : {subset X <= cover P}. Proof. by case/and3P: trPX => /andP[/eqP-> _] /subsetP. Qed. Let trX : {in P, forall B, #|X :&: B| == 1}. Proof. by case/and3P: trPX => _ _ /forall_inP. Qed. Lemma setI_transversal_pblock x0 B : B \in P -> X :&: B = [set transversal_repr x0 X B]. Proof. by case/trX/cards1P=> x defXB; rewrite /transversal_repr defXB /pick enum_set1. Qed. Lemma repr_mem_pblock x0 B : B \in P -> transversal_repr x0 X B \in B. Proof. by move=> PB; rewrite -sub1set -setI_transversal_pblock ?subsetIr. Qed. Lemma repr_mem_transversal x0 B : B \in P -> transversal_repr x0 X B \in X. Proof. by move=> PB; rewrite -sub1set -setI_transversal_pblock ?subsetIl. Qed. Lemma transversal_reprK x0 : {in P, cancel (transversal_repr x0 X) (pblock P)}. Proof. by move=> B PB; rewrite /= (def_pblock tiP PB) ?repr_mem_pblock. Qed. Lemma pblockK x0 : {in X, cancel (pblock P) (transversal_repr x0 X)}. Proof. move=> x Xx; have /bigcupP[B PB Bx] := sXP Xx; rewrite (def_pblock tiP PB Bx). by apply/esym/set1P; rewrite -setI_transversal_pblock // inE Xx. Qed. Lemma pblock_inj : {in X &, injective (pblock P)}. Proof. by move=> x0; apply: (can_in_inj (pblockK x0)). Qed. Lemma pblock_transversal : pblock P @: X = P. Proof. apply/setP=> B; apply/imsetP/idP=> [[x Xx ->] | PB]. by rewrite pblock_mem ?sXP. have /cards1P[x0 _] := trX PB; set x := transversal_repr x0 X B. by exists x; rewrite ?transversal_reprK ?repr_mem_transversal. Qed. Lemma card_transversal : #|X| = #|P|. Proof. by rewrite -pblock_transversal card_in_imset //; apply: pblock_inj. Qed. Lemma im_transversal_repr x0 : transversal_repr x0 X @: P = X. Proof. rewrite -{2}[X]imset_id -pblock_transversal -imset_comp. by apply: eq_in_imset; apply: pblockK. Qed. End Transversals. End Partitions. Arguments trivIsetP {T P}. Arguments big_trivIset_cond [T R idx op] P [K E]. Arguments set_partition_big_cond [T R idx op] P [D K E]. Arguments big_trivIset [T R idx op] P [E]. Arguments set_partition_big [T R idx op] P [D E]. Prenex Implicits cover trivIset partition pblock. Lemma partition_partition (T : finType) (D : {set T}) P Q : partition P D -> partition Q P -> partition (cover @: Q) D /\ {in Q &, injective cover}. Proof. move=> /and3P[/eqP defG tiP notP0] /and3P[/eqP defP tiQ notQ0]. have sQP E: E \in Q -> {subset E <= P}. by move=> Q_E; apply/subsetP; rewrite -defP (bigcup_max E). rewrite /partition cover_imset -(big_trivIset _ tiQ) defP -defG eqxx /= andbC. have{} notQ0: set0 \notin cover @: Q. apply: contra notP0 => /imsetP[E Q_E E0]. have /set0Pn[/= A E_A] := memPn notQ0 E Q_E. congr (_ \in P): (sQP E Q_E A E_A). by apply/eqP; rewrite -subset0 E0 (bigcup_max A). rewrite notQ0; apply: trivIimset => // E F Q_E Q_F. apply: contraR => /pred0Pn[x /andP[/bigcupP[A E_A Ax] /bigcupP[B F_B Bx]]]. rewrite -(def_pblock tiQ Q_E E_A) -(def_pblock tiP _ Ax) ?(sQP E) //. by rewrite -(def_pblock tiQ Q_F F_B) -(def_pblock tiP _ Bx) ?(sQP F). Qed. Lemma indexed_partition (I T : finType) (J : {pred I}) (B : I -> {set T}) : let P := [set B i | i in J] in {in J &, forall i j : I, j != i -> [disjoint B i & B j]} -> (forall i : I, J i -> B i != set0) -> partition P (cover P) /\ {in J &, injective B}. Proof. move=> P disjB inhB; have s0NP : set0 \notin P. by apply/negP => /imsetP[x xI /eqP]; apply/negP; rewrite eq_sym inhB. by rewrite /partition eqxx s0NP andbT /=; apply: trivIimset. Qed. Section PartitionImage. Variables (T : finType) (P : {set {set T}}) (D : {set T}). Variables (T' : finType) (f : T -> T') (inj_f : injective f). Let fP := [set f @: (B : {set T}) | B in P]. Lemma imset_trivIset : trivIset fP = trivIset P. Proof. apply/trivIsetP/trivIsetP => [trivP A B AP BP|]. - rewrite -(imset_disjoint inj_f) -(inj_eq (imset_inj inj_f)). by apply: trivP; rewrite imset_f. - move=> trivP ? ? /imsetP[A AP ->] /imsetP[B BP ->]. by rewrite (inj_eq (imset_inj inj_f)) imset_disjoint //; apply: trivP. Qed. Lemma imset0mem : (set0 \in fP) = (set0 \in P). Proof. apply/imsetP/idP => [[A AP /esym/eqP]|P0]; last by exists set0; rewrite ?imset0. by rewrite imset_eq0 => /eqP<-. Qed. Lemma imset_partition : partition fP (f @: D) = partition P D. Proof. suff cov: (cover fP == f @:D) = (cover P == D). by rewrite /partition -imset_trivIset imset0mem cov. by rewrite /fP cover_imset -imset_cover (inj_eq (imset_inj inj_f)). Qed. End PartitionImage. (**********************************************************************) (* *) (* Maximum and minimum (sub)set with respect to a given pred *) (* *) (**********************************************************************) Section MaxSetMinSet. Variable T : finType. Notation sT := {set T}. Implicit Types A B C : sT. Implicit Type P : pred sT. Definition minset P A := [forall (B : sT | B \subset A), (B == A) == P B]. Lemma minset_eq P1 P2 A : P1 =1 P2 -> minset P1 A = minset P2 A. Proof. by move=> eP12; apply: eq_forallb => B; rewrite eP12. Qed. Lemma minsetP P A : reflect ((P A) /\ (forall B, P B -> B \subset A -> B = A)) (minset P A). Proof. apply: (iffP forallP) => [minA | [PA minA] B]. split; first by have:= minA A; rewrite subxx eqxx /= => /eqP. by move=> B PB sBA; have:= minA B; rewrite PB sBA /= eqb_id => /eqP. by apply/implyP=> sBA; apply/eqP; apply/eqP/idP=> [-> // | /minA]; apply. Qed. Arguments minsetP {P A}. Lemma minsetp P A : minset P A -> P A. Proof. by case/minsetP. Qed. Lemma minsetinf P A B : minset P A -> P B -> B \subset A -> B = A. Proof. by case/minsetP=> _; apply. Qed. Lemma ex_minset P : (exists A, P A) -> {A | minset P A}. Proof. move=> exP; pose pS n := [pred B | P B & #|B| == n]. pose p n := ~~ pred0b (pS n); have{exP}: exists n, p n. by case: exP => A PA; exists #|A|; apply/existsP; exists A; rewrite /= PA /=. case/ex_minnP=> n /pred0P; case: (pickP (pS n)) => // A /andP[PA] /eqP <-{n} _. move=> minA; exists A => //; apply/minsetP; split=> // B PB sBA; apply/eqP. by rewrite eqEcard sBA minA //; apply/pred0Pn; exists B; rewrite /= PB /=. Qed. Lemma minset_exists P C : P C -> {A | minset P A & A \subset C}. Proof. move=> PC; have{PC}: exists A, P A && (A \subset C) by exists C; rewrite PC /=. case/ex_minset=> A /minsetP[/andP[PA sAC] minA]; exists A => //; apply/minsetP. by split=> // B PB sBA; rewrite (minA B) // PB (subset_trans sBA). Qed. (* The 'locked_with' allows Coq to find the value of P by unification. *) Fact maxset_key : unit. Proof. by []. Qed. Definition maxset P A := minset (fun B => locked_with maxset_key P (~: B)) (~: A). Lemma maxset_eq P1 P2 A : P1 =1 P2 -> maxset P1 A = maxset P2 A. Proof. by move=> eP12; apply: minset_eq => x /=; rewrite !unlock_with eP12. Qed. Lemma maxminset P A : maxset P A = minset [pred B | P (~: B)] (~: A). Proof. by rewrite /maxset unlock. Qed. Lemma minmaxset P A : minset P A = maxset [pred B | P (~: B)] (~: A). Proof. by rewrite /maxset unlock setCK; apply: minset_eq => B /=; rewrite setCK. Qed. Lemma maxsetP P A : reflect ((P A) /\ (forall B, P B -> A \subset B -> B = A)) (maxset P A). Proof. apply: (iffP minsetP); rewrite ?setCK unlock_with => [] [PA minA]. by split=> // B PB sAB; rewrite -[B]setCK [~: B]minA (setCK, setCS). by split=> // B PB' sBA'; rewrite -(minA _ PB') -1?setCS setCK. Qed. Lemma maxsetp P A : maxset P A -> P A. Proof. by case/maxsetP. Qed. Lemma maxsetsup P A B : maxset P A -> P B -> A \subset B -> B = A. Proof. by case/maxsetP=> _; apply. Qed. Lemma ex_maxset P : (exists A, P A) -> {A | maxset P A}. Proof. move=> exP; have{exP}: exists A, P (~: A). by case: exP => A PA; exists (~: A); rewrite setCK. by case/ex_minset=> A minA; exists (~: A); rewrite /maxset unlock setCK. Qed. Lemma maxset_exists P C : P C -> {A : sT | maxset P A & C \subset A}. Proof. move=> PC; pose P' B := P (~: B); have: P' (~: C) by rewrite /P' setCK. case/minset_exists=> B; rewrite -[B]setCK setCS. by exists (~: B); rewrite // /maxset unlock. Qed. End MaxSetMinSet. Arguments setCK {T}. Arguments minsetP {T P A}. Arguments maxsetP {T P A}. Prenex Implicits minset maxset. Section SetFixpoint. Section Least. Variables (T : finType) (F : {set T} -> {set T}). Hypothesis (F_mono : {homo F : X Y / X \subset Y}). Let n := #|T|. Let iterF i := iter i F set0. Lemma subset_iterS i : iterF i \subset iterF i.+1. Proof. by elim: i => [| i IHi]; rewrite /= ?sub0set ?F_mono. Qed. Lemma subset_iter : {homo iterF : i j / i <= j >-> i \subset j}. Proof. by apply: homo_leq => //[? ? ?|]; [apply: subset_trans|apply: subset_iterS]. Qed. Definition fixset := iterF n. Lemma fixsetK : F fixset = fixset. Proof. suff /'exists_eqP[x /= e]: [exists k : 'I_n.+1, iterF k == iterF k.+1]. by rewrite /fixset -(subnK (leq_ord x)) /iterF iterD iter_fix. apply: contraT => /existsPn /(_ (Ordinal _)) /= neq_iter. suff iter_big k : k <= n.+1 -> k <= #|iter k F set0|. by have := iter_big _ (leqnn _); rewrite ltnNge max_card. elim: k => [|k IHk] k_lt //=; apply: (leq_ltn_trans (IHk (ltnW k_lt))). by rewrite proper_card// properEneq// subset_iterS neq_iter. Qed. Hint Resolve fixsetK : core. Lemma minset_fix : minset [pred X | F X == X] fixset. Proof. apply/minsetP; rewrite inE fixsetK eqxx; split=> // X /eqP FXeqX Xsubfix. apply/eqP; rewrite eqEsubset Xsubfix/=. suff: fixset \subset iter n F X by rewrite iter_fix. by rewrite /fixset; elim: n => //= [|m IHm]; rewrite ?sub0set ?F_mono. Qed. Lemma fixsetKn k : iter k F fixset = fixset. Proof. by rewrite iter_fix. Qed. Lemma iter_sub_fix k : iterF k \subset fixset. Proof. have [/subset_iter //|/ltnW/subnK<-] := leqP k n; by rewrite /iterF iterD fixsetKn. Qed. Lemma fix_order_proof x : x \in fixset -> exists n, x \in iterF n. Proof. by move=> x_fix; exists n. Qed. Definition fix_order (x : T) := if (x \in fixset) =P true isn't ReflectT x_fix then 0 else (ex_minn (fix_order_proof x_fix)). Lemma fix_order_le_max (x : T) : fix_order x <= n. Proof. rewrite /fix_order; case: eqP => //= x_in. by case: ex_minnP => //= ? ?; apply. Qed. Lemma in_iter_fix_orderE (x : T) : (x \in iterF (fix_order x)) = (x \in fixset). Proof. rewrite /fix_order; case: eqP => [x_in | /negP/negPf-> /[1!inE]//]. by case: ex_minnP => m ->; rewrite x_in. Qed. Lemma fix_order_gt0 (x : T) : (fix_order x > 0) = (x \in fixset). Proof. rewrite /fix_order; case: eqP => [x_in | /negP/negPf->//]. by rewrite x_in; case: ex_minnP => -[/[!inE] | m]. Qed. Lemma fix_order_eq0 (x : T) : (fix_order x == 0) = (x \notin fixset). Proof. by rewrite -fix_order_gt0 -ltnNge ltnS leqn0. Qed. Lemma in_iter_fixE (x : T) k : (x \in iterF k) = (0 < fix_order x <= k). Proof. rewrite /fix_order; case: eqP => //= [x_in|/negP xNin]; last first. by apply: contraNF xNin; apply/subsetP/iter_sub_fix. case: ex_minnP => -[/[!inE]//|m] xm mP. by apply/idP/idP=> [/mP//|lt_mk]; apply: subsetP xm; apply: subset_iter. Qed. Lemma in_iter (x : T) k : x \in fixset -> fix_order x <= k -> x \in iterF k. Proof. by move=> x_in xk; rewrite in_iter_fixE fix_order_gt0 x_in xk. Qed. Lemma notin_iter (x : T) k : k < fix_order x -> x \notin iterF k. Proof. by move=> k_le; rewrite in_iter_fixE negb_and orbC -ltnNge k_le. Qed. Lemma fix_order_small x k : x \in iterF k -> fix_order x <= k. Proof. by rewrite in_iter_fixE => /andP[]. Qed. Lemma fix_order_big x k : x \in fixset -> x \notin iterF k -> fix_order x > k. Proof. by move=> x_in; rewrite in_iter_fixE fix_order_gt0 x_in /= -ltnNge. Qed. Lemma le_fix_order (x y : T) : y \in iterF (fix_order x) -> fix_order y <= fix_order x. Proof. exact: fix_order_small. Qed. End Least. Section Greatest. Variables (T : finType) (F : {set T} -> {set T}). Hypothesis (F_mono : {homo F : X Y / X \subset Y}). Definition funsetC X := ~: (F (~: X)). Lemma funsetC_mono : {homo funsetC : X Y / X \subset Y}. Proof. by move=> *; rewrite subCset setCK F_mono// subCset setCK. Qed. Hint Resolve funsetC_mono : core. Definition cofixset := ~: fixset funsetC. Lemma cofixsetK : F cofixset = cofixset. Proof. by rewrite /cofixset -[in RHS]fixsetK ?setCK. Qed. Lemma maxset_cofix : maxset [pred X | F X == X] cofixset. Proof. rewrite maxminset setCK. rewrite (@minset_eq _ _ [pred X | funsetC X == X]) ?minset_fix//. by move=> X /=; rewrite (can2_eq setCK setCK). Qed. End Greatest. End SetFixpoint. Section FProd. Variables (I : finType) (T_ : I -> finType). Lemma card_fprod : #|fprod T_| = \prod_(i : I) #|T_ i|. Proof. rewrite card_sub (card_family (tagged_with T_)) foldrE big_image/=. apply: eq_bigr => i _/=; rewrite -card_sig; apply/esym. exact: bij_eq_card (tag_with_bij T_ i). Qed. Definition fprod_pick : 0 < #|fprod T_| -> forall i : I, T_ i. Proof. by rewrite card_fprod => /[swap] i /gt0_prodn/(_ i isT) /card_gt0P/sigW[]. Qed. Definition ftagged (T_gt0 : 0 < #|fprod T_|) (f : {ffun I -> {i : I & T_ i}}) (i : I) := @untag I T_ (T_ i) (fprod_pick T_gt0 i) i id (f i). Lemma ftaggedE t T_gt0 i : ftagged T_gt0 (fprod_fun t) i = t i. Proof. by rewrite /ftagged untagE ?tag_fprod_fun// => e; rewrite etaggedE. Qed. End FProd. Section BigTag. Variables (R : Type) (idx : R) (op : Monoid.com_law idx). Variables (I : finType) (T_ : I -> finType). Lemma big_tag_cond (Q_ : forall i, {pred T_ i}) (P_ : forall i : I, T_ i -> R) (i : I) : \big[op/idx]_(j in Q_ i) P_ i j = \big[op/idx]_(j in tagged_with T_ i | untag true (Q_ i) j) untag idx (P_ i) j. Proof. rewrite (big_sub_cond (tagged_with T_ i)). rewrite (reindex (tag_with i)); last exact/onW_bij/tag_with_bij. by apply: eq_big => [x|x Qix]; rewrite ?untagE. Qed. Lemma big_tag (P_ : forall i : I, T_ i -> R) (i : I) : \big[op/idx]_(j : T_ i) P_ i j = \big[op/idx]_(j in tagged_with T_ i) untag idx (P_ i) j. Proof. by rewrite big_tag_cond; under eq_bigl do rewrite untag_cst ?andbT. Qed. End BigTag. Arguments big_tag_cond [R idx op I T_] _ _ _. Arguments big_tag [R idx op I T_] _ _. Section BigFProd. Variables (R : Type) (zero one : R) (times : R -> R -> R). Variables (plus : Monoid.add_law zero times). Variables (I : finType) (T_ : I -> finType). Variables (P_ : forall i : I, {ffun T_ i -> R}). Let T := fprod T_. Lemma big_fprod_dep (Q : {pred {ffun I -> {i : I & (T_ i)}}}) : \big[plus/zero]_(t : T | Q (fprod_fun t)) \big[times/one]_(i : I) P_ i (t i) = \big[plus/zero]_(g in family (tagged_with T_) | Q g) \big[times/one]_(i : I) (untag zero (P_ i) (g i)). Proof. rewrite (reindex (@of_family_tagged_with _ T_)); last first. exact/onW_bij/of_family_tagged_with_bij. rewrite [in RHS]big_sub_cond; apply/esym/eq_bigr => -[/= f fP] Qf. apply: eq_bigr => i _; rewrite /fun_of_fprod/=. by case: (f i) ('forall_eqP _ _) => //= j t; case: _ /; rewrite untagE. Qed. Lemma big_fprod : \big[plus/zero]_(t : T) \big[times/one]_(i in I) P_ i (t i) = \big[plus/zero]_(g in family (tagged_with T_)) \big[times/one]_(i : I) (untag zero (P_ i) (g i)). Proof. by rewrite (big_fprod_dep predT) big_mkcondr. Qed. End BigFProd.
Basic.lean
/- Copyright (c) 2025 David Kurniadi Angdinata. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: David Kurniadi Angdinata -/ import Mathlib.Algebra.MvPolynomial.PDeriv import Mathlib.AlgebraicGeometry.EllipticCurve.Affine.Basic import Mathlib.Data.Fin.Tuple.Reflection import Mathlib.Tactic.Ring.NamePolyVars /-! # Weierstrass equations and the nonsingular condition in Jacobian coordinates A point on the projective plane over a commutative ring `R` with weights `(2, 3, 1)` is an equivalence class `[x : y : z]` of triples `(x, y, z) ≠ (0, 0, 0)` of elements in `R` such that `(x, y, z) ∼ (x', y', z')` if there is some unit `u` in `Rˣ` with `(x, y, z) = (u²x', u³y', uz')`. Let `W` be a Weierstrass curve over a commutative ring `R` with coefficients `aᵢ`. A *Jacobian point* is a point on the projective plane over `R` with weights `(2, 3, 1)` satisfying the *`(2, 3, 1)`-homogeneous Weierstrass equation* `W(X, Y, Z) = 0` in *Jacobian coordinates*, where `W(X, Y, Z) := Y² + a₁XYZ + a₃YZ³ - (X³ + a₂X²Z² + a₄XZ⁴ + a₆Z⁶)`. It is *nonsingular* if its partial derivatives `W_X(x, y, z)`, `W_Y(x, y, z)`, and `W_Z(x, y, z)` do not vanish simultaneously. This file gives an explicit implementation of equivalence classes of triples up to scaling by weights, and defines polynomials associated to Weierstrass equations and the nonsingular condition in Jacobian coordinates. The group law on the actual type of nonsingular Jacobian points will be defined in `Mathlib/AlgebraicGeometry/EllipticCurve/Jacobian/Point.lean`, based on the formulae for group operations in `Mathlib/AlgebraicGeometry/EllipticCurve/Jacobian/Formula.lean`. ## Main definitions * `WeierstrassCurve.Jacobian.PointClass`: the equivalence class of a point representative. * `WeierstrassCurve.Jacobian.Nonsingular`: the nonsingular condition on a point representative. * `WeierstrassCurve.Jacobian.NonsingularLift`: the nonsingular condition on a point class. ## Main statements * `WeierstrassCurve.Jacobian.polynomial_relation`: Euler's homogeneous function theorem. ## Implementation notes All definitions and lemmas for Weierstrass curves in Jacobian coordinates live in the namespace `WeierstrassCurve.Jacobian` to distinguish them from those in other coordinates. This is simply an abbreviation for `WeierstrassCurve` that can be converted using `WeierstrassCurve.toJacobian`. This can be converted into `WeierstrassCurve.Affine` using `WeierstrassCurve.Jacobian.toAffine`. A point representative is implemented as a term `P` of type `Fin 3 → R`, which allows for the vector notation `![x, y, z]`. However, `P` is not syntactically equivalent to the expanded vector `![P x, P y, P z]`, so the lemmas `fin3_def` and `fin3_def_ext` can be used to convert between the two forms. The equivalence of two point representatives `P` and `Q` is implemented as an equivalence of orbits of the action of `Rˣ`, or equivalently that there is some unit `u` of `R` such that `P = u • Q`. However, `u • Q` is not syntactically equal to `![u² * Q x, u³ * Q y, u * Q z]`, so the lemmas `smul_fin3` and `smul_fin3_ext` can be used to convert between the two forms. Files in `Mathlib/AlgebraicGeometry/EllipticCurve/Jacobian` make extensive use of `erw` to get around this. While `erw` is often an indication of a problem, in this case it is self-contained and should not cause any issues. It would alternatively be possible to add some automation to assist here. Whenever possible, all changes to documentation and naming of definitions and theorems should be mirrored in `Mathlib/AlgebraicGeometry/EllipticCurve/Projective/Basic.lean`. ## References [J Silverman, *The Arithmetic of Elliptic Curves*][silverman2009] ## Tags elliptic curve, Jacobian, Weierstrass equation, nonsingular -/ local notation3 "x" => (0 : Fin 3) local notation3 "y" => (1 : Fin 3) local notation3 "z" => (2 : Fin 3) open MvPolynomial local macro "eval_simp" : tactic => `(tactic| simp only [eval_C, eval_X, eval_add, eval_sub, eval_mul, eval_pow]) local macro "map_simp" : tactic => `(tactic| simp only [map_ofNat, map_C, map_X, map_neg, map_add, map_sub, map_mul, map_pow, map_div₀, WeierstrassCurve.map, Function.comp_apply]) local macro "matrix_simp" : tactic => `(tactic| simp only [Matrix.head_cons, Matrix.tail_cons, Matrix.smul_empty, Matrix.smul_cons, Matrix.cons_val_zero, Matrix.cons_val_one, Matrix.cons_val_two]) local macro "pderiv_simp" : tactic => `(tactic| simp only [map_ofNat, map_neg, map_add, map_sub, map_mul, pderiv_mul, pderiv_pow, pderiv_C, pderiv_X_self, pderiv_X_of_ne one_ne_zero, pderiv_X_of_ne one_ne_zero.symm, pderiv_X_of_ne (by decide : z ≠ x), pderiv_X_of_ne (by decide : x ≠ z), pderiv_X_of_ne (by decide : z ≠ y), pderiv_X_of_ne (by decide : y ≠ z)]) universe r s u v variable {R : Type r} {S : Type s} {A F : Type u} {B K : Type v} name_poly_vars X, Y, Z over R namespace WeierstrassCurve /-! ## Jacobian coordinates -/ variable (R) in /-- An abbreviation for a Weierstrass curve in Jacobian coordinates. -/ abbrev Jacobian : Type r := WeierstrassCurve R /-- The conversion from a Weierstrass curve to Jacobian coordinates. -/ abbrev toJacobian (W : WeierstrassCurve R) : Jacobian R := W namespace Jacobian /-- The conversion from a Weierstrass curve in Jacobian coordinates to affine coordinates. -/ abbrev toAffine (W' : Jacobian R) : Affine R := W' lemma fin3_def (P : Fin 3 → R) : ![P x, P y, P z] = P := by ext n; fin_cases n <;> rfl lemma fin3_def_ext (a b c : R) : ![a, b, c] x = a ∧ ![a, b, c] y = b ∧ ![a, b, c] z = c := ⟨rfl, rfl, rfl⟩ lemma comp_fin3 (f : R → S) (a b c : R) : f ∘ ![a, b, c] = ![f a, f b, f c] := (FinVec.map_eq ..).symm variable [CommRing R] [CommRing S] [CommRing A] [CommRing B] [Field F] [Field K] {W' : Jacobian R} {W : Jacobian F} /-- The scalar multiplication for a Jacobian point representative on a Weierstrass curve. -/ scoped instance : SMul R <| Fin 3 → R := ⟨fun u P => ![u ^ 2 * P x, u ^ 3 * P y, u * P z]⟩ lemma smul_fin3 (P : Fin 3 → R) (u : R) : u • P = ![u ^ 2 * P x, u ^ 3 * P y, u * P z] := rfl lemma smul_fin3_ext (P : Fin 3 → R) (u : R) : (u • P) x = u ^ 2 * P x ∧ (u • P) y = u ^ 3 * P y ∧ (u • P) z = u * P z := ⟨rfl, rfl, rfl⟩ lemma comp_smul (f : R →+* S) (P : Fin 3 → R) (u : R) : f ∘ (u • P) = f u • f ∘ P := by ext n; fin_cases n <;> simp only [smul_fin3, comp_fin3] <;> map_simp /-- The multiplicative action for a Jacobian point representative on a Weierstrass curve. -/ scoped instance : MulAction R <| Fin 3 → R where one_smul _ := by simp only [smul_fin3, one_pow, one_mul, fin3_def] mul_smul _ _ _ := by simp only [smul_fin3, mul_pow, mul_assoc, fin3_def_ext] /-- The equivalence setoid for a Jacobian point representative on a Weierstrass curve. -/ @[reducible] scoped instance : Setoid <| Fin 3 → R := MulAction.orbitRel Rˣ <| Fin 3 → R variable (R) in /-- The equivalence class of a Jacobian point representative on a Weierstrass curve. -/ abbrev PointClass : Type r := MulAction.orbitRel.Quotient Rˣ <| Fin 3 → R lemma smul_equiv (P : Fin 3 → R) {u : R} (hu : IsUnit u) : u • P ≈ P := ⟨hu.unit, rfl⟩ @[simp] lemma smul_eq (P : Fin 3 → R) {u : R} (hu : IsUnit u) : (⟦u • P⟧ : PointClass R) = ⟦P⟧ := Quotient.eq.mpr <| smul_equiv P hu lemma smul_equiv_smul (P Q : Fin 3 → R) {u v : R} (hu : IsUnit u) (hv : IsUnit v) : u • P ≈ v • Q ↔ P ≈ Q := by rw [← Quotient.eq_iff_equiv, ← Quotient.eq_iff_equiv, smul_eq P hu, smul_eq Q hv] lemma equiv_iff_eq_of_Z_eq' {P Q : Fin 3 → R} (hz : P z = Q z) (hQz : Q z ∈ nonZeroDivisors R) : P ≈ Q ↔ P = Q := by refine ⟨?_, Quotient.exact.comp <| congrArg _⟩ rintro ⟨u, rfl⟩ simp only [Units.smul_def, (mul_cancel_right_mem_nonZeroDivisors hQz).mp <| one_mul (Q z) ▸ hz] rw [one_smul] lemma equiv_iff_eq_of_Z_eq [NoZeroDivisors R] {P Q : Fin 3 → R} (hz : P z = Q z) (hQz : Q z ≠ 0) : P ≈ Q ↔ P = Q := equiv_iff_eq_of_Z_eq' hz <| mem_nonZeroDivisors_of_ne_zero hQz lemma Z_eq_zero_of_equiv {P Q : Fin 3 → R} (h : P ≈ Q) : P z = 0 ↔ Q z = 0 := by rcases h with ⟨_, rfl⟩ simp only [Units.smul_def, smul_fin3_ext, Units.mul_right_eq_zero] lemma X_eq_of_equiv {P Q : Fin 3 → R} (h : P ≈ Q) : P x * Q z ^ 2 = Q x * P z ^ 2 := by rcases h with ⟨u, rfl⟩ simp only [Units.smul_def, smul_fin3_ext] ring1 lemma Y_eq_of_equiv {P Q : Fin 3 → R} (h : P ≈ Q) : P y * Q z ^ 3 = Q y * P z ^ 3 := by rcases h with ⟨u, rfl⟩ simp only [Units.smul_def, smul_fin3_ext] ring1 lemma not_equiv_of_Z_eq_zero_left {P Q : Fin 3 → R} (hPz : P z = 0) (hQz : Q z ≠ 0) : ¬P ≈ Q := fun h => hQz <| (Z_eq_zero_of_equiv h).mp hPz lemma not_equiv_of_Z_eq_zero_right {P Q : Fin 3 → R} (hPz : P z ≠ 0) (hQz : Q z = 0) : ¬P ≈ Q := fun h => hPz <| (Z_eq_zero_of_equiv h).mpr hQz lemma not_equiv_of_X_ne {P Q : Fin 3 → R} (hx : P x * Q z ^ 2 ≠ Q x * P z ^ 2) : ¬P ≈ Q := hx.comp X_eq_of_equiv lemma not_equiv_of_Y_ne {P Q : Fin 3 → R} (hy : P y * Q z ^ 3 ≠ Q y * P z ^ 3) : ¬P ≈ Q := hy.comp Y_eq_of_equiv lemma equiv_of_X_eq_of_Y_eq {P Q : Fin 3 → F} (hPz : P z ≠ 0) (hQz : Q z ≠ 0) (hx : P x * Q z ^ 2 = Q x * P z ^ 2) (hy : P y * Q z ^ 3 = Q y * P z ^ 3) : P ≈ Q := by use Units.mk0 _ hPz / Units.mk0 _ hQz simp only [Units.smul_def, smul_fin3, Units.val_div_eq_div_val, Units.val_mk0, div_pow, mul_comm, mul_div, ← hx, ← hy, mul_div_cancel_right₀ _ <| pow_ne_zero _ hQz, mul_div_cancel_right₀ _ hQz, fin3_def] lemma equiv_some_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) : P ≈ ![P x / P z ^ 2, P y / P z ^ 3, 1] := equiv_of_X_eq_of_Y_eq hPz one_ne_zero (by linear_combination (norm := (matrix_simp; ring1)) -P x * div_self (pow_ne_zero 2 hPz)) (by linear_combination (norm := (matrix_simp; ring1)) -P y * div_self (pow_ne_zero 3 hPz)) lemma X_eq_iff {P Q : Fin 3 → F} (hPz : P z ≠ 0) (hQz : Q z ≠ 0) : P x * Q z ^ 2 = Q x * P z ^ 2 ↔ P x / P z ^ 2 = Q x / Q z ^ 2 := (div_eq_div_iff (pow_ne_zero 2 hPz) (pow_ne_zero 2 hQz)).symm lemma Y_eq_iff {P Q : Fin 3 → F} (hPz : P z ≠ 0) (hQz : Q z ≠ 0) : P y * Q z ^ 3 = Q y * P z ^ 3 ↔ P y / P z ^ 3 = Q y / Q z ^ 3 := (div_eq_div_iff (pow_ne_zero 3 hPz) (pow_ne_zero 3 hQz)).symm /-! ## Weierstrass equations in Jacobian coordinates -/ variable (W') in /-- The polynomial `W(X, Y, Z) := Y² + a₁XYZ + a₃YZ³ - (X³ + a₂X²Z² + a₄XZ⁴ + a₆Z⁶)` associated to a Weierstrass curve `W` over a ring `R` in Jacobian coordinates. This is represented as a term of type `MvPolynomial (Fin 3) R`, where `X`, `Y`, and `Z` represent `X`, `Y`, and `Z` respectively. -/ noncomputable def polynomial : MvPolynomial (Fin 3) R := Y ^ 2 + C W'.a₁ * X * Y * Z + C W'.a₃ * Y * Z ^ 3 - (X ^ 3 + C W'.a₂ * X ^ 2 * Z ^ 2 + C W'.a₄ * X * Z ^ 4 + C W'.a₆ * Z ^ 6) lemma eval_polynomial (P : Fin 3 → R) : eval P W'.polynomial = P y ^ 2 + W'.a₁ * P x * P y * P z + W'.a₃ * P y * P z ^ 3 - (P x ^ 3 + W'.a₂ * P x ^ 2 * P z ^ 2 + W'.a₄ * P x * P z ^ 4 + W'.a₆ * P z ^ 6) := by rw [polynomial] simp lemma eval_polynomial_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) : eval P W.polynomial / P z ^ 6 = W.toAffine.polynomial.evalEval (P x / P z ^ 2) (P y / P z ^ 3) := by linear_combination (norm := (rw [eval_polynomial, Affine.evalEval_polynomial]; ring1)) W.a₁ * P x * P y / P z ^ 5 * div_self hPz + W.a₃ * P y / P z ^ 3 * div_self (pow_ne_zero 3 hPz) - W.a₂ * P x ^ 2 / P z ^ 4 * div_self (pow_ne_zero 2 hPz) - W.a₄ * P x / P z ^ 2 * div_self (pow_ne_zero 4 hPz) - W.a₆ * div_self (pow_ne_zero 6 hPz) variable (W') in /-- The proposition that a Jacobian point representative `(x, y, z)` lies in a Weierstrass curve `W`. In other words, it satisfies the `(2, 3, 1)`-homogeneous Weierstrass equation `W(X, Y, Z) = 0`. -/ def Equation (P : Fin 3 → R) : Prop := eval P W'.polynomial = 0 lemma equation_iff (P : Fin 3 → R) : W'.Equation P ↔ P y ^ 2 + W'.a₁ * P x * P y * P z + W'.a₃ * P y * P z ^ 3 - (P x ^ 3 + W'.a₂ * P x ^ 2 * P z ^ 2 + W'.a₄ * P x * P z ^ 4 + W'.a₆ * P z ^ 6) = 0 := by rw [Equation, eval_polynomial] lemma equation_smul (P : Fin 3 → R) {u : R} (hu : IsUnit u) : W'.Equation (u • P) ↔ W'.Equation P := have hP (u : R) {P : Fin 3 → R} (hP : W'.Equation P) : W'.Equation <| u • P := by rw [equation_iff] at hP ⊢ linear_combination (norm := (simp only [smul_fin3_ext]; ring1)) u ^ 6 * hP ⟨fun h => by convert hP ↑hu.unit⁻¹ h; rw [smul_smul, hu.val_inv_mul, one_smul], hP u⟩ lemma equation_of_equiv {P Q : Fin 3 → R} (h : P ≈ Q) : W'.Equation P ↔ W'.Equation Q := by rcases h with ⟨u, rfl⟩ exact equation_smul Q u.isUnit lemma equation_of_Z_eq_zero {P : Fin 3 → R} (hPz : P z = 0) : W'.Equation P ↔ P y ^ 2 = P x ^ 3 := by simp only [equation_iff, hPz, add_zero, mul_zero, zero_pow <| OfNat.ofNat_ne_zero _, sub_eq_zero] lemma equation_zero : W'.Equation ![1, 1, 0] := by simp only [equation_of_Z_eq_zero, fin3_def_ext, one_pow] lemma equation_some (a b : R) : W'.Equation ![a, b, 1] ↔ W'.toAffine.Equation a b := by simp only [equation_iff, Affine.equation_iff', fin3_def_ext, one_pow, mul_one] lemma equation_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) : W.Equation P ↔ W.toAffine.Equation (P x / P z ^ 2) (P y / P z ^ 3) := (equation_of_equiv <| equiv_some_of_Z_ne_zero hPz).trans <| equation_some .. /-! ## The nonsingular condition in Jacobian coordinates -/ variable (W') in /-- The partial derivative `W_X(X, Y, Z)` with respect to `X` of the polynomial `W(X, Y, Z)` associated to a Weierstrass curve `W` in Jacobian coordinates. -/ noncomputable def polynomialX : MvPolynomial (Fin 3) R := pderiv x W'.polynomial lemma polynomialX_eq : W'.polynomialX = C W'.a₁ * Y * Z - (C 3 * X ^ 2 + C (2 * W'.a₂) * X * Z ^ 2 + C W'.a₄ * Z ^ 4) := by rw [polynomialX, polynomial] pderiv_simp ring1 lemma eval_polynomialX (P : Fin 3 → R) : eval P W'.polynomialX = W'.a₁ * P y * P z - (3 * P x ^ 2 + 2 * W'.a₂ * P x * P z ^ 2 + W'.a₄ * P z ^ 4) := by rw [polynomialX_eq] simp lemma eval_polynomialX_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) : eval P W.polynomialX / P z ^ 4 = W.toAffine.polynomialX.evalEval (P x / P z ^ 2) (P y / P z ^ 3) := by linear_combination (norm := (rw [eval_polynomialX, Affine.evalEval_polynomialX]; ring1)) W.a₁ * P y / P z ^ 3 * div_self hPz - 2 * W.a₂ * P x / P z ^ 2 * div_self (pow_ne_zero 2 hPz) - W.a₄ * div_self (pow_ne_zero 4 hPz) variable (W') in /-- The partial derivative `W_Y(X, Y, Z)` with respect to `Y` of the polynomial `W(X, Y, Z)` associated to a Weierstrass curve `W` in Jacobian coordinates. -/ noncomputable def polynomialY : MvPolynomial (Fin 3) R := pderiv y W'.polynomial lemma polynomialY_eq : W'.polynomialY = C 2 * Y + C W'.a₁ * X * Z + C W'.a₃ * Z ^ 3 := by rw [polynomialY, polynomial] pderiv_simp ring1 lemma eval_polynomialY (P : Fin 3 → R) : eval P W'.polynomialY = 2 * P y + W'.a₁ * P x * P z + W'.a₃ * P z ^ 3 := by rw [polynomialY_eq] simp lemma eval_polynomialY_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) : eval P W.polynomialY / P z ^ 3 = W.toAffine.polynomialY.evalEval (P x / P z ^ 2) (P y / P z ^ 3) := by linear_combination (norm := (rw [eval_polynomialY, Affine.evalEval_polynomialY]; ring1)) W.a₁ * P x / P z ^ 2 * div_self hPz + W.a₃ * div_self (pow_ne_zero 3 hPz) variable (W') in /-- The partial derivative `W_Z(X, Y, Z)` with respect to `Z` of the polynomial `W(X, Y, Z)` associated to a Weierstrass curve `W` in Jacobian coordinates. -/ noncomputable def polynomialZ : MvPolynomial (Fin 3) R := pderiv z W'.polynomial lemma polynomialZ_eq : W'.polynomialZ = C W'.a₁ * X * Y + C (3 * W'.a₃) * Y * Z ^ 2 - (C (2 * W'.a₂) * X ^ 2 * Z + C (4 * W'.a₄) * X * Z ^ 3 + C (6 * W'.a₆) * Z ^ 5) := by rw [polynomialZ, polynomial] pderiv_simp ring1 lemma eval_polynomialZ (P : Fin 3 → R) : eval P W'.polynomialZ = W'.a₁ * P x * P y + 3 * W'.a₃ * P y * P z ^ 2 - (2 * W'.a₂ * P x ^ 2 * P z + 4 * W'.a₄ * P x * P z ^ 3 + 6 * W'.a₆ * P z ^ 5) := by rw [polynomialZ_eq] simp /-- Euler's homogeneous function theorem in Jacobian coordinates. -/ theorem polynomial_relation (P : Fin 3 → R) : 6 * eval P W'.polynomial = 2 * P x * eval P W'.polynomialX + 3 * P y * eval P W'.polynomialY + P z * eval P W'.polynomialZ := by rw [eval_polynomial, eval_polynomialX, eval_polynomialY, eval_polynomialZ] ring1 variable (W') in /-- The proposition that a Jacobian point representative `(x, y, z)` on a Weierstrass curve `W` is nonsingular. In other words, either `W_X(x, y, z) ≠ 0`, `W_Y(x, y, z) ≠ 0`, or `W_Z(x, y, z) ≠ 0`. Note that this definition is only mathematically accurate for fields. -/ -- TODO: generalise this definition to be mathematically accurate for a larger class of rings. def Nonsingular (P : Fin 3 → R) : Prop := W'.Equation P ∧ (eval P W'.polynomialX ≠ 0 ∨ eval P W'.polynomialY ≠ 0 ∨ eval P W'.polynomialZ ≠ 0) lemma nonsingular_iff (P : Fin 3 → R) : W'.Nonsingular P ↔ W'.Equation P ∧ (W'.a₁ * P y * P z - (3 * P x ^ 2 + 2 * W'.a₂ * P x * P z ^ 2 + W'.a₄ * P z ^ 4) ≠ 0 ∨ 2 * P y + W'.a₁ * P x * P z + W'.a₃ * P z ^ 3 ≠ 0 ∨ W'.a₁ * P x * P y + 3 * W'.a₃ * P y * P z ^ 2 - (2 * W'.a₂ * P x ^ 2 * P z + 4 * W'.a₄ * P x * P z ^ 3 + 6 * W'.a₆ * P z ^ 5) ≠ 0) := by rw [Nonsingular, eval_polynomialX, eval_polynomialY, eval_polynomialZ] lemma nonsingular_smul (P : Fin 3 → R) {u : R} (hu : IsUnit u) : W'.Nonsingular (u • P) ↔ W'.Nonsingular P := have hP {u : R} (hu : IsUnit u) {P : Fin 3 → R} (hP : W'.Nonsingular <| u • P) : W'.Nonsingular P := by rcases (nonsingular_iff _).mp hP with ⟨hP, hP'⟩ refine (nonsingular_iff P).mpr ⟨(equation_smul P hu).mp hP, ?_⟩ contrapose! hP' simp only [smul_fin3_ext] exact ⟨by linear_combination (norm := ring1) u ^ 4 * hP'.left, by linear_combination (norm := ring1) u ^ 3 * hP'.right.left, by linear_combination (norm := ring1) u ^ 5 * hP'.right.right⟩ ⟨hP hu, fun h => hP hu.unit⁻¹.isUnit <| by rwa [smul_smul, hu.val_inv_mul, one_smul]⟩ lemma nonsingular_of_equiv {P Q : Fin 3 → R} (h : P ≈ Q) : W'.Nonsingular P ↔ W'.Nonsingular Q := by rcases h with ⟨u, rfl⟩ exact nonsingular_smul Q u.isUnit lemma nonsingular_of_Z_eq_zero {P : Fin 3 → R} (hPz : P z = 0) : W'.Nonsingular P ↔ W'.Equation P ∧ (3 * P x ^ 2 ≠ 0 ∨ 2 * P y ≠ 0 ∨ W'.a₁ * P x * P y ≠ 0) := by simp only [nonsingular_iff, hPz, add_zero, sub_zero, zero_sub, mul_zero, zero_pow <| OfNat.ofNat_ne_zero _, neg_ne_zero] lemma nonsingular_zero [Nontrivial R] : W'.Nonsingular ![1, 1, 0] := by simp only [nonsingular_of_Z_eq_zero, equation_zero, true_and, fin3_def_ext, ← not_and_or] exact fun h => one_ne_zero <| by linear_combination (norm := ring1) h.1 - h.2.1 lemma nonsingular_some (a b : R) : W'.Nonsingular ![a, b, 1] ↔ W'.toAffine.Nonsingular a b := by simp_rw [nonsingular_iff, equation_some, fin3_def_ext, Affine.nonsingular_iff', Affine.equation_iff', and_congr_right_iff, ← not_and_or, not_iff_not, one_pow, mul_one, and_congr_right_iff, Iff.comm, iff_self_and] intro h ha hb linear_combination (norm := ring1) 6 * h - 2 * a * ha - 3 * b * hb lemma nonsingular_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) : W.Nonsingular P ↔ W.toAffine.Nonsingular (P x / P z ^ 2) (P y / P z ^ 3) := (nonsingular_of_equiv <| equiv_some_of_Z_ne_zero hPz).trans <| nonsingular_some .. lemma nonsingular_iff_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) : W.Nonsingular P ↔ W.Equation P ∧ (eval P W.polynomialX ≠ 0 ∨ eval P W.polynomialY ≠ 0) := by rw [nonsingular_of_Z_ne_zero hPz, Affine.Nonsingular, ← equation_of_Z_ne_zero hPz, ← eval_polynomialX_of_Z_ne_zero hPz, div_ne_zero_iff, and_iff_left <| pow_ne_zero 4 hPz, ← eval_polynomialY_of_Z_ne_zero hPz, div_ne_zero_iff, and_iff_left <| pow_ne_zero 3 hPz] lemma X_ne_zero_of_Z_eq_zero [NoZeroDivisors R] {P : Fin 3 → R} (hP : W'.Nonsingular P) (hPz : P z = 0) : P x ≠ 0 := by intro hPx simp only [nonsingular_of_Z_eq_zero hPz, equation_of_Z_eq_zero hPz, hPx, mul_zero, zero_mul, zero_pow <| OfNat.ofNat_ne_zero _, ne_self_iff_false, or_false, false_or] at hP rwa [pow_eq_zero_iff two_ne_zero, hP.left, eq_self, true_and, mul_zero, ne_self_iff_false] at hP lemma isUnit_X_of_Z_eq_zero {P : Fin 3 → F} (hP : W.Nonsingular P) (hPz : P z = 0) : IsUnit (P x) := (X_ne_zero_of_Z_eq_zero hP hPz).isUnit lemma Y_ne_zero_of_Z_eq_zero [NoZeroDivisors R] {P : Fin 3 → R} (hP : W'.Nonsingular P) (hPz : P z = 0) : P y ≠ 0 := by have hPx : P x ≠ 0 := X_ne_zero_of_Z_eq_zero hP hPz intro hPy rw [nonsingular_of_Z_eq_zero hPz, equation_of_Z_eq_zero hPz, hPy, zero_pow two_ne_zero] at hP exact hPx <| pow_eq_zero hP.left.symm lemma isUnit_Y_of_Z_eq_zero {P : Fin 3 → F} (hP : W.Nonsingular P) (hPz : P z = 0) : IsUnit (P y) := (Y_ne_zero_of_Z_eq_zero hP hPz).isUnit lemma equiv_of_Z_eq_zero {P Q : Fin 3 → F} (hP : W.Nonsingular P) (hQ : W.Nonsingular Q) (hPz : P z = 0) (hQz : Q z = 0) : P ≈ Q := by have hPx : IsUnit <| P x := isUnit_X_of_Z_eq_zero hP hPz have hPy : IsUnit <| P y := isUnit_Y_of_Z_eq_zero hP hPz have hQx : IsUnit <| Q x := isUnit_X_of_Z_eq_zero hQ hQz have hQy : IsUnit <| Q y := isUnit_Y_of_Z_eq_zero hQ hQz simp only [nonsingular_of_Z_eq_zero, equation_of_Z_eq_zero, hPz, hQz] at hP hQ use (hPy.unit / hPx.unit) * (hQx.unit / hQy.unit) simp only [Units.smul_def, smul_fin3, Units.val_mul, Units.val_div_eq_div_val, IsUnit.unit_spec, mul_pow, div_pow, hQz, mul_zero] conv_rhs => rw [← fin3_def P, hPz] congr! 2 · rw [hP.left, pow_succ, (hPx.pow 2).mul_div_cancel_left, hQ.left, pow_succ _ 2, (hQx.pow 2).div_mul_cancel_left, hQx.inv_mul_cancel_right] · rw [← hP.left, pow_succ, (hPy.pow 2).mul_div_cancel_left, ← hQ.left, pow_succ _ 2, (hQy.pow 2).div_mul_cancel_left, hQy.inv_mul_cancel_right] lemma equiv_zero_of_Z_eq_zero {P : Fin 3 → F} (hP : W.Nonsingular P) (hPz : P z = 0) : P ≈ ![1, 1, 0] := equiv_of_Z_eq_zero hP nonsingular_zero hPz rfl lemma comp_equiv_comp (f : F →+* K) {P Q : Fin 3 → F} (hP : W.Nonsingular P) (hQ : W.Nonsingular Q) : f ∘ P ≈ f ∘ Q ↔ P ≈ Q := by refine ⟨fun h => ?_, fun h => ?_⟩ · by_cases hz : f (P z) = 0 · exact equiv_of_Z_eq_zero hP hQ ((map_eq_zero_iff f f.injective).mp hz) <| (map_eq_zero_iff f f.injective).mp <| (Z_eq_zero_of_equiv h).mp hz · refine equiv_of_X_eq_of_Y_eq ((map_ne_zero_iff f f.injective).mp hz) ((map_ne_zero_iff f f.injective).mp <| hz.comp (Z_eq_zero_of_equiv h).mpr) ?_ ?_ all_goals apply f.injective; map_simp exacts [X_eq_of_equiv h, Y_eq_of_equiv h] · rcases h with ⟨u, rfl⟩ exact ⟨Units.map f u, (comp_smul ..).symm⟩ variable (W') in /-- The proposition that a Jacobian point class on a Weierstrass curve `W` is nonsingular. If `P` is a Jacobian point representative on `W`, then `W.NonsingularLift ⟦P⟧` is definitionally equivalent to `W.Nonsingular P`. Note that this definition is only mathematically accurate for fields. -/ def NonsingularLift (P : PointClass R) : Prop := P.lift W'.Nonsingular fun _ _ => propext ∘ nonsingular_of_equiv lemma nonsingularLift_iff (P : Fin 3 → R) : W'.NonsingularLift ⟦P⟧ ↔ W'.Nonsingular P := Iff.rfl lemma nonsingularLift_zero [Nontrivial R] : W'.NonsingularLift ⟦![1, 1, 0]⟧ := nonsingular_zero lemma nonsingularLift_some (a b : R) : W'.NonsingularLift ⟦![a, b, 1]⟧ ↔ W'.toAffine.Nonsingular a b := nonsingular_some a b /-! ## Maps and base changes -/ variable (f : R →+* S) (P : Fin 3 → R) @[simp] lemma map_polynomial : (W'.map f).toJacobian.polynomial = MvPolynomial.map f W'.polynomial := by simp only [polynomial] map_simp variable {P} in lemma Equation.map (h : W'.Equation P) : (W'.map f).toJacobian.Equation (f ∘ P) := by rw [Equation, map_polynomial, eval_map, ← eval₂_comp, h, map_zero] variable {f} in @[simp] lemma map_equation (hf : Function.Injective f) : (W'.map f).toJacobian.Equation (f ∘ P) ↔ W'.Equation P := by simp only [Equation, map_polynomial, eval_map, ← eval₂_comp, map_eq_zero_iff f hf] @[simp] lemma map_polynomialX : (W'.map f).toJacobian.polynomialX = MvPolynomial.map f W'.polynomialX := by simp only [polynomialX, map_polynomial, pderiv_map] @[simp] lemma map_polynomialY : (W'.map f).toJacobian.polynomialY = MvPolynomial.map f W'.polynomialY := by simp only [polynomialY, map_polynomial, pderiv_map] @[simp] lemma map_polynomialZ : (W'.map f).toJacobian.polynomialZ = MvPolynomial.map f W'.polynomialZ := by simp only [polynomialZ, map_polynomial, pderiv_map] variable {f} in @[simp] lemma map_nonsingular (hf : Function.Injective f) : (W'.map f).toJacobian.Nonsingular (f ∘ P) ↔ W'.Nonsingular P := by simp only [Nonsingular, map_equation P hf, map_polynomialX, map_polynomialY, map_polynomialZ, eval_map, ← eval₂_comp, map_ne_zero_iff f hf] variable [Algebra R S] [Algebra R A] [Algebra S A] [IsScalarTower R S A] [Algebra R B] [Algebra S B] [IsScalarTower R S B] (f : A →ₐ[S] B) (P : Fin 3 → A) lemma baseChange_polynomial : (W'.baseChange B).toJacobian.polynomial = MvPolynomial.map f (W'.baseChange A).toJacobian.polynomial := by rw [← map_polynomial, map_baseChange] variable {P} in lemma Equation.baseChange (h : (W'.baseChange A).toJacobian.Equation P) : (W'.baseChange B).toJacobian.Equation (f ∘ P) := by convert Equation.map f.toRingHom h using 1 rw [AlgHom.toRingHom_eq_coe, map_baseChange] variable {f} in lemma baseChange_equation (hf : Function.Injective f) : (W'.baseChange B).toJacobian.Equation (f ∘ P) ↔ (W'.baseChange A).toJacobian.Equation P := by rw [← RingHom.coe_coe, ← map_equation P hf, AlgHom.toRingHom_eq_coe, map_baseChange] lemma baseChange_polynomialX : (W'.baseChange B).toJacobian.polynomialX = MvPolynomial.map f (W'.baseChange A).toJacobian.polynomialX := by rw [← map_polynomialX, map_baseChange] lemma baseChange_polynomialY : (W'.baseChange B).toJacobian.polynomialY = MvPolynomial.map f (W'.baseChange A).toJacobian.polynomialY := by rw [← map_polynomialY, map_baseChange] lemma baseChange_polynomialZ : (W'.baseChange B).toJacobian.polynomialZ = MvPolynomial.map f (W'.baseChange A).toJacobian.polynomialZ := by rw [← map_polynomialZ, map_baseChange] variable {f} in lemma baseChange_nonsingular (hf : Function.Injective f) : (W'.baseChange B).toJacobian.Nonsingular (f ∘ P) ↔ (W'.baseChange A).toJacobian.Nonsingular P := by rw [← RingHom.coe_coe, ← map_nonsingular P hf, AlgHom.toRingHom_eq_coe, map_baseChange] end Jacobian end WeierstrassCurve
alt.v
(* (c) Copyright 2006-2016 Microsoft Corporation and Inria. *) (* Distributed under the terms of CeCILL-B. *) From HB Require Import structures. From mathcomp Require Import ssreflect ssrbool ssrfun eqtype ssrnat seq choice. From mathcomp Require Import div fintype tuple tuple bigop prime finset ssralg. From mathcomp Require Import zmodp fingroup morphism perm automorphism quotient. From mathcomp Require Import action cyclic pgroup gseries sylow. From mathcomp Require Import primitive_action nilpotent maximal. (******************************************************************************) (* Definitions of the symmetric and alternate groups, and some properties. *) (* 'Sym_T == The symmetric group over type T (which must have a finType *) (* structure). *) (* := [set: {perm T}] *) (* 'Alt_T == The alternating group over type T. *) (******************************************************************************) Unset Printing Implicit Defensive. Set Implicit Arguments. Unset Strict Implicit. Import GroupScope GRing. HB.instance Definition _ := isMulGroup.Build bool addbA addFb addbb. Section SymAltDef. Variable T : finType. Implicit Types (s : {perm T}) (x y z : T). (** Definitions of the alternate groups and some Properties **) Definition Sym : {set {perm T}} := setT. Canonical Sym_group := Eval hnf in [group of Sym]. Local Notation "'Sym_T" := Sym. Canonical sign_morph := @Morphism _ _ 'Sym_T _ (in2W (@odd_permM _)). Definition Alt := 'ker (@odd_perm T). Canonical Alt_group := Eval hnf in [group of Alt]. Local Notation "'Alt_T" := Alt. Lemma Alt_even p : (p \in 'Alt_T) = ~~ p. Proof. by rewrite !inE /=; case: odd_perm. Qed. Lemma Alt_subset : 'Alt_T \subset 'Sym_T. Proof. exact: subsetT. Qed. Lemma Alt_normal : 'Alt_T <| 'Sym_T. Proof. exact: ker_normal. Qed. Lemma Alt_norm : 'Sym_T \subset 'N('Alt_T). Proof. by case/andP: Alt_normal. Qed. Let n := #|T|. Lemma Alt_index : 1 < n -> #|'Sym_T : 'Alt_T| = 2. Proof. move=> lt1n; rewrite -card_quotient ?Alt_norm //=. have : ('Sym_T / 'Alt_T) \isog (@odd_perm T @* 'Sym_T) by apply: first_isog. case/isogP=> g /injmP/card_in_imset <-. rewrite /morphim setIid=> ->; rewrite -card_bool; apply: eq_card => b. apply/imsetP; case: b => /=; last first. by exists (1 : {perm T}); [rewrite setIid inE | rewrite odd_perm1]. case: (pickP T) lt1n => [x1 _ | d0]; last by rewrite /n eq_card0. rewrite /n (cardD1 x1) ltnS lt0n => /existsP[x2 /=]. by rewrite eq_sym andbT -odd_tperm; exists (tperm x1 x2); rewrite ?inE. Qed. Lemma card_Sym : #|'Sym_T| = n`!. Proof. rewrite -[n]cardsE -card_perm; apply: eq_card => p. by apply/idP/subsetP=> [? ?|]; rewrite !inE. Qed. Lemma card_Alt : 1 < n -> (2 * #|'Alt_T|)%N = n`!. Proof. by move/Alt_index <-; rewrite mulnC (Lagrange Alt_subset) card_Sym. Qed. Lemma Sym_trans : [transitive^n 'Sym_T, on setT | 'P]. Proof. apply/imsetP; pose t1 := [tuple of enum T]. have dt1: t1 \in n.-dtuple(setT) by rewrite inE enum_uniq; apply/subsetP. exists t1 => //; apply/setP=> t; apply/idP/imsetP=> [|[a _ ->{t}]]; last first. by apply: n_act_dtuple => //; apply/astabsP=> x; rewrite !inE. case/dtuple_onP=> injt _; have injf := inj_comp injt enum_rank_inj. exists (perm injf); first by rewrite inE. apply: eq_from_tnth => i; rewrite tnth_map /= [aperm _ _]permE; congr tnth. by rewrite (tnth_nth (enum_default i)) enum_valK. Qed. Lemma Alt_trans : [transitive^n.-2 'Alt_T, on setT | 'P]. Proof. case n_m2: n Sym_trans => [|[|m]] /= tr_m2; try exact: ntransitive0. have tr_m := ntransitive_weak (leqW (leqnSn m)) tr_m2. case/imsetP: tr_m2; case/tupleP=> x; case/tupleP=> y t. rewrite !dtuple_on_add 2![x \in _]inE inE negb_or /= -!andbA. case/and4P=> nxy ntx nty dt _; apply/imsetP; exists t => //; apply/setP=> u. apply/idP/imsetP=> [|[a _ ->{u}]]; last first. by apply: n_act_dtuple => //; apply/astabsP=> z; rewrite !inE. case/(atransP2 tr_m dt)=> /= a _ ->{u}. case odd_a: (odd_perm a); last by exists a => //; rewrite !inE /= odd_a. exists (tperm x y * a); first by rewrite !inE /= odd_permM odd_tperm nxy odd_a. apply/val_inj/eq_in_map => z tz; rewrite actM /= /aperm; congr (a _). by case: tpermP ntx nty => // <-; rewrite tz. Qed. Lemma aperm_faithful (A : {group {perm T}}) : [faithful A, on setT | 'P]. Proof. by apply/faithfulP=> /= p _ np1; apply/eqP/perm_act1P=> y; rewrite np1 ?inE. Qed. End SymAltDef. Arguments Sym T%_type. Arguments Sym_group T%_type. Arguments Alt T%_type. Arguments Alt_group T%_type. Notation "''Sym_' T" := (Sym T) (at level 8, T at level 2, format "''Sym_' T") : group_scope. Notation "''Sym_' T" := (Sym_group T) : Group_scope. Notation "''Alt_' T" := (Alt T) (at level 8, T at level 2, format "''Alt_' T") : group_scope. Notation "''Alt_' T" := (Alt_group T) : Group_scope. Lemma trivial_Alt_2 (T : finType) : #|T| <= 2 -> 'Alt_T = 1. Proof. rewrite leq_eqVlt => /predU1P[] oT. by apply: card_le1_trivg; rewrite -leq_double -mul2n card_Alt oT. suffices Sym1: 'Sym_T = 1 by apply/trivgP; rewrite -Sym1 subsetT. by apply: card1_trivg; rewrite card_Sym; case: #|T| oT; do 2?case. Qed. Lemma simple_Alt_3 (T : finType) : #|T| = 3 -> simple 'Alt_T. Proof. move=> T3; have{T3} oA: #|'Alt_T| = 3. by apply: double_inj; rewrite -mul2n card_Alt T3. apply/simpleP; split=> [|K]; [by rewrite trivg_card1 oA | case/andP=> sKH _]. have:= cardSg sKH; rewrite oA dvdn_divisors // !inE orbC /= -oA. case/pred2P=> eqK; [right | left]; apply/eqP. by rewrite eqEcard sKH eqK leqnn. by rewrite eq_sym eqEcard sub1G eqK cards1. Qed. Lemma not_simple_Alt_4 (T : finType) : #|T| = 4 -> ~~ simple 'Alt_T. Proof. move=> oT; set A := 'Alt_T. have oA: #|A| = 12 by apply: double_inj; rewrite -mul2n card_Alt oT. suffices [p]: exists p, [/\ prime p, 1 < #|A|`_p < #|A| & #|'Syl_p(A)| == 1%N]. case=> p_pr pA_int; rewrite /A; case/normal_sylowP=> P; case/pHallP. rewrite /= -/A => sPA pP nPA; apply/simpleP=> [] [_]; rewrite -pP in pA_int. by case/(_ P)=> // defP; rewrite defP oA ?cards1 in pA_int. have: #|'Syl_3(A)| \in filter [pred d | d %% 3 == 1%N] (divisors 12). by rewrite mem_filter -dvdn_divisors //= -oA card_Syl_dvd ?card_Syl_mod. rewrite /= oA mem_seq2 orbC. case/predU1P=> [oQ3|]; [exists 2 | exists 3]; split; rewrite ?p_part //. pose A3 := [set x : {perm T} | #[x] == 3]; suffices oA3: #|A :&: A3| = 8. have sQ2 P: P \in 'Syl_2(A) -> P :=: A :\: A3. rewrite inE pHallE oA p_part -natTrecE /= => /andP[sPA /eqP oP]. apply/eqP; rewrite eqEcard -(leq_add2l 8) -{1}oA3 cardsID oA oP. rewrite andbT subsetD sPA; apply/exists_inP=> -[x] /= Px. by rewrite inE => /eqP ox; have:= order_dvdG Px; rewrite oP ox. have [/= P sylP] := Sylow_exists 2 [group of A]. rewrite -(([set P] =P 'Syl_2(A)) _) ?cards1 // eqEsubset sub1set inE sylP. by apply/subsetP=> Q sylQ; rewrite inE -val_eqE /= !sQ2 // inE. rewrite -[8]/(4 * 2)%N -{}oQ3 -sum1_card -sum_nat_const. rewrite (partition_big (fun x => <[x]>%G) [in 'Syl_3(A)]) => [|x]; last first. by case/setIP=> Ax; rewrite /= !inE pHallE p_part cycle_subG Ax oA. apply: eq_bigr => Q; rewrite inE pHallE oA p_part -?natTrecE //=. case/andP=> sQA /eqP oQ; have:= oQ. rewrite (cardsD1 1) group1 -sum1_card => [[/= <-]]; apply: eq_bigl => x. rewrite setIC -val_eqE /= 2!inE in_setD1 -andbA -{4}[x]expg1 -order_dvdn dvdn1. apply/and3P/andP=> [[/eqP-> _ /eqP <-] | [ntx Qx]]; first by rewrite cycle_id. have:= order_dvdG Qx; rewrite oQ dvdn_divisors // mem_seq2 (negPf ntx) /=. by rewrite eqEcard cycle_subG Qx (subsetP sQA) // oQ /order => /eqP->. Qed. Lemma simple_Alt5_base (T : finType) : #|T| = 5 -> simple 'Alt_T. Proof. move=> oT. have F1: #|'Alt_T| = 60 by apply: double_inj; rewrite -mul2n card_Alt oT. have FF (H : {group {perm T}}): H <| 'Alt_T -> H :<>: 1 -> 20 %| #|H|. - move=> Hh1 Hh3. have [x _]: exists x, x \in T by apply/existsP/eqP; rewrite oT. have F2 := Alt_trans T; rewrite oT /= in F2. have F3: [transitive 'Alt_T, on setT | 'P] by apply: ntransitive1 F2. have F4: [primitive 'Alt_T, on setT | 'P] by apply: ntransitive_primitive F2. case: (prim_trans_norm F4 Hh1) => F5. by case: Hh3; apply/trivgP; apply: subset_trans F5 (aperm_faithful _). have F6: 5 %| #|H| by rewrite -oT -cardsT (atrans_dvd F5). have F7: 4 %| #|H|. have F7: #|[set~ x]| = 4 by rewrite cardsC1 oT. case: (pickP [in [set~ x]]) => [y Hy | ?]; last by rewrite eq_card0 in F7. pose K := 'C_H[x | 'P]%G. have F8 : K \subset H by apply: subsetIl. pose Gx := 'C_('Alt_T)[x | 'P]%G. have F9: [transitive^2 Gx, on [set~ x] | 'P]. by rewrite -[[set~ x]]setTI -setDE stab_ntransitive ?inE. have F10: [transitive Gx, on [set~ x] | 'P]. exact: ntransitive1 F9. have F11: [primitive Gx, on [set~ x] | 'P]. exact: ntransitive_primitive F9. have F12: K \subset Gx by apply: setSI; apply: normal_sub. have F13: K <| Gx by rewrite /(K <| _) F12 normsIG // normal_norm. case: (prim_trans_norm F11 F13) => Ksub; last first. by apply: dvdn_trans (cardSg F8); rewrite -F7; apply: atrans_dvd Ksub. have F14: [faithful Gx, on [set~ x] | 'P]. apply/subsetP=> g; do 2![case/setIP] => Altg cgx cgx'. apply: (subsetP (aperm_faithful 'Alt_T)). rewrite inE Altg /=; apply/astabP=> z _. case: (z =P x) => [->|]; first exact: (astab1P cgx). by move/eqP=> nxz; rewrite (astabP cgx') ?inE //. have Hreg g (z : T): g \in H -> g z = z -> g = 1. have F15 h: h \in H -> h x = x -> h = 1. move=> Hh Hhx; have: h \in K by rewrite inE Hh; apply/astab1P. by rewrite (trivGP (subset_trans Ksub F14)) => /set1P. move=> Hg Hgz; have:= in_setT x; rewrite -(atransP F3 z) ?inE //. case/imsetP=> g1 Hg1 Hg2; apply: (conjg_inj g1); rewrite conj1g. apply: F15; last by rewrite Hg2 -permM mulKVg permM Hgz. by case/normalP: Hh1 => _ nH1; rewrite -(nH1 _ Hg1) memJ_conjg. clear K F8 F12 F13 Ksub F14. case: (Cauchy _ F6) => // h Hh /eqP Horder. have diff_hnx_x n: 0 < n -> n < 5 -> x != (h ^+ n) x. move=> Hn1 Hn2; rewrite eq_sym; apply/negP => HH. have: #[h ^+ n] = 5. rewrite orderXgcd // (eqP Horder). by move: Hn1 Hn2 {HH}; do 5 (case: n => [|n] //). have Hhd2: h ^+ n \in H by rewrite groupX. by rewrite (Hreg _ _ Hhd2 (eqP HH)) order1. pose S1 := [tuple x; h x; (h ^+ 3) x]. have DnS1: S1 \in 3.-dtuple(setT). rewrite inE memtE subset_all /= !inE /= !negb_or -!andbA /= andbT. rewrite -{1}[h]expg1 !diff_hnx_x // expgSr permM. by rewrite (inj_eq perm_inj) diff_hnx_x. pose S2 := [tuple x; h x; (h ^+ 2) x]. have DnS2: S2 \in 3.-dtuple(setT). rewrite inE memtE subset_all /= !inE /= !negb_or -!andbA /= andbT. rewrite -{1}[h]expg1 !diff_hnx_x // expgSr permM. by rewrite (inj_eq perm_inj) diff_hnx_x. case: (atransP2 F2 DnS1 DnS2) => g Hg [/=]. rewrite /aperm => Hgx Hghx Hgh3x. have h_g_com: h * g = g * h. suff HH: (g * h * g^-1) * h^-1 = 1 by rewrite -[h * g]mul1g -HH !gnorm. apply: (Hreg _ x); last first. by rewrite !permM -Hgx Hghx -!permM mulKVg mulgV perm1. rewrite groupM // ?groupV // (conjgCV g) mulgK -mem_conjg. by case/normalP: Hh1 => _ ->. have: (g * (h ^+ 2) * g ^-1) x = (h ^+ 3) x. rewrite !permM -Hgx. have ->: h (h x) = (h ^+ 2) x by rewrite /= permM. by rewrite {1}Hgh3x -!permM /= mulgV mulg1 -expgSr. rewrite commuteX // mulgK {1}[expgn]lock expgS permM -lock. by move/perm_inj=> eqxhx; case/eqP: (diff_hnx_x 1%N isT isT); rewrite expg1. by rewrite (@Gauss_dvd 4 5) // F7. apply/simpleP; split => [|H Hnorm]; first by rewrite trivg_card1 F1. case Hcard1: (#|H| == 1%N); move/eqP: Hcard1 => Hcard1. by left; apply: card1_trivg; rewrite Hcard1. right; case Hcard60: (#|H| == 60); move/eqP: Hcard60 => Hcard60. by apply/eqP; rewrite eqEcard Hcard60 F1 andbT; case/andP: Hnorm. have {Hcard1 Hcard60} Hcard20: #|H| = 20. have Hdiv: 20 %| #|H| by apply: FF => // HH; case Hcard1; rewrite HH cards1. case H20: (#|H| == 20); first exact/eqP. case: Hcard60; case/andP: Hnorm; move/cardSg; rewrite F1 => Hdiv1 _. by case/dvdnP: Hdiv H20 Hdiv1 => n ->; move: n; do 4!case=> //. have prime_5: prime 5 by []. have nSyl5: #|'Syl_5(H)| = 1%N. move: (card_Syl_dvd 5 H) (card_Syl_mod H prime_5). rewrite Hcard20; case: (card _) => // n Hdiv. move: (dvdn_leq (isT: (0 < 20)%N) Hdiv). by move: (n) Hdiv; do 20 (case=> //). case: (Sylow_exists 5 H) => S; case/pHallP=> sSH oS. have{} oS: #|S| = 5 by rewrite oS p_part Hcard20. suff: 20 %| #|S| by rewrite oS. apply: FF => [|S1]; last by rewrite S1 cards1 in oS. apply: char_normal_trans Hnorm; apply: lone_subgroup_char => // Q sQH isoQS. rewrite subEproper; apply/norP=> [[nQS _]]; move: nSyl5. rewrite (cardsD1 S) (cardsD1 Q) 4!{1}inE nQS !pHallE sQH sSH Hcard20 p_part. by rewrite (card_isog isoQS) oS. Qed. Section Restrict. Variables (T : finType) (x : T). Notation T' := {y | y != x}. Lemma rfd_funP (p : {perm T}) (u : T') : let p1 := if p x == x then p else 1 in p1 (val u) != x. Proof. case: (p x =P x) => /= [pxx | _]; last by rewrite perm1 (valP u). by rewrite -[x in _ != x]pxx (inj_eq perm_inj); apply: (valP u). Qed. Definition rfd_fun p := [fun u => Sub ((_ : {perm T}) _) (rfd_funP p u) : T']. Lemma rfdP p : injective (rfd_fun p). Proof. apply: can_inj (rfd_fun p^-1) _ => u; apply: val_inj => /=. rewrite -(can_eq (permK p)) permKV eq_sym. by case: eqP => _; rewrite !(perm1, permK). Qed. Definition rfd p := perm (@rfdP p). Hypothesis card_T : 2 < #|T|. Lemma rfd_morph : {in 'C_('Sym_T)[x | 'P] &, {morph rfd : y z / y * z}}. Proof. move=> p q; rewrite !setIA !setIid; move/astab1P=> p_x; move/astab1P=> q_x. apply/permP=> u; apply: val_inj. by rewrite permE /= !permM !permE /= [p x]p_x [q x]q_x eqxx permM /=. Qed. Canonical rfd_morphism := Morphism rfd_morph. Definition rgd_fun (p : {perm T'}) := [fun x1 => if insub x1 is Some u then sval (p u) else x]. Lemma rgdP p : injective (rgd_fun p). Proof. apply: can_inj (rgd_fun p^-1) _ => y /=. case: (insubP _ y) => [u _ val_u|]; first by rewrite valK permK. by rewrite negbK; move/eqP->; rewrite insubF //= eqxx. Qed. Definition rgd p := perm (@rgdP p). Lemma rfd_odd (p : {perm T}) : p x = x -> rfd p = p :> bool. Proof. have rfd1: rfd 1 = 1. by apply/permP => u; apply: val_inj; rewrite permE /= if_same !perm1. have [n] := ubnP #|[set x | p x != x]|; elim: n p => // n IHn p le_p_n px_x. have [p_id | [x1 Hx1]] := set_0Vmem [set x | p x != x]. suffices ->: p = 1 by rewrite rfd1 !odd_perm1. by apply/permP => z; apply: contraFeq (in_set0 z); rewrite perm1 -p_id inE. have nx1x: x1 != x by apply: contraTneq Hx1 => ->; rewrite inE px_x eqxx. have npxx1: p x != x1 by apply: contraNneq nx1x => <-; rewrite px_x. have npx1x: p x1 != x by rewrite -px_x (inj_eq perm_inj). pose p1 := p * tperm x1 (p x1). have fix_p1 y: p y = y -> p1 y = y. by move=> pyy; rewrite permM; have [<-|/perm_inj<-|] := tpermP; rewrite ?pyy. have p1x_x: p1 x = x by apply: fix_p1. have{le_p_n} lt_p1_n: #|[set x | p1 x != x]| < n. move: le_p_n; rewrite ltnS (cardsD1 x1) Hx1; apply/leq_trans/subset_leq_card. rewrite subsetD1 inE permM tpermR eqxx andbT. by apply/subsetP=> y /[!inE]; apply: contraNneq=> /fix_p1->. transitivity (p1 (+) true); last first. by rewrite odd_permM odd_tperm -Hx1 inE eq_sym addbK. have ->: p = p1 * tperm x1 (p x1) by rewrite -tpermV mulgK. rewrite morphM; last 2 first; first by rewrite 2!inE; apply/astab1P. by rewrite 2!inE; apply/astab1P; rewrite -[RHS]p1x_x permM px_x. rewrite odd_permM IHn //=; congr (_ (+) _). pose x2 : T' := Sub x1 nx1x; pose px2 : T' := Sub (p x1) npx1x. suffices ->: rfd (tperm x1 (p x1)) = tperm x2 px2. by rewrite odd_tperm eq_sym; rewrite inE in Hx1. apply/permP => z; apply/val_eqP; rewrite permE /= tpermD // eqxx. by rewrite !permE /= -!val_eqE /= !(fun_if sval) /=. Qed. Lemma rfd_iso : 'C_('Alt_T)[x | 'P] \isog 'Alt_T'. Proof. have rgd_x p: rgd p x = x by rewrite permE /= insubF //= eqxx. have rfd_rgd p: rfd (rgd p) = p. apply/permP => [[z Hz]]; apply/val_eqP; rewrite !permE. by rewrite /= [rgd _ _]permE /= insubF eqxx // permE /= insubT. have sSd: 'C_('Alt_T)[x | 'P] \subset 'dom rfd. by apply/subsetP=> p /[!inE]/= /andP[]. apply/isogP; exists [morphism of restrm sSd rfd] => /=; last first. rewrite morphim_restrm setIid; apply/setP=> z; apply/morphimP/idP=> [[p _]|]. case/setIP; rewrite Alt_even => Hp; move/astab1P=> Hp1 ->. by rewrite Alt_even rfd_odd. have dz': rgd z x == x by rewrite rgd_x. move=> kz; exists (rgd z); last by rewrite /= rfd_rgd. by rewrite 2!inE (sameP astab1P eqP). rewrite 4!inE /= (sameP astab1P eqP) dz' -rfd_odd; last exact/eqP. by rewrite rfd_rgd mker // ?set11. apply/injmP=> x1 y1 /=. case/setIP=> Hax1; move/astab1P; rewrite /= /aperm => Hx1. case/setIP=> Hay1; move/astab1P; rewrite /= /aperm => Hy1 Hr. apply/permP => z. case (z =P x) => [->|]; [by rewrite Hx1 | move/eqP => nzx]. move: (congr1 (fun q : {perm T'} => q (Sub z nzx)) Hr). by rewrite !permE => [[]]; rewrite Hx1 Hy1 !eqxx. Qed. End Restrict. Lemma simple_Alt5 (T : finType) : #|T| >= 5 -> simple 'Alt_T. Proof. suff F1 n: #|T| = n + 5 -> simple 'Alt_T by move/subnK/esym/F1. elim: n T => [| n Hrec T Hde]; first exact: simple_Alt5_base. have oT: 5 < #|T| by rewrite Hde addnC. apply/simpleP; split=> [|H Hnorm]; last have [Hh1 nH] := andP Hnorm. rewrite trivg_card1 -[#|_|]half_double -mul2n card_Alt Hde addnC //. by rewrite addSn factS mulnC -(prednK (fact_gt0 _)). case E1: (pred0b T); first by rewrite /pred0b in E1; rewrite (eqP E1) in oT. case/pred0Pn: E1 => x _; have Hx := in_setT x. have F2: [transitive^4 'Alt_T, on setT | 'P]. by apply: ntransitive_weak (Alt_trans T); rewrite -(subnKC oT). have F3 := ntransitive1 (isT: 0 < 4) F2. have F4 := ntransitive_primitive (isT: 1 < 4) F2. case Hcard1: (#|H| == 1%N); move/eqP: Hcard1 => Hcard1. by left; apply: card1_trivg; rewrite Hcard1. right; case: (prim_trans_norm F4 Hnorm) => F5. by rewrite (trivGP (subset_trans F5 (aperm_faithful _))) cards1 in Hcard1. case E1: (pred0b (predD1 T x)). rewrite /pred0b in E1; move: oT. by rewrite (cardD1 x) (eqP E1); case: (T x). case/pred0Pn: E1 => y Hdy; case/andP: (Hdy) => diff_x_y Hy. pose K := 'C_H[x | 'P]%G. have F8: K \subset H by apply: subsetIl. pose Gx := 'C_('Alt_T)[x | 'P]. have F9: [transitive^3 Gx, on [set~ x] | 'P]. by rewrite -[[set~ x]]setTI -setDE stab_ntransitive ?inE. have F10: [transitive Gx, on [set~ x] | 'P]. by apply: ntransitive1 F9. have F11: [primitive Gx, on [set~ x] | 'P]. by apply: ntransitive_primitive F9. have F12: K \subset Gx by rewrite setSI // normal_sub. have F13: K <| Gx by apply/andP; rewrite normsIG. have:= prim_trans_norm F11; case/(_ K) => //= => Ksub; last first. have F14: Gx * H = 'Alt_T by apply/(subgroup_transitiveP _ _ F3). have: simple Gx. by rewrite (isog_simple (rfd_iso x)) Hrec //= card_sig cardC1 Hde. case/simpleP=> _ simGx; case/simGx: F13 => /= HH2. case Ez: (pred0b (predD1 (predD1 T x) y)). move: oT; rewrite /pred0b in Ez. by rewrite (cardD1 x) (cardD1 y) (eqP Ez) inE /= inE /= diff_x_y. case/pred0Pn: Ez => z; case/andP => diff_y_z Hdz. have [diff_x_z Hz] := andP Hdz. have: z \in [set~ x] by rewrite !inE. rewrite -(atransP Ksub y) ?inE //; case/imsetP => g. rewrite /= HH2 inE; move/eqP=> -> HH4. by case/negP: diff_y_z; rewrite HH4 act1. by rewrite /= -F14 -[Gx]HH2 (mulSGid F8). have F14: [faithful Gx, on [set~ x] | 'P]. apply: subset_trans (aperm_faithful 'Sym_T); rewrite subsetI subsetT. apply/subsetP=> g; do 2![case/setIP]=> _ cgx cgx'; apply/astabP=> z _ /=. case: (z =P x) => [->|]; first exact: (astab1P cgx). by move/eqP=> zx; rewrite [_ g](astabP cgx') ?inE. have Hreg g z: g \in H -> g z = z -> g = 1. have F15 h: h \in H -> h x = x -> h = 1. move=> Hh Hhx; have: h \in K by rewrite inE Hh; apply/astab1P. by rewrite [K](trivGP (subset_trans Ksub F14)) => /set1P. move=> Hg Hgz; have:= in_setT x; rewrite -(atransP F3 z) ?inE //. case/imsetP=> g1 Hg1 Hg2; apply: (conjg_inj g1); rewrite conj1g. apply: F15; last by rewrite Hg2 -permM mulKVg permM Hgz. by rewrite memJ_norm ?(subsetP nH). clear K F8 F12 F13 Ksub F14. have Hcard: 5 < #|H|. apply: (leq_trans oT); apply: dvdn_leq; first exact: cardG_gt0. by rewrite -cardsT (atrans_dvd F5). case Eh: (pred0b [predD1 H & 1]). by move: Hcard; rewrite /pred0b in Eh; rewrite (cardD1 1) group1 (eqP Eh). case/pred0Pn: Eh => h; case/andP => diff_1_h /= Hh. case Eg: (pred0b (predD1 (predD1 [predD1 H & 1] h) h^-1)). move: Hcard; rewrite ltnNge; case/negP. rewrite (cardD1 1) group1 (cardD1 h) (cardD1 h^-1) (eqnP Eg). by do 2!case: (_ \in _). case/pred0Pn: Eg => g; case/andP => diff_h1_g; case/andP => diff_h_g. case/andP => diff_1_g /= Hg. case diff_hx_x: (h x == x). by case/negP: diff_1_h; apply/eqP; apply: (Hreg _ _ Hh (eqP diff_hx_x)). case diff_gx_x: (g x == x). case/negP: diff_1_g; apply/eqP; apply: (Hreg _ _ Hg (eqP diff_gx_x)). case diff_gx_hx: (g x == h x). case/negP: diff_h_g; apply/eqP; symmetry; apply: (mulIg g^-1); rewrite gsimp. apply: (Hreg _ x); first by rewrite groupM // groupV. by rewrite permM -(eqP diff_gx_hx) -permM mulgV perm1. case diff_hgx_x: ((h * g) x == x). case/negP: diff_h1_g; apply/eqP; apply: (mulgI h); rewrite !gsimp. by apply: (Hreg _ x); [apply: groupM | apply/eqP]. case diff_hgx_hx: ((h * g) x == h x). case/negP: diff_1_g; apply/eqP. by apply: (Hreg _ (h x)) => //; apply/eqP; rewrite -permM. case diff_hgx_gx: ((h * g) x == g x). by case/idP: diff_hx_x; rewrite -(can_eq (permK g)) -permM. case Ez: (pred0b (predD1 (predD1 (predD1 (predD1 T x) (h x)) (g x)) ((h * g) x))). - move: oT; rewrite /pred0b in Ez. rewrite (cardD1 x) (cardD1 (h x)) (cardD1 (g x)) (cardD1 ((h * g) x)). by rewrite (eqP Ez) addnC; do 3!case: (_ x \in _). case/pred0Pn: Ez => z. case/and5P=> diff_hgx_z diff_gx_z diff_hx_z diff_x_z /= Hz. pose S1 := [tuple x; h x; g x; z]. have DnS1: S1 \in 4.-dtuple(setT). rewrite inE memtE subset_all -!andbA !negb_or /= !inE !andbT. rewrite -!(eq_sym z) diff_gx_z diff_x_z diff_hx_z. by rewrite !(eq_sym x) diff_hx_x diff_gx_x eq_sym diff_gx_hx. pose S2 := [tuple x; h x; g x; (h * g) x]. have DnS2: S2 \in 4.-dtuple(setT). rewrite inE memtE subset_all -!andbA !negb_or /= !inE !andbT !(eq_sym x). rewrite diff_hx_x diff_gx_x diff_hgx_x. by rewrite !(eq_sym (h x)) diff_gx_hx diff_hgx_hx eq_sym diff_hgx_gx. case: (atransP2 F2 DnS1 DnS2) => k Hk [/=]. rewrite /aperm => Hkx Hkhx Hkgx Hkhgx. have h_k_com: h * k = k * h. suff HH: (k * h * k^-1) * h^-1 = 1 by rewrite -[h * k]mul1g -HH !gnorm. apply: (Hreg _ x); last first. by rewrite !permM -Hkx Hkhx -!permM mulKVg mulgV perm1. by rewrite groupM // ?groupV // (conjgCV k) mulgK -mem_conjg (normsP nH). have g_k_com: g * k = k * g. suff HH: (k * g * k^-1) * g^-1 = 1 by rewrite -[g * k]mul1g -HH !gnorm. apply: (Hreg _ x); last first. by rewrite !permM -Hkx Hkgx -!permM mulKVg mulgV perm1. by rewrite groupM // ?groupV // (conjgCV k) mulgK -mem_conjg (normsP nH). have HH: (k * (h * g) * k ^-1) x = z. by rewrite 2!permM -Hkx Hkhgx -permM mulgV perm1. case/negP: diff_hgx_z. rewrite -HH !mulgA -h_k_com -!mulgA [k * _]mulgA. by rewrite -g_k_com -!mulgA mulgV mulg1. Qed. Lemma gen_tperm_circular_shift (X : finType) x y c : prime #|X| -> x != y -> #[c]%g = #|X| -> <<[set tperm x y; c]>>%g = ('Sym_X)%g. Proof. move=> Xprime neq_xy ord_c; apply/eqP; rewrite eqEsubset subsetT/=. have c_gt1 : (1 < #[c]%g)%N by rewrite ord_c prime_gt1. have cppSS : #[c]%g.-2.+2 = #|X| by rewrite ?prednK ?ltn_predRL. pose f (i : 'Z_#[c]%g) : X := Zpm i x. have [g fK gK] : bijective f. apply: inj_card_bij; rewrite ?cppSS ?card_ord// /f /Zpm => i j cijx. pose stabx := ('C_<[c]>[x | 'P])%g. have cjix : (c ^+ (j - i)%R)%g x = x. by apply: (@perm_inj _ (c ^+ i)%g); rewrite -permM -expgD_Zp// addrNK. have : (c ^+ (j - i)%R)%g \in stabx. by rewrite !inE ?groupX ?mem_gen ?sub1set ?inE// ['P%act _ _]cjix eqxx. rewrite [stabx]perm_prime_astab// => /set1gP. move=> /(congr1 (mulg (c ^+ i))); rewrite -expgD_Zp// addrC addrNK mulg1. by move=> /eqP; rewrite eq_expg_ord// ?cppSS ?ord_c// => /eqP->. pose gsf s := g \o s \o f. have gsf_inj (s : {perm X}) : injective (gsf s). apply: inj_comp; last exact: can_inj fK. by apply: inj_comp; [exact: can_inj gK|exact: perm_inj]. pose fsg s := f \o s \o g. have fsg_inj (s : {perm _}) : injective (fsg s). apply: inj_comp; last exact: can_inj gK. by apply: inj_comp; [exact: can_inj fK|exact: perm_inj]. have gsf_morphic : morphic 'Sym_X (fun s => perm (gsf_inj s)). apply/morphicP => u v _ _; apply/permP => /= i. by rewrite !permE/= !permE /gsf /= gK permM. pose phi := morphm gsf_morphic; rewrite /= in phi. have phi_inj : ('injm phi)%g. apply/subsetP => /= u /mker/=; rewrite morphmE => gsfu1. apply/set1gP/permP=> z; have /permP/(_ (g z)) := gsfu1. by rewrite !perm1 permE /gsf/= gK => /(can_inj gK). have phiT : (phi @* 'Sym_X)%g = [set: {perm 'Z_#[c]%g}]. apply/eqP; rewrite eqEsubset subsetT/=; apply/subsetP => /= u _. apply/morphimP; exists (perm (fsg_inj u)); rewrite ?in_setT//. by apply/permP => /= i; rewrite morphmE permE /gsf/fsg/= permE/= !fK. have f0 : f 0%R = x by rewrite /f /Zpm permX. pose k := g y; have k_gt0 : (k > 0)%N. by rewrite lt0n (val_eqE k 0%R) -(can_eq fK) eq_sym gK f0. have phixy : phi (tperm x y) = tperm (0%R : 'Z_#[c]) k. apply/permP => i; rewrite permE/= /gsf/=; apply: (canLR fK). by rewrite !permE/= -f0 -[y]gK !(can_eq fK) -!fun_if. have phic : phi c = perm (addrI (1%R : 'Z_#[c])). apply/permP => i; rewrite /phi morphmE !permE /gsf/=; apply: (canLR fK). by rewrite /f /Zpm -permM addrC expgD_Zp. rewrite -(injmSK phi_inj)//= morphim_gen/= ?subsetT//= -/phi. rewrite phiT /morphim !setTI/= -/phi imsetU1 imset_set1/= phixy phic. suff /gen_tpermn_circular_shift<- : coprime #[c]%g.-2.+2 (k - 0)%R by []. by rewrite subr0 prime_coprime ?gtnNdvd// ?cppSS. Qed. Section Perm_solvable. Local Open Scope nat_scope. Variable T : finType. Lemma solvable_AltF : 4 < #|T| -> solvable 'Alt_T = false. Proof. move=> card_T; apply/negP => Alt_solvable. have/simple_Alt5 Alt_simple := card_T. have := simple_sol_prime Alt_solvable Alt_simple. have lt_T n : n <= 4 -> n < #|T| by move/leq_ltn_trans; apply. have -> : #|('Alt_T)%G| = #|T|`! %/ 2 by rewrite -card_Alt ?mulKn ?lt_T. move/even_prime => [/eqP|]; apply/negP. rewrite neq_ltn leq_divRL // mulnC -[2 * 3]/(3`!). by apply/orP; right; apply/ltnW/ltn_fact/lt_T. by rewrite -dvdn2 dvdn_divRL dvdn_fact //=; apply/ltnW/lt_T. Qed. Lemma solvable_SymF : 4 < #|T| -> solvable 'Sym_T = false. Proof. by rewrite (series_sol (Alt_normal T)) => /solvable_AltF->. Qed. End Perm_solvable.
CommGrp_.lean
/- Copyright (c) 2025 Yaël Dillies. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yaël Dillies -/ import Mathlib.CategoryTheory.Monoidal.Cartesian.CommMon_ import Mathlib.CategoryTheory.Monoidal.Cartesian.Grp_ /-! # Yoneda embedding of `CommGrp_ C` -/ assert_not_exists Field open CategoryTheory MonoidalCategory Limits Opposite CartesianMonoidalCategory Mon_Class universe w v u variable {C : Type u} [Category.{v} C] [CartesianMonoidalCategory C] [BraidedCategory C] {X : C} variable (X) in /-- Abbreviation for an unbundled commutative group object. It is a group object that is a commutative monoid object. -/ class abbrev CommGrp_Class := Grp_Class X, IsCommMon X section CommGrp_ variable (X) in /-- If `X` represents a presheaf of commutative groups, then `X` is a commutative group object. -/ def CommGrp_Class.ofRepresentableBy (F : Cᵒᵖ ⥤ CommGrp.{w}) (α : (F ⋙ forget _).RepresentableBy X) : CommGrp_Class X where __ := Grp_Class.ofRepresentableBy X (F ⋙ forget₂ CommGrp Grp) α __ := IsCommMon.ofRepresentableBy X (F ⋙ forget₂ CommGrp CommMonCat) α end CommGrp_
PreorderRestrict.lean
/- Copyright (c) 2024 Etienne Marion. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Etienne Marion -/ import Mathlib.Order.Restriction import Mathlib.Topology.Constructions /-! # Continuity of the restriction function for functions indexed by a preorder We prove that the map which restricts a function `f : (i : α) → X i` to elements `≤ a` is continuous. -/ namespace Preorder variable {α : Type*} [Preorder α] {X : α → Type*} [∀ i, TopologicalSpace (X i)] @[continuity, fun_prop] theorem continuous_restrictLe (a : α) : Continuous (restrictLe (π := X) a) := Pi.continuous_restrict _ @[continuity, fun_prop] theorem continuous_restrictLe₂ {a b : α} (hab : a ≤ b) : Continuous (restrictLe₂ (π := X) hab) := Pi.continuous_restrict₂ _ variable [LocallyFiniteOrderBot α] @[continuity, fun_prop] theorem continuous_frestrictLe (a : α) : Continuous (frestrictLe (π := X) a) := Finset.continuous_restrict _ @[continuity, fun_prop] theorem continuous_frestrictLe₂ {a b : α} (hab : a ≤ b) : Continuous (frestrictLe₂ (π := X) hab) := Finset.continuous_restrict₂ _ end Preorder
TwoSquare.lean
/- Copyright (c) 2025 Jakob von Raumer. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joël Riou, Jakob von Raumer -/ import Mathlib.CategoryTheory.Whiskering import Mathlib.CategoryTheory.Opposites import Mathlib.Tactic.CategoryTheory.Slice /-! # 2-squares of functors Given four functors `T`, `L`, `R` and `B`, a 2-square `TwoSquare T L R B` consists of a natural transformation `w : T ⋙ R ⟶ L ⋙ B`: ``` T C₁ ⥤ C₂ L | | R v v C₃ ⥤ C₄ B ``` We define operations to paste such squares horizontally and vertically and prove the interchange law of those two operations. ## TODO Generalize all of this to double categories. -/ universe v₁ v₂ v₃ v₄ v₅ v₆ v₇ v₈ v₉ u₁ u₂ u₃ u₄ u₅ u₆ u₇ u₈ u₉ namespace CategoryTheory open Category Functor variable {C₁ : Type u₁} {C₂ : Type u₂} {C₃ : Type u₃} {C₄ : Type u₄} [Category.{v₁} C₁] [Category.{v₂} C₂] [Category.{v₃} C₃] [Category.{v₄} C₄] (T : C₁ ⥤ C₂) (L : C₁ ⥤ C₃) (R : C₂ ⥤ C₄) (B : C₃ ⥤ C₄) /-- A `2`-square consists of a natural transformation `T ⋙ R ⟶ L ⋙ B` involving fours functors `T`, `L`, `R`, `B` that are on the top/left/right/bottom sides of a square of categories. -/ def TwoSquare := T ⋙ R ⟶ L ⋙ B namespace TwoSquare /-- Constructor for `TwoSquare`. -/ abbrev mk (α : T ⋙ R ⟶ L ⋙ B) : TwoSquare T L R B := α variable {T} {L} {R} {B} in /-- The natural transformation associated to a 2-square. -/ abbrev natTrans (w : TwoSquare T L R B) : T ⋙ R ⟶ L ⋙ B := w /-- The type of 2-squares on functors `T`, `L`, `R`, and `B` is trivially equivalent to the type of natural transformations `T ⋙ R ⟶ L ⋙ B`. -/ @[simps] def equivNatTrans : TwoSquare T L R B ≃ (T ⋙ R ⟶ L ⋙ B) where toFun := natTrans invFun := mk T L R B variable {T L R B} /-- The opposite of a `2`-square. -/ def op (α : TwoSquare T L R B) : TwoSquare L.op T.op B.op R.op := NatTrans.op α @[simp] lemma natTrans_op (α : TwoSquare T L R B) : α.op.natTrans = NatTrans.op α.natTrans := rfl @[ext] lemma ext (w w' : TwoSquare T L R B) (h : ∀ (X : C₁), w.natTrans.app X = w'.natTrans.app X) : w = w' := NatTrans.ext (funext h) /-- The horizontal identity 2-square. -/ @[simps!] def hId (L : C₁ ⥤ C₃) : TwoSquare (𝟭 _) L L (𝟭 _) := 𝟙 _ /-- Notation for the horizontal identity 2-square. -/ scoped notation "𝟙ₕ" => hId -- type as \b1\_h /-- The vertical identity 2-square. -/ @[simps!] def vId (T : C₁ ⥤ C₂) : TwoSquare T (𝟭 _) (𝟭 _) T := 𝟙 _ /-- Notation for the vertical identity 2-square. -/ scoped notation "𝟙ᵥ" => vId -- type as \b1\_v /-- Whiskering a 2-square with a natural transformation at the top. -/ @[simps!] protected def whiskerTop {T' : C₁ ⥤ C₂} (w : TwoSquare T' L R B) (α : T ⟶ T') : TwoSquare T L R B := .mk _ _ _ _ <| whiskerRight α R ≫ w.natTrans /-- Whiskering a 2-square with a natural transformation at the left side. -/ @[simps!] protected def whiskerLeft {L' : C₁ ⥤ C₃} (w : TwoSquare T L R B) (α : L ⟶ L') : TwoSquare T L' R B := .mk _ _ _ _ <| w.natTrans ≫ whiskerRight α B /-- Whiskering a 2-square with a natural transformation at the right side. -/ @[simps!] protected def whiskerRight {R' : C₂ ⥤ C₄} (w : TwoSquare T L R' B) (α : R ⟶ R') : TwoSquare T L R B := .mk _ _ _ _ <| whiskerLeft T α ≫ w.natTrans /-- Whiskering a 2-square with a natural transformation at the bottom. -/ @[simps!] protected def whiskerBottom {B' : C₃ ⥤ C₄} (w : TwoSquare T L R B) (α : B ⟶ B') : TwoSquare T L R B' := .mk _ _ _ _ <| w.natTrans ≫ whiskerLeft L α variable {C₅ : Type u₅} {C₆ : Type u₆} {C₇ : Type u₇} {C₈ : Type u₈} [Category.{v₅} C₅] [Category.{v₆} C₆] [Category.{v₇} C₇] [Category.{v₈} C₈] {T' : C₂ ⥤ C₅} {R' : C₅ ⥤ C₆} {B' : C₄ ⥤ C₆} {L' : C₃ ⥤ C₇} {R'' : C₄ ⥤ C₈} {B'' : C₇ ⥤ C₈} /-- The horizontal composition of 2-squares. -/ @[simps!] def hComp (w : TwoSquare T L R B) (w' : TwoSquare T' R R' B') : TwoSquare (T ⋙ T') L R' (B ⋙ B') := .mk _ _ _ _ <| (associator _ _ _).hom ≫ (whiskerLeft T w'.natTrans) ≫ (associator _ _ _).inv ≫ (whiskerRight w.natTrans B') ≫ (associator _ _ _).hom /-- Notation for the horizontal composition of 2-squares. -/ scoped infixr:80 " ≫ₕ " => hComp -- type as \gg\_h /-- The vertical composition of 2-squares. -/ @[simps!] def vComp (w : TwoSquare T L R B) (w' : TwoSquare B L' R'' B'') : TwoSquare T (L ⋙ L') (R ⋙ R'') B'' := .mk _ _ _ _ <| (associator _ _ _).inv ≫ whiskerRight w.natTrans R'' ≫ (associator _ _ _).hom ≫ whiskerLeft L w'.natTrans ≫ (associator _ _ _).inv /-- Notation for the vertical composition of 2-squares. -/ scoped infixr:80 " ≫ᵥ " => vComp -- type as \gg\_v section Interchange variable {C₉ : Type u₉} [Category.{v₉} C₉] {R₃ : C₆ ⥤ C₉} {B₃ : C₈ ⥤ C₉} /-- When composing 2-squares which form a diagram of grid, composing horizontally first yields the same result as composing vertically first. -/ lemma hCompVCompHComp (w₁ : TwoSquare T L R B) (w₂ : TwoSquare T' R R' B') (w₃ : TwoSquare B L' R'' B'') (w₄ : TwoSquare B' R'' R₃ B₃) : (w₁ ≫ₕ w₂) ≫ᵥ (w₃ ≫ₕ w₄) = (w₁ ≫ᵥ w₃) ≫ₕ (w₂ ≫ᵥ w₄) := by unfold hComp vComp whiskerLeft whiskerRight ext c simp only [comp_obj, NatTrans.comp_app, associator_hom_app, associator_inv_app, comp_id, id_comp, map_comp, assoc] slice_rhs 2 3 => rw [← Functor.comp_map _ B₃, ← w₄.naturality] simp end Interchange end TwoSquare end CategoryTheory
Tree.lean
/- Copyright (c) 2024 Sven Manthe. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sven Manthe -/ import Mathlib.Order.CompleteLattice.SetLike /-! # Trees in the sense of descriptive set theory This file defines trees of depth `ω` in the sense of descriptive set theory as sets of finite sequences that are stable under taking prefixes. ## Main declarations * `tree A`: a (possibly infinite) tree of depth at most `ω` with nodes in `A` -/ namespace Descriptive /-- A tree is a set of finite sequences, implemented as `List A`, that is stable under taking prefixes. For the definition we use the equivalent property `x ++ [a] ∈ T → x ∈ T`, which is more convenient to check. We define `tree A` as a complete sublattice of `Set (List A)`, which coerces to the type of trees on `A`. -/ def tree (A : Type*) : CompleteSublattice (Set (List A)) := CompleteSublattice.mk' {T | ∀ ⦃x : List A⦄ ⦃a : A⦄, x ++ [a] ∈ T → x ∈ T} (by rintro S hS x a ⟨t, ht, hx⟩; use t, ht, hS ht hx) (by rintro S hS x a h T hT; exact hS hT <| h T hT) @[simps!] instance (A : Type*) : SetLike (tree A) (List A) := SetLike.instSubtypeSet namespace Tree variable {A : Type*} {S T : tree A} lemma mem_of_append {x y : List A} (h : x ++ y ∈ T) : x ∈ T := by induction y generalizing x with | nil => simpa using h | cons y ys ih => exact T.prop (ih (by simpa)) lemma mem_of_prefix {x y : List A} (h' : x <+: y) (h : y ∈ T) : x ∈ T := by obtain ⟨_, rfl⟩ := h'; exact mem_of_append h instance : Trans List.IsPrefix (fun x (T : tree A) ↦ x ∈ T) (fun x T ↦ x ∈ T) where trans := mem_of_prefix lemma singleton_mem (T : tree A) {a : A} {x : List A} (h : a :: x ∈ T) : [a] ∈ T := mem_of_prefix ⟨x, rfl⟩ h @[simp] lemma tree_eq_bot : T = ⊥ ↔ [] ∉ T where mp := by rintro rfl; simp mpr h := by ext x; simpa using fun h' ↦ h <| mem_of_prefix x.nil_prefix h' lemma take_mem {n : ℕ} (x : T) : x.val.take n ∈ T := mem_of_prefix (x.val.take_prefix n) x.prop /-- A variant of `List.take` internally to a tree -/ @[simps] def take (n : ℕ) (x : T) : T := ⟨x.val.take n, take_mem x⟩ @[simp] lemma take_take (m n : ℕ) (x : T) : take m (take n x) = take (m ⊓ n) x := by simp [Subtype.ext_iff, List.take_take] @[simp] lemma take_eq_take {x : T} {m n : ℕ} : take m x = take n x ↔ m ⊓ x.val.length = n ⊓ x.val.length := by simp [Subtype.ext_iff] -- ### `subAt` variable (T) (x y : List A) /-- The residual tree obtained by regarding the node x as new root -/ def subAt : tree A := ⟨(x ++ ·)⁻¹' T, fun _ _ _ ↦ mem_of_append (by rwa [List.append_assoc])⟩ @[simp] lemma mem_subAt : y ∈ subAt T x ↔ x ++ y ∈ T := Iff.rfl @[simp] lemma subAt_nil : subAt T [] = T := rfl @[simp] lemma subAt_append : subAt (subAt T x) y = subAt T (x ++ y) := by ext; simp @[gcongr] lemma subAt_mono (h : S ≤ T) : subAt S x ≤ subAt T x := Set.preimage_mono h /-- A variant of `List.drop` that takes values in `subAt` -/ @[simps] def drop (n : ℕ) (x : T) : subAt T (Tree.take n x).val := ⟨x.val.drop n, by simp⟩ -- ### `pullSub` /-- Adjoint of `subAt`, given by pasting x before the root of T. Explicitly, elements are prefixes of x or x with an element of T appended -/ def pullSub : tree A where val := { y | y.take x.length <+: x ∧ y.drop x.length ∈ T } property := fun y a ⟨h1, h2⟩ ↦ ⟨((y.prefix_append [a]).take x.length).trans h1, mem_of_prefix ((y.prefix_append [a]).drop x.length) h2⟩ variable {T x y} lemma mem_pullSub_short (hl : y.length ≤ x.length) : y ∈ pullSub T x ↔ y <+: x ∧ [] ∈ T := by simp [pullSub, List.take_of_length_le hl, List.drop_eq_nil_iff.mpr hl] lemma mem_pullSub_long (hl : x.length ≤ y.length) : y ∈ pullSub T x ↔ ∃ z ∈ T, y = x ++ z where mp := by intro ⟨h1, h2⟩; use y.drop x.length, h2 nth_rw 1 [← List.take_append_drop x.length y] simpa [-List.take_append_drop, List.prefix_iff_eq_take, hl] using h1 mpr := by simp +contextual [pullSub] @[simp] lemma mem_pullSub_append : x ++ y ∈ pullSub T x ↔ y ∈ T := by simp [mem_pullSub_long] @[simp] lemma mem_pullSub_self : x ∈ pullSub T x ↔ [] ∈ T := by simpa using mem_pullSub_append (y := []) variable (T x y) lemma pullSub_subAt : pullSub (subAt T x) x ≤ T := by intro y (h : y ∈ pullSub _ x); rcases le_total y.length x.length with h' | h' · rw [mem_pullSub_short h'] at h; exact mem_of_prefix h.1 (by simpa using h.2) · rw [mem_pullSub_long h'] at h; obtain ⟨_, h, rfl⟩ := h; exact h @[simp] lemma subAt_pullSub : subAt (pullSub T x) x = T := by ext y; simp @[gcongr] lemma pullSub_mono (h : S ≤ T) x : pullSub S x ≤ pullSub T x := fun _ ⟨h1, h2⟩ ↦ ⟨h1, h h2⟩ lemma pullSub_adjunction (S T : tree A) (x : List A) : pullSub S x ≤ T ↔ S ≤ subAt T x where mp _ := by rw [← subAt_pullSub S x]; gcongr mpr _ := le_trans (by gcongr) (pullSub_subAt T x) @[simp] lemma pullSub_nil : pullSub T [] = T := by simp [pullSub] @[simp] lemma pullSub_append : pullSub (pullSub T y) x = pullSub T (x ++ y) := by ext z; rcases le_total x.length z.length with hl | hl · by_cases hp : x <+: z · obtain ⟨z, rfl⟩ := hp simp [pullSub, List.take_add] · constructor <;> intro ⟨h, _⟩ <;> [skip; replace h := by simpa [List.take_take] using h.take x.length] <;> cases hp <| List.prefix_iff_eq_take.mpr (h.eq_of_length (by simpa)).symm · rw [mem_pullSub_short hl, mem_pullSub_short (by simp), mem_pullSub_short (by simp; omega)] simpa using fun _ ↦ (z.isPrefix_append_of_length hl).symm end Descriptive.Tree
PiSystem.lean
/- Copyright (c) 2021 Martin Zinkevich. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Martin Zinkevich, Rémy Degenne -/ import Mathlib.Logic.Encodable.Lattice import Mathlib.MeasureTheory.MeasurableSpace.Defs import Mathlib.Order.Disjointed /-! # Induction principles for measurable sets, related to π-systems and λ-systems. ## Main statements * The main theorem of this file is Dynkin's π-λ theorem, which appears here as an induction principle `induction_on_inter`. Suppose `s` is a collection of subsets of `α` such that the intersection of two members of `s` belongs to `s` whenever it is nonempty. Let `m` be the σ-algebra generated by `s`. In order to check that a predicate `C` holds on every member of `m`, it suffices to check that `C` holds on the members of `s` and that `C` is preserved by complementation and *disjoint* countable unions. * The proof of this theorem relies on the notion of `IsPiSystem`, i.e., a collection of sets which is closed under binary non-empty intersections. Note that this is a small variation around the usual notion in the literature, which often requires that a π-system is non-empty, and closed also under disjoint intersections. This variation turns out to be convenient for the formalization. * The proof of Dynkin's π-λ theorem also requires the notion of `DynkinSystem`, i.e., a collection of sets which contains the empty set, is closed under complementation and under countable union of pairwise disjoint sets. The disjointness condition is the only difference with `σ`-algebras. * `generatePiSystem g` gives the minimal π-system containing `g`. This can be considered a Galois insertion into both measurable spaces and sets. * `generateFrom_generatePiSystem_eq` proves that if you start from a collection of sets `g`, take the generated π-system, and then the generated σ-algebra, you get the same result as the σ-algebra generated from `g`. This is useful because there are connections between independent sets that are π-systems and the generated independent spaces. * `mem_generatePiSystem_iUnion_elim` and `mem_generatePiSystem_iUnion_elim'` show that any element of the π-system generated from the union of a set of π-systems can be represented as the intersection of a finite number of elements from these sets. * `piiUnionInter` defines a new π-system from a family of π-systems `π : ι → Set (Set α)` and a set of indices `S : Set ι`. `piiUnionInter π S` is the set of sets that can be written as `⋂ x ∈ t, f x` for some finset `t ∈ S` and sets `f x ∈ π x`. ## Implementation details * `IsPiSystem` is a predicate, not a type. Thus, we don't explicitly define the galois insertion, nor do we define a complete lattice. In theory, we could define a complete lattice and galois insertion on the subtype corresponding to `IsPiSystem`. -/ open MeasurableSpace Set open MeasureTheory variable {α β : Type*} /-- A π-system is a collection of subsets of `α` that is closed under binary intersection of non-disjoint sets. Usually it is also required that the collection is nonempty, but we don't do that here. -/ def IsPiSystem (C : Set (Set α)) : Prop := ∀ᵉ (s ∈ C) (t ∈ C), (s ∩ t : Set α).Nonempty → s ∩ t ∈ C namespace MeasurableSpace theorem isPiSystem_measurableSet {α : Type*} [MeasurableSpace α] : IsPiSystem { s : Set α | MeasurableSet s } := fun _ hs _ ht _ => hs.inter ht end MeasurableSpace theorem IsPiSystem.singleton (S : Set α) : IsPiSystem ({S} : Set (Set α)) := by intro s h_s t h_t _ rw [Set.mem_singleton_iff.1 h_s, Set.mem_singleton_iff.1 h_t, Set.inter_self, Set.mem_singleton_iff] theorem IsPiSystem.insert_empty {S : Set (Set α)} (h_pi : IsPiSystem S) : IsPiSystem (insert ∅ S) := by intro s hs t ht hst rcases hs with hs | hs · simp [hs] · rcases ht with ht | ht · simp [ht] · exact Set.mem_insert_of_mem _ (h_pi s hs t ht hst) theorem IsPiSystem.insert_univ {S : Set (Set α)} (h_pi : IsPiSystem S) : IsPiSystem (insert Set.univ S) := by intro s hs t ht hst rcases hs with hs | hs · rcases ht with ht | ht <;> simp [hs, ht] · rcases ht with ht | ht · simp [hs, ht] · exact Set.mem_insert_of_mem _ (h_pi s hs t ht hst) theorem IsPiSystem.comap {α β} {S : Set (Set β)} (h_pi : IsPiSystem S) (f : α → β) : IsPiSystem { s : Set α | ∃ t ∈ S, f ⁻¹' t = s } := by rintro _ ⟨s, hs_mem, rfl⟩ _ ⟨t, ht_mem, rfl⟩ hst rw [← Set.preimage_inter] at hst ⊢ exact ⟨s ∩ t, h_pi s hs_mem t ht_mem (nonempty_of_nonempty_preimage hst), rfl⟩ theorem isPiSystem_iUnion_of_directed_le {α ι} (p : ι → Set (Set α)) (hp_pi : ∀ n, IsPiSystem (p n)) (hp_directed : Directed (· ≤ ·) p) : IsPiSystem (⋃ n, p n) := by intro t1 ht1 t2 ht2 h rw [Set.mem_iUnion] at ht1 ht2 ⊢ obtain ⟨n, ht1⟩ := ht1 obtain ⟨m, ht2⟩ := ht2 obtain ⟨k, hpnk, hpmk⟩ : ∃ k, p n ≤ p k ∧ p m ≤ p k := hp_directed n m exact ⟨k, hp_pi k t1 (hpnk ht1) t2 (hpmk ht2) h⟩ theorem isPiSystem_iUnion_of_monotone {α ι} [SemilatticeSup ι] (p : ι → Set (Set α)) (hp_pi : ∀ n, IsPiSystem (p n)) (hp_mono : Monotone p) : IsPiSystem (⋃ n, p n) := isPiSystem_iUnion_of_directed_le p hp_pi (Monotone.directed_le hp_mono) /-- Rectangles formed by π-systems form a π-system. -/ lemma IsPiSystem.prod {C : Set (Set α)} {D : Set (Set β)} (hC : IsPiSystem C) (hD : IsPiSystem D) : IsPiSystem (image2 (· ×ˢ ·) C D) := by rintro _ ⟨s₁, hs₁, t₁, ht₁, rfl⟩ _ ⟨s₂, hs₂, t₂, ht₂, rfl⟩ hst rw [prod_inter_prod] at hst ⊢; rw [prod_nonempty_iff] at hst exact mem_image2_of_mem (hC _ hs₁ _ hs₂ hst.1) (hD _ ht₁ _ ht₂ hst.2) /-- A nonempty finite intersection of sets in a π-system belongs to the π-system. -/ lemma IsPiSystem.biInter_mem {S : Set (Set α)} (h_pi : IsPiSystem S) {t : Finset (Set α)} (t_ne : t.Nonempty) (ht : ∀ s ∈ t, s ∈ S) (h' : (⋂ s ∈ t, s).Nonempty) : (⋂ s ∈ t, s) ∈ S := by classical induction t_ne using Finset.Nonempty.cons_induction with | singleton a => simpa using ht | cons a t hat t_ne ih => simp only [Finset.cons_eq_insert, Finset.mem_insert, iInter_iInter_eq_or_left] at h' ht ⊢ refine h_pi _ (ht a (Or.inl rfl)) _ ?_ h' refine ih (fun s hs ↦ ?_) h'.right exact ht s (Or.inr hs) section Order variable {ι ι' : Sort*} [LinearOrder α] theorem isPiSystem_image_Iio (s : Set α) : IsPiSystem (Iio '' s) := by rintro _ ⟨a, ha, rfl⟩ _ ⟨b, hb, rfl⟩ - exact ⟨a ⊓ b, inf_ind a b ha hb, Iio_inter_Iio.symm⟩ theorem isPiSystem_Iio : IsPiSystem (range Iio : Set (Set α)) := @image_univ α _ Iio ▸ isPiSystem_image_Iio univ theorem isPiSystem_image_Ioi (s : Set α) : IsPiSystem (Ioi '' s) := @isPiSystem_image_Iio αᵒᵈ _ s theorem isPiSystem_Ioi : IsPiSystem (range Ioi : Set (Set α)) := @image_univ α _ Ioi ▸ isPiSystem_image_Ioi univ theorem isPiSystem_image_Iic (s : Set α) : IsPiSystem (Iic '' s) := by rintro _ ⟨a, ha, rfl⟩ _ ⟨b, hb, rfl⟩ - exact ⟨a ⊓ b, inf_ind a b ha hb, Iic_inter_Iic.symm⟩ theorem isPiSystem_Iic : IsPiSystem (range Iic : Set (Set α)) := @image_univ α _ Iic ▸ isPiSystem_image_Iic univ theorem isPiSystem_image_Ici (s : Set α) : IsPiSystem (Ici '' s) := @isPiSystem_image_Iic αᵒᵈ _ s theorem isPiSystem_Ici : IsPiSystem (range Ici : Set (Set α)) := @image_univ α _ Ici ▸ isPiSystem_image_Ici univ theorem isPiSystem_Ixx_mem {Ixx : α → α → Set α} {p : α → α → Prop} (Hne : ∀ {a b}, (Ixx a b).Nonempty → p a b) (Hi : ∀ {a₁ b₁ a₂ b₂}, Ixx a₁ b₁ ∩ Ixx a₂ b₂ = Ixx (max a₁ a₂) (min b₁ b₂)) (s t : Set α) : IsPiSystem { S | ∃ᵉ (l ∈ s) (u ∈ t), p l u ∧ Ixx l u = S } := by rintro _ ⟨l₁, hls₁, u₁, hut₁, _, rfl⟩ _ ⟨l₂, hls₂, u₂, hut₂, _, rfl⟩ simp only [Hi] exact fun H => ⟨l₁ ⊔ l₂, sup_ind l₁ l₂ hls₁ hls₂, u₁ ⊓ u₂, inf_ind u₁ u₂ hut₁ hut₂, Hne H, rfl⟩ theorem isPiSystem_Ixx {Ixx : α → α → Set α} {p : α → α → Prop} (Hne : ∀ {a b}, (Ixx a b).Nonempty → p a b) (Hi : ∀ {a₁ b₁ a₂ b₂}, Ixx a₁ b₁ ∩ Ixx a₂ b₂ = Ixx (max a₁ a₂) (min b₁ b₂)) (f : ι → α) (g : ι' → α) : @IsPiSystem α { S | ∃ i j, p (f i) (g j) ∧ Ixx (f i) (g j) = S } := by simpa only [exists_range_iff] using isPiSystem_Ixx_mem (@Hne) (@Hi) (range f) (range g) theorem isPiSystem_Ioo_mem (s t : Set α) : IsPiSystem { S | ∃ᵉ (l ∈ s) (u ∈ t), l < u ∧ Ioo l u = S } := isPiSystem_Ixx_mem (Ixx := Ioo) (fun ⟨_, hax, hxb⟩ => hax.trans hxb) Ioo_inter_Ioo s t theorem isPiSystem_Ioo (f : ι → α) (g : ι' → α) : @IsPiSystem α { S | ∃ l u, f l < g u ∧ Ioo (f l) (g u) = S } := isPiSystem_Ixx (Ixx := Ioo) (fun ⟨_, hax, hxb⟩ => hax.trans hxb) Ioo_inter_Ioo f g theorem isPiSystem_Ioc_mem (s t : Set α) : IsPiSystem { S | ∃ᵉ (l ∈ s) (u ∈ t), l < u ∧ Ioc l u = S } := isPiSystem_Ixx_mem (Ixx := Ioc) (fun ⟨_, hax, hxb⟩ => hax.trans_le hxb) Ioc_inter_Ioc s t theorem isPiSystem_Ioc (f : ι → α) (g : ι' → α) : @IsPiSystem α { S | ∃ i j, f i < g j ∧ Ioc (f i) (g j) = S } := isPiSystem_Ixx (Ixx := Ioc) (fun ⟨_, hax, hxb⟩ => hax.trans_le hxb) Ioc_inter_Ioc f g theorem isPiSystem_Ico_mem (s t : Set α) : IsPiSystem { S | ∃ᵉ (l ∈ s) (u ∈ t), l < u ∧ Ico l u = S } := isPiSystem_Ixx_mem (Ixx := Ico) (fun ⟨_, hax, hxb⟩ => hax.trans_lt hxb) Ico_inter_Ico s t theorem isPiSystem_Ico (f : ι → α) (g : ι' → α) : @IsPiSystem α { S | ∃ i j, f i < g j ∧ Ico (f i) (g j) = S } := isPiSystem_Ixx (Ixx := Ico) (fun ⟨_, hax, hxb⟩ => hax.trans_lt hxb) Ico_inter_Ico f g theorem isPiSystem_Icc_mem (s t : Set α) : IsPiSystem { S | ∃ᵉ (l ∈ s) (u ∈ t), l ≤ u ∧ Icc l u = S } := isPiSystem_Ixx_mem (Ixx := Icc) nonempty_Icc.1 (by exact Icc_inter_Icc) s t theorem isPiSystem_Icc (f : ι → α) (g : ι' → α) : @IsPiSystem α { S | ∃ i j, f i ≤ g j ∧ Icc (f i) (g j) = S } := isPiSystem_Ixx (Ixx := Icc) nonempty_Icc.1 (by exact Icc_inter_Icc) f g end Order /-- Given a collection `S` of subsets of `α`, then `generatePiSystem S` is the smallest π-system containing `S`. -/ inductive generatePiSystem (S : Set (Set α)) : Set (Set α) | base {s : Set α} (h_s : s ∈ S) : generatePiSystem S s | inter {s t : Set α} (h_s : generatePiSystem S s) (h_t : generatePiSystem S t) (h_nonempty : (s ∩ t).Nonempty) : generatePiSystem S (s ∩ t) theorem isPiSystem_generatePiSystem (S : Set (Set α)) : IsPiSystem (generatePiSystem S) := fun _ h_s _ h_t h_nonempty => generatePiSystem.inter h_s h_t h_nonempty theorem subset_generatePiSystem_self (S : Set (Set α)) : S ⊆ generatePiSystem S := fun _ => generatePiSystem.base theorem generatePiSystem_subset_self {S : Set (Set α)} (h_S : IsPiSystem S) : generatePiSystem S ⊆ S := fun x h => by induction h with | base h_s => exact h_s | inter _ _ h_nonempty h_s h_u => exact h_S _ h_s _ h_u h_nonempty theorem generatePiSystem_eq {S : Set (Set α)} (h_pi : IsPiSystem S) : generatePiSystem S = S := Set.Subset.antisymm (generatePiSystem_subset_self h_pi) (subset_generatePiSystem_self S) theorem generatePiSystem_mono {S T : Set (Set α)} (hST : S ⊆ T) : generatePiSystem S ⊆ generatePiSystem T := fun t ht => by induction ht with | base h_s => exact generatePiSystem.base (Set.mem_of_subset_of_mem hST h_s) | inter _ _ h_nonempty h_s h_u => exact isPiSystem_generatePiSystem T _ h_s _ h_u h_nonempty theorem generatePiSystem_measurableSet [M : MeasurableSpace α] {S : Set (Set α)} (h_meas_S : ∀ s ∈ S, MeasurableSet s) (t : Set α) (h_in_pi : t ∈ generatePiSystem S) : MeasurableSet t := by induction h_in_pi with | base h_s => apply h_meas_S _ h_s | inter _ _ _ h_s h_u => apply MeasurableSet.inter h_s h_u theorem generateFrom_measurableSet_of_generatePiSystem {g : Set (Set α)} (t : Set α) (ht : t ∈ generatePiSystem g) : MeasurableSet[generateFrom g] t := @generatePiSystem_measurableSet α (generateFrom g) g (fun _ h_s_in_g => measurableSet_generateFrom h_s_in_g) t ht theorem generateFrom_generatePiSystem_eq {g : Set (Set α)} : generateFrom (generatePiSystem g) = generateFrom g := by apply le_antisymm <;> apply generateFrom_le · exact fun t h_t => generateFrom_measurableSet_of_generatePiSystem t h_t · exact fun t h_t => measurableSet_generateFrom (generatePiSystem.base h_t) /-- Every element of the π-system generated by the union of a family of π-systems is a finite intersection of elements from the π-systems. For an indexed union version, see `mem_generatePiSystem_iUnion_elim'`. -/ theorem mem_generatePiSystem_iUnion_elim {α β} {g : β → Set (Set α)} (h_pi : ∀ b, IsPiSystem (g b)) (t : Set α) (h_t : t ∈ generatePiSystem (⋃ b, g b)) : ∃ (T : Finset β) (f : β → Set α), (t = ⋂ b ∈ T, f b) ∧ ∀ b ∈ T, f b ∈ g b := by classical induction h_t with | @base s h_s => rcases h_s with ⟨t', ⟨⟨b, rfl⟩, h_s_in_t'⟩⟩ refine ⟨{b}, fun _ => s, ?_⟩ simpa using h_s_in_t' | inter h_gen_s h_gen_t' h_nonempty h_s h_t' => rcases h_t' with ⟨T_t', ⟨f_t', ⟨rfl, h_t'⟩⟩⟩ rcases h_s with ⟨T_s, ⟨f_s, ⟨rfl, h_s⟩⟩⟩ use T_s ∪ T_t', fun b : β => if b ∈ T_s then if b ∈ T_t' then f_s b ∩ f_t' b else f_s b else if b ∈ T_t' then f_t' b else (∅ : Set α) constructor · ext a simp_rw [Set.mem_inter_iff, Set.mem_iInter, Finset.mem_union] grind intro b h_b split_ifs with hbs hbt hbt · refine h_pi b (f_s b) (h_s b hbs) (f_t' b) (h_t' b hbt) (Set.Nonempty.mono ?_ h_nonempty) exact Set.inter_subset_inter (Set.biInter_subset_of_mem hbs) (Set.biInter_subset_of_mem hbt) · exact h_s b hbs · exact h_t' b hbt · rw [Finset.mem_union] at h_b apply False.elim (h_b.elim hbs hbt) /-- Every element of the π-system generated by an indexed union of a family of π-systems is a finite intersection of elements from the π-systems. For a total union version, see `mem_generatePiSystem_iUnion_elim`. -/ theorem mem_generatePiSystem_iUnion_elim' {α β} {g : β → Set (Set α)} {s : Set β} (h_pi : ∀ b ∈ s, IsPiSystem (g b)) (t : Set α) (h_t : t ∈ generatePiSystem (⋃ b ∈ s, g b)) : ∃ (T : Finset β) (f : β → Set α), ↑T ⊆ s ∧ (t = ⋂ b ∈ T, f b) ∧ ∀ b ∈ T, f b ∈ g b := by classical have : t ∈ generatePiSystem (⋃ b : Subtype s, (g ∘ Subtype.val) b) := by suffices h1 : ⋃ b : Subtype s, (g ∘ Subtype.val) b = ⋃ b ∈ s, g b by rwa [h1] ext x simp only [exists_prop, Set.mem_iUnion, Function.comp_apply, Subtype.exists] rfl rcases @mem_generatePiSystem_iUnion_elim α (Subtype s) (g ∘ Subtype.val) (fun b => h_pi b.val b.property) t this with ⟨T, ⟨f, ⟨rfl, h_t'⟩⟩⟩ refine ⟨T.image (fun x : s => (x : β)), Function.extend (fun x : s => (x : β)) f fun _ : β => (∅ : Set α), by simp, ?_, ?_⟩ · ext a constructor <;> · simp -proj only [Set.mem_iInter, Subtype.forall, Finset.set_biInter_finset_image] intro h1 b h_b h_b_in_T have h2 := h1 b h_b h_b_in_T revert h2 rw [Subtype.val_injective.extend_apply] apply id · intros b h_b simp_rw [Finset.mem_image, Subtype.exists, exists_and_right, exists_eq_right] at h_b obtain ⟨h_b_w, h_b_h⟩ := h_b have h_b_alt : b = (Subtype.mk b h_b_w).val := rfl rw [h_b_alt, Subtype.val_injective.extend_apply] apply h_t' apply h_b_h section UnionInter variable {α ι : Type*} /-! ### π-system generated by finite intersections of sets of a π-system family -/ /-- From a set of indices `S : Set ι` and a family of sets of sets `π : ι → Set (Set α)`, define the set of sets that can be written as `⋂ x ∈ t, f x` for some finset `t ⊆ S` and sets `f x ∈ π x`. If `π` is a family of π-systems, then it is a π-system. -/ def piiUnionInter (π : ι → Set (Set α)) (S : Set ι) : Set (Set α) := { s : Set α | ∃ (t : Finset ι) (_ : ↑t ⊆ S) (f : ι → Set α) (_ : ∀ x, x ∈ t → f x ∈ π x), s = ⋂ x ∈ t, f x } theorem piiUnionInter_singleton (π : ι → Set (Set α)) (i : ι) : piiUnionInter π {i} = π i ∪ {univ} := by ext1 s simp only [piiUnionInter, exists_prop, mem_union] refine ⟨?_, fun h => ?_⟩ · rintro ⟨t, hti, f, hfπ, rfl⟩ simp only [subset_singleton_iff, Finset.mem_coe] at hti by_cases hi : i ∈ t · have ht_eq_i : t = {i} := by ext1 x rw [Finset.mem_singleton] exact ⟨fun h => hti x h, fun h => h.symm ▸ hi⟩ simp only [ht_eq_i, Finset.mem_singleton, iInter_iInter_eq_left] exact Or.inl (hfπ i hi) · have ht_empty : t = ∅ := by ext1 x simp only [Finset.notMem_empty, iff_false] exact fun hx => hi (hti x hx ▸ hx) simp [ht_empty, iInter_univ, Set.mem_singleton univ] · rcases h with hs | hs · refine ⟨{i}, ?_, fun _ => s, ⟨fun x hx => ?_, ?_⟩⟩ · rw [Finset.coe_singleton] · rw [Finset.mem_singleton] at hx rwa [hx] · simp only [Finset.mem_singleton, iInter_iInter_eq_left] · refine ⟨∅, ?_⟩ simpa only [Finset.coe_empty, subset_singleton_iff, mem_empty_iff_false, IsEmpty.forall_iff, imp_true_iff, Finset.notMem_empty, iInter_false, iInter_univ, true_and, exists_const] using hs theorem piiUnionInter_singleton_left (s : ι → Set α) (S : Set ι) : piiUnionInter (fun i => ({s i} : Set (Set α))) S = { s' : Set α | ∃ (t : Finset ι) (_ : ↑t ⊆ S), s' = ⋂ i ∈ t, s i } := by ext1 s' simp_rw [piiUnionInter, Set.mem_singleton_iff, exists_prop, Set.mem_setOf_eq] refine ⟨fun h => ?_, fun ⟨t, htS, h_eq⟩ => ⟨t, htS, s, fun _ _ => rfl, h_eq⟩⟩ grind theorem generateFrom_piiUnionInter_singleton_left (s : ι → Set α) (S : Set ι) : generateFrom (piiUnionInter (fun k => {s k}) S) = generateFrom { t | ∃ k ∈ S, s k = t } := by refine le_antisymm (generateFrom_le ?_) (generateFrom_mono ?_) · rintro _ ⟨I, hI, f, hf, rfl⟩ refine Finset.measurableSet_biInter _ fun m hm => measurableSet_generateFrom ?_ exact ⟨m, hI hm, (hf m hm).symm⟩ · rintro _ ⟨k, hk, rfl⟩ refine ⟨{k}, fun m hm => ?_, s, fun i _ => ?_, ?_⟩ · rw [Finset.mem_coe, Finset.mem_singleton] at hm rwa [hm] · exact Set.mem_singleton _ · simp only [Finset.mem_singleton, Set.iInter_iInter_eq_left] /-- If `π` is a family of π-systems, then `piiUnionInter π S` is a π-system. -/ theorem isPiSystem_piiUnionInter (π : ι → Set (Set α)) (hpi : ∀ x, IsPiSystem (π x)) (S : Set ι) : IsPiSystem (piiUnionInter π S) := by classical rintro t1 ⟨p1, hp1S, f1, hf1m, ht1_eq⟩ t2 ⟨p2, hp2S, f2, hf2m, ht2_eq⟩ h_nonempty simp_rw [piiUnionInter, Set.mem_setOf_eq] let g n := ite (n ∈ p1) (f1 n) Set.univ ∩ ite (n ∈ p2) (f2 n) Set.univ have hp_union_ss : ↑(p1 ∪ p2) ⊆ S := by simp only [hp1S, hp2S, Finset.coe_union, union_subset_iff, and_self_iff] use p1 ∪ p2, hp_union_ss, g have h_inter_eq : t1 ∩ t2 = ⋂ i ∈ p1 ∪ p2, g i := by rw [ht1_eq, ht2_eq] simp_rw [← Set.inf_eq_inter] ext1 x simp only [g, inf_eq_inter, mem_inter_iff, mem_iInter, Finset.mem_union] refine ⟨fun h i _ => ?_, fun h => ⟨fun i hi1 => ?_, fun i hi2 => ?_⟩⟩ · split_ifs with h_1 h_2 h_2 exacts [⟨h.1 i h_1, h.2 i h_2⟩, ⟨h.1 i h_1, Set.mem_univ _⟩, ⟨Set.mem_univ _, h.2 i h_2⟩, ⟨Set.mem_univ _, Set.mem_univ _⟩] · specialize h i (Or.inl hi1) rw [if_pos hi1] at h exact h.1 · specialize h i (Or.inr hi2) rw [if_pos hi2] at h exact h.2 refine ⟨fun n hn => ?_, h_inter_eq⟩ simp only [g] split_ifs with hn1 hn2 h · refine hpi n (f1 n) (hf1m n hn1) (f2 n) (hf2m n hn2) (Set.nonempty_iff_ne_empty.2 fun h => ?_) rw [h_inter_eq] at h_nonempty suffices h_empty : ⋂ i ∈ p1 ∪ p2, g i = ∅ from (Set.not_nonempty_iff_eq_empty.mpr h_empty) h_nonempty refine le_antisymm (Set.iInter_subset_of_subset n ?_) (Set.empty_subset _) refine Set.iInter_subset_of_subset hn ?_ simp_rw [g, if_pos hn1, if_pos hn2] exact h.subset · simp [hf1m n hn1] · simp [hf2m n h] · exact absurd hn (by simp [hn1, h]) theorem piiUnionInter_mono_left {π π' : ι → Set (Set α)} (h_le : ∀ i, π i ⊆ π' i) (S : Set ι) : piiUnionInter π S ⊆ piiUnionInter π' S := fun _ ⟨t, ht_mem, ft, hft_mem_pi, h_eq⟩ => ⟨t, ht_mem, ft, fun x hxt => h_le x (hft_mem_pi x hxt), h_eq⟩ theorem piiUnionInter_mono_right {π : ι → Set (Set α)} {S T : Set ι} (hST : S ⊆ T) : piiUnionInter π S ⊆ piiUnionInter π T := fun _ ⟨t, ht_mem, ft, hft_mem_pi, h_eq⟩ => ⟨t, ht_mem.trans hST, ft, hft_mem_pi, h_eq⟩ theorem generateFrom_piiUnionInter_le {m : MeasurableSpace α} (π : ι → Set (Set α)) (h : ∀ n, generateFrom (π n) ≤ m) (S : Set ι) : generateFrom (piiUnionInter π S) ≤ m := by refine generateFrom_le ?_ rintro t ⟨ht_p, _, ft, hft_mem_pi, rfl⟩ refine Finset.measurableSet_biInter _ fun x hx_mem => (h x) _ ?_ exact measurableSet_generateFrom (hft_mem_pi x hx_mem) theorem subset_piiUnionInter {π : ι → Set (Set α)} {S : Set ι} {i : ι} (his : i ∈ S) : π i ⊆ piiUnionInter π S := by have h_ss : {i} ⊆ S := by intro j hj rw [mem_singleton_iff] at hj rwa [hj] refine Subset.trans ?_ (piiUnionInter_mono_right h_ss) rw [piiUnionInter_singleton] exact subset_union_left theorem mem_piiUnionInter_of_measurableSet (m : ι → MeasurableSpace α) {S : Set ι} {i : ι} (hiS : i ∈ S) (s : Set α) (hs : MeasurableSet[m i] s) : s ∈ piiUnionInter (fun n => { s | MeasurableSet[m n] s }) S := subset_piiUnionInter hiS hs theorem le_generateFrom_piiUnionInter {π : ι → Set (Set α)} (S : Set ι) {x : ι} (hxS : x ∈ S) : generateFrom (π x) ≤ generateFrom (piiUnionInter π S) := generateFrom_mono (subset_piiUnionInter hxS) theorem measurableSet_iSup_of_mem_piiUnionInter (m : ι → MeasurableSpace α) (S : Set ι) (t : Set α) (ht : t ∈ piiUnionInter (fun n => { s | MeasurableSet[m n] s }) S) : MeasurableSet[⨆ i ∈ S, m i] t := by rcases ht with ⟨pt, hpt, ft, ht_m, rfl⟩ refine pt.measurableSet_biInter fun i hi => ?_ suffices h_le : m i ≤ ⨆ i ∈ S, m i from h_le (ft i) (ht_m i hi) have hi' : i ∈ S := hpt hi exact le_iSup₂ (f := fun i (_ : i ∈ S) => m i) i hi' theorem generateFrom_piiUnionInter_measurableSet (m : ι → MeasurableSpace α) (S : Set ι) : generateFrom (piiUnionInter (fun n => { s | MeasurableSet[m n] s }) S) = ⨆ i ∈ S, m i := by refine le_antisymm ?_ ?_ · rw [← @generateFrom_measurableSet α (⨆ i ∈ S, m i)] exact generateFrom_mono (measurableSet_iSup_of_mem_piiUnionInter m S) · refine iSup₂_le fun i hi => ?_ rw [← @generateFrom_measurableSet α (m i)] exact generateFrom_mono (mem_piiUnionInter_of_measurableSet m hi) end UnionInter namespace MeasurableSpace open scoped Function -- required for scoped `on` notation variable {α : Type*} /-! ## Dynkin systems and Π-λ theorem -/ /-- A Dynkin system is a collection of subsets of a type `α` that contains the empty set, is closed under complementation and under countable union of pairwise disjoint sets. The disjointness condition is the only difference with `σ`-algebras. The main purpose of Dynkin systems is to provide a powerful induction rule for σ-algebras generated by a collection of sets which is stable under intersection. A Dynkin system is also known as a "λ-system" or a "d-system". -/ structure DynkinSystem (α : Type*) where /-- Predicate saying that a given set is contained in the Dynkin system. -/ Has : Set α → Prop /-- A Dynkin system contains the empty set. -/ has_empty : Has ∅ /-- A Dynkin system is closed under complementation. -/ has_compl : ∀ {a}, Has a → Has aᶜ /-- A Dynkin system is closed under countable union of pairwise disjoint sets. Use a more general `MeasurableSpace.DynkinSystem.has_iUnion` instead. -/ has_iUnion_nat : ∀ {f : ℕ → Set α}, Pairwise (Disjoint on f) → (∀ i, Has (f i)) → Has (⋃ i, f i) namespace DynkinSystem @[ext] theorem ext : ∀ {d₁ d₂ : DynkinSystem α}, (∀ s : Set α, d₁.Has s ↔ d₂.Has s) → d₁ = d₂ | ⟨s₁, _, _, _⟩, ⟨s₂, _, _, _⟩, h => by have : s₁ = s₂ := funext fun x => propext <| h x subst this rfl variable (d : DynkinSystem α) theorem has_compl_iff {a} : d.Has aᶜ ↔ d.Has a := ⟨fun h => by simpa using d.has_compl h, fun h => d.has_compl h⟩ theorem has_univ : d.Has univ := by simpa using d.has_compl d.has_empty theorem has_iUnion {β} [Countable β] {f : β → Set α} (hd : Pairwise (Disjoint on f)) (h : ∀ i, d.Has (f i)) : d.Has (⋃ i, f i) := by cases nonempty_encodable β rw [← Encodable.iUnion_decode₂] exact d.has_iUnion_nat (Encodable.iUnion_decode₂_disjoint_on hd) fun n => Encodable.iUnion_decode₂_cases d.has_empty h theorem has_union {s₁ s₂ : Set α} (h₁ : d.Has s₁) (h₂ : d.Has s₂) (h : Disjoint s₁ s₂) : d.Has (s₁ ∪ s₂) := by rw [union_eq_iUnion] exact d.has_iUnion (pairwise_disjoint_on_bool.2 h) (Bool.forall_bool.2 ⟨h₂, h₁⟩) theorem has_diff {s₁ s₂ : Set α} (h₁ : d.Has s₁) (h₂ : d.Has s₂) (h : s₂ ⊆ s₁) : d.Has (s₁ \ s₂) := by apply d.has_compl_iff.1 simp only [diff_eq, compl_inter, compl_compl] exact d.has_union (d.has_compl h₁) h₂ (disjoint_compl_left.mono_right h) instance instLEDynkinSystem : LE (DynkinSystem α) where le m₁ m₂ := m₁.Has ≤ m₂.Has theorem le_def {a b : DynkinSystem α} : a ≤ b ↔ a.Has ≤ b.Has := Iff.rfl instance : PartialOrder (DynkinSystem α) := { DynkinSystem.instLEDynkinSystem with le_refl := fun _ _ => le_rfl le_trans := fun _ _ _ hab hbc => le_def.mpr (le_trans hab hbc) le_antisymm := fun _ _ h₁ h₂ => ext fun s => ⟨h₁ s, h₂ s⟩ } /-- Every measurable space (σ-algebra) forms a Dynkin system -/ def ofMeasurableSpace (m : MeasurableSpace α) : DynkinSystem α where Has := m.MeasurableSet' has_empty := m.measurableSet_empty has_compl {a} := m.measurableSet_compl a has_iUnion_nat {f} _ hf := m.measurableSet_iUnion f hf theorem ofMeasurableSpace_le_ofMeasurableSpace_iff {m₁ m₂ : MeasurableSpace α} : ofMeasurableSpace m₁ ≤ ofMeasurableSpace m₂ ↔ m₁ ≤ m₂ := Iff.rfl /-- The least Dynkin system containing a collection of basic sets. This inductive type gives the underlying collection of sets. -/ inductive GenerateHas (s : Set (Set α)) : Set α → Prop | basic : ∀ t ∈ s, GenerateHas s t | empty : GenerateHas s ∅ | compl : ∀ {a}, GenerateHas s a → GenerateHas s aᶜ | iUnion : ∀ {f : ℕ → Set α}, Pairwise (Disjoint on f) → (∀ i, GenerateHas s (f i)) → GenerateHas s (⋃ i, f i) theorem generateHas_compl {C : Set (Set α)} {s : Set α} : GenerateHas C sᶜ ↔ GenerateHas C s := by refine ⟨?_, GenerateHas.compl⟩ intro h convert GenerateHas.compl h simp /-- The least Dynkin system containing a collection of basic sets. -/ def generate (s : Set (Set α)) : DynkinSystem α where Has := GenerateHas s has_empty := GenerateHas.empty has_compl {_} := GenerateHas.compl has_iUnion_nat {_} := GenerateHas.iUnion theorem generateHas_def {C : Set (Set α)} : (generate C).Has = GenerateHas C := rfl instance : Inhabited (DynkinSystem α) := ⟨generate univ⟩ /-- If a Dynkin system is closed under binary intersection, then it forms a `σ`-algebra. -/ def toMeasurableSpace (h_inter : ∀ s₁ s₂, d.Has s₁ → d.Has s₂ → d.Has (s₁ ∩ s₂)) : MeasurableSpace α where MeasurableSet' := d.Has measurableSet_empty := d.has_empty measurableSet_compl _ h := d.has_compl h measurableSet_iUnion f hf := by rw [← iUnion_disjointed] exact d.has_iUnion (disjoint_disjointed _) fun n => disjointedRec (fun (t : Set α) i h => h_inter _ _ h <| d.has_compl <| hf i) (hf n) theorem ofMeasurableSpace_toMeasurableSpace (h_inter : ∀ s₁ s₂, d.Has s₁ → d.Has s₂ → d.Has (s₁ ∩ s₂)) : ofMeasurableSpace (d.toMeasurableSpace h_inter) = d := ext fun _ => Iff.rfl /-- If `s` is in a Dynkin system `d`, we can form the new Dynkin system `{s ∩ t | t ∈ d}`. -/ def restrictOn {s : Set α} (h : d.Has s) : DynkinSystem α where Has t := d.Has (t ∩ s) has_empty := by simp [d.has_empty] has_compl {t} hts := by have : tᶜ ∩ s = (t ∩ s)ᶜ \ sᶜ := Set.ext fun x => by by_cases h : x ∈ s <;> simp [h] simp_rw [this] exact d.has_diff (d.has_compl hts) (d.has_compl h) (compl_subset_compl.mpr inter_subset_right) has_iUnion_nat {f} hd hf := by rw [iUnion_inter] refine d.has_iUnion_nat ?_ hf exact hd.mono fun i j => Disjoint.mono inter_subset_left inter_subset_left theorem generate_le {s : Set (Set α)} (h : ∀ t ∈ s, d.Has t) : generate s ≤ d := fun _ ht => ht.recOn h d.has_empty (fun {_} _ h => d.has_compl h) fun {_} hd _ hf => d.has_iUnion hd hf theorem generate_has_subset_generate_measurable {C : Set (Set α)} {s : Set α} (hs : (generate C).Has s) : MeasurableSet[generateFrom C] s := generate_le (ofMeasurableSpace (generateFrom C)) (fun _ => measurableSet_generateFrom) s hs theorem generate_inter {s : Set (Set α)} (hs : IsPiSystem s) {t₁ t₂ : Set α} (ht₁ : (generate s).Has t₁) (ht₂ : (generate s).Has t₂) : (generate s).Has (t₁ ∩ t₂) := have : generate s ≤ (generate s).restrictOn ht₂ := generate_le _ fun s₁ hs₁ => have : (generate s).Has s₁ := GenerateHas.basic s₁ hs₁ have : generate s ≤ (generate s).restrictOn this := generate_le _ fun s₂ hs₂ => show (generate s).Has (s₂ ∩ s₁) from (s₂ ∩ s₁).eq_empty_or_nonempty.elim (fun h => h.symm ▸ GenerateHas.empty) fun h => GenerateHas.basic _ <| hs _ hs₂ _ hs₁ h have : (generate s).Has (t₂ ∩ s₁) := this _ ht₂ show (generate s).Has (s₁ ∩ t₂) by rwa [inter_comm] this _ ht₁ /-- **Dynkin's π-λ theorem**: Given a collection of sets closed under binary intersections, then the Dynkin system it generates is equal to the σ-algebra it generates. This result is known as the π-λ theorem. A collection of sets closed under binary intersection is called a π-system (often requiring additionally that it is non-empty, but we drop this condition in the formalization). -/ theorem generateFrom_eq {s : Set (Set α)} (hs : IsPiSystem s) : generateFrom s = (generate s).toMeasurableSpace fun _ _ => generate_inter hs := le_antisymm (generateFrom_le fun t ht => GenerateHas.basic t ht) (ofMeasurableSpace_le_ofMeasurableSpace_iff.mp <| by rw [ofMeasurableSpace_toMeasurableSpace] exact generate_le _ fun t ht => measurableSet_generateFrom ht) end DynkinSystem /-- Induction principle for measurable sets. If `s` is a π-system that generates the product `σ`-algebra on `α` and a predicate `C` defined on measurable sets is true - on the empty set; - on each set `t ∈ s`; - on the complement of a measurable set that satisfies `C`; - on the union of a sequence of pairwise disjoint measurable sets that satisfy `C`, then it is true on all measurable sets in `α`. -/ @[elab_as_elim] theorem induction_on_inter {m : MeasurableSpace α} {C : ∀ s : Set α, MeasurableSet s → Prop} {s : Set (Set α)} (h_eq : m = generateFrom s) (h_inter : IsPiSystem s) (empty : C ∅ .empty) (basic : ∀ t (ht : t ∈ s), C t <| h_eq ▸ .basic t ht) (compl : ∀ t (htm : MeasurableSet t), C t htm → C tᶜ htm.compl) (iUnion : ∀ (f : ℕ → Set α), Pairwise (Disjoint on f) → ∀ (hfm : ∀ i, MeasurableSet (f i)), (∀ i, C (f i) (hfm i)) → C (⋃ i, f i) (.iUnion hfm)) : ∀ t (ht : MeasurableSet t), C t ht := by have eq : MeasurableSet = DynkinSystem.GenerateHas s := by rw [h_eq, DynkinSystem.generateFrom_eq h_inter] rfl suffices ∀ t (ht : DynkinSystem.GenerateHas s t), C t (eq ▸ ht) from fun t ht ↦ this t (eq ▸ ht) intro t ht induction ht with | basic u hu => exact basic u hu | empty => exact empty | @compl u hu ihu => exact compl _ (eq ▸ hu) ihu | @iUnion f hfd hf ihf => exact iUnion f hfd (eq ▸ hf) ihf end MeasurableSpace
Set.lean
/- Copyright (c) 2024 Markus Himmel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Markus Himmel, Timothy Carlin-Burns -/ import Mathlib.Data.Set.Lattice import Mathlib.Logic.Small.Basic /-! # Results about `Small` on coerced sets -/ universe u u1 u2 u3 u4 variable {α : Type u1} {β : Type u2} {γ : Type u3} {ι : Type u4} theorem small_subset {s t : Set α} (hts : t ⊆ s) [Small.{u} s] : Small.{u} t := small_of_injective (Set.inclusion_injective hts) instance small_powerset (s : Set α) [Small.{u} s] : Small.{u} (𝒫 s) := small_map (Equiv.Set.powerset s) instance small_setProd (s : Set α) (t : Set β) [Small.{u} s] [Small.{u} t] : Small.{u} (s ×ˢ t : Set (α × β)) := small_of_injective (Equiv.Set.prod s t).injective instance small_setPi {β : α → Type u2} (s : (a : α) → Set (β a)) [Small.{u} α] [∀ a, Small.{u} (s a)] : Small.{u} (Set.pi Set.univ s) := small_of_injective (Equiv.Set.univPi s).injective instance small_range (f : α → β) [Small.{u} α] : Small.{u} (Set.range f) := small_of_surjective Set.surjective_onto_range instance small_image (f : α → β) (s : Set α) [Small.{u} s] : Small.{u} (f '' s) := small_of_surjective Set.surjective_onto_image instance small_image2 (f : α → β → γ) (s : Set α) (t : Set β) [Small.{u} s] [Small.{u} t] : Small.{u} (Set.image2 f s t) := by rw [← Set.image_uncurry_prod] infer_instance theorem small_univ_iff : Small.{u} (@Set.univ α) ↔ Small.{u} α := small_congr <| Equiv.Set.univ α instance small_univ [h : Small.{u} α] : Small.{u} (@Set.univ α) := small_univ_iff.2 h instance small_union (s t : Set α) [Small.{u} s] [Small.{u} t] : Small.{u} (s ∪ t : Set α) := by rw [← Subtype.range_val (s := s), ← Subtype.range_val (s := t), ← Set.Sum.elim_range] infer_instance instance small_iUnion [Small.{u} ι] (s : ι → Set α) [∀ i, Small.{u} (s i)] : Small.{u} (⋃ i, s i) := small_of_surjective <| Set.sigmaToiUnion_surjective _ instance small_sUnion (s : Set (Set α)) [Small.{u} s] [∀ t : s, Small.{u} t] : Small.{u} (⋃₀ s) := Set.sUnion_eq_iUnion ▸ small_iUnion _ instance small_biUnion (s : Set ι) [Small.{u} s] (f : (i : ι) → i ∈ s → Set α) [∀ i hi, Small.{u} (f i hi)] : Small.{u} (⋃ i, ⋃ hi, f i hi) := Set.biUnion_eq_iUnion s f ▸ small_iUnion _ instance small_insert (x : α) (s : Set α) [Small.{u} s] : Small.{u} (insert x s : Set α) := Set.insert_eq x s ▸ small_union.{u} {x} s instance small_diff (s t : Set α) [Small.{u} s] : Small.{u} (s \ t : Set α) := small_subset (Set.diff_subset) instance small_sep (s : Set α) (P : α → Prop) [Small.{u} s] : Small.{u} { x | x ∈ s ∧ P x} := small_subset (Set.sep_subset s P) instance small_inter_of_left (s t : Set α) [Small.{u} s] : Small.{u} (s ∩ t : Set α) := small_subset Set.inter_subset_left instance small_inter_of_right (s t : Set α) [Small.{u} t] : Small.{u} (s ∩ t : Set α) := small_subset Set.inter_subset_right theorem small_iInter (s : ι → Set α) (i : ι) [Small.{u} (s i)] : Small.{u} (⋂ i, s i) := small_subset (Set.iInter_subset s i) instance small_iInter' [Nonempty ι] (s : ι → Set α) [∀ i, Small.{u} (s i)] : Small.{u} (⋂ i, s i) := let ⟨i⟩ : Nonempty ι := inferInstance small_iInter s i theorem small_sInter {s : Set (Set α)} {t : Set α} (ht : t ∈ s) [Small.{u} t] : Small.{u} (⋂₀ s) := Set.sInter_eq_iInter ▸ small_iInter _ ⟨t, ht⟩ instance small_sInter' {s : Set (Set α)} [Nonempty s] [∀ t : s, Small.{u} t] : Small.{u} (⋂₀ s) := let ⟨t⟩ : Nonempty s := inferInstance small_sInter t.prop theorem small_biInter {s : Set ι} {i : ι} (hi : i ∈ s) (f : (i : ι) → i ∈ s → Set α) [Small.{u} (f i hi)] : Small.{u} (⋂ i, ⋂ hi, f i hi) := Set.biInter_eq_iInter s f ▸ small_iInter _ ⟨i, hi⟩ instance small_biInter' (s : Set ι) [Nonempty s] (f : (i : ι) → i ∈ s → Set α) [∀ i hi, Small.{u} (f i hi)] : Small.{u} (⋂ i, ⋂ hi, f i hi) := let ⟨t⟩ : Nonempty s := inferInstance small_biInter t.prop f theorem small_empty : Small.{u} (∅ : Set α) := inferInstance theorem small_single (x : α) : Small.{u} ({x} : Set α) := inferInstance theorem small_pair (x y : α) : Small.{u} ({x, y} : Set α) := inferInstance
Fix.lean
/- Copyright (c) 2020 Simon Hudon. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Simon Hudon -/ import Mathlib.Data.Part import Mathlib.Data.Nat.Find import Mathlib.Data.Nat.Upto import Mathlib.Data.Stream.Defs import Mathlib.Tactic.Common /-! # Fixed point This module defines a generic `fix` operator for defining recursive computations that are not necessarily well-founded or productive. An instance is defined for `Part`. ## Main definition * class `Fix` * `Part.fix` -/ universe u v variable {α : Type*} {β : α → Type*} /-- `Fix α` provides a `fix` operator to define recursive computation via the fixed point of function of type `α → α`. -/ class Fix (α : Type*) where /-- `fix f` represents the computation of a fixed point for `f`. -/ fix : (α → α) → α namespace Part open Part Nat Nat.Upto section Basic variable (f : (∀ a, Part (β a)) → (∀ a, Part (β a))) /-- A series of successive, finite approximation of the fixed point of `f`, defined by `approx f n = f^[n] ⊥`. The limit of this chain is the fixed point of `f`. -/ def Fix.approx : Stream' (∀ a, Part (β a)) | 0 => ⊥ | Nat.succ i => f (Fix.approx i) /-- loop body for finding the fixed point of `f` -/ def fixAux {p : ℕ → Prop} (i : Nat.Upto p) (g : ∀ j : Nat.Upto p, i < j → ∀ a, Part (β a)) : ∀ a, Part (β a) := f fun x : α => (assert ¬p i.val) fun h : ¬p i.val => g (i.succ h) (Nat.lt_succ_self _) x /-- The least fixed point of `f`. If `f` is a continuous function (according to complete partial orders), it satisfies the equations: 1. `fix f = f (fix f)` (is a fixed point) 2. `∀ X, f X ≤ X → fix f ≤ X` (least fixed point) -/ protected def fix (x : α) : Part (β x) := (Part.assert (∃ i, (Fix.approx f i x).Dom)) fun h => WellFounded.fix.{1} (Nat.Upto.wf h) (fixAux f) Nat.Upto.zero x open Classical in protected theorem fix_def {x : α} (h' : ∃ i, (Fix.approx f i x).Dom) : Part.fix f x = Fix.approx f (Nat.succ (Nat.find h')) x := by let p := fun i : ℕ => (Fix.approx f i x).Dom have : p (Nat.find h') := Nat.find_spec h' generalize hk : Nat.find h' = k replace hk : Nat.find h' = k + (@Upto.zero p).val := hk rw [hk] at this revert hk dsimp [Part.fix]; rw [assert_pos h']; revert this generalize Upto.zero = z; intro _this hk suffices ∀ x' hwf, WellFounded.fix hwf (fixAux f) z x' = Fix.approx f (succ k) x' from this _ _ induction k generalizing z with | zero => intro x' _ rw [Fix.approx, WellFounded.fix_eq, fixAux] congr ext x : 1 rw [assert_neg] · rfl · rw [Nat.zero_add] at _this simpa only [not_not, Coe] | succ n n_ih => intro x' _ rw [Fix.approx, WellFounded.fix_eq, fixAux] congr ext : 1 have hh : ¬(Fix.approx f z.val x).Dom := by apply Nat.find_min h' omega rw [succ_add_eq_add_succ] at _this hk rw [assert_pos hh, n_ih (Upto.succ z hh) _this hk] theorem fix_def' {x : α} (h' : ¬∃ i, (Fix.approx f i x).Dom) : Part.fix f x = none := by dsimp [Part.fix] rw [assert_neg h'] end Basic end Part namespace Part instance hasFix : Fix (Part α) := ⟨fun f => Part.fix (fun x u => f (x u)) ()⟩ end Part open Sigma namespace Pi instance Part.hasFix {β} : Fix (α → Part β) := ⟨Part.fix⟩ end Pi
SumIteratedDerivative.lean
/- Copyright (c) 2022 Yuyang Zhao. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yuyang Zhao -/ import Mathlib.Algebra.Polynomial.AlgebraMap import Mathlib.Algebra.Polynomial.BigOperators import Mathlib.Algebra.Polynomial.Degree.Lemmas import Mathlib.Algebra.Polynomial.Derivative import Mathlib.Algebra.Polynomial.Eval.SMul /-! # Sum of iterated derivatives This file introduces `Polynomial.sumIDeriv`, the sum of the iterated derivatives of a polynomial, as a linear map. This is used in particular in the proof of the Lindemann-Weierstrass theorem (see https://github.com/leanprover-community/mathlib4/pull/6718). ## Main results * `Polynomial.sumIDeriv`: Sum of iterated derivatives of a polynomial, as a linear map * `Polynomial.sumIDeriv_apply`, `Polynomial.sumIDeriv_apply_of_lt`, `Polynomial.sumIDeriv_apply_of_le`: `Polynomial.sumIDeriv` expressed as a sum * `Polynomial.sumIDeriv_C`, `Polynomial.sumIDeriv_X`: `Polynomial.sumIDeriv` applied to simple polynomials * `Polynomial.sumIDeriv_map`: `Polynomial.sumIDeriv` commutes with `Polynomial.map` * `Polynomial.sumIDeriv_derivative`: `Polynomial.sumIDeriv` commutes with `Polynomial.derivative` * `Polynomial.sumIDeriv_eq_self_add`: `sumIDeriv p = p + derivative (sumIDeriv p)` * `Polynomial.exists_iterate_derivative_eq_factorial_smul`: the `k`'th iterated derivative of a polynomial has a common factor `k!` * `Polynomial.aeval_iterate_derivative_of_lt`, `Polynomial.aeval_iterate_derivative_self`, `Polynomial.aeval_iterate_derivative_of_ge`: applying `Polynomial.aeval` to iterated derivatives * `Polynomial.aeval_sumIDeriv`, `Polynomial.aeval_sumIDeriv_of_pos`: applying `Polynomial.aeval` to `Polynomial.sumIDeriv` -/ open Finset open scoped Nat namespace Polynomial variable {R S : Type*} section Semiring variable [Semiring R] [Semiring S] /-- Sum of iterated derivatives of a polynomial, as a linear map This definition does not allow different weights for the derivatives. It is likely that it could be extended to allow them, but this was not needed for the initial use case (the integration by parts of the integral $I_i$ in the [Lindemann-Weierstrass](https://en.wikipedia.org/wiki/Lindemann%E2%80%93Weierstrass_theorem) theorem). -/ noncomputable def sumIDeriv : R[X] →ₗ[R] R[X] := Finsupp.lsum ℕ (fun _ ↦ LinearMap.id) ∘ₗ derivativeFinsupp theorem sumIDeriv_apply (p : R[X]) : sumIDeriv p = ∑ i ∈ range (p.natDegree + 1), derivative^[i] p := by dsimp [sumIDeriv] exact Finsupp.sum_of_support_subset _ (by simp) _ (by simp) theorem sumIDeriv_apply_of_lt {p : R[X]} {n : ℕ} (hn : p.natDegree < n) : sumIDeriv p = ∑ i ∈ range n, derivative^[i] p := by dsimp [sumIDeriv] exact Finsupp.sum_of_support_subset _ (by simp [hn]) _ (by simp) theorem sumIDeriv_apply_of_le {p : R[X]} {n : ℕ} (hn : p.natDegree ≤ n) : sumIDeriv p = ∑ i ∈ range (n + 1), derivative^[i] p := by dsimp [sumIDeriv] exact Finsupp.sum_of_support_subset _ (by simp [Nat.lt_succ, hn]) _ (by simp) @[simp] theorem sumIDeriv_C (a : R) : sumIDeriv (C a) = C a := by rw [sumIDeriv_apply, natDegree_C, zero_add, sum_range_one, Function.iterate_zero_apply] @[simp] theorem sumIDeriv_X : sumIDeriv X = X + C 1 := by rw [sumIDeriv_apply, natDegree_X, sum_range_succ, sum_range_one, Function.iterate_zero_apply, Function.iterate_one, derivative_X, eq_natCast, Nat.cast_one] @[simp] theorem sumIDeriv_map (p : R[X]) (f : R →+* S) : sumIDeriv (p.map f) = (sumIDeriv p).map f := by let n := max (p.map f).natDegree p.natDegree rw [sumIDeriv_apply_of_le (le_max_left _ _ : _ ≤ n)] rw [sumIDeriv_apply_of_le (le_max_right _ _ : _ ≤ n)] simp_rw [Polynomial.map_sum, iterate_derivative_map p f] theorem sumIDeriv_derivative (p : R[X]) : sumIDeriv (derivative p) = derivative (sumIDeriv p) := by rw [sumIDeriv_apply_of_le ((natDegree_derivative_le p).trans tsub_le_self), sumIDeriv_apply, derivative_sum] simp_rw [← Function.iterate_succ_apply, Function.iterate_succ_apply'] theorem sumIDeriv_eq_self_add (p : R[X]) : sumIDeriv p = p + derivative (sumIDeriv p) := by rw [sumIDeriv_apply, derivative_sum, sum_range_succ', sum_range_succ, add_comm, ← add_zero (Finset.sum _ _)] simp_rw [← Function.iterate_succ_apply' derivative, Nat.succ_eq_add_one, Function.iterate_zero_apply, iterate_derivative_eq_zero (Nat.lt_succ_self _)] theorem exists_iterate_derivative_eq_factorial_smul (p : R[X]) (k : ℕ) : ∃ gp : R[X], gp.natDegree ≤ p.natDegree - k ∧ derivative^[k] p = k ! • gp := by refine ⟨_, (natDegree_sum_le _ _).trans ?_, iterate_derivative_eq_factorial_smul_sum p k⟩ rw [fold_max_le] refine ⟨Nat.zero_le _, fun i hi => ?_⟩ dsimp only [Function.comp] exact (natDegree_C_mul_le _ _).trans <| (natDegree_X_pow_le _).trans <| (le_natDegree_of_mem_supp _ hi).trans <| natDegree_iterate_derivative _ _ end Semiring section CommSemiring variable [CommSemiring R] {A : Type*} [CommRing A] [Algebra R A] theorem aeval_iterate_derivative_of_lt (p : R[X]) (q : ℕ) (r : A) {p' : A[X]} (hp : p.map (algebraMap R A) = (X - C r) ^ q * p') {k : ℕ} (hk : k < q) : aeval r (derivative^[k] p) = 0 := by have h (x) : (X - C r) ^ (q - (k - x)) = (X - C r) ^ 1 * (X - C r) ^ (q - (k - x) - 1) := by rw [← pow_add, add_tsub_cancel_of_le] rw [Nat.lt_iff_add_one_le] at hk exact (le_tsub_of_add_le_left hk).trans (tsub_le_tsub_left (tsub_le_self : _ ≤ k) _) rw [aeval_def, eval₂_eq_eval_map, ← iterate_derivative_map] simp_rw [hp, iterate_derivative_mul, iterate_derivative_X_sub_pow, ← smul_mul_assoc, smul_smul, h, ← mul_smul_comm, mul_assoc, ← mul_sum, eval_mul, pow_one, eval_sub, eval_X, eval_C, sub_self, zero_mul] theorem aeval_iterate_derivative_self (p : R[X]) (q : ℕ) (r : A) {p' : A[X]} (hp : p.map (algebraMap R A) = (X - C r) ^ q * p') : aeval r (derivative^[q] p) = q ! • p'.eval r := by have h (x) (h : 1 ≤ x) (h' : x ≤ q) : (X - C r) ^ (q - (q - x)) = (X - C r) ^ 1 * (X - C r) ^ (q - (q - x) - 1) := by rw [← pow_add, add_tsub_cancel_of_le] rwa [tsub_tsub_cancel_of_le h'] rw [aeval_def, eval₂_eq_eval_map, ← iterate_derivative_map] simp_rw [hp, iterate_derivative_mul, iterate_derivative_X_sub_pow, ← smul_mul_assoc, smul_smul] rw [sum_range_succ', Nat.choose_zero_right, one_mul, tsub_zero, Nat.descFactorial_self, tsub_self, pow_zero, smul_mul_assoc, one_mul, Function.iterate_zero_apply, eval_add, eval_smul] convert zero_add _ rw [eval_finset_sum] apply sum_eq_zero intro x hx rw [h (x + 1) le_add_self (Nat.add_one_le_iff.mpr (mem_range.mp hx)), pow_one, eval_mul, eval_smul, eval_mul, eval_sub, eval_X, eval_C, sub_self, zero_mul, smul_zero, zero_mul] variable (A) theorem aeval_iterate_derivative_of_ge (p : R[X]) (q : ℕ) {k : ℕ} (hk : q ≤ k) : ∃ gp : R[X], gp.natDegree ≤ p.natDegree - k ∧ ∀ r : A, aeval r (derivative^[k] p) = q ! • aeval r gp := by obtain ⟨p', p'_le, hp'⟩ := exists_iterate_derivative_eq_factorial_smul p k obtain ⟨k, rfl⟩ := Nat.exists_eq_add_of_le hk refine ⟨((q + k).descFactorial k : R[X]) * p', (natDegree_C_mul_le _ _).trans p'_le, fun r => ?_⟩ simp_rw [hp', nsmul_eq_mul, map_mul, map_natCast, ← mul_assoc, ← Nat.cast_mul, Nat.add_descFactorial_eq_ascFactorial, Nat.factorial_mul_ascFactorial] theorem aeval_sumIDeriv_eq_eval (p : R[X]) (r : A) : aeval r (sumIDeriv p) = eval r (sumIDeriv (map (algebraMap R A) p)) := by rw [aeval_def, eval, sumIDeriv_map, eval₂_map, RingHom.id_comp] theorem aeval_sumIDeriv (p : R[X]) (q : ℕ) : ∃ gp : R[X], gp.natDegree ≤ p.natDegree - q ∧ ∀ (r : A), (X - C r) ^ q ∣ p.map (algebraMap R A) → aeval r (sumIDeriv p) = q ! • aeval r gp := by have h (k) : ∃ gp : R[X], gp.natDegree ≤ p.natDegree - q ∧ ∀ (r : A), (X - C r) ^ q ∣ p.map (algebraMap R A) → aeval r (derivative^[k] p) = q ! • aeval r gp := by cases lt_or_ge k q with | inl hk => use 0 rw [natDegree_zero] use Nat.zero_le _ intro r ⟨p', hp⟩ rw [map_zero, smul_zero, aeval_iterate_derivative_of_lt p q r hp hk] | inr hk => obtain ⟨gp, gp_le, h⟩ := aeval_iterate_derivative_of_ge A p q hk exact ⟨gp, gp_le.trans (tsub_le_tsub_left hk _), fun r _ => h r⟩ choose c h using h choose c_le hc using h refine ⟨(range (p.natDegree + 1)).sum c, ?_, ?_⟩ · refine (natDegree_sum_le _ _).trans ?_ rw [fold_max_le] exact ⟨Nat.zero_le _, fun i _ => c_le i⟩ intro r ⟨p', hp⟩ rw [sumIDeriv_apply, map_sum]; simp_rw [hc _ r ⟨_, hp⟩, map_sum, smul_sum] theorem aeval_sumIDeriv_of_pos [Nontrivial A] [NoZeroDivisors A] (p : R[X]) {q : ℕ} (hq : 0 < q) (inj_amap : Function.Injective (algebraMap R A)) : ∃ gp : R[X], gp.natDegree ≤ p.natDegree - q ∧ ∀ (r : A) {p' : A[X]}, p.map (algebraMap R A) = (X - C r) ^ (q - 1) * p' → aeval r (sumIDeriv p) = (q - 1)! • p'.eval r + q ! • aeval r gp := by rcases eq_or_ne p 0 with (rfl | p0) · use 0 rw [natDegree_zero] use Nat.zero_le _ intro r p' hp rw [map_zero, map_zero, smul_zero, add_zero] rw [Polynomial.map_zero] at hp replace hp := (mul_eq_zero.mp hp.symm).resolve_left ?_ · rw [hp, eval_zero, smul_zero] exact fun h => X_sub_C_ne_zero r (pow_eq_zero h) let c k := if hk : q ≤ k then (aeval_iterate_derivative_of_ge A p q hk).choose else 0 have c_le (k) : (c k).natDegree ≤ p.natDegree - k := by dsimp only [c] split_ifs with h · exact (aeval_iterate_derivative_of_ge A p q h).choose_spec.1 · rw [natDegree_zero]; exact Nat.zero_le _ have hc (k) (hk : q ≤ k) : ∀ (r : A), aeval r (derivative^[k] p) = q ! • aeval r (c k) := by simp_rw [c, dif_pos hk] exact (aeval_iterate_derivative_of_ge A p q hk).choose_spec.2 refine ⟨∑ x ∈ Ico q (p.natDegree + 1), c x, ?_, ?_⟩ · refine (natDegree_sum_le _ _).trans ?_ rw [fold_max_le] exact ⟨Nat.zero_le _, fun i hi => (c_le i).trans (tsub_le_tsub_left (mem_Ico.mp hi).1 _)⟩ intro r p' hp have : range (p.natDegree + 1) = range q ∪ Ico q (p.natDegree + 1) := by rw [range_eq_Ico, Ico_union_Ico_eq_Ico hq.le] rw [← tsub_le_iff_right] calc q - 1 ≤ q - 1 + p'.natDegree := le_self_add _ = (p.map <| algebraMap R A).natDegree := by rw [hp, natDegree_mul, natDegree_pow, natDegree_X_sub_C, mul_one, ← Nat.sub_add_comm (Nat.one_le_of_lt hq)] · exact pow_ne_zero _ (X_sub_C_ne_zero r) · rintro rfl rw [mul_zero, Polynomial.map_eq_zero_iff inj_amap] at hp exact p0 hp _ ≤ p.natDegree := natDegree_map_le rw [← zero_add ((q - 1)! • p'.eval r)] rw [sumIDeriv_apply, map_sum, map_sum, this] have : range q = range (q - 1 + 1) := by rw [tsub_add_cancel_of_le (Nat.one_le_of_lt hq)] rw [sum_union, this, sum_range_succ] · congr 2 · apply sum_eq_zero exact fun x hx => aeval_iterate_derivative_of_lt p _ r hp (mem_range.mp hx) · rw [← aeval_iterate_derivative_self _ _ _ hp] · rw [smul_sum, sum_congr rfl] intro k hk exact hc k (mem_Ico.mp hk).1 r · rw [range_eq_Ico, disjoint_iff_inter_eq_empty, eq_empty_iff_forall_notMem] intro x hx rw [mem_inter, mem_Ico, mem_Ico] at hx exact hx.1.2.not_ge hx.2.1 end CommSemiring theorem eval_sumIDeriv_of_pos [CommRing R] [Nontrivial R] [NoZeroDivisors R] (p : R[X]) {q : ℕ} (hq : 0 < q) : ∃ gp : R[X], gp.natDegree ≤ p.natDegree - q ∧ ∀ (r : R) {p' : R[X]}, p = ((X : R[X]) - C r) ^ (q - 1) * p' → eval r (sumIDeriv p) = (q - 1)! • p'.eval r + q ! • eval r gp := by simpa using aeval_sumIDeriv_of_pos R p hq Function.injective_id end Polynomial
UniformEmbedding.lean
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Sébastien Gouëzel, Patrick Massot -/ import Mathlib.Topology.UniformSpace.Cauchy import Mathlib.Topology.UniformSpace.Separation import Mathlib.Topology.DenseEmbedding /-! # Uniform embeddings of uniform spaces. Extension of uniform continuous functions. -/ open Filter Function Set Uniformity Topology section universe u v w variable {α : Type u} {β : Type v} {γ : Type w} [UniformSpace α] [UniformSpace β] [UniformSpace γ] {f : α → β} /-! ### Uniform inducing maps -/ /-- A map `f : α → β` between uniform spaces is called *uniform inducing* if the uniformity filter on `α` is the pullback of the uniformity filter on `β` under `Prod.map f f`. If `α` is a separated space, then this implies that `f` is injective, hence it is a `IsUniformEmbedding`. -/ @[mk_iff] structure IsUniformInducing (f : α → β) : Prop where /-- The uniformity filter on the domain is the pullback of the uniformity filter on the codomain under `Prod.map f f`. -/ comap_uniformity : comap (fun x : α × α => (f x.1, f x.2)) (𝓤 β) = 𝓤 α lemma isUniformInducing_iff_uniformSpace {f : α → β} : IsUniformInducing f ↔ ‹UniformSpace β›.comap f = ‹UniformSpace α› := by rw [isUniformInducing_iff, UniformSpace.ext_iff, Filter.ext_iff] rfl protected alias ⟨IsUniformInducing.comap_uniformSpace, _⟩ := isUniformInducing_iff_uniformSpace lemma isUniformInducing_iff' {f : α → β} : IsUniformInducing f ↔ UniformContinuous f ∧ comap (Prod.map f f) (𝓤 β) ≤ 𝓤 α := by rw [isUniformInducing_iff, UniformContinuous, tendsto_iff_comap, le_antisymm_iff, and_comm]; rfl protected lemma Filter.HasBasis.isUniformInducing_iff {ι ι'} {p : ι → Prop} {p' : ι' → Prop} {s s'} (h : (𝓤 α).HasBasis p s) (h' : (𝓤 β).HasBasis p' s') {f : α → β} : IsUniformInducing f ↔ (∀ i, p' i → ∃ j, p j ∧ ∀ x y, (x, y) ∈ s j → (f x, f y) ∈ s' i) ∧ (∀ j, p j → ∃ i, p' i ∧ ∀ x y, (f x, f y) ∈ s' i → (x, y) ∈ s j) := by simp [isUniformInducing_iff', h.uniformContinuous_iff h', (h'.comap _).le_basis_iff h, subset_def] theorem IsUniformInducing.mk' {f : α → β} (h : ∀ s, s ∈ 𝓤 α ↔ ∃ t ∈ 𝓤 β, ∀ x y : α, (f x, f y) ∈ t → (x, y) ∈ s) : IsUniformInducing f := ⟨by simp [eq_comm, Filter.ext_iff, subset_def, h]⟩ theorem IsUniformInducing.id : IsUniformInducing (@id α) := ⟨by rw [← Prod.map_def, Prod.map_id, comap_id]⟩ theorem IsUniformInducing.comp {g : β → γ} (hg : IsUniformInducing g) {f : α → β} (hf : IsUniformInducing f) : IsUniformInducing (g ∘ f) := ⟨by rw [← hf.1, ← hg.1, comap_comap]; rfl⟩ theorem IsUniformInducing.of_comp_iff {g : β → γ} (hg : IsUniformInducing g) {f : α → β} : IsUniformInducing (g ∘ f) ↔ IsUniformInducing f := by refine ⟨fun h ↦ ?_, hg.comp⟩ rw [isUniformInducing_iff, ← hg.comap_uniformity, comap_comap, ← h.comap_uniformity, Function.comp_def, Function.comp_def] theorem IsUniformInducing.basis_uniformity {f : α → β} (hf : IsUniformInducing f) {ι : Sort*} {p : ι → Prop} {s : ι → Set (β × β)} (H : (𝓤 β).HasBasis p s) : (𝓤 α).HasBasis p fun i => Prod.map f f ⁻¹' s i := hf.1 ▸ H.comap _ theorem IsUniformInducing.cauchy_map_iff {f : α → β} (hf : IsUniformInducing f) {F : Filter α} : Cauchy (map f F) ↔ Cauchy F := by simp only [Cauchy, map_neBot_iff, prod_map_map_eq, map_le_iff_le_comap, ← hf.comap_uniformity] theorem IsUniformInducing.of_comp {f : α → β} {g : β → γ} (hf : UniformContinuous f) (hg : UniformContinuous g) (hgf : IsUniformInducing (g ∘ f)) : IsUniformInducing f := by refine ⟨le_antisymm ?_ hf.le_comap⟩ rw [← hgf.1, ← Prod.map_def, ← Prod.map_def, ← Prod.map_comp_map f f g g, ← comap_comap] exact comap_mono hg.le_comap theorem IsUniformInducing.uniformContinuous {f : α → β} (hf : IsUniformInducing f) : UniformContinuous f := (isUniformInducing_iff'.1 hf).1 theorem IsUniformInducing.uniformContinuous_iff {f : α → β} {g : β → γ} (hg : IsUniformInducing g) : UniformContinuous f ↔ UniformContinuous (g ∘ f) := by dsimp only [UniformContinuous, Tendsto] simp only [← hg.comap_uniformity, ← map_le_iff_le_comap, Filter.map_map, Function.comp_def] protected theorem IsUniformInducing.isUniformInducing_comp_iff {f : α → β} {g : β → γ} (hg : IsUniformInducing g) : IsUniformInducing (g ∘ f) ↔ IsUniformInducing f := by simp only [isUniformInducing_iff, ← hg.comap_uniformity, comap_comap, Function.comp_def] theorem IsUniformInducing.uniformContinuousOn_iff {f : α → β} {g : β → γ} {S : Set α} (hg : IsUniformInducing g) : UniformContinuousOn f S ↔ UniformContinuousOn (g ∘ f) S := by dsimp only [UniformContinuousOn, Tendsto] rw [← hg.comap_uniformity, ← map_le_iff_le_comap, Filter.map_map, comp_def, comp_def] theorem IsUniformInducing.isInducing {f : α → β} (h : IsUniformInducing f) : IsInducing f := by obtain rfl := h.comap_uniformSpace exact .induced f theorem IsUniformInducing.prod {α' : Type*} {β' : Type*} [UniformSpace α'] [UniformSpace β'] {e₁ : α → α'} {e₂ : β → β'} (h₁ : IsUniformInducing e₁) (h₂ : IsUniformInducing e₂) : IsUniformInducing fun p : α × β => (e₁ p.1, e₂ p.2) := ⟨by simp [Function.comp_def, uniformity_prod, ← h₁.1, ← h₂.1, comap_inf, comap_comap]⟩ lemma IsUniformInducing.isDenseInducing (h : IsUniformInducing f) (hd : DenseRange f) : IsDenseInducing f where toIsInducing := h.isInducing dense := hd lemma SeparationQuotient.isUniformInducing_mk : IsUniformInducing (mk : α → SeparationQuotient α) := ⟨comap_mk_uniformity⟩ protected theorem IsUniformInducing.injective [T0Space α] {f : α → β} (h : IsUniformInducing f) : Injective f := h.isInducing.injective /-! ### Uniform embeddings -/ /-- A map `f : α → β` between uniform spaces is a *uniform embedding* if it is uniform inducing and injective. If `α` is a separated space, then the latter assumption follows from the former. -/ @[mk_iff] structure IsUniformEmbedding (f : α → β) : Prop extends IsUniformInducing f where /-- A uniform embedding is injective. -/ injective : Function.Injective f lemma IsUniformEmbedding.isUniformInducing (hf : IsUniformEmbedding f) : IsUniformInducing f := hf.toIsUniformInducing theorem isUniformEmbedding_iff' {f : α → β} : IsUniformEmbedding f ↔ Injective f ∧ UniformContinuous f ∧ comap (Prod.map f f) (𝓤 β) ≤ 𝓤 α := by rw [isUniformEmbedding_iff, and_comm, isUniformInducing_iff'] theorem Filter.HasBasis.isUniformEmbedding_iff' {ι ι'} {p : ι → Prop} {p' : ι' → Prop} {s s'} (h : (𝓤 α).HasBasis p s) (h' : (𝓤 β).HasBasis p' s') {f : α → β} : IsUniformEmbedding f ↔ Injective f ∧ (∀ i, p' i → ∃ j, p j ∧ ∀ x y, (x, y) ∈ s j → (f x, f y) ∈ s' i) ∧ (∀ j, p j → ∃ i, p' i ∧ ∀ x y, (f x, f y) ∈ s' i → (x, y) ∈ s j) := by rw [isUniformEmbedding_iff, and_comm, h.isUniformInducing_iff h'] theorem Filter.HasBasis.isUniformEmbedding_iff {ι ι'} {p : ι → Prop} {p' : ι' → Prop} {s s'} (h : (𝓤 α).HasBasis p s) (h' : (𝓤 β).HasBasis p' s') {f : α → β} : IsUniformEmbedding f ↔ Injective f ∧ UniformContinuous f ∧ (∀ j, p j → ∃ i, p' i ∧ ∀ x y, (f x, f y) ∈ s' i → (x, y) ∈ s j) := by simp only [h.isUniformEmbedding_iff' h', h.uniformContinuous_iff h'] theorem isUniformEmbedding_subtype_val {p : α → Prop} : IsUniformEmbedding (Subtype.val : Subtype p → α) := { comap_uniformity := rfl injective := Subtype.val_injective } theorem isUniformEmbedding_set_inclusion {s t : Set α} (hst : s ⊆ t) : IsUniformEmbedding (inclusion hst) where comap_uniformity := by rw [uniformity_subtype, uniformity_subtype, comap_comap]; rfl injective := inclusion_injective hst theorem IsUniformEmbedding.comp {g : β → γ} (hg : IsUniformEmbedding g) {f : α → β} (hf : IsUniformEmbedding f) : IsUniformEmbedding (g ∘ f) where toIsUniformInducing := hg.isUniformInducing.comp hf.isUniformInducing injective := hg.injective.comp hf.injective theorem IsUniformEmbedding.of_comp_iff {g : β → γ} (hg : IsUniformEmbedding g) {f : α → β} : IsUniformEmbedding (g ∘ f) ↔ IsUniformEmbedding f := by simp_rw [isUniformEmbedding_iff, hg.isUniformInducing.of_comp_iff, hg.injective.of_comp_iff f] theorem Equiv.isUniformEmbedding {α β : Type*} [UniformSpace α] [UniformSpace β] (f : α ≃ β) (h₁ : UniformContinuous f) (h₂ : UniformContinuous f.symm) : IsUniformEmbedding f := isUniformEmbedding_iff'.2 ⟨f.injective, h₁, by rwa [← Equiv.prodCongr_apply, ← map_equiv_symm]⟩ theorem isUniformEmbedding_inl : IsUniformEmbedding (Sum.inl : α → α ⊕ β) := isUniformEmbedding_iff'.2 ⟨Sum.inl_injective, uniformContinuous_inl, fun s hs => ⟨Prod.map Sum.inl Sum.inl '' s ∪ range (Prod.map Sum.inr Sum.inr), union_mem_sup (image_mem_map hs) range_mem_map, fun x h => by simpa [Prod.map_apply'] using h⟩⟩ theorem isUniformEmbedding_inr : IsUniformEmbedding (Sum.inr : β → α ⊕ β) := isUniformEmbedding_iff'.2 ⟨Sum.inr_injective, uniformContinuous_inr, fun s hs => ⟨range (Prod.map Sum.inl Sum.inl) ∪ Prod.map Sum.inr Sum.inr '' s, union_mem_sup range_mem_map (image_mem_map hs), fun x h => by simpa [Prod.map_apply'] using h⟩⟩ /-- If the domain of a `IsUniformInducing` map `f` is a T₀ space, then `f` is injective, hence it is a `IsUniformEmbedding`. -/ protected theorem IsUniformInducing.isUniformEmbedding [T0Space α] {f : α → β} (hf : IsUniformInducing f) : IsUniformEmbedding f := ⟨hf, hf.isInducing.injective⟩ theorem isUniformEmbedding_iff_isUniformInducing [T0Space α] {f : α → β} : IsUniformEmbedding f ↔ IsUniformInducing f := ⟨IsUniformEmbedding.isUniformInducing, IsUniformInducing.isUniformEmbedding⟩ /-- If a map `f : α → β` sends any two distinct points to point that are **not** related by a fixed `s ∈ 𝓤 β`, then `f` is uniform inducing with respect to the discrete uniformity on `α`: the preimage of `𝓤 β` under `Prod.map f f` is the principal filter generated by the diagonal in `α × α`. -/ theorem comap_uniformity_of_spaced_out {α} {f : α → β} {s : Set (β × β)} (hs : s ∈ 𝓤 β) (hf : Pairwise fun x y => (f x, f y) ∉ s) : comap (Prod.map f f) (𝓤 β) = 𝓟 idRel := by refine le_antisymm ?_ (@refl_le_uniformity α (UniformSpace.comap f _)) calc comap (Prod.map f f) (𝓤 β) ≤ comap (Prod.map f f) (𝓟 s) := comap_mono (le_principal_iff.2 hs) _ = 𝓟 (Prod.map f f ⁻¹' s) := comap_principal _ ≤ 𝓟 idRel := principal_mono.2 ?_ rintro ⟨x, y⟩; simpa [not_imp_not] using @hf x y /-- If a map `f : α → β` sends any two distinct points to point that are **not** related by a fixed `s ∈ 𝓤 β`, then `f` is a uniform embedding with respect to the discrete uniformity on `α`. -/ theorem isUniformEmbedding_of_spaced_out {α} {f : α → β} {s : Set (β × β)} (hs : s ∈ 𝓤 β) (hf : Pairwise fun x y => (f x, f y) ∉ s) : @IsUniformEmbedding α β ⊥ ‹_› f := by let _ : UniformSpace α := ⊥; have := discreteTopology_bot α exact IsUniformInducing.isUniformEmbedding ⟨comap_uniformity_of_spaced_out hs hf⟩ protected lemma IsUniformEmbedding.isEmbedding {f : α → β} (h : IsUniformEmbedding f) : IsEmbedding f where toIsInducing := h.toIsUniformInducing.isInducing injective := h.injective theorem IsUniformEmbedding.isDenseEmbedding {f : α → β} (h : IsUniformEmbedding f) (hd : DenseRange f) : IsDenseEmbedding f := { h.isEmbedding with dense := hd } theorem isClosedEmbedding_of_spaced_out {α} [TopologicalSpace α] [DiscreteTopology α] [T0Space β] {f : α → β} {s : Set (β × β)} (hs : s ∈ 𝓤 β) (hf : Pairwise fun x y => (f x, f y) ∉ s) : IsClosedEmbedding f := by rcases @DiscreteTopology.eq_bot α _ _ with rfl; let _ : UniformSpace α := ⊥ exact { (isUniformEmbedding_of_spaced_out hs hf).isEmbedding with isClosed_range := isClosed_range_of_spaced_out hs hf } theorem closure_image_mem_nhds_of_isUniformInducing {s : Set (α × α)} {e : α → β} (b : β) (he₁ : IsUniformInducing e) (he₂ : IsDenseInducing e) (hs : s ∈ 𝓤 α) : ∃ a, closure (e '' { a' | (a, a') ∈ s }) ∈ 𝓝 b := by obtain ⟨U, ⟨hU, hUo, hsymm⟩, hs⟩ : ∃ U, (U ∈ 𝓤 β ∧ IsOpen U ∧ IsSymmetricRel U) ∧ Prod.map e e ⁻¹' U ⊆ s := by rwa [← he₁.comap_uniformity, (uniformity_hasBasis_open_symmetric.comap _).mem_iff] at hs rcases he₂.dense.mem_nhds (UniformSpace.ball_mem_nhds b hU) with ⟨a, ha⟩ refine ⟨a, mem_of_superset ?_ (closure_mono <| image_mono <| UniformSpace.ball_mono hs a)⟩ have ho : IsOpen (UniformSpace.ball (e a) U) := UniformSpace.isOpen_ball (e a) hUo refine mem_of_superset (ho.mem_nhds <| (UniformSpace.mem_ball_symmetry hsymm).2 ha) fun y hy => ?_ refine mem_closure_iff_nhds.2 fun V hV => ?_ rcases he₂.dense.mem_nhds (inter_mem hV (ho.mem_nhds hy)) with ⟨x, hxV, hxU⟩ exact ⟨e x, hxV, mem_image_of_mem e hxU⟩ theorem isUniformEmbedding_subtypeEmb (p : α → Prop) {e : α → β} (ue : IsUniformEmbedding e) (de : IsDenseEmbedding e) : IsUniformEmbedding (IsDenseEmbedding.subtypeEmb p e) := { comap_uniformity := by simp [comap_comap, Function.comp_def, IsDenseEmbedding.subtypeEmb, uniformity_subtype, ue.comap_uniformity.symm] injective := (de.subtype p).injective } theorem IsUniformEmbedding.prod {α' : Type*} {β' : Type*} [UniformSpace α'] [UniformSpace β'] {e₁ : α → α'} {e₂ : β → β'} (h₁ : IsUniformEmbedding e₁) (h₂ : IsUniformEmbedding e₂) : IsUniformEmbedding fun p : α × β => (e₁ p.1, e₂ p.2) where toIsUniformInducing := h₁.isUniformInducing.prod h₂.isUniformInducing injective := h₁.injective.prodMap h₂.injective /-- A set is complete iff its image under a uniform inducing map is complete. -/ theorem isComplete_image_iff {m : α → β} {s : Set α} (hm : IsUniformInducing m) : IsComplete (m '' s) ↔ IsComplete s := by have fact1 : SurjOn (map m) (Iic <| 𝓟 s) (Iic <| 𝓟 <| m '' s) := surjOn_image .. |>.filter_map_Iic have fact2 : MapsTo (map m) (Iic <| 𝓟 s) (Iic <| 𝓟 <| m '' s) := mapsTo_image .. |>.filter_map_Iic simp_rw [IsComplete, imp.swap (a := Cauchy _), ← mem_Iic (b := 𝓟 _), fact1.forall fact2, hm.cauchy_map_iff, exists_mem_image, map_le_iff_le_comap, hm.isInducing.nhds_eq_comap] /-- If `f : X → Y` is an `IsUniformInducing` map, the image `f '' s` of a set `s` is complete if and only if `s` is complete. -/ theorem IsUniformInducing.isComplete_iff {f : α → β} {s : Set α} (hf : IsUniformInducing f) : IsComplete (f '' s) ↔ IsComplete s := isComplete_image_iff hf /-- If `f : X → Y` is an `IsUniformEmbedding`, the image `f '' s` of a set `s` is complete if and only if `s` is complete. -/ theorem IsUniformEmbedding.isComplete_iff {f : α → β} {s : Set α} (hf : IsUniformEmbedding f) : IsComplete (f '' s) ↔ IsComplete s := hf.isUniformInducing.isComplete_iff /-- Sets of a subtype are complete iff their image under the coercion is complete. -/ theorem Subtype.isComplete_iff {p : α → Prop} {s : Set { x // p x }} : IsComplete s ↔ IsComplete ((↑) '' s : Set α) := isUniformEmbedding_subtype_val.isComplete_iff.symm alias ⟨isComplete_of_complete_image, _⟩ := isComplete_image_iff theorem completeSpace_iff_isComplete_range {f : α → β} (hf : IsUniformInducing f) : CompleteSpace α ↔ IsComplete (range f) := by rw [completeSpace_iff_isComplete_univ, ← isComplete_image_iff hf, image_univ] alias ⟨_, IsUniformInducing.completeSpace⟩ := completeSpace_iff_isComplete_range lemma IsUniformInducing.isComplete_range [CompleteSpace α] (hf : IsUniformInducing f) : IsComplete (range f) := (completeSpace_iff_isComplete_range hf).1 ‹_› /-- If `f` is a surjective uniform inducing map, then its domain is a complete space iff its codomain is a complete space. See also `_root_.completeSpace_congr` for a version that assumes `f` to be an equivalence. -/ theorem IsUniformInducing.completeSpace_congr {f : α → β} (hf : IsUniformInducing f) (hsurj : f.Surjective) : CompleteSpace α ↔ CompleteSpace β := by rw [completeSpace_iff_isComplete_range hf, hsurj.range_eq, completeSpace_iff_isComplete_univ] theorem SeparationQuotient.completeSpace_iff : CompleteSpace (SeparationQuotient α) ↔ CompleteSpace α := .symm <| isUniformInducing_mk.completeSpace_congr surjective_mk instance SeparationQuotient.instCompleteSpace [CompleteSpace α] : CompleteSpace (SeparationQuotient α) := completeSpace_iff.2 ‹_› /-- See also `IsUniformInducing.completeSpace_congr` for a version that works for non-injective maps. -/ theorem completeSpace_congr {e : α ≃ β} (he : IsUniformEmbedding e) : CompleteSpace α ↔ CompleteSpace β := he.completeSpace_congr e.surjective theorem completeSpace_coe_iff_isComplete {s : Set α} : CompleteSpace s ↔ IsComplete s := by rw [completeSpace_iff_isComplete_range isUniformEmbedding_subtype_val.isUniformInducing, Subtype.range_coe] alias ⟨_, IsComplete.completeSpace_coe⟩ := completeSpace_coe_iff_isComplete theorem IsClosed.completeSpace_coe [CompleteSpace α] {s : Set α} (hs : IsClosed s) : CompleteSpace s := hs.isComplete.completeSpace_coe theorem completeSpace_ulift_iff : CompleteSpace (ULift α) ↔ CompleteSpace α := IsUniformInducing.completeSpace_congr ⟨rfl⟩ ULift.down_surjective /-- The lift of a complete space to another universe is still complete. -/ instance ULift.instCompleteSpace [CompleteSpace α] : CompleteSpace (ULift α) := completeSpace_ulift_iff.2 ‹_› theorem completeSpace_extension {m : β → α} (hm : IsUniformInducing m) (dense : DenseRange m) (h : ∀ f : Filter β, Cauchy f → ∃ x : α, map m f ≤ 𝓝 x) : CompleteSpace α := ⟨fun {f : Filter α} (hf : Cauchy f) => let p : Set (α × α) → Set α → Set α := fun s t => { y : α | ∃ x : α, x ∈ t ∧ (x, y) ∈ s } let g := (𝓤 α).lift fun s => f.lift' (p s) have mp₀ : Monotone p := fun _ _ h _ _ ⟨x, xs, xa⟩ => ⟨x, xs, h xa⟩ have mp₁ : ∀ {s}, Monotone (p s) := fun h _ ⟨y, ya, yxs⟩ => ⟨y, h ya, yxs⟩ have : f ≤ g := le_iInf₂ fun _ hs => le_iInf₂ fun _ ht => le_principal_iff.mpr <| mem_of_superset ht fun x hx => ⟨x, hx, refl_mem_uniformity hs⟩ have : NeBot g := hf.left.mono this have : NeBot (comap m g) := comap_neBot fun _ ht => let ⟨t', ht', ht_mem⟩ := (mem_lift_sets <| monotone_lift' monotone_const mp₀).mp ht let ⟨_, ht'', ht'_sub⟩ := (mem_lift'_sets mp₁).mp ht_mem let ⟨x, hx⟩ := hf.left.nonempty_of_mem ht'' have h₀ : NeBot (𝓝[range m] x) := dense.nhdsWithin_neBot x have h₁ : { y | (x, y) ∈ t' } ∈ 𝓝[range m] x := @mem_inf_of_left α (𝓝 x) (𝓟 (range m)) _ <| mem_nhds_left x ht' have h₂ : range m ∈ 𝓝[range m] x := @mem_inf_of_right α (𝓝 x) (𝓟 (range m)) _ <| Subset.refl _ have : { y | (x, y) ∈ t' } ∩ range m ∈ 𝓝[range m] x := @inter_mem α (𝓝[range m] x) _ _ h₁ h₂ let ⟨_, xyt', b, b_eq⟩ := h₀.nonempty_of_mem this ⟨b, b_eq.symm ▸ ht'_sub ⟨x, hx, xyt'⟩⟩ have : Cauchy g := ⟨‹NeBot g›, fun _ hs => let ⟨s₁, hs₁, comp_s₁⟩ := comp_mem_uniformity_sets hs let ⟨s₂, hs₂, comp_s₂⟩ := comp_mem_uniformity_sets hs₁ let ⟨t, ht, (prod_t : t ×ˢ t ⊆ s₂)⟩ := mem_prod_same_iff.mp (hf.right hs₂) have hg₁ : p (preimage Prod.swap s₁) t ∈ g := mem_lift (symm_le_uniformity hs₁) <| @mem_lift' α α f _ t ht have hg₂ : p s₂ t ∈ g := mem_lift hs₂ <| @mem_lift' α α f _ t ht have hg : p (Prod.swap ⁻¹' s₁) t ×ˢ p s₂ t ∈ g ×ˢ g := @prod_mem_prod α α _ _ g g hg₁ hg₂ (g ×ˢ g).sets_of_superset hg fun ⟨_, _⟩ ⟨⟨c₁, c₁t, hc₁⟩, ⟨c₂, c₂t, hc₂⟩⟩ => have : (c₁, c₂) ∈ t ×ˢ t := ⟨c₁t, c₂t⟩ comp_s₁ <| prodMk_mem_compRel hc₁ <| comp_s₂ <| prodMk_mem_compRel (prod_t this) hc₂⟩ have : Cauchy (Filter.comap m g) := ‹Cauchy g›.comap' (le_of_eq hm.comap_uniformity) ‹_› let ⟨x, (hx : map m (Filter.comap m g) ≤ 𝓝 x)⟩ := h _ this have : ClusterPt x (map m (Filter.comap m g)) := (le_nhds_iff_adhp_of_cauchy (this.map hm.uniformContinuous)).mp hx have : ClusterPt x g := this.mono map_comap_le ⟨x, calc f ≤ g := by assumption _ ≤ 𝓝 x := le_nhds_of_cauchy_adhp ‹Cauchy g› this ⟩⟩ lemma totallyBounded_image_iff {f : α → β} {s : Set α} (hf : IsUniformInducing f) : TotallyBounded (f '' s) ↔ TotallyBounded s := by refine ⟨fun hs ↦ ?_, fun h ↦ h.image hf.uniformContinuous⟩ simp_rw [(hf.basis_uniformity (basis_sets _)).totallyBounded_iff] intro t ht rcases exists_subset_image_finite_and.1 (hs.exists_subset ht) with ⟨u, -, hfin, h⟩ use u, hfin rwa [biUnion_image, image_subset_iff, preimage_iUnion₂] at h theorem totallyBounded_preimage {f : α → β} {s : Set β} (hf : IsUniformInducing f) (hs : TotallyBounded s) : TotallyBounded (f ⁻¹' s) := (totallyBounded_image_iff hf).1 <| hs.subset <| image_preimage_subset .. instance CompleteSpace.sum [CompleteSpace α] [CompleteSpace β] : CompleteSpace (α ⊕ β) := by rw [completeSpace_iff_isComplete_univ, ← range_inl_union_range_inr] exact isUniformEmbedding_inl.isUniformInducing.isComplete_range.union isUniformEmbedding_inr.isUniformInducing.isComplete_range end theorem isUniformEmbedding_comap {α : Type*} {β : Type*} {f : α → β} [u : UniformSpace β] (hf : Function.Injective f) : @IsUniformEmbedding α β (UniformSpace.comap f u) u f := @IsUniformEmbedding.mk _ _ (UniformSpace.comap f u) _ _ (@IsUniformInducing.mk _ _ (UniformSpace.comap f u) _ _ rfl) hf /-- Pull back a uniform space structure by an embedding, adjusting the new uniform structure to make sure that its topology is defeq to the original one. -/ def Topology.IsEmbedding.comapUniformSpace {α β} [TopologicalSpace α] [u : UniformSpace β] (f : α → β) (h : IsEmbedding f) : UniformSpace α := (u.comap f).replaceTopology h.eq_induced theorem Embedding.to_isUniformEmbedding {α β} [TopologicalSpace α] [u : UniformSpace β] (f : α → β) (h : IsEmbedding f) : @IsUniformEmbedding α β (h.comapUniformSpace f) u f := let _ := h.comapUniformSpace f { comap_uniformity := rfl injective := h.injective } section UniformExtension variable {α : Type*} {β : Type*} {γ : Type*} [UniformSpace α] [UniformSpace β] [UniformSpace γ] {e : β → α} (h_e : IsUniformInducing e) (h_dense : DenseRange e) {f : β → γ} (h_f : UniformContinuous f) local notation "ψ" => IsDenseInducing.extend (IsUniformInducing.isDenseInducing h_e h_dense) f include h_e h_dense h_f in theorem uniformly_extend_exists [CompleteSpace γ] (a : α) : ∃ c, Tendsto f (comap e (𝓝 a)) (𝓝 c) := let de := h_e.isDenseInducing h_dense have : Cauchy (𝓝 a) := cauchy_nhds have : Cauchy (comap e (𝓝 a)) := this.comap' (le_of_eq h_e.comap_uniformity) (de.comap_nhds_neBot _) have : Cauchy (map f (comap e (𝓝 a))) := this.map h_f CompleteSpace.complete this theorem uniform_extend_subtype [CompleteSpace γ] {p : α → Prop} {e : α → β} {f : α → γ} {b : β} {s : Set α} (hf : UniformContinuous fun x : Subtype p => f x.val) (he : IsUniformEmbedding e) (hd : ∀ x : β, x ∈ closure (range e)) (hb : closure (e '' s) ∈ 𝓝 b) (hs : IsClosed s) (hp : ∀ x ∈ s, p x) : ∃ c, Tendsto f (comap e (𝓝 b)) (𝓝 c) := by have de : IsDenseEmbedding e := he.isDenseEmbedding hd have de' : IsDenseEmbedding (IsDenseEmbedding.subtypeEmb p e) := de.subtype p have ue' : IsUniformEmbedding (IsDenseEmbedding.subtypeEmb p e) := isUniformEmbedding_subtypeEmb _ he de have : b ∈ closure (e '' { x | p x }) := (closure_mono <| monotone_image <| hp) (mem_of_mem_nhds hb) let ⟨c, hc⟩ := uniformly_extend_exists ue'.isUniformInducing de'.dense hf ⟨b, this⟩ replace hc : Tendsto (f ∘ Subtype.val (p := p)) (((𝓝 b).comap e).comap Subtype.val) (𝓝 c) := by simpa only [nhds_subtype_eq_comap, comap_comap, IsDenseEmbedding.subtypeEmb_coe] using hc refine ⟨c, (tendsto_comap'_iff ?_).1 hc⟩ rw [Subtype.range_coe_subtype] exact ⟨_, hb, by rwa [← de.isInducing.closure_eq_preimage_closure_image, hs.closure_eq]⟩ include h_e h_f in theorem uniformly_extend_spec [CompleteSpace γ] (a : α) : Tendsto f (comap e (𝓝 a)) (𝓝 (ψ a)) := by simpa only [IsDenseInducing.extend] using tendsto_nhds_limUnder (uniformly_extend_exists h_e ‹_› h_f _) include h_f in theorem uniformContinuous_uniformly_extend [CompleteSpace γ] : UniformContinuous ψ := fun d hd => let ⟨s, hs, hs_comp⟩ := comp3_mem_uniformity hd have h_pnt : ∀ {a m}, m ∈ 𝓝 a → ∃ c ∈ f '' (e ⁻¹' m), (c, ψ a) ∈ s ∧ (ψ a, c) ∈ s := fun {a m} hm => have nb : NeBot (map f (comap e (𝓝 a))) := ((h_e.isDenseInducing h_dense).comap_nhds_neBot _).map _ have : f '' (e ⁻¹' m) ∩ ({ c | (c, ψ a) ∈ s } ∩ { c | (ψ a, c) ∈ s }) ∈ map f (comap e (𝓝 a)) := inter_mem (image_mem_map <| preimage_mem_comap <| hm) (uniformly_extend_spec h_e h_dense h_f _ (inter_mem (mem_nhds_right _ hs) (mem_nhds_left _ hs))) nb.nonempty_of_mem this have : (Prod.map f f) ⁻¹' s ∈ 𝓤 β := h_f hs have : (Prod.map f f) ⁻¹' s ∈ comap (Prod.map e e) (𝓤 α) := by rwa [← h_e.comap_uniformity] at this let ⟨t, ht, ts⟩ := this show (Prod.map ψ ψ) ⁻¹' d ∈ 𝓤 α from mem_of_superset (interior_mem_uniformity ht) fun ⟨x₁, x₂⟩ hx_t => by have : interior t ∈ 𝓝 (x₁, x₂) := isOpen_interior.mem_nhds hx_t let ⟨m₁, hm₁, m₂, hm₂, (hm : m₁ ×ˢ m₂ ⊆ interior t)⟩ := mem_nhds_prod_iff.mp this obtain ⟨_, ⟨a, ha₁, rfl⟩, _, ha₂⟩ := h_pnt hm₁ obtain ⟨_, ⟨b, hb₁, rfl⟩, hb₂, _⟩ := h_pnt hm₂ have : Prod.map f f (a, b) ∈ s := ts <| mem_preimage.2 <| interior_subset (@hm (e a, e b) ⟨ha₁, hb₁⟩) exact hs_comp ⟨f a, ha₂, ⟨f b, this, hb₂⟩⟩ variable [T0Space γ] include h_f in theorem uniformly_extend_of_ind (b : β) : ψ (e b) = f b := IsDenseInducing.extend_eq_at _ h_f.continuous.continuousAt theorem uniformly_extend_unique {g : α → γ} (hg : ∀ b, g (e b) = f b) (hc : Continuous g) : ψ = g := IsDenseInducing.extend_unique _ hg hc end UniformExtension section DenseExtension variable {α β : Type*} [UniformSpace α] [UniformSpace β] theorem isUniformInducing_val (s : Set α) : IsUniformInducing (@Subtype.val α s) := ⟨uniformity_setCoe⟩ namespace Dense variable {s : Set α} {f : s → β} theorem extend_exists [CompleteSpace β] (hs : Dense s) (hf : UniformContinuous f) (a : α) : ∃ b, Tendsto f (comap (↑) (𝓝 a)) (𝓝 b) := uniformly_extend_exists (isUniformInducing_val s) hs.denseRange_val hf a theorem extend_spec [CompleteSpace β] (hs : Dense s) (hf : UniformContinuous f) (a : α) : Tendsto f (comap (↑) (𝓝 a)) (𝓝 (hs.extend f a)) := uniformly_extend_spec (isUniformInducing_val s) hs.denseRange_val hf a theorem uniformContinuous_extend [CompleteSpace β] (hs : Dense s) (hf : UniformContinuous f) : UniformContinuous (hs.extend f) := uniformContinuous_uniformly_extend (isUniformInducing_val s) hs.denseRange_val hf variable [T0Space β] theorem extend_of_ind (hs : Dense s) (hf : UniformContinuous f) (x : s) : hs.extend f x = f x := IsDenseInducing.extend_eq_at _ hf.continuous.continuousAt end Dense end DenseExtension
Lemmas.lean
/- Copyright (c) 2020 Kim Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kim Morrison, Shing Tak Lam, Mario Carneiro -/ import Mathlib.Algebra.BigOperators.Intervals import Mathlib.Algebra.BigOperators.Ring.List import Mathlib.Data.Int.ModEq import Mathlib.Data.Nat.Bits import Mathlib.Data.Nat.Log import Mathlib.Tactic.IntervalCases import Mathlib.Data.Nat.Digits.Defs /-! # Digits of a natural number This provides lemma about the digits of natural numbers. -/ namespace Nat variable {n : ℕ} theorem ofDigits_eq_sum_mapIdx_aux (b : ℕ) (l : List ℕ) : (l.zipWith ((fun a i : ℕ => a * b ^ (i + 1))) (List.range l.length)).sum = b * (l.zipWith (fun a i => a * b ^ i) (List.range l.length)).sum := by suffices l.zipWith (fun a i : ℕ => a * b ^ (i + 1)) (List.range l.length) = l.zipWith (fun a i=> b * (a * b ^ i)) (List.range l.length) by simp [this] congr; ext; simp [pow_succ]; ring theorem ofDigits_eq_sum_mapIdx (b : ℕ) (L : List ℕ) : ofDigits b L = (L.mapIdx fun i a => a * b ^ i).sum := by rw [List.mapIdx_eq_zipIdx_map, List.zipIdx_eq_zip_range', List.map_zip_eq_zipWith, ofDigits_eq_foldr, ← List.range_eq_range'] induction' L with hd tl hl · simp · simpa [List.range_succ_eq_map, List.zipWith_map_right, ofDigits_eq_sum_mapIdx_aux] using Or.inl hl /-! ### Properties This section contains various lemmas of properties relating to `digits` and `ofDigits`. -/ theorem digits_len (b n : ℕ) (hb : 1 < b) (hn : n ≠ 0) : (b.digits n).length = b.log n + 1 := by induction' n using Nat.strong_induction_on with n IH rw [digits_eq_cons_digits_div hb hn, List.length] by_cases h : n / b = 0 · simp [h] aesop · have : n / b < n := div_lt_self (Nat.pos_of_ne_zero hn) hb rw [IH _ this h, log_div_base, tsub_add_cancel_of_le] refine Nat.succ_le_of_lt (log_pos hb ?_) contrapose! h exact div_eq_of_lt h theorem digits_length_le_iff {b k : ℕ} (hb : 1 < b) (n : ℕ) : (b.digits n).length ≤ k ↔ n < b ^ k := by by_cases h : n = 0 · simp [h] positivity rw [digits_len b n hb h, lt_pow_iff_log_lt hb h] exact add_one_le_iff theorem lt_digits_length_iff {b k : ℕ} (hb : 1 < b) (n : ℕ) : k < (b.digits n).length ↔ b ^ k ≤ n := by rw [← not_iff_not] push_neg exact digits_length_le_iff hb n theorem getLast_digit_ne_zero (b : ℕ) {m : ℕ} (hm : m ≠ 0) : (digits b m).getLast (digits_ne_nil_iff_ne_zero.mpr hm) ≠ 0 := by rcases b with (_ | _ | b) · cases m · cases hm rfl · simp · cases m · cases hm rfl simp only [zero_add, digits_one, List.getLast_replicate_succ] exact Nat.one_ne_zero revert hm induction m using Nat.strongRecOn with | ind n IH => ?_ intro hn by_cases hnb : n < b + 2 · simpa only [digits_of_lt (b + 2) n hn hnb] · rw [digits_getLast n (le_add_left 2 b)] refine IH _ (Nat.div_lt_self hn.bot_lt (one_lt_succ_succ b)) ?_ rw [← pos_iff_ne_zero] exact Nat.div_pos (le_of_not_gt hnb) (zero_lt_succ (succ b)) theorem digits_append_digits {b m n : ℕ} (hb : 0 < b) : digits b n ++ digits b m = digits b (n + b ^ (digits b n).length * m) := by rcases eq_or_lt_of_le (Nat.succ_le_of_lt hb) with (rfl | hb) · simp rw [← ofDigits_digits_append_digits] refine (digits_ofDigits b hb _ (fun l hl => ?_) (fun h_append => ?_)).symm · rcases (List.mem_append.mp hl) with (h | h) <;> exact digits_lt_base hb h · by_cases h : digits b m = [] · simp only [h, List.append_nil] at h_append ⊢ exact getLast_digit_ne_zero b <| digits_ne_nil_iff_ne_zero.mp h_append · exact (List.getLast_append_of_right_ne_nil _ _ h) ▸ (getLast_digit_ne_zero _ <| digits_ne_nil_iff_ne_zero.mp h) theorem digits_append_zeroes_append_digits {b k m n : ℕ} (hb : 1 < b) (hm : 0 < m) : digits b n ++ List.replicate k 0 ++ digits b m = digits b (n + b ^ ((digits b n).length + k) * m) := by rw [List.append_assoc, ← digits_base_pow_mul hb hm] simp only [digits_append_digits (zero_lt_of_lt hb), digits_inj_iff, add_right_inj] ring theorem digits_len_le_digits_len_succ (b n : ℕ) : (digits b n).length ≤ (digits b (n + 1)).length := by rcases Decidable.eq_or_ne n 0 with (rfl | hn) · simp rcases le_or_gt b 1 with hb | hb · interval_cases b <;> simp +arith [digits_zero_succ', hn] simpa [digits_len, hb, hn] using log_mono_right (le_succ _) theorem le_digits_len_le (b n m : ℕ) (h : n ≤ m) : (digits b n).length ≤ (digits b m).length := monotone_nat_of_le_succ (digits_len_le_digits_len_succ b) h theorem pow_length_le_mul_ofDigits {b : ℕ} {l : List ℕ} (hl : l ≠ []) (hl2 : l.getLast hl ≠ 0) : (b + 2) ^ l.length ≤ (b + 2) * ofDigits (b + 2) l := by rw [← List.dropLast_append_getLast hl] simp only [List.length_append, List.length, zero_add, List.length_dropLast, ofDigits_append, List.length_dropLast, ofDigits_singleton, add_comm (l.length - 1), pow_add, pow_one] apply Nat.mul_le_mul_left refine le_trans ?_ (Nat.le_add_left _ _) have : 0 < l.getLast hl := by rwa [pos_iff_ne_zero] convert Nat.mul_le_mul_left ((b + 2) ^ (l.length - 1)) this using 1 rw [Nat.mul_one] /-- Any non-zero natural number `m` is greater than (b+2)^((number of digits in the base (b+2) representation of m) - 1) -/ theorem base_pow_length_digits_le' (b m : ℕ) (hm : m ≠ 0) : (b + 2) ^ (digits (b + 2) m).length ≤ (b + 2) * m := by have : digits (b + 2) m ≠ [] := digits_ne_nil_iff_ne_zero.mpr hm convert @pow_length_le_mul_ofDigits b (digits (b+2) m) this (getLast_digit_ne_zero _ hm) rw [ofDigits_digits] /-- Any non-zero natural number `m` is greater than b^((number of digits in the base b representation of m) - 1) -/ theorem base_pow_length_digits_le (b m : ℕ) (hb : 1 < b) : m ≠ 0 → b ^ (digits b m).length ≤ b * m := by rcases b with (_ | _ | b) <;> try simp_all exact base_pow_length_digits_le' b m open Finset theorem sub_one_mul_sum_div_pow_eq_sub_sum_digits {p : ℕ} (L : List ℕ) {h_nonempty} (h_ne_zero : L.getLast h_nonempty ≠ 0) (h_lt : ∀ l ∈ L, l < p) : (p - 1) * ∑ i ∈ range L.length, (ofDigits p L) / p ^ i.succ = (ofDigits p L) - L.sum := by obtain h | rfl | h : 1 < p ∨ 1 = p ∨ p < 1 := trichotomous 1 p · induction' L with hd tl ih · simp [ofDigits] · simp only [List.length_cons, List.sum_cons, self_div_pow_eq_ofDigits_drop _ _ h, digits_ofDigits p h (hd :: tl) h_lt (fun _ => h_ne_zero)] simp only [ofDigits] rw [sum_range_succ, Nat.cast_id] simp only [List.drop, List.drop_length] obtain rfl | h' := em <| tl = [] · simp [ofDigits] · have w₁' := fun l hl ↦ h_lt l <| List.mem_cons_of_mem hd hl have w₂' := fun (h : tl ≠ []) ↦ (List.getLast_cons h) ▸ h_ne_zero have ih := ih (w₂' h') w₁' simp only [self_div_pow_eq_ofDigits_drop _ _ h, digits_ofDigits p h tl w₁' w₂', ← Nat.one_add] at ih have := sum_singleton (fun x ↦ ofDigits p <| tl.drop x) tl.length rw [← Ico_succ_singleton, List.drop_length, ofDigits] at this have h₁ : 1 ≤ tl.length := List.length_pos_iff.mpr h' rw [← sum_range_add_sum_Ico _ <| h₁, ← add_zero (∑ x ∈ Ico _ _, ofDigits p (tl.drop x)), ← this, sum_Ico_consecutive _ h₁ <| (le_add_right tl.length 1), ← sum_Ico_add _ 0 tl.length 1, Ico_zero_eq_range, mul_add, mul_add, ih, range_one, sum_singleton, List.drop, ofDigits, mul_zero, add_zero, ← Nat.add_sub_assoc <| sum_le_ofDigits _ <| Nat.le_of_lt h] nth_rw 2 [← one_mul <| ofDigits p tl] rw [← add_mul, Nat.sub_add_cancel (one_le_of_lt h), Nat.add_sub_add_left] · simp [ofDigits_one] · simp [lt_one_iff.mp h] cases L · rfl · simp [ofDigits] theorem sub_one_mul_sum_log_div_pow_eq_sub_sum_digits {p : ℕ} (n : ℕ) : (p - 1) * ∑ i ∈ range (log p n).succ, n / p ^ i.succ = n - (p.digits n).sum := by obtain h | rfl | h : 1 < p ∨ 1 = p ∨ p < 1 := trichotomous 1 p · rcases eq_or_ne n 0 with rfl | hn · simp · convert sub_one_mul_sum_div_pow_eq_sub_sum_digits (p.digits n) (getLast_digit_ne_zero p hn) <| (fun l a ↦ digits_lt_base h a) · refine (digits_len p n h hn).symm all_goals exact (ofDigits_digits p n).symm · simp · simp [lt_one_iff.mp h] cases n all_goals simp /-! ### Binary -/ theorem digits_two_eq_bits (n : ℕ) : digits 2 n = n.bits.map fun b => cond b 1 0 := by induction' n using Nat.binaryRecFromOne with b n h ih · simp · simp rw [bits_append_bit _ _ fun hn => absurd hn h] cases b · rw [digits_def' one_lt_two] · simpa [Nat.bit] · simpa [Nat.bit, pos_iff_ne_zero] · simpa [Nat.bit, add_comm, digits_add 2 one_lt_two 1 n, Nat.add_mul_div_left] /-! ### Modular Arithmetic -/ -- This is really a theorem about polynomials. theorem dvd_ofDigits_sub_ofDigits {α : Type*} [CommRing α] {a b k : α} (h : k ∣ a - b) (L : List ℕ) : k ∣ ofDigits a L - ofDigits b L := by induction' L with d L ih · change k ∣ 0 - 0 simp · simp only [ofDigits, add_sub_add_left_eq_sub] exact dvd_mul_sub_mul h ih theorem ofDigits_modEq' (b b' : ℕ) (k : ℕ) (h : b ≡ b' [MOD k]) (L : List ℕ) : ofDigits b L ≡ ofDigits b' L [MOD k] := by induction' L with d L ih · rfl · dsimp [ofDigits] dsimp [Nat.ModEq] at * conv_lhs => rw [Nat.add_mod, Nat.mul_mod, h, ih] conv_rhs => rw [Nat.add_mod, Nat.mul_mod] theorem ofDigits_modEq (b k : ℕ) (L : List ℕ) : ofDigits b L ≡ ofDigits (b % k) L [MOD k] := ofDigits_modEq' b (b % k) k (b.mod_modEq k).symm L theorem ofDigits_mod (b k : ℕ) (L : List ℕ) : ofDigits b L % k = ofDigits (b % k) L % k := ofDigits_modEq b k L theorem ofDigits_mod_eq_head! (b : ℕ) (l : List ℕ) : ofDigits b l % b = l.head! % b := by induction l <;> simp [Nat.ofDigits] theorem head!_digits {b n : ℕ} (h : b ≠ 1) : (Nat.digits b n).head! = n % b := by by_cases hb : 1 < b · rcases n with _ | n · simp · nth_rw 2 [← Nat.ofDigits_digits b (n + 1)] rw [Nat.ofDigits_mod_eq_head! _ _] exact (Nat.mod_eq_of_lt (Nat.digits_lt_base hb <| List.head!_mem_self <| Nat.digits_ne_nil_iff_ne_zero.mpr <| Nat.succ_ne_zero n)).symm · rcases n with _ | _ <;> simp_all [show b = 0 by omega] theorem ofDigits_zmodeq' (b b' : ℤ) (k : ℕ) (h : b ≡ b' [ZMOD k]) (L : List ℕ) : ofDigits b L ≡ ofDigits b' L [ZMOD k] := by induction' L with d L ih · rfl · dsimp [ofDigits] dsimp [Int.ModEq] at * conv_lhs => rw [Int.add_emod, Int.mul_emod, h, ih] conv_rhs => rw [Int.add_emod, Int.mul_emod] theorem ofDigits_zmodeq (b : ℤ) (k : ℕ) (L : List ℕ) : ofDigits b L ≡ ofDigits (b % k) L [ZMOD k] := ofDigits_zmodeq' b (b % k) k (b.mod_modEq ↑k).symm L theorem ofDigits_zmod (b : ℤ) (k : ℕ) (L : List ℕ) : ofDigits b L % k = ofDigits (b % k) L % k := ofDigits_zmodeq b k L theorem modEq_digits_sum (b b' : ℕ) (h : b' % b = 1) (n : ℕ) : n ≡ (digits b' n).sum [MOD b] := by rw [← ofDigits_one] conv => congr · skip · rw [← ofDigits_digits b' n] convert ofDigits_modEq b' b (digits b' n) exact h.symm theorem zmodeq_ofDigits_digits (b b' : ℕ) (c : ℤ) (h : b' ≡ c [ZMOD b]) (n : ℕ) : n ≡ ofDigits c (digits b' n) [ZMOD b] := by conv => congr · skip · rw [← ofDigits_digits b' n] rw [coe_int_ofDigits] apply ofDigits_zmodeq' _ _ _ h theorem ofDigits_neg_one : ∀ L : List ℕ, ofDigits (-1 : ℤ) L = (L.map fun n : ℕ => (n : ℤ)).alternatingSum | [] => rfl | [n] => by simp [ofDigits, List.alternatingSum] | a :: b :: t => by simp only [ofDigits, List.alternatingSum, List.map_cons, ofDigits_neg_one t] ring end Nat
Imo1959Q1.lean
/- Copyright (c) 2020 Kevin Lacker. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kevin Lacker -/ import Mathlib.Tactic.Ring import Mathlib.Data.Nat.Prime.Basic /-! # IMO 1959 Q1 Prove that the fraction `(21n+4)/(14n+3)` is irreducible for every natural number `n`. Since Lean doesn't have a concept of "irreducible fractions" per se, we just formalize this as saying the numerator and denominator are relatively prime. -/ open Nat namespace Imo1959Q1 theorem calculation (n k : ℕ) (h1 : k ∣ 21 * n + 4) (h2 : k ∣ 14 * n + 3) : k ∣ 1 := have h3 : k ∣ 2 * (21 * n + 4) := h1.mul_left 2 have h4 : k ∣ 3 * (14 * n + 3) := h2.mul_left 3 have h5 : 3 * (14 * n + 3) = 2 * (21 * n + 4) + 1 := by ring (Nat.dvd_add_right h3).mp (h5 ▸ h4) end Imo1959Q1 open Imo1959Q1 theorem imo1959_q1 : ∀ n : ℕ, Coprime (21 * n + 4) (14 * n + 3) := fun n => coprime_of_dvd' fun k _ h1 h2 => calculation n k h1 h2
Basic.lean
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro -/ import Mathlib.Algebra.Notation.Indicator import Mathlib.Data.Int.Cast.Pi import Mathlib.Data.Nat.Cast.Basic import Mathlib.MeasureTheory.MeasurableSpace.Defs /-! # Measurable spaces and measurable functions This file provides properties of measurable spaces and the functions and isomorphisms between them. The definition of a measurable space is in `Mathlib/MeasureTheory/MeasurableSpace/Defs.lean`. A measurable space is a set equipped with a σ-algebra, a collection of subsets closed under complementation and countable union. A function between measurable spaces is measurable if the preimage of each measurable subset is measurable. σ-algebras on a fixed set `α` form a complete lattice. Here we order σ-algebras by writing `m₁ ≤ m₂` if every set which is `m₁`-measurable is also `m₂`-measurable (that is, `m₁` is a subset of `m₂`). In particular, any collection of subsets of `α` generates a smallest σ-algebra which contains all of them. A function `f : α → β` induces a Galois connection between the lattices of σ-algebras on `α` and `β`. ## Implementation notes Measurability of a function `f : α → β` between measurable spaces is defined in terms of the Galois connection induced by `f`. ## References * <https://en.wikipedia.org/wiki/Measurable_space> * <https://en.wikipedia.org/wiki/Sigma-algebra> * <https://en.wikipedia.org/wiki/Dynkin_system> ## Tags measurable space, σ-algebra, measurable function, dynkin system, π-λ theorem, π-system -/ open Set MeasureTheory universe uι variable {α β γ : Type*} {ι : Sort uι} {s : Set α} namespace MeasurableSpace section Functors variable {m m₁ m₂ : MeasurableSpace α} {m' : MeasurableSpace β} {f : α → β} {g : β → α} /-- The forward image of a measurable space under a function. `map f m` contains the sets `s : Set β` whose preimage under `f` is measurable. -/ protected def map (f : α → β) (m : MeasurableSpace α) : MeasurableSpace β where MeasurableSet' s := MeasurableSet[m] <| f ⁻¹' s measurableSet_empty := m.measurableSet_empty measurableSet_compl _ hs := m.measurableSet_compl _ hs measurableSet_iUnion f hf := by simpa only [preimage_iUnion] using m.measurableSet_iUnion _ hf lemma map_def {s : Set β} : MeasurableSet[m.map f] s ↔ MeasurableSet[m] (f ⁻¹' s) := Iff.rfl @[simp] theorem map_id : m.map id = m := MeasurableSpace.ext fun _ => Iff.rfl @[simp] theorem map_comp {f : α → β} {g : β → γ} : (m.map f).map g = m.map (g ∘ f) := MeasurableSpace.ext fun _ => Iff.rfl /-- The reverse image of a measurable space under a function. `comap f m` contains the sets `s : Set α` such that `s` is the `f`-preimage of a measurable set in `β`. -/ protected def comap (f : α → β) (m : MeasurableSpace β) : MeasurableSpace α where MeasurableSet' s := ∃ s', MeasurableSet[m] s' ∧ f ⁻¹' s' = s measurableSet_empty := ⟨∅, m.measurableSet_empty, rfl⟩ measurableSet_compl := fun _ ⟨s', h₁, h₂⟩ => ⟨s'ᶜ, m.measurableSet_compl _ h₁, h₂ ▸ rfl⟩ measurableSet_iUnion s hs := let ⟨s', hs'⟩ := Classical.axiom_of_choice hs ⟨⋃ i, s' i, m.measurableSet_iUnion _ fun i => (hs' i).left, by simp [hs']⟩ lemma measurableSet_comap {m : MeasurableSpace β} : MeasurableSet[m.comap f] s ↔ ∃ s', MeasurableSet[m] s' ∧ f ⁻¹' s' = s := .rfl theorem comap_eq_generateFrom (m : MeasurableSpace β) (f : α → β) : m.comap f = generateFrom { t | ∃ s, MeasurableSet s ∧ f ⁻¹' s = t } := (@generateFrom_measurableSet _ (.comap f m)).symm @[simp] theorem comap_id : m.comap id = m := MeasurableSpace.ext fun s => ⟨fun ⟨_, hs', h⟩ => h ▸ hs', fun h => ⟨s, h, rfl⟩⟩ @[simp] theorem comap_comp {f : β → α} {g : γ → β} : (m.comap f).comap g = m.comap (f ∘ g) := MeasurableSpace.ext fun _ => ⟨fun ⟨_, ⟨u, h, hu⟩, ht⟩ => ⟨u, h, ht ▸ hu ▸ rfl⟩, fun ⟨t, h, ht⟩ => ⟨f ⁻¹' t, ⟨_, h, rfl⟩, ht⟩⟩ theorem comap_le_iff_le_map {f : α → β} : m'.comap f ≤ m ↔ m' ≤ m.map f := ⟨fun h _s hs => h _ ⟨_, hs, rfl⟩, fun h _s ⟨_t, ht, heq⟩ => heq ▸ h _ ht⟩ theorem gc_comap_map (f : α → β) : GaloisConnection (MeasurableSpace.comap f) (MeasurableSpace.map f) := fun _ _ => comap_le_iff_le_map theorem map_mono (h : m₁ ≤ m₂) : m₁.map f ≤ m₂.map f := (gc_comap_map f).monotone_u h theorem monotone_map : Monotone (MeasurableSpace.map f) := fun _ _ => map_mono theorem comap_mono (h : m₁ ≤ m₂) : m₁.comap g ≤ m₂.comap g := (gc_comap_map g).monotone_l h theorem monotone_comap : Monotone (MeasurableSpace.comap g) := fun _ _ h => comap_mono h @[simp] theorem comap_bot : (⊥ : MeasurableSpace α).comap g = ⊥ := (gc_comap_map g).l_bot @[simp] theorem comap_sup : (m₁ ⊔ m₂).comap g = m₁.comap g ⊔ m₂.comap g := (gc_comap_map g).l_sup @[simp] theorem comap_iSup {m : ι → MeasurableSpace α} : (⨆ i, m i).comap g = ⨆ i, (m i).comap g := (gc_comap_map g).l_iSup @[simp] theorem map_top : (⊤ : MeasurableSpace α).map f = ⊤ := (gc_comap_map f).u_top @[simp] theorem map_inf : (m₁ ⊓ m₂).map f = m₁.map f ⊓ m₂.map f := (gc_comap_map f).u_inf @[simp] theorem map_iInf {m : ι → MeasurableSpace α} : (⨅ i, m i).map f = ⨅ i, (m i).map f := (gc_comap_map f).u_iInf theorem comap_map_le : (m.map f).comap f ≤ m := (gc_comap_map f).l_u_le _ theorem le_map_comap : m ≤ (m.comap g).map g := (gc_comap_map g).le_u_l _ end Functors @[simp] theorem map_const {m} (b : β) : MeasurableSpace.map (fun _a : α ↦ b) m = ⊤ := eq_top_iff.2 <| fun s _ ↦ by rw [map_def]; by_cases h : b ∈ s <;> simp [h] @[simp] theorem comap_const {m} (b : β) : MeasurableSpace.comap (fun _a : α => b) m = ⊥ := eq_bot_iff.2 <| by rintro _ ⟨s, -, rfl⟩; by_cases b ∈ s <;> simp [*] theorem comap_generateFrom {f : α → β} {s : Set (Set β)} : (generateFrom s).comap f = generateFrom (preimage f '' s) := le_antisymm (comap_le_iff_le_map.2 <| generateFrom_le fun _t hts => GenerateMeasurable.basic _ <| mem_image_of_mem _ <| hts) (generateFrom_le fun _t ⟨u, hu, Eq⟩ => Eq ▸ ⟨u, GenerateMeasurable.basic _ hu, rfl⟩) end MeasurableSpace section MeasurableFunctions open MeasurableSpace theorem measurable_iff_le_map {m₁ : MeasurableSpace α} {m₂ : MeasurableSpace β} {f : α → β} : Measurable f ↔ m₂ ≤ m₁.map f := Iff.rfl alias ⟨Measurable.le_map, Measurable.of_le_map⟩ := measurable_iff_le_map theorem measurable_iff_comap_le {m₁ : MeasurableSpace α} {m₂ : MeasurableSpace β} {f : α → β} : Measurable f ↔ m₂.comap f ≤ m₁ := comap_le_iff_le_map.symm alias ⟨Measurable.comap_le, Measurable.of_comap_le⟩ := measurable_iff_comap_le theorem comap_measurable {m : MeasurableSpace β} (f : α → β) : Measurable[m.comap f] f := fun s hs => ⟨s, hs, rfl⟩ theorem Measurable.mono {ma ma' : MeasurableSpace α} {mb mb' : MeasurableSpace β} {f : α → β} (hf : @Measurable α β ma mb f) (ha : ma ≤ ma') (hb : mb' ≤ mb) : @Measurable α β ma' mb' f := fun _t ht => ha _ <| hf <| hb _ ht lemma Measurable.iSup' {mα : ι → MeasurableSpace α} {_ : MeasurableSpace β} {f : α → β} (i₀ : ι) (h : Measurable[mα i₀] f) : Measurable[⨆ i, mα i] f := h.mono (le_iSup mα i₀) le_rfl lemma Measurable.sup_of_left {mα mα' : MeasurableSpace α} {_ : MeasurableSpace β} {f : α → β} (h : Measurable[mα] f) : Measurable[mα ⊔ mα'] f := h.mono le_sup_left le_rfl lemma Measurable.sup_of_right {mα mα' : MeasurableSpace α} {_ : MeasurableSpace β} {f : α → β} (h : Measurable[mα'] f) : Measurable[mα ⊔ mα'] f := h.mono le_sup_right le_rfl theorem measurable_id'' {m mα : MeasurableSpace α} (hm : m ≤ mα) : @Measurable α α mα m id := measurable_id.mono le_rfl hm @[measurability] theorem measurable_from_top [MeasurableSpace β] {f : α → β} : Measurable[⊤] f := fun _ _ => trivial theorem measurable_generateFrom [MeasurableSpace α] {s : Set (Set β)} {f : α → β} (h : ∀ t ∈ s, MeasurableSet (f ⁻¹' t)) : @Measurable _ _ _ (generateFrom s) f := Measurable.of_le_map <| generateFrom_le h variable {f g : α → β} section TypeclassMeasurableSpace variable [MeasurableSpace α] [MeasurableSpace β] @[nontriviality, measurability] theorem Subsingleton.measurable [Subsingleton α] : Measurable f := fun _ _ => @Subsingleton.measurableSet α _ _ _ @[nontriviality, measurability] theorem measurable_of_subsingleton_codomain [Subsingleton β] (f : α → β) : Measurable f := fun s _ => Subsingleton.set_cases MeasurableSet.empty MeasurableSet.univ s @[to_additive (attr := measurability, fun_prop)] theorem measurable_one [One α] : Measurable (1 : β → α) := @measurable_const _ _ _ _ 1 theorem measurable_of_empty [IsEmpty α] (f : α → β) : Measurable f := Subsingleton.measurable theorem measurable_of_empty_codomain [IsEmpty β] (f : α → β) : Measurable f := measurable_of_subsingleton_codomain f /-- A version of `measurable_const` that assumes `f x = f y` for all `x, y`. This version works for functions between empty types. -/ theorem measurable_const' {f : β → α} (hf : ∀ x y, f x = f y) : Measurable f := by nontriviality β inhabit β convert @measurable_const α β _ _ (f default) using 2 apply hf @[measurability] theorem measurable_natCast [NatCast α] (n : ℕ) : Measurable (n : β → α) := @measurable_const α _ _ _ n @[measurability] theorem measurable_intCast [IntCast α] (n : ℤ) : Measurable (n : β → α) := @measurable_const α _ _ _ n theorem measurable_of_countable [Countable α] [MeasurableSingletonClass α] (f : α → β) : Measurable f := fun s _ => (f ⁻¹' s).to_countable.measurableSet theorem measurable_of_finite [Finite α] [MeasurableSingletonClass α] (f : α → β) : Measurable f := measurable_of_countable f end TypeclassMeasurableSpace variable {m : MeasurableSpace α} @[measurability] theorem Measurable.iterate {f : α → α} (hf : Measurable f) : ∀ n, Measurable f^[n] | 0 => measurable_id | n + 1 => (Measurable.iterate hf n).comp hf variable {mβ : MeasurableSpace β} @[measurability] theorem measurableSet_preimage {t : Set β} (hf : Measurable f) (ht : MeasurableSet t) : MeasurableSet (f ⁻¹' t) := hf ht protected theorem MeasurableSet.preimage {t : Set β} (ht : MeasurableSet t) (hf : Measurable f) : MeasurableSet (f ⁻¹' t) := hf ht @[measurability, fun_prop] protected theorem Measurable.piecewise {_ : DecidablePred (· ∈ s)} (hs : MeasurableSet s) (hf : Measurable f) (hg : Measurable g) : Measurable (piecewise s f g) := by intro t ht rw [piecewise_preimage] exact hs.ite (hf ht) (hg ht) /-- This is slightly different from `Measurable.piecewise`. It can be used to show `Measurable (ite (x=0) 0 1)` by `exact Measurable.ite (measurableSet_singleton 0) measurable_const measurable_const`, but replacing `Measurable.ite` by `Measurable.piecewise` in that example proof does not work. -/ theorem Measurable.ite {p : α → Prop} {_ : DecidablePred p} (hp : MeasurableSet { a : α | p a }) (hf : Measurable f) (hg : Measurable g) : Measurable fun x => ite (p x) (f x) (g x) := Measurable.piecewise hp hf hg @[measurability, fun_prop] theorem Measurable.indicator [Zero β] (hf : Measurable f) (hs : MeasurableSet s) : Measurable (s.indicator f) := hf.piecewise hs measurable_const /-- The measurability of a set `A` is equivalent to the measurability of the indicator function which takes a constant value `b ≠ 0` on a set `A` and `0` elsewhere. -/ lemma measurable_indicator_const_iff [Zero β] [MeasurableSingletonClass β] (b : β) [NeZero b] : Measurable (s.indicator (fun (_ : α) ↦ b)) ↔ MeasurableSet s := by constructor <;> intro h · convert h (MeasurableSet.singleton (0 : β)).compl ext a simp [NeZero.ne b] · exact measurable_const.indicator h @[to_additive (attr := measurability)] theorem measurableSet_mulSupport [One β] [MeasurableSingletonClass β] (hf : Measurable f) : MeasurableSet (Function.mulSupport f) := hf (measurableSet_singleton 1).compl /-- If a function coincides with a measurable function outside of a countable set, it is measurable. -/ theorem Measurable.measurable_of_countable_ne [MeasurableSingletonClass α] (hf : Measurable f) (h : Set.Countable { x | f x ≠ g x }) : Measurable g := by intro t ht have : g ⁻¹' t = g ⁻¹' t ∩ { x | f x = g x }ᶜ ∪ g ⁻¹' t ∩ { x | f x = g x } := by simp [← inter_union_distrib_left] rw [this] refine (h.mono inter_subset_right).measurableSet.union ?_ have : g ⁻¹' t ∩ { x : α | f x = g x } = f ⁻¹' t ∩ { x : α | f x = g x } := by ext x simp +contextual rw [this] exact (hf ht).inter h.measurableSet.of_compl end MeasurableFunctions /-- We say that a collection of sets is countably spanning if a countable subset spans the whole type. This is a useful condition in various parts of measure theory. For example, it is a needed condition to show that the product of two collections generate the product sigma algebra, see `generateFrom_prod_eq`. -/ def IsCountablySpanning (C : Set (Set α)) : Prop := ∃ s : ℕ → Set α, (∀ n, s n ∈ C) ∧ ⋃ n, s n = univ theorem isCountablySpanning_measurableSet [MeasurableSpace α] : IsCountablySpanning { s : Set α | MeasurableSet s } := ⟨fun _ => univ, fun _ => MeasurableSet.univ, iUnion_const _⟩ /-- Rectangles of countably spanning sets are countably spanning. -/ lemma IsCountablySpanning.prod {C : Set (Set α)} {D : Set (Set β)} (hC : IsCountablySpanning C) (hD : IsCountablySpanning D) : IsCountablySpanning (image2 (· ×ˢ ·) C D) := by rcases hC, hD with ⟨⟨s, h1s, h2s⟩, t, h1t, h2t⟩ refine ⟨fun n => s n.unpair.1 ×ˢ t n.unpair.2, fun n => mem_image2_of_mem (h1s _) (h1t _), ?_⟩ rw [iUnion_unpair_prod, h2s, h2t, univ_prod_univ]
SplitLengths.lean
/- Copyright (c) 2024 Daniel Weber. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Daniel Weber -/ import Mathlib.Algebra.Group.Nat.Defs import Mathlib.Order.MinMax /-! # Splitting a list to chunks of specified lengths This file defines splitting a list to chunks of given lengths, and some proofs about that. -/ variable {α : Type*} (l : List α) (sz : List ℕ) namespace List /-- Split a list to chunks of given lengths. -/ def splitLengths : List ℕ → List α → List (List α) | [], _ => [] | n::ns, x => let (x0, x1) := x.splitAt n x0 :: ns.splitLengths x1 @[simp] theorem length_splitLengths : (sz.splitLengths l).length = sz.length := by induction sz generalizing l <;> simp [splitLengths, *] @[simp] lemma splitLengths_nil : [].splitLengths l = [] := rfl @[simp] lemma splitLengths_cons (n : ℕ) : (n :: sz).splitLengths l = l.take n :: sz.splitLengths (l.drop n) := by simp [splitLengths] theorem take_splitLength (i : ℕ) : (sz.splitLengths l).take i = (sz.take i).splitLengths l := by induction i generalizing sz l case zero => simp case succ i hi => cases sz · simp · simp only [splitLengths_cons, take_succ_cons, hi] theorem length_splitLengths_getElem_le {i : ℕ} {hi : i < (sz.splitLengths l).length} : (sz.splitLengths l)[i].length ≤ sz[i]'(by simpa using hi) := by induction sz generalizing l i · simp at hi case cons head tail tail_ih => simp only [splitLengths_cons] cases i · simp · simp only [getElem_cons_succ, tail_ih] theorem flatten_splitLengths (h : l.length ≤ sz.sum) : (sz.splitLengths l).flatten = l := by induction sz generalizing l · simp_all case cons head tail ih => simp only [splitLengths_cons, flatten_cons] rw [ih, take_append_drop] simpa [add_comm] using h theorem map_splitLengths_length (h : sz.sum ≤ l.length) : (sz.splitLengths l).map length = sz := by induction sz generalizing l · simp case cons head tail ih => simp only [sum_cons] at h simp only [splitLengths_cons, map_cons, length_take, cons.injEq, min_eq_left_iff] rw [ih] · simp [Nat.le_of_add_right_le h] · simp [Nat.le_sub_of_add_le' h] theorem length_splitLengths_getElem_eq {i : ℕ} (hi : i < sz.length) (h : (sz.take (i + 1)).sum ≤ l.length) : ((sz.splitLengths l)[i]'(by simpa)).length = sz[i] := by rw [List.getElem_take' (hj := i.lt_add_one)] simp only [take_splitLength] conv_rhs => rw [List.getElem_take' (hj := i.lt_add_one)] simp +singlePass only [← map_splitLengths_length l _ h] rw [getElem_map] theorem splitLengths_length_getElem {α : Type*} (l : List α) (sz : List ℕ) (h : sz.sum ≤ l.length) (i : ℕ) (hi : i < (sz.splitLengths l).length) : (sz.splitLengths l)[i].length = sz[i]'(by simpa using hi) := by have := map_splitLengths_length l sz h rw [← List.getElem_map List.length] · simp [this] · simpa using hi theorem length_mem_splitLengths {α : Type*} (l : List α) (sz : List ℕ) (b : ℕ) (h : ∀ n ∈ sz, n ≤ b) : ∀ l₂ ∈ sz.splitLengths l, l₂.length ≤ b := by rw [← List.forall_getElem] intro i hi have := length_splitLengths_getElem_le l sz (hi := hi) have := h (sz[i]'(by simpa using hi)) (getElem_mem ..) omega end List
CartesianMonoidal.lean
/- Copyright (c) 2024 Robin Carlier. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Robin Carlier -/ import Mathlib.CategoryTheory.Monoidal.Cartesian.FunctorCategory import Mathlib.CategoryTheory.Sites.Limits /-! # Chosen finite products on sheaves In this file, we put a `CartesianMonoidalCategory` instance on `A`-valued sheaves for a `GrothendieckTopology` whenever `A` has a `CartesianMonoidalCategory` instance. -/ universe v₁ v₂ u₁ u₂ namespace CategoryTheory open Opposite Category Limits Sieve MonoidalCategory CartesianMonoidalCategory variable {C : Type u₁} [Category.{v₁} C] variable {A : Type u₂} [Category.{v₂} A] variable (J : GrothendieckTopology C) variable [CartesianMonoidalCategory A] namespace Sheaf variable (X Y : Sheaf J A) lemma tensorProd_isSheaf : Presheaf.IsSheaf J (X.val ⊗ Y.val) := by apply isSheaf_of_isLimit (E := (Cones.postcompose (pairComp X Y (sheafToPresheaf J A)).inv).obj (BinaryFan.mk (fst X.val Y.val) (snd _ _))) exact (IsLimit.postcomposeInvEquiv _ _).invFun (tensorProductIsBinaryProduct X.val Y.val) lemma tensorUnit_isSheaf : Presheaf.IsSheaf J (𝟙_ (Cᵒᵖ ⥤ A)) := by apply isSheaf_of_isLimit (E := (Cones.postcompose (Functor.uniqueFromEmpty _).inv).obj (asEmptyCone (𝟙_ _))) · exact (IsLimit.postcomposeInvEquiv _ _).invFun isTerminalTensorUnit · exact .empty _ /-- Any `CartesianMonoidalCategory` on `A` induce a `CartesianMonoidalCategory` structure on `A`-valued sheaves. -/ noncomputable instance cartesianMonoidalCategory : CartesianMonoidalCategory (Sheaf J A) := .ofChosenFiniteProducts ({cone := asEmptyCone { val := 𝟙_ (Cᵒᵖ ⥤ A), cond := tensorUnit_isSheaf _} isLimit.lift f := ⟨toUnit f.pt.val⟩ isLimit.fac := by rintro _ ⟨⟨⟩⟩ isLimit.uniq x f h := Sheaf.hom_ext _ _ (toUnit_unique f.val _) }) fun X Y ↦ { cone := BinaryFan.mk (P := { val := X.val ⊗ Y.val cond := tensorProd_isSheaf J X Y}) ⟨(fst _ _)⟩ ⟨(snd _ _)⟩ isLimit.lift f := ⟨lift (BinaryFan.fst f).val (BinaryFan.snd f).val⟩ isLimit.fac := by rintro s ⟨⟨j⟩⟩ <;> apply Sheaf.hom_ext <;> simp isLimit.uniq x f h := by apply Sheaf.hom_ext apply CartesianMonoidalCategory.hom_ext · specialize h ⟨.left⟩ rw [Sheaf.hom_ext_iff] at h simpa using h · specialize h ⟨.right⟩ rw [Sheaf.hom_ext_iff] at h simpa using h } @[simp] lemma cartesianMonoidalCategoryFst_val : (fst X Y).val = fst X.val Y.val := rfl @[simp] lemma cartesianMonoidalCategorySnd_val : (snd X Y).val = snd X.val Y.val := rfl variable {X Y} variable {W : Sheaf J A} (f : W ⟶ X) (g : W ⟶ Y) @[simp] lemma cartesianMonoidalCategoryLift_val : (lift f g).val = lift f.val g.val := rfl @[simp] lemma cartesianMonoidalCategoryWhiskerLeft_val : (X ◁ f).val = X.val ◁ f.val := rfl @[simp] lemma cartesianMonoidalCategoryWhiskerRight_val : (f ▷ X).val = f.val ▷ X.val := rfl end Sheaf /-- The inclusion from sheaves to presheaves is monoidal with respect to the cartesian monoidal structures. -/ noncomputable instance sheafToPresheafMonoidal : (sheafToPresheaf J A).Monoidal := Functor.CoreMonoidal.toMonoidal { εIso := .refl _ μIso F G := .refl _ } open Functor.LaxMonoidal Functor.OplaxMonoidal @[simp] lemma sheafToPresheaf_ε : ε (sheafToPresheaf J A) = 𝟙 _ := rfl @[simp] lemma sheafToPresheaf_η : η (sheafToPresheaf J A) = 𝟙 _ := rfl variable {J} @[simp] lemma sheafToPresheaf_μ (X Y : Sheaf J A) : μ (sheafToPresheaf J A) X Y = 𝟙 _ := rfl @[simp] lemma sheafToPresheaf_δ (X Y : Sheaf J A) : δ (sheafToPresheaf J A) X Y = 𝟙 _ := rfl end CategoryTheory
IndexNormal.lean
/- Copyright (c) 2025 Antoine Chambert-Loir. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Antoine Chambert-Loir -/ import Mathlib.Data.Finite.Perm import Mathlib.Data.Nat.Prime.Factorial import Mathlib.GroupTheory.Index /-! # Subgroups of small index are normal * `Subgroup.normal_of_index_eq_smallest_prime_factor`: in a finite group `G`, a subgroup of index equal to the smallest prime factor of `Nat.card G` is normal. * `Subgroup.normal_of_index_two`: in a group `G`, a subgroup of index 2 is normal (This does not require `G` to be finite.) -/ assert_not_exists Field open MulAction MonoidHom Nat variable {G : Type*} [Group G] {H : Subgroup G} {p : ℕ} namespace Subgroup /-- A subgroup of index 1 is normal (does not require finiteness of G) -/ theorem normal_of_index_eq_one (hH : H.index = 1) : H.Normal := by rw [index_eq_one] at hH rw [hH] infer_instance /-- A subgroup of index 2 is normal (does not require finiteness of G) -/ theorem normal_of_index_eq_two (hH : H.index = 2) : H.Normal where conj_mem x hxH g := by simp_rw [mul_mem_iff_of_index_two hH, hxH, iff_true, inv_mem_iff] /-- A subgroup of a finite group whose index is the smallest prime factor is normal. Note : if `G` is infinite, then `Nat.card G = 0` and `(Nat.card G).minFac = 2` -/ theorem normal_of_index_eq_minFac_card (hHp : H.index = (Nat.card G).minFac) : H.Normal := by by_cases hG0 : Nat.card G = 0 · rw [hG0, minFac_zero] at hHp exact normal_of_index_eq_two hHp by_cases hG1 : Nat.card G = 1 · rw [hG1, minFac_one] at hHp exact normal_of_index_eq_one hHp suffices H.normalCore.relindex H = 1 by convert H.normalCore_normal exact le_antisymm (relindex_eq_one.mp this) (normalCore_le H) have : Finite G := finite_of_card_ne_zero hG0 have index_ne_zero : H.index ≠ 0 := index_ne_zero_of_finite rw [← mul_left_inj' index_ne_zero, one_mul, relindex_mul_index H.normalCore_le] have hp : Nat.Prime H.index := hHp ▸ minFac_prime hG1 have h : H.normalCore.index ∣ H.index ! := by rw [normalCore_eq_ker, index_ker, index_eq_card, ← Nat.card_perm] exact card_subgroup_dvd_card (toPermHom G (G ⧸ H)).range apply dvd_antisymm _ (index_dvd_of_le H.normalCore_le) rwa [← Coprime.dvd_mul_right, mul_factorial_pred hp.ne_zero] have hr1 : H.normalCore.index ≠ 1 := fun hr1 ↦ hp.ne_one <| Nat.eq_one_of_dvd_one (hr1 ▸ H.normalCore.index_dvd_of_le H.normalCore_le) rw [Nat.coprime_factorial_iff hr1] exact lt_of_lt_of_le (Nat.sub_one_lt hp.ne_zero) <| hHp ▸ minFac_le_of_dvd (Nat.minFac_prime hr1).two_le (dvd_trans (minFac_dvd H.normalCore.index) (H.normalCore.index_dvd_card)) end Subgroup
commutator.v
(* (c) Copyright 2006-2016 Microsoft Corporation and Inria. *) (* Distributed under the terms of CeCILL-B. *) From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat fintype. From mathcomp Require Import bigop finset binomial fingroup morphism. From mathcomp Require Import automorphism quotient gfunctor. (******************************************************************************) (* This files contains the proofs of several key properties of commutators, *) (* including the Hall-Witt identity and the Three Subgroup Lemma. *) (* The definition and notation for both pointwise and set wise commutators *) (* ([~x, y, ...] and [~: A, B ,...], respectively) are given in fingroup.v *) (* This file defines the derived group series: *) (* G^`(0) == G *) (* G^`(n.+1) == [~: G^`(n), G^`(n)] *) (* as several classical results involve the (first) derived group G^`(1), *) (* such as the equivalence H <| G /\ G / H abelian <-> G^`(1) \subset H. *) (* The connection between the derived series and solvable groups will only be *) (* established in nilpotent.v, however. *) (******************************************************************************) Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. Import GroupScope. Definition derived_at n (gT : finGroupType) (A : {set gT}) := iter n (fun B => [~: B, B]) A. Arguments derived_at n%_N {gT} A%_g : simpl never. Notation "G ^` ( n )" := (derived_at n G) : group_scope. Section DerivedBasics. Variables gT : finGroupType. Implicit Type A : {set gT}. Implicit Types G : {group gT}. Lemma derg0 A : A^`(0) = A. Proof. by []. Qed. Lemma derg1 A : A^`(1) = [~: A, A]. Proof. by []. Qed. Lemma dergSn n A : A^`(n.+1) = [~: A^`(n), A^`(n)]. Proof. by []. Qed. Lemma der_group_set G n : group_set G^`(n). Proof. by case: n => [|n]; apply: groupP. Qed. Canonical derived_at_group G n := Group (der_group_set G n). End DerivedBasics. Notation "G ^` ( n )" := (derived_at_group G n) : Group_scope. Section Basic_commutator_properties. Variable gT : finGroupType. Implicit Types x y z : gT. Lemma conjg_mulR x y : x ^ y = x * [~ x, y]. Proof. by rewrite mulKVg. Qed. Lemma conjg_Rmul x y : x ^ y = [~ y, x^-1] * x. Proof. by rewrite commgEr invgK mulgKV. Qed. Lemma commMgJ x y z : [~ x * y, z] = [~ x, z] ^ y * [~ y, z]. Proof. by rewrite !commgEr conjgM mulgA -conjMg mulgK. Qed. Lemma commgMJ x y z : [~ x, y * z] = [~ x, z] * [~ x, y] ^ z. Proof. by rewrite !commgEl conjgM -mulgA -conjMg mulKVg. Qed. Lemma commMgR x y z : [~ x * y, z] = [~ x, z] * [~ x, z, y] * [~ y, z]. Proof. by rewrite commMgJ conjg_mulR. Qed. Lemma commgMR x y z : [~ x, y * z] = [~ x, z] * [~ x, y] * [~ x, y, z]. Proof. by rewrite commgMJ conjg_mulR mulgA. Qed. Lemma Hall_Witt_identity x y z : [~ x, y^-1, z] ^ y * [~ y, z^-1, x] ^ z * [~ z, x^-1, y] ^ x = 1. Proof. (* gsimpl *) pose a x y z : gT := x * z * y ^ x. suffices{x y z} hw_aux x y z: [~ x, y^-1, z] ^ y = (a x y z)^-1 * (a y z x). by rewrite !hw_aux 2!mulgA !mulgK mulVg. by rewrite commgEr conjMg -conjgM -conjg_Rmul 2!invMg conjgE !mulgA. Qed. (* the following properties are useful for studying p-groups of class 2 *) Section LeftComm. Variables (i : nat) (x y : gT). Hypothesis cxz : commute x [~ x, y]. Lemma commVg : [~ x^-1, y] = [~ x, y]^-1. Proof. apply/eqP; rewrite commgEl eq_sym eq_invg_mul invgK mulgA -cxz. by rewrite -conjg_mulR -conjMg mulgV conj1g. Qed. Lemma commXg : [~ x ^+ i, y] = [~ x, y] ^+ i. Proof. elim: i => [|i' IHi]; first exact: comm1g. by rewrite !expgS commMgJ /conjg commuteX // mulKg IHi. Qed. End LeftComm. Section RightComm. Variables (i : nat) (x y : gT). Hypothesis cyz : commute y [~ x, y]. Let cyz' := commuteV cyz. Lemma commgV : [~ x, y^-1] = [~ x, y]^-1. Proof. by rewrite -invg_comm commVg -(invg_comm x y) ?invgK. Qed. Lemma commgX : [~ x, y ^+ i] = [~ x, y] ^+ i. Proof. by rewrite -invg_comm commXg -(invg_comm x y) ?expgVn ?invgK. Qed. End RightComm. Section LeftRightComm. Variables (i j : nat) (x y : gT). Hypotheses (cxz : commute x [~ x, y]) (cyz : commute y [~ x, y]). Lemma commXXg : [~ x ^+ i, y ^+ j] = [~ x, y] ^+ (i * j). Proof. by rewrite expgM commgX commXg //; apply: commuteX. Qed. Lemma expMg_Rmul : (y * x) ^+ i = y ^+ i * x ^+ i * [~ x, y] ^+ 'C(i, 2). Proof. rewrite -bin2_sum; symmetry. elim: i => [|k IHk] /=; first by rewrite big_geq ?mulg1. rewrite big_nat_recr //= addnC expgD !expgS -{}IHk !mulgA; congr (_ * _). by rewrite -!mulgA commuteX2 // -commgX // [mulg y]lock 3!mulgA -commgC. Qed. End LeftRightComm. End Basic_commutator_properties. (***** Set theoretic commutators *****) Section Commutator_properties. Variable gT : finGroupType. Implicit Type (rT : finGroupType) (A B C : {set gT}) (D G H K : {group gT}). Lemma commG1 A : [~: A, 1] = 1. Proof. by apply/commG1P; rewrite centsC sub1G. Qed. Lemma comm1G A : [~: 1, A] = 1. Proof. by rewrite commGC commG1. Qed. Lemma commg_sub A B : [~: A, B] \subset A <*> B. Proof. by rewrite comm_subG // (joing_subl, joing_subr). Qed. Lemma commg_norml G A : G \subset 'N([~: G, A]). Proof. apply/subsetP=> x Gx; rewrite inE -genJ gen_subG. apply/subsetP=> _ /imsetP[_ /imset2P[y z Gy Az ->] ->]. by rewrite -(mulgK [~ x, z] (_ ^ x)) -commMgJ !(mem_commg, groupMl, groupV). Qed. Lemma commg_normr G A : G \subset 'N([~: A, G]). Proof. by rewrite commGC commg_norml. Qed. Lemma commg_norm G H : G <*> H \subset 'N([~: G, H]). Proof. by rewrite join_subG ?commg_norml ?commg_normr. Qed. Lemma commg_normal G H : [~: G, H] <| G <*> H. Proof. by rewrite /(_ <| _) commg_sub commg_norm. Qed. Lemma normsRl A G B : A \subset G -> A \subset 'N([~: G, B]). Proof. by move=> sAG; apply: subset_trans (commg_norml G B). Qed. Lemma normsRr A G B : A \subset G -> A \subset 'N([~: B, G]). Proof. by move=> sAG; apply: subset_trans (commg_normr G B). Qed. Lemma commg_subr G H : ([~: G, H] \subset H) = (G \subset 'N(H)). Proof. rewrite gen_subG; apply/subsetP/subsetP=> [sRH x Gx | nGH xy]. rewrite inE; apply/subsetP=> _ /imsetP[y Ky ->]. by rewrite conjg_Rmul groupMr // sRH // imset2_f ?groupV. case/imset2P=> x y Gx Hy ->{xy}. by rewrite commgEr groupMr // memJ_norm (groupV, nGH). Qed. Lemma commg_subl G H : ([~: G, H] \subset G) = (H \subset 'N(G)). Proof. by rewrite commGC commg_subr. Qed. Lemma commg_subI A B G H : A \subset 'N_G(H) -> B \subset 'N_H(G) -> [~: A, B] \subset G :&: H. Proof. rewrite !subsetI -(gen_subG _ 'N(G)) -(gen_subG _ 'N(H)). rewrite -commg_subr -commg_subl; case/andP=> sAG sRH; case/andP=> sBH sRG. by rewrite (subset_trans _ sRG) ?(subset_trans _ sRH) ?commgSS ?subset_gen. Qed. Lemma quotient_cents2 A B K : A \subset 'N(K) -> B \subset 'N(K) -> (A / K \subset 'C(B / K)) = ([~: A, B] \subset K). Proof. move=> nKA nKB. by rewrite (sameP commG1P trivgP) /= -quotientR // quotient_sub1 // comm_subG. Qed. Lemma quotient_cents2r A B K : [~: A, B] \subset K -> (A / K) \subset 'C(B / K). Proof. move=> sABK; rewrite -2![_ / _]morphimIdom -!quotientE. by rewrite quotient_cents2 ?subsetIl ?(subset_trans _ sABK) ?commgSS ?subsetIr. Qed. Lemma sub_der1_norm G H : G^`(1) \subset H -> H \subset G -> G \subset 'N(H). Proof. by move=> sG'H sHG; rewrite -commg_subr (subset_trans _ sG'H) ?commgS. Qed. Lemma sub_der1_normal G H : G^`(1) \subset H -> H \subset G -> H <| G. Proof. by move=> sG'H sHG; rewrite /(H <| G) sHG sub_der1_norm. Qed. Lemma sub_der1_abelian G H : G^`(1) \subset H -> abelian (G / H). Proof. by move=> sG'H; apply: quotient_cents2r. Qed. Lemma der1_min G H : G \subset 'N(H) -> abelian (G / H) -> G^`(1) \subset H. Proof. by move=> nHG abGH; rewrite -quotient_cents2. Qed. Lemma der_abelian n G : abelian (G^`(n) / G^`(n.+1)). Proof. by rewrite sub_der1_abelian // der_subS. Qed. Lemma commg_normSl G H K : G \subset 'N(H) -> [~: G, H] \subset 'N([~: K, H]). Proof. by move=> nHG; rewrite normsRr // commg_subr. Qed. Lemma commg_normSr G H K : G \subset 'N(H) -> [~: H, G] \subset 'N([~: H, K]). Proof. by move=> nHG; rewrite !(commGC H) commg_normSl. Qed. Lemma commMGr G H K : [~: G, K] * [~: H, K] \subset [~: G * H , K]. Proof. by rewrite mul_subG ?commSg ?(mulG_subl, mulG_subr). Qed. Lemma commMG G H K : H \subset 'N([~: G, K]) -> [~: G * H , K] = [~: G, K] * [~: H, K]. Proof. move=> nRH; apply/eqP; rewrite eqEsubset commMGr andbT. have nRHK: [~: H, K] \subset 'N([~: G, K]) by rewrite comm_subG ?commg_normr. have defM := norm_joinEr nRHK; rewrite -defM gen_subG /=. apply/subsetP=> _ /imset2P[_ z /imset2P[x y Gx Hy ->] Kz ->]. by rewrite commMgJ {}defM mem_mulg ?memJ_norm ?mem_commg // (subsetP nRH). Qed. Lemma comm3G1P A B C : reflect {in A & B & C, forall h k l, [~ h, k, l] = 1} ([~: A, B, C] :==: 1). Proof. have R_C := sameP trivgP commG1P. rewrite -subG1 R_C gen_subG -{}R_C gen_subG. apply: (iffP subsetP) => [cABC x y z Ax By Cz | cABC xyz]. by apply/set1P; rewrite cABC // !imset2_f. by case/imset2P=> _ z /imset2P[x y Ax By ->] Cz ->; rewrite cABC. Qed. Lemma three_subgroup G H K : [~: G, H, K] :=: 1 -> [~: H, K, G] :=: 1-> [~: K, G, H] :=: 1. Proof. move/eqP/comm3G1P=> cGHK /eqP/comm3G1P cHKG. apply/eqP/comm3G1P=> x y z Kx Gy Hz; symmetry. rewrite -(conj1g y) -(Hall_Witt_identity y^-1 z x) invgK. by rewrite cGHK ?groupV // cHKG ?groupV // !conj1g !mul1g conjgKV. Qed. Lemma der1_joing_cycles (x y : gT) : let XY := <[x]> <*> <[y]> in let xy := [~ x, y] in xy \in 'C(XY) -> XY^`(1) = <[xy]>. Proof. rewrite joing_idl joing_idr /= -sub_cent1 => /norms_gen nRxy. apply/eqP; rewrite eqEsubset cycle_subG mem_commg ?mem_gen ?set21 ?set22 //. rewrite der1_min // quotient_gen -1?gen_subG // quotientU abelian_gen. rewrite /abelian subUset centU !subsetI andbC centsC -andbA -!abelianE. rewrite !quotient_abelian ?(abelianS (subset_gen _) (cycle_abelian _)) //=. by rewrite andbb quotient_cents2r ?genS // /commg_set imset2_set1l imset_set1. Qed. Lemma commgAC G x y z : x \in G -> y \in G -> z \in G -> commute y z -> abelian [~: [set x], G] -> [~ x, y, z] = [~ x, z, y]. Proof. move=> Gx Gy Gz cyz /centsP cRxG; pose cx' u := [~ x^-1, u]. have xR3 u v: [~ x, u, v] = x^-1 * (cx' u * cx' v) * x ^ (u * v). rewrite mulgA -conjg_mulR conjVg [cx' v]commgEl mulgA -invMg. by rewrite -mulgA conjgM -conjMg -!commgEl. suffices RxGcx' u: u \in G -> cx' u \in [~: [set x], G]. by rewrite !xR3 {}cyz; congr (_ * _ * _); rewrite cRxG ?RxGcx'. move=> Gu; suffices/groupMl <-: [~ x, u] ^ x^-1 \in [~: [set x], G]. by rewrite -commMgJ mulgV comm1g group1. by rewrite memJ_norm ?mem_commg ?set11 // groupV (subsetP (commg_normr _ _)). Qed. (* Aschbacher, exercise 3.6 (used in proofs of Aschbacher 24.7 and B & G 1.10 *) Lemma comm_norm_cent_cent H G K : H \subset 'N(G) -> H \subset 'C(K) -> G \subset 'N(K) -> [~: G, H] \subset 'C(K). Proof. move=> nGH /centsP cKH nKG; rewrite commGC gen_subG centsC. apply/centsP=> x Kx _ /imset2P[y z Hy Gz ->]; red. rewrite mulgA -[x * _]cKH ?groupV // -!mulgA; congr (_ * _). rewrite (mulgA x) (conjgC x) (conjgCV z) 3!mulgA; congr (_ * _). by rewrite -2!mulgA (cKH y) // -mem_conjg (normsP nKG). Qed. Lemma charR H K G : H \char G -> K \char G -> [~: H, K] \char G. Proof. case/charP=> sHG chH /charP[sKG chK]; apply/charP. by split=> [|f infj Gf]; [rewrite comm_subG | rewrite morphimR // chH // chK]. Qed. Lemma der_char n G : G^`(n) \char G. Proof. by elim: n => [|n IHn]; rewrite ?char_refl // dergSn charR. Qed. Lemma der_sub n G : G^`(n) \subset G. Proof. by rewrite char_sub ?der_char. Qed. Lemma der_norm n G : G \subset 'N(G^`(n)). Proof. by rewrite char_norm ?der_char. Qed. Lemma der_normal n G : G^`(n) <| G. Proof. by rewrite char_normal ?der_char. Qed. Lemma der_subS n G : G^`(n.+1) \subset G^`(n). Proof. by rewrite comm_subG. Qed. Lemma der_normalS n G : G^`(n.+1) <| G^`(n). Proof. by rewrite sub_der1_normal // der_subS. Qed. Lemma morphim_der rT D (f : {morphism D >-> rT}) n G : G \subset D -> f @* G^`(n) = (f @* G)^`(n). Proof. move=> sGD; elim: n => // n IHn. by rewrite !dergSn -IHn morphimR ?(subset_trans (der_sub n G)). Qed. Lemma dergS n G H : G \subset H -> G^`(n) \subset H^`(n). Proof. by move=> sGH; elim: n => // n IHn; apply: commgSS. Qed. Lemma quotient_der n G H : G \subset 'N(H) -> G^`(n) / H = (G / H)^`(n). Proof. exact: morphim_der. Qed. Lemma derJ G n x : (G :^ x)^`(n) = G^`(n) :^ x. Proof. by elim: n => //= n IHn; rewrite !dergSn IHn -conjsRg. Qed. Lemma derG1P G : reflect (G^`(1) = 1) (abelian G). Proof. exact: commG1P. Qed. End Commutator_properties. Arguments derG1P {gT G}. Lemma der_cont n : GFunctor.continuous (@derived_at n). Proof. by move=> aT rT G f; rewrite morphim_der. Qed. Canonical der_igFun n := [igFun by der_sub^~ n & der_cont n]. Canonical der_gFun n := [gFun by der_cont n]. Canonical der_mgFun n := [mgFun by dergS^~ n]. Lemma isog_der (aT rT : finGroupType) n (G : {group aT}) (H : {group rT}) : G \isog H -> G^`(n) \isog H^`(n). Proof. exact: gFisog. Qed.
Prime.lean
/- Copyright (c) 2020 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes -/ import Mathlib.Algebra.Ring.Divisibility.Basic import Mathlib.Algebra.Order.Group.Unbundled.Abs import Mathlib.Algebra.Prime.Defs import Mathlib.Algebra.Ring.Units import Mathlib.Algebra.BigOperators.Group.Finset.Basic /-! # Prime elements in rings This file contains lemmas about prime elements of commutative rings. -/ section CancelCommMonoidWithZero variable {R : Type*} [CancelCommMonoidWithZero R] open Finset /-- If `x * y = a * ∏ i ∈ s, p i` where `p i` is always prime, then `x` and `y` can both be written as a divisor of `a` multiplied by a product over a subset of `s` -/ theorem mul_eq_mul_prime_prod {α : Type*} [DecidableEq α] {x y a : R} {s : Finset α} {p : α → R} (hp : ∀ i ∈ s, Prime (p i)) (hx : x * y = a * ∏ i ∈ s, p i) : ∃ (t u : Finset α) (b c : R), t ∪ u = s ∧ Disjoint t u ∧ a = b * c ∧ (x = b * ∏ i ∈ t, p i) ∧ y = c * ∏ i ∈ u, p i := by induction' s using Finset.induction with i s his ih generalizing x y a · exact ⟨∅, ∅, x, y, by simp [hx]⟩ · rw [prod_insert his, ← mul_assoc] at hx have hpi : Prime (p i) := hp i (mem_insert_self _ _) rcases ih (fun i hi ↦ hp i (mem_insert_of_mem hi)) hx with ⟨t, u, b, c, htus, htu, hbc, rfl, rfl⟩ have hit : i ∉ t := fun hit ↦ his (htus ▸ mem_union_left _ hit) have hiu : i ∉ u := fun hiu ↦ his (htus ▸ mem_union_right _ hiu) obtain ⟨d, rfl⟩ | ⟨d, rfl⟩ : p i ∣ b ∨ p i ∣ c := hpi.dvd_or_dvd ⟨a, by rw [← hbc, mul_comm]⟩ · rw [mul_assoc, mul_comm a, mul_right_inj' hpi.ne_zero] at hbc exact ⟨insert i t, u, d, c, by rw [insert_union, htus], disjoint_insert_left.2 ⟨hiu, htu⟩, by simp [hbc, prod_insert hit, mul_comm, mul_left_comm]⟩ · rw [← mul_assoc, mul_right_comm b, mul_left_inj' hpi.ne_zero] at hbc exact ⟨t, insert i u, b, d, by rw [union_insert, htus], disjoint_insert_right.2 ⟨hit, htu⟩, by simp [← hbc, prod_insert hiu, mul_comm, mul_left_comm]⟩ /-- If `x * y = a * p ^ n` where `p` is prime, then `x` and `y` can both be written as the product of a power of `p` and a divisor of `a`. -/ theorem mul_eq_mul_prime_pow {x y a p : R} {n : ℕ} (hp : Prime p) (hx : x * y = a * p ^ n) : ∃ (i j : ℕ) (b c : R), i + j = n ∧ a = b * c ∧ x = b * p ^ i ∧ y = c * p ^ j := by rcases mul_eq_mul_prime_prod (fun _ _ ↦ hp) (show x * y = a * (range n).prod fun _ ↦ p by simpa) with ⟨t, u, b, c, htus, htu, rfl, rfl, rfl⟩ exact ⟨#t, #u, b, c, by rw [← card_union_of_disjoint htu, htus, card_range], by simp⟩ end CancelCommMonoidWithZero section CommRing variable {α : Type*} [CommRing α] theorem Prime.neg {p : α} (hp : Prime p) : Prime (-p) := by obtain ⟨h1, h2, h3⟩ := hp exact ⟨neg_ne_zero.mpr h1, by rwa [IsUnit.neg_iff], by simpa [neg_dvd] using h3⟩ theorem Prime.abs [LinearOrder α] {p : α} (hp : Prime p) : Prime (abs p) := by obtain h | h := abs_choice p <;> rw [h] · exact hp · exact hp.neg end CommRing
Interval.lean
/- Copyright (c) 2022 Yaël Dillies. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yaël Dillies -/ import Mathlib.Data.Sigma.Order import Mathlib.Order.Interval.Finset.Defs /-! # Finite intervals in a sigma type This file provides the `LocallyFiniteOrder` instance for the disjoint sum of orders `Σ i, α i` and calculates the cardinality of its finite intervals. ## TODO Do the same for the lexicographical order -/ open Finset Function namespace Sigma variable {ι : Type*} {α : ι → Type*} /-! ### Disjoint sum of orders -/ section Disjoint section LocallyFiniteOrder variable [DecidableEq ι] [∀ i, Preorder (α i)] [∀ i, LocallyFiniteOrder (α i)] instance instLocallyFiniteOrder : LocallyFiniteOrder (Σ i, α i) where finsetIcc := sigmaLift fun _ => Icc finsetIco := sigmaLift fun _ => Ico finsetIoc := sigmaLift fun _ => Ioc finsetIoo := sigmaLift fun _ => Ioo finset_mem_Icc := fun ⟨i, a⟩ ⟨j, b⟩ ⟨k, c⟩ => by simp_rw [mem_sigmaLift, le_def, mem_Icc, exists_and_left, ← exists_and_right, ← exists_prop] exact exists₂_congr fun _ _ => by constructor <;> rintro ⟨⟨⟩, ht⟩ <;> exact ⟨rfl, ht⟩ finset_mem_Ico := fun ⟨i, a⟩ ⟨j, b⟩ ⟨k, c⟩ => by simp_rw [mem_sigmaLift, le_def, lt_def, mem_Ico, exists_and_left, ← exists_and_right, ← exists_prop] exact exists₂_congr fun _ _ => by constructor <;> rintro ⟨⟨⟩, ht⟩ <;> exact ⟨rfl, ht⟩ finset_mem_Ioc := fun ⟨i, a⟩ ⟨j, b⟩ ⟨k, c⟩ => by simp_rw [mem_sigmaLift, le_def, lt_def, mem_Ioc, exists_and_left, ← exists_and_right, ← exists_prop] exact exists₂_congr fun _ _ => by constructor <;> rintro ⟨⟨⟩, ht⟩ <;> exact ⟨rfl, ht⟩ finset_mem_Ioo := fun ⟨i, a⟩ ⟨j, b⟩ ⟨k, c⟩ => by simp_rw [mem_sigmaLift, lt_def, mem_Ioo, exists_and_left, ← exists_and_right, ← exists_prop] exact exists₂_congr fun _ _ => by constructor <;> rintro ⟨⟨⟩, ht⟩ <;> exact ⟨rfl, ht⟩ section variable (a b : Σ i, α i) theorem card_Icc : #(Icc a b) = if h : a.1 = b.1 then #(Icc (h.rec a.2) b.2) else 0 := card_sigmaLift (fun _ => Icc) _ _ theorem card_Ico : #(Ico a b) = if h : a.1 = b.1 then #(Ico (h.rec a.2) b.2) else 0 := card_sigmaLift (fun _ => Ico) _ _ theorem card_Ioc : #(Ioc a b) = if h : a.1 = b.1 then #(Ioc (h.rec a.2) b.2) else 0 := card_sigmaLift (fun _ => Ioc) _ _ theorem card_Ioo : #(Ioo a b) = if h : a.1 = b.1 then #(Ioo (h.rec a.2) b.2) else 0 := card_sigmaLift (fun _ => Ioo) _ _ end variable (i : ι) (a b : α i) @[simp] theorem Icc_mk_mk : Icc (⟨i, a⟩ : Sigma α) ⟨i, b⟩ = (Icc a b).map (Embedding.sigmaMk i) := dif_pos rfl @[simp] theorem Ico_mk_mk : Ico (⟨i, a⟩ : Sigma α) ⟨i, b⟩ = (Ico a b).map (Embedding.sigmaMk i) := dif_pos rfl @[simp] theorem Ioc_mk_mk : Ioc (⟨i, a⟩ : Sigma α) ⟨i, b⟩ = (Ioc a b).map (Embedding.sigmaMk i) := dif_pos rfl @[simp] theorem Ioo_mk_mk : Ioo (⟨i, a⟩ : Sigma α) ⟨i, b⟩ = (Ioo a b).map (Embedding.sigmaMk i) := dif_pos rfl end LocallyFiniteOrder section LocallyFiniteOrderBot variable [∀ i, Preorder (α i)] [∀ i, LocallyFiniteOrderBot (α i)] instance instLocallyFiniteOrderBot : LocallyFiniteOrderBot (Σ i, α i) where finsetIic | ⟨i, a⟩ => (Iic a).map (Embedding.sigmaMk i) finsetIio | ⟨i, a⟩ => (Iio a).map (Embedding.sigmaMk i) finset_mem_Iic := fun ⟨i, a⟩ ⟨j, b⟩ => by obtain rfl | hij := eq_or_ne i j · simp · simp [hij, le_def, hij.symm] finset_mem_Iio := fun ⟨i, a⟩ ⟨j, b⟩ => by obtain rfl | hij := eq_or_ne i j · simp · simp [hij, lt_def, hij.symm] variable (i : ι) (a : α i) @[simp] theorem Iic_mk : Iic (⟨i, a⟩ : Sigma α) = (Iic a).map (Embedding.sigmaMk i) := rfl @[simp] theorem Iio_mk : Iio (⟨i, a⟩ : Sigma α) = (Iio a).map (Embedding.sigmaMk i) := rfl end LocallyFiniteOrderBot section LocallyFiniteOrderTop variable [∀ i, Preorder (α i)] [∀ i, LocallyFiniteOrderTop (α i)] instance instLocallyFiniteOrderTop : LocallyFiniteOrderTop (Σ i, α i) where finsetIci | ⟨i, a⟩ => (Ici a).map (Embedding.sigmaMk i) finsetIoi | ⟨i, a⟩ => (Ioi a).map (Embedding.sigmaMk i) finset_mem_Ici := fun ⟨i, a⟩ ⟨j, b⟩ => by obtain rfl | hij := eq_or_ne i j · simp · simp [hij, le_def] finset_mem_Ioi := fun ⟨i, a⟩ ⟨j, b⟩ => by obtain rfl | hij := eq_or_ne i j · simp · simp [hij, lt_def] variable (i : ι) (a : α i) @[simp] theorem Ici_mk : Ici (⟨i, a⟩ : Sigma α) = (Ici a).map (Embedding.sigmaMk i) := rfl @[simp] theorem Ioi_mk : Ioi (⟨i, a⟩ : Sigma α) = (Ioi a).map (Embedding.sigmaMk i) := rfl end LocallyFiniteOrderTop end Disjoint end Sigma
Set.lean
/- Copyright (c) 2014 Jeremy Avigad. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jeremy Avigad, Leonardo de Moura -/ import Mathlib.Data.Set.Insert import Mathlib.Order.BooleanAlgebra.Basic /-! # Boolean algebra of sets This file proves that `Set α` is a boolean algebra, and proves results about set difference and complement. ## Notation * `sᶜ` for the complement of `s` ## Tags set, sets, subset, subsets, complement -/ assert_not_exists RelIso open Function namespace Set variable {α β : Type*} {s s₁ s₂ t t₁ t₂ u : Set α} {a b : α} instance instBooleanAlgebra : BooleanAlgebra (Set α) where __ : DistribLattice (Set α) := inferInstance __ : BooleanAlgebra (α → Prop) := inferInstance compl := (·ᶜ) sdiff := (· \ ·) /-- See also `Set.sdiff_inter_right_comm`. -/ lemma inter_diff_assoc (a b c : Set α) : (a ∩ b) \ c = a ∩ (b \ c) := inf_sdiff_assoc .. /-- See also `Set.inter_diff_assoc`. -/ lemma sdiff_inter_right_comm (s t u : Set α) : s \ t ∩ u = (s ∩ u) \ t := sdiff_inf_right_comm .. lemma inter_sdiff_left_comm (s t u : Set α) : s ∩ (t \ u) = t ∩ (s \ u) := inf_sdiff_left_comm .. theorem diff_union_diff_cancel (hts : t ⊆ s) (hut : u ⊆ t) : s \ t ∪ t \ u = s \ u := sdiff_sup_sdiff_cancel hts hut /-- A version of `diff_union_diff_cancel` with more general hypotheses. -/ theorem diff_union_diff_cancel' (hi : s ∩ u ⊆ t) (hu : t ⊆ s ∪ u) : (s \ t) ∪ (t \ u) = s \ u := sdiff_sup_sdiff_cancel' hi hu theorem diff_diff_eq_sdiff_union (h : u ⊆ s) : s \ (t \ u) = s \ t ∪ u := sdiff_sdiff_eq_sdiff_sup h theorem inter_diff_distrib_left (s t u : Set α) : s ∩ (t \ u) = (s ∩ t) \ (s ∩ u) := inf_sdiff_distrib_left _ _ _ theorem inter_diff_distrib_right (s t u : Set α) : (s \ t) ∩ u = (s ∩ u) \ (t ∩ u) := inf_sdiff_distrib_right _ _ _ theorem diff_inter_distrib_right (s t r : Set α) : (t ∩ r) \ s = (t \ s) ∩ (r \ s) := inf_sdiff /-! ### Lemmas about complement -/ theorem compl_def (s : Set α) : sᶜ = { x | x ∉ s } := rfl theorem mem_compl {s : Set α} {x : α} (h : x ∉ s) : x ∈ sᶜ := h theorem compl_setOf {α} (p : α → Prop) : { a | p a }ᶜ = { a | ¬p a } := rfl theorem notMem_of_mem_compl {s : Set α} {x : α} (h : x ∈ sᶜ) : x ∉ s := h @[deprecated (since := "2025-05-23")] alias not_mem_of_mem_compl := notMem_of_mem_compl theorem notMem_compl_iff {x : α} : x ∉ sᶜ ↔ x ∈ s := not_not @[deprecated (since := "2025-05-23")] alias not_mem_compl_iff := notMem_compl_iff @[simp] theorem inter_compl_self (s : Set α) : s ∩ sᶜ = ∅ := inf_compl_eq_bot @[simp] theorem compl_inter_self (s : Set α) : sᶜ ∩ s = ∅ := compl_inf_eq_bot @[simp] theorem compl_empty : (∅ : Set α)ᶜ = univ := compl_bot @[simp] theorem compl_union (s t : Set α) : (s ∪ t)ᶜ = sᶜ ∩ tᶜ := compl_sup theorem compl_inter (s t : Set α) : (s ∩ t)ᶜ = sᶜ ∪ tᶜ := compl_inf @[simp] theorem compl_univ : (univ : Set α)ᶜ = ∅ := compl_top @[simp] theorem compl_empty_iff {s : Set α} : sᶜ = ∅ ↔ s = univ := compl_eq_bot @[simp] theorem compl_univ_iff {s : Set α} : sᶜ = univ ↔ s = ∅ := compl_eq_top theorem compl_ne_univ : sᶜ ≠ univ ↔ s.Nonempty := compl_univ_iff.not.trans nonempty_iff_ne_empty.symm lemma inl_compl_union_inr_compl {s : Set α} {t : Set β} : Sum.inl '' sᶜ ∪ Sum.inr '' tᶜ = (Sum.inl '' s ∪ Sum.inr '' t)ᶜ := by rw [compl_union] aesop theorem nonempty_compl : sᶜ.Nonempty ↔ s ≠ univ := (ne_univ_iff_exists_notMem s).symm theorem union_eq_compl_compl_inter_compl (s t : Set α) : s ∪ t = (sᶜ ∩ tᶜ)ᶜ := ext fun _ => or_iff_not_and_not theorem inter_eq_compl_compl_union_compl (s t : Set α) : s ∩ t = (sᶜ ∪ tᶜ)ᶜ := ext fun _ => and_iff_not_or_not @[simp] theorem union_compl_self (s : Set α) : s ∪ sᶜ = univ := eq_univ_iff_forall.2 fun _ => em _ @[simp] theorem compl_union_self (s : Set α) : sᶜ ∪ s = univ := by rw [union_comm, union_compl_self] theorem compl_subset_comm : sᶜ ⊆ t ↔ tᶜ ⊆ s := @compl_le_iff_compl_le _ s _ _ theorem subset_compl_comm : s ⊆ tᶜ ↔ t ⊆ sᶜ := @le_compl_iff_le_compl _ _ _ t @[simp] theorem compl_subset_compl : sᶜ ⊆ tᶜ ↔ t ⊆ s := @compl_le_compl_iff_le (Set α) _ _ _ @[gcongr] theorem compl_subset_compl_of_subset (h : t ⊆ s) : sᶜ ⊆ tᶜ := compl_subset_compl.2 h theorem subset_union_compl_iff_inter_subset {s t u : Set α} : s ⊆ t ∪ uᶜ ↔ s ∩ u ⊆ t := (@isCompl_compl _ u _).le_sup_right_iff_inf_left_le theorem compl_subset_iff_union {s t : Set α} : sᶜ ⊆ t ↔ s ∪ t = univ := Iff.symm <| eq_univ_iff_forall.trans <| forall_congr' fun _ => or_iff_not_imp_left theorem inter_subset (a b c : Set α) : a ∩ b ⊆ c ↔ a ⊆ bᶜ ∪ c := forall_congr' fun _ => and_imp.trans <| imp_congr_right fun _ => imp_iff_not_or theorem inter_compl_nonempty_iff {s t : Set α} : (s ∩ tᶜ).Nonempty ↔ ¬s ⊆ t := (not_subset.trans <| exists_congr fun x => by simp).symm lemma subset_compl_iff_disjoint_left : s ⊆ tᶜ ↔ Disjoint t s := le_compl_iff_disjoint_left lemma subset_compl_iff_disjoint_right : s ⊆ tᶜ ↔ Disjoint s t := le_compl_iff_disjoint_right lemma disjoint_compl_left_iff_subset : Disjoint sᶜ t ↔ t ⊆ s := disjoint_compl_left_iff lemma disjoint_compl_right_iff_subset : Disjoint s tᶜ ↔ s ⊆ t := disjoint_compl_right_iff alias ⟨_, _root_.Disjoint.subset_compl_right⟩ := subset_compl_iff_disjoint_right alias ⟨_, _root_.Disjoint.subset_compl_left⟩ := subset_compl_iff_disjoint_left alias ⟨_, _root_.HasSubset.Subset.disjoint_compl_left⟩ := disjoint_compl_left_iff_subset alias ⟨_, _root_.HasSubset.Subset.disjoint_compl_right⟩ := disjoint_compl_right_iff_subset @[simp] lemma nonempty_compl_of_nontrivial [Nontrivial α] (x : α) : Set.Nonempty {x}ᶜ := exists_ne x lemma mem_compl_singleton_iff : a ∈ ({b} : Set α)ᶜ ↔ a ≠ b := .rfl lemma compl_singleton_eq (a : α) : {a}ᶜ = {x | x ≠ a} := rfl @[simp] lemma compl_ne_eq_singleton (a : α) : {x | x ≠ a}ᶜ = {a} := compl_compl _ @[simp] lemma subset_compl_singleton_iff : s ⊆ {a}ᶜ ↔ a ∉ s := subset_compl_comm.trans singleton_subset_iff /-! ### Lemmas about set difference -/ theorem notMem_diff_of_mem {s t : Set α} {x : α} (hx : x ∈ t) : x ∉ s \ t := fun h => h.2 hx @[deprecated (since := "2025-05-23")] alias not_mem_diff_of_mem := notMem_diff_of_mem theorem mem_of_mem_diff {s t : Set α} {x : α} (h : x ∈ s \ t) : x ∈ s := h.left theorem notMem_of_mem_diff {s t : Set α} {x : α} (h : x ∈ s \ t) : x ∉ t := h.right @[deprecated (since := "2025-05-23")] alias not_mem_of_mem_diff := notMem_of_mem_diff theorem diff_eq_compl_inter {s t : Set α} : s \ t = tᶜ ∩ s := by rw [diff_eq, inter_comm] theorem diff_nonempty {s t : Set α} : (s \ t).Nonempty ↔ ¬s ⊆ t := inter_compl_nonempty_iff theorem diff_subset {s t : Set α} : s \ t ⊆ s := show s \ t ≤ s from sdiff_le theorem diff_subset_compl (s t : Set α) : s \ t ⊆ tᶜ := diff_eq_compl_inter ▸ inter_subset_left theorem union_diff_cancel' {s t u : Set α} (h₁ : s ⊆ t) (h₂ : t ⊆ u) : t ∪ u \ s = u := sup_sdiff_cancel' h₁ h₂ theorem union_diff_cancel {s t : Set α} (h : s ⊆ t) : s ∪ t \ s = t := sup_sdiff_cancel_right h theorem union_diff_cancel_left {s t : Set α} (h : s ∩ t ⊆ ∅) : (s ∪ t) \ s = t := Disjoint.sup_sdiff_cancel_left <| disjoint_iff_inf_le.2 h theorem union_diff_cancel_right {s t : Set α} (h : s ∩ t ⊆ ∅) : (s ∪ t) \ t = s := Disjoint.sup_sdiff_cancel_right <| disjoint_iff_inf_le.2 h @[simp] theorem union_diff_left {s t : Set α} : (s ∪ t) \ s = t \ s := sup_sdiff_left_self @[simp] theorem union_diff_right {s t : Set α} : (s ∪ t) \ t = s \ t := sup_sdiff_right_self theorem union_diff_distrib {s t u : Set α} : (s ∪ t) \ u = s \ u ∪ t \ u := sup_sdiff @[simp] theorem inter_diff_self (a b : Set α) : a ∩ (b \ a) = ∅ := inf_sdiff_self_right @[simp] theorem inter_union_diff (s t : Set α) : s ∩ t ∪ s \ t = s := sup_inf_sdiff s t @[simp] theorem diff_union_inter (s t : Set α) : s \ t ∪ s ∩ t = s := by rw [union_comm] exact sup_inf_sdiff _ _ @[simp] theorem inter_union_compl (s t : Set α) : s ∩ t ∪ s ∩ tᶜ = s := inter_union_diff _ _ theorem subset_inter_union_compl_left (s t : Set α) : t ⊆ s ∩ t ∪ sᶜ := by simp [inter_union_distrib_right] theorem subset_inter_union_compl_right (s t : Set α) : s ⊆ s ∩ t ∪ tᶜ := by simp [inter_union_distrib_right] theorem union_inter_compl_left_subset (s t : Set α) : (s ∪ t) ∩ sᶜ ⊆ t := by simp [union_inter_distrib_right] theorem union_inter_compl_right_subset (s t : Set α) : (s ∪ t) ∩ tᶜ ⊆ s := by simp [union_inter_distrib_right] @[gcongr] theorem diff_subset_diff {s₁ s₂ t₁ t₂ : Set α} : s₁ ⊆ s₂ → t₂ ⊆ t₁ → s₁ \ t₁ ⊆ s₂ \ t₂ := show s₁ ≤ s₂ → t₂ ≤ t₁ → s₁ \ t₁ ≤ s₂ \ t₂ from sdiff_le_sdiff theorem diff_subset_diff_left {s₁ s₂ t : Set α} (h : s₁ ⊆ s₂) : s₁ \ t ⊆ s₂ \ t := sdiff_le_sdiff_right ‹s₁ ≤ s₂› theorem diff_subset_diff_right {s t u : Set α} (h : t ⊆ u) : s \ u ⊆ s \ t := sdiff_le_sdiff_left ‹t ≤ u› theorem diff_subset_diff_iff_subset {r : Set α} (hs : s ⊆ r) (ht : t ⊆ r) : r \ s ⊆ r \ t ↔ t ⊆ s := sdiff_le_sdiff_iff_le hs ht theorem compl_eq_univ_diff (s : Set α) : sᶜ = univ \ s := top_sdiff.symm @[simp] theorem empty_diff (s : Set α) : (∅ \ s : Set α) = ∅ := bot_sdiff theorem diff_eq_empty {s t : Set α} : s \ t = ∅ ↔ s ⊆ t := sdiff_eq_bot_iff @[simp] theorem diff_empty {s : Set α} : s \ ∅ = s := sdiff_bot @[simp] theorem diff_univ (s : Set α) : s \ univ = ∅ := diff_eq_empty.2 (subset_univ s) theorem diff_diff {u : Set α} : (s \ t) \ u = s \ (t ∪ u) := sdiff_sdiff_left -- the following statement contains parentheses to help the reader theorem diff_diff_comm {s t u : Set α} : (s \ t) \ u = (s \ u) \ t := sdiff_sdiff_comm theorem diff_subset_iff {s t u : Set α} : s \ t ⊆ u ↔ s ⊆ t ∪ u := show s \ t ≤ u ↔ s ≤ t ∪ u from sdiff_le_iff theorem subset_diff_union (s t : Set α) : s ⊆ s \ t ∪ t := show s ≤ s \ t ∪ t from le_sdiff_sup theorem diff_union_of_subset {s t : Set α} (h : t ⊆ s) : s \ t ∪ t = s := Subset.antisymm (union_subset diff_subset h) (subset_diff_union _ _) theorem diff_subset_comm {s t u : Set α} : s \ t ⊆ u ↔ s \ u ⊆ t := show s \ t ≤ u ↔ s \ u ≤ t from sdiff_le_comm theorem diff_inter {s t u : Set α} : s \ (t ∩ u) = s \ t ∪ s \ u := sdiff_inf theorem diff_inter_diff : s \ t ∩ (s \ u) = s \ (t ∪ u) := sdiff_sup.symm theorem diff_compl : s \ tᶜ = s ∩ t := sdiff_compl theorem compl_diff : (t \ s)ᶜ = s ∪ tᶜ := Eq.trans compl_sdiff himp_eq theorem diff_diff_right {s t u : Set α} : s \ (t \ u) = s \ t ∪ s ∩ u := sdiff_sdiff_right' theorem inter_diff_right_comm : (s ∩ t) \ u = s \ u ∩ t := by rw [diff_eq, diff_eq, inter_right_comm] theorem diff_inter_right_comm : (s \ u) ∩ t = (s ∩ t) \ u := by rw [diff_eq, diff_eq, inter_right_comm] @[simp] theorem union_diff_self {s t : Set α} : s ∪ t \ s = s ∪ t := sup_sdiff_self _ _ @[simp] theorem diff_union_self {s t : Set α} : s \ t ∪ t = s ∪ t := sdiff_sup_self _ _ @[simp] theorem diff_inter_self {a b : Set α} : b \ a ∩ a = ∅ := inf_sdiff_self_left @[simp] theorem diff_inter_self_eq_diff {s t : Set α} : s \ (t ∩ s) = s \ t := sdiff_inf_self_right _ _ @[simp] theorem diff_self_inter {s t : Set α} : s \ (s ∩ t) = s \ t := sdiff_inf_self_left _ _ theorem diff_self {s : Set α} : s \ s = ∅ := sdiff_self theorem diff_diff_right_self (s t : Set α) : s \ (s \ t) = s ∩ t := sdiff_sdiff_right_self theorem diff_diff_cancel_left {s t : Set α} (h : s ⊆ t) : t \ (t \ s) = s := sdiff_sdiff_eq_self h theorem union_eq_diff_union_diff_union_inter (s t : Set α) : s ∪ t = s \ t ∪ t \ s ∪ s ∩ t := sup_eq_sdiff_sup_sdiff_sup_inf @[simp] lemma sdiff_sep_self (s : Set α) (p : α → Prop) : s \ {a ∈ s | p a} = {a ∈ s | ¬ p a} := diff_self_inter lemma disjoint_sdiff_left : Disjoint (t \ s) s := disjoint_sdiff_self_left lemma disjoint_sdiff_right : Disjoint s (t \ s) := disjoint_sdiff_self_right -- TODO: prove this in terms of a boolean algebra lemma lemma disjoint_sdiff_inter : Disjoint (s \ t) (s ∩ t) := disjoint_of_subset_right inter_subset_right disjoint_sdiff_left lemma subset_diff : s ⊆ t \ u ↔ s ⊆ t ∧ Disjoint s u := le_iff_subset.symm.trans le_sdiff lemma disjoint_of_subset_iff_left_eq_empty (h : s ⊆ t) : Disjoint s t ↔ s = ∅ := disjoint_of_le_iff_left_eq_bot h @[simp] lemma diff_ssubset_left_iff : s \ t ⊂ s ↔ (s ∩ t).Nonempty := sdiff_lt_left.trans <| by rw [not_disjoint_iff_nonempty_inter, inter_comm] lemma _root_.HasSubset.Subset.diff_ssubset_of_nonempty (hst : s ⊆ t) (hs : s.Nonempty) : t \ s ⊂ t := by simpa [inter_eq_self_of_subset_right hst] lemma ssubset_iff_sdiff_singleton : s ⊂ t ↔ ∃ a ∈ t, s ⊆ t \ {a} := by simp [ssubset_iff_insert, subset_diff, insert_subset_iff]; aesop @[simp] lemma diff_singleton_subset_iff : s \ {a} ⊆ t ↔ s ⊆ insert a t := by rw [← union_singleton, union_comm] apply diff_subset_iff lemma subset_diff_singleton (h : s ⊆ t) (ha : a ∉ s) : s ⊆ t \ {a} := subset_inter h <| subset_compl_comm.1 <| singleton_subset_iff.2 ha lemma subset_insert_diff_singleton (x : α) (s : Set α) : s ⊆ insert x (s \ {x}) := by rw [← diff_singleton_subset_iff] lemma diff_insert_of_notMem (h : a ∉ s) : s \ insert a t = s \ t := by refine Subset.antisymm (diff_subset_diff (refl _) (subset_insert ..)) fun y hy ↦ ?_ simp only [mem_diff, mem_insert_iff, not_or] at hy ⊢ exact ⟨hy.1, fun hxy ↦ h <| hxy ▸ hy.1, hy.2⟩ @[deprecated (since := "2025-05-23")] alias diff_insert_of_not_mem := diff_insert_of_notMem @[simp] lemma insert_diff_of_mem (s) (h : a ∈ t) : insert a s \ t = s \ t := by ext constructor <;> simp +contextual [or_imp, h] lemma insert_diff_of_notMem (s) (h : a ∉ t) : insert a s \ t = insert a (s \ t) := by classical ext x by_cases h' : x ∈ t · simp [h', ne_of_mem_of_not_mem h' h] · simp [h'] @[deprecated (since := "2025-05-23")] alias insert_diff_of_not_mem := insert_diff_of_notMem lemma insert_diff_self_of_notMem (h : a ∉ s) : insert a s \ {a} = s := by ext x; simp [and_iff_left_of_imp (ne_of_mem_of_not_mem · h)] @[deprecated (since := "2025-05-23")] alias insert_diff_self_of_not_mem := insert_diff_self_of_notMem @[simp] lemma insert_diff_self_of_mem (ha : a ∈ s) : insert a (s \ {a}) = s := by ext; simp +contextual [or_and_left, em, ha] lemma insert_diff_subset : insert a s \ t ⊆ insert a (s \ t) := by rintro b ⟨rfl | hbs, hbt⟩ <;> simp [*] lemma insert_erase_invOn : InvOn (insert a) (fun s ↦ s \ {a}) {s : Set α | a ∈ s} {s : Set α | a ∉ s} := ⟨fun _s ha ↦ insert_diff_self_of_mem ha, fun _s ↦ insert_diff_self_of_notMem⟩ @[simp] lemma diff_singleton_eq_self (h : a ∉ s) : s \ {a} = s := sdiff_eq_self_iff_disjoint.2 <| by simp [h] lemma diff_singleton_ssubset : s \ {a} ⊂ s ↔ a ∈ s := by simp @[deprecated (since := "2025-03-20")] alias diff_singleton_sSubset := diff_singleton_ssubset @[simp] lemma insert_diff_singleton : insert a (s \ {a}) = insert a s := by simp [insert_eq, union_diff_self, -union_singleton, -singleton_union] lemma insert_diff_singleton_comm (hab : a ≠ b) (s : Set α) : insert a (s \ {b}) = insert a s \ {b} := by simp_rw [← union_singleton, union_diff_distrib, diff_singleton_eq_self (mem_singleton_iff.not.2 hab.symm)] @[simp] lemma insert_diff_insert : insert a (s \ insert a t) = insert a (s \ t) := by rw [← union_singleton (s := t), ← diff_diff, insert_diff_singleton] lemma mem_diff_singleton : a ∈ s \ {b} ↔ a ∈ s ∧ a ≠ b := .rfl lemma mem_diff_singleton_empty {t : Set (Set α)} : s ∈ t \ {∅} ↔ s ∈ t ∧ s.Nonempty := mem_diff_singleton.trans <| and_congr_right' nonempty_iff_ne_empty.symm lemma subset_insert_iff : s ⊆ insert a t ↔ s ⊆ t ∨ (a ∈ s ∧ s \ {a} ⊆ t) := by rw [← diff_singleton_subset_iff] by_cases hx : a ∈ s · rw [and_iff_right hx, or_iff_right_of_imp diff_subset.trans] rw [diff_singleton_eq_self hx, or_iff_left_of_imp And.right] lemma pair_diff_left (hab : a ≠ b) : ({a, b} : Set α) \ {a} = {b} := by rw [insert_diff_of_mem _ (mem_singleton a), diff_singleton_eq_self (by simpa)] lemma pair_diff_right (hab : a ≠ b) : ({a, b} : Set α) \ {b} = {a} := by rw [pair_comm, pair_diff_left hab.symm] /-! ### If-then-else for sets -/ /-- `ite` for sets: `Set.ite t s s' ∩ t = s ∩ t`, `Set.ite t s s' ∩ tᶜ = s' ∩ tᶜ`. Defined as `s ∩ t ∪ s' \ t`. -/ protected def ite (t s s' : Set α) : Set α := s ∩ t ∪ s' \ t @[simp] theorem ite_inter_self (t s s' : Set α) : t.ite s s' ∩ t = s ∩ t := by rw [Set.ite, union_inter_distrib_right, diff_inter_self, inter_assoc, inter_self, union_empty] @[simp] theorem ite_compl (t s s' : Set α) : tᶜ.ite s s' = t.ite s' s := by rw [Set.ite, Set.ite, diff_compl, union_comm, diff_eq] @[simp] theorem ite_inter_compl_self (t s s' : Set α) : t.ite s s' ∩ tᶜ = s' ∩ tᶜ := by rw [← ite_compl, ite_inter_self] @[simp] theorem ite_diff_self (t s s' : Set α) : t.ite s s' \ t = s' \ t := ite_inter_compl_self t s s' @[simp] theorem ite_same (t s : Set α) : t.ite s s = s := inter_union_diff _ _ @[simp] theorem ite_left (s t : Set α) : s.ite s t = s ∪ t := by simp [Set.ite] @[simp] theorem ite_right (s t : Set α) : s.ite t s = t ∩ s := by simp [Set.ite] @[simp] theorem ite_empty (s s' : Set α) : Set.ite ∅ s s' = s' := by simp [Set.ite] @[simp] theorem ite_univ (s s' : Set α) : Set.ite univ s s' = s := by simp [Set.ite] @[simp] theorem ite_empty_left (t s : Set α) : t.ite ∅ s = s \ t := by simp [Set.ite] @[simp] theorem ite_empty_right (t s : Set α) : t.ite s ∅ = s ∩ t := by simp [Set.ite] theorem ite_mono (t : Set α) {s₁ s₁' s₂ s₂' : Set α} (h : s₁ ⊆ s₂) (h' : s₁' ⊆ s₂') : t.ite s₁ s₁' ⊆ t.ite s₂ s₂' := union_subset_union (inter_subset_inter_left _ h) (inter_subset_inter_left _ h') theorem ite_subset_union (t s s' : Set α) : t.ite s s' ⊆ s ∪ s' := union_subset_union inter_subset_left diff_subset theorem inter_subset_ite (t s s' : Set α) : s ∩ s' ⊆ t.ite s s' := ite_same t (s ∩ s') ▸ ite_mono _ inter_subset_left inter_subset_right theorem ite_inter_inter (t s₁ s₂ s₁' s₂' : Set α) : t.ite (s₁ ∩ s₂) (s₁' ∩ s₂') = t.ite s₁ s₁' ∩ t.ite s₂ s₂' := by ext x simp only [Set.ite, Set.mem_inter_iff, Set.mem_diff, Set.mem_union] tauto theorem ite_inter (t s₁ s₂ s : Set α) : t.ite (s₁ ∩ s) (s₂ ∩ s) = t.ite s₁ s₂ ∩ s := by rw [ite_inter_inter, ite_same] theorem ite_inter_of_inter_eq (t : Set α) {s₁ s₂ s : Set α} (h : s₁ ∩ s = s₂ ∩ s) : t.ite s₁ s₂ ∩ s = s₁ ∩ s := by rw [← ite_inter, ← h, ite_same] theorem subset_ite {t s s' u : Set α} : u ⊆ t.ite s s' ↔ u ∩ t ⊆ s ∧ u \ t ⊆ s' := by simp only [subset_def, ← forall_and] refine forall_congr' fun x => ?_ by_cases hx : x ∈ t <;> simp [*, Set.ite] theorem ite_eq_of_subset_left (t : Set α) {s₁ s₂ : Set α} (h : s₁ ⊆ s₂) : t.ite s₁ s₂ = s₁ ∪ (s₂ \ t) := by ext x by_cases hx : x ∈ t <;> simp [*, Set.ite, or_iff_right_of_imp (@h x)] theorem ite_eq_of_subset_right (t : Set α) {s₁ s₂ : Set α} (h : s₂ ⊆ s₁) : t.ite s₁ s₂ = (s₁ ∩ t) ∪ s₂ := by ext x by_cases hx : x ∈ t <;> simp [*, Set.ite, or_iff_left_of_imp (@h x)] end Set
NonUnitalAlgebra.lean
/- Copyright (c) 2024 Jireh Loreaux. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jireh Loreaux -/ import Mathlib.Algebra.Algebra.NonUnitalSubalgebra import Mathlib.Topology.Algebra.Module.Basic /-! # Non-unital topological (sub)algebras A non-unital topological algebra over a topological semiring `R` is a topological (non-unital) semiring with a compatible continuous scalar multiplication by elements of `R`. We reuse typeclass `ContinuousSMul` to express the latter condition. ## Results Any non-unital subalgebra of a non-unital topological algebra is itself a non-unital topological algebra, and its closure is again a non-unital subalgebra. -/ namespace NonUnitalSubalgebra section Semiring variable {R A : Type*} [CommSemiring R] [TopologicalSpace A] variable [NonUnitalSemiring A] [Module R A] [IsTopologicalSemiring A] variable [ContinuousConstSMul R A] instance instIsTopologicalSemiring (s : NonUnitalSubalgebra R A) : IsTopologicalSemiring s := s.toNonUnitalSubsemiring.instIsTopologicalSemiring /-- The (topological) closure of a non-unital subalgebra of a non-unital topological algebra is itself a non-unital subalgebra. -/ def topologicalClosure (s : NonUnitalSubalgebra R A) : NonUnitalSubalgebra R A := { s.toNonUnitalSubsemiring.topologicalClosure, s.toSubmodule.topologicalClosure with carrier := _root_.closure (s : Set A) } theorem le_topologicalClosure (s : NonUnitalSubalgebra R A) : s ≤ s.topologicalClosure := subset_closure theorem isClosed_topologicalClosure (s : NonUnitalSubalgebra R A) : IsClosed (s.topologicalClosure : Set A) := isClosed_closure theorem topologicalClosure_minimal (s : NonUnitalSubalgebra R A) {t : NonUnitalSubalgebra R A} (h : s ≤ t) (ht : IsClosed (t : Set A)) : s.topologicalClosure ≤ t := closure_minimal h ht /-- If a non-unital subalgebra of a non-unital topological algebra is commutative, then so is its topological closure. See note [reducible non-instances]. -/ abbrev nonUnitalCommSemiringTopologicalClosure [T2Space A] (s : NonUnitalSubalgebra R A) (hs : ∀ x y : s, x * y = y * x) : NonUnitalCommSemiring s.topologicalClosure := s.toNonUnitalSubsemiring.nonUnitalCommSemiringTopologicalClosure hs end Semiring section Ring variable {R A : Type*} [CommRing R] [TopologicalSpace A] variable [NonUnitalRing A] [Module R A] [IsTopologicalRing A] variable [ContinuousConstSMul R A] instance instIsTopologicalRing (s : NonUnitalSubalgebra R A) : IsTopologicalRing s := s.toNonUnitalSubring.instIsTopologicalRing /-- If a non-unital subalgebra of a non-unital topological algebra is commutative, then so is its topological closure. See note [reducible non-instances]. -/ abbrev nonUnitalCommRingTopologicalClosure [T2Space A] (s : NonUnitalSubalgebra R A) (hs : ∀ x y : s, x * y = y * x) : NonUnitalCommRing s.topologicalClosure := { s.topologicalClosure.toNonUnitalRing, s.toSubsemigroup.commSemigroupTopologicalClosure hs with } end Ring end NonUnitalSubalgebra namespace NonUnitalAlgebra open NonUnitalSubalgebra variable (R : Type*) {A : Type*} [CommSemiring R] [NonUnitalSemiring A] variable [Module R A] [IsScalarTower R A A] [SMulCommClass R A A] variable [TopologicalSpace A] [IsTopologicalSemiring A] [ContinuousConstSMul R A] /-- The topological closure of the non-unital subalgebra generated by a single element. -/ def elemental (x : A) : NonUnitalSubalgebra R A := adjoin R {x} |>.topologicalClosure namespace elemental @[simp, aesop safe (rule_sets := [SetLike])] theorem self_mem (x : A) : x ∈ elemental R x := le_topologicalClosure _ <| self_mem_adjoin_singleton R x variable {R} in theorem le_of_mem {x : A} {s : NonUnitalSubalgebra R A} (hs : IsClosed (s : Set A)) (hx : x ∈ s) : elemental R x ≤ s := topologicalClosure_minimal _ (adjoin_le <| by simpa using hx) hs variable {R} in theorem le_iff_mem {x : A} {s : NonUnitalSubalgebra R A} (hs : IsClosed (s : Set A)) : elemental R x ≤ s ↔ x ∈ s := ⟨fun h ↦ h (self_mem R x), fun h ↦ le_of_mem hs h⟩ instance isClosed (x : A) : IsClosed (elemental R x : Set A) := isClosed_topologicalClosure _ instance [T2Space A] {x : A} : NonUnitalCommSemiring (elemental R x) := nonUnitalCommSemiringTopologicalClosure _ letI : NonUnitalCommSemiring (adjoin R {x}) := NonUnitalAlgebra.adjoinNonUnitalCommSemiringOfComm R fun y hy z hz => by rw [Set.mem_singleton_iff] at hy hz rw [hy, hz] fun _ _ => mul_comm _ _ instance {R A : Type*} [CommRing R] [NonUnitalRing A] [Module R A] [IsScalarTower R A A] [SMulCommClass R A A] [TopologicalSpace A] [IsTopologicalRing A] [ContinuousConstSMul R A] [T2Space A] {x : A} : NonUnitalCommRing (elemental R x) where mul_comm := mul_comm instance {A : Type*} [UniformSpace A] [CompleteSpace A] [NonUnitalSemiring A] [IsTopologicalSemiring A] [Module R A] [IsScalarTower R A A] [SMulCommClass R A A] [ContinuousConstSMul R A] (x : A) : CompleteSpace (elemental R x) := isClosed_closure.completeSpace_coe /-- The coercion from an elemental algebra to the full algebra is a `IsClosedEmbedding`. -/ theorem isClosedEmbedding_coe (x : A) : Topology.IsClosedEmbedding ((↑) : elemental R x → A) where eq_induced := rfl injective := Subtype.coe_injective isClosed_range := by simpa using isClosed R x end elemental end NonUnitalAlgebra
all_ssreflect.v
Attributes deprecated(since="mathcomp 2.5.0", note="Use 'all_boot' and/or 'all_order' instead."). From mathcomp Require Export all_boot. From mathcomp Require Export preorder. From mathcomp Require Export order.
falgebra.v
(* (c) Copyright 2006-2016 Microsoft Corporation and Inria. *) (* Distributed under the terms of CeCILL-B. *) From HB Require Import structures. From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq path. From mathcomp Require Import choice fintype div tuple finfun bigop ssralg. From mathcomp Require Import finalg zmodp matrix vector poly. (******************************************************************************) (* Finite dimensional free algebras, usually known as F-algebras *) (* *) (* falgType K == the interface type for F-algebras over K; it simply *) (* joins the unitAlgType K and vectType K interfaces *) (* The HB class is called Falgebra. *) (* Any aT with an falgType structure inherits all the Vector, NzRing and *) (* Algebra operations, and supports the following additional operations: *) (* \dim_A M == (\dim M %/ dim A)%N -- free module dimension *) (* amull u == the linear function v |-> u * v, for u, v : aT *) (* amulr u == the linear function v |-> v * u, for u, v : aT *) (* 1, f * g, f ^+ n == the identity function, the composite g \o f, the nth *) (* iterate of f, for 1, f, g in 'End(aT) *) (* This is just the usual F-algebra structure on *) (* 'End(aT). It is NOT canonical by default, but can be *) (* activated by the line Import FalgLfun. Beware also *) (* that (f^-1)%VF is the linear function inverse, not *) (* the ring inverse of f (though they do coincide when *) (* f is injective). *) (* 1%VS == the line generated by 1 : aT *) (* (U * V)%VS == the smallest subspace of aT that contains all *) (* products u * v for u in U, v in V *) (* (U ^+ n)%VS == (U * U * ... * U), n-times. U ^+ 0 = 1%VS *) (* 'C[u]%VS == the centraliser subspace of the vector u *) (* 'C_U[v]%VS := (U :&: 'C[v])%VS *) (* 'C(V)%VS == the centraliser subspace of the subspace V *) (* 'C_U(V)%VS := (U :&: 'C(V))%VS *) (* 'Z(V)%VS == the center subspace of the subspace V *) (* agenv U == the smallest subalgebra containing U ^+ n for all n *) (* <<U; v>>%VS == agenv (U + <[v]>) (adjoin v to U) *) (* <<U & vs>>%VS == agenv (U + <<vs>>) (adjoin vs to U) *) (* {aspace aT} == a subType of {vspace aT} consisting of sub-algebras *) (* of aT (see below); for A : {aspace aT}, subvs_of A *) (* has a canonical falgType K structure *) (* is_aspace U <=> the characteristic predicate of {aspace aT} stating *) (* that U is closed under product and contains an *) (* identity element, := has_algid U && (U * U <= U)%VS *) (* algid A == the identity element of A : {aspace aT}, which need *) (* not be equal to 1 (indeed, in a Wedderburn *) (* decomposition it is not even a unit in aT) *) (* is_algid U e <-> e : aT is an identity element for the subspace U: *) (* e in U, e != 0 & e * u = u * e = u for all u in U *) (* has_algid U <=> there is an e such that is_algid U e *) (* [aspace of U] == a clone of an existing {aspace aT} structure on *) (* U : {vspace aT} (more instances of {aspace aT} will *) (* be defined in extFieldType) *) (* [aspace of U for A] == a clone of A : {aspace aT} for U : {vspace aT} *) (* 1%AS == the canonical sub-algebra 1%VS *) (* {:aT}%AS == the canonical full algebra *) (* <<U>>%AS == the canonical algebra for agenv U; note that this is *) (* unrelated to <<vs>>%VS, the subspace spanned by vs *) (* <<U; v>>%AS == the canonical algebra for <<U; v>>%VS *) (* <<U & vs>>%AS == the canonical algebra for <<U & vs>>%VS *) (* ahom_in U f <=> f : 'Hom(aT, rT) is a multiplicative homomorphism *) (* inside U, and in addition f 1 = 1 (even if U doesn't *) (* contain 1) *) (* Note that f @: U need not be a subalgebra when U is, *) (* as f could annilate U. *) (* 'AHom(aT, rT) == the type of algebra homomorphisms from aT to rT, *) (* where aT and rT ARE falgType structures. Elements of *) (* 'AHom(aT, rT) coerce to 'End(aT, rT) and aT -> rT *) (* 'AEnd(aT) == algebra endomorphisms of aT (:= 'AHom(aT, aT)) *) (******************************************************************************) Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. Declare Scope aspace_scope. Declare Scope lrfun_scope. Local Open Scope ring_scope. Reserved Notation "{ 'aspace' T }" (format "{ 'aspace' T }"). Reserved Notation "<< U & vs >>" (format "<< U & vs >>"). Reserved Notation "<< U ; x >>" (format "<< U ; x >>"). Reserved Notation "''AHom' ( T , rT )" (format "''AHom' ( T , rT )"). Reserved Notation "''AEnd' ( T )" (format "''AEnd' ( T )"). Notation "\dim_ E V" := (divn (\dim V) (\dim E)) (at level 10, E at level 2, V at level 8, format "\dim_ E V") : nat_scope. Import GRing.Theory. (* Finite dimensional algebra *) #[short(type="falgType")] HB.structure Definition Falgebra (R : nzRingType) := { A of Vector R A & GRing.UnitAlgebra R A }. #[deprecated(since="mathcomp 2.0.0", note="Use falgType instead.")] Notation FalgType := falgType. (* Supply a default unitRing mixin for the default unitAlgType base type. *) HB.factory Record Algebra_isFalgebra (K : fieldType) A of Vector K A & GRing.Algebra K A := {}. HB.builders Context K A of Algebra_isFalgebra K A. Let vA : Vector.type K := A. Let am u := linfun (u \o* idfun : vA -> vA). Let uam := [pred u | lker (am u) == 0%VS]. Let vam := [fun u => if u \in uam then (am u)^-1%VF 1 else u]. Lemma amE u v : am u v = v * u. Proof. by rewrite lfunE. Qed. Lemma mulVr : {in uam, left_inverse 1 vam *%R}. Proof. by move=> u Uu; rewrite /= Uu -amE lker0_lfunVK. Qed. Lemma divrr : {in uam, right_inverse 1 vam *%R}. Proof. by move=> u Uu; apply/(lker0P Uu); rewrite !amE -mulrA mulVr // mul1r mulr1. Qed. Lemma unitrP : forall x y, y * x = 1 /\ x * y = 1 -> uam x. Proof. move=> u v [_ uv1]. by apply/lker0P=> w1 w2 /(congr1 (am v)); rewrite !amE -!mulrA uv1 !mulr1. Qed. Lemma invr_out : {in [predC uam], vam =1 id}. Proof. by move=> u /negbTE/= ->. Qed. HB.instance Definition _ := GRing.NzRing_hasMulInverse.Build A mulVr divrr unitrP invr_out. HB.end. Module FalgebraExports. Bind Scope ring_scope with sort. End FalgebraExports. HB.export FalgebraExports. Notation "1" := (vline 1) : vspace_scope. HB.instance Definition _ (K : fieldType) n := Algebra_isFalgebra.Build K 'M[K]_n.+1. HB.instance Definition _ (R : comUnitRingType) := GRing.UnitAlgebra.on R^o. (* FIXME: remove once https://github.com/math-comp/hierarchy-builder/issues/197 is fixed *) Lemma regular_fullv (K : fieldType) : (fullv = 1 :> {vspace K^o})%VS. Proof. by apply/esym/eqP; rewrite eqEdim subvf dim_vline oner_eq0 dimvf. Qed. Section Proper. Variables (R : nzRingType) (aT : falgType R). Import VectorInternalTheory. Lemma FalgType_proper : dim aT > 0. Proof. rewrite lt0n; apply: contraNneq (oner_neq0 aT) => aT0. by apply/eqP/v2r_inj; do 2!move: (v2r _); rewrite aT0 => u v; rewrite !thinmx0. Qed. End Proper. Module FalgLfun. Section FalgLfun. Variable (R : comNzRingType) (aT : falgType R). Implicit Types f g : 'End(aT). HB.instance Definition _ := GRing.Algebra.copy 'End(aT) (lfun_algType (FalgType_proper aT)). Lemma lfun_mulE f g u : (f * g) u = g (f u). Proof. exact: lfunE. Qed. Lemma lfun_compE f g : (g \o f)%VF = f * g. Proof. by []. Qed. End FalgLfun. Section InvLfun. Variable (K : fieldType) (aT : falgType K). Implicit Types f g : 'End(aT). Definition lfun_invr f := if lker f == 0%VS then f^-1%VF else f. Lemma lfun_mulVr f : lker f == 0%VS -> f^-1%VF * f = 1. Proof. exact: lker0_compfV. Qed. Lemma lfun_mulrV f : lker f == 0%VS -> f * f^-1%VF = 1. Proof. exact: lker0_compVf. Qed. Fact lfun_mulRVr f : lker f == 0%VS -> lfun_invr f * f = 1. Proof. by move=> Uf; rewrite /lfun_invr Uf lfun_mulVr. Qed. Fact lfun_mulrRV f : lker f == 0%VS -> f * lfun_invr f = 1. Proof. by move=> Uf; rewrite /lfun_invr Uf lfun_mulrV. Qed. Fact lfun_unitrP f g : g * f = 1 /\ f * g = 1 -> lker f == 0%VS. Proof. case=> _ fK; apply/lker0P; apply: can_inj (g) _ => u. by rewrite -lfun_mulE fK lfunE. Qed. Lemma lfun_invr_out f : lker f != 0%VS -> lfun_invr f = f. Proof. by rewrite /lfun_invr => /negPf->. Qed. HB.instance Definition _ := GRing.NzRing_hasMulInverse.Build 'End(aT) lfun_mulRVr lfun_mulrRV lfun_unitrP lfun_invr_out. Lemma lfun_invE f : lker f == 0%VS -> f^-1%VF = f^-1. Proof. by rewrite /f^-1 /= /lfun_invr => ->. Qed. End InvLfun. End FalgLfun. Section FalgebraTheory. Variables (K : fieldType) (aT : falgType K). Implicit Types (u v : aT) (U V W : {vspace aT}). Import FalgLfun. Definition amull u : 'End(aT) := linfun (u \*o @idfun aT). Definition amulr u : 'End(aT) := linfun (u \o* @idfun aT). Lemma amull_inj : injective amull. Proof. by move=> u v /lfunP/(_ 1); rewrite !lfunE /= !mulr1. Qed. Lemma amulr_inj : injective amulr. Proof. by move=> u v /lfunP/(_ 1); rewrite !lfunE /= !mul1r. Qed. Fact amull_is_linear : linear amull. Proof. move=> a u v; apply/lfunP => w. by rewrite !lfunE /= scale_lfunE !lfunE /= mulrDl scalerAl. Qed. #[hnf] HB.instance Definition _ := GRing.isSemilinear.Build K aT (hom aT aT) _ amull (GRing.semilinear_linear amull_is_linear). (* amull is a converse ring morphism *) Lemma amull1 : amull 1 = \1%VF. Proof. by apply/lfunP => z; rewrite id_lfunE lfunE /= mul1r. Qed. Lemma amullM u v : (amull (u * v) = amull v * amull u)%VF. Proof. by apply/lfunP => w; rewrite comp_lfunE !lfunE /= mulrA. Qed. Lemma amulr_is_linear : linear amulr. Proof. move=> a u v; apply/lfunP => w. by rewrite !lfunE /= !lfunE /= lfunE mulrDr /= scalerAr. Qed. Lemma amulr_is_monoid_morphism : monoid_morphism amulr. Proof. split=> [|x y]; first by apply/lfunP => w; rewrite id_lfunE !lfunE /= mulr1. by apply/lfunP=> w; rewrite comp_lfunE !lfunE /= mulrA. Qed. #[warning="-deprecated-since-mathcomp-2.5.0", deprecated(since="mathcomp 2.5.0", note="use `amulr_is_monoid_morphism` instead")] Definition amulr_is_multiplicative := (fun p => (p.2, p.1)) amulr_is_monoid_morphism. #[hnf] HB.instance Definition _ := GRing.isSemilinear.Build K aT (hom aT aT) _ amulr (GRing.semilinear_linear amulr_is_linear). #[hnf] HB.instance Definition _ := GRing.isMonoidMorphism.Build aT (hom aT aT) amulr amulr_is_monoid_morphism. Lemma lker0_amull u : u \is a GRing.unit -> lker (amull u) == 0%VS. Proof. by move=> Uu; apply/lker0P=> v w; rewrite !lfunE; apply: mulrI. Qed. Lemma lker0_amulr u : u \is a GRing.unit -> lker (amulr u) == 0%VS. Proof. by move=> Uu; apply/lker0P=> v w; rewrite !lfunE; apply: mulIr. Qed. Lemma lfun1_poly (p : {poly aT}) : map_poly \1%VF p = p. Proof. by apply: map_poly_id => u _; apply: id_lfunE. Qed. Fact prodv_key : unit. Proof. by []. Qed. Definition prodv := locked_with prodv_key (fun U V => <<allpairs *%R (vbasis U) (vbasis V)>>%VS). Canonical prodv_unlockable := [unlockable fun prodv]. Local Notation "A * B" := (prodv A B) : vspace_scope. Lemma memv_mul U V : {in U & V, forall u v, u * v \in (U * V)%VS}. Proof. move=> u v /coord_vbasis-> /coord_vbasis->. rewrite mulr_suml; apply: memv_suml => i _. rewrite mulr_sumr; apply: memv_suml => j _. rewrite -scalerAl -scalerAr !memvZ // [prodv]unlock memv_span //. by apply/allpairsP; exists ((vbasis U)`_i, (vbasis V)`_j); rewrite !memt_nth. Qed. Lemma prodvP {U V W} : reflect {in U & V, forall u v, u * v \in W} (U * V <= W)%VS. Proof. apply: (iffP idP) => [sUVW u v Uu Vv | sUVW]. by rewrite (subvP sUVW) ?memv_mul. rewrite [prodv]unlock; apply/span_subvP=> _ /allpairsP[[u v] /= [Uu Vv ->]]. by rewrite sUVW ?vbasis_mem. Qed. Lemma prodv_line u v : (<[u]> * <[v]> = <[u * v]>)%VS. Proof. apply: subv_anti; rewrite -memvE memv_mul ?memv_line // andbT. apply/prodvP=> _ _ /vlineP[a ->] /vlineP[b ->]. by rewrite -scalerAr -scalerAl !memvZ ?memv_line. Qed. Lemma dimv1: \dim (1%VS : {vspace aT}) = 1. Proof. by rewrite dim_vline oner_neq0. Qed. Lemma dim_prodv U V : \dim (U * V) <= \dim U * \dim V. Proof. by rewrite unlock (leq_trans (dim_span _)) ?size_tuple. Qed. Lemma vspace1_neq0 : (1 != 0 :> {vspace aT})%VS. Proof. by rewrite -dimv_eq0 dimv1. Qed. Lemma vbasis1 : exists2 k, k != 0 & vbasis 1 = [:: k%:A] :> seq aT. Proof. move: (vbasis 1) (@vbasisP K aT 1); rewrite dim_vline oner_neq0. case/tupleP=> x X0; rewrite {X0}tuple0 => defX; have Xx := mem_head x nil. have /vlineP[k def_x] := basis_mem defX Xx; exists k; last by rewrite def_x. by have:= basis_not0 defX Xx; rewrite def_x scaler_eq0 oner_eq0 orbF. Qed. Lemma prod0v : left_zero 0%VS prodv. Proof. move=> U; apply/eqP; rewrite -dimv_eq0 -leqn0 (leq_trans (dim_prodv 0 U)) //. by rewrite dimv0. Qed. Lemma prodv0 : right_zero 0%VS prodv. Proof. move=> U; apply/eqP; rewrite -dimv_eq0 -leqn0 (leq_trans (dim_prodv U 0)) //. by rewrite dimv0 muln0. Qed. HB.instance Definition _ := Monoid.isMulLaw.Build {vspace aT} 0%VS prodv prod0v prodv0. Lemma prod1v : left_id 1%VS prodv. Proof. move=> U; apply/subv_anti/andP; split. by apply/prodvP=> _ u /vlineP[a ->] Uu; rewrite mulr_algl memvZ. by apply/subvP=> u Uu; rewrite -[u]mul1r memv_mul ?memv_line. Qed. Lemma prodv1 : right_id 1%VS prodv. Proof. move=> U; apply/subv_anti/andP; split. by apply/prodvP=> u _ Uu /vlineP[a ->]; rewrite mulr_algr memvZ. by apply/subvP=> u Uu; rewrite -[u]mulr1 memv_mul ?memv_line. Qed. Lemma prodvS U1 U2 V1 V2 : (U1 <= U2 -> V1 <= V2 -> U1 * V1 <= U2 * V2)%VS. Proof. move/subvP=> sU12 /subvP sV12; apply/prodvP=> u v Uu Vv. by rewrite memv_mul ?sU12 ?sV12. Qed. Lemma prodvSl U1 U2 V : (U1 <= U2 -> U1 * V <= U2 * V)%VS. Proof. by move/prodvS->. Qed. Lemma prodvSr U V1 V2 : (V1 <= V2 -> U * V1 <= U * V2)%VS. Proof. exact: prodvS. Qed. Lemma prodvDl : left_distributive prodv addv. Proof. move=> U1 U2 V; apply/esym/subv_anti/andP; split. by rewrite subv_add 2?prodvS ?addvSl ?addvSr. apply/prodvP=> _ v /memv_addP[u1 Uu1 [u2 Uu2 ->]] Vv. by rewrite mulrDl memv_add ?memv_mul. Qed. Lemma prodvDr : right_distributive prodv addv. Proof. move=> U V1 V2; apply/esym/subv_anti/andP; split. by rewrite subv_add 2?prodvS ?addvSl ?addvSr. apply/prodvP=> u _ Uu /memv_addP[v1 Vv1 [v2 Vv2 ->]]. by rewrite mulrDr memv_add ?memv_mul. Qed. HB.instance Definition _ := Monoid.isAddLaw.Build {vspace aT} prodv addv prodvDl prodvDr. Lemma prodvA : associative prodv. Proof. move=> U V W; rewrite -(span_basis (vbasisP U)) span_def !big_distrl /=. apply: eq_bigr => u _; rewrite -(span_basis (vbasisP W)) span_def !big_distrr. apply: eq_bigr => w _; rewrite -(span_basis (vbasisP V)) span_def /=. rewrite !(big_distrl, big_distrr) /=; apply: eq_bigr => v _. by rewrite !prodv_line mulrA. Qed. HB.instance Definition _ := Monoid.isLaw.Build {vspace aT} 1%VS prodv prodvA prod1v prodv1. Definition expv U n := iterop n.+1.-1 prodv U 1%VS. Local Notation "A ^+ n" := (expv A n) : vspace_scope. Lemma expv0 U : (U ^+ 0 = 1)%VS. Proof. by []. Qed. Lemma expv1 U : (U ^+ 1 = U)%VS. Proof. by []. Qed. Lemma expv2 U : (U ^+ 2 = U * U)%VS. Proof. by []. Qed. Lemma expvSl U n : (U ^+ n.+1 = U * U ^+ n)%VS. Proof. by case: n => //; rewrite prodv1. Qed. Lemma expv0n n : (0 ^+ n = if n is _.+1 then 0 else 1)%VS. Proof. by case: n => // n; rewrite expvSl prod0v. Qed. Lemma expv1n n : (1 ^+ n = 1)%VS. Proof. by elim: n => // n IHn; rewrite expvSl IHn prodv1. Qed. Lemma expvD U m n : (U ^+ (m + n) = U ^+ m * U ^+ n)%VS. Proof. by elim: m => [|m IHm]; rewrite ?prod1v // !expvSl IHm prodvA. Qed. Lemma expvSr U n : (U ^+ n.+1 = U ^+ n * U)%VS. Proof. by rewrite -addn1 expvD. Qed. Lemma expvM U m n : (U ^+ (m * n) = U ^+ m ^+ n)%VS. Proof. by elim: n => [|n IHn]; rewrite ?muln0 // mulnS expvD IHn expvSl. Qed. Lemma expvS U V n : (U <= V -> U ^+ n <= V ^+ n)%VS. Proof. move=> sUV; elim: n => [|n IHn]; first by rewrite !expv0 subvv. by rewrite !expvSl prodvS. Qed. Lemma expv_line u n : (<[u]> ^+ n = <[u ^+ n]>)%VS. Proof. elim: n => [|n IH]; first by rewrite expr0 expv0. by rewrite exprS expvSl IH prodv_line. Qed. (* Centralisers and centers. *) Definition centraliser1_vspace u := lker (amulr u - amull u). Local Notation "'C [ u ]" := (centraliser1_vspace u) : vspace_scope. Definition centraliser_vspace V := (\bigcap_i 'C[tnth (vbasis V) i])%VS. Local Notation "'C ( V )" := (centraliser_vspace V) : vspace_scope. Definition center_vspace V := (V :&: 'C(V))%VS. Local Notation "'Z ( V )" := (center_vspace V) : vspace_scope. Lemma cent1vP u v : reflect (u * v = v * u) (u \in 'C[v]%VS). Proof. by rewrite (sameP eqlfunP eqP) !lfunE /=; apply: eqP. Qed. Lemma cent1v1 u : 1 \in 'C[u]%VS. Proof. by apply/cent1vP; rewrite commr1. Qed. Lemma cent1v_id u : u \in 'C[u]%VS. Proof. exact/cent1vP. Qed. Lemma cent1vX u n : u ^+ n \in 'C[u]%VS. Proof. exact/cent1vP/esym/commrX. Qed. Lemma cent1vC u v : (u \in 'C[v])%VS = (v \in 'C[u])%VS. Proof. exact/cent1vP/cent1vP. Qed. Lemma centvP u V : reflect {in V, forall v, u * v = v * u} (u \in 'C(V))%VS. Proof. apply: (iffP subv_bigcapP) => [cVu y /coord_vbasis-> | cVu i _]. apply/esym/cent1vP/rpred_sum=> i _; apply: rpredZ. by rewrite -tnth_nth cent1vC memvE cVu. exact/cent1vP/cVu/vbasis_mem/mem_tnth. Qed. Lemma centvsP U V : reflect {in U & V, commutative *%R} (U <= 'C(V))%VS. Proof. by apply: (iffP subvP) => [cUV u v | cUV u] /cUV-/centvP; apply. Qed. Lemma subv_cent1 U v : (U <= 'C[v])%VS = (v \in 'C(U)%VS). Proof. by apply/subvP/centvP=> cUv u Uu; apply/cent1vP; rewrite 1?cent1vC cUv. Qed. Lemma centv1 V : 1 \in 'C(V)%VS. Proof. by apply/centvP=> v _; rewrite commr1. Qed. Lemma centvX V u n : u \in 'C(V)%VS -> u ^+ n \in 'C(V)%VS. Proof. by move/centvP=> cVu; apply/centvP=> v /cVu/esym/commrX->. Qed. Lemma centvC U V : (U <= 'C(V))%VS = (V <= 'C(U))%VS. Proof. by apply/centvsP/centvsP=> cUV u v UVu /cUV->. Qed. Lemma centerv_sub V : ('Z(V) <= V)%VS. Proof. exact: capvSl. Qed. Lemma cent_centerv V : (V <= 'C('Z(V)))%VS. Proof. by rewrite centvC capvSr. Qed. (* Building the predicate that checks is a vspace has a unit *) Definition is_algid e U := [/\ e \in U, e != 0 & {in U, forall u, e * u = u /\ u * e = u}]. Fact algid_decidable U : decidable (exists e, is_algid e U). Proof. have [-> | nzU] := eqVneq U 0%VS. by right=> [[e []]]; rewrite memv0 => ->. pose X := vbasis U; pose feq f1 f2 := [tuple of map f1 X ++ map f2 X]. have feqL f i: tnth (feq _ f _) (lshift _ i) = f X`_i. set v := f _; rewrite (tnth_nth v) /= nth_cat size_map size_tuple. by rewrite ltn_ord (nth_map 0) ?size_tuple. have feqR f i: tnth (feq _ _ f) (rshift _ i) = f X`_i. set v := f _; rewrite (tnth_nth v) /= nth_cat size_map size_tuple. by rewrite ltnNge leq_addr addKn /= (nth_map 0) ?size_tuple. apply: decP (vsolve_eq (feq _ amulr amull) (feq _ id id) U) _. apply: (iffP (vsolve_eqP _ _ _)) => [[e Ue id_e] | [e [Ue _ id_e]]]. suffices idUe: {in U, forall u, e * u = u /\ u * e = u}. exists e; split=> //; apply: contraNneq nzU => e0; rewrite -subv0. by apply/subvP=> u /idUe[<- _]; rewrite e0 mul0r mem0v. move=> u /coord_vbasis->; rewrite mulr_sumr mulr_suml. split; apply/eq_bigr=> i _; rewrite -(scalerAr, scalerAl); congr (_ *: _). by have:= id_e (lshift _ i); rewrite !feqL lfunE. by have:= id_e (rshift _ i); rewrite !feqR lfunE. have{id_e} /all_and2[ideX idXe]:= id_e _ (vbasis_mem (mem_tnth _ X)). exists e => // k; rewrite -[k]splitK. by case: (split k) => i; rewrite !(feqL, feqR) lfunE /= -tnth_nth. Qed. Definition has_algid : pred {vspace aT} := algid_decidable. Lemma has_algidP {U} : reflect (exists e, is_algid e U) (has_algid U). Proof. exact: sumboolP. Qed. Lemma has_algid1 U : 1 \in U -> has_algid U. Proof. move=> U1; apply/has_algidP; exists 1; split; rewrite ?oner_eq0 // => u _. by rewrite mulr1 mul1r. Qed. Definition is_aspace U := has_algid U && (U * U <= U)%VS. Structure aspace := ASpace {asval :> {vspace aT}; _ : is_aspace asval}. HB.instance Definition _ := [isSub for asval]. HB.instance Definition _ := [Choice of aspace by <:]. Definition clone_aspace U (A : aspace) := fun algU & phant_id algU (valP A) => @ASpace U algU : aspace. Fact aspace1_subproof : is_aspace 1. Proof. by rewrite /is_aspace prod1v -memvE has_algid1 memv_line. Qed. Canonical aspace1 : aspace := ASpace aspace1_subproof. Lemma aspacef_subproof : is_aspace fullv. Proof. by rewrite /is_aspace subvf has_algid1 ?memvf. Qed. Canonical aspacef : aspace := ASpace aspacef_subproof. Lemma polyOver1P p : reflect (exists q, p = map_poly (in_alg aT) q) (p \is a polyOver 1%VS). Proof. apply: (iffP idP) => [/allP/=Qp | [q ->]]; last first. by apply/polyOverP=> j; rewrite coef_map rpredZ ?memv_line. exists (map_poly (coord [tuple 1] 0) p). rewrite -map_poly_comp map_poly_id // => _ /Qp/vlineP[a ->] /=. by rewrite linearZ /= (coord_free 0) ?mulr1 // seq1_free ?oner_eq0. Qed. End FalgebraTheory. Delimit Scope aspace_scope with AS. Bind Scope aspace_scope with aspace. Arguments asval {K aT} a%_AS. Arguments aspace [K]%_type aT%_type. Arguments clone_aspace [K aT U%_VS A%_AS algU] _. Notation "{ 'aspace' T }" := (aspace T) : type_scope. Notation "A * B" := (prodv A B) : vspace_scope. Notation "A ^+ n" := (expv A n) : vspace_scope. Notation "'C [ u ]" := (centraliser1_vspace u) : vspace_scope. Notation "'C_ U [ v ]" := (capv U 'C[v]) : vspace_scope. Notation "'C_ ( U ) [ v ]" := (capv U 'C[v]) (only parsing) : vspace_scope. Notation "'C ( V )" := (centraliser_vspace V) : vspace_scope. Notation "'C_ U ( V )" := (capv U 'C(V)) : vspace_scope. Notation "'C_ ( U ) ( V )" := (capv U 'C(V)) (only parsing) : vspace_scope. Notation "'Z ( V )" := (center_vspace V) : vspace_scope. Notation "1" := (aspace1 _) : aspace_scope. Notation "{ : aT }" := (aspacef aT) : aspace_scope. Notation "[ 'aspace' 'of' U ]" := (@clone_aspace _ _ U _ _ id) (format "[ 'aspace' 'of' U ]") : form_scope. Notation "[ 'aspace' 'of' U 'for' A ]" := (@clone_aspace _ _ U A _ idfun) (format "[ 'aspace' 'of' U 'for' A ]") : form_scope. Arguments prodvP {K aT U V W}. Arguments cent1vP {K aT u v}. Arguments centvP {K aT u V}. Arguments centvsP {K aT U V}. Arguments has_algidP {K aT U}. Arguments polyOver1P {K aT p}. Section AspaceTheory. Variables (K : fieldType) (aT : falgType K). Implicit Types (u v e : aT) (U V : {vspace aT}) (A B : {aspace aT}). Import FalgLfun. Lemma algid_subproof U : {e | e \in U & has_algid U ==> (U <= lker (amull e - 1) :&: lker (amulr e - 1))%VS}. Proof. apply: sig2W; case: has_algidP => [[e]|]; last by exists 0; rewrite ?mem0v. case=> Ae _ idAe; exists e => //; apply/subvP=> u /idAe[eu_u ue_u]. by rewrite memv_cap !memv_ker !lfun_simp /= eu_u ue_u subrr eqxx. Qed. Definition algid U := s2val (algid_subproof U). Lemma memv_algid U : algid U \in U. Proof. by rewrite /algid; case: algid_subproof. Qed. Lemma algidl A : {in A, left_id (algid A) *%R}. Proof. rewrite /algid; case: algid_subproof => e _ /=; have /andP[-> _] := valP A. move/subvP=> idAe u /idAe/memv_capP[]. by rewrite memv_ker !lfun_simp /= subr_eq0 => /eqP. Qed. Lemma algidr A : {in A, right_id (algid A) *%R}. Proof. rewrite /algid; case: algid_subproof => e _ /=; have /andP[-> _] := valP A. move/subvP=> idAe u /idAe/memv_capP[_]. by rewrite memv_ker !lfun_simp /= subr_eq0 => /eqP. Qed. Lemma unitr_algid1 A u : u \in A -> u \is a GRing.unit -> algid A = 1. Proof. by move=> Eu /mulrI; apply; rewrite mulr1 algidr. Qed. Lemma algid_eq1 A : (algid A == 1) = (1 \in A). Proof. by apply/eqP/idP=> [<- | /algidr <-]; rewrite ?memv_algid ?mul1r. Qed. Lemma algid_neq0 A : algid A != 0. Proof. have /andP[/has_algidP[u [Au nz_u _]] _] := valP A. by apply: contraNneq nz_u => e0; rewrite -(algidr Au) e0 mulr0. Qed. Lemma dim_algid A : \dim <[algid A]> = 1%N. Proof. by rewrite dim_vline algid_neq0. Qed. Lemma adim_gt0 A : (0 < \dim A)%N. Proof. by rewrite -(dim_algid A) dimvS // -memvE ?memv_algid. Qed. Lemma not_asubv0 A : ~~ (A <= 0)%VS. Proof. by rewrite subv0 -dimv_eq0 -lt0n adim_gt0. Qed. Lemma adim1P {A} : reflect (A = <[algid A]>%VS :> {vspace aT}) (\dim A == 1%N). Proof. rewrite eqn_leq adim_gt0 -(memv_algid A) andbC -(dim_algid A) -eqEdim eq_sym. exact: eqP. Qed. Lemma asubv A : (A * A <= A)%VS. Proof. by have /andP[] := valP A. Qed. Lemma memvM A : {in A &, forall u v, u * v \in A}. Proof. exact/prodvP/asubv. Qed. Lemma prodv_id A : (A * A)%VS = A. Proof. apply/eqP; rewrite eqEsubv asubv; apply/subvP=> u Au. by rewrite -(algidl Au) memv_mul // memv_algid. Qed. Lemma prodv_sub U V A : (U <= A -> V <= A -> U * V <= A)%VS. Proof. by move=> sUA sVA; rewrite -prodv_id prodvS. Qed. Lemma expv_id A n : (A ^+ n.+1)%VS = A. Proof. by elim: n => // n IHn; rewrite !expvSl prodvA prodv_id -expvSl. Qed. Lemma limg_amulr U v : (amulr v @: U = U * <[v]>)%VS. Proof. rewrite -(span_basis (vbasisP U)) limg_span !span_def big_distrl /= big_map. by apply: eq_bigr => u; rewrite prodv_line lfunE. Qed. Lemma memv_cosetP {U v w} : reflect (exists2 u, u\in U & w = u * v) (w \in U * <[v]>)%VS. Proof. rewrite -limg_amulr. by apply: (iffP memv_imgP) => [] [u] Uu ->; exists u; rewrite ?lfunE. Qed. Lemma dim_cosetv_unit V u : u \is a GRing.unit -> \dim (V * <[u]>) = \dim V. Proof. by move/lker0_amulr/eqP=> Uu; rewrite -limg_amulr limg_dim_eq // Uu capv0. Qed. Lemma memvV A u : (u^-1 \in A) = (u \in A). Proof. suffices{u} invA: invr_closed A by apply/idP/idP=> /invA; rewrite ?invrK. move=> u Au; have [Uu | /invr_out-> //] := boolP (u \is a GRing.unit). rewrite memvE -(limg_ker0 _ _ (lker0_amulr Uu)) limg_line lfunE /= mulVr //. suff ->: (amulr u @: A)%VS = A by rewrite -memvE -algid_eq1 (unitr_algid1 Au). by apply/eqP; rewrite limg_amulr -dimv_leqif_eq ?prodv_sub ?dim_cosetv_unit. Qed. Fact aspace_cap_subproof A B : algid A \in B -> is_aspace (A :&: B). Proof. move=> BeA; apply/andP. split; [apply/has_algidP | by rewrite subv_cap !prodv_sub ?capvSl ?capvSr]. exists (algid A); rewrite /is_algid algid_neq0 memv_cap memv_algid. by split=> // u /memv_capP[Au _]; rewrite ?algidl ?algidr. Qed. Definition aspace_cap A B BeA := ASpace (@aspace_cap_subproof A B BeA). Fact centraliser1_is_aspace u : is_aspace 'C[u]. Proof. rewrite /is_aspace has_algid1 ?cent1v1 //=. apply/prodvP=> v w /cent1vP-cuv /cent1vP-cuw. by apply/cent1vP; rewrite -mulrA cuw !mulrA cuv. Qed. Canonical centraliser1_aspace u := ASpace (centraliser1_is_aspace u). Fact centraliser_is_aspace V : is_aspace 'C(V). Proof. rewrite /is_aspace has_algid1 ?centv1 //=. apply/prodvP=> u w /centvP-cVu /centvP-cVw. by apply/centvP=> v Vv; rewrite /= -mulrA cVw // !mulrA cVu. Qed. Canonical centraliser_aspace V := ASpace (centraliser_is_aspace V). Lemma centv_algid A : algid A \in 'C(A)%VS. Proof. by apply/centvP=> u Au; rewrite algidl ?algidr. Qed. Canonical center_aspace A := [aspace of 'Z(A) for aspace_cap (centv_algid A)]. Lemma algid_center A : algid 'Z(A) = algid A. Proof. rewrite -(algidl (subvP (centerv_sub A) _ (memv_algid _))) algidr //=. by rewrite memv_cap memv_algid centv_algid. Qed. Lemma Falgebra_FieldMixin : GRing.integral_domain_axiom aT -> GRing.field_axiom aT. Proof. move=> domT u nz_u; apply/unitrP. have kerMu: lker (amulr u) == 0%VS. rewrite eqEsubv sub0v andbT; apply/subvP=> v; rewrite memv_ker lfunE /=. by move/eqP/domT; rewrite (negPf nz_u) orbF memv0. have /memv_imgP[v _ vu1]: 1 \in limg (amulr u); last rewrite lfunE /= in vu1. suffices /eqP->: limg (amulr u) == fullv by rewrite memvf. by rewrite -dimv_leqif_eq ?subvf ?limg_dim_eq // (eqP kerMu) capv0. exists v; split=> //; apply: (lker0P kerMu). by rewrite !lfunE /= -mulrA -vu1 mulr1 mul1r. Qed. Section SkewField. Hypothesis fieldT : GRing.field_axiom aT. Lemma skew_field_algid1 A : algid A = 1. Proof. by rewrite (unitr_algid1 (memv_algid A)) ?fieldT ?algid_neq0. Qed. Lemma skew_field_module_semisimple A M : let sumA X := (\sum_(x <- X) A * <[x]>)%VS in (A * M <= M)%VS -> {X | [/\ sumA X = M, directv (sumA X) & 0 \notin X]}. Proof. move=> sumA sAM_M; pose X := Nil aT; pose k := (\dim (A * M) - \dim (sumA X))%N. have: (\dim (A * M) - \dim (sumA X) < k.+1)%N by []. have: [/\ (sumA X <= A * M)%VS, directv (sumA X) & 0 \notin X]. by rewrite /sumA directvE /= !big_nil sub0v dimv0. elim: {X k}k.+1 (X) => // k IHk X [sAX_AM dxAX nzX]; rewrite ltnS => leAXk. have [sM_AX | /subvPn/sig2W[y My notAXy]] := boolP (M <= sumA X)%VS. by exists X; split=> //; apply/eqP; rewrite eqEsubv (subv_trans sAX_AM). have nz_y: y != 0 by rewrite (memPnC notAXy) ?mem0v. pose AY := sumA (y :: X). have sAY_AM: (AY <= A * M)%VS by rewrite [AY]big_cons subv_add ?prodvSr. have dxAY: directv AY. rewrite directvE /= !big_cons [_ == _]directv_addE dxAX directvE eqxx /=. rewrite -/(sumA X) eqEsubv sub0v andbT -limg_amulr. apply/subvP=> _ /memv_capP[/memv_imgP[a Aa ->]]/[!lfunE]/= AXay. rewrite memv0 (mulIr_eq0 a (mulIr _)) ?fieldT //. apply: contraR notAXy => /fieldT-Ua; rewrite -[y](mulKr Ua) /sumA. by rewrite -big_distrr -(prodv_id A) /= -prodvA big_distrr memv_mul ?memvV. apply: (IHk (y :: X)); first by rewrite !inE eq_sym negb_or nz_y. rewrite -subSn ?dimvS // (directvP dxAY) /= big_cons -(directvP dxAX) /=. rewrite subnDA (leq_trans _ leAXk) ?leq_sub2r // leq_subLR -add1n leq_add2r. by rewrite dim_cosetv_unit ?fieldT ?adim_gt0. Qed. Lemma skew_field_module_dimS A M : (A * M <= M)%VS -> \dim A %| \dim M. Proof. case/skew_field_module_semisimple=> X [<- /directvP-> nzX] /=. rewrite big_seq prime.dvdn_sum // => x /(memPn nzX)nz_x. by rewrite dim_cosetv_unit ?fieldT. Qed. Lemma skew_field_dimS A B : (A <= B)%VS -> \dim A %| \dim B. Proof. by move=> sAB; rewrite skew_field_module_dimS ?prodv_sub. Qed. End SkewField. End AspaceTheory. (* Note that local centraliser might not be proper sub-algebras. *) Notation "'C [ u ]" := (centraliser1_aspace u) : aspace_scope. Notation "'C ( V )" := (centraliser_aspace V) : aspace_scope. Notation "'Z ( A )" := (center_aspace A) : aspace_scope. Arguments adim1P {K aT A}. Arguments memv_cosetP {K aT U v w}. Section Closure. Variables (K : fieldType) (aT : falgType K). Implicit Types (u v : aT) (U V W : {vspace aT}). (* Subspaces of an F-algebra form a Kleene algebra *) Definition agenv U := (\sum_(i < \dim {:aT}) U ^+ i)%VS. Local Notation "<< U & vs >>" := (agenv (U + <<vs>>)) : vspace_scope. Local Notation "<< U ; x >>" := (agenv (U + <[x]>)) : vspace_scope. Lemma agenvEl U : agenv U = (1 + U * agenv U)%VS. Proof. pose f V := (1 + U * V)%VS; rewrite -/(f _); pose n := \dim {:aT}. have ->: agenv U = iter n f 0%VS. rewrite /agenv -/n; elim: n => [|n IHn]; first by rewrite big_ord0. rewrite big_ord_recl /= -{}IHn; congr (1 + _)%VS; rewrite big_distrr /=. by apply: eq_bigr => i; rewrite expvSl. have fS i j: i <= j -> (iter i f 0 <= iter j f 0)%VS. by elim: i j => [|i IHi] [|j] leij; rewrite ?sub0v //= addvS ?prodvSr ?IHi. suffices /(@trajectP _ f _ n.+1)[i le_i_n Dfi]: looping f 0%VS n.+1. by apply/eqP; rewrite eqEsubv -iterS fS // Dfi fS. apply: contraLR (dimvS (subvf (iter n.+1 f 0%VS))); rewrite -/n -ltnNge. rewrite -looping_uniq; elim: n.+1 => // i IHi; rewrite trajectSr rcons_uniq. rewrite {1}trajectSr mem_rcons inE negb_or eq_sym eqEdim fS ?leqW // -ltnNge. by rewrite -andbA => /and3P[lt_fi _ /IHi/leq_ltn_trans->]. Qed. Lemma agenvEr U : agenv U = (1 + agenv U * U)%VS. Proof. rewrite [lhs in lhs = _]agenvEl big_distrr big_distrl /=; congr (_ + _)%VS. by apply: eq_bigr => i _ /=; rewrite -expvSr -expvSl. Qed. Lemma agenv_modl U V : (U * V <= V -> agenv U * V <= V)%VS. Proof. rewrite big_distrl /= => idlU_V; apply/subv_sumP=> [[i _] /= _]. elim: i => [|i]; first by rewrite expv0 prod1v. by apply: subv_trans; rewrite expvSr -prodvA prodvSr. Qed. Lemma agenv_modr U V : (V * U <= V -> V * agenv U <= V)%VS. Proof. rewrite big_distrr /= => idrU_V; apply/subv_sumP=> [[i _] /= _]. elim: i => [|i]; first by rewrite expv0 prodv1. by apply: subv_trans; rewrite expvSl prodvA prodvSl. Qed. Fact agenv_is_aspace U : is_aspace (agenv U). Proof. rewrite /is_aspace has_algid1; last by rewrite memvE agenvEl addvSl. by rewrite agenv_modl // [V in (_ <= V)%VS]agenvEl addvSr. Qed. Canonical agenv_aspace U : {aspace aT} := ASpace (agenv_is_aspace U). Lemma agenvE U : agenv U = agenv_aspace U. Proof. by []. Qed. (* Kleene algebra properties *) Lemma agenvM U : (agenv U * agenv U)%VS = agenv U. Proof. exact: prodv_id. Qed. Lemma agenvX n U : (agenv U ^+ n.+1)%VS = agenv U. Proof. exact: expv_id. Qed. Lemma sub1_agenv U : (1 <= agenv U)%VS. Proof. by rewrite agenvEl addvSl. Qed. Lemma sub_agenv U : (U <= agenv U)%VS. Proof. by rewrite 2!agenvEl addvC prodvDr prodv1 -addvA addvSl. Qed. Lemma subX_agenv U n : (U ^+ n <= agenv U)%VS. Proof. by case: n => [|n]; rewrite ?sub1_agenv // -(agenvX n) expvS // sub_agenv. Qed. Lemma agenv_sub_modl U V : (1 <= V -> U * V <= V -> agenv U <= V)%VS. Proof. move=> s1V /agenv_modl; apply: subv_trans. by rewrite -[Us in (Us <= _)%VS]prodv1 prodvSr. Qed. Lemma agenv_sub_modr U V : (1 <= V -> V * U <= V -> agenv U <= V)%VS. Proof. move=> s1V /agenv_modr; apply: subv_trans. by rewrite -[Us in (Us <= _)%VS]prod1v prodvSl. Qed. Lemma agenv_id U : agenv (agenv U) = agenv U. Proof. apply/eqP; rewrite eqEsubv sub_agenv andbT. by rewrite agenv_sub_modl ?sub1_agenv ?agenvM. Qed. Lemma agenvS U V : (U <= V -> agenv U <= agenv V)%VS. Proof. move=> sUV; rewrite agenv_sub_modl ?sub1_agenv //. by rewrite -[Vs in (_ <= Vs)%VS]agenvM prodvSl ?(subv_trans sUV) ?sub_agenv. Qed. Lemma agenv_add_id U V : agenv (agenv U + V) = agenv (U + V). Proof. apply/eqP; rewrite eqEsubv andbC agenvS ?addvS ?sub_agenv //=. rewrite agenv_sub_modl ?sub1_agenv //. rewrite -[rhs in (_ <= rhs)%VS]agenvM prodvSl // subv_add agenvS ?addvSl //=. exact: subv_trans (addvSr U V) (sub_agenv _). Qed. Lemma subv_adjoin U x : (U <= <<U; x>>)%VS. Proof. by rewrite (subv_trans (sub_agenv _)) ?agenvS ?addvSl. Qed. Lemma subv_adjoin_seq U xs : (U <= <<U & xs>>)%VS. Proof. by rewrite (subv_trans (sub_agenv _)) // ?agenvS ?addvSl. Qed. Lemma memv_adjoin U x : x \in <<U; x>>%VS. Proof. by rewrite memvE (subv_trans (sub_agenv _)) ?agenvS ?addvSr. Qed. Lemma seqv_sub_adjoin U xs : {subset xs <= <<U & xs>>%VS}. Proof. by apply/span_subvP; rewrite (subv_trans (sub_agenv _)) ?agenvS ?addvSr. Qed. Lemma subvP_adjoin U x y : y \in U -> y \in <<U; x>>%VS. Proof. exact/subvP/subv_adjoin. Qed. Lemma adjoin_nil V : <<V & [::]>>%VS = agenv V. Proof. by rewrite span_nil addv0. Qed. Lemma adjoin_cons V x rs : <<V & x :: rs>>%VS = << <<V; x>> & rs>>%VS. Proof. by rewrite span_cons addvA agenv_add_id. Qed. Lemma adjoin_rcons V rs x : <<V & rcons rs x>>%VS = << <<V & rs>>%VS; x>>%VS. Proof. by rewrite -cats1 span_cat addvA span_seq1 agenv_add_id. Qed. Lemma adjoin_seq1 V x : <<V & [:: x]>>%VS = <<V; x>>%VS. Proof. by rewrite adjoin_cons adjoin_nil agenv_id. Qed. Lemma adjoinC V x y : << <<V; x>>; y>>%VS = << <<V; y>>; x>>%VS. Proof. by rewrite !agenv_add_id -!addvA (addvC <[x]>%VS). Qed. Lemma adjoinSl U V x : (U <= V -> <<U; x>> <= <<V; x>>)%VS. Proof. by move=> sUV; rewrite agenvS ?addvS. Qed. Lemma adjoin_seqSl U V rs : (U <= V -> <<U & rs>> <= <<V & rs>>)%VS. Proof. by move=> sUV; rewrite agenvS ?addvS. Qed. Lemma adjoin_seqSr U rs1 rs2 : {subset rs1 <= rs2} -> (<<U & rs1>> <= <<U & rs2>>)%VS. Proof. by move/sub_span=> s_rs12; rewrite agenvS ?addvS. Qed. End Closure. Notation "<< U >>" := (agenv_aspace U) : aspace_scope. Notation "<< U & vs >>" := (agenv (U + <<vs>>)) : vspace_scope. Notation "<< U ; x >>" := (agenv (U + <[x]>)) : vspace_scope. Notation "<< U & vs >>" := << U + <<vs>> >>%AS : aspace_scope. Notation "<< U ; x >>" := << U + <[x]> >>%AS : aspace_scope. Section SubFalgType. (* The falgType structure of subvs_of A for A : {aspace aT}. *) (* We can't use the rpred-based mixin, because A need not contain 1. *) Variable (K : fieldType) (aT : falgType K) (A : {aspace aT}). Definition subvs_one := Subvs (memv_algid A). Definition subvs_mul (u v : subvs_of A) := Subvs (subv_trans (memv_mul (subvsP u) (subvsP v)) (asubv _)). Fact subvs_mulA : associative subvs_mul. Proof. by move=> x y z; apply/val_inj/mulrA. Qed. Fact subvs_mu1l : left_id subvs_one subvs_mul. Proof. by move=> x; apply/val_inj/algidl/(valP x). Qed. Fact subvs_mul1 : right_id subvs_one subvs_mul. Proof. by move=> x; apply/val_inj/algidr/(valP x). Qed. Fact subvs_mulDl : left_distributive subvs_mul +%R. Proof. move=> x y z; apply/val_inj/mulrDl. Qed. Fact subvs_mulDr : right_distributive subvs_mul +%R. Proof. move=> x y z; apply/val_inj/mulrDr. Qed. HB.instance Definition _ := GRing.Zmodule_isNzRing.Build (subvs_of A) subvs_mulA subvs_mu1l subvs_mul1 subvs_mulDl subvs_mulDr (algid_neq0 _). Lemma subvs_scaleAl k (x y : subvs_of A) : k *: (x * y) = (k *: x) * y. Proof. exact/val_inj/scalerAl. Qed. HB.instance Definition _ := GRing.Lmodule_isLalgebra.Build K (subvs_of A) subvs_scaleAl. Lemma subvs_scaleAr k (x y : subvs_of A) : k *: (x * y) = x * (k *: y). Proof. exact/val_inj/scalerAr. Qed. HB.instance Definition _ := GRing.Lalgebra_isAlgebra.Build K (subvs_of A) subvs_scaleAr. HB.instance Definition _ := Algebra_isFalgebra.Build K (subvs_of A). Implicit Type w : subvs_of A. Lemma vsval_unitr w : vsval w \is a GRing.unit -> w \is a GRing.unit. Proof. case: w => /= u Au Uu; have Au1: u^-1 \in A by rewrite memvV. apply/unitrP; exists (Subvs Au1). by split; apply: val_inj; rewrite /= ?mulrV ?mulVr ?(unitr_algid1 Au). Qed. Lemma vsval_invr w : vsval w \is a GRing.unit -> val w^-1 = (val w)^-1. Proof. move=> Uu; have def_w: w / w * w = w by rewrite divrK ?vsval_unitr. by apply: (mulrI Uu); rewrite -[in u in u / _]def_w ?mulrK. Qed. End SubFalgType. Section AHom. Variable K : fieldType. Section Class_Def. Variables aT rT : falgType K. Definition ahom_in (U : {vspace aT}) (f : 'Hom(aT, rT)) := all2rel (fun x y : aT => f (x * y) == f x * f y) (vbasis U) && (f 1 == 1). Lemma ahom_inP {f : 'Hom(aT, rT)} {U : {vspace aT}} : reflect ({in U &, {morph f : x y / x * y >-> x * y}} * (f 1 = 1)) (ahom_in U f). Proof. apply: (iffP andP) => [[/allrelP fM /eqP f1] | [fM f1]]; last first. rewrite f1; split=> //; apply/allrelP => x y Ax Ay. by rewrite fM // vbasis_mem. split=> // x y /coord_vbasis -> /coord_vbasis ->. rewrite !mulr_suml ![f _]linear_sum mulr_suml; apply: eq_bigr => i _ /=. rewrite !mulr_sumr linear_sum; apply: eq_bigr => j _ /=. rewrite !linearZ -!scalerAr -!scalerAl 2!linearZ /=; congr (_ *: (_ *: _)). by apply/eqP/fM; apply: memt_nth. Qed. Lemma ahomP_tmp {f : 'Hom(aT, rT)} : reflect (monoid_morphism f) (ahom_in {:aT} f). Proof. apply: (iffP ahom_inP) => [[fM f1] | fRM_P]; last first. by split=> [x y|]; [rewrite fRM_P.2|rewrite fRM_P.1]. by split=> // x y; rewrite fM ?memvf. Qed. #[warning="-deprecated-since-mathcomp-2.5.0", deprecated(since="mathcomp 2.5.0", note="use `ahomP_tmp` instead")] Lemma ahomP {f : 'Hom(aT, rT)} : reflect (multiplicative f) (ahom_in {:aT} f). Proof. by apply: (iffP ahomP_tmp) => [][]. Qed. Structure ahom := AHom {ahval :> 'Hom(aT, rT); _ : ahom_in {:aT} ahval}. HB.instance Definition _ := [isSub for ahval]. HB.instance Definition _ := [Equality of ahom by <:]. HB.instance Definition _ := [Choice of ahom by <:]. Fact linfun_is_ahom (f : {lrmorphism aT -> rT}) : ahom_in {:aT} (linfun f). Proof. by apply/ahom_inP; split=> [x y|]; rewrite !lfunE ?rmorphM ?rmorph1. Qed. Canonical linfun_ahom f := AHom (linfun_is_ahom f). End Class_Def. Arguments ahom_in [aT rT]. Arguments ahom_inP {aT rT f U}. #[warning="-deprecated-since-mathcomp-2.5.0"] Arguments ahomP {aT rT f}. Arguments ahomP_tmp {aT rT f}. Section LRMorphism. Variables aT rT sT : falgType K. Fact ahom_is_monoid_morphism (f : ahom aT rT) : monoid_morphism f. Proof. by apply/ahomP_tmp; case: f. Qed. #[hnf] HB.instance Definition _ (f : ahom aT rT) := GRing.isMonoidMorphism.Build aT rT f (ahom_is_monoid_morphism f). #[warning="-deprecated-since-mathcomp-2.5.0", deprecated(since="mathcomp 2.5.0", note="use `ahom_is_monoid_morphism` instead")] Definition ahom_is_multiplicative (f : ahom aT rT) : multiplicative f := (fun p => (p.2, p.1)) (ahom_is_monoid_morphism f). Lemma ahomWin (f : ahom aT rT) U : ahom_in U f. Proof. by apply/ahom_inP; split; [apply: in2W (rmorphM _) | apply: rmorph1]. Qed. Lemma id_is_ahom (V : {vspace aT}) : ahom_in V \1. Proof. by apply/ahom_inP; split=> [x y|] /=; rewrite !id_lfunE. Qed. Canonical id_ahom := AHom (id_is_ahom (aspacef aT)). Lemma comp_is_ahom (V : {vspace aT}) (f : 'Hom(rT, sT)) (g : 'Hom(aT, rT)) : ahom_in {:rT} f -> ahom_in V g -> ahom_in V (f \o g). Proof. move=> /ahom_inP fM /ahom_inP gM; apply/ahom_inP. by split=> [x y Vx Vy|] /=; rewrite !comp_lfunE gM // fM ?memvf. Qed. Canonical comp_ahom (f : ahom rT sT) (g : ahom aT rT) := AHom (comp_is_ahom (valP f) (valP g)). Lemma aimgM (f : ahom aT rT) U V : (f @: (U * V) = f @: U * f @: V)%VS. Proof. apply/eqP; rewrite eqEsubv; apply/andP; split; last first. apply/prodvP=> _ _ /memv_imgP[u Hu ->] /memv_imgP[v Hv ->]. by rewrite -rmorphM memv_img // memv_mul. apply/subvP=> _ /memv_imgP[w UVw ->]; rewrite memv_preim (subvP _ w UVw) //. by apply/prodvP=> u v Uu Vv; rewrite -memv_preim rmorphM memv_mul // memv_img. Qed. Lemma aimg1 (f : ahom aT rT) : (f @: 1 = 1)%VS. Proof. by rewrite limg_line rmorph1. Qed. Lemma aimgX (f : ahom aT rT) U n : (f @: (U ^+ n) = f @: U ^+ n)%VS. Proof. elim: n => [|n IH]; first by rewrite !expv0 aimg1. by rewrite !expvSl aimgM IH. Qed. Lemma aimg_agen (f : ahom aT rT) U : (f @: agenv U)%VS = agenv (f @: U). Proof. apply/eqP; rewrite eqEsubv; apply/andP; split. by rewrite limg_sum; apply/subv_sumP => i _; rewrite aimgX subX_agenv. apply: agenv_sub_modl; first by rewrite -(aimg1 f) limgS // sub1_agenv. by rewrite -aimgM limgS // [rhs in (_ <= rhs)%VS]agenvEl addvSr. Qed. Lemma aimg_adjoin (f : ahom aT rT) U x : (f @: <<U; x>> = <<f @: U; f x>>)%VS. Proof. by rewrite aimg_agen limgD limg_line. Qed. Lemma aimg_adjoin_seq (f : ahom aT rT) U xs : (f @: <<U & xs>> = <<f @: U & map f xs>>)%VS. Proof. by rewrite aimg_agen limgD limg_span. Qed. Fact ker_sub_ahom_is_aspace (f g : ahom aT rT) : is_aspace (lker (ahval f - ahval g)). Proof. rewrite /is_aspace has_algid1; last by apply/eqlfunP; rewrite !rmorph1. apply/prodvP=> a b /eqlfunP Dfa /eqlfunP Dfb. by apply/eqlfunP; rewrite !rmorphM /= Dfa Dfb. Qed. Canonical ker_sub_ahom_aspace f g := ASpace (ker_sub_ahom_is_aspace f g). End LRMorphism. Canonical fixedSpace_aspace aT (f : ahom aT aT) := [aspace of fixedSpace f]. End AHom. Arguments ahom_in [K aT rT]. Notation "''AHom' ( aT , rT )" := (ahom aT rT) : type_scope. Notation "''AEnd' ( aT )" := (ahom aT aT) : type_scope. Delimit Scope lrfun_scope with AF. Bind Scope lrfun_scope with ahom. Notation "\1" := (@id_ahom _ _) : lrfun_scope. Notation "f \o g" := (comp_ahom f g) : lrfun_scope.
Iterate.lean
/- Copyright (c) 2020 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.Logic.Function.Iterate import Mathlib.Order.Monotone.Basic /-! # Inequalities on iterates In this file we prove some inequalities comparing `f^[n] x` and `g^[n] x` where `f` and `g` are two self-maps that commute with each other. Current selection of inequalities is motivated by formalization of the rotation number of a circle homeomorphism. -/ open Function open Function (Commute) namespace Monotone variable {α : Type*} [Preorder α] {f : α → α} {x y : ℕ → α} /-! ### Comparison of two sequences If $f$ is a monotone function, then $∀ k, x_{k+1} ≤ f(x_k)$ implies that $x_k$ grows slower than $f^k(x_0)$, and similarly for the reversed inequalities. If $x_k$ and $y_k$ are two sequences such that $x_{k+1} ≤ f(x_k)$ and $y_{k+1} ≥ f(y_k)$ for all $k < n$, then $x_0 ≤ y_0$ implies $x_n ≤ y_n$, see `Monotone.seq_le_seq`. If some of the inequalities in this lemma are strict, then we have $x_n < y_n$. The rest of the lemmas in this section formalize this fact for different inequalities made strict. -/ theorem seq_le_seq (hf : Monotone f) (n : ℕ) (h₀ : x 0 ≤ y 0) (hx : ∀ k < n, x (k + 1) ≤ f (x k)) (hy : ∀ k < n, f (y k) ≤ y (k + 1)) : x n ≤ y n := by induction n with | zero => exact h₀ | succ n ihn => refine (hx _ n.lt_succ_self).trans ((hf <| ihn ?_ ?_).trans (hy _ n.lt_succ_self)) · exact fun k hk => hx _ (hk.trans n.lt_succ_self) · exact fun k hk => hy _ (hk.trans n.lt_succ_self) theorem seq_pos_lt_seq_of_lt_of_le (hf : Monotone f) {n : ℕ} (hn : 0 < n) (h₀ : x 0 ≤ y 0) (hx : ∀ k < n, x (k + 1) < f (x k)) (hy : ∀ k < n, f (y k) ≤ y (k + 1)) : x n < y n := by induction n with | zero => exact hn.false.elim | succ n ihn => suffices x n ≤ y n from (hx n n.lt_succ_self).trans_le ((hf this).trans <| hy n n.lt_succ_self) cases n with | zero => exact h₀ | succ n => refine (ihn n.zero_lt_succ (fun k hk => hx _ ?_) fun k hk => hy _ ?_).le <;> exact hk.trans n.succ.lt_succ_self theorem seq_pos_lt_seq_of_le_of_lt (hf : Monotone f) {n : ℕ} (hn : 0 < n) (h₀ : x 0 ≤ y 0) (hx : ∀ k < n, x (k + 1) ≤ f (x k)) (hy : ∀ k < n, f (y k) < y (k + 1)) : x n < y n := hf.dual.seq_pos_lt_seq_of_lt_of_le hn h₀ hy hx theorem seq_lt_seq_of_lt_of_le (hf : Monotone f) (n : ℕ) (h₀ : x 0 < y 0) (hx : ∀ k < n, x (k + 1) < f (x k)) (hy : ∀ k < n, f (y k) ≤ y (k + 1)) : x n < y n := by cases n exacts [h₀, hf.seq_pos_lt_seq_of_lt_of_le (Nat.zero_lt_succ _) h₀.le hx hy] theorem seq_lt_seq_of_le_of_lt (hf : Monotone f) (n : ℕ) (h₀ : x 0 < y 0) (hx : ∀ k < n, x (k + 1) ≤ f (x k)) (hy : ∀ k < n, f (y k) < y (k + 1)) : x n < y n := hf.dual.seq_lt_seq_of_lt_of_le n h₀ hy hx /-! ### Iterates of two functions In this section we compare the iterates of a monotone function `f : α → α` to iterates of any function `g : β → β`. If `h : β → α` satisfies `h ∘ g ≤ f ∘ h`, then `h (g^[n] x)` grows slower than `f^[n] (h x)`, and similarly for the reversed inequality. Then we specialize these two lemmas to the case `β = α`, `h = id`. -/ variable {β : Type*} {g : β → β} {h : β → α} open Function theorem le_iterate_comp_of_le (hf : Monotone f) (H : h ∘ g ≤ f ∘ h) (n : ℕ) : h ∘ g^[n] ≤ f^[n] ∘ h := fun x => by apply hf.seq_le_seq n <;> intros <;> simp [iterate_succ', -iterate_succ, comp_apply, id_eq, le_refl] case hx => exact H _ theorem iterate_comp_le_of_le (hf : Monotone f) (H : f ∘ h ≤ h ∘ g) (n : ℕ) : f^[n] ∘ h ≤ h ∘ g^[n] := hf.dual.le_iterate_comp_of_le H n /-- If `f ≤ g` and `f` is monotone, then `f^[n] ≤ g^[n]`. -/ theorem iterate_le_of_le {g : α → α} (hf : Monotone f) (h : f ≤ g) (n : ℕ) : f^[n] ≤ g^[n] := hf.iterate_comp_le_of_le h n /-- If `f ≤ g` and `g` is monotone, then `f^[n] ≤ g^[n]`. -/ theorem le_iterate_of_le {g : α → α} (hg : Monotone g) (h : f ≤ g) (n : ℕ) : f^[n] ≤ g^[n] := hg.dual.iterate_le_of_le h n end Monotone /-! ### Comparison of iterations and the identity function If $f(x) ≤ x$ for all $x$ (we express this as `f ≤ id` in the code), then the same is true for any iterate of $f$, and similarly for the reversed inequality. -/ namespace Function section Preorder variable {α : Type*} [Preorder α] {f : α → α} /-- If $x ≤ f x$ for all $x$ (we write this as `id ≤ f`), then the same is true for any iterate `f^[n]` of `f`. -/ theorem id_le_iterate_of_id_le (h : id ≤ f) (n : ℕ) : id ≤ f^[n] := by simpa only [iterate_id] using monotone_id.iterate_le_of_le h n theorem iterate_le_id_of_le_id (h : f ≤ id) (n : ℕ) : f^[n] ≤ id := @id_le_iterate_of_id_le αᵒᵈ _ f h n theorem monotone_iterate_of_id_le (h : id ≤ f) : Monotone fun m => f^[m] := monotone_nat_of_le_succ fun n x => by rw [iterate_succ_apply'] exact h _ theorem antitone_iterate_of_le_id (h : f ≤ id) : Antitone fun m => f^[m] := fun m n hmn => @monotone_iterate_of_id_le αᵒᵈ _ f h m n hmn end Preorder /-! ### Iterates of commuting functions If `f` and `g` are monotone and commute, then `f x ≤ g x` implies `f^[n] x ≤ g^[n] x`, see `Function.Commute.iterate_le_of_map_le`. We also prove two strict inequality versions of this lemma, as well as `iff` versions. -/ namespace Commute section Preorder variable {α : Type*} [Preorder α] {f g : α → α} theorem iterate_le_of_map_le (h : Commute f g) (hf : Monotone f) (hg : Monotone g) {x} (hx : f x ≤ g x) (n : ℕ) : f^[n] x ≤ g^[n] x := by apply hf.seq_le_seq n · rfl · intros; rw [iterate_succ_apply'] · intros; simp [h.iterate_right _ _, hg.iterate _ hx] theorem iterate_pos_lt_of_map_lt (h : Commute f g) (hf : Monotone f) (hg : StrictMono g) {x} (hx : f x < g x) {n} (hn : 0 < n) : f^[n] x < g^[n] x := by apply hf.seq_pos_lt_seq_of_le_of_lt hn · rfl · intros; rw [iterate_succ_apply'] · intros; simp [h.iterate_right _ _, hg.iterate _ hx] theorem iterate_pos_lt_of_map_lt' (h : Commute f g) (hf : StrictMono f) (hg : Monotone g) {x} (hx : f x < g x) {n} (hn : 0 < n) : f^[n] x < g^[n] x := @iterate_pos_lt_of_map_lt αᵒᵈ _ g f h.symm hg.dual hf.dual x hx n hn end Preorder variable {α : Type*} [LinearOrder α] {f g : α → α} theorem iterate_pos_lt_iff_map_lt (h : Commute f g) (hf : Monotone f) (hg : StrictMono g) {x n} (hn : 0 < n) : f^[n] x < g^[n] x ↔ f x < g x := by rcases lt_trichotomy (f x) (g x) with (H | H | H) · simp only [*, iterate_pos_lt_of_map_lt] · simp only [*, h.iterate_eq_of_map_eq, lt_irrefl] · simp only [lt_asymm H, lt_asymm (h.symm.iterate_pos_lt_of_map_lt' hg hf H hn)] theorem iterate_pos_lt_iff_map_lt' (h : Commute f g) (hf : StrictMono f) (hg : Monotone g) {x n} (hn : 0 < n) : f^[n] x < g^[n] x ↔ f x < g x := @iterate_pos_lt_iff_map_lt αᵒᵈ _ _ _ h.symm hg.dual hf.dual x n hn theorem iterate_pos_le_iff_map_le (h : Commute f g) (hf : Monotone f) (hg : StrictMono g) {x n} (hn : 0 < n) : f^[n] x ≤ g^[n] x ↔ f x ≤ g x := by simpa only [not_lt] using not_congr (h.symm.iterate_pos_lt_iff_map_lt' hg hf hn) theorem iterate_pos_le_iff_map_le' (h : Commute f g) (hf : StrictMono f) (hg : Monotone g) {x n} (hn : 0 < n) : f^[n] x ≤ g^[n] x ↔ f x ≤ g x := by simpa only [not_lt] using not_congr (h.symm.iterate_pos_lt_iff_map_lt hg hf hn) theorem iterate_pos_eq_iff_map_eq (h : Commute f g) (hf : Monotone f) (hg : StrictMono g) {x n} (hn : 0 < n) : f^[n] x = g^[n] x ↔ f x = g x := by simp only [le_antisymm_iff, h.iterate_pos_le_iff_map_le hf hg hn, h.symm.iterate_pos_le_iff_map_le' hg hf hn] end Commute end Function namespace Monotone variable {α : Type*} [Preorder α] {f : α → α} {x : α} /-- If `f` is a monotone map and `x ≤ f x` at some point `x`, then the iterates `f^[n] x` form a monotone sequence. -/ theorem monotone_iterate_of_le_map (hf : Monotone f) (hx : x ≤ f x) : Monotone fun n => f^[n] x := monotone_nat_of_le_succ fun n => by rw [iterate_succ_apply] exact hf.iterate n hx /-- If `f` is a monotone map and `f x ≤ x` at some point `x`, then the iterates `f^[n] x` form an antitone sequence. -/ theorem antitone_iterate_of_map_le (hf : Monotone f) (hx : f x ≤ x) : Antitone fun n => f^[n] x := hf.dual.monotone_iterate_of_le_map hx end Monotone namespace StrictMono variable {α : Type*} [Preorder α] {f : α → α} {x : α} /-- If `f` is a strictly monotone map and `x < f x` at some point `x`, then the iterates `f^[n] x` form a strictly monotone sequence. -/ theorem strictMono_iterate_of_lt_map (hf : StrictMono f) (hx : x < f x) : StrictMono fun n => f^[n] x := strictMono_nat_of_lt_succ fun n => by rw [iterate_succ_apply] exact hf.iterate n hx /-- If `f` is a strictly antitone map and `f x < x` at some point `x`, then the iterates `f^[n] x` form a strictly antitone sequence. -/ theorem strictAnti_iterate_of_map_lt (hf : StrictMono f) (hx : f x < x) : StrictAnti fun n => f^[n] x := hf.dual.strictMono_iterate_of_lt_map hx end StrictMono
all_field.v
From mathcomp Require Export algC. From mathcomp Require Export algebraics_fundamentals. From mathcomp Require Export algnum. From mathcomp Require Export closed_field. From mathcomp Require Export cyclotomic. From mathcomp Require Export falgebra. From mathcomp Require Export fieldext. From mathcomp Require Export finfield. From mathcomp Require Export galois. From mathcomp Require Export separable. From mathcomp Require Export qfpoly.
Fintype.lean
/- Copyright (c) 2021 Yakov Pechersky. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yakov Pechersky -/ import Mathlib.Data.Fintype.EquivFin import Mathlib.Data.Fintype.Inv /-! # Equivalence between fintypes This file contains some basic results on equivalences where one or both sides of the equivalence are `Fintype`s. # Main definitions - `Function.Embedding.toEquivRange`: computably turn an embedding of a fintype into an `Equiv` of the domain to its range - `Equiv.Perm.viaFintypeEmbedding : Perm α → (α ↪ β) → Perm β` extends the domain of a permutation, fixing everything outside the range of the embedding # Implementation details - `Function.Embedding.toEquivRange` uses a computable inverse, but one that has poor computational performance, since it operates by exhaustive search over the input `Fintype`s. -/ assert_not_exists Equiv.Perm.sign section Fintype variable {α β : Type*} [Fintype α] [DecidableEq β] (e : Equiv.Perm α) (f : α ↪ β) /-- Computably turn an embedding `f : α ↪ β` into an equiv `α ≃ Set.range f`, if `α` is a `Fintype`. Has poor computational performance, due to exhaustive searching in constructed inverse. When a better inverse is known, use `Equiv.ofLeftInverse'` or `Equiv.ofLeftInverse` instead. This is the computable version of `Equiv.ofInjective`. -/ def Function.Embedding.toEquivRange : α ≃ Set.range f := ⟨fun a => ⟨f a, Set.mem_range_self a⟩, f.invOfMemRange, fun _ => by simp, fun _ => by simp⟩ @[simp] theorem Function.Embedding.toEquivRange_apply (a : α) : f.toEquivRange a = ⟨f a, Set.mem_range_self a⟩ := rfl @[simp] theorem Function.Embedding.toEquivRange_symm_apply_self (a : α) : f.toEquivRange.symm ⟨f a, Set.mem_range_self a⟩ = a := by simp [Equiv.symm_apply_eq] theorem Function.Embedding.toEquivRange_eq_ofInjective : f.toEquivRange = Equiv.ofInjective f f.injective := by ext simp /-- Extend the domain of `e : Equiv.Perm α`, mapping it through `f : α ↪ β`. Everything outside of `Set.range f` is kept fixed. Has poor computational performance, due to exhaustive searching in constructed inverse due to using `Function.Embedding.toEquivRange`. When a better `α ≃ Set.range f` is known, use `Equiv.Perm.viaSetRange`. When `[Fintype α]` is not available, a noncomputable version is available as `Equiv.Perm.viaEmbedding`. -/ def Equiv.Perm.viaFintypeEmbedding : Equiv.Perm β := e.extendDomain f.toEquivRange @[simp] theorem Equiv.Perm.viaFintypeEmbedding_apply_image (a : α) : e.viaFintypeEmbedding f (f a) = f (e a) := by rw [Equiv.Perm.viaFintypeEmbedding] convert Equiv.Perm.extendDomain_apply_image e (Function.Embedding.toEquivRange f) a theorem Equiv.Perm.viaFintypeEmbedding_apply_mem_range {b : β} (h : b ∈ Set.range f) : e.viaFintypeEmbedding f b = f (e (f.invOfMemRange ⟨b, h⟩)) := by simp only [viaFintypeEmbedding, Function.Embedding.invOfMemRange] rw [Equiv.Perm.extendDomain_apply_subtype] congr theorem Equiv.Perm.viaFintypeEmbedding_apply_notMem_range {b : β} (h : b ∉ Set.range f) : e.viaFintypeEmbedding f b = b := by rwa [Equiv.Perm.viaFintypeEmbedding, Equiv.Perm.extendDomain_apply_not_subtype] @[deprecated (since := "2025-05-23")] alias Equiv.Perm.viaFintypeEmbedding_apply_not_mem_range := Equiv.Perm.viaFintypeEmbedding_apply_notMem_range end Fintype namespace Equiv variable {α β : Type*} [Finite α] /-- If `e` is an equivalence between two subtypes of a finite type `α`, `e.toCompl` is an equivalence between the complement of those subtypes. See also `Equiv.compl`, for a computable version when a term of type `{e' : α ≃ α // ∀ x : {x // p x}, e' x = e x}` is known. -/ noncomputable def toCompl {p q : α → Prop} (e : { x // p x } ≃ { x // q x }) : { x // ¬p x } ≃ { x // ¬q x } := by apply Classical.choice cases nonempty_fintype α classical exact Fintype.card_eq.mp <| Fintype.card_compl_eq_card_compl _ _ <| Fintype.card_congr e variable {p q : α → Prop} [DecidablePred p] [DecidablePred q] /-- If `e` is an equivalence between two subtypes of a fintype `α`, `e.extendSubtype` is a permutation of `α` acting like `e` on the subtypes and doing something arbitrary outside. Note that when `p = q`, `Equiv.Perm.subtypeCongr e (Equiv.refl _)` can be used instead. -/ noncomputable abbrev extendSubtype (e : { x // p x } ≃ { x // q x }) : Perm α := subtypeCongr e e.toCompl theorem extendSubtype_apply_of_mem (e : { x // p x } ≃ { x // q x }) (x) (hx : p x) : e.extendSubtype x = e ⟨x, hx⟩ := by dsimp only [extendSubtype] simp only [subtypeCongr, Equiv.trans_apply, Equiv.sumCongr_apply] rw [sumCompl_apply_symm_of_pos _ _ hx, Sum.map_inl, sumCompl_apply_inl] theorem extendSubtype_mem (e : { x // p x } ≃ { x // q x }) (x) (hx : p x) : q (e.extendSubtype x) := by convert (e ⟨x, hx⟩).2 rw [e.extendSubtype_apply_of_mem _ hx] theorem extendSubtype_apply_of_not_mem (e : { x // p x } ≃ { x // q x }) (x) (hx : ¬p x) : e.extendSubtype x = e.toCompl ⟨x, hx⟩ := by dsimp only [extendSubtype] simp only [subtypeCongr, Equiv.trans_apply, Equiv.sumCongr_apply] rw [sumCompl_apply_symm_of_neg _ _ hx, Sum.map_inr, sumCompl_apply_inr] theorem extendSubtype_not_mem (e : { x // p x } ≃ { x // q x }) (x) (hx : ¬p x) : ¬q (e.extendSubtype x) := by convert (e.toCompl ⟨x, hx⟩).2 rw [e.extendSubtype_apply_of_not_mem _ hx] end Equiv
Tuple.lean
/- Copyright (c) 2019 Floris van Doorn. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Floris van Doorn, Yury Kudryashov, Sébastien Gouëzel, Chris Hughes -/ import Mathlib.Data.Fin.VecNotation import Mathlib.Logic.Equiv.Fin.Basic import Mathlib.Order.Fin.Basic import Mathlib.Order.PiLex import Mathlib.Order.Interval.Set.Defs /-! # Order properties on tuples -/ assert_not_exists Monoid open Function Set namespace Fin variable {m n : ℕ} {α : Fin (n + 1) → Type*} (x : α 0) (q : ∀ i, α i) (p : ∀ i : Fin n, α i.succ) (i : Fin n) (y : α i.succ) (z : α 0) lemma pi_lex_lt_cons_cons {x₀ y₀ : α 0} {x y : ∀ i : Fin n, α i.succ} (s : ∀ {i : Fin n.succ}, α i → α i → Prop) : Pi.Lex (· < ·) (@s) (Fin.cons x₀ x) (Fin.cons y₀ y) ↔ s x₀ y₀ ∨ x₀ = y₀ ∧ Pi.Lex (· < ·) (@fun i : Fin n ↦ @s i.succ) x y := by simp_rw [Pi.Lex, Fin.exists_fin_succ, Fin.cons_succ, Fin.cons_zero, Fin.forall_iff_succ] simp [and_assoc, exists_and_left] variable [∀ i, Preorder (α i)] lemma insertNth_mem_Icc {i : Fin (n + 1)} {x : α i} {p : ∀ j, α (i.succAbove j)} {q₁ q₂ : ∀ j, α j} : i.insertNth x p ∈ Icc q₁ q₂ ↔ x ∈ Icc (q₁ i) (q₂ i) ∧ p ∈ Icc (fun j ↦ q₁ (i.succAbove j)) fun j ↦ q₂ (i.succAbove j) := by simp only [mem_Icc, insertNth_le_iff, le_insertNth_iff, and_assoc, @and_left_comm (x ≤ q₂ i)] lemma preimage_insertNth_Icc_of_mem {i : Fin (n + 1)} {x : α i} {q₁ q₂ : ∀ j, α j} (hx : x ∈ Icc (q₁ i) (q₂ i)) : i.insertNth x ⁻¹' Icc q₁ q₂ = Icc (fun j ↦ q₁ (i.succAbove j)) fun j ↦ q₂ (i.succAbove j) := Set.ext fun p ↦ by simp only [mem_preimage, insertNth_mem_Icc, hx, true_and] lemma preimage_insertNth_Icc_of_notMem {i : Fin (n + 1)} {x : α i} {q₁ q₂ : ∀ j, α j} (hx : x ∉ Icc (q₁ i) (q₂ i)) : i.insertNth x ⁻¹' Icc q₁ q₂ = ∅ := Set.ext fun p ↦ by simp only [mem_preimage, insertNth_mem_Icc, hx, false_and, mem_empty_iff_false] @[deprecated (since := "2025-05-23")] alias preimage_insertNth_Icc_of_not_mem := preimage_insertNth_Icc_of_notMem end Fin open Fin Matrix variable {α : Type*} open scoped Relator in lemma liftFun_vecCons {n : ℕ} (r : α → α → Prop) [IsTrans α r] {f : Fin (n + 1) → α} {a : α} : ((· < ·) ⇒ r) (vecCons a f) (vecCons a f) ↔ r a (f 0) ∧ ((· < ·) ⇒ r) f f := by simp only [liftFun_iff_succ r, forall_iff_succ, cons_val_succ, cons_val_zero, ← succ_castSucc, castSucc_zero] variable [Preorder α] {n : ℕ} {f : Fin (n + 1) → α} {a : α} @[simp] lemma strictMono_vecCons : StrictMono (vecCons a f) ↔ a < f 0 ∧ StrictMono f := liftFun_vecCons (· < ·) @[simp] lemma monotone_vecCons : Monotone (vecCons a f) ↔ a ≤ f 0 ∧ Monotone f := by simpa only [monotone_iff_forall_lt] using @liftFun_vecCons α n (· ≤ ·) _ f a @[simp] lemma monotone_vecEmpty : Monotone ![a] | ⟨0, _⟩, ⟨0, _⟩, _ => le_refl _ @[simp] lemma strictMono_vecEmpty : StrictMono ![a] | ⟨0, _⟩, ⟨0, _⟩, h => (irrefl _ h).elim @[simp] lemma strictAnti_vecCons : StrictAnti (vecCons a f) ↔ f 0 < a ∧ StrictAnti f := liftFun_vecCons (· > ·) @[simp] lemma antitone_vecCons : Antitone (vecCons a f) ↔ f 0 ≤ a ∧ Antitone f := monotone_vecCons (α := αᵒᵈ) @[simp] lemma antitone_vecEmpty : Antitone (vecCons a vecEmpty) | ⟨0, _⟩, ⟨0, _⟩, _ => le_rfl @[simp] lemma strictAnti_vecEmpty : StrictAnti (vecCons a vecEmpty) | ⟨0, _⟩, ⟨0, _⟩, h => (irrefl _ h).elim lemma StrictMono.vecCons (hf : StrictMono f) (ha : a < f 0) : StrictMono (vecCons a f) := strictMono_vecCons.2 ⟨ha, hf⟩ lemma StrictAnti.vecCons (hf : StrictAnti f) (ha : f 0 < a) : StrictAnti (vecCons a f) := strictAnti_vecCons.2 ⟨ha, hf⟩ lemma Monotone.vecCons (hf : Monotone f) (ha : a ≤ f 0) : Monotone (vecCons a f) := monotone_vecCons.2 ⟨ha, hf⟩ lemma Antitone.vecCons (hf : Antitone f) (ha : f 0 ≤ a) : Antitone (vecCons a f) := antitone_vecCons.2 ⟨ha, hf⟩ example : Monotone ![1, 2, 2, 3] := by decide variable {n : ℕ} /-- `Π i : Fin 2, α i` is order equivalent to `α 0 × α 1`. See also `OrderIso.finTwoArrowEquiv` for a non-dependent version. -/ def OrderIso.piFinTwoIso (α : Fin 2 → Type*) [∀ i, Preorder (α i)] : (∀ i, α i) ≃o α 0 × α 1 where toEquiv := piFinTwoEquiv α map_rel_iff' := Iff.symm Fin.forall_fin_two /-- The space of functions `Fin 2 → α` is order equivalent to `α × α`. See also `OrderIso.piFinTwoIso`. -/ def OrderIso.finTwoArrowIso (α : Type*) [Preorder α] : (Fin 2 → α) ≃o α × α := { OrderIso.piFinTwoIso fun _ => α with toEquiv := finTwoArrowEquiv α } namespace Fin /-- Order isomorphism between tuples of length `n + 1` and pairs of an element and a tuple of length `n` given by separating out the first element of the tuple. This is `Fin.cons` as an `OrderIso`. -/ @[simps!, simps toEquiv] def consOrderIso (α : Fin (n + 1) → Type*) [∀ i, LE (α i)] : α 0 × (∀ i, α (succ i)) ≃o ∀ i, α i where toEquiv := consEquiv α map_rel_iff' := forall_iff_succ /-- Order isomorphism between tuples of length `n + 1` and pairs of an element and a tuple of length `n` given by separating out the last element of the tuple. This is `Fin.snoc` as an `OrderIso`. -/ @[simps!, simps toEquiv] def snocOrderIso (α : Fin (n + 1) → Type*) [∀ i, LE (α i)] : α (last n) × (∀ i, α (castSucc i)) ≃o ∀ i, α i where toEquiv := snocEquiv α map_rel_iff' := by simp [Pi.le_def, Prod.le_def, forall_iff_castSucc] /-- Order isomorphism between tuples of length `n + 1` and pairs of an element and a tuple of length `n` given by separating out the `p`-th element of the tuple. This is `Fin.insertNth` as an `OrderIso`. -/ @[simps!, simps toEquiv] def insertNthOrderIso (α : Fin (n + 1) → Type*) [∀ i, LE (α i)] (p : Fin (n + 1)) : α p × (∀ i, α (p.succAbove i)) ≃o ∀ i, α i where toEquiv := insertNthEquiv α p map_rel_iff' := by simp [Pi.le_def, Prod.le_def, p.forall_iff_succAbove] @[simp] lemma insertNthOrderIso_zero (α : Fin (n + 1) → Type*) [∀ i, LE (α i)] : insertNthOrderIso α 0 = consOrderIso α := by ext; simp [insertNthOrderIso] /-- Note this lemma can only be written about non-dependent tuples as `insertNth (last n) = snoc` is not a definitional equality. -/ @[simp] lemma insertNthOrderIso_last (n : ℕ) (α : Type*) [LE α] : insertNthOrderIso (fun _ ↦ α) (last n) = snocOrderIso (fun _ ↦ α) := by ext; simp end Fin /-- `Fin.succAbove` as an order isomorphism between `Fin n` and `{x : Fin (n + 1) // x ≠ p}`. -/ def finSuccAboveOrderIso (p : Fin (n + 1)) : Fin n ≃o { x : Fin (n + 1) // x ≠ p } where __ := finSuccAboveEquiv p map_rel_iff' := p.succAboveOrderEmb.map_rel_iff' lemma finSuccAboveOrderIso_apply (p : Fin (n + 1)) (i : Fin n) : finSuccAboveOrderIso p i = ⟨p.succAbove i, p.succAbove_ne i⟩ := rfl lemma finSuccAboveOrderIso_symm_apply_last (x : { x : Fin (n + 1) // x ≠ Fin.last n }) : (finSuccAboveOrderIso (Fin.last n)).symm x = Fin.castLT x.1 (Fin.val_lt_last x.2) := by rw [← Option.some_inj] simp [finSuccAboveOrderIso, finSuccAboveEquiv, OrderIso.symm] lemma finSuccAboveOrderIso_symm_apply_ne_last {p : Fin (n + 1)} (h : p ≠ Fin.last n) (x : { x : Fin (n + 1) // x ≠ p }) : (finSuccAboveEquiv p).symm x = (p.castLT (Fin.val_lt_last h)).predAbove x := by rw [← Option.some_inj] simpa [finSuccAboveEquiv, OrderIso.symm] using finSuccEquiv'_ne_last_apply h x.property /-- Promote a `Fin n` into a larger `Fin m`, as a subtype where the underlying values are retained. This is the `OrderIso` version of `Fin.castLE`. -/ @[simps apply symm_apply] def Fin.castLEOrderIso {n m : ℕ} (h : n ≤ m) : Fin n ≃o { i : Fin m // (i : ℕ) < n } where toFun i := ⟨Fin.castLE h i, by simp⟩ invFun i := ⟨i, i.prop⟩ left_inv _ := by simp right_inv _ := by simp map_rel_iff' := by simp [(strictMono_castLE h).le_iff_le]
mxred.v
(* (c) Copyright 2006-2016 Microsoft Corporation and Inria. *) (* Distributed under the terms of CeCILL-B. *) From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat seq div. From mathcomp Require Import choice fintype finfun bigop fingroup perm order. From mathcomp Require Import ssralg zmodp matrix mxalgebra poly polydiv mxpoly. (*****************************************************************************) (* In this file, we prove diagonalization theorems. For this purpose, we *) (* define conjugation, similarity and diagonalizability. *) (* *) (* conjmx V f := V *m f *m pinvmx V *) (* == the conjugation of f by V, i.e. "the" matrix of f *) (* in the basis of row vectors of V. *) (* Although this makes sense only when f stabilizes V, *) (* the definition can be stated more generally. *) (* similar_to P A C == where P is a base change matrix, A is a matrix, *) (* and C is a class of matrices, *) (* this states that conjmx P A is in C, *) (* which means A is similar to a matrix in C. *) (* *) (* From the latter, we derive serveral related notions: *) (* similar P A B := similar_to P A (pred1 B) *) (* == A is similar to B, with base change matrix P *) (* similar_in D A B == A is similar to B, *) (* with a base change matrix in D *) (* similar_in_to D A C == A is similar to a matrix in the class C, *) (* with a base change matrix in D *) (* all_similar_to D As C == all the matrices in the sequence As are similar *) (* to some matrix in the class C, *) (* with a base change matrix in D. *) (* *) (* We also specialize the class C, to diagonalizability: *) (* similar_diag P A := (similar_to P A is_diag_mx). *) (* diagonalizable_in D A := (similar_in_to D A is_diag_mx). *) (* diagonalizable A := (diagonalizable_in unitmx A). *) (* codiagonalizable_in D As := (all_similar_to D As is_diag_mx). *) (* codiagonalizable As := (codiagonalizable_in unitmx As). *) (* *) (* The main results of this file are: *) (* diagonalizablePeigen: *) (* a matrix is diagonalizable iff there is a sequence *) (* of scalars r, such that the sum of the associated *) (* eigenspaces is full. *) (* diagonalizableP: *) (* a matrix is diagonalizable iff its minimal polynomial *) (* divides a split polynomial with simple roots. *) (* codiagonalizableP: *) (* a sequence of matrices are diagonalizable in the same basis *) (* iff they are all diagonalizable and commute pairwize. *) (* *) (* We also specialize the class C, to trigonalizablility: *) (* similar_trig P A := (similar_to P A is_trig_mx). *) (* trigonalizable_in D A := (similar_in_to D A is_trig_mx). *) (* trigonalizable A := (trigonalizable_in unitmx A). *) (* cotrigonalizable_in D As := (all_similar_to D As is_trig_mx). *) (* cotrigonalizable As := (cotrigonalizable_in unitmx As). *) (* The theory of trigonalization is however not developed in this file. *) (*****************************************************************************) Set Implicit Arguments. Unset Strict Implicit. Unset Printing Implicit Defensive. Import GRing.Theory. Import Monoid.Theory. Local Open Scope ring_scope. Section ConjMx. Context {F : fieldType}. Definition conjmx (m n : nat) (V : 'M_(m, n)) (f : 'M[F]_n) : 'M_m := V *m f *m pinvmx V. Notation restrictmx V := (conjmx (row_base V)). Lemma stablemx_comp (m n p : nat) (V : 'M[F]_(m, n)) (W : 'M_(n, p)) (f : 'M_p) : stablemx W f -> stablemx V (conjmx W f) -> stablemx (V *m W) f. Proof. by move=> Wf /(submxMr W); rewrite -mulmxA mulmxKpV// mulmxA. Qed. Lemma stablemx_restrict m n (A : 'M[F]_n) (V : 'M_n) (W : 'M_(m, \rank V)): stablemx V A -> stablemx W (restrictmx V A) = stablemx (W *m row_base V) A. Proof. move=> A_stabV; rewrite mulmxA -[in RHS]mulmxA. rewrite -(submxMfree _ W (row_base_free V)) mulmxKpV //. by rewrite mulmx_sub ?stablemx_row_base. Qed. Lemma conjmxM (m n : nat) (V : 'M[F]_(m, n)) : {in [pred f | stablemx V f] &, {morph conjmx V : f g / f *m g}}. Proof. move=> f g; rewrite !inE => Vf Vg /=. by rewrite /conjmx 2!mulmxA mulmxA mulmxKpV ?stablemx_row_base. Qed. Lemma conjMmx (m n p : nat) (V : 'M[F]_(m, n)) (W : 'M_(n, p)) (f : 'M_p) : row_free (V *m W) -> stablemx W f -> stablemx V (conjmx W f) -> conjmx (V *m W) f = conjmx V (conjmx W f). Proof. move=> rfVW Wf VWf; apply: (row_free_inj rfVW); rewrite mulmxKpV ?stablemx_comp//. by rewrite mulmxA mulmxKpV// -[RHS]mulmxA mulmxKpV ?mulmxA. Qed. Lemma conjuMmx (m n : nat) (V : 'M[F]_m) (W : 'M_(m, n)) (f : 'M_n) : V \in unitmx -> row_free W -> stablemx W f -> conjmx (V *m W) f = conjmx V (conjmx W f). Proof. move=> Vu rfW Wf; rewrite conjMmx ?stablemx_unit//. by rewrite /row_free mxrankMfree// -/(row_free V) row_free_unit. Qed. Lemma conjMumx (m n : nat) (V : 'M[F]_(m, n)) (W f : 'M_n) : W \in unitmx -> row_free V -> stablemx V (conjmx W f) -> conjmx (V *m W) f = conjmx V (conjmx W f). Proof. move=> Wu rfW Wf; rewrite conjMmx ?stablemx_unit//. by rewrite /row_free mxrankMfree ?row_free_unit. Qed. Lemma conjuMumx (n : nat) (V W f : 'M[F]_n) : V \in unitmx -> W \in unitmx -> conjmx (V *m W) f = conjmx V (conjmx W f). Proof. by move=> Vu Wu; rewrite conjuMmx ?stablemx_unit ?row_free_unit. Qed. Lemma conjmx_scalar (m n : nat) (V : 'M[F]_(m, n)) (a : F) : row_free V -> conjmx V a%:M = a%:M. Proof. by move=> rfV; rewrite /conjmx scalar_mxC mulmxKp. Qed. Lemma conj0mx (m n : nat) f : conjmx (0 : 'M[F]_(m, n)) f = 0. Proof. by rewrite /conjmx !mul0mx. Qed. Lemma conjmx0 (m n : nat) (V : 'M[F]_(m, n)) : conjmx V 0 = 0. Proof. by rewrite /conjmx mulmx0 mul0mx. Qed. Lemma conjumx (n : nat) (V : 'M_n) (f : 'M[F]_n) : V \in unitmx -> conjmx V f = V *m f *m invmx V. Proof. by move=> uV; rewrite /conjmx pinvmxE. Qed. Lemma conj1mx (n : nat) (f : 'M[F]_n) : conjmx 1%:M f = f. Proof. by rewrite conjumx ?unitmx1// invmx1 mulmx1 mul1mx. Qed. Lemma conjVmx (n : nat) (V : 'M_n) (f : 'M[F]_n) : V \in unitmx -> conjmx (invmx V) f = invmx V *m f *m V. Proof. by move=> Vunit; rewrite conjumx ?invmxK ?unitmx_inv. Qed. Lemma conjmxK (n : nat) (V f : 'M[F]_n) : V \in unitmx -> conjmx (invmx V) (conjmx V f) = f. Proof. by move=> Vu; rewrite -conjuMumx ?unitmx_inv// mulVmx ?conj1mx. Qed. Lemma conjmxVK (n : nat) (V f : 'M[F]_n) : V \in unitmx -> conjmx V (conjmx (invmx V) f) = f. Proof. by move=> Vu; rewrite -conjuMumx ?unitmx_inv// mulmxV ?conj1mx. Qed. Lemma horner_mx_conj m n p (B : 'M[F]_(n.+1, m.+1)) (f : 'M_m.+1) : row_free B -> stablemx B f -> horner_mx (conjmx B f) p = conjmx B (horner_mx f p). Proof. move=> B_free B_stab; rewrite/conjmx; elim/poly_ind: p => [|p c]. by rewrite !rmorph0 mulmx0 mul0mx. rewrite !(rmorphD, rmorphM)/= !(horner_mx_X, horner_mx_C) => ->. rewrite [_ * _]mulmxA [_ *m (B *m _)]mulmxA mulmxKpV ?horner_mx_stable//. apply: (row_free_inj B_free); rewrite [_ *m B]mulmxDl. pose stablemxE := (stablemxD, stablemxM, stablemxC, horner_mx_stable). by rewrite !mulmxKpV -?[B *m _ *m _]mulmxA ?stablemxE// mulmxDr -scalar_mxC. Qed. Lemma horner_mx_uconj n p (B : 'M[F]_(n.+1)) (f : 'M_n.+1) : B \is a GRing.unit -> horner_mx (B *m f *m invmx B) p = B *m horner_mx f p *m invmx B. Proof. move=> B_unit; rewrite -!conjumx//. by rewrite horner_mx_conj ?row_free_unit ?stablemx_unit. Qed. Lemma horner_mx_uconjC n p (B : 'M[F]_(n.+1)) (f : 'M_n.+1) : B \is a GRing.unit -> horner_mx (invmx B *m f *m B) p = invmx B *m horner_mx f p *m B. Proof. move=> B_unit; rewrite -[X in _ *m X](invmxK B). by rewrite horner_mx_uconj ?invmxK ?unitmx_inv. Qed. Lemma mxminpoly_conj m n (V : 'M[F]_(m.+1, n.+1)) (f : 'M_n.+1) : row_free V -> stablemx V f -> mxminpoly (conjmx V f) %| mxminpoly f. Proof. by move=> *; rewrite mxminpoly_min// horner_mx_conj// mx_root_minpoly conjmx0. Qed. Lemma mxminpoly_uconj n (V : 'M[F]_(n.+1)) (f : 'M_n.+1) : V \in unitmx -> mxminpoly (conjmx V f) = mxminpoly f. Proof. have simp := (row_free_unit, stablemx_unit, unitmx_inv, unitmx1). move=> Vu; apply/eqP; rewrite -eqp_monic ?mxminpoly_monic// /eqp. apply/andP; split; first by rewrite mxminpoly_conj ?simp. by rewrite -[f in X in X %| _](conjmxK _ Vu) mxminpoly_conj ?simp. Qed. Section fixed_stablemx_space. Variables (m n : nat). Implicit Types (V : 'M[F]_(m, n)) (f : 'M[F]_n). Implicit Types (a : F) (p : {poly F}). Section Sub. Variable (k : nat). Implicit Types (W : 'M[F]_(k, m)). Lemma sub_kermxpoly_conjmx V f p W : stablemx V f -> row_free V -> (W <= kermxpoly (conjmx V f) p)%MS = (W *m V <= kermxpoly f p)%MS. Proof. move: n m => [|n'] [|m']// in V f W *; rewrite ?thinmx0// => fV rfV. - by rewrite /row_free mxrank0 in rfV. - by rewrite mul0mx !sub0mx. - apply/sub_kermxP/sub_kermxP; rewrite horner_mx_conj//; last first. by move=> /(congr1 (mulmxr (pinvmx V)))/=; rewrite mul0mx !mulmxA. move=> /(congr1 (mulmxr V))/=; rewrite ![W *m _]mulmxA ?mul0mx mulmxKpV//. by rewrite -mulmxA mulmx_sub// horner_mx_stable//. Qed. Lemma sub_eigenspace_conjmx V f a W : stablemx V f -> row_free V -> (W <= eigenspace (conjmx V f) a)%MS = (W *m V <= eigenspace f a)%MS. Proof. by move=> fV rfV; rewrite !eigenspace_poly sub_kermxpoly_conjmx. Qed. End Sub. Lemma eigenpoly_conjmx V f : stablemx V f -> row_free V -> {subset eigenpoly (conjmx V f) <= eigenpoly f}. Proof. move=> fV rfV a /eigenpolyP [x]; rewrite sub_kermxpoly_conjmx//. move=> xV_le_fa x_neq0; apply/eigenpolyP. by exists (x *m V); rewrite ?mulmx_free_eq0. Qed. Lemma eigenvalue_conjmx V f : stablemx V f -> row_free V -> {subset eigenvalue (conjmx V f) <= eigenvalue f}. Proof. by move=> fV rfV a; rewrite ![_ \in _]eigenvalue_poly; apply: eigenpoly_conjmx. Qed. Lemma conjmx_eigenvalue a V f : (V <= eigenspace f a)%MS -> row_free V -> conjmx V f = a%:M. Proof. by move=> /eigenspaceP Vfa rfV; rewrite /conjmx Vfa -mul_scalar_mx mulmxKp. Qed. End fixed_stablemx_space. End ConjMx. Notation restrictmx V := (conjmx (row_base V)). Definition similar_to {F : fieldType} {m n} (P : 'M_(m, n)) A (C : {pred 'M[F]_m}) := C (conjmx P A). Notation similar P A B := (similar_to P A (PredOfSimpl.coerce (pred1 B))). Notation similar_in D A B := (exists2 P, P \in D & similar P A B). Notation similar_in_to D A C := (exists2 P, P \in D & similar_to P A C). Notation all_similar_to D As C := (exists2 P, P \in D & all [pred A | similar_to P A C] As). Notation similar_diag P A := (similar_to P A is_diag_mx). Notation diagonalizable_in D A := (similar_in_to D A is_diag_mx). Notation diagonalizable A := (diagonalizable_in unitmx A). Notation codiagonalizable_in D As := (all_similar_to D As is_diag_mx). Notation codiagonalizable As := (codiagonalizable_in unitmx As). Notation similar_trig P A := (similar_to P A is_trig_mx). Notation trigonalizable_in D A := (similar_in_to D A is_trig_mx). Notation trigonalizable A := (trigonalizable_in unitmx A). Notation cotrigonalizable_in D As := (all_similar_to D As is_trig_mx). Notation cotrigonalizable As := (cotrigonalizable_in unitmx As). Section Similarity. Context {F : fieldType}. Lemma similarPp m n {P : 'M[F]_(m, n)} {A B} : stablemx P A -> similar P A B -> P *m A = B *m P. Proof. by move=> stablemxPA /eqP <-; rewrite mulmxKpV. Qed. Lemma similarW m n {P : 'M[F]_(m, n)} {A B} : row_free P -> P *m A = B *m P -> similar P A B. Proof. by rewrite /similar_to/= /conjmx => fP ->; rewrite mulmxKp. Qed. Section Similar. Context {n : nat}. Implicit Types (f g p : 'M[F]_n) (fs : seq 'M[F]_n) (d : 'rV[F]_n). Lemma similarP {p f g} : p \in unitmx -> reflect (p *m f = g *m p) (similar p f g). Proof. move=> p_unit; apply: (iffP idP); first exact/similarPp/stablemx_unit. by apply: similarW; rewrite row_free_unit. Qed. Lemma similarRL {p f g} : p \in unitmx -> reflect (g = p *m f *m invmx p) (similar p f g). Proof. by move=> ?; apply: (iffP eqP); rewrite conjumx. Qed. Lemma similarLR {p f g} : p \in unitmx -> reflect (f = conjmx (invmx p) g) (similar p f g). Proof. by move=> pu; rewrite conjVmx//; apply: (iffP (similarRL pu)) => ->; rewrite !mulmxA ?(mulmxK, mulmxKV, mulVmx, mulmxV, mul1mx, mulmx1). Qed. End Similar. Lemma similar_mxminpoly {n} {p f g : 'M[F]_n.+1} : p \in unitmx -> similar p f g -> mxminpoly f = mxminpoly g. Proof. by move=> pu /eqP<-; rewrite mxminpoly_uconj. Qed. Lemma similar_diag_row_base m n (P : 'M[F]_(m, n)) (A : 'M_n) : similar_diag (row_base P) A = is_diag_mx (restrictmx P A). Proof. by []. Qed. Lemma similar_diagPp m n (P : 'M[F]_(m, n)) A : reflect (forall i j : 'I__, i != j :> nat -> conjmx P A i j = 0) (similar_diag P A). Proof. exact: @is_diag_mxP. Qed. Lemma similar_diagP n (P : 'M[F]_n) A : P \in unitmx -> reflect (forall i j : 'I__, i != j :> nat -> (P *m A *m invmx P) i j = 0) (similar_diag P A). Proof. by move=> Pu; rewrite -conjumx//; exact: is_diag_mxP. Qed. Lemma similar_diagPex {m} {n} {P : 'M[F]_(m, n)} {A} : reflect (exists D, similar P A (diag_mx D)) (similar_diag P A). Proof. by apply: (iffP (diag_mxP _)) => -[D]/eqP; exists D. Qed. Lemma similar_diagLR n {P : 'M[F]_n} {A} : P \in unitmx -> reflect (exists D, A = conjmx (invmx P) (diag_mx D)) (similar_diag P A). Proof. by move=> Punit; apply: (iffP similar_diagPex) => -[D /(similarLR Punit)]; exists D. Qed. Lemma similar_diag_mxminpoly {n} {p f : 'M[F]_n.+1} (rs := undup [seq conjmx p f i i | i <- enum 'I_n.+1]) : p \in unitmx -> similar_diag p f -> mxminpoly f = \prod_(r <- rs) ('X - r%:P). Proof. rewrite /rs => pu /(similar_diagLR pu)[d {f rs}->]. rewrite mxminpoly_uconj ?unitmx_inv// mxminpoly_diag. by rewrite [in RHS](@eq_map _ _ _ (d 0))// => i; rewrite conjmxVK// mxE eqxx. Qed. End Similarity. Lemma similar_diag_sum (F : fieldType) (m n : nat) (p_ : 'I_n -> nat) (V_ : forall i, 'M[F]_(p_ i, m)) (f : 'M[F]_m) : mxdirect (\sum_i <<V_ i>>) -> (forall i, stablemx (V_ i) f) -> (forall i, row_free (V_ i)) -> similar_diag (\mxcol_i V_ i) f = [forall i, similar_diag (V_ i) f]. Proof. move=> Vd Vf rfV; have aVf : stablemx (\mxcol_i V_ i) f. rewrite (eqmx_stable _ (eqmx_col _)) stablemx_sums//. by move=> i; rewrite (eqmx_stable _ (genmxE _)). apply/similar_diagPex/'forall_similar_diagPex => /= [[D /(similarPp aVf) +] i|/(_ _)/sigW Dof]. rewrite mxcol_mul -[D]submxrowK diag_mxrow mul_mxdiag_mxcol. move=> /eq_mxcolP/(_ i); set D0 := (submxrow _ _) => VMeq. by exists D0; apply/similarW. exists (\mxrow_i tag (Dof i)); apply/similarW. rewrite -row_leq_rank eqmx_col (mxdirectP Vd)/=. by under [X in (_ <= X)%N]eq_bigr do rewrite genmxE (eqP (rfV _)). rewrite mxcol_mul diag_mxrow mul_mxdiag_mxcol; apply: eq_mxcol => i. by case: Dof => /= k /(similarPp); rewrite Vf => /(_ isT) ->. Qed. Section Diag. Variable (F : fieldType). Lemma codiagonalizable1 n (A : 'M[F]_n) : codiagonalizable [:: A] <-> diagonalizable A. Proof. by split=> -[P Punit PA]; exists P; move: PA; rewrite //= andbT. Qed. Lemma codiagonalizablePfull n (As : seq 'M[F]_n) : codiagonalizable As <-> exists m, exists2 P : 'M_(m, n), row_full P & all [pred A | similar_diag P A] As. Proof. split => [[P Punit SPA]|[m [P Pfull SPA]]]. by exists n => //; exists P; rewrite ?row_full_unit. have Qfull := fullrowsub_unit Pfull. exists (rowsub (fullrankfun Pfull) P) => //; apply/allP => A AAs/=. have /allP /(_ _ AAs)/= /similar_diagPex[d /similarPp] := SPA. rewrite submx_full// => /(_ isT) PA_eq. apply/similar_diagPex; exists (colsub (fullrankfun Pfull) d). apply/similarP => //; apply/row_matrixP => i. rewrite !row_mul row_diag_mx -scalemxAl -rowE !row_rowsub !mxE. have /(congr1 (row (fullrankfun Pfull i))) := PA_eq. by rewrite !row_mul row_diag_mx -scalemxAl -rowE => ->. Qed. Lemma codiagonalizable_on m n (V_ : 'I_n -> 'M[F]_m) (As : seq 'M[F]_m) : (\sum_i V_ i :=: 1%:M)%MS -> mxdirect (\sum_i V_ i) -> (forall i, all (fun A => stablemx (V_ i) A) As) -> (forall i, codiagonalizable (map (restrictmx (V_ i)) As)) -> codiagonalizable As. Proof. move=> V1 Vdirect /(_ _)/allP AV /(_ _) /sig2W/= Pof. pose P_ i := tag (Pof i). have P_unit i : P_ i \in unitmx by rewrite /P_; case: {+}Pof. have P_diag i A : A \in As -> similar_diag (P_ i *m row_base (V_ i)) A. move=> AAs; rewrite /P_; case: {+}Pof => /= P Punit. rewrite all_map => /allP/(_ A AAs); rewrite /similar_to/=. by rewrite conjuMmx ?row_base_free ?stablemx_row_base ?AV. pose P := \mxcol_i (P_ i *m row_base (V_ i)). have P_full i : row_full (P_ i) by rewrite row_full_unit. have PrV i : (P_ i *m row_base (V_ i) :=: V_ i)%MS. exact/(eqmx_trans _ (eq_row_base _))/eqmxMfull. apply/codiagonalizablePfull; eexists _; last exists P; rewrite /=. - rewrite -sub1mx eqmx_col. by under eq_bigr do rewrite (eq_genmx (PrV _)); rewrite -genmx_sums genmxE V1. apply/allP => A AAs /=; rewrite similar_diag_sum. - by apply/forallP => i; apply: P_diag. - rewrite mxdirectE/=. under eq_bigr do rewrite (eq_genmx (PrV _)); rewrite -genmx_sums genmxE V1. by under eq_bigr do rewrite genmxE PrV; rewrite -(mxdirectP Vdirect)//= V1. - by move=> i; rewrite (eqmx_stable _ (PrV _)) ?AV. - by move=> i; rewrite /row_free eqmxMfull ?eq_row_base ?row_full_unit. Qed. Lemma diagonalizable_diag {n} (d : 'rV[F]_n) : diagonalizable (diag_mx d). Proof. by exists 1%:M; rewrite ?unitmx1// /similar_to conj1mx diag_mx_is_diag. Qed. Hint Resolve diagonalizable_diag : core. Lemma diagonalizable_scalar {n} (a : F) : diagonalizable (a%:M : 'M_n). Proof. by rewrite -diag_const_mx. Qed. Hint Resolve diagonalizable_scalar : core. Lemma diagonalizable0 {n} : diagonalizable (0 : 'M[F]_n). Proof. by rewrite (_ : 0 = 0%:M)//; apply/matrixP => i j; rewrite !mxE// mul0rn. Qed. Hint Resolve diagonalizable0 : core. Lemma diagonalizablePeigen {n} {f : 'M[F]_n} : diagonalizable f <-> exists2 rs, uniq rs & (\sum_(r <- rs) eigenspace f r :=: 1%:M)%MS. Proof. split=> [df|[rs urs rsP]]. suff [rs rsP] : exists rs, (\sum_(r <- rs) eigenspace f r :=: 1%:M)%MS. exists (undup rs); rewrite ?undup_uniq//; apply: eqmx_trans rsP. elim: rs => //= r rs IHrs; rewrite big_cons. case: ifPn => in_rs; rewrite ?big_cons; last exact: adds_eqmx. apply/(eqmx_trans IHrs)/eqmx_sym/addsmx_idPr. have rrs : (index r rs < size rs)%N by rewrite index_mem. rewrite (big_nth 0) big_mkord (sumsmx_sup (Ordinal rrs)) ?nth_index//. move: df => [P Punit /(similar_diagLR Punit)[d ->]]. exists [seq d 0 i | i <- enum 'I_n]; rewrite big_image/=. apply: (@eqmx_trans _ _ _ _ _ _ P); apply/eqmxP; rewrite ?sub1mx ?submx1 ?row_full_unit//. rewrite submx_full ?row_full_unit//=. apply/row_subP => i; rewrite rowE (sumsmx_sup i)//. apply/eigenspaceP; rewrite conjVmx// !mulmxA mulmxK//. by rewrite -rowE row_diag_mx scalemxAl. have mxdirect_eigenspaces : mxdirect (\sum_(i < size rs) eigenspace f rs`_i). apply: mxdirect_sum_eigenspace => i j _ _ rsij; apply/val_inj. by apply: uniqP rsij; rewrite ?inE. rewrite (big_nth 0) big_mkord in rsP; apply/codiagonalizable1. apply/(codiagonalizable_on _ mxdirect_eigenspaces) => // i/=. case: n => [|n] in f {mxdirect_eigenspaces} rsP *. by rewrite thinmx0 sub0mx. by rewrite comm_mx_stable_eigenspace. apply/codiagonalizable1. by rewrite (@conjmx_eigenvalue _ _ _ rs`_i) ?eq_row_base ?row_base_free. Qed. Lemma diagonalizableP n' (n := n'.+1) (f : 'M[F]_n) : diagonalizable f <-> exists2 rs, uniq rs & mxminpoly f %| \prod_(x <- rs) ('X - x%:P). Proof. split=> [[P Punit /similar_diagPex[d /(similarLR Punit)->]]|]. rewrite mxminpoly_uconj ?unitmx_inv// mxminpoly_diag. by eexists; [|by []]; rewrite undup_uniq. move=> [rs rsU rsP]; apply: diagonalizablePeigen.2. exists rs => //. rewrite (big_nth 0) big_mkord (eq_bigr _ (fun _ _ => eigenspace_poly _ _)). apply: (eqmx_trans (eqmx_sym (kermxpoly_prod _ _)) (kermxpoly_min _)). by move=> i j _ _; rewrite coprimep_XsubC root_XsubC nth_uniq. by rewrite (big_nth 0) big_mkord in rsP. Qed. Lemma diagonalizable_conj_diag m n (V : 'M[F]_(m, n)) (d : 'rV[F]_n) : stablemx V (diag_mx d) -> row_free V -> diagonalizable (conjmx V (diag_mx d)). Proof. (move: m n => [|m] [|n] in V d *; rewrite ?thinmx0; [by []|by []| |]) => Vd rdV. - by rewrite /row_free mxrank0 in rdV. - apply/diagonalizableP; pose u := undup [seq d 0 i | i <- enum 'I_n.+1]. exists u; first by rewrite undup_uniq. by rewrite (dvdp_trans (mxminpoly_conj rdV _))// mxminpoly_diag. Qed. Lemma codiagonalizableP n (fs : seq 'M[F]_n) : {in fs &, forall f g, comm_mx f g} /\ (forall f, f \in fs -> diagonalizable f) <-> codiagonalizable fs. Proof. split => [cdfs|[P Punit /allP/= fsD]]/=; last first. split; last by exists P; rewrite // fsD. move=> f g ffs gfs; move=> /(_ _ _)/similar_diagPex/sigW in fsD. have [[df /similarLR->//] [dg /similarLR->//]] := (fsD _ ffs, fsD _ gfs). by rewrite /comm_mx -!conjmxM 1?diag_mxC// inE stablemx_unit ?unitmx_inv. move: cdfs => [/(rwP (all_comm_mxP _)).1 cdfs1 cdfs2]. have [k] := ubnP (size fs); elim: k => [|k IHk]//= in n fs cdfs1 cdfs2 *. case: fs cdfs1 cdfs2 => [|f fs]//=; first by exists 1%:M; rewrite ?unitmx1. rewrite ltnS all_comm_mx_cons => /andP[/allP/(_ _ _)/eqP ffsC fsC dffs] fsk. have /diagonalizablePeigen [rs urs rs1] := dffs _ (mem_head _ _). rewrite (big_nth 0) big_mkord in rs1. have efg (i : 'I_(size rs)) g : g \in f :: fs -> stablemx (eigenspace f rs`_i) g. case: n => [|n'] in g f fs ffsC fsC {dffs rs1 fsk} * => g_ffs. by rewrite thinmx0 sub0mx. rewrite comm_mx_stable_eigenspace//. by move: g_ffs; rewrite !inE => /predU1P [->//|/ffsC]. apply/(@codiagonalizable_on _ _ _ (_ :: _) rs1) => [|i|i /=]. - apply: mxdirect_sum_eigenspace => i j _ _ rsij; apply/val_inj. by apply: uniqP rsij; rewrite ?inE. - by apply/allP => g g_ffs; rewrite efg. rewrite (@conjmx_eigenvalue _ _ _ rs`_i) ?eq_row_base ?row_base_free//. set gs := map _ _; suff [P Punit /= Pgs] : codiagonalizable gs. exists P; rewrite /= ?Pgs ?andbT// /similar_to. by rewrite conjmx_scalar ?mx_scalar_is_diag// row_free_unit. apply: IHk; rewrite ?size_map/= ?ltnS//. apply/all_comm_mxP => _ _ /mapP[/= g gfs ->] /mapP[/= h hfs ->]. rewrite -!conjmxM ?inE ?stablemx_row_base ?efg ?inE ?gfs ?hfs ?orbT//. by rewrite (all_comm_mxP _ fsC). move=> _ /mapP[/= g gfs ->]. have: stablemx (row_base (eigenspace f rs`_i)) g. by rewrite stablemx_row_base efg// inE gfs orbT. have := dffs g; rewrite inE gfs orbT => /(_ isT) [P Punit]. move=> /similar_diagPex[D /(similarLR Punit)->] sePD. have rfeP : row_free (row_base (eigenspace f rs`_i) *m invmx P). by rewrite /row_free mxrankMfree ?row_free_unit ?unitmx_inv// eq_row_base. rewrite -conjMumx ?unitmx_inv ?row_base_free//. apply/diagonalizable_conj_diag => //. by rewrite stablemx_comp// stablemx_unit ?unitmx_inv. Qed. End Diag.