Dataset Viewer
Auto-converted to Parquet Duplicate
Context
stringlengths
285
157k
file_name
stringlengths
21
79
start
int64
14
3.67k
end
int64
18
3.69k
theorem
stringlengths
25
2.71k
proof
stringlengths
5
10.6k
/- 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.Algebra.Category.ModuleCat.Free import Mathlib.Topology.Category.Profinite.CofilteredLimit import Mathlib.Topology.Category.Profinite.Product import Mathlib.Topology.LocallyConstant.Algebra import Mathlib.Init.Data.Bool.Lemmas /-! # Nöbeling's theorem This file proves Nöbeling's theorem. ## Main result * `LocallyConstant.freeOfProfinite`: Nöbeling's theorem. For `S : Profinite`, the `ℤ`-module `LocallyConstant S ℤ` is free. ## Proof idea We follow the proof of theorem 5.4 in [scholze2019condensed], in which the idea is to embed `S` in a product of `I` copies of `Bool` for some sufficiently large `I`, and then to choose a well-ordering on `I` and use ordinal induction over that well-order. Here we can let `I` be the set of clopen subsets of `S` since `S` is totally separated. The above means it suffices to prove the following statement: For a closed subset `C` of `I → Bool`, the `ℤ`-module `LocallyConstant C ℤ` is free. For `i : I`, let `e C i : LocallyConstant C ℤ` denote the map `fun f ↦ (if f.val i then 1 else 0)`. The basis will consist of products `e C iᵣ * ⋯ * e C i₁` with `iᵣ > ⋯ > i₁` which cannot be written as linear combinations of lexicographically smaller products. We call this set `GoodProducts C` What is proved by ordinal induction is that this set is linearly independent. The fact that it spans can be proved directly. ## References - [scholze2019condensed], Theorem 5.4. -/ universe u namespace Profinite namespace NobelingProof variable {I : Type u} [LinearOrder I] [IsWellOrder I (·<·)] (C : Set (I → Bool)) open Profinite ContinuousMap CategoryTheory Limits Opposite Submodule section Projections /-! ## Projection maps The purpose of this section is twofold. Firstly, in the proof that the set `GoodProducts C` spans the whole module `LocallyConstant C ℤ`, we need to project `C` down to finite discrete subsets and write `C` as a cofiltered limit of those. Secondly, in the inductive argument, we need to project `C` down to "smaller" sets satisfying the inductive hypothesis. In this section we define the relevant projection maps and prove some compatibility results. ### Main definitions * Let `J : I → Prop`. Then `Proj J : (I → Bool) → (I → Bool)` is the projection mapping everything that satisfies `J i` to itself, and everything else to `false`. * The image of `C` under `Proj J` is denoted `π C J` and the corresponding map `C → π C J` is called `ProjRestrict`. If `J` implies `K` we have a map `ProjRestricts : π C K → π C J`. * `spanCone_isLimit` establishes that when `C` is compact, it can be written as a limit of its images under the maps `Proj (· ∈ s)` where `s : Finset I`. -/ variable (J K L : I → Prop) [∀ i, Decidable (J i)] [∀ i, Decidable (K i)] [∀ i, Decidable (L i)] /-- The projection mapping everything that satisfies `J i` to itself, and everything else to `false` -/ def Proj : (I → Bool) → (I → Bool) := fun c i ↦ if J i then c i else false @[simp] theorem continuous_proj : Continuous (Proj J : (I → Bool) → (I → Bool)) := by dsimp (config := { unfoldPartialApp := true }) [Proj] apply continuous_pi intro i split · apply continuous_apply · apply continuous_const /-- The image of `Proj π J` -/ def π : Set (I → Bool) := (Proj J) '' C /-- The restriction of `Proj π J` to a subset, mapping to its image. -/ @[simps!] def ProjRestrict : C → π C J := Set.MapsTo.restrict (Proj J) _ _ (Set.mapsTo_image _ _) @[simp] theorem continuous_projRestrict : Continuous (ProjRestrict C J) := Continuous.restrict _ (continuous_proj _) theorem proj_eq_self {x : I → Bool} (h : ∀ i, x i ≠ false → J i) : Proj J x = x := by ext i simp only [Proj, ite_eq_left_iff] contrapose! simpa only [ne_comm] using h i theorem proj_prop_eq_self (hh : ∀ i x, x ∈ C → x i ≠ false → J i) : π C J = C := by ext x refine ⟨fun ⟨y, hy, h⟩ ↦ ?_, fun h ↦ ⟨x, h, ?_⟩⟩ · rwa [← h, proj_eq_self]; exact (hh · y hy) · rw [proj_eq_self]; exact (hh · x h) theorem proj_comp_of_subset (h : ∀ i, J i → K i) : (Proj J ∘ Proj K) = (Proj J : (I → Bool) → (I → Bool)) := by ext x i; dsimp [Proj]; aesop theorem proj_eq_of_subset (h : ∀ i, J i → K i) : π (π C K) J = π C J := by ext x refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩ · obtain ⟨y, ⟨z, hz, rfl⟩, rfl⟩ := h refine ⟨z, hz, (?_ : _ = (Proj J ∘ Proj K) z)⟩ rw [proj_comp_of_subset J K h] · obtain ⟨y, hy, rfl⟩ := h dsimp [π] rw [← Set.image_comp] refine ⟨y, hy, ?_⟩ rw [proj_comp_of_subset J K h] variable {J K L} /-- A variant of `ProjRestrict` with domain of the form `π C K` -/ @[simps!] def ProjRestricts (h : ∀ i, J i → K i) : π C K → π C J := Homeomorph.setCongr (proj_eq_of_subset C J K h) ∘ ProjRestrict (π C K) J @[simp] theorem continuous_projRestricts (h : ∀ i, J i → K i) : Continuous (ProjRestricts C h) := Continuous.comp (Homeomorph.continuous _) (continuous_projRestrict _ _) theorem surjective_projRestricts (h : ∀ i, J i → K i) : Function.Surjective (ProjRestricts C h) := (Homeomorph.surjective _).comp (Set.surjective_mapsTo_image_restrict _ _) variable (J) in theorem projRestricts_eq_id : ProjRestricts C (fun i (h : J i) ↦ h) = id := by ext ⟨x, y, hy, rfl⟩ i simp (config := { contextual := true }) only [π, Proj, ProjRestricts_coe, id_eq, if_true] theorem projRestricts_eq_comp (hJK : ∀ i, J i → K i) (hKL : ∀ i, K i → L i) : ProjRestricts C hJK ∘ ProjRestricts C hKL = ProjRestricts C (fun i ↦ hKL i ∘ hJK i) := by ext x i simp only [π, Proj, Function.comp_apply, ProjRestricts_coe] aesop theorem projRestricts_comp_projRestrict (h : ∀ i, J i → K i) : ProjRestricts C h ∘ ProjRestrict C K = ProjRestrict C J := by ext x i simp only [π, Proj, Function.comp_apply, ProjRestricts_coe, ProjRestrict_coe] aesop variable (J) /-- The objectwise map in the isomorphism `spanFunctor ≅ Profinite.indexFunctor`. -/ def iso_map : C(π C J, (IndexFunctor.obj C J)) := ⟨fun x ↦ ⟨fun i ↦ x.val i.val, by rcases x with ⟨x, y, hy, rfl⟩ refine ⟨y, hy, ?_⟩ ext ⟨i, hi⟩ simp [precomp, Proj, hi]⟩, by refine Continuous.subtype_mk (continuous_pi fun i ↦ ?_) _ exact (continuous_apply i.val).comp continuous_subtype_val⟩ lemma iso_map_bijective : Function.Bijective (iso_map C J) := by refine ⟨fun a b h ↦ ?_, fun a ↦ ?_⟩ · ext i rw [Subtype.ext_iff] at h by_cases hi : J i · exact congr_fun h ⟨i, hi⟩ · rcases a with ⟨_, c, hc, rfl⟩ rcases b with ⟨_, d, hd, rfl⟩ simp only [Proj, if_neg hi] · refine ⟨⟨fun i ↦ if hi : J i then a.val ⟨i, hi⟩ else false, ?_⟩, ?_⟩ · rcases a with ⟨_, y, hy, rfl⟩ exact ⟨y, hy, rfl⟩ · ext i exact dif_pos i.prop variable {C} (hC : IsCompact C) /-- For a given compact subset `C` of `I → Bool`, `spanFunctor` is the functor from the poset of finsets of `I` to `Profinite`, sending a finite subset set `J` to the image of `C` under the projection `Proj J`. -/ noncomputable def spanFunctor [∀ (s : Finset I) (i : I), Decidable (i ∈ s)] : (Finset I)ᵒᵖ ⥤ Profinite.{u} where obj s := @Profinite.of (π C (· ∈ (unop s))) _ (by rw [← isCompact_iff_compactSpace]; exact hC.image (continuous_proj _)) _ _ map h := ⟨(ProjRestricts C (leOfHom h.unop)), continuous_projRestricts _ _⟩ map_id J := by simp only [projRestricts_eq_id C (· ∈ (unop J))]; rfl map_comp _ _ := by dsimp; congr; dsimp; rw [projRestricts_eq_comp] /-- The limit cone on `spanFunctor` with point `C`. -/ noncomputable def spanCone [∀ (s : Finset I) (i : I), Decidable (i ∈ s)] : Cone (spanFunctor hC) where pt := @Profinite.of C _ (by rwa [← isCompact_iff_compactSpace]) _ _ π := { app := fun s ↦ ⟨ProjRestrict C (· ∈ unop s), continuous_projRestrict _ _⟩ naturality := by intro X Y h simp only [Functor.const_obj_obj, Homeomorph.setCongr, Homeomorph.homeomorph_mk_coe, Functor.const_obj_map, Category.id_comp, ← projRestricts_comp_projRestrict C (leOfHom h.unop)] rfl } /-- `spanCone` is a limit cone. -/ noncomputable def spanCone_isLimit [∀ (s : Finset I) (i : I), Decidable (i ∈ s)] : CategoryTheory.Limits.IsLimit (spanCone hC) := by refine (IsLimit.postcomposeHomEquiv (NatIso.ofComponents (fun s ↦ (Profinite.isoOfBijective _ (iso_map_bijective C (· ∈ unop s)))) ?_) (spanCone hC)) (IsLimit.ofIsoLimit (indexCone_isLimit hC) (Cones.ext (Iso.refl _) ?_)) · intro ⟨s⟩ ⟨t⟩ ⟨⟨⟨f⟩⟩⟩ ext x have : iso_map C (· ∈ t) ∘ ProjRestricts C f = IndexFunctor.map C f ∘ iso_map C (· ∈ s) := by ext _ i; exact dif_pos i.prop exact congr_fun this x · intro ⟨s⟩ ext x have : iso_map C (· ∈ s) ∘ ProjRestrict C (· ∈ s) = IndexFunctor.π_app C (· ∈ s) := by ext _ i; exact dif_pos i.prop erw [← this] rfl end Projections section Products /-! ## Defining the basis Our proposed basis consists of products `e C iᵣ * ⋯ * e C i₁` with `iᵣ > ⋯ > i₁` which cannot be written as linear combinations of lexicographically smaller products. See below for the definition of `e`. ### Main definitions * For `i : I`, we let `e C i : LocallyConstant C ℤ` denote the map `fun f ↦ (if f.val i then 1 else 0)`. * `Products I` is the type of lists of decreasing elements of `I`, so a typical element is `[i₁, i₂,..., iᵣ]` with `i₁ > i₂ > ... > iᵣ`. * `Products.eval C` is the `C`-evaluation of a list. It takes a term `[i₁, i₂,..., iᵣ] : Products I` and returns the actual product `e C i₁ ··· e C iᵣ : LocallyConstant C ℤ`. * `GoodProducts C` is the set of `Products I` such that their `C`-evaluation cannot be written as a linear combination of evaluations of lexicographically smaller lists. ### Main results * `Products.evalFacProp` and `Products.evalFacProps` establish the fact that `Products.eval`  interacts nicely with the projection maps from the previous section. * `GoodProducts.span_iff_products`: the good products span `LocallyConstant C ℤ` iff all the products span `LocallyConstant C ℤ`. -/ /-- `e C i` is the locally constant map from `C : Set (I → Bool)` to `ℤ` sending `f` to 1 if `f.val i = true`, and 0 otherwise. -/ def e (i : I) : LocallyConstant C ℤ where toFun := fun f ↦ (if f.val i then 1 else 0) isLocallyConstant := by rw [IsLocallyConstant.iff_continuous] exact (continuous_of_discreteTopology (f := fun (a : Bool) ↦ (if a then (1 : ℤ) else 0))).comp ((continuous_apply i).comp continuous_subtype_val) /-- `Products I` is the type of lists of decreasing elements of `I`, so a typical element is `[i₁, i₂, ...]` with `i₁ > i₂ > ...`. We order `Products I` lexicographically, so `[] < [i₁, ...]`, and `[i₁, i₂, ...] < [j₁, j₂, ...]` if either `i₁ < j₁`, or `i₁ = j₁` and `[i₂, ...] < [j₂, ...]`. Terms `m = [i₁, i₂, ..., iᵣ]` of this type will be used to represent products of the form `e C i₁ ··· e C iᵣ : LocallyConstant C ℤ` . The function associated to `m` is `m.eval`. -/ def Products (I : Type*) [LinearOrder I] := {l : List I // l.Chain' (·>·)} namespace Products instance : LinearOrder (Products I) := inferInstanceAs (LinearOrder {l : List I // l.Chain' (·>·)}) @[simp] theorem lt_iff_lex_lt (l m : Products I) : l < m ↔ List.Lex (·<·) l.val m.val := by cases l; cases m; rw [Subtype.mk_lt_mk]; exact Iff.rfl instance : IsWellFounded (Products I) (·<·) := by have : (· < · : Products I → _ → _) = (fun l m ↦ List.Lex (·<·) l.val m.val) := by ext; exact lt_iff_lex_lt _ _ rw [this] dsimp [Products] rw [(by rfl : (·>· : I → _) = flip (·<·))] infer_instance /-- The evaluation `e C i₁ ··· e C iᵣ : C → ℤ` of a formal product `[i₁, i₂, ..., iᵣ]`. -/ def eval (l : Products I) := (l.1.map (e C)).prod /-- The predicate on products which we prove picks out a basis of `LocallyConstant C ℤ`. We call such a product "good". -/ def isGood (l : Products I) : Prop := l.eval C ∉ Submodule.span ℤ ((Products.eval C) '' {m | m < l}) theorem rel_head!_of_mem [Inhabited I] {i : I} {l : Products I} (hi : i ∈ l.val) : i ≤ l.val.head! := List.Sorted.le_head! (List.chain'_iff_pairwise.mp l.prop) hi theorem head!_le_of_lt [Inhabited I] {q l : Products I} (h : q < l) (hq : q.val ≠ []) : q.val.head! ≤ l.val.head! := List.head!_le_of_lt l.val q.val h hq end Products /-- The set of good products. -/ def GoodProducts := {l : Products I | l.isGood C} namespace GoodProducts /-- Evaluation of good products. -/ def eval (l : {l : Products I // l.isGood C}) : LocallyConstant C ℤ := Products.eval C l.1 theorem injective : Function.Injective (eval C) := by intro ⟨a, ha⟩ ⟨b, hb⟩ h dsimp [eval] at h rcases lt_trichotomy a b with (h'|rfl|h') · exfalso; apply hb; rw [← h] exact Submodule.subset_span ⟨a, h', rfl⟩ · rfl · exfalso; apply ha; rw [h] exact Submodule.subset_span ⟨b, ⟨h',rfl⟩⟩ /-- The image of the good products in the module `LocallyConstant C ℤ`. -/ def range := Set.range (GoodProducts.eval C) /-- The type of good products is equivalent to its image. -/ noncomputable def equiv_range : GoodProducts C ≃ range C := Equiv.ofInjective (eval C) (injective C) theorem equiv_toFun_eq_eval : (equiv_range C).toFun = Set.rangeFactorization (eval C) := rfl theorem linearIndependent_iff_range : LinearIndependent ℤ (GoodProducts.eval C) ↔ LinearIndependent ℤ (fun (p : range C) ↦ p.1) := by rw [← @Set.rangeFactorization_eq _ _ (GoodProducts.eval C), ← equiv_toFun_eq_eval C] exact linearIndependent_equiv (equiv_range C) end GoodProducts namespace Products theorem eval_eq (l : Products I) (x : C) : l.eval C x = if ∀ i, i ∈ l.val → (x.val i = true) then 1 else 0 := by change LocallyConstant.evalMonoidHom x (l.eval C) = _ rw [eval, map_list_prod] split_ifs with h · simp only [List.map_map] apply List.prod_eq_one simp only [List.mem_map, Function.comp_apply] rintro _ ⟨i, hi, rfl⟩ exact if_pos (h i hi) · simp only [List.map_map, List.prod_eq_zero_iff, List.mem_map, Function.comp_apply] push_neg at h convert h with i dsimp [LocallyConstant.evalMonoidHom, e] simp only [ite_eq_right_iff, one_ne_zero] theorem evalFacProp {l : Products I} (J : I → Prop) (h : ∀ a, a ∈ l.val → J a) [∀ j, Decidable (J j)] : l.eval (π C J) ∘ ProjRestrict C J = l.eval C := by ext x dsimp [ProjRestrict] rw [Products.eval_eq, Products.eval_eq] congr apply forall_congr; intro i apply forall_congr; intro hi simp [h i hi, Proj] theorem evalFacProps {l : Products I} (J K : I → Prop) (h : ∀ a, a ∈ l.val → J a) [∀ j, Decidable (J j)] [∀ j, Decidable (K j)] (hJK : ∀ i, J i → K i) : l.eval (π C J) ∘ ProjRestricts C hJK = l.eval (π C K) := by have : l.eval (π C J) ∘ Homeomorph.setCongr (proj_eq_of_subset C J K hJK) = l.eval (π (π C K) J) := by ext; simp [Homeomorph.setCongr, Products.eval_eq] rw [ProjRestricts, ← Function.comp.assoc, this, ← evalFacProp (π C K) J h] theorem prop_of_isGood {l : Products I} (J : I → Prop) [∀ j, Decidable (J j)] (h : l.isGood (π C J)) : ∀ a, a ∈ l.val → J a := by intro i hi by_contra h' apply h suffices eval (π C J) l = 0 by rw [this] exact Submodule.zero_mem _ ext ⟨_, _, _, rfl⟩ rw [eval_eq, if_neg fun h ↦ ?_, LocallyConstant.zero_apply] simpa [Proj, h'] using h i hi end Products /-- The good products span `LocallyConstant C ℤ` if and only all the products do. -/ theorem GoodProducts.span_iff_products : ⊤ ≤ span ℤ (Set.range (eval C)) ↔ ⊤ ≤ span ℤ (Set.range (Products.eval C)) := by refine ⟨fun h ↦ le_trans h (span_mono (fun a ⟨b, hb⟩ ↦ ⟨b.val, hb⟩)), fun h ↦ le_trans h ?_⟩ rw [span_le] rintro f ⟨l, rfl⟩ let L : Products I → Prop := fun m ↦ m.eval C ∈ span ℤ (Set.range (GoodProducts.eval C)) suffices L l by assumption apply IsWellFounded.induction (·<· : Products I → Products I → Prop) intro l h dsimp by_cases hl : l.isGood C · apply subset_span exact ⟨⟨l, hl⟩, rfl⟩ · simp only [Products.isGood, not_not] at hl suffices Products.eval C '' {m | m < l} ⊆ span ℤ (Set.range (GoodProducts.eval C)) by rw [← span_le] at this exact this hl rintro a ⟨m, hm, rfl⟩ exact h m hm end Products section Span /-! ## The good products span Most of the argument is developing an API for `π C (· ∈ s)` when `s : Finset I`; then the image of `C` is finite with the discrete topology. In this case, there is a direct argument that the good products span. The general result is deduced from this. ### Main theorems * `GoodProducts.spanFin` : The good products span the locally constant functions on `π C (· ∈ s)` if `s` is finite. * `GoodProducts.span` : The good products span `LocallyConstant C ℤ` for every closed subset `C`. -/ section Fin variable (s : Finset I) /-- The `ℤ`-linear map induced by precomposition of the projection `C → π C (· ∈ s)`. -/ noncomputable def πJ : LocallyConstant (π C (· ∈ s)) ℤ →ₗ[ℤ] LocallyConstant C ℤ := LocallyConstant.comapₗ ℤ ⟨_, (continuous_projRestrict C (· ∈ s))⟩ theorem eval_eq_πJ (l : Products I) (hl : l.isGood (π C (· ∈ s))) : l.eval C = πJ C s (l.eval (π C (· ∈ s))) := by ext f simp only [πJ, LocallyConstant.comapₗ, LinearMap.coe_mk, AddHom.coe_mk, (continuous_projRestrict C (· ∈ s)), LocallyConstant.coe_comap, Function.comp_apply] exact (congr_fun (Products.evalFacProp C (· ∈ s) (Products.prop_of_isGood C (· ∈ s) hl)) _).symm /-- `π C (· ∈ s)` is finite for a finite set `s`. -/ noncomputable instance : Fintype (π C (· ∈ s)) := by let f : π C (· ∈ s) → (s → Bool) := fun x j ↦ x.val j.val refine Fintype.ofInjective f ?_ intro ⟨_, x, hx, rfl⟩ ⟨_, y, hy, rfl⟩ h ext i by_cases hi : i ∈ s · exact congrFun h ⟨i, hi⟩ · simp only [Proj, if_neg hi] open scoped Classical in /-- The Kronecker delta as a locally constant map from `π C (· ∈ s)` to `ℤ`. -/ noncomputable def spanFinBasis (x : π C (· ∈ s)) : LocallyConstant (π C (· ∈ s)) ℤ where toFun := fun y ↦ if y = x then 1 else 0 isLocallyConstant := haveI : DiscreteTopology (π C (· ∈ s)) := discrete_of_t1_of_finite IsLocallyConstant.of_discrete _ open scoped Classical in theorem spanFinBasis.span : ⊤ ≤ Submodule.span ℤ (Set.range (spanFinBasis C s)) := by intro f _ rw [Finsupp.mem_span_range_iff_exists_finsupp] use Finsupp.onFinset (Finset.univ) f.toFun (fun _ _ ↦ Finset.mem_univ _) ext x change LocallyConstant.evalₗ ℤ x _ = _ simp only [zsmul_eq_mul, map_finsupp_sum, LocallyConstant.evalₗ_apply, LocallyConstant.coe_mul, Pi.mul_apply, spanFinBasis, LocallyConstant.coe_mk, mul_ite, mul_one, mul_zero, Finsupp.sum_ite_eq, Finsupp.mem_support_iff, ne_eq, ite_not] split_ifs with h <;> [exact h.symm; rfl] /-- A certain explicit list of locally constant maps. The theorem `factors_prod_eq_basis` shows that the product of the elements in this list is the delta function `spanFinBasis C s x`. -/ def factors (x : π C (· ∈ s)) : List (LocallyConstant (π C (· ∈ s)) ℤ) := List.map (fun i ↦ if x.val i = true then e (π C (· ∈ s)) i else (1 - (e (π C (· ∈ s)) i))) (s.sort (·≥·)) theorem list_prod_apply (x : C) (l : List (LocallyConstant C ℤ)) : l.prod x = (l.map (LocallyConstant.evalMonoidHom x)).prod := by rw [← map_list_prod (LocallyConstant.evalMonoidHom x) l] rfl theorem factors_prod_eq_basis_of_eq {x y : (π C fun x ↦ x ∈ s)} (h : y = x) : (factors C s x).prod y = 1 := by rw [list_prod_apply (π C (· ∈ s)) y _] apply List.prod_eq_one simp only [h, List.mem_map, LocallyConstant.evalMonoidHom, factors] rintro _ ⟨a, ⟨b, _, rfl⟩, rfl⟩ dsimp split_ifs with hh · rw [e, LocallyConstant.coe_mk, if_pos hh] · rw [LocallyConstant.sub_apply, e, LocallyConstant.coe_mk, LocallyConstant.coe_mk, if_neg hh] simp only [LocallyConstant.toFun_eq_coe, LocallyConstant.coe_one, Pi.one_apply, sub_zero] theorem e_mem_of_eq_true {x : (π C (· ∈ s))} {a : I} (hx : x.val a = true) : e (π C (· ∈ s)) a ∈ factors C s x := by rcases x with ⟨_, z, hz, rfl⟩ simp only [factors, List.mem_map, Finset.mem_sort] refine ⟨a, ?_, if_pos hx⟩ aesop (add simp Proj) theorem one_sub_e_mem_of_false {x y : (π C (· ∈ s))} {a : I} (ha : y.val a = true) (hx : x.val a = false) : 1 - e (π C (· ∈ s)) a ∈ factors C s x := by simp only [factors, List.mem_map, Finset.mem_sort] use a simp only [hx, ite_false, and_true] rcases y with ⟨_, z, hz, rfl⟩ aesop (add simp Proj) theorem factors_prod_eq_basis_of_ne {x y : (π C (· ∈ s))} (h : y ≠ x) : (factors C s x).prod y = 0 := by rw [list_prod_apply (π C (· ∈ s)) y _] apply List.prod_eq_zero simp only [List.mem_map] obtain ⟨a, ha⟩ : ∃ a, y.val a ≠ x.val a := by contrapose! h; ext; apply h cases hx : x.val a · rw [hx, ne_eq, Bool.not_eq_false] at ha refine ⟨1 - (e (π C (· ∈ s)) a), ⟨one_sub_e_mem_of_false _ _ ha hx, ?_⟩⟩ rw [e, LocallyConstant.evalMonoidHom_apply, LocallyConstant.sub_apply, LocallyConstant.coe_one, Pi.one_apply, LocallyConstant.coe_mk, if_pos ha, sub_self] · refine ⟨e (π C (· ∈ s)) a, ⟨e_mem_of_eq_true _ _ hx, ?_⟩⟩ rw [hx] at ha rw [LocallyConstant.evalMonoidHom_apply, e, LocallyConstant.coe_mk, if_neg ha] /-- If `s` is finite, the product of the elements of the list `factors C s x` is the delta function at `x`. -/ theorem factors_prod_eq_basis (x : π C (· ∈ s)) : (factors C s x).prod = spanFinBasis C s x := by ext y dsimp [spanFinBasis] split_ifs with h <;> [exact factors_prod_eq_basis_of_eq _ _ h; exact factors_prod_eq_basis_of_ne _ _ h] theorem GoodProducts.finsupp_sum_mem_span_eval {a : I} {as : List I} (ha : List.Chain' (· > ·) (a :: as)) {c : Products I →₀ ℤ} (hc : (c.support : Set (Products I)) ⊆ {m | m.val ≤ as}) : (Finsupp.sum c fun a_1 b ↦ e (π C (· ∈ s)) a * b • Products.eval (π C (· ∈ s)) a_1) ∈ Submodule.span ℤ (Products.eval (π C (· ∈ s)) '' {m | m.val ≤ a :: as}) := by apply Submodule.finsupp_sum_mem intro m hm have hsm := (LinearMap.mulLeft ℤ (e (π C (· ∈ s)) a)).map_smul dsimp at hsm rw [hsm] apply Submodule.smul_mem apply Submodule.subset_span have hmas : m.val ≤ as := by apply hc simpa only [Finset.mem_coe, Finsupp.mem_support_iff] using hm refine ⟨⟨a :: m.val, ha.cons_of_le m.prop hmas⟩, ⟨List.cons_le_cons a hmas, ?_⟩⟩ simp only [Products.eval, List.map, List.prod_cons] /-- If `s` is a finite subset of `I`, then the good products span. -/ theorem GoodProducts.spanFin : ⊤ ≤ Submodule.span ℤ (Set.range (eval (π C (· ∈ s)))) := by rw [span_iff_products] refine le_trans (spanFinBasis.span C s) ?_ rw [Submodule.span_le] rintro _ ⟨x, rfl⟩ rw [← factors_prod_eq_basis] let l := s.sort (·≥·) dsimp [factors] suffices l.Chain' (·>·) → (l.map (fun i ↦ if x.val i = true then e (π C (· ∈ s)) i else (1 - (e (π C (· ∈ s)) i)))).prod ∈ Submodule.span ℤ ((Products.eval (π C (· ∈ s))) '' {m | m.val ≤ l}) from Submodule.span_mono (Set.image_subset_range _ _) (this (Finset.sort_sorted_gt _).chain') induction l with | nil => intro _ apply Submodule.subset_span exact ⟨⟨[], List.chain'_nil⟩,⟨Or.inl rfl, rfl⟩⟩ | cons a as ih => rw [List.map_cons, List.prod_cons] intro ha specialize ih (by rw [List.chain'_cons'] at ha; exact ha.2) rw [Finsupp.mem_span_image_iff_total] at ih simp only [Finsupp.mem_supported, Finsupp.total_apply] at ih obtain ⟨c, hc, hc'⟩ := ih rw [← hc']; clear hc' have hmap := fun g ↦ map_finsupp_sum (LinearMap.mulLeft ℤ (e (π C (· ∈ s)) a)) c g dsimp at hmap ⊢ split_ifs · rw [hmap] exact finsupp_sum_mem_span_eval _ _ ha hc · ring_nf rw [hmap] apply Submodule.add_mem · apply Submodule.neg_mem exact finsupp_sum_mem_span_eval _ _ ha hc · apply Submodule.finsupp_sum_mem intro m hm apply Submodule.smul_mem apply Submodule.subset_span refine ⟨m, ⟨?_, rfl⟩⟩ simp only [Set.mem_setOf_eq] have hmas : m.val ≤ as := hc (by simpa only [Finset.mem_coe, Finsupp.mem_support_iff] using hm) refine le_trans hmas ?_ cases as with | nil => exact (List.nil_lt_cons a []).le | cons b bs => apply le_of_lt rw [List.chain'_cons] at ha have hlex := List.lt.head bs (b :: bs) ha.1 exact (List.lt_iff_lex_lt _ _).mp hlex end Fin theorem fin_comap_jointlySurjective (hC : IsClosed C) (f : LocallyConstant C ℤ) : ∃ (s : Finset I) (g : LocallyConstant (π C (· ∈ s)) ℤ), f = g.comap ⟨(ProjRestrict C (· ∈ s)), continuous_projRestrict _ _⟩ := by obtain ⟨J, g, h⟩ := @Profinite.exists_locallyConstant.{0, u, u} (Finset I)ᵒᵖ _ _ _ (spanCone hC.isCompact) ℤ (spanCone_isLimit hC.isCompact) f exact ⟨(Opposite.unop J), g, h⟩ /-- The good products span all of `LocallyConstant C ℤ` if `C` is closed. -/ theorem GoodProducts.span (hC : IsClosed C) : ⊤ ≤ Submodule.span ℤ (Set.range (eval C)) := by rw [span_iff_products] intro f _ obtain ⟨K, f', rfl⟩ : ∃ K f', f = πJ C K f' := fin_comap_jointlySurjective C hC f refine Submodule.span_mono ?_ <| Submodule.apply_mem_span_image_of_mem_span (πJ C K) <| spanFin C K (Submodule.mem_top : f' ∈ ⊤) rintro l ⟨y, ⟨m, rfl⟩, rfl⟩ exact ⟨m.val, eval_eq_πJ C K m.val m.prop⟩ end Span section Ordinal /-! ## Relating elements of the well-order `I` with ordinals We choose a well-ordering on `I`. This amounts to regarding `I` as an ordinal, and as such it can be regarded as the set of all strictly smaller ordinals, allowing to apply ordinal induction. ### Main definitions * `ord I i` is the term `i` of `I` regarded as an ordinal. * `term I ho` is a sufficiently small ordinal regarded as a term of `I`. * `contained C o` is a predicate saying that `C` is "small" enough in relation to the ordinal `o` to satisfy the inductive hypothesis. * `P I` is the predicate on ordinals about linear independence of good products, which the rest of this file is spent on proving by induction. -/ variable (I) /-- A term of `I` regarded as an ordinal. -/ def ord (i : I) : Ordinal := Ordinal.typein ((·<·) : I → I → Prop) i /-- An ordinal regarded as a term of `I`. -/ noncomputable def term {o : Ordinal} (ho : o < Ordinal.type ((·<·) : I → I → Prop)) : I := Ordinal.enum ((·<·) : I → I → Prop) o ho variable {I} theorem term_ord_aux {i : I} (ho : ord I i < Ordinal.type ((·<·) : I → I → Prop)) : term I ho = i := by simp only [term, ord, Ordinal.enum_typein] @[simp] theorem ord_term_aux {o : Ordinal} (ho : o < Ordinal.type ((·<·) : I → I → Prop)) : ord I (term I ho) = o := by simp only [ord, term, Ordinal.typein_enum] theorem ord_term {o : Ordinal} (ho : o < Ordinal.type ((·<·) : I → I → Prop)) (i : I) : ord I i = o ↔ term I ho = i := by refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩ · subst h exact term_ord_aux ho · subst h exact ord_term_aux ho /-- A predicate saying that `C` is "small" enough to satisfy the inductive hypothesis. -/ def contained (o : Ordinal) : Prop := ∀ f, f ∈ C → ∀ (i : I), f i = true → ord I i < o variable (I) in /-- The predicate on ordinals which we prove by induction, see `GoodProducts.P0`, `GoodProducts.Plimit` and `GoodProducts.linearIndependentAux` in the section `Induction` below -/ def P (o : Ordinal) : Prop := o ≤ Ordinal.type (·<· : I → I → Prop) → (∀ (C : Set (I → Bool)), IsClosed C → contained C o → LinearIndependent ℤ (GoodProducts.eval C)) theorem Products.prop_of_isGood_of_contained {l : Products I} (o : Ordinal) (h : l.isGood C) (hsC : contained C o) (i : I) (hi : i ∈ l.val) : ord I i < o := by by_contra h' apply h suffices eval C l = 0 by simp [this, Submodule.zero_mem] ext x simp only [eval_eq, LocallyConstant.coe_zero, Pi.zero_apply, ite_eq_right_iff, one_ne_zero] contrapose! h' exact hsC x.val x.prop i (h'.1 i hi) end Ordinal section Zero /-! ## The zero case of the induction In this case, we have `contained C 0` which means that `C` is either empty or a singleton. -/ instance : Subsingleton (LocallyConstant (∅ : Set (I → Bool)) ℤ) := subsingleton_iff.mpr (fun _ _ ↦ LocallyConstant.ext isEmptyElim) instance : IsEmpty { l // Products.isGood (∅ : Set (I → Bool)) l } := isEmpty_iff.mpr fun ⟨l, hl⟩ ↦ hl <| by rw [subsingleton_iff.mp inferInstance (Products.eval ∅ l) 0] exact Submodule.zero_mem _ theorem GoodProducts.linearIndependentEmpty : LinearIndependent ℤ (eval (∅ : Set (I → Bool))) := linearIndependent_empty_type /-- The empty list as a `Products` -/ def Products.nil : Products I := ⟨[], by simp only [List.chain'_nil]⟩ theorem Products.lt_nil_empty : { m : Products I | m < Products.nil } = ∅ := by ext ⟨m, hm⟩ refine ⟨fun h ↦ ?_, by tauto⟩ simp only [Set.mem_setOf_eq, lt_iff_lex_lt, nil, List.Lex.not_nil_right] at h instance {α : Type*} [TopologicalSpace α] [Nonempty α] : Nontrivial (LocallyConstant α ℤ) := ⟨0, 1, ne_of_apply_ne DFunLike.coe <| (Function.const_injective (β := ℤ)).ne zero_ne_one⟩ set_option backward.synthInstance.canonInstances false in -- See https://github.com/leanprover-community/mathlib4/issues/12532 theorem Products.isGood_nil : Products.isGood ({fun _ ↦ false} : Set (I → Bool)) Products.nil := by intro h simp only [Products.lt_nil_empty, Products.eval, List.map, List.prod_nil, Set.image_empty, Submodule.span_empty, Submodule.mem_bot, one_ne_zero] at h set_option backward.synthInstance.canonInstances false in -- See https://github.com/leanprover-community/mathlib4/issues/12532 theorem Products.span_nil_eq_top : Submodule.span ℤ (eval ({fun _ ↦ false} : Set (I → Bool)) '' {nil}) = ⊤ := by rw [Set.image_singleton, eq_top_iff] intro f _ rw [Submodule.mem_span_singleton] refine ⟨f default, ?_⟩ simp only [eval, List.map, List.prod_nil, zsmul_eq_mul, mul_one] ext x obtain rfl : x = default := by simp only [Set.default_coe_singleton, eq_iff_true_of_subsingleton] rfl /-- There is a unique `GoodProducts` for the singleton `{fun _ ↦ false}`. -/ noncomputable instance : Unique { l // Products.isGood ({fun _ ↦ false} : Set (I → Bool)) l } where default := ⟨Products.nil, Products.isGood_nil⟩ uniq := by intro ⟨⟨l, hl⟩, hll⟩ ext apply Subtype.ext apply (List.Lex.nil_left_or_eq_nil l (r := (·<·))).resolve_left intro _ apply hll have he : {Products.nil} ⊆ {m | m < ⟨l,hl⟩} := by simpa only [Products.nil, Products.lt_iff_lex_lt, Set.singleton_subset_iff, Set.mem_setOf_eq] apply Submodule.span_mono (Set.image_subset _ he) rw [Products.span_nil_eq_top] exact Submodule.mem_top instance (α : Type*) [TopologicalSpace α] : NoZeroSMulDivisors ℤ (LocallyConstant α ℤ) := by constructor intro c f h rw [or_iff_not_imp_left] intro hc ext x apply mul_right_injective₀ hc simp [LocallyConstant.ext_iff] at h ⊢ exact h x set_option backward.synthInstance.canonInstances false in -- See https://github.com/leanprover-community/mathlib4/issues/12532 theorem GoodProducts.linearIndependentSingleton : LinearIndependent ℤ (eval ({fun _ ↦ false} : Set (I → Bool))) := by refine linearIndependent_unique (eval ({fun _ ↦ false} : Set (I → Bool))) ?_ simp only [eval, Products.eval, List.map, List.prod_nil, ne_eq, one_ne_zero, not_false_eq_true] end Zero section Maps /-! ## `ℤ`-linear maps induced by projections We define injective `ℤ`-linear maps between modules of the form `LocallyConstant C ℤ` induced by precomposition with the projections defined in the section `Projections`. ### Main definitions * `πs` and `πs'` are the `ℤ`-linear maps corresponding to `ProjRestrict` and `ProjRestricts`  respectively. ### Main result * We prove that `πs` and `πs'` interact well with `Products.eval` and the main application is the theorem `isGood_mono` which says that the property `isGood` is "monotone" on ordinals. -/ theorem contained_eq_proj (o : Ordinal) (h : contained C o) : C = π C (ord I · < o) := by have := proj_prop_eq_self C (ord I · < o) simp [π, Bool.not_eq_false] at this exact (this (fun i x hx ↦ h x hx i)).symm theorem isClosed_proj (o : Ordinal) (hC : IsClosed C) : IsClosed (π C (ord I · < o)) := (continuous_proj (ord I · < o)).isClosedMap C hC theorem contained_proj (o : Ordinal) : contained (π C (ord I · < o)) o := by intro x ⟨_, _, h⟩ j hj aesop (add simp Proj) /-- The `ℤ`-linear map induced by precomposition of the projection `C → π C (ord I · < o)`. -/ @[simps!] noncomputable def πs (o : Ordinal) : LocallyConstant (π C (ord I · < o)) ℤ →ₗ[ℤ] LocallyConstant C ℤ := LocallyConstant.comapₗ ℤ ⟨(ProjRestrict C (ord I · < o)), (continuous_projRestrict _ _)⟩ theorem coe_πs (o : Ordinal) (f : LocallyConstant (π C (ord I · < o)) ℤ) : πs C o f = f ∘ ProjRestrict C (ord I · < o) := by rfl theorem injective_πs (o : Ordinal) : Function.Injective (πs C o) := LocallyConstant.comap_injective ⟨_, (continuous_projRestrict _ _)⟩ (Set.surjective_mapsTo_image_restrict _ _) /-- The `ℤ`-linear map induced by precomposition of the projection `π C (ord I · < o₂) → π C (ord I · < o₁)` for `o₁ ≤ o₂`. -/ @[simps!] noncomputable def πs' {o₁ o₂ : Ordinal} (h : o₁ ≤ o₂) : LocallyConstant (π C (ord I · < o₁)) ℤ →ₗ[ℤ] LocallyConstant (π C (ord I · < o₂)) ℤ := LocallyConstant.comapₗ ℤ ⟨(ProjRestricts C (fun _ hh ↦ lt_of_lt_of_le hh h)), (continuous_projRestricts _ _)⟩ theorem coe_πs' {o₁ o₂ : Ordinal} (h : o₁ ≤ o₂) (f : LocallyConstant (π C (ord I · < o₁)) ℤ) : (πs' C h f).toFun = f.toFun ∘ (ProjRestricts C (fun _ hh ↦ lt_of_lt_of_le hh h)) := by rfl theorem injective_πs' {o₁ o₂ : Ordinal} (h : o₁ ≤ o₂) : Function.Injective (πs' C h) := LocallyConstant.comap_injective ⟨_, (continuous_projRestricts _ _)⟩ (surjective_projRestricts _ fun _ hi ↦ lt_of_lt_of_le hi h) namespace Products theorem lt_ord_of_lt {l m : Products I} {o : Ordinal} (h₁ : m < l) (h₂ : ∀ i ∈ l.val, ord I i < o) : ∀ i ∈ m.val, ord I i < o := List.Sorted.lt_ord_of_lt (List.chain'_iff_pairwise.mp l.2) (List.chain'_iff_pairwise.mp m.2) h₁ h₂ theorem eval_πs {l : Products I} {o : Ordinal} (hlt : ∀ i ∈ l.val, ord I i < o) : πs C o (l.eval (π C (ord I · < o))) = l.eval C := by simpa only [← LocallyConstant.coe_inj] using evalFacProp C (ord I · < o) hlt theorem eval_πs' {l : Products I} {o₁ o₂ : Ordinal} (h : o₁ ≤ o₂) (hlt : ∀ i ∈ l.val, ord I i < o₁) : πs' C h (l.eval (π C (ord I · < o₁))) = l.eval (π C (ord I · < o₂)) := by rw [← LocallyConstant.coe_inj, ← LocallyConstant.toFun_eq_coe] exact evalFacProps C (fun (i : I) ↦ ord I i < o₁) (fun (i : I) ↦ ord I i < o₂) hlt (fun _ hh ↦ lt_of_lt_of_le hh h) theorem eval_πs_image {l : Products I} {o : Ordinal} (hl : ∀ i ∈ l.val, ord I i < o) : eval C '' { m | m < l } = (πs C o) '' (eval (π C (ord I · < o)) '' { m | m < l }) := by ext f simp only [Set.mem_image, Set.mem_setOf_eq, exists_exists_and_eq_and] apply exists_congr; intro m apply and_congr_right; intro hm rw [eval_πs C (lt_ord_of_lt hm hl)] theorem eval_πs_image' {l : Products I} {o₁ o₂ : Ordinal} (h : o₁ ≤ o₂) (hl : ∀ i ∈ l.val, ord I i < o₁) : eval (π C (ord I · < o₂)) '' { m | m < l } = (πs' C h) '' (eval (π C (ord I · < o₁)) '' { m | m < l }) := by ext f simp only [Set.mem_image, Set.mem_setOf_eq, exists_exists_and_eq_and] apply exists_congr; intro m apply and_congr_right; intro hm rw [eval_πs' C h (lt_ord_of_lt hm hl)] theorem head_lt_ord_of_isGood [Inhabited I] {l : Products I} {o : Ordinal} (h : l.isGood (π C (ord I · < o))) (hn : l.val ≠ []) : ord I (l.val.head!) < o := prop_of_isGood C (ord I · < o) h l.val.head! (List.head!_mem_self hn) /-- If `l` is good w.r.t. `π C (ord I · < o₁)` and `o₁ ≤ o₂`, then it is good w.r.t. `π C (ord I · < o₂)` -/ theorem isGood_mono {l : Products I} {o₁ o₂ : Ordinal} (h : o₁ ≤ o₂) (hl : l.isGood (π C (ord I · < o₁))) : l.isGood (π C (ord I · < o₂)) := by intro hl' apply hl rwa [eval_πs_image' C h (prop_of_isGood C _ hl), ← eval_πs' C h (prop_of_isGood C _ hl), Submodule.apply_mem_span_image_iff_mem_span (injective_πs' C h)] at hl' end Products end Maps section Limit /-! ## The limit case of the induction We relate linear independence in `LocallyConstant (π C (ord I · < o')) ℤ` with linear independence in `LocallyConstant C ℤ`, where `contained C o` and `o' < o`. When `o` is a limit ordinal, we prove that the good products in `LocallyConstant C ℤ` are linearly independent if and only if a certain directed union is linearly independent. Each term in this directed union is in bijection with the good products w.r.t. `π C (ord I · < o')` for an ordinal `o' < o`, and these are linearly independent by the inductive hypothesis. ### Main definitions * `GoodProducts.smaller` is the image of good products coming from a smaller ordinal. * `GoodProducts.range_equiv`: The image of the `GoodProducts` in `C` is equivalent to the union of `smaller C o'` over all ordinals `o' < o`. ### Main results * `Products.limitOrdinal`: for `o` a limit ordinal such that `contained C o`, a product `l` is good w.r.t. `C` iff it there exists an ordinal `o' < o` such that `l` is good w.r.t. `π C (ord I · < o')`. * `GoodProducts.linearIndependent_iff_union_smaller` is the result mentioned above, that the good products are linearly independent iff a directed union is. -/ namespace GoodProducts /-- The image of the `GoodProducts` for `π C (ord I · < o)` in `LocallyConstant C ℤ`. The name `smaller` refers to the setting in which we will use this, when we are mapping in `GoodProducts` from a smaller set, i.e. when `o` is a smaller ordinal than the one `C` is "contained" in. -/ def smaller (o : Ordinal) : Set (LocallyConstant C ℤ) := (πs C o) '' (range (π C (ord I · < o))) /-- The map from the image of the `GoodProducts` in `LocallyConstant (π C (ord I · < o)) ℤ` to `smaller C o` -/ noncomputable def range_equiv_smaller_toFun (o : Ordinal) (x : range (π C (ord I · < o))) : smaller C o := ⟨πs C o ↑x, x.val, x.property, rfl⟩ theorem range_equiv_smaller_toFun_bijective (o : Ordinal) : Function.Bijective (range_equiv_smaller_toFun C o) := by dsimp (config := { unfoldPartialApp := true }) [range_equiv_smaller_toFun] refine ⟨fun a b hab ↦ ?_, fun ⟨a, b, hb⟩ ↦ ?_⟩ · ext1 simp only [Subtype.mk.injEq] at hab exact injective_πs C o hab · use ⟨b, hb.1⟩ simpa only [Subtype.mk.injEq] using hb.2 /-- The equivalence from the image of the `GoodProducts` in `LocallyConstant (π C (ord I · < o)) ℤ` to `smaller C o` -/ noncomputable def range_equiv_smaller (o : Ordinal) : range (π C (ord I · < o)) ≃ smaller C o := Equiv.ofBijective (range_equiv_smaller_toFun C o) (range_equiv_smaller_toFun_bijective C o) theorem smaller_factorization (o : Ordinal) : (fun (p : smaller C o) ↦ p.1) ∘ (range_equiv_smaller C o).toFun = (πs C o) ∘ (fun (p : range (π C (ord I · < o))) ↦ p.1) := by rfl theorem linearIndependent_iff_smaller (o : Ordinal) : LinearIndependent ℤ (GoodProducts.eval (π C (ord I · < o))) ↔ LinearIndependent ℤ (fun (p : smaller C o) ↦ p.1) := by rw [GoodProducts.linearIndependent_iff_range, ← LinearMap.linearIndependent_iff (πs C o) (LinearMap.ker_eq_bot_of_injective (injective_πs _ _)), ← smaller_factorization C o] exact linearIndependent_equiv _ theorem smaller_mono {o₁ o₂ : Ordinal} (h : o₁ ≤ o₂) : smaller C o₁ ⊆ smaller C o₂ := by rintro f ⟨g, hg, rfl⟩ simp only [smaller, Set.mem_image] use πs' C h g obtain ⟨⟨l, gl⟩, rfl⟩ := hg refine ⟨?_, ?_⟩ · use ⟨l, Products.isGood_mono C h gl⟩ ext x rw [eval, ← Products.eval_πs' _ h (Products.prop_of_isGood C _ gl), eval] · rw [← LocallyConstant.coe_inj, coe_πs C o₂, ← LocallyConstant.toFun_eq_coe, coe_πs', Function.comp.assoc, projRestricts_comp_projRestrict C _, coe_πs] rfl end GoodProducts variable {o : Ordinal} (ho : o.IsLimit) (hsC : contained C o) theorem Products.limitOrdinal (l : Products I) : l.isGood (π C (ord I · < o)) ↔ ∃ (o' : Ordinal), o' < o ∧ l.isGood (π C (ord I · < o')) := by refine ⟨fun h ↦ ?_, fun ⟨o', ⟨ho', hl⟩⟩ ↦ isGood_mono C (le_of_lt ho') hl⟩ use Finset.sup l.val.toFinset (fun a ↦ Order.succ (ord I a)) have ha : ⊥ < o := by rw [Ordinal.bot_eq_zero, Ordinal.pos_iff_ne_zero]; exact ho.1 have hslt : Finset.sup l.val.toFinset (fun a ↦ Order.succ (ord I a)) < o := by simp only [Finset.sup_lt_iff ha, List.mem_toFinset] exact fun b hb ↦ ho.2 _ (prop_of_isGood C (ord I · < o) h b hb) refine ⟨hslt, fun he ↦ h ?_⟩ have hlt : ∀ i ∈ l.val, ord I i < Finset.sup l.val.toFinset (fun a ↦ Order.succ (ord I a)) := by intro i hi simp only [Finset.lt_sup_iff, List.mem_toFinset, Order.lt_succ_iff] exact ⟨i, hi, le_rfl⟩ rwa [eval_πs_image' C (le_of_lt hslt) hlt, ← eval_πs' C (le_of_lt hslt) hlt, Submodule.apply_mem_span_image_iff_mem_span (injective_πs' C _)] theorem GoodProducts.union : range C = ⋃ (e : {o' // o' < o}), (smaller C e.val) := by ext p simp only [smaller, range, Set.mem_iUnion, Set.mem_image, Set.mem_range, Subtype.exists] refine ⟨fun hp ↦ ?_, fun hp ↦ ?_⟩ · obtain ⟨l, hl, rfl⟩ := hp rw [contained_eq_proj C o hsC, Products.limitOrdinal C ho] at hl obtain ⟨o', ho'⟩ := hl refine ⟨o', ho'.1, eval (π C (ord I · < o')) ⟨l, ho'.2⟩, ⟨l, ho'.2, rfl⟩, ?_⟩ exact Products.eval_πs C (Products.prop_of_isGood C _ ho'.2) · obtain ⟨o', h, _, ⟨l, hl, rfl⟩, rfl⟩ := hp refine ⟨l, ?_, (Products.eval_πs C (Products.prop_of_isGood C _ hl)).symm⟩ rw [contained_eq_proj C o hsC] exact Products.isGood_mono C (le_of_lt h) hl /-- The image of the `GoodProducts` in `C` is equivalent to the union of `smaller C o'` over all ordinals `o' < o`. -/ def GoodProducts.range_equiv : range C ≃ ⋃ (e : {o' // o' < o}), (smaller C e.val) := Equiv.Set.ofEq (union C ho hsC) theorem GoodProducts.range_equiv_factorization : (fun (p : ⋃ (e : {o' // o' < o}), (smaller C e.val)) ↦ p.1) ∘ (range_equiv C ho hsC).toFun = (fun (p : range C) ↦ (p.1 : LocallyConstant C ℤ)) := rfl theorem GoodProducts.linearIndependent_iff_union_smaller {o : Ordinal} (ho : o.IsLimit) (hsC : contained C o) : LinearIndependent ℤ (GoodProducts.eval C) ↔ LinearIndependent ℤ (fun (p : ⋃ (e : {o' // o' < o}), (smaller C e.val)) ↦ p.1) := by rw [GoodProducts.linearIndependent_iff_range, ← range_equiv_factorization C ho hsC] exact linearIndependent_equiv (range_equiv C ho hsC) end Limit section Successor /-! ## The successor case in the induction Here we assume that `o` is an ordinal such that `contained C (o+1)` and `o < I`. The element in `I` corresponding to `o` is called `term I ho`, but in this informal docstring we refer to it simply as `o`. This section follows the proof in [scholze2019condensed] quite closely. A translation of the notation there is as follows: ``` [scholze2019condensed] | This file `S₀` |`C0` `S₁` |`C1` `\overline{S}` |`π C (ord I · < o) `\overline{S}'` |`C'` The left map in the exact sequence |`πs` The right map in the exact sequence |`Linear_CC'` ``` When comparing the proof of the successor case in Theorem 5.4 in [scholze2019condensed] with this proof, one should read the phrase "is a basis" as "is linearly independent". Also, the short exact sequence in [scholze2019condensed] is only proved to be left exact here (indeed, that is enough since we are only proving linear independence). This section is split into two sections. The first one, `ExactSequence` defines the left exact sequence mentioned in the previous paragraph (see `succ_mono` and `succ_exact`). It corresponds to the penultimate paragraph of the proof in [scholze2019condensed]. The second one, `GoodProducts` corresponds to the last paragraph in the proof in [scholze2019condensed]. ### Main definitions The main definitions in the section `ExactSequence` are all just notation explained in the table above. The main definitions in the section `GoodProducts` are as follows: * `MaxProducts`: the set of good products that contain the ordinal `o` (since we have `contained C (o+1)`, these all start with `o`). * `GoodProducts.sum_equiv`: the equivalence between `GoodProducts C` and the disjoint union of `MaxProducts C` and `GoodProducts (π C (ord I · < o))`. ### Main results * The main results in the section `ExactSequence` are `succ_mono` and `succ_exact` which together say that the secuence given by `πs` and `Linear_CC'` is left exact: ``` f g 0 --→ LocallyConstant (π C (ord I · < o)) ℤ --→ LocallyConstant C ℤ --→ LocallyConstant C' ℤ ``` where `f` is `πs` and `g` is `Linear_CC'`. The main results in the section `GoodProducts` are as follows: * `Products.max_eq_eval` says that the linear map on the right in the exact sequence, i.e. `Linear_CC'`, takes the evaluation of a term of `MaxProducts` to the evaluation of the corresponding list with the leading `o` removed. * `GoodProducts.maxTail_isGood` says that removing the leading `o` from a term of `MaxProducts C`  yields a list which `isGood` with respect to `C'`. -/ variable {o : Ordinal} (hC : IsClosed C) (hsC : contained C (Order.succ o)) (ho : o < Ordinal.type (·<· : I → I → Prop)) section ExactSequence /-- The subset of `C` consisting of those elements whose `o`-th entry is `false`. -/ def C0 := C ∩ {f | f (term I ho) = false} /-- The subset of `C` consisting of those elements whose `o`-th entry is `true`. -/ def C1 := C ∩ {f | f (term I ho) = true} theorem isClosed_C0 : IsClosed (C0 C ho) := by refine hC.inter ?_ have h : Continuous (fun (f : I → Bool) ↦ f (term I ho)) := continuous_apply (term I ho) exact IsClosed.preimage h (t := {false}) (isClosed_discrete _) theorem isClosed_C1 : IsClosed (C1 C ho) := by refine hC.inter ?_ have h : Continuous (fun (f : I → Bool) ↦ f (term I ho)) := continuous_apply (term I ho) exact IsClosed.preimage h (t := {true}) (isClosed_discrete _) theorem contained_C1 : contained (π (C1 C ho) (ord I · < o)) o := contained_proj _ _ theorem union_C0C1_eq : (C0 C ho) ∪ (C1 C ho) = C := by ext x simp only [C0, C1, Set.mem_union, Set.mem_inter_iff, Set.mem_setOf_eq, ← and_or_left, and_iff_left_iff_imp, Bool.dichotomy (x (term I ho)), implies_true] /-- The intersection of `C0` and the projection of `C1`. We will apply the inductive hypothesis to this set. -/ def C' := C0 C ho ∩ π (C1 C ho) (ord I · < o) theorem isClosed_C' : IsClosed (C' C ho) := IsClosed.inter (isClosed_C0 _ hC _) (isClosed_proj _ _ (isClosed_C1 _ hC _)) theorem contained_C' : contained (C' C ho) o := fun f hf i hi ↦ contained_C1 C ho f hf.2 i hi variable (o) /-- Swapping the `o`-th coordinate to `true`. -/ noncomputable def SwapTrue : (I → Bool) → I → Bool := fun f i ↦ if ord I i = o then true else f i theorem continuous_swapTrue : Continuous (SwapTrue o : (I → Bool) → I → Bool) := by dsimp (config := { unfoldPartialApp := true }) [SwapTrue] apply continuous_pi intro i apply Continuous.comp' · apply continuous_bot · apply continuous_apply variable {o} theorem swapTrue_mem_C1 (f : π (C1 C ho) (ord I · < o)) : SwapTrue o f.val ∈ C1 C ho := by obtain ⟨f, g, hg, rfl⟩ := f convert hg dsimp (config := { unfoldPartialApp := true }) [SwapTrue] ext i split_ifs with h · rw [ord_term ho] at h simpa only [← h] using hg.2.symm · simp only [Proj, ite_eq_left_iff, not_lt, @eq_comm _ false, ← Bool.not_eq_true] specialize hsC g hg.1 i intro h' contrapose! hsC exact ⟨hsC, Order.succ_le_of_lt (h'.lt_of_ne' h)⟩ /-- The first way to map `C'` into `C`. -/ def CC'₀ : C' C ho → C := fun g ↦ ⟨g.val,g.prop.1.1⟩ /-- The second way to map `C'` into `C`. -/ noncomputable def CC'₁ : C' C ho → C := fun g ↦ ⟨SwapTrue o g.val, (swapTrue_mem_C1 C hsC ho ⟨g.val,g.prop.2⟩).1⟩ theorem continuous_CC'₀ : Continuous (CC'₀ C ho) := Continuous.subtype_mk continuous_subtype_val _ theorem continuous_CC'₁ : Continuous (CC'₁ C hsC ho) := Continuous.subtype_mk (Continuous.comp (continuous_swapTrue o) continuous_subtype_val) _ /-- The `ℤ`-linear map induced by precomposing with `CC'₀` -/ noncomputable def Linear_CC'₀ : LocallyConstant C ℤ →ₗ[ℤ] LocallyConstant (C' C ho) ℤ := LocallyConstant.comapₗ ℤ ⟨(CC'₀ C ho), (continuous_CC'₀ C ho)⟩ /-- The `ℤ`-linear map induced by precomposing with `CC'₁` -/ noncomputable def Linear_CC'₁ : LocallyConstant C ℤ →ₗ[ℤ] LocallyConstant (C' C ho) ℤ := LocallyConstant.comapₗ ℤ ⟨(CC'₁ C hsC ho), (continuous_CC'₁ C hsC ho)⟩ /-- The difference between `Linear_CC'₁` and `Linear_CC'₀`. -/ noncomputable def Linear_CC' : LocallyConstant C ℤ →ₗ[ℤ] LocallyConstant (C' C ho) ℤ := Linear_CC'₁ C hsC ho - Linear_CC'₀ C ho theorem CC_comp_zero : ∀ y, (Linear_CC' C hsC ho) ((πs C o) y) = 0 := by intro y ext x dsimp [Linear_CC', Linear_CC'₀, Linear_CC'₁, LocallyConstant.sub_apply] simp only [continuous_CC'₀, continuous_CC'₁, LocallyConstant.coe_comap, continuous_projRestrict, Function.comp_apply, sub_eq_zero] congr 1 ext i dsimp [CC'₀, CC'₁, ProjRestrict, Proj] apply if_ctx_congr Iff.rfl _ (fun _ ↦ rfl) simp only [SwapTrue, ite_eq_right_iff] intro h₁ h₂ exact (h₁.ne h₂).elim theorem C0_projOrd {x : I → Bool} (hx : x ∈ C0 C ho) : Proj (ord I · < o) x = x := by ext i simp only [Proj, Set.mem_setOf, ite_eq_left_iff, not_lt] intro hi rw [le_iff_lt_or_eq] at hi cases' hi with hi hi · specialize hsC x hx.1 i rw [← not_imp_not] at hsC simp only [not_lt, Bool.not_eq_true, Order.succ_le_iff] at hsC exact (hsC hi).symm · simp only [C0, Set.mem_inter_iff, Set.mem_setOf_eq] at hx rw [eq_comm, ord_term ho] at hi rw [← hx.2, hi] theorem C1_projOrd {x : I → Bool} (hx : x ∈ C1 C ho) : SwapTrue o (Proj (ord I · < o) x) = x := by ext i dsimp [SwapTrue, Proj] split_ifs with hi h · rw [ord_term ho] at hi rw [← hx.2, hi] · rfl · simp only [not_lt] at h have h' : o < ord I i := lt_of_le_of_ne h (Ne.symm hi) specialize hsC x hx.1 i rw [← not_imp_not] at hsC simp only [not_lt, Bool.not_eq_true, Order.succ_le_iff] at hsC exact (hsC h').symm open scoped Classical in theorem CC_exact {f : LocallyConstant C ℤ} (hf : Linear_CC' C hsC ho f = 0) : ∃ y, πs C o y = f := by dsimp [Linear_CC', Linear_CC'₀, Linear_CC'₁] at hf simp only [sub_eq_zero, ← LocallyConstant.coe_inj, LocallyConstant.coe_comap, continuous_CC'₀, continuous_CC'₁] at hf let C₀C : C0 C ho → C := fun x ↦ ⟨x.val, x.prop.1⟩ have h₀ : Continuous C₀C := Continuous.subtype_mk continuous_induced_dom _ let C₁C : π (C1 C ho) (ord I · < o) → C := fun x ↦ ⟨SwapTrue o x.val, (swapTrue_mem_C1 C hsC ho x).1⟩ have h₁ : Continuous C₁C := Continuous.subtype_mk ((continuous_swapTrue o).comp continuous_subtype_val) _ refine ⟨LocallyConstant.piecewise' ?_ (isClosed_C0 C hC ho) (isClosed_proj _ o (isClosed_C1 C hC ho)) (f.comap ⟨C₀C, h₀⟩) (f.comap ⟨C₁C, h₁⟩) ?_, ?_⟩ · rintro _ ⟨y, hyC, rfl⟩ simp only [Set.mem_union, Set.mem_setOf_eq, Set.mem_univ, iff_true] rw [← union_C0C1_eq C ho] at hyC refine hyC.imp (fun hyC ↦ ?_) (fun hyC ↦ ⟨y, hyC, rfl⟩) rwa [C0_projOrd C hsC ho hyC] · intro x hx simpa only [h₀, h₁, LocallyConstant.coe_comap] using (congrFun hf ⟨x, hx⟩).symm · ext ⟨x, hx⟩ rw [← union_C0C1_eq C ho] at hx cases' hx with hx₀ hx₁ · have hx₀' : ProjRestrict C (ord I · < o) ⟨x, hx⟩ = x := by simpa only [ProjRestrict, Set.MapsTo.val_restrict_apply] using C0_projOrd C hsC ho hx₀ simp only [πs_apply_apply, hx₀', hx₀, LocallyConstant.piecewise'_apply_left, LocallyConstant.coe_comap, ContinuousMap.coe_mk, Function.comp_apply] · have hx₁' : (ProjRestrict C (ord I · < o) ⟨x, hx⟩).val ∈ π (C1 C ho) (ord I · < o) := by simpa only [ProjRestrict, Set.MapsTo.val_restrict_apply] using ⟨x, hx₁, rfl⟩ simp only [C₁C, πs_apply_apply, continuous_projRestrict, LocallyConstant.coe_comap, Function.comp_apply, hx₁', LocallyConstant.piecewise'_apply_right, h₁] congr simp only [ContinuousMap.coe_mk, Subtype.mk.injEq] exact C1_projOrd C hsC ho hx₁ variable (o) in theorem succ_mono : CategoryTheory.Mono (ModuleCat.ofHom (πs C o)) := by rw [ModuleCat.mono_iff_injective] exact injective_πs _ _ theorem succ_exact : (ShortComplex.mk (ModuleCat.ofHom (πs C o)) (ModuleCat.ofHom (Linear_CC' C hsC ho)) (by ext; apply CC_comp_zero)).Exact := by rw [ShortComplex.moduleCat_exact_iff] intro f exact CC_exact C hC hsC ho end ExactSequence section GoodProducts namespace GoodProducts /-- The `GoodProducts` in `C` that contain `o` (they necessarily start with `o`, see `GoodProducts.head!_eq_o_of_maxProducts`) -/ def MaxProducts : Set (Products I) := {l | l.isGood C ∧ term I ho ∈ l.val} theorem union_succ : GoodProducts C = GoodProducts (π C (ord I · < o)) ∪ MaxProducts C ho := by ext l simp only [GoodProducts, MaxProducts, Set.mem_union, Set.mem_setOf_eq] refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩ · by_cases hh : term I ho ∈ l.val · exact Or.inr ⟨h, hh⟩ · left intro he apply h have h' := Products.prop_of_isGood_of_contained C _ h hsC simp only [Order.lt_succ_iff] at h' simp only [not_imp_not] at hh have hh' : ∀ a ∈ l.val, ord I a < o := by intro a ha refine (h' a ha).lt_of_ne ?_ rw [ne_eq, ord_term ho a] rintro rfl contradiction rwa [Products.eval_πs_image C hh', ← Products.eval_πs C hh', Submodule.apply_mem_span_image_iff_mem_span (injective_πs _ _)] · refine h.elim (fun hh ↦ ?_) And.left have := Products.isGood_mono C (Order.lt_succ o).le hh rwa [contained_eq_proj C (Order.succ o) hsC] /-- The inclusion map from the sum of `GoodProducts (π C (ord I · < o))` and `(MaxProducts C ho)` to `Products I`. -/ def sum_to : (GoodProducts (π C (ord I · < o))) ⊕ (MaxProducts C ho) → Products I := Sum.elim Subtype.val Subtype.val theorem injective_sum_to : Function.Injective (sum_to C ho) := by refine Function.Injective.sum_elim Subtype.val_injective Subtype.val_injective (fun ⟨a,ha⟩ ⟨b,hb⟩ ↦ (fun (hab : a = b) ↦ ?_)) rw [← hab] at hb have ha' := Products.prop_of_isGood C _ ha (term I ho) hb.2 simp only [ord_term_aux, lt_self_iff_false] at ha' theorem sum_to_range : Set.range (sum_to C ho) = GoodProducts (π C (ord I · < o)) ∪ MaxProducts C ho := by have h : Set.range (sum_to C ho) = _ ∪ _ := Set.Sum.elim_range _ _; rw [h]; congr<;> ext l · exact ⟨fun ⟨m,hm⟩ ↦ by rw [← hm]; exact m.prop, fun hl ↦ ⟨⟨l,hl⟩, rfl⟩⟩ · exact ⟨fun ⟨m,hm⟩ ↦ by rw [← hm]; exact m.prop, fun hl ↦ ⟨⟨l,hl⟩, rfl⟩⟩ /-- The equivalence from the sum of `GoodProducts (π C (ord I · < o))` and `(MaxProducts C ho)` to `GoodProducts C`. -/ noncomputable def sum_equiv : GoodProducts (π C (ord I · < o)) ⊕ (MaxProducts C ho) ≃ GoodProducts C := calc _ ≃ Set.range (sum_to C ho) := Equiv.ofInjective (sum_to C ho) (injective_sum_to C ho) _ ≃ _ := Equiv.Set.ofEq <| by rw [sum_to_range C ho, union_succ C hsC ho] theorem sum_equiv_comp_eval_eq_elim : eval C ∘ (sum_equiv C hsC ho).toFun = (Sum.elim (fun (l : GoodProducts (π C (ord I · < o))) ↦ Products.eval C l.1) (fun (l : MaxProducts C ho) ↦ Products.eval C l.1)) := by ext ⟨_,_⟩ <;> [rfl; rfl] /-- Let `N := LocallyConstant (π C (ord I · < o)) ℤ` `M := LocallyConstant C ℤ` `P := LocallyConstant (C' C ho) ℤ` `ι := GoodProducts (π C (ord I · < o))` `ι' := GoodProducts (C' C ho')` `v : ι → N := GoodProducts.eval (π C (ord I · < o))` Then `SumEval C ho` is the map `u` in the diagram below. It is linearly independent if and only if `GoodProducts.eval C` is, see `linearIndependent_iff_sum`. The top row is the exact sequence given by `succ_exact` and `succ_mono`. The left square commutes by `GoodProducts.square_commutes`. ``` 0 --→ N --→ M --→ P ↑ ↑ ↑ v| u| | ι → ι ⊕ ι' ← ι' ``` -/ def SumEval : GoodProducts (π C (ord I · < o)) ⊕ MaxProducts C ho → LocallyConstant C ℤ := Sum.elim (fun l ↦ l.1.eval C) (fun l ↦ l.1.eval C) theorem linearIndependent_iff_sum : LinearIndependent ℤ (eval C) ↔ LinearIndependent ℤ (SumEval C ho) := by rw [← linearIndependent_equiv (sum_equiv C hsC ho), SumEval, ← sum_equiv_comp_eval_eq_elim C hsC ho] exact Iff.rfl theorem span_sum : Set.range (eval C) = Set.range (Sum.elim (fun (l : GoodProducts (π C (ord I · < o))) ↦ Products.eval C l.1) (fun (l : MaxProducts C ho) ↦ Products.eval C l.1)) := by rw [← sum_equiv_comp_eval_eq_elim C hsC ho, Equiv.toFun_as_coe, EquivLike.range_comp (e := sum_equiv C hsC ho)] theorem square_commutes : SumEval C ho ∘ Sum.inl = ModuleCat.ofHom (πs C o) ∘ eval (π C (ord I · < o)) := by ext l dsimp [SumEval] rw [← Products.eval_πs C (Products.prop_of_isGood _ _ l.prop)] rfl end GoodProducts theorem swapTrue_eq_true (x : I → Bool) : SwapTrue o x (term I ho) = true := by simp only [SwapTrue, ord_term_aux, ite_true] theorem mem_C'_eq_false : ∀ x, x ∈ C' C ho → x (term I ho) = false := by rintro x ⟨_, y, _, rfl⟩ simp only [Proj, ord_term_aux, lt_self_iff_false, ite_false] /-- `List.tail` as a `Products`. -/ def Products.Tail (l : Products I) : Products I := ⟨l.val.tail, List.Chain'.tail l.prop⟩ theorem Products.max_eq_o_cons_tail [Inhabited I] (l : Products I) (hl : l.val ≠ []) (hlh : l.val.head! = term I ho) : l.val = term I ho :: l.Tail.val := by rw [← List.cons_head!_tail hl, hlh] rfl theorem Products.max_eq_o_cons_tail' [Inhabited I] (l : Products I) (hl : l.val ≠ []) (hlh : l.val.head! = term I ho) (hlc : List.Chain' (·>·) (term I ho :: l.Tail.val)) : l = ⟨term I ho :: l.Tail.val, hlc⟩ := by simp_rw [← max_eq_o_cons_tail ho l hl hlh] rfl theorem GoodProducts.head!_eq_o_of_maxProducts [Inhabited I] (l : ↑(MaxProducts C ho)) : l.val.val.head! = term I ho := by rw [eq_comm, ← ord_term ho] have hm := l.prop.2 have := Products.prop_of_isGood_of_contained C _ l.prop.1 hsC l.val.val.head! (List.head!_mem_self (List.ne_nil_of_mem hm)) simp only [Order.lt_succ_iff] at this refine eq_of_le_of_not_lt this (not_lt.mpr ?_) have h : ord I (term I ho) ≤ ord I l.val.val.head! := by simp only [← ord_term_aux, ord, Ordinal.typein_le_typein, not_lt] exact Products.rel_head!_of_mem hm rwa [ord_term_aux] at h theorem GoodProducts.max_eq_o_cons_tail (l : MaxProducts C ho) : l.val.val = (term I ho) :: l.val.Tail.val := have : Inhabited I := ⟨term I ho⟩ Products.max_eq_o_cons_tail ho l.val (List.ne_nil_of_mem l.prop.2) (head!_eq_o_of_maxProducts _ hsC ho l) theorem Products.evalCons {l : List I} {a : I} (hla : (a::l).Chain' (·>·)) : Products.eval C ⟨a::l,hla⟩ = (e C a) * Products.eval C ⟨l,List.Chain'.sublist hla (List.tail_sublist (a::l))⟩ := by simp only [eval.eq_1, List.map, List.prod_cons]
Mathlib/Topology/Category/Profinite/Nobeling.lean
1,513
1,540
theorem Products.max_eq_eval [Inhabited I] (l : Products I) (hl : l.val ≠ []) (hlh : l.val.head! = term I ho) : Linear_CC' C hsC ho (l.eval C) = l.Tail.eval (C' C ho) := by
have hlc : ((term I ho) :: l.Tail.val).Chain' (·>·) := by rw [← max_eq_o_cons_tail ho l hl hlh]; exact l.prop rw [max_eq_o_cons_tail' ho l hl hlh hlc, Products.evalCons] ext x simp only [Linear_CC', Linear_CC'₁, LocallyConstant.comapₗ, Linear_CC'₀, Subtype.coe_eta, LinearMap.sub_apply, LinearMap.coe_mk, AddHom.coe_mk, LocallyConstant.sub_apply, LocallyConstant.coe_comap, LocallyConstant.coe_mul, ContinuousMap.coe_mk, Function.comp_apply, Pi.mul_apply] rw [CC'₁, CC'₀, Products.eval_eq, Products.eval_eq, Products.eval_eq] simp only [mul_ite, mul_one, mul_zero] have hi' : ∀ i, i ∈ l.Tail.val → (x.val i = SwapTrue o x.val i) := by intro i hi simp only [SwapTrue, @eq_comm _ (x.val i), ite_eq_right_iff, ord_term ho] rintro rfl exact ((List.Chain.rel hlc hi).ne rfl).elim have H : (∀ i, i ∈ l.Tail.val → (x.val i = true)) = (∀ i, i ∈ l.Tail.val → (SwapTrue o x.val i = true)) := by apply forall_congr; intro i; apply forall_congr; intro hi; rw [hi' i hi] simp only [H] split_ifs with h₁ h₂ h₃ <;> try (dsimp [e]) · rw [if_pos (swapTrue_eq_true _ _), if_neg] · rfl · simp [mem_C'_eq_false C ho x x.prop, Bool.coe_false] · push_neg at h₂; obtain ⟨i, hi⟩ := h₂; exfalso; rw [hi' i hi.1] at hi; exact hi.2 (h₁ i hi.1) · push_neg at h₁; obtain ⟨i, hi⟩ := h₁; exfalso; rw [← hi' i hi.1] at hi; exact hi.2 (h₃ i hi.1)
/- Copyright (c) 2022 Jake Levinson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jake Levinson -/ import Mathlib.Order.UpperLower.Basic import Mathlib.Data.Finset.Preimage #align_import combinatorics.young.young_diagram from "leanprover-community/mathlib"@"59694bd07f0a39c5beccba34bd9f413a160782bf" /-! # Young diagrams A Young diagram is a finite set of up-left justified boxes: ```text □□□□□ □□□ □□□ □ ``` This Young diagram corresponds to the [5, 3, 3, 1] partition of 12. We represent it as a lower set in `ℕ × ℕ` in the product partial order. We write `(i, j) ∈ μ` to say that `(i, j)` (in matrix coordinates) is in the Young diagram `μ`. ## Main definitions - `YoungDiagram` : Young diagrams - `YoungDiagram.card` : the number of cells in a Young diagram (its *cardinality*) - `YoungDiagram.instDistribLatticeYoungDiagram` : a distributive lattice instance for Young diagrams ordered by containment, with `(⊥ : YoungDiagram)` the empty diagram. - `YoungDiagram.row` and `YoungDiagram.rowLen`: rows of a Young diagram and their lengths - `YoungDiagram.col` and `YoungDiagram.colLen`: columns of a Young diagram and their lengths ## Notation In "English notation", a Young diagram is drawn so that (i1, j1) ≤ (i2, j2) means (i1, j1) is weakly up-and-left of (i2, j2). This terminology is used below, e.g. in `YoungDiagram.up_left_mem`. ## Tags Young diagram ## References <https://en.wikipedia.org/wiki/Young_tableau> -/ open Function /-- A Young diagram is a finite collection of cells on the `ℕ × ℕ` grid such that whenever a cell is present, so are all the ones above and to the left of it. Like matrices, an `(i, j)` cell is a cell in row `i` and column `j`, where rows are enumerated downward and columns rightward. Young diagrams are modeled as finite sets in `ℕ × ℕ` that are lower sets with respect to the standard order on products. -/ @[ext] structure YoungDiagram where /-- A finite set which represents a finite collection of cells on the `ℕ × ℕ` grid. -/ cells : Finset (ℕ × ℕ) /-- Cells are up-left justified, witnessed by the fact that `cells` is a lower set in `ℕ × ℕ`. -/ isLowerSet : IsLowerSet (cells : Set (ℕ × ℕ)) #align young_diagram YoungDiagram namespace YoungDiagram instance : SetLike YoungDiagram (ℕ × ℕ) where -- Porting note (#11215): TODO: figure out how to do this correctly coe := fun y => y.cells coe_injective' μ ν h := by rwa [YoungDiagram.ext_iff, ← Finset.coe_inj] @[simp] theorem mem_cells {μ : YoungDiagram} (c : ℕ × ℕ) : c ∈ μ.cells ↔ c ∈ μ := Iff.rfl #align young_diagram.mem_cells YoungDiagram.mem_cells @[simp] theorem mem_mk (c : ℕ × ℕ) (cells) (isLowerSet) : c ∈ YoungDiagram.mk cells isLowerSet ↔ c ∈ cells := Iff.rfl #align young_diagram.mem_mk YoungDiagram.mem_mk instance decidableMem (μ : YoungDiagram) : DecidablePred (· ∈ μ) := inferInstanceAs (DecidablePred (· ∈ μ.cells)) #align young_diagram.decidable_mem YoungDiagram.decidableMem /-- In "English notation", a Young diagram is drawn so that (i1, j1) ≤ (i2, j2) means (i1, j1) is weakly up-and-left of (i2, j2). -/ theorem up_left_mem (μ : YoungDiagram) {i1 i2 j1 j2 : ℕ} (hi : i1 ≤ i2) (hj : j1 ≤ j2) (hcell : (i2, j2) ∈ μ) : (i1, j1) ∈ μ := μ.isLowerSet (Prod.mk_le_mk.mpr ⟨hi, hj⟩) hcell #align young_diagram.up_left_mem YoungDiagram.up_left_mem section DistribLattice @[simp] theorem cells_subset_iff {μ ν : YoungDiagram} : μ.cells ⊆ ν.cells ↔ μ ≤ ν := Iff.rfl #align young_diagram.cells_subset_iff YoungDiagram.cells_subset_iff @[simp] theorem cells_ssubset_iff {μ ν : YoungDiagram} : μ.cells ⊂ ν.cells ↔ μ < ν := Iff.rfl #align young_diagram.cells_ssubset_iff YoungDiagram.cells_ssubset_iff instance : Sup YoungDiagram where sup μ ν := { cells := μ.cells ∪ ν.cells isLowerSet := by rw [Finset.coe_union] exact μ.isLowerSet.union ν.isLowerSet } @[simp] theorem cells_sup (μ ν : YoungDiagram) : (μ ⊔ ν).cells = μ.cells ∪ ν.cells := rfl #align young_diagram.cells_sup YoungDiagram.cells_sup @[simp, norm_cast] theorem coe_sup (μ ν : YoungDiagram) : ↑(μ ⊔ ν) = (μ ∪ ν : Set (ℕ × ℕ)) := Finset.coe_union _ _ #align young_diagram.coe_sup YoungDiagram.coe_sup @[simp] theorem mem_sup {μ ν : YoungDiagram} {x : ℕ × ℕ} : x ∈ μ ⊔ ν ↔ x ∈ μ ∨ x ∈ ν := Finset.mem_union #align young_diagram.mem_sup YoungDiagram.mem_sup instance : Inf YoungDiagram where inf μ ν := { cells := μ.cells ∩ ν.cells isLowerSet := by rw [Finset.coe_inter] exact μ.isLowerSet.inter ν.isLowerSet } @[simp] theorem cells_inf (μ ν : YoungDiagram) : (μ ⊓ ν).cells = μ.cells ∩ ν.cells := rfl #align young_diagram.cells_inf YoungDiagram.cells_inf @[simp, norm_cast] theorem coe_inf (μ ν : YoungDiagram) : ↑(μ ⊓ ν) = (μ ∩ ν : Set (ℕ × ℕ)) := Finset.coe_inter _ _ #align young_diagram.coe_inf YoungDiagram.coe_inf @[simp] theorem mem_inf {μ ν : YoungDiagram} {x : ℕ × ℕ} : x ∈ μ ⊓ ν ↔ x ∈ μ ∧ x ∈ ν := Finset.mem_inter #align young_diagram.mem_inf YoungDiagram.mem_inf /-- The empty Young diagram is (⊥ : young_diagram). -/ instance : OrderBot YoungDiagram where bot := { cells := ∅ isLowerSet := by intros a b _ h simp only [Finset.coe_empty, Set.mem_empty_iff_false] simp only [Finset.coe_empty, Set.mem_empty_iff_false] at h } bot_le _ _ := by intro y simp only [mem_mk, Finset.not_mem_empty] at y @[simp] theorem cells_bot : (⊥ : YoungDiagram).cells = ∅ := rfl #align young_diagram.cells_bot YoungDiagram.cells_bot -- Porting note: removed `↑`, added `.cells` and changed proof -- @[simp] -- Porting note (#10618): simp can prove this @[norm_cast] theorem coe_bot : (⊥ : YoungDiagram).cells = (∅ : Set (ℕ × ℕ)) := by refine Set.eq_of_subset_of_subset ?_ ?_ · intros x h simp? [mem_mk, Finset.coe_empty, Set.mem_empty_iff_false] at h says simp only [cells_bot, Finset.coe_empty, Set.mem_empty_iff_false] at h · simp only [cells_bot, Finset.coe_empty, Set.empty_subset] #align young_diagram.coe_bot YoungDiagram.coe_bot @[simp] theorem not_mem_bot (x : ℕ × ℕ) : x ∉ (⊥ : YoungDiagram) := Finset.not_mem_empty x #align young_diagram.not_mem_bot YoungDiagram.not_mem_bot instance : Inhabited YoungDiagram := ⟨⊥⟩ instance : DistribLattice YoungDiagram := Function.Injective.distribLattice YoungDiagram.cells (fun μ ν h => by rwa [YoungDiagram.ext_iff]) (fun _ _ => rfl) fun _ _ => rfl end DistribLattice /-- Cardinality of a Young diagram -/ protected abbrev card (μ : YoungDiagram) : ℕ := μ.cells.card #align young_diagram.card YoungDiagram.card section Transpose /-- The `transpose` of a Young diagram is obtained by swapping i's with j's. -/ def transpose (μ : YoungDiagram) : YoungDiagram where cells := (Equiv.prodComm _ _).finsetCongr μ.cells isLowerSet _ _ h := by simp only [Finset.mem_coe, Equiv.finsetCongr_apply, Finset.mem_map_equiv] intro hcell apply μ.isLowerSet _ hcell simp [h] #align young_diagram.transpose YoungDiagram.transpose @[simp] theorem mem_transpose {μ : YoungDiagram} {c : ℕ × ℕ} : c ∈ μ.transpose ↔ c.swap ∈ μ := by simp [transpose] #align young_diagram.mem_transpose YoungDiagram.mem_transpose @[simp] theorem transpose_transpose (μ : YoungDiagram) : μ.transpose.transpose = μ := by ext x simp #align young_diagram.transpose_transpose YoungDiagram.transpose_transpose theorem transpose_eq_iff_eq_transpose {μ ν : YoungDiagram} : μ.transpose = ν ↔ μ = ν.transpose := by constructor <;> · rintro rfl simp #align young_diagram.transpose_eq_iff_eq_transpose YoungDiagram.transpose_eq_iff_eq_transpose @[simp] theorem transpose_eq_iff {μ ν : YoungDiagram} : μ.transpose = ν.transpose ↔ μ = ν := by rw [transpose_eq_iff_eq_transpose] simp #align young_diagram.transpose_eq_iff YoungDiagram.transpose_eq_iff -- This is effectively both directions of `transpose_le_iff` below. protected theorem le_of_transpose_le {μ ν : YoungDiagram} (h_le : μ.transpose ≤ ν) : μ ≤ ν.transpose := fun c hc => by simp only [mem_cells, mem_transpose] apply h_le simpa #align young_diagram.le_of_transpose_le YoungDiagram.le_of_transpose_le @[simp] theorem transpose_le_iff {μ ν : YoungDiagram} : μ.transpose ≤ ν.transpose ↔ μ ≤ ν := ⟨fun h => by convert YoungDiagram.le_of_transpose_le h simp, fun h => by rw [← transpose_transpose μ] at h exact YoungDiagram.le_of_transpose_le h ⟩ #align young_diagram.transpose_le_iff YoungDiagram.transpose_le_iff @[mono] protected theorem transpose_mono {μ ν : YoungDiagram} (h_le : μ ≤ ν) : μ.transpose ≤ ν.transpose := transpose_le_iff.mpr h_le #align young_diagram.transpose_mono YoungDiagram.transpose_mono /-- Transposing Young diagrams is an `OrderIso`. -/ @[simps] def transposeOrderIso : YoungDiagram ≃o YoungDiagram := ⟨⟨transpose, transpose, fun _ => by simp, fun _ => by simp⟩, by simp⟩ #align young_diagram.transpose_order_iso YoungDiagram.transposeOrderIso end Transpose section Rows /-! ### Rows and row lengths of Young diagrams. This section defines `μ.row` and `μ.rowLen`, with the following API: 1. `(i, j) ∈ μ ↔ j < μ.rowLen i` 2. `μ.row i = {i} ×ˢ (Finset.range (μ.rowLen i))` 3. `μ.rowLen i = (μ.row i).card` 4. `∀ {i1 i2}, i1 ≤ i2 → μ.rowLen i2 ≤ μ.rowLen i1` Note: #3 is not convenient for defining `μ.rowLen`; instead, `μ.rowLen` is defined as the smallest `j` such that `(i, j) ∉ μ`. -/ /-- The `i`-th row of a Young diagram consists of the cells whose first coordinate is `i`. -/ def row (μ : YoungDiagram) (i : ℕ) : Finset (ℕ × ℕ) := μ.cells.filter fun c => c.fst = i #align young_diagram.row YoungDiagram.row theorem mem_row_iff {μ : YoungDiagram} {i : ℕ} {c : ℕ × ℕ} : c ∈ μ.row i ↔ c ∈ μ ∧ c.fst = i := by simp [row] #align young_diagram.mem_row_iff YoungDiagram.mem_row_iff theorem mk_mem_row_iff {μ : YoungDiagram} {i j : ℕ} : (i, j) ∈ μ.row i ↔ (i, j) ∈ μ := by simp [row] #align young_diagram.mk_mem_row_iff YoungDiagram.mk_mem_row_iff protected theorem exists_not_mem_row (μ : YoungDiagram) (i : ℕ) : ∃ j, (i, j) ∉ μ := by obtain ⟨j, hj⟩ := Infinite.exists_not_mem_finset (μ.cells.preimage (Prod.mk i) fun _ _ _ _ h => by cases h rfl) rw [Finset.mem_preimage] at hj exact ⟨j, hj⟩ #align young_diagram.exists_not_mem_row YoungDiagram.exists_not_mem_row /-- Length of a row of a Young diagram -/ def rowLen (μ : YoungDiagram) (i : ℕ) : ℕ := Nat.find <| μ.exists_not_mem_row i #align young_diagram.row_len YoungDiagram.rowLen theorem mem_iff_lt_rowLen {μ : YoungDiagram} {i j : ℕ} : (i, j) ∈ μ ↔ j < μ.rowLen i := by rw [rowLen, Nat.lt_find_iff] push_neg exact ⟨fun h _ hmj => μ.up_left_mem (by rfl) hmj h, fun h => h _ (by rfl)⟩ #align young_diagram.mem_iff_lt_row_len YoungDiagram.mem_iff_lt_rowLen theorem row_eq_prod {μ : YoungDiagram} {i : ℕ} : μ.row i = {i} ×ˢ Finset.range (μ.rowLen i) := by ext ⟨a, b⟩ simp only [Finset.mem_product, Finset.mem_singleton, Finset.mem_range, mem_row_iff, mem_iff_lt_rowLen, and_comm, and_congr_right_iff] rintro rfl rfl #align young_diagram.row_eq_prod YoungDiagram.row_eq_prod theorem rowLen_eq_card (μ : YoungDiagram) {i : ℕ} : μ.rowLen i = (μ.row i).card := by simp [row_eq_prod] #align young_diagram.row_len_eq_card YoungDiagram.rowLen_eq_card @[mono] theorem rowLen_anti (μ : YoungDiagram) (i1 i2 : ℕ) (hi : i1 ≤ i2) : μ.rowLen i2 ≤ μ.rowLen i1 := by by_contra! h_lt rw [← lt_self_iff_false (μ.rowLen i1)] rw [← mem_iff_lt_rowLen] at h_lt ⊢ exact μ.up_left_mem hi (by rfl) h_lt #align young_diagram.row_len_anti YoungDiagram.rowLen_anti end Rows section Columns /-! ### Columns and column lengths of Young diagrams. This section has an identical API to the rows section. -/ /-- The `j`-th column of a Young diagram consists of the cells whose second coordinate is `j`. -/ def col (μ : YoungDiagram) (j : ℕ) : Finset (ℕ × ℕ) := μ.cells.filter fun c => c.snd = j #align young_diagram.col YoungDiagram.col theorem mem_col_iff {μ : YoungDiagram} {j : ℕ} {c : ℕ × ℕ} : c ∈ μ.col j ↔ c ∈ μ ∧ c.snd = j := by simp [col] #align young_diagram.mem_col_iff YoungDiagram.mem_col_iff theorem mk_mem_col_iff {μ : YoungDiagram} {i j : ℕ} : (i, j) ∈ μ.col j ↔ (i, j) ∈ μ := by simp [col] #align young_diagram.mk_mem_col_iff YoungDiagram.mk_mem_col_iff protected theorem exists_not_mem_col (μ : YoungDiagram) (j : ℕ) : ∃ i, (i, j) ∉ μ.cells := by convert μ.transpose.exists_not_mem_row j using 1 simp #align young_diagram.exists_not_mem_col YoungDiagram.exists_not_mem_col /-- Length of a column of a Young diagram -/ def colLen (μ : YoungDiagram) (j : ℕ) : ℕ := Nat.find <| μ.exists_not_mem_col j #align young_diagram.col_len YoungDiagram.colLen @[simp] theorem colLen_transpose (μ : YoungDiagram) (j : ℕ) : μ.transpose.colLen j = μ.rowLen j := by simp [rowLen, colLen] #align young_diagram.col_len_transpose YoungDiagram.colLen_transpose @[simp] theorem rowLen_transpose (μ : YoungDiagram) (i : ℕ) : μ.transpose.rowLen i = μ.colLen i := by simp [rowLen, colLen] #align young_diagram.row_len_transpose YoungDiagram.rowLen_transpose theorem mem_iff_lt_colLen {μ : YoungDiagram} {i j : ℕ} : (i, j) ∈ μ ↔ i < μ.colLen j := by rw [← rowLen_transpose, ← mem_iff_lt_rowLen] simp #align young_diagram.mem_iff_lt_col_len YoungDiagram.mem_iff_lt_colLen theorem col_eq_prod {μ : YoungDiagram} {j : ℕ} : μ.col j = Finset.range (μ.colLen j) ×ˢ {j} := by ext ⟨a, b⟩ simp only [Finset.mem_product, Finset.mem_singleton, Finset.mem_range, mem_col_iff, mem_iff_lt_colLen, and_comm, and_congr_right_iff] rintro rfl rfl #align young_diagram.col_eq_prod YoungDiagram.col_eq_prod theorem colLen_eq_card (μ : YoungDiagram) {j : ℕ} : μ.colLen j = (μ.col j).card := by simp [col_eq_prod] #align young_diagram.col_len_eq_card YoungDiagram.colLen_eq_card @[mono] theorem colLen_anti (μ : YoungDiagram) (j1 j2 : ℕ) (hj : j1 ≤ j2) : μ.colLen j2 ≤ μ.colLen j1 := by convert μ.transpose.rowLen_anti j1 j2 hj using 1 <;> simp #align young_diagram.col_len_anti YoungDiagram.colLen_anti end Columns section RowLens /-! ### The list of row lengths of a Young diagram This section defines `μ.rowLens : List ℕ`, the list of row lengths of a Young diagram `μ`. 1. `YoungDiagram.rowLens_sorted` : It is weakly decreasing (`List.Sorted (· ≥ ·)`). 2. `YoungDiagram.rowLens_pos` : It is strictly positive. -/ /-- List of row lengths of a Young diagram -/ def rowLens (μ : YoungDiagram) : List ℕ := (List.range <| μ.colLen 0).map μ.rowLen #align young_diagram.row_lens YoungDiagram.rowLens @[simp] theorem get_rowLens {μ : YoungDiagram} {i} : μ.rowLens.get i = μ.rowLen i := by simp only [rowLens, List.get_range, List.get_map] #align young_diagram.nth_le_row_lens YoungDiagram.get_rowLens @[simp] theorem length_rowLens {μ : YoungDiagram} : μ.rowLens.length = μ.colLen 0 := by simp only [rowLens, List.length_map, List.length_range] #align young_diagram.length_row_lens YoungDiagram.length_rowLens theorem rowLens_sorted (μ : YoungDiagram) : μ.rowLens.Sorted (· ≥ ·) := (List.pairwise_le_range _).map _ μ.rowLen_anti #align young_diagram.row_lens_sorted YoungDiagram.rowLens_sorted theorem pos_of_mem_rowLens (μ : YoungDiagram) (x : ℕ) (hx : x ∈ μ.rowLens) : 0 < x := by rw [rowLens, List.mem_map] at hx obtain ⟨i, hi, rfl : μ.rowLen i = x⟩ := hx rwa [List.mem_range, ← mem_iff_lt_colLen, mem_iff_lt_rowLen] at hi #align young_diagram.pos_of_mem_row_lens YoungDiagram.pos_of_mem_rowLens end RowLens section EquivListRowLens /-! ### Equivalence between Young diagrams and lists of natural numbers This section defines the equivalence between Young diagrams `μ` and weakly decreasing lists `w` of positive natural numbers, corresponding to row lengths of the diagram: `YoungDiagram.equivListRowLens :` `YoungDiagram ≃ {w : List ℕ // w.Sorted (· ≥ ·) ∧ ∀ x ∈ w, 0 < x}` The two directions are `YoungDiagram.rowLens` (defined above) and `YoungDiagram.ofRowLens`. -/ /-- The cells making up a `YoungDiagram` from a list of row lengths -/ protected def cellsOfRowLens : List ℕ → Finset (ℕ × ℕ) | [] => ∅ | w::ws => ({0} : Finset ℕ) ×ˢ Finset.range w ∪ (YoungDiagram.cellsOfRowLens ws).map (Embedding.prodMap ⟨_, Nat.succ_injective⟩ (Embedding.refl ℕ)) #align young_diagram.cells_of_row_lens YoungDiagram.cellsOfRowLens protected theorem mem_cellsOfRowLens {w : List ℕ} {c : ℕ × ℕ} : c ∈ YoungDiagram.cellsOfRowLens w ↔ ∃ h : c.fst < w.length, c.snd < w.get ⟨c.fst, h⟩ := by induction' w with w_hd w_tl w_ih generalizing c <;> rw [YoungDiagram.cellsOfRowLens] · simp [YoungDiagram.cellsOfRowLens] · rcases c with ⟨⟨_, _⟩, _⟩ · simp -- Porting note: was `simpa` · simp [w_ih, -Finset.singleton_product, Nat.succ_lt_succ_iff] #align young_diagram.mem_cells_of_row_lens YoungDiagram.mem_cellsOfRowLens /-- Young diagram from a sorted list -/ def ofRowLens (w : List ℕ) (hw : w.Sorted (· ≥ ·)) : YoungDiagram where cells := YoungDiagram.cellsOfRowLens w isLowerSet := by rintro ⟨i2, j2⟩ ⟨i1, j1⟩ ⟨hi : i1 ≤ i2, hj : j1 ≤ j2⟩ hcell rw [Finset.mem_coe, YoungDiagram.mem_cellsOfRowLens] at hcell ⊢ obtain ⟨h1, h2⟩ := hcell refine ⟨hi.trans_lt h1, ?_⟩ calc j1 ≤ j2 := hj _ < w.get ⟨i2, _⟩ := h2 _ ≤ w.get ⟨i1, _⟩ := by obtain rfl | h := eq_or_lt_of_le hi · convert le_refl (w.get ⟨i1, h1⟩) · exact List.pairwise_iff_get.mp hw _ _ h #align young_diagram.of_row_lens YoungDiagram.ofRowLens theorem mem_ofRowLens {w : List ℕ} {hw : w.Sorted (· ≥ ·)} {c : ℕ × ℕ} : c ∈ ofRowLens w hw ↔ ∃ h : c.fst < w.length, c.snd < w.get ⟨c.fst, h⟩ := YoungDiagram.mem_cellsOfRowLens #align young_diagram.mem_of_row_lens YoungDiagram.mem_ofRowLens /-- The number of rows in `ofRowLens w hw` is the length of `w` -/ theorem rowLens_length_ofRowLens {w : List ℕ} {hw : w.Sorted (· ≥ ·)} (hpos : ∀ x ∈ w, 0 < x) : (ofRowLens w hw).rowLens.length = w.length := by simp only [length_rowLens, colLen, Nat.find_eq_iff, mem_cells, mem_ofRowLens, lt_self_iff_false, IsEmpty.exists_iff, Classical.not_not] exact ⟨not_false, fun n hn => ⟨hn, hpos _ (List.get_mem _ _ hn)⟩⟩ #align young_diagram.row_lens_length_of_row_lens YoungDiagram.rowLens_length_ofRowLens /-- The length of the `i`th row in `ofRowLens w hw` is the `i`th entry of `w` -/ theorem rowLen_ofRowLens {w : List ℕ} {hw : w.Sorted (· ≥ ·)} (i : Fin w.length) : (ofRowLens w hw).rowLen i = w.get i := by simp [rowLen, Nat.find_eq_iff, mem_ofRowLens] #align young_diagram.row_len_of_row_lens YoungDiagram.rowLen_ofRowLens /-- The left_inv direction of the equivalence -/
Mathlib/Combinatorics/Young/YoungDiagram.lean
506
509
theorem ofRowLens_to_rowLens_eq_self {μ : YoungDiagram} : ofRowLens _ (rowLens_sorted μ) = μ := by
ext ⟨i, j⟩ simp only [mem_cells, mem_ofRowLens, length_rowLens, get_rowLens] simpa [← mem_iff_lt_colLen, mem_iff_lt_rowLen] using j.zero_le.trans_lt
/- Copyright (c) 2018 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes, Aaron Anderson, Yakov Pechersky -/ import Mathlib.Algebra.Group.Commute.Basic import Mathlib.Data.Fintype.Card import Mathlib.GroupTheory.Perm.Basic #align_import group_theory.perm.support from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853" /-! # support of a permutation ## Main definitions In the following, `f g : Equiv.Perm α`. * `Equiv.Perm.Disjoint`: two permutations `f` and `g` are `Disjoint` if every element is fixed either by `f`, or by `g`. Equivalently, `f` and `g` are `Disjoint` iff their `support` are disjoint. * `Equiv.Perm.IsSwap`: `f = swap x y` for `x ≠ y`. * `Equiv.Perm.support`: the elements `x : α` that are not fixed by `f`. Assume `α` is a Fintype: * `Equiv.Perm.fixed_point_card_lt_of_ne_one f` says that `f` has strictly less than `Fintype.card α - 1` fixed points, unless `f = 1`. (Equivalently, `f.support` has at least 2 elements.) -/ open Equiv Finset namespace Equiv.Perm variable {α : Type*} section Disjoint /-- Two permutations `f` and `g` are `Disjoint` if their supports are disjoint, i.e., every element is fixed either by `f`, or by `g`. -/ def Disjoint (f g : Perm α) := ∀ x, f x = x ∨ g x = x #align equiv.perm.disjoint Equiv.Perm.Disjoint variable {f g h : Perm α} @[symm] theorem Disjoint.symm : Disjoint f g → Disjoint g f := by simp only [Disjoint, or_comm, imp_self] #align equiv.perm.disjoint.symm Equiv.Perm.Disjoint.symm theorem Disjoint.symmetric : Symmetric (@Disjoint α) := fun _ _ => Disjoint.symm #align equiv.perm.disjoint.symmetric Equiv.Perm.Disjoint.symmetric instance : IsSymm (Perm α) Disjoint := ⟨Disjoint.symmetric⟩ theorem disjoint_comm : Disjoint f g ↔ Disjoint g f := ⟨Disjoint.symm, Disjoint.symm⟩ #align equiv.perm.disjoint_comm Equiv.Perm.disjoint_comm theorem Disjoint.commute (h : Disjoint f g) : Commute f g := Equiv.ext fun x => (h x).elim (fun hf => (h (g x)).elim (fun hg => by simp [mul_apply, hf, hg]) fun hg => by simp [mul_apply, hf, g.injective hg]) fun hg => (h (f x)).elim (fun hf => by simp [mul_apply, f.injective hf, hg]) fun hf => by simp [mul_apply, hf, hg] #align equiv.perm.disjoint.commute Equiv.Perm.Disjoint.commute @[simp] theorem disjoint_one_left (f : Perm α) : Disjoint 1 f := fun _ => Or.inl rfl #align equiv.perm.disjoint_one_left Equiv.Perm.disjoint_one_left @[simp] theorem disjoint_one_right (f : Perm α) : Disjoint f 1 := fun _ => Or.inr rfl #align equiv.perm.disjoint_one_right Equiv.Perm.disjoint_one_right theorem disjoint_iff_eq_or_eq : Disjoint f g ↔ ∀ x : α, f x = x ∨ g x = x := Iff.rfl #align equiv.perm.disjoint_iff_eq_or_eq Equiv.Perm.disjoint_iff_eq_or_eq @[simp] theorem disjoint_refl_iff : Disjoint f f ↔ f = 1 := by refine ⟨fun h => ?_, fun h => h.symm ▸ disjoint_one_left 1⟩ ext x cases' h x with hx hx <;> simp [hx] #align equiv.perm.disjoint_refl_iff Equiv.Perm.disjoint_refl_iff theorem Disjoint.inv_left (h : Disjoint f g) : Disjoint f⁻¹ g := by intro x rw [inv_eq_iff_eq, eq_comm] exact h x #align equiv.perm.disjoint.inv_left Equiv.Perm.Disjoint.inv_left theorem Disjoint.inv_right (h : Disjoint f g) : Disjoint f g⁻¹ := h.symm.inv_left.symm #align equiv.perm.disjoint.inv_right Equiv.Perm.Disjoint.inv_right @[simp] theorem disjoint_inv_left_iff : Disjoint f⁻¹ g ↔ Disjoint f g := by refine ⟨fun h => ?_, Disjoint.inv_left⟩ convert h.inv_left #align equiv.perm.disjoint_inv_left_iff Equiv.Perm.disjoint_inv_left_iff @[simp] theorem disjoint_inv_right_iff : Disjoint f g⁻¹ ↔ Disjoint f g := by rw [disjoint_comm, disjoint_inv_left_iff, disjoint_comm] #align equiv.perm.disjoint_inv_right_iff Equiv.Perm.disjoint_inv_right_iff theorem Disjoint.mul_left (H1 : Disjoint f h) (H2 : Disjoint g h) : Disjoint (f * g) h := fun x => by cases H1 x <;> cases H2 x <;> simp [*] #align equiv.perm.disjoint.mul_left Equiv.Perm.Disjoint.mul_left theorem Disjoint.mul_right (H1 : Disjoint f g) (H2 : Disjoint f h) : Disjoint f (g * h) := by rw [disjoint_comm] exact H1.symm.mul_left H2.symm #align equiv.perm.disjoint.mul_right Equiv.Perm.Disjoint.mul_right -- Porting note (#11215): TODO: make it `@[simp]` theorem disjoint_conj (h : Perm α) : Disjoint (h * f * h⁻¹) (h * g * h⁻¹) ↔ Disjoint f g := (h⁻¹).forall_congr fun {_} ↦ by simp only [mul_apply, eq_inv_iff_eq] theorem Disjoint.conj (H : Disjoint f g) (h : Perm α) : Disjoint (h * f * h⁻¹) (h * g * h⁻¹) := (disjoint_conj h).2 H theorem disjoint_prod_right (l : List (Perm α)) (h : ∀ g ∈ l, Disjoint f g) : Disjoint f l.prod := by induction' l with g l ih · exact disjoint_one_right _ · rw [List.prod_cons] exact (h _ (List.mem_cons_self _ _)).mul_right (ih fun g hg => h g (List.mem_cons_of_mem _ hg)) #align equiv.perm.disjoint_prod_right Equiv.Perm.disjoint_prod_right open scoped List in theorem disjoint_prod_perm {l₁ l₂ : List (Perm α)} (hl : l₁.Pairwise Disjoint) (hp : l₁ ~ l₂) : l₁.prod = l₂.prod := hp.prod_eq' <| hl.imp Disjoint.commute #align equiv.perm.disjoint_prod_perm Equiv.Perm.disjoint_prod_perm theorem nodup_of_pairwise_disjoint {l : List (Perm α)} (h1 : (1 : Perm α) ∉ l) (h2 : l.Pairwise Disjoint) : l.Nodup := by refine List.Pairwise.imp_of_mem ?_ h2 intro τ σ h_mem _ h_disjoint _ subst τ suffices (σ : Perm α) = 1 by rw [this] at h_mem exact h1 h_mem exact ext fun a => or_self_iff.mp (h_disjoint a) #align equiv.perm.nodup_of_pairwise_disjoint Equiv.Perm.nodup_of_pairwise_disjoint theorem pow_apply_eq_self_of_apply_eq_self {x : α} (hfx : f x = x) : ∀ n : ℕ, (f ^ n) x = x | 0 => rfl | n + 1 => by rw [pow_succ, mul_apply, hfx, pow_apply_eq_self_of_apply_eq_self hfx n] #align equiv.perm.pow_apply_eq_self_of_apply_eq_self Equiv.Perm.pow_apply_eq_self_of_apply_eq_self theorem zpow_apply_eq_self_of_apply_eq_self {x : α} (hfx : f x = x) : ∀ n : ℤ, (f ^ n) x = x | (n : ℕ) => pow_apply_eq_self_of_apply_eq_self hfx n | Int.negSucc n => by rw [zpow_negSucc, inv_eq_iff_eq, pow_apply_eq_self_of_apply_eq_self hfx] #align equiv.perm.zpow_apply_eq_self_of_apply_eq_self Equiv.Perm.zpow_apply_eq_self_of_apply_eq_self theorem pow_apply_eq_of_apply_apply_eq_self {x : α} (hffx : f (f x) = x) : ∀ n : ℕ, (f ^ n) x = x ∨ (f ^ n) x = f x | 0 => Or.inl rfl | n + 1 => (pow_apply_eq_of_apply_apply_eq_self hffx n).elim (fun h => Or.inr (by rw [pow_succ', mul_apply, h])) fun h => Or.inl (by rw [pow_succ', mul_apply, h, hffx]) #align equiv.perm.pow_apply_eq_of_apply_apply_eq_self Equiv.Perm.pow_apply_eq_of_apply_apply_eq_self theorem zpow_apply_eq_of_apply_apply_eq_self {x : α} (hffx : f (f x) = x) : ∀ i : ℤ, (f ^ i) x = x ∨ (f ^ i) x = f x | (n : ℕ) => pow_apply_eq_of_apply_apply_eq_self hffx n | Int.negSucc n => by rw [zpow_negSucc, inv_eq_iff_eq, ← f.injective.eq_iff, ← mul_apply, ← pow_succ', eq_comm, inv_eq_iff_eq, ← mul_apply, ← pow_succ, @eq_comm _ x, or_comm] exact pow_apply_eq_of_apply_apply_eq_self hffx _ #align equiv.perm.zpow_apply_eq_of_apply_apply_eq_self Equiv.Perm.zpow_apply_eq_of_apply_apply_eq_self theorem Disjoint.mul_apply_eq_iff {σ τ : Perm α} (hστ : Disjoint σ τ) {a : α} : (σ * τ) a = a ↔ σ a = a ∧ τ a = a := by refine ⟨fun h => ?_, fun h => by rw [mul_apply, h.2, h.1]⟩ cases' hστ a with hσ hτ · exact ⟨hσ, σ.injective (h.trans hσ.symm)⟩ · exact ⟨(congr_arg σ hτ).symm.trans h, hτ⟩ #align equiv.perm.disjoint.mul_apply_eq_iff Equiv.Perm.Disjoint.mul_apply_eq_iff theorem Disjoint.mul_eq_one_iff {σ τ : Perm α} (hστ : Disjoint σ τ) : σ * τ = 1 ↔ σ = 1 ∧ τ = 1 := by simp_rw [ext_iff, one_apply, hστ.mul_apply_eq_iff, forall_and] #align equiv.perm.disjoint.mul_eq_one_iff Equiv.Perm.Disjoint.mul_eq_one_iff theorem Disjoint.zpow_disjoint_zpow {σ τ : Perm α} (hστ : Disjoint σ τ) (m n : ℤ) : Disjoint (σ ^ m) (τ ^ n) := fun x => Or.imp (fun h => zpow_apply_eq_self_of_apply_eq_self h m) (fun h => zpow_apply_eq_self_of_apply_eq_self h n) (hστ x) #align equiv.perm.disjoint.zpow_disjoint_zpow Equiv.Perm.Disjoint.zpow_disjoint_zpow theorem Disjoint.pow_disjoint_pow {σ τ : Perm α} (hστ : Disjoint σ τ) (m n : ℕ) : Disjoint (σ ^ m) (τ ^ n) := hστ.zpow_disjoint_zpow m n #align equiv.perm.disjoint.pow_disjoint_pow Equiv.Perm.Disjoint.pow_disjoint_pow end Disjoint section IsSwap variable [DecidableEq α] /-- `f.IsSwap` indicates that the permutation `f` is a transposition of two elements. -/ def IsSwap (f : Perm α) : Prop := ∃ x y, x ≠ y ∧ f = swap x y #align equiv.perm.is_swap Equiv.Perm.IsSwap @[simp] theorem ofSubtype_swap_eq {p : α → Prop} [DecidablePred p] (x y : Subtype p) : ofSubtype (Equiv.swap x y) = Equiv.swap ↑x ↑y := Equiv.ext fun z => by by_cases hz : p z · rw [swap_apply_def, ofSubtype_apply_of_mem _ hz] split_ifs with hzx hzy · simp_rw [hzx, Subtype.coe_eta, swap_apply_left] · simp_rw [hzy, Subtype.coe_eta, swap_apply_right] · rw [swap_apply_of_ne_of_ne] <;> simp [Subtype.ext_iff, *] · rw [ofSubtype_apply_of_not_mem _ hz, swap_apply_of_ne_of_ne] · intro h apply hz rw [h] exact Subtype.prop x intro h apply hz rw [h] exact Subtype.prop y #align equiv.perm.of_subtype_swap_eq Equiv.Perm.ofSubtype_swap_eq theorem IsSwap.of_subtype_isSwap {p : α → Prop} [DecidablePred p] {f : Perm (Subtype p)} (h : f.IsSwap) : (ofSubtype f).IsSwap := let ⟨⟨x, hx⟩, ⟨y, hy⟩, hxy⟩ := h ⟨x, y, by simp only [Ne, Subtype.ext_iff] at hxy exact hxy.1, by rw [hxy.2, ofSubtype_swap_eq]⟩ #align equiv.perm.is_swap.of_subtype_is_swap Equiv.Perm.IsSwap.of_subtype_isSwap theorem ne_and_ne_of_swap_mul_apply_ne_self {f : Perm α} {x y : α} (hy : (swap x (f x) * f) y ≠ y) : f y ≠ y ∧ y ≠ x := by simp only [swap_apply_def, mul_apply, f.injective.eq_iff] at * by_cases h : f y = x · constructor <;> intro <;> simp_all only [if_true, eq_self_iff_true, not_true, Ne] · split_ifs at hy with h h <;> try { simp [*] at * } #align equiv.perm.ne_and_ne_of_swap_mul_apply_ne_self Equiv.Perm.ne_and_ne_of_swap_mul_apply_ne_self end IsSwap section support section Set variable (p q : Perm α) theorem set_support_inv_eq : { x | p⁻¹ x ≠ x } = { x | p x ≠ x } := by ext x simp only [Set.mem_setOf_eq, Ne] rw [inv_def, symm_apply_eq, eq_comm] #align equiv.perm.set_support_inv_eq Equiv.Perm.set_support_inv_eq theorem set_support_apply_mem {p : Perm α} {a : α} : p a ∈ { x | p x ≠ x } ↔ a ∈ { x | p x ≠ x } := by simp #align equiv.perm.set_support_apply_mem Equiv.Perm.set_support_apply_mem theorem set_support_zpow_subset (n : ℤ) : { x | (p ^ n) x ≠ x } ⊆ { x | p x ≠ x } := by intro x simp only [Set.mem_setOf_eq, Ne] intro hx H simp [zpow_apply_eq_self_of_apply_eq_self H] at hx #align equiv.perm.set_support_zpow_subset Equiv.Perm.set_support_zpow_subset theorem set_support_mul_subset : { x | (p * q) x ≠ x } ⊆ { x | p x ≠ x } ∪ { x | q x ≠ x } := by intro x simp only [Perm.coe_mul, Function.comp_apply, Ne, Set.mem_union, Set.mem_setOf_eq] by_cases hq : q x = x <;> simp [hq] #align equiv.perm.set_support_mul_subset Equiv.Perm.set_support_mul_subset end Set variable [DecidableEq α] [Fintype α] {f g : Perm α} /-- The `Finset` of nonfixed points of a permutation. -/ def support (f : Perm α) : Finset α := univ.filter fun x => f x ≠ x #align equiv.perm.support Equiv.Perm.support @[simp] theorem mem_support {x : α} : x ∈ f.support ↔ f x ≠ x := by rw [support, mem_filter, and_iff_right (mem_univ x)] #align equiv.perm.mem_support Equiv.Perm.mem_support theorem not_mem_support {x : α} : x ∉ f.support ↔ f x = x := by simp #align equiv.perm.not_mem_support Equiv.Perm.not_mem_support theorem coe_support_eq_set_support (f : Perm α) : (f.support : Set α) = { x | f x ≠ x } := by ext simp #align equiv.perm.coe_support_eq_set_support Equiv.Perm.coe_support_eq_set_support @[simp] theorem support_eq_empty_iff {σ : Perm α} : σ.support = ∅ ↔ σ = 1 := by simp_rw [Finset.ext_iff, mem_support, Finset.not_mem_empty, iff_false_iff, not_not, Equiv.Perm.ext_iff, one_apply] #align equiv.perm.support_eq_empty_iff Equiv.Perm.support_eq_empty_iff @[simp] theorem support_one : (1 : Perm α).support = ∅ := by rw [support_eq_empty_iff] #align equiv.perm.support_one Equiv.Perm.support_one @[simp] theorem support_refl : support (Equiv.refl α) = ∅ := support_one #align equiv.perm.support_refl Equiv.Perm.support_refl theorem support_congr (h : f.support ⊆ g.support) (h' : ∀ x ∈ g.support, f x = g x) : f = g := by ext x by_cases hx : x ∈ g.support · exact h' x hx · rw [not_mem_support.mp hx, ← not_mem_support] exact fun H => hx (h H) #align equiv.perm.support_congr Equiv.Perm.support_congr theorem support_mul_le (f g : Perm α) : (f * g).support ≤ f.support ⊔ g.support := fun x => by simp only [sup_eq_union] rw [mem_union, mem_support, mem_support, mem_support, mul_apply, ← not_and_or, not_imp_not] rintro ⟨hf, hg⟩ rw [hg, hf] #align equiv.perm.support_mul_le Equiv.Perm.support_mul_le theorem exists_mem_support_of_mem_support_prod {l : List (Perm α)} {x : α} (hx : x ∈ l.prod.support) : ∃ f : Perm α, f ∈ l ∧ x ∈ f.support := by contrapose! hx simp_rw [mem_support, not_not] at hx ⊢ induction' l with f l ih · rfl · rw [List.prod_cons, mul_apply, ih, hx] · simp only [List.find?, List.mem_cons, true_or] intros f' hf' refine hx f' ?_ simp only [List.find?, List.mem_cons] exact Or.inr hf' #align equiv.perm.exists_mem_support_of_mem_support_prod Equiv.Perm.exists_mem_support_of_mem_support_prod theorem support_pow_le (σ : Perm α) (n : ℕ) : (σ ^ n).support ≤ σ.support := fun _ h1 => mem_support.mpr fun h2 => mem_support.mp h1 (pow_apply_eq_self_of_apply_eq_self h2 n) #align equiv.perm.support_pow_le Equiv.Perm.support_pow_le @[simp] theorem support_inv (σ : Perm α) : support σ⁻¹ = σ.support := by simp_rw [Finset.ext_iff, mem_support, not_iff_not, inv_eq_iff_eq.trans eq_comm, imp_true_iff] #align equiv.perm.support_inv Equiv.Perm.support_inv -- @[simp] -- Porting note (#10618): simp can prove this theorem apply_mem_support {x : α} : f x ∈ f.support ↔ x ∈ f.support := by rw [mem_support, mem_support, Ne, Ne, apply_eq_iff_eq] #align equiv.perm.apply_mem_support Equiv.Perm.apply_mem_support -- Porting note (#10756): new theorem @[simp]
Mathlib/GroupTheory/Perm/Support.lean
369
371
theorem apply_pow_apply_eq_iff (f : Perm α) (n : ℕ) {x : α} : f ((f ^ n) x) = (f ^ n) x ↔ f x = x := by
rw [← mul_apply, Commute.self_pow f, mul_apply, apply_eq_iff_eq]
/- Copyright (c) 2023 Rémy Degenne. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Rémy Degenne -/ import Mathlib.Probability.Kernel.Basic import Mathlib.MeasureTheory.Constructions.Prod.Basic import Mathlib.MeasureTheory.Integral.DominatedConvergence #align_import probability.kernel.measurable_integral from "leanprover-community/mathlib"@"28b2a92f2996d28e580450863c130955de0ed398" /-! # Measurability of the integral against a kernel The Lebesgue integral of a measurable function against a kernel is measurable. The Bochner integral is strongly measurable. ## Main statements * `Measurable.lintegral_kernel_prod_right`: the function `a ↦ ∫⁻ b, f a b ∂(κ a)` is measurable, for an s-finite kernel `κ : kernel α β` and a function `f : α → β → ℝ≥0∞` such that `uncurry f` is measurable. * `MeasureTheory.StronglyMeasurable.integral_kernel_prod_right`: the function `a ↦ ∫ b, f a b ∂(κ a)` is measurable, for an s-finite kernel `κ : kernel α β` and a function `f : α → β → E` such that `uncurry f` is measurable. -/ open MeasureTheory ProbabilityTheory Function Set Filter open scoped MeasureTheory ENNReal Topology variable {α β γ : Type*} {mα : MeasurableSpace α} {mβ : MeasurableSpace β} {mγ : MeasurableSpace γ} {κ : kernel α β} {η : kernel (α × β) γ} {a : α} namespace ProbabilityTheory namespace kernel /-- This is an auxiliary lemma for `measurable_kernel_prod_mk_left`. -/ theorem measurable_kernel_prod_mk_left_of_finite {t : Set (α × β)} (ht : MeasurableSet t) (hκs : ∀ a, IsFiniteMeasure (κ a)) : Measurable fun a => κ a (Prod.mk a ⁻¹' t) := by -- `t` is a measurable set in the product `α × β`: we use that the product σ-algebra is generated -- by boxes to prove the result by induction. -- Porting note: added motive refine MeasurableSpace.induction_on_inter (C := fun t => Measurable fun a => κ a (Prod.mk a ⁻¹' t)) generateFrom_prod.symm isPiSystem_prod ?_ ?_ ?_ ?_ ht ·-- case `t = ∅` simp only [preimage_empty, measure_empty, measurable_const] · -- case of a box: `t = t₁ ×ˢ t₂` for measurable sets `t₁` and `t₂` intro t' ht' simp only [Set.mem_image2, Set.mem_setOf_eq, exists_and_left] at ht' obtain ⟨t₁, ht₁, t₂, ht₂, rfl⟩ := ht' classical simp_rw [mk_preimage_prod_right_eq_if] have h_eq_ite : (fun a => κ a (ite (a ∈ t₁) t₂ ∅)) = fun a => ite (a ∈ t₁) (κ a t₂) 0 := by ext1 a split_ifs exacts [rfl, measure_empty] rw [h_eq_ite] exact Measurable.ite ht₁ (kernel.measurable_coe κ ht₂) measurable_const · -- we assume that the result is true for `t` and we prove it for `tᶜ` intro t' ht' h_meas have h_eq_sdiff : ∀ a, Prod.mk a ⁻¹' t'ᶜ = Set.univ \ Prod.mk a ⁻¹' t' := by intro a ext1 b simp only [mem_compl_iff, mem_preimage, mem_diff, mem_univ, true_and_iff] simp_rw [h_eq_sdiff] have : (fun a => κ a (Set.univ \ Prod.mk a ⁻¹' t')) = fun a => κ a Set.univ - κ a (Prod.mk a ⁻¹' t') := by ext1 a rw [← Set.diff_inter_self_eq_diff, Set.inter_univ, measure_diff (Set.subset_univ _)] · exact (@measurable_prod_mk_left α β _ _ a) ht' · exact measure_ne_top _ _ rw [this] exact Measurable.sub (kernel.measurable_coe κ MeasurableSet.univ) h_meas · -- we assume that the result is true for a family of disjoint sets and prove it for their union intro f h_disj hf_meas hf have h_Union : (fun a => κ a (Prod.mk a ⁻¹' ⋃ i, f i)) = fun a => κ a (⋃ i, Prod.mk a ⁻¹' f i) := by ext1 a congr with b simp only [mem_iUnion, mem_preimage] rw [h_Union] have h_tsum : (fun a => κ a (⋃ i, Prod.mk a ⁻¹' f i)) = fun a => ∑' i, κ a (Prod.mk a ⁻¹' f i) := by ext1 a rw [measure_iUnion] · intro i j hij s hsi hsj b hbs have habi : {(a, b)} ⊆ f i := by rw [Set.singleton_subset_iff]; exact hsi hbs have habj : {(a, b)} ⊆ f j := by rw [Set.singleton_subset_iff]; exact hsj hbs simpa only [Set.bot_eq_empty, Set.le_eq_subset, Set.singleton_subset_iff, Set.mem_empty_iff_false] using h_disj hij habi habj · exact fun i => (@measurable_prod_mk_left α β _ _ a) (hf_meas i) rw [h_tsum] exact Measurable.ennreal_tsum hf #align probability_theory.kernel.measurable_kernel_prod_mk_left_of_finite ProbabilityTheory.kernel.measurable_kernel_prod_mk_left_of_finite theorem measurable_kernel_prod_mk_left [IsSFiniteKernel κ] {t : Set (α × β)} (ht : MeasurableSet t) : Measurable fun a => κ a (Prod.mk a ⁻¹' t) := by rw [← kernel.kernel_sum_seq κ] have : ∀ a, kernel.sum (kernel.seq κ) a (Prod.mk a ⁻¹' t) = ∑' n, kernel.seq κ n a (Prod.mk a ⁻¹' t) := fun a => kernel.sum_apply' _ _ (measurable_prod_mk_left ht) simp_rw [this] refine Measurable.ennreal_tsum fun n => ?_ exact measurable_kernel_prod_mk_left_of_finite ht inferInstance #align probability_theory.kernel.measurable_kernel_prod_mk_left ProbabilityTheory.kernel.measurable_kernel_prod_mk_left theorem measurable_kernel_prod_mk_left' [IsSFiniteKernel η] {s : Set (β × γ)} (hs : MeasurableSet s) (a : α) : Measurable fun b => η (a, b) (Prod.mk b ⁻¹' s) := by have : ∀ b, Prod.mk b ⁻¹' s = {c | ((a, b), c) ∈ {p : (α × β) × γ | (p.1.2, p.2) ∈ s}} := by intro b; rfl simp_rw [this] refine (measurable_kernel_prod_mk_left ?_).comp measurable_prod_mk_left exact (measurable_fst.snd.prod_mk measurable_snd) hs #align probability_theory.kernel.measurable_kernel_prod_mk_left' ProbabilityTheory.kernel.measurable_kernel_prod_mk_left' theorem measurable_kernel_prod_mk_right [IsSFiniteKernel κ] {s : Set (β × α)} (hs : MeasurableSet s) : Measurable fun y => κ y ((fun x => (x, y)) ⁻¹' s) := measurable_kernel_prod_mk_left (measurableSet_swap_iff.mpr hs) #align probability_theory.kernel.measurable_kernel_prod_mk_right ProbabilityTheory.kernel.measurable_kernel_prod_mk_right end kernel open ProbabilityTheory.kernel section Lintegral variable [IsSFiniteKernel κ] [IsSFiniteKernel η] /-- Auxiliary lemma for `Measurable.lintegral_kernel_prod_right`. -/ theorem kernel.measurable_lintegral_indicator_const {t : Set (α × β)} (ht : MeasurableSet t) (c : ℝ≥0∞) : Measurable fun a => ∫⁻ b, t.indicator (Function.const (α × β) c) (a, b) ∂κ a := by -- Porting note: was originally by -- `simp_rw [lintegral_indicator_const_comp measurable_prod_mk_left ht _]` -- but this has no effect, so added the `conv` below conv => congr ext erw [lintegral_indicator_const_comp measurable_prod_mk_left ht _] exact Measurable.const_mul (measurable_kernel_prod_mk_left ht) c #align probability_theory.kernel.measurable_lintegral_indicator_const ProbabilityTheory.kernel.measurable_lintegral_indicator_const /-- For an s-finite kernel `κ` and a function `f : α → β → ℝ≥0∞` which is measurable when seen as a map from `α × β` (hypothesis `Measurable (uncurry f)`), the integral `a ↦ ∫⁻ b, f a b ∂(κ a)` is measurable. -/ theorem _root_.Measurable.lintegral_kernel_prod_right {f : α → β → ℝ≥0∞} (hf : Measurable (uncurry f)) : Measurable fun a => ∫⁻ b, f a b ∂κ a := by let F : ℕ → SimpleFunc (α × β) ℝ≥0∞ := SimpleFunc.eapprox (uncurry f) have h : ∀ a, ⨆ n, F n a = uncurry f a := SimpleFunc.iSup_eapprox_apply (uncurry f) hf simp only [Prod.forall, uncurry_apply_pair] at h simp_rw [← h] have : ∀ a, (∫⁻ b, ⨆ n, F n (a, b) ∂κ a) = ⨆ n, ∫⁻ b, F n (a, b) ∂κ a := by intro a rw [lintegral_iSup] · exact fun n => (F n).measurable.comp measurable_prod_mk_left · exact fun i j hij b => SimpleFunc.monotone_eapprox (uncurry f) hij _ simp_rw [this] refine measurable_iSup fun n => ?_ refine SimpleFunc.induction (P := fun f => Measurable (fun (a : α) => ∫⁻ (b : β), f (a, b) ∂κ a)) ?_ ?_ (F n) · intro c t ht simp only [SimpleFunc.const_zero, SimpleFunc.coe_piecewise, SimpleFunc.coe_const, SimpleFunc.coe_zero, Set.piecewise_eq_indicator] exact kernel.measurable_lintegral_indicator_const (κ := κ) ht c · intro g₁ g₂ _ hm₁ hm₂ simp only [SimpleFunc.coe_add, Pi.add_apply] have h_add : (fun a => ∫⁻ b, g₁ (a, b) + g₂ (a, b) ∂κ a) = (fun a => ∫⁻ b, g₁ (a, b) ∂κ a) + fun a => ∫⁻ b, g₂ (a, b) ∂κ a := by ext1 a rw [Pi.add_apply] -- Porting note (#10691): was `rw` (`Function.comp` reducibility) erw [lintegral_add_left (g₁.measurable.comp measurable_prod_mk_left)] simp_rw [Function.comp_apply] rw [h_add] exact Measurable.add hm₁ hm₂ #align measurable.lintegral_kernel_prod_right Measurable.lintegral_kernel_prod_right theorem _root_.Measurable.lintegral_kernel_prod_right' {f : α × β → ℝ≥0∞} (hf : Measurable f) : Measurable fun a => ∫⁻ b, f (a, b) ∂κ a := by refine Measurable.lintegral_kernel_prod_right ?_ have : (uncurry fun (a : α) (b : β) => f (a, b)) = f := by ext x; rw [uncurry_apply_pair] rwa [this] #align measurable.lintegral_kernel_prod_right' Measurable.lintegral_kernel_prod_right' theorem _root_.Measurable.lintegral_kernel_prod_right'' {f : β × γ → ℝ≥0∞} (hf : Measurable f) : Measurable fun x => ∫⁻ y, f (x, y) ∂η (a, x) := by -- Porting note: used `Prod.mk a` instead of `fun x => (a, x)` below change Measurable ((fun x => ∫⁻ y, (fun u : (α × β) × γ => f (u.1.2, u.2)) (x, y) ∂η x) ∘ Prod.mk a) -- Porting note: specified `κ`, `f`. refine (Measurable.lintegral_kernel_prod_right' (κ := η) (f := (fun u ↦ f (u.fst.snd, u.snd))) ?_).comp measurable_prod_mk_left exact hf.comp (measurable_fst.snd.prod_mk measurable_snd) #align measurable.lintegral_kernel_prod_right'' Measurable.lintegral_kernel_prod_right'' theorem _root_.Measurable.set_lintegral_kernel_prod_right {f : α → β → ℝ≥0∞} (hf : Measurable (uncurry f)) {s : Set β} (hs : MeasurableSet s) : Measurable fun a => ∫⁻ b in s, f a b ∂κ a := by simp_rw [← lintegral_restrict κ hs]; exact hf.lintegral_kernel_prod_right #align measurable.set_lintegral_kernel_prod_right Measurable.set_lintegral_kernel_prod_right theorem _root_.Measurable.lintegral_kernel_prod_left' {f : β × α → ℝ≥0∞} (hf : Measurable f) : Measurable fun y => ∫⁻ x, f (x, y) ∂κ y := (measurable_swap_iff.mpr hf).lintegral_kernel_prod_right' #align measurable.lintegral_kernel_prod_left' Measurable.lintegral_kernel_prod_left' theorem _root_.Measurable.lintegral_kernel_prod_left {f : β → α → ℝ≥0∞} (hf : Measurable (uncurry f)) : Measurable fun y => ∫⁻ x, f x y ∂κ y := hf.lintegral_kernel_prod_left' #align measurable.lintegral_kernel_prod_left Measurable.lintegral_kernel_prod_left theorem _root_.Measurable.set_lintegral_kernel_prod_left {f : β → α → ℝ≥0∞} (hf : Measurable (uncurry f)) {s : Set β} (hs : MeasurableSet s) : Measurable fun b => ∫⁻ a in s, f a b ∂κ b := by simp_rw [← lintegral_restrict κ hs]; exact hf.lintegral_kernel_prod_left #align measurable.set_lintegral_kernel_prod_left Measurable.set_lintegral_kernel_prod_left theorem _root_.Measurable.lintegral_kernel {f : β → ℝ≥0∞} (hf : Measurable f) : Measurable fun a => ∫⁻ b, f b ∂κ a := Measurable.lintegral_kernel_prod_right (hf.comp measurable_snd) #align measurable.lintegral_kernel Measurable.lintegral_kernel theorem _root_.Measurable.set_lintegral_kernel {f : β → ℝ≥0∞} (hf : Measurable f) {s : Set β} (hs : MeasurableSet s) : Measurable fun a => ∫⁻ b in s, f b ∂κ a := by -- Porting note: was term mode proof (`Function.comp` reducibility) refine Measurable.set_lintegral_kernel_prod_right ?_ hs convert hf.comp measurable_snd #align measurable.set_lintegral_kernel Measurable.set_lintegral_kernel end Lintegral variable {E : Type*} [NormedAddCommGroup E] [IsSFiniteKernel κ] [IsSFiniteKernel η] theorem measurableSet_kernel_integrable ⦃f : α → β → E⦄ (hf : StronglyMeasurable (uncurry f)) : MeasurableSet {x | Integrable (f x) (κ x)} := by simp_rw [Integrable, hf.of_uncurry_left.aestronglyMeasurable, true_and_iff] exact measurableSet_lt (Measurable.lintegral_kernel_prod_right hf.ennnorm) measurable_const #align probability_theory.measurable_set_kernel_integrable ProbabilityTheory.measurableSet_kernel_integrable end ProbabilityTheory open ProbabilityTheory ProbabilityTheory.kernel namespace MeasureTheory variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [IsSFiniteKernel κ] [IsSFiniteKernel η]
Mathlib/Probability/Kernel/MeasurableIntegral.lean
257
302
theorem StronglyMeasurable.integral_kernel_prod_right ⦃f : α → β → E⦄ (hf : StronglyMeasurable (uncurry f)) : StronglyMeasurable fun x => ∫ y, f x y ∂κ x := by
classical by_cases hE : CompleteSpace E; swap · simp [integral, hE, stronglyMeasurable_const] borelize E haveI : TopologicalSpace.SeparableSpace (range (uncurry f) ∪ {0} : Set E) := hf.separableSpace_range_union_singleton let s : ℕ → SimpleFunc (α × β) E := SimpleFunc.approxOn _ hf.measurable (range (uncurry f) ∪ {0}) 0 (by simp) let s' : ℕ → α → SimpleFunc β E := fun n x => (s n).comp (Prod.mk x) measurable_prod_mk_left let f' : ℕ → α → E := fun n => {x | Integrable (f x) (κ x)}.indicator fun x => (s' n x).integral (κ x) have hf' : ∀ n, StronglyMeasurable (f' n) := by intro n; refine StronglyMeasurable.indicator ?_ (measurableSet_kernel_integrable hf) have : ∀ x, ((s' n x).range.filter fun x => x ≠ 0) ⊆ (s n).range := by intro x; refine Finset.Subset.trans (Finset.filter_subset _ _) ?_; intro y simp_rw [SimpleFunc.mem_range]; rintro ⟨z, rfl⟩; exact ⟨(x, z), rfl⟩ simp only [SimpleFunc.integral_eq_sum_of_subset (this _)] refine Finset.stronglyMeasurable_sum _ fun x _ => ?_ refine (Measurable.ennreal_toReal ?_).stronglyMeasurable.smul_const _ simp only [s', SimpleFunc.coe_comp, preimage_comp] apply kernel.measurable_kernel_prod_mk_left exact (s n).measurableSet_fiber x have h2f' : Tendsto f' atTop (𝓝 fun x : α => ∫ y : β, f x y ∂κ x) := by rw [tendsto_pi_nhds]; intro x by_cases hfx : Integrable (f x) (κ x) · have (n) : Integrable (s' n x) (κ x) := by apply (hfx.norm.add hfx.norm).mono' (s' n x).aestronglyMeasurable filter_upwards with y simp_rw [s', SimpleFunc.coe_comp]; exact SimpleFunc.norm_approxOn_zero_le _ _ (x, y) n simp only [f', hfx, SimpleFunc.integral_eq_integral _ (this _), indicator_of_mem, mem_setOf_eq] refine tendsto_integral_of_dominated_convergence (fun y => ‖f x y‖ + ‖f x y‖) (fun n => (s' n x).aestronglyMeasurable) (hfx.norm.add hfx.norm) ?_ ?_ · -- Porting note: was -- exact fun n => eventually_of_forall fun y => -- SimpleFunc.norm_approxOn_zero_le _ _ (x, y) n exact fun n => eventually_of_forall fun y => SimpleFunc.norm_approxOn_zero_le hf.measurable (by simp) (x, y) n · refine eventually_of_forall fun y => SimpleFunc.tendsto_approxOn hf.measurable (by simp) ?_ apply subset_closure simp [-uncurry_apply_pair] · simp [f', hfx, integral_undef] exact stronglyMeasurable_of_tendsto _ hf' h2f'
/- Copyright (c) 2022 Jiale Miao. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jiale Miao, Kevin Buzzard, Alexander Bentkamp -/ import Mathlib.Analysis.InnerProductSpace.PiL2 import Mathlib.LinearAlgebra.Matrix.Block #align_import analysis.inner_product_space.gram_schmidt_ortho from "leanprover-community/mathlib"@"1a4df69ca1a9a0e5e26bfe12e2b92814216016d0" /-! # Gram-Schmidt Orthogonalization and Orthonormalization In this file we introduce Gram-Schmidt Orthogonalization and Orthonormalization. The Gram-Schmidt process takes a set of vectors as input and outputs a set of orthogonal vectors which have the same span. ## Main results - `gramSchmidt` : the Gram-Schmidt process - `gramSchmidt_orthogonal` : `gramSchmidt` produces an orthogonal system of vectors. - `span_gramSchmidt` : `gramSchmidt` preserves span of vectors. - `gramSchmidt_ne_zero` : If the input vectors of `gramSchmidt` are linearly independent, then the output vectors are non-zero. - `gramSchmidt_basis` : The basis produced by the Gram-Schmidt process when given a basis as input. - `gramSchmidtNormed` : the normalized `gramSchmidt` (i.e each vector in `gramSchmidtNormed` has unit length.) - `gramSchmidt_orthonormal` : `gramSchmidtNormed` produces an orthornormal system of vectors. - `gramSchmidtOrthonormalBasis`: orthonormal basis constructed by the Gram-Schmidt process from an indexed set of vectors of the right size -/ open Finset Submodule FiniteDimensional variable (𝕜 : Type*) {E : Type*} [RCLike 𝕜] [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] variable {ι : Type*} [LinearOrder ι] [LocallyFiniteOrderBot ι] [IsWellOrder ι (· < ·)] attribute [local instance] IsWellOrder.toHasWellFounded local notation "⟪" x ", " y "⟫" => @inner 𝕜 _ _ x y /-- The Gram-Schmidt process takes a set of vectors as input and outputs a set of orthogonal vectors which have the same span. -/ noncomputable def gramSchmidt [IsWellOrder ι (· < ·)] (f : ι → E) (n : ι) : E := f n - ∑ i : Iio n, orthogonalProjection (𝕜 ∙ gramSchmidt f i) (f n) termination_by n decreasing_by exact mem_Iio.1 i.2 #align gram_schmidt gramSchmidt /-- This lemma uses `∑ i in` instead of `∑ i :`. -/ theorem gramSchmidt_def (f : ι → E) (n : ι) : gramSchmidt 𝕜 f n = f n - ∑ i ∈ Iio n, orthogonalProjection (𝕜 ∙ gramSchmidt 𝕜 f i) (f n) := by rw [← sum_attach, attach_eq_univ, gramSchmidt] #align gram_schmidt_def gramSchmidt_def theorem gramSchmidt_def' (f : ι → E) (n : ι) : f n = gramSchmidt 𝕜 f n + ∑ i ∈ Iio n, orthogonalProjection (𝕜 ∙ gramSchmidt 𝕜 f i) (f n) := by rw [gramSchmidt_def, sub_add_cancel] #align gram_schmidt_def' gramSchmidt_def' theorem gramSchmidt_def'' (f : ι → E) (n : ι) : f n = gramSchmidt 𝕜 f n + ∑ i ∈ Iio n, (⟪gramSchmidt 𝕜 f i, f n⟫ / (‖gramSchmidt 𝕜 f i‖ : 𝕜) ^ 2) • gramSchmidt 𝕜 f i := by convert gramSchmidt_def' 𝕜 f n rw [orthogonalProjection_singleton, RCLike.ofReal_pow] #align gram_schmidt_def'' gramSchmidt_def'' @[simp] theorem gramSchmidt_zero {ι : Type*} [LinearOrder ι] [LocallyFiniteOrder ι] [OrderBot ι] [IsWellOrder ι (· < ·)] (f : ι → E) : gramSchmidt 𝕜 f ⊥ = f ⊥ := by rw [gramSchmidt_def, Iio_eq_Ico, Finset.Ico_self, Finset.sum_empty, sub_zero] #align gram_schmidt_zero gramSchmidt_zero /-- **Gram-Schmidt Orthogonalisation**: `gramSchmidt` produces an orthogonal system of vectors. -/ theorem gramSchmidt_orthogonal (f : ι → E) {a b : ι} (h₀ : a ≠ b) : ⟪gramSchmidt 𝕜 f a, gramSchmidt 𝕜 f b⟫ = 0 := by suffices ∀ a b : ι, a < b → ⟪gramSchmidt 𝕜 f a, gramSchmidt 𝕜 f b⟫ = 0 by cases' h₀.lt_or_lt with ha hb · exact this _ _ ha · rw [inner_eq_zero_symm] exact this _ _ hb clear h₀ a b intro a b h₀ revert a apply wellFounded_lt.induction b intro b ih a h₀ simp only [gramSchmidt_def 𝕜 f b, inner_sub_right, inner_sum, orthogonalProjection_singleton, inner_smul_right] rw [Finset.sum_eq_single_of_mem a (Finset.mem_Iio.mpr h₀)] · by_cases h : gramSchmidt 𝕜 f a = 0 · simp only [h, inner_zero_left, zero_div, zero_mul, sub_zero] · rw [RCLike.ofReal_pow, ← inner_self_eq_norm_sq_to_K, div_mul_cancel₀, sub_self] rwa [inner_self_ne_zero] intro i hi hia simp only [mul_eq_zero, div_eq_zero_iff, inner_self_eq_zero] right cases' hia.lt_or_lt with hia₁ hia₂ · rw [inner_eq_zero_symm] exact ih a h₀ i hia₁ · exact ih i (mem_Iio.1 hi) a hia₂ #align gram_schmidt_orthogonal gramSchmidt_orthogonal /-- This is another version of `gramSchmidt_orthogonal` using `Pairwise` instead. -/ theorem gramSchmidt_pairwise_orthogonal (f : ι → E) : Pairwise fun a b => ⟪gramSchmidt 𝕜 f a, gramSchmidt 𝕜 f b⟫ = 0 := fun _ _ => gramSchmidt_orthogonal 𝕜 f #align gram_schmidt_pairwise_orthogonal gramSchmidt_pairwise_orthogonal theorem gramSchmidt_inv_triangular (v : ι → E) {i j : ι} (hij : i < j) : ⟪gramSchmidt 𝕜 v j, v i⟫ = 0 := by rw [gramSchmidt_def'' 𝕜 v] simp only [inner_add_right, inner_sum, inner_smul_right] set b : ι → E := gramSchmidt 𝕜 v convert zero_add (0 : 𝕜) · exact gramSchmidt_orthogonal 𝕜 v hij.ne' apply Finset.sum_eq_zero rintro k hki' have hki : k < i := by simpa using hki' have : ⟪b j, b k⟫ = 0 := gramSchmidt_orthogonal 𝕜 v (hki.trans hij).ne' simp [this] #align gram_schmidt_inv_triangular gramSchmidt_inv_triangular open Submodule Set Order theorem mem_span_gramSchmidt (f : ι → E) {i j : ι} (hij : i ≤ j) : f i ∈ span 𝕜 (gramSchmidt 𝕜 f '' Set.Iic j) := by rw [gramSchmidt_def' 𝕜 f i] simp_rw [orthogonalProjection_singleton] exact Submodule.add_mem _ (subset_span <| mem_image_of_mem _ hij) (Submodule.sum_mem _ fun k hk => smul_mem (span 𝕜 (gramSchmidt 𝕜 f '' Set.Iic j)) _ <| subset_span <| mem_image_of_mem (gramSchmidt 𝕜 f) <| (Finset.mem_Iio.1 hk).le.trans hij) #align mem_span_gram_schmidt mem_span_gramSchmidt theorem gramSchmidt_mem_span (f : ι → E) : ∀ {j i}, i ≤ j → gramSchmidt 𝕜 f i ∈ span 𝕜 (f '' Set.Iic j) := by intro j i hij rw [gramSchmidt_def 𝕜 f i] simp_rw [orthogonalProjection_singleton] refine Submodule.sub_mem _ (subset_span (mem_image_of_mem _ hij)) (Submodule.sum_mem _ fun k hk => ?_) let hkj : k < j := (Finset.mem_Iio.1 hk).trans_le hij exact smul_mem _ _ (span_mono (image_subset f <| Iic_subset_Iic.2 hkj.le) <| gramSchmidt_mem_span _ le_rfl) termination_by j => j #align gram_schmidt_mem_span gramSchmidt_mem_span theorem span_gramSchmidt_Iic (f : ι → E) (c : ι) : span 𝕜 (gramSchmidt 𝕜 f '' Set.Iic c) = span 𝕜 (f '' Set.Iic c) := span_eq_span (Set.image_subset_iff.2 fun _ => gramSchmidt_mem_span _ _) <| Set.image_subset_iff.2 fun _ => mem_span_gramSchmidt _ _ #align span_gram_schmidt_Iic span_gramSchmidt_Iic theorem span_gramSchmidt_Iio (f : ι → E) (c : ι) : span 𝕜 (gramSchmidt 𝕜 f '' Set.Iio c) = span 𝕜 (f '' Set.Iio c) := span_eq_span (Set.image_subset_iff.2 fun _ hi => span_mono (image_subset _ <| Iic_subset_Iio.2 hi) <| gramSchmidt_mem_span _ _ le_rfl) <| Set.image_subset_iff.2 fun _ hi => span_mono (image_subset _ <| Iic_subset_Iio.2 hi) <| mem_span_gramSchmidt _ _ le_rfl #align span_gram_schmidt_Iio span_gramSchmidt_Iio /-- `gramSchmidt` preserves span of vectors. -/ theorem span_gramSchmidt (f : ι → E) : span 𝕜 (range (gramSchmidt 𝕜 f)) = span 𝕜 (range f) := span_eq_span (range_subset_iff.2 fun _ => span_mono (image_subset_range _ _) <| gramSchmidt_mem_span _ _ le_rfl) <| range_subset_iff.2 fun _ => span_mono (image_subset_range _ _) <| mem_span_gramSchmidt _ _ le_rfl #align span_gram_schmidt span_gramSchmidt theorem gramSchmidt_of_orthogonal {f : ι → E} (hf : Pairwise fun i j => ⟪f i, f j⟫ = 0) : gramSchmidt 𝕜 f = f := by ext i rw [gramSchmidt_def] trans f i - 0 · congr apply Finset.sum_eq_zero intro j hj rw [Submodule.coe_eq_zero] suffices span 𝕜 (f '' Set.Iic j) ⟂ 𝕜 ∙ f i by apply orthogonalProjection_mem_subspace_orthogonalComplement_eq_zero rw [mem_orthogonal_singleton_iff_inner_left] rw [← mem_orthogonal_singleton_iff_inner_right] exact this (gramSchmidt_mem_span 𝕜 f (le_refl j)) rw [isOrtho_span] rintro u ⟨k, hk, rfl⟩ v (rfl : v = f i) apply hf exact (lt_of_le_of_lt hk (Finset.mem_Iio.mp hj)).ne · simp #align gram_schmidt_of_orthogonal gramSchmidt_of_orthogonal variable {𝕜} theorem gramSchmidt_ne_zero_coe {f : ι → E} (n : ι) (h₀ : LinearIndependent 𝕜 (f ∘ ((↑) : Set.Iic n → ι))) : gramSchmidt 𝕜 f n ≠ 0 := by by_contra h have h₁ : f n ∈ span 𝕜 (f '' Set.Iio n) := by rw [← span_gramSchmidt_Iio 𝕜 f n, gramSchmidt_def' 𝕜 f, h, zero_add] apply Submodule.sum_mem _ _ intro a ha simp only [Set.mem_image, Set.mem_Iio, orthogonalProjection_singleton] apply Submodule.smul_mem _ _ _ rw [Finset.mem_Iio] at ha exact subset_span ⟨a, ha, by rfl⟩ have h₂ : (f ∘ ((↑) : Set.Iic n → ι)) ⟨n, le_refl n⟩ ∈ span 𝕜 (f ∘ ((↑) : Set.Iic n → ι) '' Set.Iio ⟨n, le_refl n⟩) := by rw [image_comp] simpa using h₁ apply LinearIndependent.not_mem_span_image h₀ _ h₂ simp only [Set.mem_Iio, lt_self_iff_false, not_false_iff] #align gram_schmidt_ne_zero_coe gramSchmidt_ne_zero_coe /-- If the input vectors of `gramSchmidt` are linearly independent, then the output vectors are non-zero. -/ theorem gramSchmidt_ne_zero {f : ι → E} (n : ι) (h₀ : LinearIndependent 𝕜 f) : gramSchmidt 𝕜 f n ≠ 0 := gramSchmidt_ne_zero_coe _ (LinearIndependent.comp h₀ _ Subtype.coe_injective) #align gram_schmidt_ne_zero gramSchmidt_ne_zero /-- `gramSchmidt` produces a triangular matrix of vectors when given a basis. -/ theorem gramSchmidt_triangular {i j : ι} (hij : i < j) (b : Basis ι 𝕜 E) : b.repr (gramSchmidt 𝕜 b i) j = 0 := by have : gramSchmidt 𝕜 b i ∈ span 𝕜 (gramSchmidt 𝕜 b '' Set.Iio j) := subset_span ((Set.mem_image _ _ _).2 ⟨i, hij, rfl⟩) have : gramSchmidt 𝕜 b i ∈ span 𝕜 (b '' Set.Iio j) := by rwa [← span_gramSchmidt_Iio 𝕜 b j] have : ↑(b.repr (gramSchmidt 𝕜 b i)).support ⊆ Set.Iio j := Basis.repr_support_subset_of_mem_span b (Set.Iio j) this exact (Finsupp.mem_supported' _ _).1 ((Finsupp.mem_supported 𝕜 _).2 this) j Set.not_mem_Iio_self #align gram_schmidt_triangular gramSchmidt_triangular /-- `gramSchmidt` produces linearly independent vectors when given linearly independent vectors. -/ theorem gramSchmidt_linearIndependent {f : ι → E} (h₀ : LinearIndependent 𝕜 f) : LinearIndependent 𝕜 (gramSchmidt 𝕜 f) := linearIndependent_of_ne_zero_of_inner_eq_zero (fun _ => gramSchmidt_ne_zero _ h₀) fun _ _ => gramSchmidt_orthogonal 𝕜 f #align gram_schmidt_linear_independent gramSchmidt_linearIndependent /-- When given a basis, `gramSchmidt` produces a basis. -/ noncomputable def gramSchmidtBasis (b : Basis ι 𝕜 E) : Basis ι 𝕜 E := Basis.mk (gramSchmidt_linearIndependent b.linearIndependent) ((span_gramSchmidt 𝕜 b).trans b.span_eq).ge #align gram_schmidt_basis gramSchmidtBasis theorem coe_gramSchmidtBasis (b : Basis ι 𝕜 E) : (gramSchmidtBasis b : ι → E) = gramSchmidt 𝕜 b := Basis.coe_mk _ _ #align coe_gram_schmidt_basis coe_gramSchmidtBasis variable (𝕜) /-- the normalized `gramSchmidt` (i.e each vector in `gramSchmidtNormed` has unit length.) -/ noncomputable def gramSchmidtNormed (f : ι → E) (n : ι) : E := (‖gramSchmidt 𝕜 f n‖ : 𝕜)⁻¹ • gramSchmidt 𝕜 f n #align gram_schmidt_normed gramSchmidtNormed variable {𝕜} theorem gramSchmidtNormed_unit_length_coe {f : ι → E} (n : ι) (h₀ : LinearIndependent 𝕜 (f ∘ ((↑) : Set.Iic n → ι))) : ‖gramSchmidtNormed 𝕜 f n‖ = 1 := by simp only [gramSchmidt_ne_zero_coe n h₀, gramSchmidtNormed, norm_smul_inv_norm, Ne, not_false_iff] #align gram_schmidt_normed_unit_length_coe gramSchmidtNormed_unit_length_coe theorem gramSchmidtNormed_unit_length {f : ι → E} (n : ι) (h₀ : LinearIndependent 𝕜 f) : ‖gramSchmidtNormed 𝕜 f n‖ = 1 := gramSchmidtNormed_unit_length_coe _ (LinearIndependent.comp h₀ _ Subtype.coe_injective) #align gram_schmidt_normed_unit_length gramSchmidtNormed_unit_length theorem gramSchmidtNormed_unit_length' {f : ι → E} {n : ι} (hn : gramSchmidtNormed 𝕜 f n ≠ 0) : ‖gramSchmidtNormed 𝕜 f n‖ = 1 := by rw [gramSchmidtNormed] at * rw [norm_smul_inv_norm] simpa using hn #align gram_schmidt_normed_unit_length' gramSchmidtNormed_unit_length' /-- **Gram-Schmidt Orthonormalization**: `gramSchmidtNormed` applied to a linearly independent set of vectors produces an orthornormal system of vectors. -/ theorem gramSchmidt_orthonormal {f : ι → E} (h₀ : LinearIndependent 𝕜 f) : Orthonormal 𝕜 (gramSchmidtNormed 𝕜 f) := by unfold Orthonormal constructor · simp only [gramSchmidtNormed_unit_length, h₀, eq_self_iff_true, imp_true_iff] · intro i j hij simp only [gramSchmidtNormed, inner_smul_left, inner_smul_right, RCLike.conj_inv, RCLike.conj_ofReal, mul_eq_zero, inv_eq_zero, RCLike.ofReal_eq_zero, norm_eq_zero] repeat' right exact gramSchmidt_orthogonal 𝕜 f hij #align gram_schmidt_orthonormal gramSchmidt_orthonormal /-- **Gram-Schmidt Orthonormalization**: `gramSchmidtNormed` produces an orthornormal system of vectors after removing the vectors which become zero in the process. -/ theorem gramSchmidt_orthonormal' (f : ι → E) : Orthonormal 𝕜 fun i : { i | gramSchmidtNormed 𝕜 f i ≠ 0 } => gramSchmidtNormed 𝕜 f i := by refine ⟨fun i => gramSchmidtNormed_unit_length' i.prop, ?_⟩ rintro i j (hij : ¬_) rw [Subtype.ext_iff] at hij simp [gramSchmidtNormed, inner_smul_left, inner_smul_right, gramSchmidt_orthogonal 𝕜 f hij] #align gram_schmidt_orthonormal' gramSchmidt_orthonormal' theorem span_gramSchmidtNormed (f : ι → E) (s : Set ι) : span 𝕜 (gramSchmidtNormed 𝕜 f '' s) = span 𝕜 (gramSchmidt 𝕜 f '' s) := by refine span_eq_span (Set.image_subset_iff.2 fun i hi => smul_mem _ _ <| subset_span <| mem_image_of_mem _ hi) (Set.image_subset_iff.2 fun i hi => span_mono (image_subset _ <| singleton_subset_set_iff.2 hi) ?_) simp only [coe_singleton, Set.image_singleton] by_cases h : gramSchmidt 𝕜 f i = 0 · simp [h] · refine mem_span_singleton.2 ⟨‖gramSchmidt 𝕜 f i‖, smul_inv_smul₀ ?_ _⟩ exact mod_cast norm_ne_zero_iff.2 h #align span_gram_schmidt_normed span_gramSchmidtNormed
Mathlib/Analysis/InnerProductSpace/GramSchmidtOrtho.lean
321
323
theorem span_gramSchmidtNormed_range (f : ι → E) : span 𝕜 (range (gramSchmidtNormed 𝕜 f)) = span 𝕜 (range (gramSchmidt 𝕜 f)) := by
simpa only [image_univ.symm] using span_gramSchmidtNormed f univ
/- Copyright (c) 2021 Ashvni Narayanan. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Ashvni Narayanan, David Loeffler -/ import Mathlib.Algebra.Polynomial.AlgebraMap import Mathlib.Algebra.Polynomial.Derivative import Mathlib.Data.Nat.Choose.Cast import Mathlib.NumberTheory.Bernoulli #align_import number_theory.bernoulli_polynomials from "leanprover-community/mathlib"@"ca3d21f7f4fd613c2a3c54ac7871163e1e5ecb3a" /-! # Bernoulli polynomials The [Bernoulli polynomials](https://en.wikipedia.org/wiki/Bernoulli_polynomials) are an important tool obtained from Bernoulli numbers. ## Mathematical overview The $n$-th Bernoulli polynomial is defined as $$ B_n(X) = ∑_{k = 0}^n {n \choose k} (-1)^k B_k X^{n - k} $$ where $B_k$ is the $k$-th Bernoulli number. The Bernoulli polynomials are generating functions, $$ \frac{t e^{tX} }{ e^t - 1} = ∑_{n = 0}^{\infty} B_n(X) \frac{t^n}{n!} $$ ## Implementation detail Bernoulli polynomials are defined using `bernoulli`, the Bernoulli numbers. ## Main theorems - `sum_bernoulli`: The sum of the $k^\mathrm{th}$ Bernoulli polynomial with binomial coefficients up to `n` is `(n + 1) * X^n`. - `Polynomial.bernoulli_generating_function`: The Bernoulli polynomials act as generating functions for the exponential. ## TODO - `bernoulli_eval_one_neg` : $$ B_n(1 - x) = (-1)^n B_n(x) $$ -/ noncomputable section open Nat Polynomial open Nat Finset namespace Polynomial /-- The Bernoulli polynomials are defined in terms of the negative Bernoulli numbers. -/ def bernoulli (n : ℕ) : ℚ[X] := ∑ i ∈ range (n + 1), Polynomial.monomial (n - i) (_root_.bernoulli i * choose n i) #align polynomial.bernoulli Polynomial.bernoulli theorem bernoulli_def (n : ℕ) : bernoulli n = ∑ i ∈ range (n + 1), Polynomial.monomial i (_root_.bernoulli (n - i) * choose n i) := by rw [← sum_range_reflect, add_succ_sub_one, add_zero, bernoulli] apply sum_congr rfl rintro x hx rw [mem_range_succ_iff] at hx rw [choose_symm hx, tsub_tsub_cancel_of_le hx] #align polynomial.bernoulli_def Polynomial.bernoulli_def /- ### examples -/ section Examples @[simp] theorem bernoulli_zero : bernoulli 0 = 1 := by simp [bernoulli] #align polynomial.bernoulli_zero Polynomial.bernoulli_zero @[simp] theorem bernoulli_eval_zero (n : ℕ) : (bernoulli n).eval 0 = _root_.bernoulli n := by rw [bernoulli, eval_finset_sum, sum_range_succ] have : ∑ x ∈ range n, _root_.bernoulli x * n.choose x * 0 ^ (n - x) = 0 := by apply sum_eq_zero fun x hx => _ intros x hx simp [tsub_eq_zero_iff_le, mem_range.1 hx] simp [this] #align polynomial.bernoulli_eval_zero Polynomial.bernoulli_eval_zero @[simp] theorem bernoulli_eval_one (n : ℕ) : (bernoulli n).eval 1 = bernoulli' n := by simp only [bernoulli, eval_finset_sum] simp only [← succ_eq_add_one, sum_range_succ, mul_one, cast_one, choose_self, (_root_.bernoulli _).mul_comm, sum_bernoulli, one_pow, mul_one, eval_C, eval_monomial, one_mul] by_cases h : n = 1 · norm_num [h] · simp [h, bernoulli_eq_bernoulli'_of_ne_one h] #align polynomial.bernoulli_eval_one Polynomial.bernoulli_eval_one end Examples theorem derivative_bernoulli_add_one (k : ℕ) : Polynomial.derivative (bernoulli (k + 1)) = (k + 1) * bernoulli k := by simp_rw [bernoulli, derivative_sum, derivative_monomial, Nat.sub_sub, Nat.add_sub_add_right] -- LHS sum has an extra term, but the coefficient is zero: rw [range_add_one, sum_insert not_mem_range_self, tsub_self, cast_zero, mul_zero, map_zero, zero_add, mul_sum] -- the rest of the sum is termwise equal: refine sum_congr (by rfl) fun m _ => ?_ conv_rhs => rw [← Nat.cast_one, ← Nat.cast_add, ← C_eq_natCast, C_mul_monomial, mul_comm] rw [mul_assoc, mul_assoc, ← Nat.cast_mul, ← Nat.cast_mul] congr 3 rw [(choose_mul_succ_eq k m).symm] #align polynomial.derivative_bernoulli_add_one Polynomial.derivative_bernoulli_add_one theorem derivative_bernoulli (k : ℕ) : Polynomial.derivative (bernoulli k) = k * bernoulli (k - 1) := by cases k with | zero => rw [Nat.cast_zero, zero_mul, bernoulli_zero, derivative_one] | succ k => exact mod_cast derivative_bernoulli_add_one k #align polynomial.derivative_bernoulli Polynomial.derivative_bernoulli @[simp] nonrec theorem sum_bernoulli (n : ℕ) : (∑ k ∈ range (n + 1), ((n + 1).choose k : ℚ) • bernoulli k) = monomial n (n + 1 : ℚ) := by simp_rw [bernoulli_def, Finset.smul_sum, Finset.range_eq_Ico, ← Finset.sum_Ico_Ico_comm, Finset.sum_Ico_eq_sum_range] simp only [add_tsub_cancel_left, tsub_zero, zero_add, map_add] simp_rw [smul_monomial, mul_comm (_root_.bernoulli _) _, smul_eq_mul, ← mul_assoc] conv_lhs => apply_congr · skip · conv => apply_congr · skip · rw [← Nat.cast_mul, choose_mul ((le_tsub_iff_left <| mem_range_le (by assumption)).1 <| mem_range_le (by assumption)) (le.intro rfl), Nat.cast_mul, add_tsub_cancel_left, mul_assoc, mul_comm, ← smul_eq_mul, ← smul_monomial] simp_rw [← sum_smul] rw [sum_range_succ_comm] simp only [add_right_eq_self, mul_one, cast_one, cast_add, add_tsub_cancel_left, choose_succ_self_right, one_smul, _root_.bernoulli_zero, sum_singleton, zero_add, map_add, range_one, bernoulli_zero, mul_one, one_mul, add_zero, choose_self] apply sum_eq_zero fun x hx => _ have f : ∀ x ∈ range n, ¬n + 1 - x = 1 := by rintro x H rw [mem_range] at H rw [eq_comm] exact _root_.ne_of_lt (Nat.lt_of_lt_of_le one_lt_two (le_tsub_of_add_le_left (succ_le_succ H))) intro x hx rw [sum_bernoulli] have g : ite (n + 1 - x = 1) (1 : ℚ) 0 = 0 := by simp only [ite_eq_right_iff, one_ne_zero] intro h₁ exact (f x hx) h₁ rw [g, zero_smul] #align polynomial.sum_bernoulli Polynomial.sum_bernoulli /-- Another version of `Polynomial.sum_bernoulli`. -/ theorem bernoulli_eq_sub_sum (n : ℕ) : (n.succ : ℚ) • bernoulli n = monomial n (n.succ : ℚ) - ∑ k ∈ Finset.range n, ((n + 1).choose k : ℚ) • bernoulli k := by rw [Nat.cast_succ, ← sum_bernoulli n, sum_range_succ, add_sub_cancel_left, choose_succ_self_right, Nat.cast_succ] #align polynomial.bernoulli_eq_sub_sum Polynomial.bernoulli_eq_sub_sum /-- Another version of `sum_range_pow`. -/ theorem sum_range_pow_eq_bernoulli_sub (n p : ℕ) : ((p + 1 : ℚ) * ∑ k ∈ range n, (k : ℚ) ^ p) = (bernoulli p.succ).eval (n : ℚ) - _root_.bernoulli p.succ := by rw [sum_range_pow, bernoulli_def, eval_finset_sum, ← sum_div, mul_div_cancel₀ _ _] · simp_rw [eval_monomial] symm rw [← sum_flip _, sum_range_succ] simp only [tsub_self, tsub_zero, choose_zero_right, cast_one, mul_one, _root_.pow_zero, add_tsub_cancel_right] apply sum_congr rfl fun x hx => _ intro x hx apply congr_arg₂ _ (congr_arg₂ _ _ _) rfl · rw [Nat.sub_sub_self (mem_range_le hx)] · rw [← choose_symm (mem_range_le hx)] · norm_cast #align polynomial.sum_range_pow_eq_bernoulli_sub Polynomial.sum_range_pow_eq_bernoulli_sub /-- Rearrangement of `Polynomial.sum_range_pow_eq_bernoulli_sub`. -/ theorem bernoulli_succ_eval (n p : ℕ) : (bernoulli p.succ).eval (n : ℚ) = _root_.bernoulli p.succ + (p + 1 : ℚ) * ∑ k ∈ range n, (k : ℚ) ^ p := by apply eq_add_of_sub_eq' rw [sum_range_pow_eq_bernoulli_sub] #align polynomial.bernoulli_succ_eval Polynomial.bernoulli_succ_eval
Mathlib/NumberTheory/BernoulliPolynomials.lean
188
211
theorem bernoulli_eval_one_add (n : ℕ) (x : ℚ) : (bernoulli n).eval (1 + x) = (bernoulli n).eval x + n * x ^ (n - 1) := by
refine Nat.strong_induction_on n fun d hd => ?_ have nz : ((d.succ : ℕ) : ℚ) ≠ 0 := by norm_cast apply (mul_right_inj' nz).1 rw [← smul_eq_mul, ← eval_smul, bernoulli_eq_sub_sum, mul_add, ← smul_eq_mul, ← eval_smul, bernoulli_eq_sub_sum, eval_sub, eval_finset_sum] conv_lhs => congr · skip · apply_congr · skip · rw [eval_smul, hd _ (mem_range.1 (by assumption))] rw [eval_sub, eval_finset_sum] simp_rw [eval_smul, smul_add] rw [sum_add_distrib, sub_add, sub_eq_sub_iff_sub_eq_sub, _root_.add_sub_sub_cancel] conv_rhs => congr · skip · congr rw [succ_eq_add_one, ← choose_succ_self_right d] rw [Nat.cast_succ, ← smul_eq_mul, ← sum_range_succ _ d, eval_monomial_one_add_sub] simp_rw [smul_eq_mul]
/- 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.Algebra.Group.Basic import Mathlib.Algebra.Group.Pi.Basic import Mathlib.Order.Fin import Mathlib.Order.PiLex import Mathlib.Order.Interval.Set.Basic #align_import data.fin.tuple.basic from "leanprover-community/mathlib"@"ef997baa41b5c428be3fb50089a7139bf4ee886b" /-! # Operation on tuples We interpret maps `∀ i : Fin n, α i` as `n`-tuples of elements of possibly varying type `α i`, `(α 0, …, α (n-1))`. A particular case is `Fin n → α` of elements with all the same type. In this case when `α i` is a constant map, then tuples are isomorphic (but not definitionally equal) to `Vector`s. We define the following operations: * `Fin.tail` : the tail of an `n+1` tuple, i.e., its last `n` entries; * `Fin.cons` : adding an element at the beginning of an `n`-tuple, to get an `n+1`-tuple; * `Fin.init` : the beginning of an `n+1` tuple, i.e., its first `n` entries; * `Fin.snoc` : adding an element at the end of an `n`-tuple, to get an `n+1`-tuple. The name `snoc` comes from `cons` (i.e., adding an element to the left of a tuple) read in reverse order. * `Fin.insertNth` : insert an element to a tuple at a given position. * `Fin.find p` : returns the first index `n` where `p n` is satisfied, and `none` if it is never satisfied. * `Fin.append a b` : append two tuples. * `Fin.repeat n a` : repeat a tuple `n` times. -/ assert_not_exists MonoidWithZero universe u v namespace Fin variable {m n : ℕ} open Function section Tuple /-- There is exactly one tuple of size zero. -/ example (α : Fin 0 → Sort u) : Unique (∀ i : Fin 0, α i) := by infer_instance theorem tuple0_le {α : Fin 0 → Type*} [∀ i, Preorder (α i)] (f g : ∀ i, α i) : f ≤ g := finZeroElim #align fin.tuple0_le Fin.tuple0_le variable {α : Fin (n + 1) → Type u} (x : α 0) (q : ∀ i, α i) (p : ∀ i : Fin n, α i.succ) (i : Fin n) (y : α i.succ) (z : α 0) /-- The tail of an `n+1` tuple, i.e., its last `n` entries. -/ def tail (q : ∀ i, α i) : ∀ i : Fin n, α i.succ := fun i ↦ q i.succ #align fin.tail Fin.tail theorem tail_def {n : ℕ} {α : Fin (n + 1) → Type*} {q : ∀ i, α i} : (tail fun k : Fin (n + 1) ↦ q k) = fun k : Fin n ↦ q k.succ := rfl #align fin.tail_def Fin.tail_def /-- Adding an element at the beginning of an `n`-tuple, to get an `n+1`-tuple. -/ def cons (x : α 0) (p : ∀ i : Fin n, α i.succ) : ∀ i, α i := fun j ↦ Fin.cases x p j #align fin.cons Fin.cons @[simp] theorem tail_cons : tail (cons x p) = p := by simp (config := { unfoldPartialApp := true }) [tail, cons] #align fin.tail_cons Fin.tail_cons @[simp] theorem cons_succ : cons x p i.succ = p i := by simp [cons] #align fin.cons_succ Fin.cons_succ @[simp] theorem cons_zero : cons x p 0 = x := by simp [cons] #align fin.cons_zero Fin.cons_zero @[simp] theorem cons_one {α : Fin (n + 2) → Type*} (x : α 0) (p : ∀ i : Fin n.succ, α i.succ) : cons x p 1 = p 0 := by rw [← cons_succ x p]; rfl /-- Updating a tuple and adding an element at the beginning commute. -/ @[simp] theorem cons_update : cons x (update p i y) = update (cons x p) i.succ y := by ext j by_cases h : j = 0 · rw [h] simp [Ne.symm (succ_ne_zero i)] · let j' := pred j h have : j'.succ = j := succ_pred j h rw [← this, cons_succ] by_cases h' : j' = i · rw [h'] simp · have : j'.succ ≠ i.succ := by rwa [Ne, succ_inj] rw [update_noteq h', update_noteq this, cons_succ] #align fin.cons_update Fin.cons_update /-- As a binary function, `Fin.cons` is injective. -/ theorem cons_injective2 : Function.Injective2 (@cons n α) := fun x₀ y₀ x y h ↦ ⟨congr_fun h 0, funext fun i ↦ by simpa using congr_fun h (Fin.succ i)⟩ #align fin.cons_injective2 Fin.cons_injective2 @[simp] theorem cons_eq_cons {x₀ y₀ : α 0} {x y : ∀ i : Fin n, α i.succ} : cons x₀ x = cons y₀ y ↔ x₀ = y₀ ∧ x = y := cons_injective2.eq_iff #align fin.cons_eq_cons Fin.cons_eq_cons theorem cons_left_injective (x : ∀ i : Fin n, α i.succ) : Function.Injective fun x₀ ↦ cons x₀ x := cons_injective2.left _ #align fin.cons_left_injective Fin.cons_left_injective theorem cons_right_injective (x₀ : α 0) : Function.Injective (cons x₀) := cons_injective2.right _ #align fin.cons_right_injective Fin.cons_right_injective /-- Adding an element at the beginning of a tuple and then updating it amounts to adding it directly. -/
Mathlib/Data/Fin/Tuple/Basic.lean
128
136
theorem update_cons_zero : update (cons x p) 0 z = cons z p := by
ext j by_cases h : j = 0 · rw [h] simp · simp only [h, update_noteq, Ne, not_false_iff] let j' := pred j h have : j'.succ = j := succ_pred j h rw [← this, cons_succ, cons_succ]
/- Copyright (c) 2022 Yaël Dillies, Bhavik Mehta. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yaël Dillies, Bhavik Mehta -/ import Mathlib.Combinatorics.SimpleGraph.Regularity.Bound import Mathlib.Combinatorics.SimpleGraph.Regularity.Equitabilise import Mathlib.Combinatorics.SimpleGraph.Regularity.Uniform #align_import combinatorics.simple_graph.regularity.chunk from "leanprover-community/mathlib"@"bf7ef0e83e5b7e6c1169e97f055e58a2e4e9d52d" /-! # Chunk of the increment partition for Szemerédi Regularity Lemma In the proof of Szemerédi Regularity Lemma, we need to partition each part of a starting partition to increase the energy. This file defines those partitions of parts and shows that they locally increase the energy. This entire file is internal to the proof of Szemerédi Regularity Lemma. ## Main declarations * `SzemerediRegularity.chunk`: The partition of a part of the starting partition. * `SzemerediRegularity.edgeDensity_chunk_uniform`: `chunk` does not locally decrease the edge density between uniform parts too much. * `SzemerediRegularity.edgeDensity_chunk_not_uniform`: `chunk` locally increases the edge density between non-uniform parts. ## TODO Once ported to mathlib4, this file will be a great golfing ground for Heather's new tactic `gcongr`. ## References [Yaël Dillies, Bhavik Mehta, *Formalising Szemerédi’s Regularity Lemma in Lean*][srl_itp] -/ open Finpartition Finset Fintype Rel Nat open scoped SzemerediRegularity.Positivity namespace SzemerediRegularity variable {α : Type*} [Fintype α] [DecidableEq α] {P : Finpartition (univ : Finset α)} (hP : P.IsEquipartition) (G : SimpleGraph α) [DecidableRel G.Adj] (ε : ℝ) {U : Finset α} (hU : U ∈ P.parts) (V : Finset α) local notation3 "m" => (card α / stepBound P.parts.card : ℕ) /-! ### Definitions We define `chunk`, the partition of a part, and `star`, the sets of parts of `chunk` that are contained in the corresponding witness of non-uniformity. -/ /-- The portion of `SzemerediRegularity.increment` which partitions `U`. -/ noncomputable def chunk : Finpartition U := if hUcard : U.card = m * 4 ^ P.parts.card + (card α / P.parts.card - m * 4 ^ P.parts.card) then (atomise U <| P.nonuniformWitnesses G ε U).equitabilise <| card_aux₁ hUcard else (atomise U <| P.nonuniformWitnesses G ε U).equitabilise <| card_aux₂ hP hU hUcard #align szemeredi_regularity.chunk SzemerediRegularity.chunk -- `hP` and `hU` are used to get that `U` has size -- `m * 4 ^ P.parts.card + a or m * 4 ^ P.parts.card + a + 1` /-- The portion of `SzemerediRegularity.chunk` which is contained in the witness of non-uniformity of `U` and `V`. -/ noncomputable def star (V : Finset α) : Finset (Finset α) := (chunk hP G ε hU).parts.filter (· ⊆ G.nonuniformWitness ε U V) #align szemeredi_regularity.star SzemerediRegularity.star /-! ### Density estimates We estimate the density between parts of `chunk`. -/ theorem biUnion_star_subset_nonuniformWitness : (star hP G ε hU V).biUnion id ⊆ G.nonuniformWitness ε U V := biUnion_subset_iff_forall_subset.2 fun _ hA => (mem_filter.1 hA).2 #align szemeredi_regularity.bUnion_star_subset_nonuniform_witness SzemerediRegularity.biUnion_star_subset_nonuniformWitness variable {hP G ε hU V} {𝒜 : Finset (Finset α)} {s : Finset α} theorem star_subset_chunk : star hP G ε hU V ⊆ (chunk hP G ε hU).parts := filter_subset _ _ #align szemeredi_regularity.star_subset_chunk SzemerediRegularity.star_subset_chunk private theorem card_nonuniformWitness_sdiff_biUnion_star (hV : V ∈ P.parts) (hUV : U ≠ V) (h₂ : ¬G.IsUniform ε U V) : (G.nonuniformWitness ε U V \ (star hP G ε hU V).biUnion id).card ≤ 2 ^ (P.parts.card - 1) * m := by have hX : G.nonuniformWitness ε U V ∈ P.nonuniformWitnesses G ε U := nonuniformWitness_mem_nonuniformWitnesses h₂ hV hUV have q : G.nonuniformWitness ε U V \ (star hP G ε hU V).biUnion id ⊆ ((atomise U <| P.nonuniformWitnesses G ε U).parts.filter fun B => B ⊆ G.nonuniformWitness ε U V ∧ B.Nonempty).biUnion fun B => B \ ((chunk hP G ε hU).parts.filter (· ⊆ B)).biUnion id := by intro x hx rw [← biUnion_filter_atomise hX (G.nonuniformWitness_subset h₂), star, mem_sdiff, mem_biUnion] at hx simp only [not_exists, mem_biUnion, and_imp, exists_prop, mem_filter, not_and, mem_sdiff, id, mem_sdiff] at hx ⊢ obtain ⟨⟨B, hB₁, hB₂⟩, hx⟩ := hx exact ⟨B, hB₁, hB₂, fun A hA AB => hx A hA <| AB.trans hB₁.2.1⟩ apply (card_le_card q).trans (card_biUnion_le.trans _) trans ∑ _i in (atomise U <| P.nonuniformWitnesses G ε U).parts.filter fun B => B ⊆ G.nonuniformWitness ε U V ∧ B.Nonempty, m · suffices ∀ B ∈ (atomise U <| P.nonuniformWitnesses G ε U).parts, (B \ ((chunk hP G ε hU).parts.filter (· ⊆ B)).biUnion id).card ≤ m by exact sum_le_sum fun B hB => this B <| filter_subset _ _ hB intro B hB unfold chunk split_ifs with h₁ · convert card_parts_equitabilise_subset_le _ (card_aux₁ h₁) hB · convert card_parts_equitabilise_subset_le _ (card_aux₂ hP hU h₁) hB rw [sum_const] refine mul_le_mul_right' ?_ _ have t := card_filter_atomise_le_two_pow (s := U) hX refine t.trans (pow_le_pow_right (by norm_num) <| tsub_le_tsub_right ?_ _) exact card_image_le.trans (card_le_card <| filter_subset _ _) private theorem one_sub_eps_mul_card_nonuniformWitness_le_card_star (hV : V ∈ P.parts) (hUV : U ≠ V) (hunif : ¬G.IsUniform ε U V) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5) (hε₁ : ε ≤ 1) : (1 - ε / 10) * (G.nonuniformWitness ε U V).card ≤ ((star hP G ε hU V).biUnion id).card := by have hP₁ : 0 < P.parts.card := Finset.card_pos.2 ⟨_, hU⟩ have : (↑2 ^ P.parts.card : ℝ) * m / (U.card * ε) ≤ ε / 10 := by rw [← div_div, div_le_iff'] swap · sz_positivity refine le_of_mul_le_mul_left ?_ (pow_pos zero_lt_two P.parts.card) calc ↑2 ^ P.parts.card * ((↑2 ^ P.parts.card * m : ℝ) / U.card) = ((2 : ℝ) * 2) ^ P.parts.card * m / U.card := by rw [mul_pow, ← mul_div_assoc, mul_assoc] _ = ↑4 ^ P.parts.card * m / U.card := by norm_num _ ≤ 1 := div_le_one_of_le (pow_mul_m_le_card_part hP hU) (cast_nonneg _) _ ≤ ↑2 ^ P.parts.card * ε ^ 2 / 10 := by refine (one_le_sq_iff <| by positivity).1 ?_ rw [div_pow, mul_pow, pow_right_comm, ← pow_mul ε, one_le_div (sq_pos_of_ne_zero <| by norm_num)] calc (↑10 ^ 2) = 100 := by norm_num _ ≤ ↑4 ^ P.parts.card * ε ^ 5 := hPε _ ≤ ↑4 ^ P.parts.card * ε ^ 4 := (mul_le_mul_of_nonneg_left (pow_le_pow_of_le_one (by sz_positivity) hε₁ <| le_succ _) (by positivity)) _ = (↑2 ^ 2) ^ P.parts.card * ε ^ (2 * 2) := by norm_num _ = ↑2 ^ P.parts.card * (ε * (ε / 10)) := by rw [mul_div_assoc, sq, mul_div_assoc] calc (↑1 - ε / 10) * (G.nonuniformWitness ε U V).card ≤ (↑1 - ↑2 ^ P.parts.card * m / (U.card * ε)) * (G.nonuniformWitness ε U V).card := mul_le_mul_of_nonneg_right (sub_le_sub_left this _) (cast_nonneg _) _ = (G.nonuniformWitness ε U V).card - ↑2 ^ P.parts.card * m / (U.card * ε) * (G.nonuniformWitness ε U V).card := by rw [sub_mul, one_mul] _ ≤ (G.nonuniformWitness ε U V).card - ↑2 ^ (P.parts.card - 1) * m := by refine sub_le_sub_left ?_ _ have : (2 : ℝ) ^ P.parts.card = ↑2 ^ (P.parts.card - 1) * 2 := by rw [← _root_.pow_succ, tsub_add_cancel_of_le (succ_le_iff.2 hP₁)] rw [← mul_div_right_comm, this, mul_right_comm _ (2 : ℝ), mul_assoc, le_div_iff] · refine mul_le_mul_of_nonneg_left ?_ (by positivity) exact (G.le_card_nonuniformWitness hunif).trans (le_mul_of_one_le_left (cast_nonneg _) one_le_two) have := Finset.card_pos.mpr (P.nonempty_of_mem_parts hU) sz_positivity _ ≤ ((star hP G ε hU V).biUnion id).card := by rw [sub_le_comm, ← cast_sub (card_le_card <| biUnion_star_subset_nonuniformWitness hP G ε hU V), ← card_sdiff (biUnion_star_subset_nonuniformWitness hP G ε hU V)] exact mod_cast card_nonuniformWitness_sdiff_biUnion_star hV hUV hunif /-! ### `chunk` -/ theorem card_chunk (hm : m ≠ 0) : (chunk hP G ε hU).parts.card = 4 ^ P.parts.card := by unfold chunk split_ifs · rw [card_parts_equitabilise _ _ hm, tsub_add_cancel_of_le] exact le_of_lt a_add_one_le_four_pow_parts_card · rw [card_parts_equitabilise _ _ hm, tsub_add_cancel_of_le a_add_one_le_four_pow_parts_card] #align szemeredi_regularity.card_chunk SzemerediRegularity.card_chunk theorem card_eq_of_mem_parts_chunk (hs : s ∈ (chunk hP G ε hU).parts) : s.card = m ∨ s.card = m + 1 := by unfold chunk at hs split_ifs at hs <;> exact card_eq_of_mem_parts_equitabilise hs #align szemeredi_regularity.card_eq_of_mem_parts_chunk SzemerediRegularity.card_eq_of_mem_parts_chunk theorem m_le_card_of_mem_chunk_parts (hs : s ∈ (chunk hP G ε hU).parts) : m ≤ s.card := (card_eq_of_mem_parts_chunk hs).elim ge_of_eq fun i => by simp [i] #align szemeredi_regularity.m_le_card_of_mem_chunk_parts SzemerediRegularity.m_le_card_of_mem_chunk_parts theorem card_le_m_add_one_of_mem_chunk_parts (hs : s ∈ (chunk hP G ε hU).parts) : s.card ≤ m + 1 := (card_eq_of_mem_parts_chunk hs).elim (fun i => by simp [i]) fun i => i.le #align szemeredi_regularity.card_le_m_add_one_of_mem_chunk_parts SzemerediRegularity.card_le_m_add_one_of_mem_chunk_parts theorem card_biUnion_star_le_m_add_one_card_star_mul : (((star hP G ε hU V).biUnion id).card : ℝ) ≤ (star hP G ε hU V).card * (m + 1) := mod_cast card_biUnion_le_card_mul _ _ _ fun _ hs => card_le_m_add_one_of_mem_chunk_parts <| star_subset_chunk hs #align szemeredi_regularity.card_bUnion_star_le_m_add_one_card_star_mul SzemerediRegularity.card_biUnion_star_le_m_add_one_card_star_mul private theorem le_sum_card_subset_chunk_parts (h𝒜 : 𝒜 ⊆ (chunk hP G ε hU).parts) (hs : s ∈ 𝒜) : (𝒜.card : ℝ) * s.card * (m / (m + 1)) ≤ (𝒜.sup id).card := by rw [mul_div_assoc', div_le_iff coe_m_add_one_pos, mul_right_comm] refine mul_le_mul ?_ ?_ (cast_nonneg _) (cast_nonneg _) · rw [← (ofSubset _ h𝒜 rfl).sum_card_parts, ofSubset_parts, ← cast_mul, cast_le] exact card_nsmul_le_sum _ _ _ fun x hx => m_le_card_of_mem_chunk_parts <| h𝒜 hx · exact mod_cast card_le_m_add_one_of_mem_chunk_parts (h𝒜 hs) private theorem sum_card_subset_chunk_parts_le (m_pos : (0 : ℝ) < m) (h𝒜 : 𝒜 ⊆ (chunk hP G ε hU).parts) (hs : s ∈ 𝒜) : ((𝒜.sup id).card : ℝ) ≤ 𝒜.card * s.card * ((m + 1) / m) := by rw [sup_eq_biUnion, mul_div_assoc', le_div_iff m_pos, mul_right_comm] refine mul_le_mul ?_ ?_ (cast_nonneg _) (by positivity) · norm_cast refine card_biUnion_le_card_mul _ _ _ fun x hx => ?_ apply card_le_m_add_one_of_mem_chunk_parts (h𝒜 hx) · exact mod_cast m_le_card_of_mem_chunk_parts (h𝒜 hs) private theorem one_sub_le_m_div_m_add_one_sq [Nonempty α] (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5) : ↑1 - ε ^ 5 / ↑50 ≤ (m / (m + 1 : ℝ)) ^ 2 := by have : (m : ℝ) / (m + 1) = 1 - 1 / (m + 1) := by rw [one_sub_div coe_m_add_one_pos.ne', add_sub_cancel_right] rw [this, sub_sq, one_pow, mul_one] refine le_trans ?_ (le_add_of_nonneg_right <| sq_nonneg _) rw [sub_le_sub_iff_left, ← le_div_iff' (show (0 : ℝ) < 2 by norm_num), div_div, one_div_le coe_m_add_one_pos, one_div_div] · refine le_trans ?_ (le_add_of_nonneg_right zero_le_one) set_option tactic.skipAssignedInstances false in norm_num apply hundred_div_ε_pow_five_le_m hPα hPε sz_positivity private theorem m_add_one_div_m_le_one_add [Nonempty α] (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5) (hε₁ : ε ≤ 1) : ((m + 1 : ℝ) / m) ^ 2 ≤ ↑1 + ε ^ 5 / 49 := by rw [same_add_div] swap; · sz_positivity have : ↑1 + ↑1 / (m : ℝ) ≤ ↑1 + ε ^ 5 / 100 := by rw [add_le_add_iff_left, ← one_div_div (100 : ℝ)] exact one_div_le_one_div_of_le (by sz_positivity) (hundred_div_ε_pow_five_le_m hPα hPε) refine (pow_le_pow_left ?_ this 2).trans ?_ · positivity rw [add_sq, one_pow, add_assoc, add_le_add_iff_left, mul_one, ← le_sub_iff_add_le', div_eq_mul_one_div _ (49 : ℝ), mul_div_left_comm (2 : ℝ), ← mul_sub_left_distrib, div_pow, div_le_iff (show (0 : ℝ) < ↑100 ^ 2 by norm_num), mul_assoc, sq] refine mul_le_mul_of_nonneg_left ?_ (by sz_positivity) exact (pow_le_one 5 (by sz_positivity) hε₁).trans (by norm_num) private theorem density_sub_eps_le_sum_density_div_card [Nonempty α] (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5) {hU : U ∈ P.parts} {hV : V ∈ P.parts} {A B : Finset (Finset α)} (hA : A ⊆ (chunk hP G ε hU).parts) (hB : B ⊆ (chunk hP G ε hV).parts) : (G.edgeDensity (A.biUnion id) (B.biUnion id)) - ε ^ 5 / 50 ≤ (∑ ab ∈ A.product B, (G.edgeDensity ab.1 ab.2 : ℝ)) / (A.card * B.card) := by have : ↑(G.edgeDensity (A.biUnion id) (B.biUnion id)) - ε ^ 5 / ↑50 ≤ (↑1 - ε ^ 5 / 50) * G.edgeDensity (A.biUnion id) (B.biUnion id) := by rw [sub_mul, one_mul, sub_le_sub_iff_left] refine mul_le_of_le_one_right (by sz_positivity) ?_ exact mod_cast G.edgeDensity_le_one _ _ refine this.trans ?_ conv_rhs => -- Porting note: LHS and RHS need separate treatment to get the desired form simp only [SimpleGraph.edgeDensity_def, sum_div, Rat.cast_div, div_div] conv_lhs => rw [SimpleGraph.edgeDensity_def, SimpleGraph.interedges, ← sup_eq_biUnion, ← sup_eq_biUnion, Rel.card_interedges_finpartition _ (ofSubset _ hA rfl) (ofSubset _ hB rfl), ofSubset_parts, ofSubset_parts] simp only [cast_sum, sum_div, mul_sum, Rat.cast_sum, Rat.cast_div, mul_div_left_comm ((1 : ℝ) - _)] push_cast apply sum_le_sum simp only [and_imp, Prod.forall, mem_product] rintro x y hx hy rw [mul_mul_mul_comm, mul_comm (x.card : ℝ), mul_comm (y.card : ℝ), le_div_iff, mul_assoc] · refine mul_le_of_le_one_right (cast_nonneg _) ?_ rw [div_mul_eq_mul_div, ← mul_assoc, mul_assoc] refine div_le_one_of_le ?_ (by positivity) refine (mul_le_mul_of_nonneg_right (one_sub_le_m_div_m_add_one_sq hPα hPε) ?_).trans ?_ · exact mod_cast _root_.zero_le _ rw [sq, mul_mul_mul_comm, mul_comm ((m : ℝ) / _), mul_comm ((m : ℝ) / _)] refine mul_le_mul ?_ ?_ ?_ (cast_nonneg _) · apply le_sum_card_subset_chunk_parts hA hx · apply le_sum_card_subset_chunk_parts hB hy · positivity refine mul_pos (mul_pos ?_ ?_) (mul_pos ?_ ?_) <;> rw [cast_pos, Finset.card_pos] exacts [⟨_, hx⟩, nonempty_of_mem_parts _ (hA hx), ⟨_, hy⟩, nonempty_of_mem_parts _ (hB hy)] private theorem sum_density_div_card_le_density_add_eps [Nonempty α] (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5) (hε₁ : ε ≤ 1) {hU : U ∈ P.parts} {hV : V ∈ P.parts} {A B : Finset (Finset α)} (hA : A ⊆ (chunk hP G ε hU).parts) (hB : B ⊆ (chunk hP G ε hV).parts) : (∑ ab ∈ A.product B, G.edgeDensity ab.1 ab.2 : ℝ) / (A.card * B.card) ≤ G.edgeDensity (A.biUnion id) (B.biUnion id) + ε ^ 5 / 49 := by have : (↑1 + ε ^ 5 / ↑49) * G.edgeDensity (A.biUnion id) (B.biUnion id) ≤ G.edgeDensity (A.biUnion id) (B.biUnion id) + ε ^ 5 / 49 := by rw [add_mul, one_mul, add_le_add_iff_left] refine mul_le_of_le_one_right (by sz_positivity) ?_ exact mod_cast G.edgeDensity_le_one _ _ refine le_trans ?_ this conv_lhs => -- Porting note: LHS and RHS need separate treatment to get the desired form simp only [SimpleGraph.edgeDensity, edgeDensity, sum_div, Rat.cast_div, div_div] conv_rhs => rw [SimpleGraph.edgeDensity, edgeDensity, ← sup_eq_biUnion, ← sup_eq_biUnion, Rel.card_interedges_finpartition _ (ofSubset _ hA rfl) (ofSubset _ hB rfl)] simp only [cast_sum, mul_sum, sum_div, Rat.cast_sum, Rat.cast_div, mul_div_left_comm ((1 : ℝ) + _)] push_cast apply sum_le_sum simp only [and_imp, Prod.forall, mem_product, show A.product B = A ×ˢ B by rfl] intro x y hx hy rw [mul_mul_mul_comm, mul_comm (x.card : ℝ), mul_comm (y.card : ℝ), div_le_iff, mul_assoc] · refine le_mul_of_one_le_right (cast_nonneg _) ?_ rw [div_mul_eq_mul_div, one_le_div] · refine le_trans ?_ (mul_le_mul_of_nonneg_right (m_add_one_div_m_le_one_add hPα hPε hε₁) ?_) · rw [sq, mul_mul_mul_comm, mul_comm (_ / (m : ℝ)), mul_comm (_ / (m : ℝ))] exact mul_le_mul (sum_card_subset_chunk_parts_le (by sz_positivity) hA hx) (sum_card_subset_chunk_parts_le (by sz_positivity) hB hy) (by positivity) (by positivity) · exact mod_cast _root_.zero_le _ rw [← cast_mul, cast_pos] apply mul_pos <;> rw [Finset.card_pos, sup_eq_biUnion, biUnion_nonempty] · exact ⟨_, hx, nonempty_of_mem_parts _ (hA hx)⟩ · exact ⟨_, hy, nonempty_of_mem_parts _ (hB hy)⟩ refine mul_pos (mul_pos ?_ ?_) (mul_pos ?_ ?_) <;> rw [cast_pos, Finset.card_pos] exacts [⟨_, hx⟩, nonempty_of_mem_parts _ (hA hx), ⟨_, hy⟩, nonempty_of_mem_parts _ (hB hy)] private theorem average_density_near_total_density [Nonempty α] (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5) (hε₁ : ε ≤ 1) {hU : U ∈ P.parts} {hV : V ∈ P.parts} {A B : Finset (Finset α)} (hA : A ⊆ (chunk hP G ε hU).parts) (hB : B ⊆ (chunk hP G ε hV).parts) : |(∑ ab ∈ A.product B, G.edgeDensity ab.1 ab.2 : ℝ) / (A.card * B.card) - G.edgeDensity (A.biUnion id) (B.biUnion id)| ≤ ε ^ 5 / 49 := by rw [abs_sub_le_iff] constructor · rw [sub_le_iff_le_add'] exact sum_density_div_card_le_density_add_eps hPα hPε hε₁ hA hB suffices (G.edgeDensity (A.biUnion id) (B.biUnion id) : ℝ) - (∑ ab ∈ A.product B, (G.edgeDensity ab.1 ab.2 : ℝ)) / (A.card * B.card) ≤ ε ^ 5 / 50 by apply this.trans gcongr <;> [sz_positivity; norm_num] rw [sub_le_iff_le_add, ← sub_le_iff_le_add'] apply density_sub_eps_le_sum_density_div_card hPα hPε hA hB private theorem edgeDensity_chunk_aux [Nonempty α] (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5) (hU : U ∈ P.parts) (hV : V ∈ P.parts) : (G.edgeDensity U V : ℝ) ^ 2 - ε ^ 5 / ↑25 ≤ ((∑ ab ∈ (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts, (G.edgeDensity ab.1 ab.2 : ℝ)) / ↑16 ^ P.parts.card) ^ 2 := by obtain hGε | hGε := le_total (G.edgeDensity U V : ℝ) (ε ^ 5 / 50) · refine (sub_nonpos_of_le <| (sq_le ?_ ?_).trans <| hGε.trans ?_).trans (sq_nonneg _) · exact mod_cast G.edgeDensity_nonneg _ _ · exact mod_cast G.edgeDensity_le_one _ _ · exact div_le_div_of_nonneg_left (by sz_positivity) (by norm_num) (by norm_num) rw [← sub_nonneg] at hGε have : ↑(G.edgeDensity U V) - ε ^ 5 / ↑50 ≤ (∑ ab ∈ (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts, (G.edgeDensity ab.1 ab.2 : ℝ)) / ↑16 ^ P.parts.card := by have rflU := Set.Subset.refl (chunk hP G ε hU).parts.toSet have rflV := Set.Subset.refl (chunk hP G ε hV).parts.toSet refine (le_trans ?_ <| density_sub_eps_le_sum_density_div_card hPα hPε rflU rflV).trans ?_ · rw [biUnion_parts, biUnion_parts] · rw [card_chunk (m_pos hPα).ne', card_chunk (m_pos hPα).ne', ← cast_mul, ← mul_pow, cast_pow] norm_cast refine le_trans ?_ (pow_le_pow_left hGε this 2) rw [sub_sq, sub_add, sub_le_sub_iff_left] refine (sub_le_self _ <| sq_nonneg <| ε ^ 5 / 50).trans ?_ rw [mul_right_comm, mul_div_left_comm, div_eq_mul_inv (ε ^ 5), show (2 : ℝ) / 50 = 25⁻¹ by norm_num] exact mul_le_of_le_one_right (by sz_positivity) (mod_cast G.edgeDensity_le_one _ _) private theorem abs_density_star_sub_density_le_eps (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5) (hε₁ : ε ≤ 1) {hU : U ∈ P.parts} {hV : V ∈ P.parts} (hUV' : U ≠ V) (hUV : ¬G.IsUniform ε U V) : |(G.edgeDensity ((star hP G ε hU V).biUnion id) ((star hP G ε hV U).biUnion id) : ℝ) - G.edgeDensity (G.nonuniformWitness ε U V) (G.nonuniformWitness ε V U)| ≤ ε / 5 := by convert abs_edgeDensity_sub_edgeDensity_le_two_mul G.Adj (biUnion_star_subset_nonuniformWitness hP G ε hU V) (biUnion_star_subset_nonuniformWitness hP G ε hV U) (by sz_positivity) (one_sub_eps_mul_card_nonuniformWitness_le_card_star hV hUV' hUV hPε hε₁) (one_sub_eps_mul_card_nonuniformWitness_le_card_star hU hUV'.symm (fun hVU => hUV hVU.symm) hPε hε₁) using 1 linarith private theorem eps_le_card_star_div [Nonempty α] (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5) (hε₁ : ε ≤ 1) (hU : U ∈ P.parts) (hV : V ∈ P.parts) (hUV : U ≠ V) (hunif : ¬G.IsUniform ε U V) : ↑4 / ↑5 * ε ≤ (star hP G ε hU V).card / ↑4 ^ P.parts.card := by have hm : (0 : ℝ) ≤ 1 - (↑m)⁻¹ := sub_nonneg_of_le (inv_le_one <| one_le_m_coe hPα) have hε : 0 ≤ 1 - ε / 10 := sub_nonneg_of_le (div_le_one_of_le (hε₁.trans <| by norm_num) <| by norm_num) have hε₀ : 0 < ε := by sz_positivity calc 4 / 5 * ε = (1 - 1 / 10) * (1 - 9⁻¹) * ε := by norm_num _ ≤ (1 - ε / 10) * (1 - (↑m)⁻¹) * ((G.nonuniformWitness ε U V).card / U.card) := by gcongr exacts [mod_cast (show 9 ≤ 100 by norm_num).trans (hundred_le_m hPα hPε hε₁), (le_div_iff' <| cast_pos.2 (P.nonempty_of_mem_parts hU).card_pos).2 <| G.le_card_nonuniformWitness hunif] _ = (1 - ε / 10) * (G.nonuniformWitness ε U V).card * ((1 - (↑m)⁻¹) / U.card) := by rw [mul_assoc, mul_assoc, mul_div_left_comm] _ ≤ ((star hP G ε hU V).biUnion id).card * ((1 - (↑m)⁻¹) / U.card) := (mul_le_mul_of_nonneg_right (one_sub_eps_mul_card_nonuniformWitness_le_card_star hV hUV hunif hPε hε₁) (by positivity)) _ ≤ (star hP G ε hU V).card * (m + 1) * ((1 - (↑m)⁻¹) / U.card) := (mul_le_mul_of_nonneg_right card_biUnion_star_le_m_add_one_card_star_mul (by positivity)) _ ≤ (star hP G ε hU V).card * (m + ↑1) * ((↑1 - (↑m)⁻¹) / (↑4 ^ P.parts.card * m)) := (mul_le_mul_of_nonneg_left (div_le_div_of_nonneg_left hm (by sz_positivity) <| pow_mul_m_le_card_part hP hU) (by positivity)) _ ≤ (star hP G ε hU V).card / ↑4 ^ P.parts.card := by rw [mul_assoc, mul_comm ((4 : ℝ) ^ P.parts.card), ← div_div, ← mul_div_assoc, ← mul_comm_div] refine mul_le_of_le_one_right (by positivity) ?_ have hm : (0 : ℝ) < m := by sz_positivity rw [mul_div_assoc', div_le_one hm, ← one_div, one_sub_div hm.ne', mul_div_assoc', div_le_iff hm] linarith /-! ### Final bounds Those inequalities are the end result of all this hard work. -/ /-- Lower bound on the edge densities between non-uniform parts of `SzemerediRegularity.star`. -/ private theorem edgeDensity_star_not_uniform [Nonempty α] (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5) (hε₁ : ε ≤ 1) {hU : U ∈ P.parts} {hV : V ∈ P.parts} (hUVne : U ≠ V) (hUV : ¬G.IsUniform ε U V) : ↑3 / ↑4 * ε ≤ |(∑ ab ∈ (star hP G ε hU V).product (star hP G ε hV U), (G.edgeDensity ab.1 ab.2 : ℝ)) / ((star hP G ε hU V).card * (star hP G ε hV U).card) - (∑ ab ∈ (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts, (G.edgeDensity ab.1 ab.2 : ℝ)) / (16 : ℝ) ^ P.parts.card| := by rw [show (16 : ℝ) = ↑4 ^ 2 by norm_num, pow_right_comm, sq ((4 : ℝ) ^ _)] set p : ℝ := (∑ ab ∈ (star hP G ε hU V).product (star hP G ε hV U), (G.edgeDensity ab.1 ab.2 : ℝ)) / ((star hP G ε hU V).card * (star hP G ε hV U).card) set q : ℝ := (∑ ab ∈ (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts, (G.edgeDensity ab.1 ab.2 : ℝ)) / (↑4 ^ P.parts.card * ↑4 ^ P.parts.card) change _ ≤ |p - q| set r : ℝ := ↑(G.edgeDensity ((star hP G ε hU V).biUnion id) ((star hP G ε hV U).biUnion id)) set s : ℝ := ↑(G.edgeDensity (G.nonuniformWitness ε U V) (G.nonuniformWitness ε V U)) set t : ℝ := ↑(G.edgeDensity U V) have hrs : |r - s| ≤ ε / 5 := abs_density_star_sub_density_le_eps hPε hε₁ hUVne hUV have hst : ε ≤ |s - t| := by -- After leanprover/lean4#2734, we need to do the zeta reduction before `mod_cast`. unfold_let s t exact mod_cast G.nonuniformWitness_spec hUVne hUV have hpr : |p - r| ≤ ε ^ 5 / 49 := average_density_near_total_density hPα hPε hε₁ star_subset_chunk star_subset_chunk have hqt : |q - t| ≤ ε ^ 5 / 49 := by have := average_density_near_total_density hPα hPε hε₁ (Subset.refl (chunk hP G ε hU).parts) (Subset.refl (chunk hP G ε hV).parts) simp_rw [← sup_eq_biUnion, sup_parts, card_chunk (m_pos hPα).ne', cast_pow] at this set_option tactic.skipAssignedInstances false in norm_num at this exact this have hε' : ε ^ 5 ≤ ε := by simpa using pow_le_pow_of_le_one (by sz_positivity) hε₁ (show 1 ≤ 5 by norm_num) rw [abs_sub_le_iff] at hrs hpr hqt rw [le_abs] at hst ⊢ cases hst · left; linarith · right; linarith set_option tactic.skipAssignedInstances false in /-- Lower bound on the edge densities between non-uniform parts of `SzemerediRegularity.increment`. -/
Mathlib/Combinatorics/SimpleGraph/Regularity/Chunk.lean
473
521
theorem edgeDensity_chunk_not_uniform [Nonempty α] (hPα : P.parts.card * 16 ^ P.parts.card ≤ card α) (hPε : ↑100 ≤ ↑4 ^ P.parts.card * ε ^ 5) (hε₁ : ε ≤ 1) {hU : U ∈ P.parts} {hV : V ∈ P.parts} (hUVne : U ≠ V) (hUV : ¬G.IsUniform ε U V) : (G.edgeDensity U V : ℝ) ^ 2 - ε ^ 5 / ↑25 + ε ^ 4 / ↑3 ≤ (∑ ab ∈ (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts, (G.edgeDensity ab.1 ab.2 : ℝ) ^ 2) / ↑16 ^ P.parts.card := calc ↑(G.edgeDensity U V) ^ 2 - ε ^ 5 / 25 + ε ^ 4 / ↑3 ≤ ↑(G.edgeDensity U V) ^ 2 - ε ^ 5 / ↑25 + (star hP G ε hU V).card * (star hP G ε hV U).card / ↑16 ^ P.parts.card * (↑9 / ↑16) * ε ^ 2 := by
apply add_le_add_left have Ul : 4 / 5 * ε ≤ (star hP G ε hU V).card / _ := eps_le_card_star_div hPα hPε hε₁ hU hV hUVne hUV have Vl : 4 / 5 * ε ≤ (star hP G ε hV U).card / _ := eps_le_card_star_div hPα hPε hε₁ hV hU hUVne.symm fun h => hUV h.symm rw [show (16 : ℝ) = ↑4 ^ 2 by norm_num, pow_right_comm, sq ((4 : ℝ) ^ _), ← _root_.div_mul_div_comm, mul_assoc] have : 0 < ε := by sz_positivity have UVl := mul_le_mul Ul Vl (by positivity) ?_ swap · -- This seems faster than `exact div_nonneg (by positivity) (by positivity)` and *much* -- (tens of seconds) faster than `positivity` on its own. apply div_nonneg <;> positivity refine le_trans ?_ (mul_le_mul_of_nonneg_right UVl ?_) · norm_num nlinarith · norm_num positivity _ ≤ (∑ ab ∈ (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts, (G.edgeDensity ab.1 ab.2 : ℝ) ^ 2) / ↑16 ^ P.parts.card := by have t : (star hP G ε hU V).product (star hP G ε hV U) ⊆ (chunk hP G ε hU).parts.product (chunk hP G ε hV).parts := product_subset_product star_subset_chunk star_subset_chunk have hε : 0 ≤ ε := by sz_positivity have sp : ∀ (a b : Finset (Finset α)), a.product b = a ×ˢ b := fun a b => rfl have := add_div_le_sum_sq_div_card t (fun x => (G.edgeDensity x.1 x.2 : ℝ)) ((G.edgeDensity U V : ℝ) ^ 2 - ε ^ 5 / ↑25) (show 0 ≤ 3 / 4 * ε by linarith) ?_ ?_ · simp_rw [sp, card_product, card_chunk (m_pos hPα).ne', ← mul_pow, cast_pow, mul_pow, div_pow, ← mul_assoc] at this norm_num at this exact this · simp_rw [sp, card_product, card_chunk (m_pos hPα).ne', ← mul_pow] norm_num exact edgeDensity_star_not_uniform hPα hPε hε₁ hUVne hUV · rw [sp, card_product] apply (edgeDensity_chunk_aux hPα hPε hU hV).trans · rw [card_chunk (m_pos hPα).ne', card_chunk (m_pos hPα).ne', ← mul_pow] · norm_num rfl
/- Copyright (c) 2022 Wrenna Robson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Wrenna Robson -/ import Mathlib.Topology.MetricSpace.Basic #align_import topology.metric_space.infsep from "leanprover-community/mathlib"@"5316314b553dcf8c6716541851517c1a9715e22b" /-! # Infimum separation This file defines the extended infimum separation of a set. This is approximately dual to the diameter of a set, but where the extended diameter of a set is the supremum of the extended distance between elements of the set, the extended infimum separation is the infimum of the (extended) distance between *distinct* elements in the set. We also define the infimum separation as the cast of the extended infimum separation to the reals. This is the infimum of the distance between distinct elements of the set when in a pseudometric space. All lemmas and definitions are in the `Set` namespace to give access to dot notation. ## Main definitions * `Set.einfsep`: Extended infimum separation of a set. * `Set.infsep`: Infimum separation of a set (when in a pseudometric space). !-/ variable {α β : Type*} namespace Set section Einfsep open ENNReal open Function /-- The "extended infimum separation" of a set with an edist function. -/ noncomputable def einfsep [EDist α] (s : Set α) : ℝ≥0∞ := ⨅ (x ∈ s) (y ∈ s) (_ : x ≠ y), edist x y #align set.einfsep Set.einfsep section EDist variable [EDist α] {x y : α} {s t : Set α} theorem le_einfsep_iff {d} : d ≤ s.einfsep ↔ ∀ x ∈ s, ∀ y ∈ s, x ≠ y → d ≤ edist x y := by simp_rw [einfsep, le_iInf_iff] #align set.le_einfsep_iff Set.le_einfsep_iff theorem einfsep_zero : s.einfsep = 0 ↔ ∀ C > 0, ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ edist x y < C := by simp_rw [einfsep, ← _root_.bot_eq_zero, iInf_eq_bot, iInf_lt_iff, exists_prop] #align set.einfsep_zero Set.einfsep_zero theorem einfsep_pos : 0 < s.einfsep ↔ ∃ C > 0, ∀ x ∈ s, ∀ y ∈ s, x ≠ y → C ≤ edist x y := by rw [pos_iff_ne_zero, Ne, einfsep_zero] simp only [not_forall, not_exists, not_lt, exists_prop, not_and] #align set.einfsep_pos Set.einfsep_pos theorem einfsep_top : s.einfsep = ∞ ↔ ∀ x ∈ s, ∀ y ∈ s, x ≠ y → edist x y = ∞ := by simp_rw [einfsep, iInf_eq_top] #align set.einfsep_top Set.einfsep_top theorem einfsep_lt_top : s.einfsep < ∞ ↔ ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ edist x y < ∞ := by simp_rw [einfsep, iInf_lt_iff, exists_prop] #align set.einfsep_lt_top Set.einfsep_lt_top theorem einfsep_ne_top : s.einfsep ≠ ∞ ↔ ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ edist x y ≠ ∞ := by simp_rw [← lt_top_iff_ne_top, einfsep_lt_top] #align set.einfsep_ne_top Set.einfsep_ne_top theorem einfsep_lt_iff {d} : s.einfsep < d ↔ ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ edist x y < d := by simp_rw [einfsep, iInf_lt_iff, exists_prop] #align set.einfsep_lt_iff Set.einfsep_lt_iff theorem nontrivial_of_einfsep_lt_top (hs : s.einfsep < ∞) : s.Nontrivial := by rcases einfsep_lt_top.1 hs with ⟨_, hx, _, hy, hxy, _⟩ exact ⟨_, hx, _, hy, hxy⟩ #align set.nontrivial_of_einfsep_lt_top Set.nontrivial_of_einfsep_lt_top theorem nontrivial_of_einfsep_ne_top (hs : s.einfsep ≠ ∞) : s.Nontrivial := nontrivial_of_einfsep_lt_top (lt_top_iff_ne_top.mpr hs) #align set.nontrivial_of_einfsep_ne_top Set.nontrivial_of_einfsep_ne_top theorem Subsingleton.einfsep (hs : s.Subsingleton) : s.einfsep = ∞ := by rw [einfsep_top] exact fun _ hx _ hy hxy => (hxy <| hs hx hy).elim #align set.subsingleton.einfsep Set.Subsingleton.einfsep theorem le_einfsep_image_iff {d} {f : β → α} {s : Set β} : d ≤ einfsep (f '' s) ↔ ∀ x ∈ s, ∀ y ∈ s, f x ≠ f y → d ≤ edist (f x) (f y) := by simp_rw [le_einfsep_iff, forall_mem_image] #align set.le_einfsep_image_iff Set.le_einfsep_image_iff theorem le_edist_of_le_einfsep {d x} (hx : x ∈ s) {y} (hy : y ∈ s) (hxy : x ≠ y) (hd : d ≤ s.einfsep) : d ≤ edist x y := le_einfsep_iff.1 hd x hx y hy hxy #align set.le_edist_of_le_einfsep Set.le_edist_of_le_einfsep theorem einfsep_le_edist_of_mem {x} (hx : x ∈ s) {y} (hy : y ∈ s) (hxy : x ≠ y) : s.einfsep ≤ edist x y := le_edist_of_le_einfsep hx hy hxy le_rfl #align set.einfsep_le_edist_of_mem Set.einfsep_le_edist_of_mem theorem einfsep_le_of_mem_of_edist_le {d x} (hx : x ∈ s) {y} (hy : y ∈ s) (hxy : x ≠ y) (hxy' : edist x y ≤ d) : s.einfsep ≤ d := le_trans (einfsep_le_edist_of_mem hx hy hxy) hxy' #align set.einfsep_le_of_mem_of_edist_le Set.einfsep_le_of_mem_of_edist_le theorem le_einfsep {d} (h : ∀ x ∈ s, ∀ y ∈ s, x ≠ y → d ≤ edist x y) : d ≤ s.einfsep := le_einfsep_iff.2 h #align set.le_einfsep Set.le_einfsep @[simp] theorem einfsep_empty : (∅ : Set α).einfsep = ∞ := subsingleton_empty.einfsep #align set.einfsep_empty Set.einfsep_empty @[simp] theorem einfsep_singleton : ({x} : Set α).einfsep = ∞ := subsingleton_singleton.einfsep #align set.einfsep_singleton Set.einfsep_singleton theorem einfsep_iUnion_mem_option {ι : Type*} (o : Option ι) (s : ι → Set α) : (⋃ i ∈ o, s i).einfsep = ⨅ i ∈ o, (s i).einfsep := by cases o <;> simp #align set.einfsep_Union_mem_option Set.einfsep_iUnion_mem_option theorem einfsep_anti (hst : s ⊆ t) : t.einfsep ≤ s.einfsep := le_einfsep fun _x hx _y hy => einfsep_le_edist_of_mem (hst hx) (hst hy) #align set.einfsep_anti Set.einfsep_anti theorem einfsep_insert_le : (insert x s).einfsep ≤ ⨅ (y ∈ s) (_ : x ≠ y), edist x y := by simp_rw [le_iInf_iff] exact fun _ hy hxy => einfsep_le_edist_of_mem (mem_insert _ _) (mem_insert_of_mem _ hy) hxy #align set.einfsep_insert_le Set.einfsep_insert_le theorem le_einfsep_pair : edist x y ⊓ edist y x ≤ ({x, y} : Set α).einfsep := by simp_rw [le_einfsep_iff, inf_le_iff, mem_insert_iff, mem_singleton_iff] rintro a (rfl | rfl) b (rfl | rfl) hab <;> (try simp only [le_refl, true_or, or_true]) <;> contradiction #align set.le_einfsep_pair Set.le_einfsep_pair theorem einfsep_pair_le_left (hxy : x ≠ y) : ({x, y} : Set α).einfsep ≤ edist x y := einfsep_le_edist_of_mem (mem_insert _ _) (mem_insert_of_mem _ (mem_singleton _)) hxy #align set.einfsep_pair_le_left Set.einfsep_pair_le_left theorem einfsep_pair_le_right (hxy : x ≠ y) : ({x, y} : Set α).einfsep ≤ edist y x := by rw [pair_comm]; exact einfsep_pair_le_left hxy.symm #align set.einfsep_pair_le_right Set.einfsep_pair_le_right theorem einfsep_pair_eq_inf (hxy : x ≠ y) : ({x, y} : Set α).einfsep = edist x y ⊓ edist y x := le_antisymm (le_inf (einfsep_pair_le_left hxy) (einfsep_pair_le_right hxy)) le_einfsep_pair #align set.einfsep_pair_eq_inf Set.einfsep_pair_eq_inf theorem einfsep_eq_iInf : s.einfsep = ⨅ d : s.offDiag, (uncurry edist) (d : α × α) := by refine eq_of_forall_le_iff fun _ => ?_ simp_rw [le_einfsep_iff, le_iInf_iff, imp_forall_iff, SetCoe.forall, mem_offDiag, Prod.forall, uncurry_apply_pair, and_imp] #align set.einfsep_eq_infi Set.einfsep_eq_iInf theorem einfsep_of_fintype [DecidableEq α] [Fintype s] : s.einfsep = s.offDiag.toFinset.inf (uncurry edist) := by refine eq_of_forall_le_iff fun _ => ?_ simp_rw [le_einfsep_iff, imp_forall_iff, Finset.le_inf_iff, mem_toFinset, mem_offDiag, Prod.forall, uncurry_apply_pair, and_imp] #align set.einfsep_of_fintype Set.einfsep_of_fintype theorem Finite.einfsep (hs : s.Finite) : s.einfsep = hs.offDiag.toFinset.inf (uncurry edist) := by refine eq_of_forall_le_iff fun _ => ?_ simp_rw [le_einfsep_iff, imp_forall_iff, Finset.le_inf_iff, Finite.mem_toFinset, mem_offDiag, Prod.forall, uncurry_apply_pair, and_imp] #align set.finite.einfsep Set.Finite.einfsep theorem Finset.coe_einfsep [DecidableEq α] {s : Finset α} : (s : Set α).einfsep = s.offDiag.inf (uncurry edist) := by simp_rw [einfsep_of_fintype, ← Finset.coe_offDiag, Finset.toFinset_coe] #align set.finset.coe_einfsep Set.Finset.coe_einfsep theorem Nontrivial.einfsep_exists_of_finite [Finite s] (hs : s.Nontrivial) : ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ s.einfsep = edist x y := by classical cases nonempty_fintype s simp_rw [einfsep_of_fintype] rcases Finset.exists_mem_eq_inf s.offDiag.toFinset (by simpa) (uncurry edist) with ⟨w, hxy, hed⟩ simp_rw [mem_toFinset] at hxy exact ⟨w.fst, hxy.1, w.snd, hxy.2.1, hxy.2.2, hed⟩ #align set.nontrivial.einfsep_exists_of_finite Set.Nontrivial.einfsep_exists_of_finite theorem Finite.einfsep_exists_of_nontrivial (hsf : s.Finite) (hs : s.Nontrivial) : ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ s.einfsep = edist x y := letI := hsf.fintype hs.einfsep_exists_of_finite #align set.finite.einfsep_exists_of_nontrivial Set.Finite.einfsep_exists_of_nontrivial end EDist section PseudoEMetricSpace variable [PseudoEMetricSpace α] {x y z : α} {s t : Set α} theorem einfsep_pair (hxy : x ≠ y) : ({x, y} : Set α).einfsep = edist x y := by nth_rw 1 [← min_self (edist x y)] convert einfsep_pair_eq_inf hxy using 2 rw [edist_comm] #align set.einfsep_pair Set.einfsep_pair theorem einfsep_insert : einfsep (insert x s) = (⨅ (y ∈ s) (_ : x ≠ y), edist x y) ⊓ s.einfsep := by refine le_antisymm (le_min einfsep_insert_le (einfsep_anti (subset_insert _ _))) ?_ simp_rw [le_einfsep_iff, inf_le_iff, mem_insert_iff] rintro y (rfl | hy) z (rfl | hz) hyz · exact False.elim (hyz rfl) · exact Or.inl (iInf_le_of_le _ (iInf₂_le hz hyz)) · rw [edist_comm] exact Or.inl (iInf_le_of_le _ (iInf₂_le hy hyz.symm)) · exact Or.inr (einfsep_le_edist_of_mem hy hz hyz) #align set.einfsep_insert Set.einfsep_insert theorem einfsep_triple (hxy : x ≠ y) (hyz : y ≠ z) (hxz : x ≠ z) : einfsep ({x, y, z} : Set α) = edist x y ⊓ edist x z ⊓ edist y z := by simp_rw [einfsep_insert, iInf_insert, iInf_singleton, einfsep_singleton, inf_top_eq, ciInf_pos hxy, ciInf_pos hyz, ciInf_pos hxz] #align set.einfsep_triple Set.einfsep_triple theorem le_einfsep_pi_of_le {π : β → Type*} [Fintype β] [∀ b, PseudoEMetricSpace (π b)] {s : ∀ b : β, Set (π b)} {c : ℝ≥0∞} (h : ∀ b, c ≤ einfsep (s b)) : c ≤ einfsep (Set.pi univ s) := by refine le_einfsep fun x hx y hy hxy => ?_ rw [mem_univ_pi] at hx hy rcases Function.ne_iff.mp hxy with ⟨i, hi⟩ exact le_trans (le_einfsep_iff.1 (h i) _ (hx _) _ (hy _) hi) (edist_le_pi_edist _ _ i) #align set.le_einfsep_pi_of_le Set.le_einfsep_pi_of_le end PseudoEMetricSpace section PseudoMetricSpace variable [PseudoMetricSpace α] {s : Set α} theorem subsingleton_of_einfsep_eq_top (hs : s.einfsep = ∞) : s.Subsingleton := by rw [einfsep_top] at hs exact fun _ hx _ hy => of_not_not fun hxy => edist_ne_top _ _ (hs _ hx _ hy hxy) #align set.subsingleton_of_einfsep_eq_top Set.subsingleton_of_einfsep_eq_top theorem einfsep_eq_top_iff : s.einfsep = ∞ ↔ s.Subsingleton := ⟨subsingleton_of_einfsep_eq_top, Subsingleton.einfsep⟩ #align set.einfsep_eq_top_iff Set.einfsep_eq_top_iff
Mathlib/Topology/MetricSpace/Infsep.lean
257
260
theorem Nontrivial.einfsep_ne_top (hs : s.Nontrivial) : s.einfsep ≠ ∞ := by
contrapose! hs rw [not_nontrivial_iff] exact subsingleton_of_einfsep_eq_top hs
"/-\nCopyright (c) 2019 Sébastien Gouëzel. All rights reserved.\nReleased under Apache 2.0 license(...TRUNCATED)
Mathlib/Topology/FiberBundle/Basic.lean
318
381
"theorem FiberBundle.exists_trivialization_Icc_subset [ConditionallyCompleteLinearOrder B]\n [Ord(...TRUNCATED)
"\n obtain ⟨ea, hea⟩ : ∃ ea : Trivialization F (π F E), a ∈ ea.baseSet :=\n ⟨triviali(...TRUNCATED)
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
1